@Override public void process(WatchedEvent event) { ReplyHeader h = new ReplyHeader(-1, -1L, 0); if (LOG.isTraceEnabled()) { ZooTrace.logTraceMessage(LOG, ZooTrace.EVENT_DELIVERY_TRACE_MASK, "Deliver event " + event + " to 0x" + Long.toHexString(this.sessionId) + " through " + this); } // Convert WatchedEvent to a type that can be sent over the wire WatcherEvent e = event.getWrapper(); try { sendResponse(h, e, "notification"); } catch (IOException e1) { if (LOG.isDebugEnabled()) { LOG.debug("Problem sending to " + getRemoteSocketAddress(), e1); } close(); } }
@Override synchronized public void process(WatchedEvent event) { ReplyHeader h = new ReplyHeader(-1, -1L, 0); if (LOG.isTraceEnabled()) { ZooTrace.logTraceMessage(LOG, ZooTrace.EVENT_DELIVERY_TRACE_MASK, "Deliver event " + event + " to 0x" + 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"); }
@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); Assert.fail("Was able to create WatchedEvent from bad wrapper"); } catch (RuntimeException re) { // we're good } }
@Test public void testConvertingToEventWrapper() { WatchedEvent we = new WatchedEvent(EventType.NodeCreated, KeeperState.Expired, "blah"); WatcherEvent wew = we.getWrapper(); Assert.assertEquals(EventType.NodeCreated.getIntValue(), wew.getType()); Assert.assertEquals(KeeperState.Expired.getIntValue(), wew.getState()); Assert.assertEquals("blah", wew.getPath()); }
@Override public void process(WatchedEvent event) { ReplyHeader h = new ReplyHeader(-1, -1L, 0); if (LOG.isTraceEnabled()) { ZooTrace.logTraceMessage(LOG, ZooTrace.EVENT_DELIVERY_TRACE_MASK, "Deliver event " + event + " to 0x" + 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"); }
@Test public void testCreatingWatchedEventFromInvalidWrapper() { // Make sure we can't convert from an invalid wrapper try { WatcherEvent wep = new WatcherEvent(-2342, -252352, "foo"); new WatchedEvent(wep); Assert.fail("Was able to create WatchedEvent from bad wrapper"); } catch (RuntimeException re) { // we're good } }