Package org.jgrapes.net
Class SocketConnectionManager
java.lang.Object
org.jgrapes.core.internal.ComponentVertex
org.jgrapes.core.Component
org.jgrapes.net.SocketConnectionManager
- All Implemented Interfaces:
Iterable<ComponentType>
,Channel
,ComponentType
,Eligible
,Manager
- Direct Known Subclasses:
SocketConnector
,SocketServer
Provides a base class for the
SocketServer
and the
SocketConnector
.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jgrapes.core.Channel
Channel.Default
-
Field Summary
-
Constructor Summary
ConstructorDescriptionSocketConnectionManager
(Channel componentChannel) Creates a new server using the given channel. -
Method Summary
Modifier and TypeMethodDescriptionint
Return the configured buffer size.Returns the executor service.void
onOutput
(Output<ByteBuffer> event, SocketConnectionManager.SocketChannelImpl channel) Writes the data passed in the event.protected boolean
Removes the channel from the set of registered channels.setBufferSize
(int bufferSize) Sets the buffer size for the send an receive buffers.setExecutorService
(ExecutorService executorService) Sets an executor service to be used by the event pipelines that process the data from the network.toString()
If a name has been set for this component (seeManager.setName(String)
), return the name, else return the object name provided byComponents.objectName(Object)
, usingComponentVertex.component()
as argument.Methods inherited from class org.jgrapes.core.Component
channel, component, defaultCriterion, isEligibleFor, setName
Methods inherited from class org.jgrapes.core.internal.ComponentVertex
activeEventPipeline, addHandler, attach, channelReplacements, children, componentPath, componentVertex, detach, fire, initComponentsHandlers, iterator, name, newEventPipeline, newEventPipeline, parent, registerAsGenerator, root, unregisterAsGenerator
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
channels
-
-
Constructor Details
-
SocketConnectionManager
Creates a new server using the given channel.- Parameters:
componentChannel
- the component’s channel
-
-
Method Details
-
setBufferSize
Sets the buffer size for the send an receive buffers.If no size is set, a default value of 32768 will be used.
- Parameters:
bufferSize
- the size to use for the send and receive buffers- Returns:
- the socket connection manager for easy chaining
-
bufferSize
Return the configured buffer size.- Returns:
- the bufferSize
-
setExecutorService
Sets an executor service to be used by the event pipelines that process the data from the network.Setting this to an executor service with a limited number of threads allows to control the maximum load from the network.
- Parameters:
executorService
- the executorService to set- Returns:
- the socket connection manager for easy chaining
- See Also:
-
executorService
Returns the executor service.- Returns:
- the executorService
-
onOutput
@Handler public void onOutput(Output<ByteBuffer> event, SocketConnectionManager.SocketChannelImpl channel) throws InterruptedException Writes the data passed in the event.The end of record flag is used to determine if a channel is eligible for purging. If the flag is set and all output has been processed, the channel is purgeable until input is received or another output event causes the state to be reevaluated.
- Parameters:
event
- the eventchannel
- the channel- Throws:
InterruptedException
- the interrupted exception
-
removeChannel
Removes the channel from the set of registered channels.- Parameters:
channel
- the channel- Returns:
- true, if channel was registered
-
toString
Description copied from class:ComponentVertex
If a name has been set for this component (seeManager.setName(String)
), return the name, else return the object name provided byComponents.objectName(Object)
, usingComponentVertex.component()
as argument.- Overrides:
toString
in classComponentVertex
-