Search in sources :

Example 6 with NodePath

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

the class EndpointNodeImpl method setOffline.

public void setOffline() throws ServiceLocatorException, InterruptedException {
    NodePath endpointStatusNodePath = child(LIVE);
    NodePath expNodePath = child(TIMETOLIVE);
    zkBackend.ensurePathDeleted(endpointStatusNodePath, false);
    zkBackend.ensurePathDeleted(expNodePath, false);
}
Also used : NodePath(org.talend.esb.servicelocator.client.internal.NodePath)

Example 7 with NodePath

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

the class EndpointNodeImpl method setLive.

public void setLive(boolean persistent) throws ServiceLocatorException, InterruptedException {
    CreateMode mode = persistent ? CreateMode.PERSISTENT : CreateMode.EPHEMERAL;
    NodePath endpointStatusNodePath = child(LIVE);
    zkBackend.ensurePathExists(endpointStatusNodePath, mode);
    // the old expiration time is not valid after re-registering the endpoint
    zkBackend.ensurePathDeleted(child(TIMETOLIVE), false);
}
Also used : CreateMode(org.apache.zookeeper.CreateMode) NodePath(org.talend.esb.servicelocator.client.internal.NodePath)

Example 8 with NodePath

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

the class EndpointNodeTest method setOffline.

@Test
public void setOffline() throws Exception {
    NodePath livePath = endpointNode.child(LIVE);
    NodePath expiryPath = endpointNode.child(TIMETOLIVE);
    backend.ensurePathDeleted(livePath, false);
    backend.ensurePathDeleted(expiryPath, false);
    replay(backend);
    endpointNode.setOffline();
    verify(backend);
}
Also used : NodePath(org.talend.esb.servicelocator.client.internal.NodePath) Test(org.junit.Test)

Example 9 with NodePath

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

the class EndpointNodeTest method isLiveTrue.

@Test
public void isLiveTrue() throws Exception {
    NodePath livePath = endpointNode.child(LIVE);
    expect(backend.nodeExists(livePath)).andReturn(true);
    replay(backend);
    assertTrue(endpointNode.isLive());
    verify(backend);
}
Also used : NodePath(org.talend.esb.servicelocator.client.internal.NodePath) Test(org.junit.Test)

Example 10 with NodePath

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

the class EndpointNodeTest method setLiveNonPersistent.

@Test
public void setLiveNonPersistent() throws Exception {
    NodePath livePath = endpointNode.child(LIVE);
    backend.ensurePathExists(livePath, CreateMode.EPHEMERAL);
    backend.ensurePathDeleted(endpointNode.child(TIMETOLIVE), false);
    replay(backend);
    endpointNode.setLive(false);
    verify(backend);
}
Also used : NodePath(org.talend.esb.servicelocator.client.internal.NodePath) Test(org.junit.Test)

Aggregations

NodePath (org.talend.esb.servicelocator.client.internal.NodePath)13 Test (org.junit.Test)9 Date (java.util.Date)4 CreateMode (org.apache.zookeeper.CreateMode)2