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