Search in sources :

Example 1 with PostConnectAction

use of org.talend.esb.servicelocator.client.ServiceLocator.PostConnectAction in project tesb-rt-se by Talend.

the class ZKBackend method connect.

@Override
public RootNode connect() throws InterruptedException, ServiceLocatorException {
    if (!isConnected()) {
        disconnect();
        if (LOG.isLoggable(Level.FINE)) {
            LOG.log(Level.FINE, "Start connect session");
        }
        CountDownLatch connectionLatch = new CountDownLatch(1);
        zk = createZooKeeper(connectionLatch);
        if (authentication) {
            authenticate();
        }
        boolean connected = connectionLatch.await(settings.getConnectionTimeout(), TimeUnit.MILLISECONDS);
        if (!connected) {
            throw new ServiceLocatorException("Connection to Service Locator failed.");
        }
        for (PostConnectAction postConnectAction : postConnectActions) {
            postConnectAction.process(null);
        }
        if (LOG.isLoggable(Level.FINER)) {
            LOG.log(Level.FINER, "End connect session");
        }
    }
    return rootNode;
}
Also used : PostConnectAction(org.talend.esb.servicelocator.client.ServiceLocator.PostConnectAction) ServiceLocatorException(org.talend.esb.servicelocator.client.ServiceLocatorException) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

CountDownLatch (java.util.concurrent.CountDownLatch)1 PostConnectAction (org.talend.esb.servicelocator.client.ServiceLocator.PostConnectAction)1 ServiceLocatorException (org.talend.esb.servicelocator.client.ServiceLocatorException)1