Package org.apache.zookeeper.proto

Examples of org.apache.zookeeper.proto.WatcherEvent


            }
            if (replyHdr.getXid() == -1) {
                // -1 means notification
                LOG.debug("Got notification sessionid:0x"
                    + Long.toHexString(sessionId));
                WatcherEvent event = new WatcherEvent();
                event.deserialize(bbia, "response");
                WatchedEvent we = new WatchedEvent(event);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Got " + we + " for sessionid 0x"
                            + Long.toHexString(sessionId));
                }
View Full Code Here


                                     + 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

            }
            if (replyHdr.getXid() == -1) {
                // -1 means notification
                LOG.debug("Got notification sessionid:0x"
                    + Long.toHexString(sessionId));
                WatcherEvent event = new WatcherEvent();
                event.deserialize(bbia, "response");
                WatchedEvent we = new WatchedEvent(event);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Got " + we + " for sessionid 0x"
                            + Long.toHexString(sessionId));
                }
View Full Code Here

                // -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

                                     + 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

                // -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

        // 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

    @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

    }

   @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

                                     + 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

Related Classes of org.apache.zookeeper.proto.WatcherEvent

Copyright © 2018 www.massapicom. 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.