public abstract class DataPublisher extends Object implements Closeable, CapabilityAware
| Modifier and Type | Field and Description |
|---|---|
static Capability |
REUSABLE
Reusable capability.
|
protected State |
state |
| Constructor and Description |
|---|
DataPublisher(State state) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canBeSkipped()
Return true if the current publisher can be skipped.
|
static DataPublisher |
getInstance(Class<? extends DataPublisher> dataPublisherClass,
State state)
Get an instance of
DataPublisher. |
State |
getState() |
abstract void |
initialize()
Deprecated.
DataPublisher initialization should be done in the constructor. |
boolean |
isThreadSafe()
Returns true if the implementation of
DataPublisher is thread-safe. |
protected void |
markCommit(Collection<? extends WorkUnitState> states) |
void |
publish(Collection<? extends WorkUnitState> states)
First publish the metadata via
publishMetadata(Collection), and then publish the output data
via the publishData(Collection) method. |
abstract void |
publishData(Collection<? extends WorkUnitState> states)
Publish the data for the given tasks.
|
abstract void |
publishMetadata(Collection<? extends WorkUnitState> states)
Publish the metadata (e.g., schema) for the given tasks.
|
protected boolean |
shouldPublishMetadataFirst()
Generally metadata should be published before the data it represents, but this allows subclasses to override
if they are dependent on data getting published first.
|
boolean |
supportsCapability(Capability c,
Map<String,Object> properties)
Checks if this object supports the given Capability with the given properties.
|
public static final Capability REUSABLE
protected final State state
public DataPublisher(State state)
@Deprecated public abstract void initialize() throws IOException
DataPublisher initialization should be done in the constructor.IOExceptionpublic abstract void publishData(Collection<? extends WorkUnitState> states) throws IOException
IOExceptionpublic abstract void publishMetadata(Collection<? extends WorkUnitState> states) throws IOException
IOExceptionpublic void publish(Collection<? extends WorkUnitState> states) throws IOException
publishMetadata(Collection), and then publish the output data
via the publishData(Collection) method.states - is a Collection of WorkUnitStates.IOException - if there is a problem with publishing the metadata or the data.protected void markCommit(Collection<? extends WorkUnitState> states)
public State getState()
public static DataPublisher getInstance(Class<? extends DataPublisher> dataPublisherClass, State state) throws ReflectiveOperationException
DataPublisher.dataPublisherClass - A concrete class that extends DataPublisher.state - A State used to instantiate the DataPublisher.DataPublisher instance.ReflectiveOperationExceptionpublic boolean isThreadSafe()
DataPublisher is thread-safe.
For a thread-safe DataPublisher, this method should return this.getClass() ==
public boolean canBeSkipped()
For a publisher that can be skipped, it should not have any effect on state persistence. It will be skipped when a job is cancelled, and all finished tasks are configured to be committed.
protected boolean shouldPublishMetadataFirst()
public boolean supportsCapability(Capability c, Map<String,Object> properties)
CapabilityAwaresupportsCapability in interface CapabilityAwarec - Capability being queriedproperties - Properties specific to the capability. Properties are capability specific.