Hi , all ! I write my own executor to run code,
I override the launchTask method like that : ------------------------------------------------------------------------------------------------------------------------------------------------ @Override public void launchTask(ExecutorDriver driver, Protos.TaskInfo task) { LOGGER.info("Executor is launching task#{}\n...", task); //before launch driver.sendStatusUpdate( Protos.TaskStatus.newBuilder().setTaskId(task.getTaskId()).setState( Protos.TaskState.TASK_RUNNING).build()); LOGGER.info("Add your bussiness code hear .. "); //bussiness code hear //after launch driver.sendStatusUpdate( Protos.TaskStatus.newBuilder().setTaskId(task.getTaskId()).setState(Protos.TaskState.TASK_FINISHED).setData( ByteString.copyFromUtf8( "${taksData}")).build()); } // end method launchTask ------------------------------------------------------------------------------------------------------------------------------------------------ And i build the commandInfo like that: ------------------------------------------------------------------------------------------------------------------------------------------------ String executorCommand = String.format("java -jar %s", extractPath(executorJarPath)); Protos.CommandInfo.URI.Builder executorJarURI = Protos.CommandInfo.URI.newBuilder().setValue(executorJarPath); // executorJarURI is local uri or hadoop Protos.CommandInfo.Builder commandInfoBuilder = Protos.CommandInfo.newBuilder().setEnvironment(envBuilder).setValue( executorCommand).addUris(executorJarURI); // executorJarURI is local uri or hadoop long ctms = System.nanoTime(); Protos.ExecutorID.Builder executorIDBuilder = Protos.ExecutorID.newBuilder().setValue(new StringBuilder().append( ctms).append("-").append(task.getTaskRequestId()).toString()); Protos.ExecutorInfo.Builder executorInfoBuilder = Protos.ExecutorInfo.newBuilder().setExecutorId( executorIDBuilder).setCommand(commandInfoBuilder).setName("flexcloud-executor-2.0.1-" + ctms).setSource("java"); // TaskInfo Protos.TaskInfo.Builder taskInfoBuilder = Protos.TaskInfo.newBuilder().setName(task.getTaskName()).setTaskId( taskIDBuilder).setSlaveId(offer.getSlaveId()).setExecutor(executorInfoBuilder); return taskInfoBuilder.build(); ------------------------------------------------------------------------------------------------------------------------------------------------ After run the executor with mesos for several times , i found every executor was not exit , I execute $ ps -ef | grep “java -jar” on the slave machine , that shows me : wangyao$ ps -ef | grep "java -jar" 501 20078 19302 0 3:54下午 ?? 0:15.77 /usr/bin/java -jar flexcloud-executor.jar 501 20154 19302 0 3:54下午 ?? 0:17.92 /usr/bin/java -jar flexcloud-executor.jar 501 20230 19302 0 3:54下午 ?? 0:16.13 /usr/bin/java -jar flexcloud-executor.jar In order to stop these process after running a executor, first , i tried to add code "driver.stop()” or “driver.abort()” to the Executor’s launchTask method, but it is unused. So, I add code “System.exit(0)” , stop the JVM directly……. it works … I have doubt about this way to stop executor , it is the only way to do that?