    001/*
    002 * Copyright (c) 2007-2017 Xplenty, Inc. All Rights Reserved.
    003 *
    004 * Project and contact information: http://www.cascading.org/
    005 *
    006 * This file is part of the Cascading project.
    007 *
    008 * Licensed under the Apache License, Version 2.0 (the "License");
    009 * you may not use this file except in compliance with the License.
    010 * You may obtain a copy of the License at
    011 *
    012 *     http://www.apache.org/licenses/LICENSE-2.0
    013 *
    014 * Unless required by applicable law or agreed to in writing, software
    015 * distributed under the License is distributed on an "AS IS" BASIS,
    016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    017 * See the License for the specific language governing permissions and
    018 * limitations under the License.
    019 */
    020
    021package cascading.flow;
    022
    023import java.util.Map;
    024import java.util.Set;
    025
    026import cascading.flow.planner.process.FlowNodeGraph;
    027import cascading.flow.planner.process.ProcessModel;
    028import cascading.pipe.Group;
    029import cascading.stats.FlowStepStats;
    030import cascading.tap.Tap;
    031
    032/**
    033 * Class FlowStep is an internal representation of a given "job" possibly to be executed on a remote cluster. During
    034 * planning, pipe assemblies are broken down into "steps" and encapsulated in this class.
    035 * <p/>
    036 * FlowSteps are submitted in order of dependency. If two or more steps do not share the same dependencies and all
    037 * can be scheduled simultaneously, the {@link #getSubmitPriority()} value determines the order in which
    038 * all steps will be submitted for execution. The default submit priority is 5.
    039 */
    040public interface FlowStep<Config> extends ProcessModel
    041  {
    042  String CASCADING_FLOW_STEP_ID = "cascading.flow.step.id";
    043
    044  /**
    045   * Method getId returns the id of this FlowStep object.
    046   *
    047   * @return the id (type int) of this FlowStep object.
    048   */
    049  String getID();
    050
    051  int getOrdinal();
    052
    053  /**
    054   * Method getName returns the name of this FlowStep object.
    055   *
    056   * @return the name (type String) of this FlowStep object.
    057   */
    058  String getName();
    059
    060  /**
    061   * Returns an immutable map of properties giving more details about the FlowStep object.
    062   * <p/>
    063   * FlowStep descriptions provide meta-data to monitoring systems describing the workload a given FlowStep represents.
    064   * For known description types, see {@link FlowStepDescriptors}.
    065   *
    066   * @return Map<String,String>
    067   */
    068  Map<String, String> getFlowStepDescriptor();
    069
    070  Flow<Config> getFlow();
    071
    072  String getFlowID();
    073
    074  /**
    075   * Method getParentFlowName returns the parentFlowName of this FlowStep object.
    076   *
    077   * @return the parentFlowName (type Flow) of this FlowStep object.
    078   */
    079  String getFlowName();
    080
    081  /**
    082   * Method getConfig returns the current initialized configuration.
    083   * <p/>
    084   * The returned configuration is mutable and may be changed prior to this step being started
    085   * or submitted.
    086   *
    087   * @return the current initialized configuration
    088   */
    089  Config getConfig();
    090
    091  /**
    092   * Method getConfigAsProperties converts the internal configuration object into a {@link java.util.Map} of
    093   * key value pairs.
    094   *
    095   * @return a Map of key/value pairs, may return an empty collection if unsupported
    096   */
    097  Map<Object, Object> getConfigAsProperties();
    098
    099  /**
    100   * Method getStepDisplayName returns the stepDisplayName of this FlowStep object.
    101   *
    102   * @return the stepName (type String) of this FlowStep object.
    103   */
    104  String getStepDisplayName();
    105
    106  /**
    107   * Method getSubmitPriority returns the submitPriority of this FlowStep object.
    108   * <p/>
    109   * 10 is lowest, 1 is the highest, 5 is the default.
    110   *
    111   * @return the submitPriority (type int) of this FlowStep object.
    112   */
    113  int getSubmitPriority();
    114
    115  /**
    116   * Method setSubmitPriority sets the submitPriority of this FlowStep object.
    117   * <p/>
    118   * 10 is lowest, 1 is the highest, 5 is the default.
    119   *
    120   * @param submitPriority the submitPriority of this FlowStep object.
    121   */
    122  void setSubmitPriority( int submitPriority );
    123
    124  FlowNodeGraph getFlowNodeGraph();
    125
    126  int getNumFlowNodes();
    127
    128  Group getGroup();
    129
    130  Tap getSink();
    131
    132  Set<String> getSourceName( Tap source );
    133
    134  Set<String> getSinkName( Tap sink );
    135
    136  Tap getSourceWith( String identifier );
    137
    138  Tap getSinkWith( String identifier );
    139
    140  Set<Tap> getTraps();
    141
    142  Tap getTrap( String name );
    143
    144  /**
    145   * Returns true if this FlowStep contains a pipe/branch with the given name.
    146   *
    147   * @param pipeName the name of the Pipe
    148   * @return a boolean
    149   */
    150  boolean containsPipeNamed( String pipeName );
    151
    152  void setFlowStepStats( FlowStepStats flowStepStats );
    153
    154  FlowStepStats getFlowStepStats();
    155
    156  /**
    157   * Method hasListeners returns true if {@link FlowStepListener} instances have been registered.
    158   *
    159   * @return boolean
    160   */
    161  boolean hasListeners();
    162
    163  /**
    164   * Method addListener registers the given {@link FlowStepListener} with this instance.
    165   *
    166   * @param flowStepListener of type flowStepListener
    167   */
    168  void addListener( FlowStepListener flowStepListener );
    169
    170  /**
    171   * Method removeListener removes the given flowStepListener from this instance.
    172   *
    173   * @param flowStepListener of type FlowStepListener
    174   * @return true if the listener was removed
    175   */
    176  boolean removeListener( FlowStepListener flowStepListener );
    177  }