Examples of WatcherEvent


Examples of org.apache.zookeeper.proto.WatcherEvent

    Master master = new Master(protocol, false);
    master.start();
    TestUtil.waitUntilBecomeMaster(master);

    final IDeployClient deployClient = new DeployClient(_protocol);
    WatchedEvent event = new WatchedEvent(new WatcherEvent(EventType.None.getIntValue(), KeeperState.Expired
            .getIntValue(), null));
    for (int i = 0; i < 25; i++) {
      final String indexName = "index" + i;
      IIndexDeployFuture deployFuture = deployClient.addIndex(indexName, INDEX_FILE.getAbsolutePath(), 1);
      zkClient.getEventLock().lock();
View Full Code Here

Examples of org.apache.zookeeper.proto.WatcherEvent

    ConnectedComponent component1 = mock(ConnectedComponent.class);
    WaitingAnswer waitingAnswer = new WaitingAnswer();
    doAnswer(waitingAnswer).when(component1).disconnect();
    _protocol = _zk.createInteractionProtocol();
    _protocol.registerComponent(component1);
    WatchedEvent expiredEvent = new WatchedEvent(new WatcherEvent(EventType.None.getIntValue(), KeeperState.Expired
            .getIntValue(), null));
    _protocol.getZkClient().process(
            new WatchedEvent(new WatcherEvent(EventType.None.getIntValue(), KeeperState.SyncConnected.getIntValue(),
                    null)));
    _protocol.getZkClient().process(expiredEvent);
    // verify(component1).disconnect();

    ConnectedComponent component2 = mock(ConnectedComponent.class, "2ndComp");
View Full Code Here

Examples of org.apache.zookeeper.proto.WatcherEvent

                // -1 means notification
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Got notification sessionid:0x"
                        + Long.toHexString(sessionId));
                }
                WatcherEvent event = new WatcherEvent();
                event.deserialize(bbia, "response");

                // convert from a server path to a client path
                if (chrootPath != null) {
                    String serverPath = event.getPath();
                    if(serverPath.compareTo(chrootPath)==0)
                        event.setPath("/");
                    else
                        event.setPath(serverPath.substring(chrootPath.length()));
                }

                WatchedEvent we = new WatchedEvent(event);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Got " + we + " for sessionid 0x"
View Full Code Here

Examples of org.apache.zookeeper.proto.WatcherEvent

                                     + Long.toHexString(this.sessionId)
                                     + " through " + this);
        }

        // Convert WatchedEvent to a type that can be sent over the wire
        WatcherEvent e = event.getWrapper();

        sendResponse(h, e, "notification");
    }
View Full Code Here

Examples of org.apache.zookeeper.proto.WatcherEvent

        // 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());
           }
View Full Code Here

Examples of org.apache.zookeeper.proto.WatcherEvent

    @Test
    public void testCreatingWatchedEventFromInvalidWrapper() {
        // Make sure we can't convert from an invalid wrapper

       try {
           WatcherEvent wep = new WatcherEvent(-2342, -252352, "foo");
           WatchedEvent we = new WatchedEvent(wep);
           fail("Was able to create WatchedEvent from bad wrapper");
       } catch (RuntimeException re) {
           // we're good
       }
View Full Code Here

Examples of org.apache.zookeeper.proto.WatcherEvent

    }

   @Test
   public void testConvertingToEventWrapper() {
       WatchedEvent we = new WatchedEvent(EventType.NodeCreated, KeeperState.Expired, "blah");
       WatcherEvent wew = we.getWrapper();
      
       assertEquals(EventType.NodeCreated.getIntValue(), wew.getType());
       assertEquals(KeeperState.Expired.getIntValue(), wew.getState());
       assertEquals("blah", wew.getPath());
   }
View Full Code Here

Examples of org.apache.zookeeper.proto.WatcherEvent

                // -1 means notification
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Got notification sessionid:0x"
                        + Long.toHexString(sessionId));
                }
                WatcherEvent event = new WatcherEvent();
                event.deserialize(bbia, "response");

                // convert from a server path to a client path
                if (chrootPath != null) {
                    String serverPath = event.getPath();
                    if(serverPath.compareTo(chrootPath)==0)
                        event.setPath("/");
                    else if (serverPath.length() > chrootPath.length())
                        event.setPath(serverPath.substring(chrootPath.length()));
                    else {
                      LOG.warn("Got server path " + event.getPath()
                          + " which is too short for chroot path "
                          + chrootPath);
                    }
                }
View Full Code Here

Examples of org.apache.zookeeper.proto.WatcherEvent

                // -1 means notification
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Got notification sessionid:0x"
                        + Long.toHexString(sessionId));
                }
                WatcherEvent event = new WatcherEvent();
                event.deserialize(bbia, "response");

                // convert from a server path to a client path
                if (chrootPath != null) {
                    String serverPath = event.getPath();
                    if(serverPath.compareTo(chrootPath)==0)
                        event.setPath("/");
                    else if (serverPath.length() > chrootPath.length())
                        event.setPath(serverPath.substring(chrootPath.length()));
                    else {
                      LOG.warn("Got server path " + event.getPath()
                          + " which is too short for chroot path "
                          + chrootPath);
                    }
                }
View Full Code Here

Examples of org.apache.zookeeper.proto.WatcherEvent

                                     + Long.toHexString(this.sessionId)
                                     + " through " + this);
        }

        // Convert WatchedEvent to a type that can be sent over the wire
        WatcherEvent e = event.getWrapper();

        sendResponse(h, e, "notification");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.