Class AsyncNodeContext
java.lang.Object
org.jppf.nio.AbstractNioContext
org.jppf.server.nio.nodeserver.BaseNodeContext
org.jppf.server.nio.nodeserver.async.AsyncNodeContext
- All Implemented Interfaces:
AutoCloseable,org.jppf.execute.ExecutorChannel<ServerTaskBundleNode>,org.jppf.nio.CloseableContext,org.jppf.nio.NioChannelHandler,org.jppf.nio.NioContext
Context or state information associated with a channel that exchanges heartbeat messages between the server and a node or client.
- Author:
- Laurent Cohen
-
Field Summary
Fields inherited from class org.jppf.server.nio.nodeserver.BaseNodeContext
driver, serverFields inherited from class org.jppf.nio.AbstractNioContext
closed, connectionUuid, enabled, inSnapshot, local, onCloseAction, outSnapshot, peer, readByteCount, readMessage, socketChannel, ssl, sslHandler, uuid, writeByteCount, writeMessage -
Constructor Summary
ConstructorsConstructorDescriptionAsyncNodeContext(AsyncNodeNioServer server, SocketChannel socketChannel, boolean local) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddJobEntry(ServerTaskBundleNode bundle) Add a new job to the job map.voidclose()Deserialize a task bundle from the message read into this buffer.intgetJobEntry(String uuid, long bundleId) Retrieve the job entry with the specified id.org.jppf.utils.concurrent.ThreadSynchronizationorg.jppf.utils.concurrent.ThreadSynchronizationintintgetNbBundlesForJob(String jobUuid) Get the number of dispatches to the node for the specified job.voidhandleException(Exception exception) booleanCreate a new message.protected AbstractTaskBundleMessagebooleanremoveJobEntry(String uuid, long bundleId) Remove the job entry with the specified id.serializeBundle(ServerTaskBundleNode bundle) Serialize specified bundle into a message to send.voidsetAcceptingNewJobs(boolean acceptingNewJobs) voidsetMaxJobs(int maxJobs) Set the maximum number of concurrent jobs for this channel.Future<?>submit(ServerTaskBundleNode nodeBundle) Take a message from the pending queue, waiting if necessary.toString()booleanMethods inherited from class org.jppf.server.nio.nodeserver.BaseNodeContext
addExecutionStatusListener, cancelJob, checkBundler, fireExecutionStatusChanged, getBundler, getBundlerAlgorithm, getDriver, getExecutionStatus, getIdle, getJmxConnection, getManagementInfo, getNodeIdentifier, getPeerJmxConnection, getReservationScore, getReservationTansition, getSystemInformation, initializeJmxConnection, isActive, isOffline, removeExecutionStatusListener, setActive, setBundler, setBundlerAlgorithm, setExecutionStatus, setJmxConnection, setManagementInfo, setNodeIdentifier, setNodeInfo, setOffline, setPeerJmxConnection, setReservationScore, setReservationTansitionMethods inherited from class org.jppf.nio.AbstractNioContext
getConnectionUuid, getInterestOps, getReadMessage, getSelectionKey, getSocketChannel, getSSLHandler, getUuid, getWriteMessage, isClosed, isEnabled, isLocal, isPeer, isSecure, isSsl, onClose, setClosed, setConnectionUuid, setEnabled, setInterestOps, setLocal, setOnCloseAction, setPeer, setReadMessage, setSelectionKey, setSsl, setSSLHandler, setUuid, setWriteMessageMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jppf.execute.ExecutorChannel
getConnectionUuid, getUuid, isAsynchronous, isLocal
-
Constructor Details
-
AsyncNodeContext
- Parameters:
server- the server that handles this context.socketChannel- the associated socket channel.local- whether this channel context is local.
-
-
Method Details
-
handleException
-
serializeBundle
Serialize specified bundle into a message to send.- Parameters:
bundle- the byndle to process.- Returns:
- the created message.
- Throws:
Exception- if any error occurs.
-
deserializeBundle
Deserialize a task bundle from the message read into this buffer.- Parameters:
message- the message to process.- Returns:
- a pairing of the received result head and the serialized tasks.
- Throws:
Exception- if an error occurs during the deserialization.
-
newMessage
Create a new message.- Returns:
- an
AbstractTaskBundleMessageinstance.
-
readMessage
- Throws:
Exception
-
writeMessage
- Throws:
Exception
-
addJobEntry
Add a new job to the job map.- Parameters:
bundle- the job to add.
-
getJobEntry
Retrieve the job entry with the specified id.- Parameters:
uuid- the job uuid.bundleId- the id of the bundle to remove.- Returns:
- a
ServerTaskBundleNodeinstance, ornullif there is no entry with the specified id.
-
removeJobEntry
Remove the job entry with the specified id.- Parameters:
uuid- the job uuid.bundleId- the id of the bundle to remove.- Returns:
- the removed
ServerTaskBundleNodeinstance, ornullif there is no entry with the specified id.
-
nextMessageToSend
- Overrides:
nextMessageToSendin classorg.jppf.nio.AbstractNioContext
-
takeNextMessageToSend
Take a message from the pending queue, waiting if necessary.- Returns:
- a
AbstractTaskBundleMessageinstance. - Throws:
InterruptedException- if the thread is interrupted.
-
toString
- Overrides:
toStringin classorg.jppf.nio.AbstractNioContext
-
close
public void close() -
getMonitor
-
getCurrentNbJobs
public int getCurrentNbJobs() -
submit
- Throws:
Exception
-
getServer
- Returns:
- the server handling this channel context.
-
getLocalNodeReadLock
public org.jppf.utils.concurrent.ThreadSynchronization getLocalNodeReadLock()- Returns:
- a lock used to synchronize input I/O with a local node.
-
getLocalNodeWriteLock
public org.jppf.utils.concurrent.ThreadSynchronization getLocalNodeWriteLock()- Returns:
- a lock used to synchronize output I/O with a local node.
-
getMaxJobs
public int getMaxJobs() -
setMaxJobs
public void setMaxJobs(int maxJobs) Set the maximum number of concurrent jobs for this channel.- Parameters:
maxJobs- the max number of jobs to set.
-
getNbBundlesForJob
Get the number of dispatches to the node for the specified job.- Parameters:
jobUuid- the uuid of the job to check.- Returns:
- the number of dispatches of the job.
-
isAcceptingNewJobs
public boolean isAcceptingNewJobs()- Returns:
- whether the job is accepting new jobs.
-
setAcceptingNewJobs
public void setAcceptingNewJobs(boolean acceptingNewJobs) - Parameters:
acceptingNewJobs- whether the job is accepting new jobs.
-