cascading.tap
Class MultiSinkTap<Child extends Tap,Config,Output>

java.lang.Object
  extended by cascading.tap.Tap<Config,Void,Output>
      extended by cascading.tap.SinkTap<Config,Output>
          extended by cascading.tap.MultiSinkTap<Child,Config,Output>
All Implemented Interfaces:
FlowElement, CompositeTap<Child>, Traceable, Serializable

public class MultiSinkTap<Child extends Tap,Config,Output>
extends SinkTap<Config,Output>
implements CompositeTap<Child>

Class MultiSinkTap is both a CompositeTap and SinkTap that can write to multiple child Tap instances simultaneously.

It is the counterpart to MultiSourceTap.

Note all child Tap instances may or may not have the same declared Fields. In the case they do not, all sink fields will be merged into a single Fields instance via Fields.merge(cascading.tuple.Fields...).

See Also:
Serialized Form

Constructor Summary
MultiSinkTap(Child... taps)
          Constructor MultiSinkTap creates a new MultiSinkTap instance.
 
Method Summary
 boolean commitResource(Config conf)
          Method commitResource allows the underlying resource to be notified when all write processing is successful so that any additional cleanup or processing may be completed.
 boolean createResource(Config conf)
          Method createResource creates the underlying resource.
 boolean deleteResource(Config conf)
          Method deleteResource deletes the resource represented by this instance.
 boolean equals(Object o)
           
 Iterator<Child> getChildTaps()
           
 String getIdentifier()
          Method getIdentifier returns a String representing the resource this Tap instance represents.
 long getModifiedTime(Config conf)
          Method getModifiedTime returns the date this resource was last modified.
 long getNumChildTaps()
           
 Scheme getScheme()
          Method getScheme returns the scheme of this Tap object.
protected  Child[] getTaps()
           
 int hashCode()
           
 TupleEntryCollector openForWrite(FlowProcess<Config> flowProcess, Output output)
          Method openForWrite opens the resource represented by this Tap instance for writing.
 void presentSinkFields(FlowProcess<Config> flowProcess, Fields fields)
           
 boolean resourceExists(Config conf)
          Method resourceExists returns true if the path represented by this instance exists.
 boolean rollbackResource(Config conf)
          Method rollbackResource allows the underlying resource to be notified when any write processing has failed or was stopped so that any cleanup may be started.
 void sinkConfInit(FlowProcess<Config> process, Config conf)
          Method sinkConfInit initializes this instance as a sink.
 String toString()
           
 
Methods inherited from class cascading.tap.SinkTap
getSourceFields, isSource, openForRead, prepareResourceForRead, sourceConfInit
 
Methods inherited from class cascading.tap.Tap
createResource, deleteResource, flowConfInit, getConfigDef, getFullIdentifier, getFullIdentifier, getModifiedTime, getSinkFields, getSinkMode, getStepConfigDef, getTrace, hasConfigDef, hasStepConfigDef, id, isEquivalentTo, isKeep, isReplace, isSink, isTemporary, isUpdate, openForRead, openForWrite, outgoingScopeFor, prepareResourceForWrite, presentSourceFields, resolveIncomingOperationArgumentFields, resolveIncomingOperationPassThroughFields, resourceExists, retrieveSinkFields, retrieveSourceFields, setScheme, taps
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MultiSinkTap

@ConstructorProperties(value="taps")
public MultiSinkTap(Child... taps)
Constructor MultiSinkTap creates a new MultiSinkTap instance.

Parameters:
taps - of type Tap...
Method Detail

getTaps

protected Child[] getTaps()

getChildTaps

public Iterator<Child> getChildTaps()
Specified by:
getChildTaps in interface CompositeTap<Child extends Tap>

getNumChildTaps

public long getNumChildTaps()
Specified by:
getNumChildTaps in interface CompositeTap<Child extends Tap>

getIdentifier

public String getIdentifier()
Description copied from class: Tap
Method getIdentifier returns a String representing the resource this Tap instance represents.

Often, if the tap accesses a filesystem, the identifier is nothing more than the path to the file or directory. In other cases it may be a an URL or URI representing a connection string or remote resource.

Any two Tap instances having the same value for the identifier are considered equal.

Specified by:
getIdentifier in class Tap<Config,Void,Output>
Returns:
String

presentSinkFields

public void presentSinkFields(FlowProcess<Config> flowProcess,
                              Fields fields)
Overrides:
presentSinkFields in class Tap<Config,Void,Output>

openForWrite

public TupleEntryCollector openForWrite(FlowProcess<Config> flowProcess,
                                        Output output)
                                 throws IOException
Description copied from class: Tap
Method openForWrite opens the resource represented by this Tap instance for writing.

This method is used internally and does not honor the SinkMode setting. If SinkMode is SinkMode.REPLACE, this call may fail. See Tap.openForWrite(cascading.flow.FlowProcess).

output value may be null, if so, sub-classes must inquire with the underlying Scheme via Scheme.sinkConfInit(cascading.flow.FlowProcess, Tap, Object) to get the proper output type and instantiate it before calling super.openForWrite().

Specified by:
openForWrite in class Tap<Config,Void,Output>
Parameters:
flowProcess - of type FlowProcess
output - of type Output
Returns:
TupleEntryCollector
Throws:
IOException - when the resource cannot be opened

sinkConfInit

public void sinkConfInit(FlowProcess<Config> process,
                         Config conf)
Description copied from class: Tap
Method sinkConfInit initializes this instance as a sink.

This method maybe called more than once if this Tap instance is used outside the scope of a Flow instance or if it participates in multiple times in a given Flow or across different Flows in a Cascade.

Note this method will be called in context of this Tap being used as a traditional 'sink' and as a 'trap'.

In the context of a Flow, it will be called after FlowListener.onStarting(cascading.flow.Flow)

Note that no resources or services should be modified by this method. If this Tap instance returns true for Tap.isReplace(), then Tap.deleteResource(Object) will be called by the parent Flow.

Overrides:
sinkConfInit in class Tap<Config,Void,Output>
Parameters:
process - of type FlowProcess
conf - of type Config

createResource

public boolean createResource(Config conf)
                       throws IOException
Description copied from class: Tap
Method createResource creates the underlying resource.

Specified by:
createResource in class Tap<Config,Void,Output>
Parameters:
conf - of type Config
Returns:
boolean
Throws:
IOException - when there is an error making directories

deleteResource

public boolean deleteResource(Config conf)
                       throws IOException
Description copied from class: Tap
Method deleteResource deletes the resource represented by this instance.

Specified by:
deleteResource in class Tap<Config,Void,Output>
Parameters:
conf - of type Config
Returns:
boolean
Throws:
IOException - when the resource cannot be deleted

commitResource

public boolean commitResource(Config conf)
                       throws IOException
Description copied from class: Tap
Method commitResource allows the underlying resource to be notified when all write processing is successful so that any additional cleanup or processing may be completed.

See Tap.rollbackResource(Object) to handle cleanup in the face of failures.

This method is invoked once client side and not in the cluster, if any.

If other sink Tap instance in a given Flow fail on commitResource after called on this instance, rollbackResource will not be called.

Overrides:
commitResource in class Tap<Config,Void,Output>
Parameters:
conf - of type Config
Returns:
returns true if successful
Throws:
IOException

rollbackResource

public boolean rollbackResource(Config conf)
                         throws IOException
Description copied from class: Tap
Method rollbackResource allows the underlying resource to be notified when any write processing has failed or was stopped so that any cleanup may be started.

See Tap.commitResource(Object) to handle cleanup when the write has successfully completed.

This method is invoked once client side and not in the cluster, if any.

Overrides:
rollbackResource in class Tap<Config,Void,Output>
Parameters:
conf - of type Config
Returns:
returns true if successful
Throws:
IOException

resourceExists

public boolean resourceExists(Config conf)
                       throws IOException
Description copied from class: Tap
Method resourceExists returns true if the path represented by this instance exists.

Specified by:
resourceExists in class Tap<Config,Void,Output>
Parameters:
conf - of type Config
Returns:
true if the underlying resource already exists
Throws:
IOException - when the status cannot be determined

getModifiedTime

public long getModifiedTime(Config conf)
                     throws IOException
Description copied from class: Tap
Method getModifiedTime returns the date this resource was last modified.

Specified by:
getModifiedTime in class Tap<Config,Void,Output>
Parameters:
conf - of type Config
Returns:
The date this resource was last modified.
Throws:
IOException

getScheme

public Scheme getScheme()
Description copied from class: Tap
Method getScheme returns the scheme of this Tap object.

Overrides:
getScheme in class Tap<Config,Void,Output>
Returns:
the scheme (type Scheme) of this Tap object.

toString

public String toString()
Overrides:
toString in class Tap<Config,Void,Output>

equals

public boolean equals(Object o)
Overrides:
equals in class Tap<Config,Void,Output>

hashCode

public int hashCode()
Overrides:
hashCode in class Tap<Config,Void,Output>


Copyright © 2007-2015 Concurrent, Inc. All Rights Reserved.