Convenience method used to sending appropriate Kill signal to the task
VM
@param context
@param command
@throws IOException
681
private void finishTask(TaskControllerContext context,
      TaskCommands command) throws IOException{
    if(context.task == null) {
      LOG.info("Context task null not killing the JVM");
      return;
    }
    ShellCommandExecutor shExec = buildTaskControllerExecutor(
        command, context.env.conf.getUser(), 
        buildKillTaskCommandArgs(context), context.env.workDir,
        context.env.env);
    try {
      shExec.execute();
    } catch (Exception e) {
      LOG.warn("Output from task-contoller is : " + shExec.getOutput());
      throw new IOException(e);
    }
  }
1112574
@Override
	public void execute(ExecutionContext context){

		final String[] args = context.getArguments();
		
		String clusterValue = getArgumentValue(ARG_CLUSTER_NAME,args,null); 

		if(clusterValue != null){
			// Add all the arguments which need to be validated	
			this.createCollectiveArgumentsValues();
			this.validateArgumentList(args, true);
			
			String serverValues = getArgumentValue(ARG_SERVER_ADDRESS, args, null);
			if(serverValues == null){
				throw new IllegalArgumentException(getMessage(MISSING_VALUE_MSG , 
						"["+ARG_SERVER_ADDRESS + "]"));
			}

			String targetPathValue = getArgumentValue(ARG_OPT_TARGET_PATH, args, null);

			GeneratePluginForCollective collectiveTask = 
					new GeneratePluginForCollective(serverValues, clusterValue ,targetPathValue,commandConsole);
			ParseLoginAddress controllerAddress = null;
			try {
				controllerAddress = collectiveTask.parseCollectiveAddressValue();
			} catch (IllegalArgumentException e) {
				throw e;
			}		
			invokeGeneratePluginCfgMBean(controllerAddress, collectiveTask.getCluster(),targetPathValue,"collective");		
		}
		else{
			// Add all the arguments which need to be validated	
			this.createServerArgumentsValues();
			String serverValues = getArgumentValue(ARG_SERVER_ADDRESS, args, null);
			if(serverValues == null){
				throw new IllegalArgumentException(getMessage(MISSING_VALUE_MSG , 
						"["+ARG_SERVER_ADDRESS + "]" ));
			}

			this.validateArgumentList(args, true);

			String targetPathValue = getArgumentValue(ARG_OPT_TARGET_PATH, args, null);			
			GeneratePluginForServer serverTask = 
					new GeneratePluginForServer(serverValues, targetPathValue, commandConsole);
			ParseLoginAddress serverAddress = null;
			try {
				serverAddress = serverTask.parseServerAddressValue();
			} catch (IllegalArgumentException e) {
				throw e;
			}
			this.invokeGeneratePluginCfgMBean(serverAddress, null, targetPathValue,"server");
		}
		
	
	}
773886
final public function execute($command, AnCommandContext $context)
    {
        $identifier = $context->caller->getIdentifier();

        if ($context->entity instanceof AnDomainEntityAbstract) {
            $identifier = $context->entity->getIdentifier();
        }

        $type = $identifier->path;
        $type = array_pop($type);

        $parts = explode('.', $command);
        $method = '_'.($parts[0]).ucfirst($type).ucfirst($parts[1]);

        $result = null;

        if (method_exists($this, $method)) {
            $result = $this->$method($context);
        }

        if ($context->entity) {
            $result = $context->entity->execute($command, $context);
        }

        return $result;
    }
844189
public void writeCommand(Command command) throws Exception {

        checkConnected();

        switch (command.getKind()) {
        case PREPARE:
            writeCommand((PrepareCommand) command);
            break;
        case START:
            writeCommand((StartCommand) command);
            break;
        case ABORT:
            writeCommand((AbortCommand) command);
            break;
        case AWAIT:
            writeCommand((AwaitCommand) command);
            break;
        case NOTIFY:
            writeCommand((NotifyCommand) command);
            break;
        case CLOSE:
            writeCommand((CloseCommand) command);
            break;
        default:
            throw new IllegalArgumentException("Urecognized command kind: " + command.getKind());
        }
    }
40049
public void execute() {
    try {
      Command command = new Parser().parse();
      try {
        command.execute(new ContextImpl(), execute);
        close();
      } catch (Exception e) {
        throw new RuntimeException(
            "Error while executing command " + command, e);
      } catch (AssertionError e) {
        throw new RuntimeException(
            "Error while executing command " + command, e);
      }
    } finally {
      try {
        reader.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
      writer.close();
      try {
        close();
      } catch (SQLException e) {
        // ignore
      }
    }
  }
765551
protected void fireCommandRegistered(AbstractCommand command) {
        
        Assert.notNull(command, "command");
        
        if (commandRegistryListeners.isEmpty()) {
            return;
        }
        
        CommandRegistryEvent event = new CommandRegistryEvent(this, command);
        
        for (Iterator i = commandRegistryListeners.iterator(); i.hasNext();) {
            ((CommandRegistryListener)i.next()).commandRegistered(event);
        }
        
    }
876070
private void validateCommandResult(ZooCommand command, TestContext context) {
        Message commandResult = getCommandResult(command);

        extractVariables(commandResult, context);

        if (log.isDebugEnabled()) {
            log.debug("Validating Zookeeper response");
        }

        if (StringUtils.hasText(expectedCommandResult)) {
            assertResultExists(commandResult);
            JsonMessageValidationContext validationContext = new JsonMessageValidationContext();
            jsonTextMessageValidator.validateMessage(commandResult, new DefaultMessage(expectedCommandResult), context, validationContext);
        }

        if (jsonPathMessageValidationContext != null) {
            assertResultExists(commandResult);
            jsonPathMessageValidator.validateMessage(commandResult, null, context, jsonPathMessageValidationContext);
        }

        log.info("Zookeeper command result validation successful - all values OK!");

        if (command.getResultCallback() != null) {
            command.getResultCallback().doWithCommandResult(command.getCommandResult(), context);
        }
    }
189104
void launchTaskJVM(TaskController.TaskControllerContext context) 
                                      throws IOException {
    JvmEnv env = context.env;
    List<String> wrappedCommand = 
      TaskLog.captureOutAndError(env.setup, env.vargs, env.stdout, env.stderr,
          env.logSize, true);
    ShellCommandExecutor shexec = 
        new ShellCommandExecutor(wrappedCommand.toArray(new String[0]), 
                                  env.workDir, env.env);
    // set the ShellCommandExecutor for later use.
    context.shExec = shexec;
    shexec.execute();
  }
983588
protected void execute(Runnable command) throws RejectedExecutionException
    {
        if (isDie())
        {
            logger.warn("AgiServer is shutting down: Refused to execute AgiScript");
            return;
        }

        getPool().execute(command);
    }
754351
public String executeCommandOnServlet(String command) {
    try {
      return getCommandResponseAsString(command);
    } catch (IOException e) {
      if (e instanceof ConnectException) {
        throw new SeleniumException(e.getMessage(), e);
      }
      e.printStackTrace();
      throw new UnsupportedOperationException("Catch body broken: IOException from " + command +
          " -> " + e, e);
    }
  }
568434
public static void killProcess(String pid) {

    //If process tree is not alive then return immediately.
    if(!ProcessTree.isAlive(pid)) {
      return;
    }
    String[] args = { "kill", "-9", pid };
    ShellCommandExecutor shexec = new ShellCommandExecutor(args);
    try {
      shexec.execute();
    } catch (IOException e) {
      LOG.warn("Error sending SIGKILL to process "+ pid + " ."+ 
          StringUtils.stringifyException(e));
    } finally {
      LOG.info("Killing process " + pid + " with SIGKILL. Exit code "
          + shexec.getExitCode());
    }
  }
217184
protected void execute(EntityManagerCommand command) {
        try {
            getEntityManagerCommandExecutor().execute(command);
        } catch (javax.persistence.PersistenceException e) {
            throw new PersistenceException(e);
        }
    }
1090467
@Override
    public boolean sendCommand(String command) {
        try {
            sendCommand2(command);
        } catch (Exception ex) {
            logger.error("Could not run command " + command, ex);
            return false;
        }
        return true;
    }
537201
public void run(Context context) throws IOException, InterruptedException {
    setup(context);
    while (context.nextKey()) {
      context.progress();
      reduce(context.getCurrentKey(), context.getValues(), context);
    }
    cleanup(context);
  }
975273
@Override
    public String sendCommand2(String command) throws IOException {
        String str = null;
        SshConnection ssh = null;
        try {
            ssh = SshConnectionFactory.getConnection(config.getGerritHostName(),
                    config.getGerritSshPort(), config.getGerritProxy(), config.getGerritAuthentication());
            str = ssh.executeCommand(command);
        } catch (Exception ex) {
            throw new IOException("Error during sending command", ex);
        } finally {
            if (ssh != null) {
                ssh.disconnect();
            }
        }
        return str;
    }
149072
@CommandHandler
    public void handle(RequestStartTransactionRejectedCommand command) {
        apply(new RequestStartTransactionRejectedEvent(command.getChargingStationId(), command.getEvseId(), command.getIdentifyingToken(), command.getIdentityContext()));
    }
359250
private String executeCommand(String command) {
        System.out.println("Execute: " + command);

        StringBuilder output = new StringBuilder();
        Process       p;
        try {
            p = Runtime.getRuntime().exec(command);
            p.waitFor();
            BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
            String         line;
            while ((line = reader.readLine()) != null) {
                output.append(line).append("\n");
            }
        } catch (Exception e) {
            throw new WebpIOException(e);
        }
        if (!"".equals(output.toString())) {
            System.out.println("Output: " + output);
        }
        return "";
    }