Package com.levigo.jadice.server.nodes
Class URLOutputNode
- java.lang.Object
-
- com.levigo.jadice.server.internal.NodeInternal
-
- com.levigo.jadice.server.Node
-
- com.levigo.jadice.server.nodes.URLOutputNode
-
public class URLOutputNode extends Node
ThisNodewrites out incoming streams the specified URL.As several incoming streams cause several resulting files, the filenames can be patternized:
- If it contains
SEQUENCE_NUMBERthis will be replaced by a sequential number per stream (i.e. 0..n ). - If it contains
STREAMDESCRIPTOR_FILENAMEthis will be replaced by the filename that theStreamDescriptorprovides for particular stream.
See:StreamDescriptor.getFileName()
Currently, the only supported protocols are:
file- stores the results on the server side
ftp- uploads the result on an FTP server
As this node is a data sink it must not have a successor.
- If it contains
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceURLOutputNode.StreamListenerThis listener will be informed whenever aStreamhas been successfully written on the server side.-
Nested classes/interfaces inherited from class com.levigo.jadice.server.Node
Node.Cardinality
-
-
Field Summary
Fields Modifier and Type Field Description static StringSEQUENCE_NUMBERPattern that will be replaced by a sequence number.static StringSTREAMDESCRIPTOR_FILENAMEPattern that will be replaced by the filename given in theStreamDescriptor.static String[]SUPPORTED_PROTOCOLSProtocols supported by this node.
-
Constructor Summary
Constructors Constructor Description URLOutputNode()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddStreamListener(URLOutputNode.StreamListener listener)Adds a listener to be informed about aStreambeen writtenURLgenerateEffectiveURL(StreamDescriptor sd, String seqNumber)Creates an URL for aStreamto write as specified in this node and replaces all patterns.StringgetFileNamePattern()Node.CardinalitygetOutputCardinality()Return the output cardinality of this node, i.e.URLgetUrlPath()StringgetWorkerClassName()Return the node's associatedcom.levigo.jadice.server.core.NodeWorkerfull qualified class's name.protected voidinitialize(CommunicationSide side)booleanisAllowOverwrite()voidremoveStreamListener(URLOutputNode.StreamListener listener)Removes aURLOutputNode.StreamListenerfor the events.voidsetAllowOverwrite(boolean allowOverwrite)Flag if it's allowed to overwrite already existing files (default:false).voidsetFileNamePattern(String fileNamePattern)Set a pattern for the filename.voidsetUrlPath(URL url)Set the path of theURL(without the filename)voidvalidate()Tests if all parameters are valid.protected voidvalidateConfiguration()-
Methods inherited from class com.levigo.jadice.server.Node
addTransportReceiver, appendSuccessor, apply, equals, getInputCardinality, getJob, getPredecessors, getSubsidiaryNodes, getSuccessors, getTransportSender, getUUID, hashCode, prependPredecessor, remove
-
-
-
-
Field Detail
-
SEQUENCE_NUMBER
public static final String SEQUENCE_NUMBER
Pattern that will be replaced by a sequence number.- See Also:
- Constant Field Values
-
STREAMDESCRIPTOR_FILENAME
public static final String STREAMDESCRIPTOR_FILENAME
Pattern that will be replaced by the filename given in theStreamDescriptor.
-
SUPPORTED_PROTOCOLS
public static final String[] SUPPORTED_PROTOCOLS
Protocols supported by this node.
-
-
Method Detail
-
generateEffectiveURL
public URL generateEffectiveURL(StreamDescriptor sd, String seqNumber) throws MalformedURLException
Creates an URL for aStreamto write as specified in this node and replaces all patterns.- Parameters:
sd- The StreamDescriptorseqNumber- The sequence number of the Stream- Returns:
- The URI where so store the Stream
- Throws:
MalformedURLException- If the given parameters are not valid
-
validate
public void validate() throws IllegalArgumentExceptionTests if all parameters are valid.- Throws:
IllegalArgumentException- if any of the parameters is not valid.
-
getWorkerClassName
public String getWorkerClassName()
Description copied from class:NodeReturn the node's associatedcom.levigo.jadice.server.core.NodeWorkerfull 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:
getWorkerClassNamein classNode- Returns:
- the full qualified class name of the worker of this node.
-
initialize
protected void initialize(CommunicationSide side)
- Overrides:
initializein classNode
-
getFileNamePattern
public String getFileNamePattern()
-
setFileNamePattern
public void setFileNamePattern(String fileNamePattern)
Set a pattern for the filename.Legal place holders are
SEQUENCE_NUMBERandSTREAMDESCRIPTOR_FILENAME.- Parameters:
fileNamePattern- The pattern to set
-
isAllowOverwrite
public boolean isAllowOverwrite()
-
setAllowOverwrite
public void setAllowOverwrite(boolean allowOverwrite)
Flag if it's allowed to overwrite already existing files (default:false). In such a case an error with MessageIDJS.SERVER.NODES-OVERWRITE_FORBIDDENwill be raised.Implementation node: This flag is only respected when using the protocol
file.- Parameters:
allowOverwrite- files are allowed be be overwritten iff set totrue
-
getUrlPath
public URL getUrlPath()
-
setUrlPath
public void setUrlPath(URL url)
Set the path of theURL(without the filename)- Parameters:
url- the base URL.
-
getOutputCardinality
public Node.Cardinality getOutputCardinality()
Description copied from class:NodeReturn the output cardinality of this node, i.e. how many bundles (not streams!) it expects to produce. By default, nodes are "pipe-style", i.e. one input, one output.- Overrides:
getOutputCardinalityin classNode- Returns:
- output cardinality
-
validateConfiguration
protected void validateConfiguration() throws ConfigurationException- Overrides:
validateConfigurationin classNode- Throws:
ConfigurationException
-
addStreamListener
public void addStreamListener(URLOutputNode.StreamListener listener)
Adds a listener to be informed about aStreambeen written- Parameters:
listener- The listener to add- Since:
- jadice server 5.4.2.0
-
removeStreamListener
public void removeStreamListener(URLOutputNode.StreamListener listener)
Removes aURLOutputNode.StreamListenerfor the events.- Parameters:
listener- The listener to remove- Since:
- jadice server 5.4.2.0
-
-