/** * Creates a new primitive event. * * @param eventType the event type * @param value the event value * @return the primitive event */ public static PrimitiveEvent event(EventType eventType, byte[] value) { return new PrimitiveEvent(EventType.canonical(eventType), value); }
/** * Called when a leadership change event occurs. * * @param oldLeadership the old leadership * @param newLeadership the new leadership */ @Event void onLeadershipChange(Leadership<byte[]> oldLeadership, Leadership<byte[]> newLeadership);
/** * Creates a new primitive event. * * @param eventType the event type * @return the primitive event */ public static PrimitiveEvent event(EventType eventType) { return event(eventType, null); }
/** * Simplifies the given event type. * * @param eventType the event type to simplify * @return the simplified event type */ static EventType canonical(EventType eventType) { return new DefaultEventType(eventType.id()); }
/** * Returns an identical event type in canonical form. * * @return an identical event type in canonical form */ default EventType canonicalize() { return canonical(this); } }
/** * Handles a change event. * * @param key the key that changed * @param oldValue the old value * @param newValue the new value */ @Event("change") void onChange(String key, byte[] oldValue, byte[] newValue);
@Override public void publish(EventType eventType, Object event) { publish(PrimitiveEvent.event(eventType, encode(event))); }
/** * Handles a document tree event. * * @param event the document tree event */ @Event void change(DocumentTreeEvent<byte[]> event);
/** * Notifies the client that the barrier is broken. * * @param id the barrier instance identifier */ @Event void broken(long id);
/** * Called when the client has acquired a lock. * * @param id the lock identifier * @param version the lock version */ @Event("locked") void locked(int id, long version);
/** * Called when a leadership change occurs. * * @param topic the topic for which the leadership change occurred * @param oldLeadership the old leadership * @param newLeadership the new leadership */ @Event void onLeadershipChange(String topic, Leadership<byte[]> oldLeadership, Leadership<byte[]> newLeadership);
/** * Notifies the client of a change event. * * @param newValue the updated value * @param oldValue the previous value */ @Event void change(byte[] newValue, byte[] oldValue);
/** * Called when a map change event occurs. * * @param event the change event */ @Event("change") void change(AtomicMapEvent<K, byte[]> event);
/** * Called when a lock attempt has failed. * * @param id the lock identifier */ @Event("failed") void failed(int id);
/** * Notifies the client that a task is available. */ @Event void taskAvailable();
/** * Releases the client from waiting. * * @param id the barrier instance identifier * @param index the index at which the client entered the barrier */ @Event void release(long id, int index);
/** * Notifies this client to run the barrier action. */ @Event void runAction();
/** * Called when an event is received by the client. * * @param event the collection event */ @Event void onEvent(CollectionEvent<E> event);
@Event("succeeded") void succeeded(long id, long version, int permits);
@Event("failed") void failed(long id);