Search in sources :

Example 11 with EventType

use of org.apache.zookeeper.Watcher.Event.EventType in project zookeeper by apache.

the class WatcherFuncTest method setUp.

@BeforeEach
@Override
public void setUp() throws Exception {
    super.setUp();
    client_latch = new CountDownLatch(1);
    client_dwatch = new SimpleWatcher(client_latch);
    client = createClient(client_dwatch, client_latch);
    lsnr_latch = new CountDownLatch(1);
    lsnr_dwatch = new SimpleWatcher(lsnr_latch);
    lsnr = createClient(lsnr_dwatch, lsnr_latch);
    expected = new ArrayList<EventType>();
}
Also used : EventType(org.apache.zookeeper.Watcher.Event.EventType) CountDownLatch(java.util.concurrent.CountDownLatch) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 12 with EventType

use of org.apache.zookeeper.Watcher.Event.EventType in project zookeeper by apache.

the class WatchedEventTest method testCreatingWatchedEventFromWrapper.

@Test
public void testCreatingWatchedEventFromWrapper() {
    // Make sure we can handle any type of correct wrapper
    EnumSet<EventType> allTypes = EnumSet.allOf(EventType.class);
    EnumSet<KeeperState> allStates = EnumSet.allOf(KeeperState.class);
    WatchedEvent we;
    WatcherEvent wep;
    for (EventType et : allTypes) {
        for (KeeperState ks : allStates) {
            wep = new WatcherEvent(et.getIntValue(), ks.getIntValue(), "blah");
            we = new WatchedEvent(wep);
            assertEquals(et, we.getType());
            assertEquals(ks, we.getState());
            assertEquals("blah", we.getPath());
        }
    }
}
Also used : WatchedEvent(org.apache.zookeeper.WatchedEvent) EventType(org.apache.zookeeper.Watcher.Event.EventType) KeeperState(org.apache.zookeeper.Watcher.Event.KeeperState) WatcherEvent(org.apache.zookeeper.proto.WatcherEvent) Test(org.junit.jupiter.api.Test)

Example 13 with EventType

use of org.apache.zookeeper.Watcher.Event.EventType in project coprhd-controller by CoprHD.

the class ZkCmdHandler method process.

/**
 * Interface Method, do things after receiving event from Server Watcher
 */
@Override
public void process(WatchedEvent event) {
    KeeperState eventState = event.getState();
    EventType eventType = event.getType();
    log.info("Receive from Watcher, State: {}, Type: {}.", eventState, eventType);
    if (eventState == KeeperState.SyncConnected) {
        connectedSignal.countDown();
        log.info("Connect to {} sucessfully", connectionString);
    }
}
Also used : EventType(org.apache.zookeeper.Watcher.Event.EventType) KeeperState(org.apache.zookeeper.Watcher.Event.KeeperState)

Aggregations

EventType (org.apache.zookeeper.Watcher.Event.EventType)13 KeeperState (org.apache.zookeeper.Watcher.Event.KeeperState)9 Test (org.junit.jupiter.api.Test)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 WatchedEvent (org.apache.zookeeper.WatchedEvent)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 TimeUnit (java.util.concurrent.TimeUnit)1 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)1 Ids (org.apache.zookeeper.ZooDefs.Ids)1 WatcherEvent (org.apache.zookeeper.proto.WatcherEvent)1 ClientBase (org.apache.zookeeper.test.ClientBase)1 Test (org.junit.Test)1 AfterEach (org.junit.jupiter.api.AfterEach)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)1 Timeout (org.junit.jupiter.api.Timeout)1