Package com.levigo.jadice.server.nodes
Class StreamInputNode
- java.lang.Object
-
- com.levigo.jadice.server.internal.NodeInternal
-
- com.levigo.jadice.server.Node
-
- com.levigo.jadice.server.nodes.StreamInputNode
-
public class StreamInputNode extends Node
ANode
that takesInputStream
s from the client side and makes them available on the server. The underlying transport mechanism is made transparent due to this class.The sequence of this node has four phases:
- Initiating a new StreamInputNode and configuring the enclosing job
- Submitting the job
- Transferring
Stream
s to the server via - Finally, the method
complete()
must be called to indicate that no moreStream
s will follow
As this node is a data source it must not have a predecessor.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.levigo.jadice.server.Node
Node.Cardinality
-
-
Constructor Summary
Constructors Constructor Description StreamInputNode()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addStream(Stream stream)
Transmit aStream
to the server.void
addStream(InputStream is)
Transmit anInputStream
(but no meta data about it) to the server.void
addStream(InputStream is, StreamDescriptor sd)
Transmit anInputStream
and meta data about it to the server.void
complete()
After allStream
s were initiated to be sent to the server, this method must be called.OutputStream
createOutputStream()
Creates anOutputStream
.OutputStream
createOutputStream(StreamDescriptor sd)
Creates anOutputStream
.Node.Cardinality
getInputCardinality()
Return the input cardinality of this node, i.e.StreamBundle
getStreamBundle()
Get theStream
s that the client has sent.String
getWorkerClassName()
Return the node's associatedcom.levigo.jadice.server.core.NodeWorker
full qualified class's name.protected void
initialize(CommunicationSide side)
-
Methods inherited from class com.levigo.jadice.server.Node
addTransportReceiver, appendSuccessor, apply, equals, getJob, getOutputCardinality, getPredecessors, getSubsidiaryNodes, getSuccessors, getTransportSender, getUUID, hashCode, prependPredecessor, remove, validateConfiguration
-
-
-
-
Method Detail
-
getWorkerClassName
public String getWorkerClassName()
Description copied from class:Node
Return the node's associatedcom.levigo.jadice.server.core.NodeWorker
full qualified class's name. By default, the worker class name is- The same as the node name with the trailing "Node" replaced by "Worker" if the node name ends in "Node"
- The node class name with an appended "Worker" otherwise.
This behavior can be overridden in concrete subclasses.
- Overrides:
getWorkerClassName
in classNode
- Returns:
- the full qualified class name of the worker of this node.
-
addStream
public void addStream(InputStream is, StreamDescriptor sd) throws IOException
Transmit anInputStream
and meta data about it to the server.Must not be called before the underlying job was successfully submitted.
- Parameters:
is
- AnInputStream
sd
- TheInputStream
's meta data- Throws:
IOException
- If the stream can't be sent.- See Also:
addStream(Stream)
-
addStream
public void addStream(Stream stream) throws IOException
Transmit aStream
to the server.Must not be called before the underlying job was successfully submitted.
- Parameters:
stream
- AStream
- Throws:
IOException
- If the stream can't be sent.IllegalStateException
- If you attempt to use this method before the according job has been accepted by a server instance.- Since:
- jadice server 4.3.1.17
-
addStream
public void addStream(InputStream is) throws IOException
Transmit anInputStream
(but no meta data about it) to the server.Must not be called before the underlying job was successfully submitted.
- Parameters:
is
- AnInputStream
- Throws:
IOException
- If the stream can't be sent.- See Also:
addStream(InputStream, StreamDescriptor)
,addStream(Stream)
-
createOutputStream
public OutputStream createOutputStream(StreamDescriptor sd) throws IOException
Creates anOutputStream
. Data written herein will be directly transfered to the server. As each call on thewrite
methods ofOutputStream
will result in at least one message between client and server, it's preferable to write in larger chunks.Must not be called before the underlying job was successfully submitted.
- Parameters:
sd
- TheOutputStream
's meta data- Returns:
- an
OutputStream
that can be written to - Throws:
IOException
- If the stream can't be sent.
-
createOutputStream
public OutputStream createOutputStream() throws IOException
Creates anOutputStream
. Data written herein will be directly transfered to the server. As each call on thewrite
methods ofOutputStream
will result in at least one message between client and server, it's preferable to write in larger chunks.Must not be called before the underlying job was successfully submitted.
- Returns:
- an
OutputStream
that can be written to - Throws:
IOException
- If the stream can't be sent.- See Also:
createOutputStream(StreamDescriptor)
-
complete
public void complete() throws IOException
After allStream
s were initiated to be sent to the server, this method must be called. So, the server knows that no moreStream
s will follow. Thereafter, calling the methods will cause an error.- Throws:
IOException
- If the "End-of-Streams" signal cannot be sent.IllegalStateException
- If you attempt to use this method before the according job has been accepted by a server instance.
-
getStreamBundle
public StreamBundle getStreamBundle()
Get theStream
s that the client has sent. To be used on the server side only...!- Returns:
- the
Stream
s sent by the client
-
initialize
protected void initialize(CommunicationSide side)
- Overrides:
initialize
in classNode
-
getInputCardinality
public Node.Cardinality getInputCardinality()
Description copied from class:Node
Return the input cardinality of this node, i.e. how many bundles (not streams!) it expects to process. By default, nodes are "pipe-style", i.e. one input, one output.- Overrides:
getInputCardinality
in classNode
- Returns:
- input cardinality
-
-