001    /*
002     * Copyright (c) 2007-2014 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    
021    package cascading.flow;
022    
023    import java.util.List;
024    import java.util.Map;
025    import java.util.Set;
026    
027    import cascading.pipe.Group;
028    import cascading.pipe.HashJoin;
029    import cascading.stats.FlowStepStats;
030    import 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     */
040    public interface FlowStep<Config>
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 getStepNum();
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 getStepDisplayName returns the stepDisplayName of this FlowStep object.
083       *
084       * @return the stepName (type String) of this FlowStep object.
085       */
086      String getStepDisplayName();
087    
088      /**
089       * Method getSubmitPriority returns the submitPriority of this FlowStep object.
090       * <p/>
091       * 10 is lowest, 1 is the highest, 5 is the default.
092       *
093       * @return the submitPriority (type int) of this FlowStep object.
094       */
095      int getSubmitPriority();
096    
097      /**
098       * Method setSubmitPriority sets the submitPriority of this FlowStep object.
099       * <p/>
100       * 10 is lowest, 1 is the highest, 5 is the default.
101       *
102       * @param submitPriority the submitPriority of this FlowStep object.
103       */
104      void setSubmitPriority( int submitPriority );
105    
106      Group getGroup();
107    
108      List<Group> getGroups();
109    
110      Map<HashJoin, Tap> getStreamedSourceByJoin();
111    
112      Set<Tap> getAllAccumulatedSources();
113    
114      Set<Tap> getSources();
115    
116      Set<Tap> getSinks();
117    
118      Tap getSink();
119    
120      Set<String> getSourceName( Tap source );
121    
122      Set<String> getSinkName( Tap sink );
123    
124      Tap getSourceWith( String identifier );
125    
126      Tap getSinkWith( String identifier );
127    
128      Set<Tap> getTraps();
129    
130      Tap getTrap( String name );
131    
132      /**
133       * Returns true if this FlowStep contains a pipe/branch with the given name.
134       *
135       * @param pipeName the name of the Pipe
136       * @return a boolean
137       */
138      boolean containsPipeNamed( String pipeName );
139    
140      FlowStepStats getFlowStepStats();
141    
142      /**
143       * Method hasListeners returns true if {@link FlowStepListener} instances have been registered.
144       *
145       * @return boolean
146       */
147      boolean hasListeners();
148    
149      /**
150       * Method addListener registers the given {@link FlowStepListener} with this instance.
151       *
152       * @param flowStepListener of type flowStepListener
153       */
154      void addListener( FlowStepListener flowStepListener );
155    
156      /**
157       * Method removeListener removes the given flowStepListener from this instance.
158       *
159       * @param flowStepListener of type FlowStepListener
160       * @return true if the listener was removed
161       */
162      boolean removeListener( FlowStepListener flowStepListener );
163      }