Search in sources :

Example 6 with ZkInterruptedException

use of org.I0Itec.zkclient.exception.ZkInterruptedException in project otter by alibaba.

the class ZkClientx method reconnect.

private void reconnect() {
    getEventLock().lock();
    try {
        _connection.close();
        _connection.connect(this);
    } catch (InterruptedException e) {
        throw new ZkInterruptedException(e);
    } finally {
        getEventLock().unlock();
    }
}
Also used : ZkInterruptedException(org.I0Itec.zkclient.exception.ZkInterruptedException) ZkInterruptedException(org.I0Itec.zkclient.exception.ZkInterruptedException)

Example 7 with ZkInterruptedException

use of org.I0Itec.zkclient.exception.ZkInterruptedException in project otter by alibaba.

the class ZkClientx method waitUntilExists.

public boolean waitUntilExists(String path, TimeUnit timeUnit, long time) throws ZkInterruptedException {
    Date timeout = new Date(System.currentTimeMillis() + timeUnit.toMillis(time));
    LOG.debug("Waiting until znode '" + path + "' becomes available.");
    if (exists(path)) {
        return true;
    }
    acquireEventLock();
    try {
        while (!exists(path, true)) {
            boolean gotSignal = getEventLock().getZNodeEventCondition().awaitUntil(timeout);
            if (!gotSignal) {
                return false;
            }
        }
        return true;
    } catch (InterruptedException e) {
        throw new ZkInterruptedException(e);
    } finally {
        getEventLock().unlock();
    }
}
Also used : ZkInterruptedException(org.I0Itec.zkclient.exception.ZkInterruptedException) ZkInterruptedException(org.I0Itec.zkclient.exception.ZkInterruptedException) Date(java.util.Date)

Aggregations

ZkInterruptedException (org.I0Itec.zkclient.exception.ZkInterruptedException)7 ZkException (org.I0Itec.zkclient.exception.ZkException)3 ZkNoNodeException (org.I0Itec.zkclient.exception.ZkNoNodeException)3 Date (java.util.Date)2 ArbitrateException (com.alibaba.otter.shared.arbitrate.exception.ArbitrateException)1 MainStemEventData (com.alibaba.otter.shared.arbitrate.model.MainStemEventData)1 ProcessNodeEventData (com.alibaba.otter.shared.arbitrate.model.ProcessNodeEventData)1 ZkNodeExistsException (org.I0Itec.zkclient.exception.ZkNodeExistsException)1