Class SchedulingConnector
java.lang.Object
org.eclipse.net4j.util.event.Notifier
org.eclipse.net4j.util.lifecycle.Lifecycle
org.eclipse.net4j.util.lifecycle.ShareableLifecycle
org.eclipse.net4j.util.container.Container<IChannel>
org.eclipse.spi.net4j.ChannelMultiplexer
org.eclipse.spi.net4j.Connector
org.eclipse.spi.net4j.SchedulingConnector
- All Implemented Interfaces:
IBufferProvider, IChannelMultiplexer, IConnector, ILocationAware, ITransportConfigAware, org.eclipse.net4j.util.collection.Closeable, org.eclipse.net4j.util.concurrent.IExecutorServiceProvider, org.eclipse.net4j.util.container.IContainer<IChannel>, 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.properties.IPropertiesContainer, org.eclipse.net4j.util.security.INegotiatorAware, org.eclipse.net4j.util.security.IUserAware, InternalChannelMultiplexer, InternalConnector, InverseCloseable
- Direct Known Subclasses:
MessageConnector
A connector base for transports that send channel buffers over a shared connection. It owns the common channel scheduler and control
channel while leaving transport execution and I/O to subclasses. The lifecycle lock serializes scheduling state with shutdown; scheduler
operations acquire channel queue locks before scheduler state locks, and release scheduler locks before returning to transport hooks.
- Since:
- 4.23
- Author:
- Eike Stepper
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceSchedules channels that have outgoing buffers.Nested classes/interfaces inherited from class org.eclipse.net4j.util.event.Notifier
org.eclipse.net4j.util.event.Notifier.CancelationNested classes/interfaces inherited from interface IBufferProvider
IBufferProvider.Introspection, IBufferProvider.NotificationNested classes/interfaces inherited from interface org.eclipse.net4j.util.container.IContainer
org.eclipse.net4j.util.container.IContainer.Modifiable<E>, org.eclipse.net4j.util.container.IContainer.Persistable<E>, org.eclipse.net4j.util.container.IContainer.Persistence<E>Nested classes/interfaces inherited from interface org.eclipse.net4j.util.lifecycle.ILifecycle
org.eclipse.net4j.util.lifecycle.ILifecycle.DeferrableActivationNested classes/interfaces inherited from interface 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 InternalChannelMultiplexer
InternalChannelMultiplexer.BufferMultiplexer -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final shortThe reserved channel identifier used for shared control messages.static final byteThe opcode used for negotiation messages on the shared control channel.Fields inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle
USE_LABELFields inherited from interface IChannelMultiplexer
DEFAULT_OPEN_CHANNEL_TIMEOUT, NO_CHANNEL_TIMEOUTFields inherited from interface IConnector
NO_TIMEOUTFields inherited from interface InternalChannelMultiplexer
CONTEXT_MULTIPLEXER, RESERVED_CHANNEL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcloseChannel(InternalChannel channel) protected final booleancompleteScheduledChannel(InternalChannel channel, boolean bufferCompleted) Called by a transport sender after a send attempt.protected abstract org.eclipse.net4j.util.security.INegotiationContextprotected voidderegisterChannelFromPeer(InternalChannel channel) protected voidprotected voidfinal IChannelReturns the shared control channel through the public channel interface.protected final InternalChannelReturns the shared control channel for transport implementations that need the internal buffer-dispatch contract.Returns the scheduler used to select channels with pending outgoing buffers.final voidmultiplexChannel(InternalChannel channel) protected voidCalled when the scheduler becomes idle.protected abstract voidCalled when the scheduler transitions from idle to having pending work.protected voidregisterChannelWithPeer(short channelID, long timeout, IProtocol<?> protocol) protected final voidrestoreSendingInterest(boolean additionalWork) Restores transport write readiness according to scheduler work and any transport-specific work that must be serviced on the write path.protected final InternalChannelSelects the current channel for a transport sender.final voidsetScheduler(SchedulingConnector.IScheduler scheduler) Sets the scheduler before activation.protected final voidStops transport write readiness if no channel remains scheduled.Methods inherited from class Connector
close, connect, connect, connectAsync, doBeforeActivate, doBeforeOpenChannel, getBufferCapacity, getLocation, getNegotiationContext, getNegotiationException, getNegotiator, getState, getURL, getUserID, initChannel, isClient, isClosed, isConnected, isConnecting, isDeferredActivation, isDisconnected, isNegotiating, isServer, leaveConnecting, provideBuffer, retainBuffer, setNegotiationException, setNegotiator, setState, setUserID, waitForConnectionMethods inherited from class ChannelMultiplexer
createChannel, createProtocol, createProtocolFactoryKey, getChannel, getChannels, getConfig, getElements, getExecutorService, getOpenChannelTimeout, inverseClose, inverseCloseChannel, inverseOpenChannel, inverseOpenChannel, isEmpty, needsBufferProvider, openChannel, openChannel, openChannel, properties, setConfig, setOpenChannelTimeoutMethods inherited from class org.eclipse.net4j.util.container.Container
fireContainerEvent, fireContainerEvent, fireContainerEvent, fireElementAddedEvent, fireElementRemovedEvent, fireElementsAddedEvent, fireElementsRemovedEvent, fireEvent, newContainerEvent, newContainerEventMethods inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle
activate, checkActive, checkArg, checkArg, checkInactive, checkNull, checkState, checkState, deactivate, deferredActivate, doAfterActivate, doBeforeDeactivate, doCancelActivation, dump, getLifecycleState, isActive, toStringMethods inherited from class org.eclipse.net4j.util.event.Notifier
addListener, addUniqueListener, fireEvent, fireEvent, fireThrowable, firstListenerAdded, getListeners, getNotificationService, hasListener, hasListeners, lastListenerRemoved, listenerAdded, listenerRemoved, removeListenerMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface IChannelMultiplexer
getChannels, getOpenChannelTimeout, openChannel, openChannel, openChannel, setOpenChannelTimeoutMethods inherited from interface org.eclipse.net4j.util.container.IContainer
getElements, isEmptyMethods inherited from interface org.eclipse.net4j.util.event.INotifier
addListener, getListeners, hasListeners, removeListenerMethods inherited from interface InternalChannelMultiplexer
needsBufferProviderMethods inherited from interface org.eclipse.net4j.util.properties.IPropertiesContainer
propertiesMethods inherited from interface ITransportConfigAware
getConfig, setConfig
-
Field Details
-
CONTROL_CHANNEL_ID
public static final short CONTROL_CHANNEL_IDThe reserved channel identifier used for shared control messages.- See Also:
-
CONTROL_OPCODE_NEGOTIATION
public static final byte CONTROL_OPCODE_NEGOTIATIONThe opcode used for negotiation messages on the shared control channel.- See Also:
-
-
Constructor Details
-
SchedulingConnector
public SchedulingConnector()
-
-
Method Details
-
getScheduler
Returns the scheduler used to select channels with pending outgoing buffers.- Returns:
- the current channel scheduler
-
setScheduler
Sets the scheduler before activation.- Parameters:
scheduler- the scheduler to use
-
getControlChannel
Returns the shared control channel through the public channel interface. The channel isnullbefore activation and after deactivation.- Returns:
- the shared control channel
-
multiplexChannel
Description copied from interface:InternalChannelMultiplexerCalled by achanneleach time a newbufferis available for multiplexing. This or another buffer can be dequeued from thesend queueof the channel. -
closeChannel
- Specified by:
closeChannelin interfaceInternalChannelMultiplexer- Overrides:
closeChannelin classChannelMultiplexer- Throws:
ChannelException
-
getInternalControlChannel
Returns the shared control channel for transport implementations that need the internal buffer-dispatch contract.- Returns:
- the shared internal control channel
-
onSendingRequired
protected abstract void onSendingRequired()Called when the scheduler transitions from idle to having pending work. Implementations should arrange a send attempt without blocking the producer that enqueued the buffer. The hook runs outside the scheduling lifecycle lock, so it must only arrange asynchronous work and must not perform transport I/O or block. -
onSendingNoLongerRequired
protected void onSendingNoLongerRequired()Called when the scheduler becomes idle. Implementations should asynchronously stop requesting transport write readiness without performing transport I/O or blocking. -
completeScheduledChannel
Called by a transport sender after a send attempt. An incomplete current buffer keeps that channel selected; a completed buffer allows it to rotate to the tail if more work remains. After a successful completion, this method requests another send attempt when scheduled work remains. The transport hook must enqueue or wake an asynchronous sender rather than sending reentrantly.- Parameters:
channel- the serviced channelbufferCompleted- whether the current buffer completed successfully- Returns:
trueif the sender should continue because scheduled work remains
-
selectScheduledChannel
Selects the current channel for a transport sender.- Returns:
- the current eligible channel or
null
-
restoreSendingInterest
protected final void restoreSendingInterest(boolean additionalWork) Restores transport write readiness according to scheduler work and any transport-specific work that must be serviced on the write path. The check and notification are serialized with channel offers and removals to prevent lost selector wakeups.- Parameters:
additionalWork- whether the transport has work that must be serviced by its write-ready callback
-
stopSendingIfIdle
protected final void stopSendingIfIdle()Stops transport write readiness if no channel remains scheduled. The check is serialized with channel offers and removals. -
registerChannelWithPeer
protected void registerChannelWithPeer(short channelID, long timeout, IProtocol<?> protocol) throws ChannelException - Specified by:
registerChannelWithPeerin classChannelMultiplexer- Throws:
ChannelException
-
deregisterChannelFromPeer
- Overrides:
deregisterChannelFromPeerin classConnector- Throws:
ChannelException
-
doActivate
- Overrides:
doActivatein classConnector- Throws:
Exception
-
doDeactivate
- Overrides:
doDeactivatein classConnector- Throws:
Exception
-
createNegotiationContext
protected abstract org.eclipse.net4j.util.security.INegotiationContext createNegotiationContext()- Specified by:
createNegotiationContextin classConnector
-