/** * Creates a {@link RemoteEnvironment}. The remote environment sends (parts of) the program * to a cluster for execution. Note that all file paths used in the program must be accessible from the * cluster. The execution will use the specified degree of parallelism. * * @param host The host name or address of the master (JobManager), where the program should be executed. * @param port The port of the master (JobManager), where the program should be executed. * @param degreeOfParallelism The degree of parallelism to use during the execution. * @param jarFiles The JAR files with code that needs to be shipped to the cluster. If the program uses * user-defined functions, user-defined input formats, or any libraries, those must be * provided in the JAR files. * @return A remote environment that executes the program on a cluster. */ public static ExecutionEnvironment createRemoteEnvironment(String host, int port, int degreeOfParallelism, String... jarFiles) { RemoteEnvironment rec = new RemoteEnvironment(host, port, jarFiles); rec.setDegreeOfParallelism(degreeOfParallelism); return rec; }
@Override public String toString() { return "Remote Environment (" + this.host + ":" + this.port + " - DOP = " + (getDegreeOfParallelism() == -1 ? "default" : getDegreeOfParallelism()) + ") : " + getIdString(); } }
@Override public String getExecutionPlan() throws Exception { Plan p = createProgramPlan("unnamed"); p.setDefaultParallelism(getDegreeOfParallelism()); registerCachedFilesWithPlan(p); PlanExecutor executor = PlanExecutor.createRemoteExecutor(host, port, jarFiles); return executor.getOptimizerPlanAsJSON(p); }
/** * Creates a {@link RemoteEnvironment}. The remote environment sends (parts of) the program * to a cluster for execution. Note that all file paths used in the program must be accessible from the * cluster. The execution will use the cluster's default degree of parallelism, unless the parallelism is * set explicitly via {@link ExecutionEnvironment#setDegreeOfParallelism(int)}. * * @param host The host name or address of the master (JobManager), where the program should be executed. * @param port The port of the master (JobManager), where the program should be executed. * @param jarFiles The JAR files with code that needs to be shipped to the cluster. If the program uses * user-defined functions, user-defined input formats, or any libraries, those must be * provided in the JAR files. * @return A remote environment that executes the program on a cluster. */ public static ExecutionEnvironment createRemoteEnvironment(String host, int port, String... jarFiles) { return new RemoteEnvironment(host, port, jarFiles); }
@Override public JobExecutionResult execute(String jobName) throws Exception { Plan p = createProgramPlan(jobName); PlanExecutor executor = PlanExecutor.createRemoteExecutor(host, port, jarFiles); return executor.executePlan(p); }
ExecutionEnvironment env = new RemoteEnvironment("localhost", 1, null);