Java Code Examples for org.apache.mesos.ExecutorDriver#stop()
The following examples show how to use
org.apache.mesos.ExecutorDriver#stop() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CassandraExecutor.java From cassandra-mesos-deprecated with Apache License 2.0 | 6 votes |
@Override public void killTask(final ExecutorDriver driver, final TaskID taskId) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("killTask(driver : {}, taskId : {})", driver, protoToString(taskId)); } if (serverTask != null && serverTask.getTaskId().equals(taskId)) { killCassandraDaemon(driver); } else if (executorInfo.getExecutorId().getValue().equals(taskId.getValue())) { killCassandraDaemon(driver); driver.sendStatusUpdate(taskStatus(executorInfo.getExecutorId(), taskId, TaskState.TASK_FINISHED, ExecutorUtils.nullSlaveStatusDetails())); driver.stop(); } }
Example 2
Source File: TaskExecutor.java From shardingsphere-elasticjob-cloud with Apache License 2.0 | 5 votes |
@Override public void frameworkMessage(final ExecutorDriver executorDriver, final byte[] bytes) { if (null != bytes && "STOP".equals(new String(bytes))) { log.error("call frameworkMessage executor stopped."); executorDriver.stop(); } }
Example 3
Source File: LogstashExecutor.java From logstash with Apache License 2.0 | 5 votes |
@Override public void launchTask(final ExecutorDriver driver, final Protos.TaskInfo task) { LOGGER.info("Launching task taskId={}", task.getTaskId()); ExecutorBootConfiguration bootConfiguration = SerializationUtils.deserialize(task.getData().toByteArray()); final Thread thread = new Thread(() -> { LOGGER.info("Forked thread with LogstashService.run()"); try { logstashService.run(bootConfiguration); LOGGER.info("LogstashService finished"); driver.sendStatusUpdate(Protos.TaskStatus.newBuilder() .setExecutorId(task.getExecutor().getExecutorId()) .setTaskId(task.getTaskId()) .setState(Protos.TaskState.TASK_FINISHED).build()); } catch (Exception e) { LOGGER.error("Logstash service failed", e); driver.sendStatusUpdate(Protos.TaskStatus.newBuilder() .setExecutorId(task.getExecutor().getExecutorId()) .setTaskId(task.getTaskId()) .setState(Protos.TaskState.TASK_FAILED) .setMessage(e.getMessage()).build()); } driver.stop(); }); thread.setDaemon(true); logstashService.addOnLogstashReadyListener(() -> driver.sendStatusUpdate(Protos.TaskStatus.newBuilder() .setExecutorId(task.getExecutor().getExecutorId()) .setTaskId(task.getTaskId()) .setState(Protos.TaskState.TASK_RUNNING).build())); thread.start(); }
Example 4
Source File: LogstashExecutor.java From logstash with Apache License 2.0 | 5 votes |
@Override public void killTask(ExecutorDriver driver, Protos.TaskID taskId) { LOGGER.info("Kill task. taskId={}", taskId.getValue()); driver.sendStatusUpdate(Protos.TaskStatus.newBuilder() .setTaskId(taskId) .setState(Protos.TaskState.TASK_KILLED).build()); driver.stop(); }
Example 5
Source File: SingularityExecutorMonitor.java From Singularity with Apache License 2.0 | 4 votes |
public void shutdown(ExecutorDriver driver) { if (!alreadyShutDown.compareAndSet(false, true)) { LOG.info("Already ran shut down process"); return; } LOG.info("Shutdown requested with driver {}", driver); threadChecker.getExecutorService().shutdown(); processBuilderPool.shutdown(); runningProcessPool.shutdown(); cgroupCfsWatcherService.shutdown(); for (SingularityExecutorTask task : tasks.values()) { if (!task.wasKilled()) { task .getLog() .info( "Executor shutting down - requested task kill with state: {}", requestKill(task.getTaskId()) ); } } processKiller.getExecutorService().shutdown(); for (Entry<String, ListeningExecutorService> taskIdToShellCommandPool : taskToShellCommandPool.entrySet()) { // in case LOG.warn("Shutting down abandoned pool for {}", taskIdToShellCommandPool.getKey()); taskIdToShellCommandPool.getValue().shutdown(); } cgroupCheckers.values().forEach(SingularityExecutorCgroupCfsChecker::close); exitChecker.shutdown(); final long start = System.currentTimeMillis(); JavaUtils.awaitTerminationWithLatch( latch, "threadChecker", threadChecker.getExecutorService(), configuration.getShutdownTimeoutWaitMillis() ); JavaUtils.awaitTerminationWithLatch( latch, "processBuilder", processBuilderPool, configuration.getShutdownTimeoutWaitMillis() ); JavaUtils.awaitTerminationWithLatch( latch, "runningProcess", runningProcessPool, configuration.getShutdownTimeoutWaitMillis() ); JavaUtils.awaitTerminationWithLatch( latch, "processKiller", processKiller.getExecutorService(), configuration.getShutdownTimeoutWaitMillis() ); LOG.info( "Awaiting shutdown of all thread pools for a max of {}", JavaUtils.durationFromMillis(configuration.getShutdownTimeoutWaitMillis()) ); try { latch.await(); } catch (InterruptedException e) { LOG.warn("While awaiting shutdown of executor services", e); } LOG.info( "Waited {} for shutdown of thread pools, now waiting {} before exiting...", JavaUtils.duration(start), JavaUtils.durationFromMillis(configuration.getStopDriverAfterMillis()) ); try { Thread.sleep(configuration.getStopDriverAfterMillis()); } catch (Throwable t) { LOG.warn("While waiting to exit", t); } LOG.info("Stopping driver {}", driver); Status status = driver.stop(); LOG.info("Driver stopped with status {}", status); }