use of org.apache.zookeeper.Watcher.Event.EventType in project camel by apache.
the class FutureEventDrivenOperation method process.
public void process(WatchedEvent event) {
this.event = event;
EventType received = event.getType();
if (LOG.isDebugEnabled()) {
LOG.debug(format("Recieved event of type %s for node '%s'", received, event.getPath()));
}
for (EventType watched : awaitedTypes) {
if (watched.equals(received)) {
result = getResult();
waitForAnyWatchedType.countDown();
}
}
if (LOG.isTraceEnabled() && waitForAnyWatchedType.getCount() > 0) {
StringBuilder b = new StringBuilder();
for (EventType type : awaitedTypes) {
b.append(type).append(", ");
}
if (b.length() > 0) {
b.setLength(b.length() - 2);
}
LOG.trace(String.format("Recieved event of type %s did not match any watched types %s", received, awaitedTypes));
}
}
use of org.apache.zookeeper.Watcher.Event.EventType in project camel by apache.
the class ConsumeDataTest method shouldAwaitCreationAndGetDataNotification.
@Test
public void shouldAwaitCreationAndGetDataNotification() throws Exception {
EventType[] expectedEventTypes = new EventType[] { EventType.NodeCreated, EventType.NodeDataChanged, EventType.NodeDataChanged, EventType.NodeDataChanged, EventType.NodeDataChanged, EventType.NodeDataChanged, EventType.NodeDataChanged, EventType.NodeDataChanged, EventType.NodeDataChanged, EventType.NodeDataChanged, EventType.NodeDeleted };
MockEndpoint mock = getMockEndpoint("mock:zookeeper-data");
mock.expectedMessageCount(expectedEventTypes.length);
createCamelNode();
updateNode(10);
delay(500);
client.delete("/camel");
MockEndpoint.assertIsSatisfied(30, TimeUnit.SECONDS);
int lastVersion = -1;
for (int i = 0; i < mock.getExchanges().size(); i++) {
assertEquals(expectedEventTypes[i], mock.getExchanges().get(i).getIn().getHeader(ZooKeeperMessage.ZOOKEEPER_EVENT_TYPE));
if (!EventType.NodeDeleted.equals(expectedEventTypes[i])) {
// As a delete event does not carry statistics, ignore it in the version check.
int version = ZooKeeperMessage.getStatistics(mock.getExchanges().get(i).getIn()).getVersion();
assertTrue("Version did not increase", lastVersion < version);
lastVersion = version;
}
}
}
use of org.apache.zookeeper.Watcher.Event.EventType in project pinpoint by naver.
the class ZookeeperUtils method isDisconnectedEvent.
public static boolean isDisconnectedEvent(WatchedEvent event) {
KeeperState state = event.getState();
EventType eventType = event.getType();
return isDisconnectedEvent(state, eventType);
}
use of org.apache.zookeeper.Watcher.Event.EventType in project pinpoint by naver.
the class ZookeeperUtils method isConnectedEvent.
public static boolean isConnectedEvent(WatchedEvent event) {
KeeperState state = event.getState();
EventType eventType = event.getType();
return isConnectedEvent(state, eventType);
}
use of org.apache.zookeeper.Watcher.Event.EventType in project pinpoint by naver.
the class FlinkServerRegister method process.
@SuppressWarnings("deprecation")
@Override
public void process(WatchedEvent event) {
logger.info("Handle Zookeeper Event({}) started.", event);
KeeperState state = event.getState();
EventType eventType = event.getType();
if (state == KeeperState.SyncConnected || state == KeeperState.NoSyncConnected) {
// reconnects automatically, and process gets notified for all events
if (eventType == EventType.NodeChildrenChanged) {
logger.info("zookeeper Event occurs : NodeChildrenChanged event");
} else if (eventType == EventType.NodeDeleted) {
logger.info("zookeeper Event occurs : NodeDeleted");
} else if (eventType == EventType.NodeDataChanged) {
logger.info("zookeeper Event occurs : NodeDataChanged");
}
}
logger.info("Handle Zookeeper Event({}) completed.", event);
}
Aggregations