Search in sources :

Example 11 with NodePath

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

the class EndpointNodeTest method isLiveFalse.

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

Example 12 with NodePath

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

the class EndpointNodeImpl method getExpiryTime.

@Override
public Date getExpiryTime() throws ServiceLocatorException, InterruptedException {
    NodePath expNodePath = child(TIMETOLIVE);
    if (!zkBackend.nodeExists(expNodePath)) {
        return null;
    }
    byte[] content = zkBackend.getContent(expNodePath);
    String strTime = new String(content, UTF8);
    return new Date(Long.valueOf(strTime));
}
Also used : NodePath(org.talend.esb.servicelocator.client.internal.NodePath) Date(java.util.Date)

Example 13 with NodePath

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

the class EndpointNodeImpl method setExpiryTime.

@Override
public void setExpiryTime(Date expiryTime, boolean persistent) throws ServiceLocatorException, InterruptedException {
    NodePath expNodePath = child(TIMETOLIVE);
    String strTime = Long.toString(expiryTime.getTime());
    byte[] content = strTime.getBytes(UTF8);
    CreateMode mode = persistent ? CreateMode.PERSISTENT : CreateMode.EPHEMERAL;
    zkBackend.ensurePathExists(expNodePath, mode, content);
}
Also used : CreateMode(org.apache.zookeeper.CreateMode) NodePath(org.talend.esb.servicelocator.client.internal.NodePath)

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