Class SignalProtocol<INFRA_STRUCTURE>
- Type Parameters:
INFRA_STRUCTURE- the infrastructure structure associated with the protocol
- All Implemented Interfaces:
IBufferHandler,ILocationAware,IProtocol<INFRA_STRUCTURE>,IProtocol2<INFRA_STRUCTURE>,IProtocol3<INFRA_STRUCTURE>,ISignalProtocol<INFRA_STRUCTURE>,ISignalProtocol.WithSignalCounters<INFRA_STRUCTURE>,org.eclipse.net4j.util.collection.Entity.Store.Provider,org.eclipse.net4j.util.concurrent.IExecutorServiceProvider,org.eclipse.net4j.util.container.IManagedContainerProvider,org.eclipse.net4j.util.event.INotifier,org.eclipse.net4j.util.event.INotifier.INotifier2,org.eclipse.net4j.util.lifecycle.IDeactivateable,org.eclipse.net4j.util.lifecycle.ILifecycle,org.eclipse.net4j.util.lifecycle.ILifecycle.DeferrableActivation,org.eclipse.net4j.util.security.IUserAware
- Direct Known Subclasses:
AuthenticatingSignalProtocol,HeartBeatProtocol,HeartBeatProtocol.Server
signal protocol.
On the receiver side(s) of protocol the
createSignalReactor() method has to be overridden to
create appropriate peer instances for incoming signals.
- Author:
- Eike Stepper
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classWrites signal data to the underlying channel.static final classNested classes/interfaces inherited from class org.eclipse.spi.net4j.Protocol
Protocol.InfraStructureChangedEventNested classes/interfaces inherited from class org.eclipse.net4j.util.event.Notifier
org.eclipse.net4j.util.event.Notifier.CancelationNested classes/interfaces inherited from interface org.eclipse.net4j.util.lifecycle.ILifecycle
org.eclipse.net4j.util.lifecycle.ILifecycle.DeferrableActivationNested classes/interfaces inherited from interface org.eclipse.net4j.ILocationAware
ILocationAware.LocationNested classes/interfaces inherited from interface org.eclipse.net4j.util.event.INotifier
org.eclipse.net4j.util.event.INotifier.INotifier2Nested classes/interfaces inherited from interface org.eclipse.net4j.signal.ISignalProtocol
ISignalProtocol.WithSignalCounters<INFRA_STRUCTURE> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final shortstatic final shortstatic final shortstatic final shortstatic final shortstatic final shortFields inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle
USE_LABELFields inherited from interface org.eclipse.net4j.protocol.IProtocol2
UNSPECIFIED_VERSIONFields inherited from interface org.eclipse.net4j.signal.ISignalProtocol
DEFAULT_TIMEOUT, NO_TIMEOUT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddStreamWrapper(org.eclipse.net4j.util.io.IStreamWrapper streamWrapper) voidclose()protected SignalReactorcreateSignalReactor(short signalID) Returns a new signal instance to serve the given signal ID ornullif the signal ID is invalid/unknown for this protocol.protected ExecutorcreateSignalReactorExecutor(SignalReactor signal, Object orderKey) Creates the serial executor for a newly encountered order key.protected voidprotected voidprotected longorg.eclipse.net4j.util.collection.Entity.Storelonglongprotected ExecutorReturns the executor for an incoming signal reactor.protected ExecutorgetSignalReactorExecutor(SignalReactor signal, Object orderKey) Returns the serial executor associated with an order key, creating it on first use.protected ObjectReturns the execution-order key for an incoming signal reactor.org.eclipse.net4j.util.io.IStreamWrapperprotected org.eclipse.net4j.util.io.StringCompressorlongvoidhandleBuffer(IBuffer buffer) Handles a given (incoming) buffer.protected voidprotected booleanReturnstrueby default, override to change this behavior.booleanopen(IConnector connector) protected final SignalReactorprovideSignalReactor(short signalID) voidsetStreamWrapper(org.eclipse.net4j.util.io.IStreamWrapper streamWrapper) voidsetTimeout(long timeout) Equivalent to calling SignalProtocol.setTimeout(timeout, false).booleansetTimeout(long timeout, boolean useOldTimeoutToSendNewOne) Update the timeout used for signal end of stream waiting time.voidsetTrustingPeer(boolean trustingPeer) toString()booleanwaitForSignals(long timeout) Methods inherited from class org.eclipse.spi.net4j.Protocol
doBeforeActivate, getBufferProvider, getChannel, getContainer, getExecutorService, getInfraStructure, getLocation, getType, getUserID, getVersion, isClient, isServer, setChannel, setExecutorService, setInfraStructure, setUserIDMethods inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle
activate, checkActive, checkArg, checkArg, checkInactive, checkNull, checkState, checkState, deactivate, deferredActivate, doActivate, doAfterActivate, dump, getLifecycleState, isActive, isDeferredActivationMethods inherited from class org.eclipse.net4j.util.event.Notifier
addListener, addUniqueListener, fireEvent, fireEvent, fireEvent, fireThrowable, firstListenerAdded, getListeners, getNotificationService, hasListener, hasListeners, lastListenerRemoved, listenerAdded, listenerRemoved, removeListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.net4j.ILocationAware
getLocation, isClient, isServerMethods inherited from interface org.eclipse.net4j.util.event.INotifier
addListener, getListeners, hasListeners, removeListenerMethods inherited from interface org.eclipse.net4j.protocol.IProtocol
getBufferProvider, getChannel, getExecutorService, getInfraStructure, getType, setChannel, setExecutorService, setInfraStructureMethods inherited from interface org.eclipse.net4j.protocol.IProtocol3
doWhenFullyConnectedMethods inherited from interface org.eclipse.net4j.util.security.IUserAware
getUserID
-
Field Details
-
COMPRESSED_STRINGS_ACKNOWLEDGE_TIMEOUT
public static final long COMPRESSED_STRINGS_ACKNOWLEDGE_TIMEOUT- Since:
- 4.7
-
SIGNAL_REMOTE_EXCEPTION
public static final short SIGNAL_REMOTE_EXCEPTION- Since:
- 2.0
- See Also:
-
SIGNAL_MONITOR_CANCELED
public static final short SIGNAL_MONITOR_CANCELED- Since:
- 2.0
- See Also:
-
SIGNAL_MONITOR_PROGRESS
public static final short SIGNAL_MONITOR_PROGRESS- Since:
- 2.0
- See Also:
-
SIGNAL_SET_TIMEOUT
public static final short SIGNAL_SET_TIMEOUT- Since:
- 4.1
- See Also:
-
SIGNAL_ACKNOWLEDGE_COMPRESSED_STRINGS
public static final short SIGNAL_ACKNOWLEDGE_COMPRESSED_STRINGS- Since:
- 4.7
- See Also:
-
SIGNAL_ENTITY
public static final short SIGNAL_ENTITY- Since:
- 4.20
- See Also:
-
-
Constructor Details
-
SignalProtocol
- Since:
- 2.0
-
-
Method Details
-
getTimeout
public long getTimeout()- Specified by:
getTimeoutin interfaceISignalProtocol<INFRA_STRUCTURE>- Since:
- 2.0
-
setTimeout
public void setTimeout(long timeout) Equivalent to calling SignalProtocol.setTimeout(timeout, false).- Specified by:
setTimeoutin interfaceISignalProtocol<INFRA_STRUCTURE>- Since:
- 2.0
-
setTimeout
public boolean setTimeout(long timeout, boolean useOldTimeoutToSendNewOne) Update the timeout used for signal end of stream waiting time.- Parameters:
timeout- the new timeoutuseOldTimeoutToSendNewOne-trueto use the old timeout,falseto use the new specified one to sent to server side the new specified timeout- Returns:
trueif the new specified timeout has correctly been sent NOTE: this second parameter is useful mostly for test to be able to set a to small timeout- Since:
- 4.4
-
isTrustingPeer
public boolean isTrustingPeer()- Since:
- 4.22
-
setTrustingPeer
public void setTrustingPeer(boolean trustingPeer) - Since:
- 4.22
-
getStreamWrapper
public org.eclipse.net4j.util.io.IStreamWrapper getStreamWrapper()- Specified by:
getStreamWrapperin interfaceISignalProtocol<INFRA_STRUCTURE>
-
setStreamWrapper
public void setStreamWrapper(org.eclipse.net4j.util.io.IStreamWrapper streamWrapper) - Specified by:
setStreamWrapperin interfaceISignalProtocol<INFRA_STRUCTURE>
-
addStreamWrapper
public void addStreamWrapper(org.eclipse.net4j.util.io.IStreamWrapper streamWrapper) - Specified by:
addStreamWrapperin interfaceISignalProtocol<INFRA_STRUCTURE>
-
getEntityStore
public org.eclipse.net4j.util.collection.Entity.Store getEntityStore()- Specified by:
getEntityStorein interfaceorg.eclipse.net4j.util.collection.Entity.Store.Provider
-
getSentSignals
public long getSentSignals()- Specified by:
getSentSignalsin interfaceISignalProtocol.WithSignalCounters<INFRA_STRUCTURE>- Since:
- 4.13
-
getReceivedSignals
public long getReceivedSignals()- Specified by:
getReceivedSignalsin interfaceISignalProtocol.WithSignalCounters<INFRA_STRUCTURE>
-
open
- Specified by:
openin interfaceISignalProtocol<INFRA_STRUCTURE>- Since:
- 2.0
-
close
public void close()- Specified by:
closein interfaceISignalProtocol<INFRA_STRUCTURE>- Since:
- 2.0
-
waitForSignals
public boolean waitForSignals(long timeout) -
handleBuffer
Handles a given (incoming) buffer.Creates a signal to act upon the given buffer or uses a previously created signal.
- Specified by:
handleBufferin interfaceIBufferHandler- Parameters:
buffer- The buffer to be handled.
-
toString
- Overrides:
toStringin classorg.eclipse.net4j.util.lifecycle.Lifecycle
-
doBeforeDeactivate
- Overrides:
doBeforeDeactivatein classorg.eclipse.net4j.util.lifecycle.Lifecycle- Throws:
Exception
-
doDeactivate
- Overrides:
doDeactivatein classProtocol<INFRA_STRUCTURE>- Throws:
Exception
-
handleChannelDeactivation
protected void handleChannelDeactivation()- Overrides:
handleChannelDeactivationin classProtocol<INFRA_STRUCTURE>
-
provideSignalReactor
-
createSignalReactor
Returns a new signal instance to serve the given signal ID ornullif the signal ID is invalid/unknown for this protocol. -
isSendingTimeoutChanges
protected boolean isSendingTimeoutChanges()Returnstrueby default, override to change this behavior.- Since:
- 4.1
-
getStringCompressor
protected org.eclipse.net4j.util.io.StringCompressor getStringCompressor()- Since:
- 4.7
-
getDeactivationTimeout
protected long getDeactivationTimeout()- Since:
- 4.22
-
getSignalReactorOrderKey
Returns the execution-order key for an incoming signal reactor.Equal non-null keys, according to
Object.equals(Object)andObject.hashCode(), select one execution lane. Signals in that lane execute sequentially in the order this protocol receives their begin-of-signal buffers. Different keys may execute concurrently, and signals with anullkey use the normal executor and may run concurrently with both ordered lanes and each other. This preserves receiver-side reception order only; it does not establish semantic ordering between signals produced independently by senders.Keys should normally be stable and low-cardinality. A signal class is often a natural key, and different signal classes may deliberately return the same key when they must share a lane. Keys and their executors are retained for this protocol's active lifetime.
For example:
if (signal instanceof MySensibleIndication) { return MySensibleIndication.class; }- Parameters:
signal- the incoming signal reactor- Returns:
- the order key, or
nullfor normal unordered execution - Since:
- 4.23
-
getSignalReactorExecutor
Returns the executor for an incoming signal reactor. The default preserves the direct executor fast path for unordered signals and uses a protocol-owned serial executor for a non-null order key.- Parameters:
signal- the incoming signal reactor- Returns:
- the executor that will run the signal
- Since:
- 4.23
-
getSignalReactorExecutor
Returns the serial executor associated with an order key, creating it on first use. Keys are compared using normalequals()andhashCode()semantics. The executor is retained for the active lifetime of this protocol and deactivated with it.- Parameters:
signal- the first signal reactor that caused this lane to be created, or a later signal assigned to the laneorderKey- the non-null key identifying the lane- Returns:
- the executor for the lane
- Since:
- 4.23
-
createSignalReactorExecutor
Creates the serial executor for a newly encountered order key. Thesignalargument is the first reactor that caused this lane to be created; it does not imply that the lane is dedicated to that reactor's class.- Parameters:
signal- the first signal reactor assigned to the laneorderKey- the non-null key identifying the lane- Returns:
- a serial executor for the lane
- Since:
- 4.23
-