cascading.tap
Class SourceTap<Config,Input>

java.lang.Object
  extended by cascading.tap.Tap<Config,Input,Void>
      extended by cascading.tap.SourceTap<Config,Input>
All Implemented Interfaces:
FlowElement, Serializable
Direct Known Subclasses:
MultiSourceTap, StdInTap

public abstract class SourceTap<Config,Input>
extends Tap<Config,Input,Void>

Class SourceTap is an optional base class for source only Taps.

Some Tap instances may only be sources (as opposed to being a sink). These types should subclass SourceTap for convenience or set isSink() to false in a custom Tap sub-class.

See Also:
Serialized Form

Constructor Summary
protected SourceTap()
           
protected SourceTap(Scheme<Config,Input,?,?,?> scheme)
           
 
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.
 Fields getSinkFields()
          Method getSinkFields returns the sinkFields of this Tap object.
 boolean isSink()
          Method isSink returns true if this Tap instance can be used as a sink.
 TupleEntryCollector openForWrite(FlowProcess<Config> flowProcess, Void output)
          Method openForWrite opens the resource represented by this Tap instance for writing.
 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> flowProcess, Config conf)
          Method sinkConfInit initializes this instance as a sink.
 
Methods inherited from class cascading.tap.Tap
createResource, deleteResource, equals, flowConfInit, getConfigDef, getFullIdentifier, getFullIdentifier, getIdentifier, getModifiedTime, getModifiedTime, getScheme, getSinkMode, getSourceFields, getStepConfigDef, getTrace, hasConfigDef, hashCode, hasStepConfigDef, id, isEquivalentTo, isKeep, isReplace, isSource, isTemporary, isUpdate, openForRead, openForRead, openForWrite, outgoingScopeFor, presentSinkFields, presentSourceFields, resolveIncomingOperationArgumentFields, resolveIncomingOperationPassThroughFields, resourceExists, resourceExists, retrieveSinkFields, retrieveSourceFields, setScheme, sourceConfInit, taps, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SourceTap

protected SourceTap()

SourceTap

protected SourceTap(Scheme<Config,Input,?,?,?> scheme)
Method Detail

getSinkFields

public Fields getSinkFields()
Description copied from class: Tap
Method getSinkFields returns the sinkFields of this Tap object.

Overrides:
getSinkFields in class Tap<Config,Input,Void>
Returns:
the sinkFields (type Fields) of this Tap object.

isSink

public final boolean isSink()
Description copied from class: Tap
Method isSink returns true if this Tap instance can be used as a sink.

Overrides:
isSink in class Tap<Config,Input,Void>
Returns:
boolean

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,Input,Void>
Parameters:
conf - of type Config
Returns:
boolean
Throws:
IOException - when the resource cannot be deleted

sinkConfInit

public void sinkConfInit(FlowProcess<Config> flowProcess,
                         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,Input,Void>
Parameters:
flowProcess - 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,Input,Void>
Parameters:
conf - of type Config
Returns:
boolean
Throws:
IOException - when there is an error making directories

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.

This is an experimental API and subject to refinement!!

Overrides:
commitResource in class Tap<Config,Input,Void>
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.

This is an experimental API and subject to refinement!!

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

openForWrite

public TupleEntryCollector openForWrite(FlowProcess<Config> flowProcess,
                                        Void 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,Input,Void>
Parameters:
flowProcess - of type FlowProcess
output - of type Output
Returns:
TupleEntryCollector
Throws:
IOException - when the resource cannot be opened


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