Example usage for java.util.concurrent.locks Lock unlock

List of usage examples for java.util.concurrent.locks Lock unlock

Introduction

In this page you can find the example usage for java.util.concurrent.locks Lock unlock.

Prototype

void unlock();

Source Link

Document

Releases the lock.

Usage

From source file:com.reactive.hzdfs.dll.AbstractFileSharingService.java

/**
 * Distributed unlock//from   ww  w.  j  a  v a 2s.c o  m
 */
private void unlock() {
    Lock lock = hzService.getClusterLock("FileSharingAgent");
    lock.unlock();
}

From source file:com.alibaba.shared.django.DjangoClient.java

public String accessToken() {
    Lock rl = lock.readLock();
    rl.lock(); // Waiting for refresh!
    try {/*from w ww .ja  v a2 s  .com*/
        if (accessToken != null) {
            return accessToken;
        }
    } finally {
        rl.unlock();
    }
    if (accessToken == null) {
        try {
            refreshToken();
        } catch (URISyntaxException e) {
            LOGGER.error("refreshTokenError", e);
        } catch (IOException e) {
            LOGGER.error("refreshTokenError", e);
        }
    }
    return accessToken;
}

From source file:org.codehaus.wadi.location.partitionmanager.local.LocalPartitionMoveIMToPMAction.java

protected void relocateSession(Envelope message, Location location, MoveIMToPM request, String imCorrelationId)
        throws MessageExchangeException {
    Object key = location.getKey();
    // session does exist - we need to ask SM to move it to IM
    Lock lock = location.getExclusiveLock();
    try {//from  w  w  w . j  a v  a 2  s. co  m
        // ensures that no-one else tries to relocate session whilst we are doing so...
        // wait til we have a lock on Location before retrieving the SM
        lock.lockInterruptibly();
        try {
            doRelocateSession(message, location, request, imCorrelationId);
        } finally {
            lock.unlock();
        }
    } catch (InterruptedException e) {
        log.error("unexpected interruption waiting to perform Session relocation: " + key, e);
        Thread.currentThread().interrupt();
    }
}

From source file:com.netxforge.oss2.config.DatabaseSchemaConfigFactory.java

/**
 * Return a count of the number of tables defined.
 *
 * @return the number of tables in the schema
 *///from   w  w  w.  j av  a 2 s  .  c  o m
public int getTableCount() {
    final Lock lock = getReadLock();
    lock.lock();
    try {
        return getDatabaseSchema().getTableCount();
    } finally {
        lock.unlock();
    }
}

From source file:com.iternox.piggate.samples.PiggateLogin.Activity_Logged.java

public void addOffers(JSONArray bar) {

    Lock l = rwLock2.writeLock();
    l.lock();/*from ww w  . j a  va2s . co  m*/
    try {
        registryOffers(bar);
    } catch (Exception ex) {
    } finally {
        l.unlock();
    }
}

From source file:com.callidusrobotics.droptables.configuration.MongoFactory.java

/**
 * Generates a connection pool using the read-only credentials. <br>
 * If the read-only credentials are not provided, or if the read-only
 * credentials are the same as the read-write credentials, it returns the
 * read-write connection pool instead.//from ww  w.j  av a 2 s  .  c o m
 *
 * @param env
 *          The application's environment
 * @return The connection pool, never null
 * @throws UnknownHostException
 * @see #setRoUser(LoginInfo)
 */
public MongoClient buildReadOnlyClient(Environment env) throws UnknownHostException {
    if (roClient != null) {
        return roClient;
    }

    if (roUser == null || rwUser.equals(roUser)) {
        roClient = buildReadWriteClient(env);
    }

    Lock lock = locks[LockFlags.MONGO_CLIENT.ordinal()];
    lock.lock();

    try {
        if (roClient == null && roUser != null) {
            roClient = buildClient(env, roUser.getUsername(), roUser.getPassword());
        }
    } finally {
        lock.unlock();
    }

    return roClient;
}

From source file:com.iternox.piggate.samples.PiggateLogin.Activity_Logged.java

public void addPendingBeacons(ArrayList<PiggateBeacon> bar) {
    Lock l = rwLock.writeLock();
    l.lock();/* www  .j a  v  a 2  s.  c o m*/
    try {
        this.pending.addAll(bar);
    } catch (Exception ex) {
    } finally {
        l.unlock();
    }
}

From source file:org.mule.util.queue.DualRandomAccessFileQueueStoreDelegate.java

private void delete() {
    Lock lock = filesLock.writeLock();
    lock.lock();/*from   w  ww  .j  a v  a2  s  .c o  m*/
    try {
        randomAccessFileQueueStore1.delete();
        randomAccessFileQueueStore2.delete();
        queueControlDataFile.delete();
    } finally {
        lock.unlock();
    }
}

From source file:com.aretha.content.image.AsyncImageLoader.java

/**
 * Cancel a image load request before is was been execute. if you want to
 * cancel it in progress, please see {@link OnImageLoadListener}
 * // w  w  w . j  a  v  a  2s .  com
 * @param uri
 */
public void cancel(Uri uri) {
    Lock lock = mMainLock.writeLock();
    ImageLoadingTask task = obtainImageLoadingTask(uri, 0, 0, null, false);
    lock.lock();
    mTaskList.remove(task);
    lock.unlock();
}

From source file:SoftReferenceCache.java

/**
 * @see java.util.Map#putAll(java.util.Map)
 *//*from w w w  .j  a  v  a2s .  co  m*/
public void putAll(Map<? extends K, ? extends V> m) {
    Lock lock = theLock.writeLock();
    lock.lock();
    try {
        removeQueued();
        for (java.util.Map.Entry<? extends K, ? extends V> entry : m.entrySet()) {
            theCache.put(entry.getKey(),
                    new KeyedSoftReference<V>(entry.getKey(), entry.getValue(), theRefQueue));
        }
    } finally {
        lock.unlock();
    }
}