/** * Adds local user event listener. * * @param lsnr User listener to add. * @param types Event types to subscribe listener for. */ public void addLocalEventListener(GridPredicate<? extends GridEvent> lsnr, int[] types) { addLocalEventListener(new UserListenerWrapper(lsnr), types); }
/** * Checks if the event type is user-recordable. * * @param type Event type to check. * @return {@code true} if passed event should be recorded, {@code false} - otherwise. */ public boolean isUserRecordable(int type) { assert type > 0 : "Invalid event type: " + type; return type < len ? userRecordableEvts[type] : isUserRecordable0(type); }
/** * Checks if the event type is user-recordable against grid configuration. * * @param type Event type to check. * @return {@code true} if passed event should be recorded, {@code false} - otherwise. */ private boolean isUserRecordable0(int type) { return binarySearch(inclEvtTypes, type); }
/** {@inheritDoc} */ @Override public void onEvent(GridEvent evt) { if (!lsnr.apply(evt)) removeLocalEventListener(this); }
/** * Removes user listener for specified events, if any. If no event types provided - it * removes the listener for all its registered events. * * @param lsnr User listener predicate. * @param types Event types. * @return Returns {@code true} if removed. */ public boolean removeLocalEventListener(GridPredicate<? extends GridEvent> lsnr, @Nullable int... types) { return removeLocalEventListener(new UserListenerWrapper(lsnr), types); }
/** * Adds local event listener. * * @param lsnr Listener. * @param evts Types of events. */ public void addListener(GridLocalEventListener lsnr, int... evts) { cctx.gridEvents().addLocalEventListener(lsnr, evts); }
/** {@inheritDoc} */ @SuppressWarnings({"CloneDoesntCallSuperClone", "CloneCallsConstructors"}) @Override public GridTcpCommunicationMessageAdapter clone() { GridEventStorageMessage _clone = new GridEventStorageMessage(); clone0(_clone); return _clone; }
@Override public boolean isEventRecordable(int... types) { for (int t : types) if (!ctx.event().isRecordable(t)) return false; return true; }
/** * @param p Grid event predicate. * @return Collection of grid events. */ public <T extends GridEvent> Collection<T> localEvents(GridPredicate<T> p) { assert p != null; return getSpi().localEvents(p); }
/** {@inheritDoc} */ @Override public int[] enabledEvents() { return ctx.event().enabledEvents(); }
/** {@inheritDoc} */ @Override public void unregister(UUID routineId, GridKernalContext ctx) { assert routineId != null; assert ctx != null; if (lsnr != null) ctx.event().removeLocalEventListener(lsnr, types); }
/** {@inheritDoc} */ @Override public void onKernalStart() throws GridException { ctx.event().addLocalEventListener(lsnr, EVT_NODE_FAILED, EVT_NODE_LEFT, EVT_NODE_JOINED); }
/** * Checks whether this event type should be recorded. Note that internal event types are * always recordable for notification purposes but may not be sent down to SPI level for * storage and subsequent querying. * * @param type Event type to check. * @return Whether or not this event type should be recorded. */ public boolean isRecordable(int type) { assert type > 0 : "Invalid event type: " + type; return type < len ? recordableEvts[type] : isUserRecordable0(type); }
/** * Removes local event listener. * * @param lsnr Local event listener. */ public void removeListener(GridLocalEventListener lsnr) { cctx.gridEvents().removeLocalEventListener(lsnr); }
/** {@inheritDoc} */ @Override public void onKernalStart0() throws GridException { cctx.gridEvents().addLocalEventListener(discoLsnr, EVT_NODE_FAILED, EVT_NODE_LEFT); }
/** {@inheritDoc} */ @Override protected void stop0(boolean cancel) { cctx.gridEvents().removeLocalEventListener(discoLsnr, EVT_NODE_METRICS_UPDATED); }
/** {@inheritDoc} */ @Override public void onKernalStop0(boolean cancel) { cctx.gridEvents().removeLocalEventListener(discoLsnr); }
/** {@inheritDoc} */ @Override public void onKernalStop(boolean cancel) { if (ctx != null && ctx.event() != null) ctx.event().removeLocalEventListener(lsnr); }
/** {@inheritDoc} */ @Override public void onKernalStop() { if (discoLsnr != null) { ctx.event().removeLocalEventListener(discoLsnr); if (log.isDebugEnabled()) log.debug("Unregistered deployment discovery listener: " + discoLsnr); } }