001/*
002 * Copyright (c) 2007-2015 Concurrent, 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  Flow<Config> getFlow();
061
062  String getFlowID();
063
064  /**
065   * Method getParentFlowName returns the parentFlowName of this FlowStep object.
066   *
067   * @return the parentFlowName (type Flow) of this FlowStep object.
068   */
069  String getFlowName();
070
071  /**
072   * Method getConfig returns the current initialized configuration.
073   * <p/>
074   * The returned configuration is mutable and may be changed prior to this step being started
075   * or submitted.
076   *
077   * @return the current initialized configuration
078   */
079  Config getConfig();
080
081  /**
082   * Method getConfigAsProperties converts the internal configuration object into a {@link java.util.Map} of
083   * key value pairs.
084   *
085   * @return a Map of key/value pairs, may return an empty collection if unsupported
086   */
087  Map<Object, Object> getConfigAsProperties();
088
089  /**
090   * Method getStepDisplayName returns the stepDisplayName of this FlowStep object.
091   *
092   * @return the stepName (type String) of this FlowStep object.
093   */
094  String getStepDisplayName();
095
096  /**
097   * Method getSubmitPriority returns the submitPriority of this FlowStep object.
098   * <p/>
099   * 10 is lowest, 1 is the highest, 5 is the default.
100   *
101   * @return the submitPriority (type int) of this FlowStep object.
102   */
103  int getSubmitPriority();
104
105  /**
106   * Method setSubmitPriority sets the submitPriority of this FlowStep object.
107   * <p/>
108   * 10 is lowest, 1 is the highest, 5 is the default.
109   *
110   * @param submitPriority the submitPriority of this FlowStep object.
111   */
112  void setSubmitPriority( int submitPriority );
113
114  FlowNodeGraph getFlowNodeGraph();
115
116  int getNumFlowNodes();
117
118  Group getGroup();
119
120  Tap getSink();
121
122  Set<String> getSourceName( Tap source );
123
124  Set<String> getSinkName( Tap sink );
125
126  Tap getSourceWith( String identifier );
127
128  Tap getSinkWith( String identifier );
129
130  Set<Tap> getTraps();
131
132  Tap getTrap( String name );
133
134  /**
135   * Returns true if this FlowStep contains a pipe/branch with the given name.
136   *
137   * @param pipeName the name of the Pipe
138   * @return a boolean
139   */
140  boolean containsPipeNamed( String pipeName );
141
142  void setFlowStepStats( FlowStepStats flowStepStats );
143
144  FlowStepStats getFlowStepStats();
145
146  /**
147   * Method hasListeners returns true if {@link FlowStepListener} instances have been registered.
148   *
149   * @return boolean
150   */
151  boolean hasListeners();
152
153  /**
154   * Method addListener registers the given {@link FlowStepListener} with this instance.
155   *
156   * @param flowStepListener of type flowStepListener
157   */
158  void addListener( FlowStepListener flowStepListener );
159
160  /**
161   * Method removeListener removes the given flowStepListener from this instance.
162   *
163   * @param flowStepListener of type FlowStepListener
164   * @return true if the listener was removed
165   */
166  boolean removeListener( FlowStepListener flowStepListener );
167  }