26
26
import org .apache .flink .api .common .Plan ;
27
27
import org .apache .flink .api .common .PlanExecutor ;
28
28
import org .apache .flink .api .common .Program ;
29
- import org .apache .flink .client .minicluster .FlinkMiniCluster ;
29
+ import org .apache .flink .configuration .Configuration ;
30
+ import org .apache .flink .runtime .minicluster .FlinkMiniCluster ;
30
31
import org .apache .flink .runtime .client .JobClient ;
31
32
import org .apache .flink .runtime .jobgraph .JobGraph ;
32
33
import org .apache .flink .api .java .ExecutionEnvironment ;
37
38
import org .apache .flink .compiler .plan .OptimizedPlan ;
38
39
import org .apache .flink .compiler .plandump .PlanJSONDumpGenerator ;
39
40
import org .apache .flink .compiler .plantranslate .NepheleJobGraphGenerator ;
41
+ import org .apache .flink .runtime .minicluster .LocalFlinkMiniCluster ;
40
42
41
43
/**
42
44
* A class for executing a {@link Plan} on a local embedded Flink runtime instance.
@@ -49,7 +51,7 @@ public class LocalExecutor extends PlanExecutor {
49
51
50
52
private final Object lock = new Object (); // we lock to ensure singleton execution
51
53
52
- private FlinkMiniCluster nephele ;
54
+ private LocalFlinkMiniCluster flink ;
53
55
54
56
// ---------------------------------- config options ------------------------------------------
55
57
@@ -141,33 +143,14 @@ public void setDefaultAlwaysCreateDirectory(boolean defaultAlwaysCreateDirectory
141
143
142
144
public void start () throws Exception {
143
145
synchronized (this .lock ) {
144
- if (this .nephele == null ) {
146
+ if (this .flink == null ) {
145
147
146
148
// create the embedded runtime
147
- this .nephele = new FlinkMiniCluster ();
148
-
149
- // configure it, if values were changed. otherwise the embedded runtime uses the internal defaults
150
- if (jobManagerRpcPort > 0 ) {
151
- nephele .setJobManagerRpcPort (jobManagerRpcPort );
152
- }
153
- if (taskManagerRpcPort > 0 ) {
154
- nephele .setTaskManagerRpcPort (jobManagerRpcPort );
155
- }
156
- if (taskManagerDataPort > 0 ) {
157
- nephele .setTaskManagerDataPort (taskManagerDataPort );
158
- }
159
- if (configDir != null ) {
160
- nephele .setConfigDir (configDir );
161
- }
162
- if (hdfsConfigFile != null ) {
163
- nephele .setHdfsConfigFile (hdfsConfigFile );
164
- }
165
- nephele .setDefaultOverwriteFiles (defaultOverwriteFiles );
166
- nephele .setDefaultAlwaysCreateDirectory (defaultAlwaysCreateDirectory );
167
- nephele .setTaskManagerNumSlots (taskManagerNumSlots );
149
+ this .flink = new LocalFlinkMiniCluster (configDir );
150
+ Configuration configuration = new Configuration ();
168
151
169
152
// start it up
170
- this .nephele .start ();
153
+ this .flink .start (configuration );
171
154
} else {
172
155
throw new IllegalStateException ("The local executor was already started." );
173
156
}
@@ -179,9 +162,9 @@ public void start() throws Exception {
179
162
*/
180
163
public void stop () throws Exception {
181
164
synchronized (this .lock ) {
182
- if (this .nephele != null ) {
183
- this .nephele .stop ();
184
- this .nephele = null ;
165
+ if (this .flink != null ) {
166
+ this .flink .stop ();
167
+ this .flink = null ;
185
168
} else {
186
169
throw new IllegalStateException ("The local executor was not started." );
187
170
}
@@ -210,7 +193,7 @@ public JobExecutionResult executePlan(Plan plan) throws Exception {
210
193
211
194
// check if we start a session dedicated for this execution
212
195
final boolean shutDownAtEnd ;
213
- if (this .nephele == null ) {
196
+ if (this .flink == null ) {
214
197
// we start a session just for us now
215
198
shutDownAtEnd = true ;
216
199
@@ -235,7 +218,7 @@ public JobExecutionResult executePlan(Plan plan) throws Exception {
235
218
NepheleJobGraphGenerator jgg = new NepheleJobGraphGenerator ();
236
219
JobGraph jobGraph = jgg .compileJobGraph (op );
237
220
238
- JobClient jobClient = this .nephele .getJobClient (jobGraph );
221
+ JobClient jobClient = this .flink .getJobClient (jobGraph );
239
222
JobExecutionResult result = jobClient .submitJobAndWait ();
240
223
return result ;
241
224
}
0 commit comments