org.kitesdk.morphline.base
Class AbstractCommand

java.lang.Object
  extended by org.kitesdk.morphline.base.AbstractCommand
All Implemented Interfaces:
Command
Direct Known Subclasses:
AbstractFieldTransformCommand, AbstractParser

public abstract class AbstractCommand
extends Object
implements Command

Base class for convenient implementation of Command classes.


Field Summary
protected  org.slf4j.Logger LOG
           
 
Constructor Summary
protected AbstractCommand(CommandBuilder builder, com.typesafe.config.Config config, Command parent, Command child, MorphlineContext context)
          Using the given builder, constructs a command rooted at the given morphline JSON config.
protected AbstractCommand(com.typesafe.config.Config config, Command parent, Command child, MorphlineContext context)
          Deprecated. 
 
Method Summary
protected  Command buildCommand(com.typesafe.config.Config cmdConfig, Command currentParent, Command finalChild)
          Factory method to create a command rooted at the given cmdConfig.
protected  List<Command> buildCommandChain(com.typesafe.config.Config rootConfig, String configKey, Command finalChild, boolean ignoreNotifications)
          Factory method to create the chain of commands rooted at the given rootConfig.
protected  void doNotify(Record notification)
          Processes the given notification on the control plane of the subtree rooted at this command.
protected  boolean doProcess(Record record)
          Processes the given record on the data plane of this command.
protected  Command getChild()
          Returns the child of this command.
protected  com.typesafe.config.Config getConfig()
          Returns the JSON configuration of this command.
protected  Configs getConfigs()
          Returns a helper for convenient access to the JSON configuration of this command.
protected  MorphlineContext getContext()
          Returns the context of this command.
protected  com.codahale.metrics.Counter getCounter(String... names)
          Returns a counter for maintaining main-memory metrics.
protected  com.codahale.metrics.Histogram getHistogram(String... names)
          Returns a histogram for maintaining main-memory metrics.
protected  com.codahale.metrics.Meter getMeter(String... names)
          Returns a meter for maintaining main-memory metrics.
 Command getParent()
          Returns the parent of this command.
protected  com.codahale.metrics.Timer getTimer(String... names)
          Returns a timer for maintaining main-memory metrics.
protected  boolean isMeasuringMetrics()
          Returns whether or not metrics should be measured.
 void notify(Record notification)
          Processes the given notification on the control plane of the subtree rooted at this command.
 boolean process(Record record)
          Processes the given record on the data plane of this command.
protected  void validateArguments()
          Helper that checks if the user provided configuration parameters are valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected final org.slf4j.Logger LOG
Constructor Detail

AbstractCommand

protected AbstractCommand(CommandBuilder builder,
                          com.typesafe.config.Config config,
                          Command parent,
                          Command child,
                          MorphlineContext context)
Using the given builder, constructs a command rooted at the given morphline JSON config. The command will feed records into child. The command will have parent as it's parent. Additional parameters can be passed via the morphline context.


AbstractCommand

@Deprecated
protected AbstractCommand(com.typesafe.config.Config config,
                                     Command parent,
                                     Command child,
                                     MorphlineContext context)
Deprecated. 

Deprecated; will be removed in the next release

Method Detail

getParent

public Command getParent()
Description copied from interface: Command
Returns the parent of this command. The parent of a command A is the command B that passes records to A. A is the child of B.

Specified by:
getParent in interface Command

getChild

protected Command getChild()
Returns the child of this command. The parent of a command A is the command B that passes records to A. A is the child of B.


getConfig

protected com.typesafe.config.Config getConfig()
Returns the JSON configuration of this command.


getContext

protected MorphlineContext getContext()
Returns the context of this command.


getConfigs

protected Configs getConfigs()
Returns a helper for convenient access to the JSON configuration of this command.


notify

public final void notify(Record notification)
Description copied from interface: Command
Processes the given notification on the control plane of the subtree rooted at this command.

Specified by:
notify in interface Command

doNotify

protected void doNotify(Record notification)
Processes the given notification on the control plane of the subtree rooted at this command.


process

public final boolean process(Record record)
Description copied from interface: Command
Processes the given record on the data plane of this command.

Specified by:
process in interface Command
Returns:
true to indicate that processing shall continue, false to indicate that backtracking shall be done

doProcess

protected boolean doProcess(Record record)
Processes the given record on the data plane of this command.

Returns:
true to indicate that processing shall continue, false to indicate that backtracking shall be done

validateArguments

protected void validateArguments()
Helper that checks if the user provided configuration parameters are valid.


getCounter

protected com.codahale.metrics.Counter getCounter(String... names)
Returns a counter for maintaining main-memory metrics.


getHistogram

protected com.codahale.metrics.Histogram getHistogram(String... names)
Returns a histogram for maintaining main-memory metrics.


getMeter

protected com.codahale.metrics.Meter getMeter(String... names)
Returns a meter for maintaining main-memory metrics.


getTimer

protected com.codahale.metrics.Timer getTimer(String... names)
Returns a timer for maintaining main-memory metrics.


isMeasuringMetrics

protected final boolean isMeasuringMetrics()
Returns whether or not metrics should be measured.


buildCommandChain

protected List<Command> buildCommandChain(com.typesafe.config.Config rootConfig,
                                          String configKey,
                                          Command finalChild,
                                          boolean ignoreNotifications)
Factory method to create the chain of commands rooted at the given rootConfig. The last command in the chain will feed records into finalChild.

Parameters:
ignoreNotifications - if true indicates don't forward notifications at the end of the chain of commands. This is a feature that multi-branch commands like tryRules and ifThenElse need to avoid sending a notification multiple times to finalChild, once from each branch.

buildCommand

protected Command buildCommand(com.typesafe.config.Config cmdConfig,
                               Command currentParent,
                               Command finalChild)
Factory method to create a command rooted at the given cmdConfig. The command will feed records into finalChild. The command will have currentParent as it's parent.



Copyright © 2013–2014. All rights reserved.