Package org.apache.curator.framework.recipes.locks

Examples of org.apache.curator.framework.recipes.locks.InterProcessMutex


            else {
                lockEntry = new InterProcessReadWriteLock(zk.getClient(), LOCKS_NODE + "/" + resource);
                zkLocks.put(resource, lockEntry);
            }
        }
        InterProcessMutex writeLock = lockEntry.writeLock();
        return acquireLock(wait, writeLock, resource);
    }
View Full Code Here


        this.client = client;
        this.listener = new WrappedListener(this, listener);
        hasLeadership = false;

        this.executorService = executorService;
        mutex = new InterProcessMutex(client, leaderPath)
        {
            @Override
            protected byte[] getLockNodeBytes()
            {
                return (id.length() > 0) ? getIdBytes(id) : null;
View Full Code Here

    public ExampleClientThatLocks(CuratorFramework client, String lockPath, FakeLimitedResource resource, String clientName)
    {
        this.resource = resource;
        this.clientName = clientName;
        lock = new InterProcessMutex(client, lockPath);
    }
View Full Code Here

    {
        this.client = client;
        this.path = path;
        this.retryPolicy = retryPolicy;
        this.promotedToLock = promotedToLock;
        mutex = (promotedToLock != null) ? new InterProcessMutex(client, promotedToLock.getPath()) : null;
        ensurePath = client.newNamespaceAwareEnsurePath(path).excludingLast();
    }
View Full Code Here

        synchronized void checkMutex() {
            if (client == null) {
                state = LockState.ERROR;
                stateChanged = nowMillis();
            } else if (mutex == null) {
                mutex = new InterProcessMutex(client, getLockId(shard));
            }
        }
View Full Code Here

    {
        this.client = client;
        this.path = path;
        this.retryPolicy = retryPolicy;
        this.promotedToLock = promotedToLock;
        mutex = (promotedToLock != null) ? new InterProcessMutex(client, promotedToLock.getPath()) : null;
        ensurePath = client.newNamespaceAwareEnsurePath(path).excludingLast();
    }
View Full Code Here

        this.client = client;
        this.listener = new WrappedListener(this, listener);
        hasLeadership = false;

        this.executorService = executorService;
        mutex = new InterProcessMutex(client, leaderPath)
        {
            @Override
            protected byte[] getLockNodeBytes()
            {
                return (id.length() > 0) ? getIdBytes(id) : null;
View Full Code Here

    }

    @Override
    public Object lockRoot(int id) {
        try {
            final InterProcessMutex mutex = new InterProcessMutex(client, ROOT_LOCKS + '/' + id);
            mutex.acquire();
            return mutex;
        } catch (Exception ex) {
            throw Throwables.propagate(ex);
        }
    }
View Full Code Here

    }

    @Override
    public void unlockRoot(Object lock) {
        try {
            final InterProcessMutex mutex = (InterProcessMutex) lock;
            mutex.release();
        } catch (Exception ex) {
            throw Throwables.propagate(ex);
        }
    }
View Full Code Here

        synchronized (locks) {
            assertValid();
            if (locks.containsKey(path)) {
                return locks.get(path);
            } else {
                locks.put(path, new InterProcessMutex(curator.get(), path));
                return locks.get(path);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.curator.framework.recipes.locks.InterProcessMutex

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.