Executes a remotely received command, repairs it when necessary and resends repaired versions of local commands
that where obsoleted by the received command.

@param command
The command to execute.
483553
@SuppressWarnings({ "rawtypes", "unchecked" })
    // The alternative would be to change the TopologolyLayerCallback.send() to take List<? extends Command>
    private void execute(final ListCommand command) {
        getMetaData(command);

        final Queue<ListCommand> log = metaData.getUnapprovedCommands();
        if (log.isEmpty()) {
            updateVersion(command);
            executeCommand(command);
        } else if (log.peek().getListVersionChange().equals(command.getListVersionChange())) {
            updateVersion(command);
            log.remove();
        } else {
            // repair indices
            List<? extends ListCommand> repairedCommands = indexRepairer.repairCommands(
                    metaData.getUnapprovedCommands(), command);

            // repair versions if local commands are left after repairing indices.
            versionRepairer.repairLocalCommandsVersion(metaData.getUnapprovedCommands(), command);
            repairedCommands = versionRepairer.repairRemoteCommandVersion(repairedCommands,
                    metaData.getUnapprovedCommandsAsList());
            // re-send repaired local changes
            topologyLayerCallback.sendCommands((List) metaData.getUnapprovedCommandsAsList());

            // execute repaired commands
            for (final ListCommand repaired : repairedCommands) {
                executeCommand(repaired);
            }
            updateVersion(command);
        }
    }
85144
protected static String runCommand(String... command) {
		try {
			final Process p = Runtime.getRuntime().exec(command);
			if (p == null) {
				return null;
			}
			final StringBuilder bStr = new StringBuilder();
			try (InputStream standardOutput = p.getInputStream()) {
				final byte[] buffer = new byte[BUFFER_SIZE];
				int len;
				while ((len = standardOutput.read(buffer)) > 0) {
					bStr.append(new String(buffer, 0, len));
				}
				p.waitFor();
				return bStr.toString();
			}
		} catch (Exception e) {
			return null;
		}
	}
217184
protected void execute(EntityManagerCommand command) {
        try {
            getEntityManagerCommandExecutor().execute(command);
        } catch (javax.persistence.PersistenceException e) {
            throw new PersistenceException(e);
        }
    }
689994
public <T extends KubernetesCommand> T command(T command) {
		action.setCommand(command);
		return command;
	}
155154
def _exec_command(self, command: str):
        
        stdin, stdout, stderr = self._ssh.exec_command(command)
        # Clearing the buffers
        stdout.read()
        stderr.read()
        stdin.close()
203343
public static String command(Command command) throws Exception {
        // Check Service
        if (!IS_BIND)
            bindService();

        // Return
        try {
            return commandRun(command);
        } catch (Exception e) {
            e.printStackTrace();
            restart();
            throw e;
        }
    }
385972
protected void firePressed(Command command) {
		getState(command).down = true;
		getState(command).pressed = true;

		if (!isActive()) {
			return;
		}

		for (int i = 0; i < listeners.size(); i++) {
			((InputProviderListener) listeners.get(i)).controlPressed(command);
		}
	}
865609
private void deliverSyncCommand(byte command) {
        for (final SyncListener listener : getSyncListeners()) {
            try {
                switch (command) {

                    case 0x01:
                        listener.becomeMaster();

                    case 0x10:
                       listener.setSyncMode(true);
                       break;

                    case 0x20:
                        listener.setSyncMode(false);
                        break;

                }
            } catch (Throwable t) {
                logger.warn("Problem delivering sync command to listener", t);
            }
        }
    }
917270
def exec(command)
      remote_shell do |shell|
        shell.cd(shell.uri.path)
        shell.exec(command)
      end

      return true
    end
800195
public void addCommand(Command command) {
        if(command == null)
            throw new IllegalArgumentException();

        if(_frozen)
            throw new IllegalStateException();

        Command[] results = new Command[_commands.length + 1];
        System.arraycopy(_commands, 0, results, 0, _commands.length);
        results[_commands.length] = command;
        _commands = results;
    }
957999
public void process(final T command) {
        boolean traceStarted = false;
        incrementCommandsProcessed();
		DehydratedExecutionContext ctx = null;
		try {
            validateCommand(command);
			CommandResolver<T> resolver = createCommandResolver(command, tracer);
			ctx = resolver.resolveExecutionContext();
            List<ExecutionCommand> executionCommands = resolver.resolveExecutionCommands();
            if (executionCommands.size() > 1) {
                throw new CougarFrameworkException("Resolved >1 command in a non-batch call!");
            }
            ExecutionCommand exec = executionCommands.get(0);
            tracer.start(ctx.getRequestUUID(), exec.getOperationKey());
            traceStarted = true;
			executeCommand(exec, ctx);
		} catch(CougarException ce) {
            executeError(command, ctx, ce, traceStarted);
		} catch (Exception e) {
            executeError(command, ctx, new CougarFrameworkException("Unexpected exception while processing transport command", e), traceStarted);
		}
	}
35452
private void executeCommand(long index, long sequence, long timestamp, ServerCommit commit, ServerSessionContext session, CompletableFuture<Result> future, ThreadContext context) {
    if (!log.isOpen()) {
      context.executor().execute(() -> future.completeExceptionally(new IllegalStateException("log closed")));
      return;
    }

    // If the session is already in an inactive state, complete the future exceptionally.
    if (!session.state().active()) {
      context.executor().execute(() -> future.completeExceptionally(new UnknownSessionException("inactive session: " + session.id())));
      return;
    }

    // Trigger scheduled callbacks in the state machine.
    executor.tick(index, timestamp);

    // Update the state machine context with the commit index and local server context. The synchronous flag
    // indicates whether the server expects linearizable completion of published events. Events will be published
    // based on the configured consistency level for the context.
    executor.init(commit.index(), commit.time(), ServerStateMachineContext.Type.COMMAND);

    // Store the event index to return in the command response.
    long eventIndex = session.getEventIndex();

    try {
      // Execute the state machine operation and get the result.
      Object output = executor.executeOperation(commit);

      // Once the operation has been applied to the state machine, commit events published by the command.
      // The state machine context will build a composite future for events published to all sessions.
      executor.commit();

      // Store the result for linearizability and complete the command.
      Result result = new Result(index, eventIndex, output);
      session.registerResult(sequence, result);
      context.executor().execute(() -> future.complete(result));
    } catch (Exception e) {
      // If an exception occurs during execution of the command, store the exception.
      Result result = new Result(index, eventIndex, e);
      session.registerResult(sequence, result);
      context.executor().execute(() -> future.complete(result));
    }
  }
755998
public void run(
      List<String> command,
      @Nullable Path workingDirectory,
      @Nullable Map<String, String> environment,
      ConsoleListener consoleListener)
      throws InterruptedException, CommandExitException, CommandExecutionException {
    ProcessExecutor processExecutor = processExecutorFactory.newProcessExecutor();
    try {
      int exitCode =
          processExecutor.run(
              command,
              workingDirectory,
              environment,
              streamHandlerFactory.newHandler(consoleListener),
              streamHandlerFactory.newHandler(consoleListener));
      if (exitCode != 0) {
        throw new CommandExitException(exitCode);
      }
    } catch (IOException ex) {
      throw new CommandExecutionException(ex);
    }
  }
91683
@Override
    public String sendCommandStr(String command) {
        String str = null;
        try {
            str = sendCommand2(command);
        } catch (Exception ex) {
            logger.error("Could not run command " + command, ex);
        }
        return str;
    }
953890
@Override
    protected <T> CompletableFuture<T> doExecute(Command<T> command) throws Exception {
        final CompletableFuture<T> future = new CompletableFuture<>();
        executor.execute(() -> {
            try {
                future.complete(blockingExecute(command));
            } catch (Throwable t) {
                future.completeExceptionally(t);
            }
        });
        return future;
    }
1219342
public void setCommands(java.util.Collection<Command> commands) {
        if (commands == null) {
            this.commands = null;
            return;
        }

        this.commands = new com.amazonaws.internal.SdkInternalList<Command>(commands);
    }
175084
@CommandHandler
    public void handle(RequestStopTransactionRejectedCommand command) {
        apply(new RequestStopTransactionRejectedEvent(command.getChargingStationId(), command.getTransactionId(), command.getIdentityContext()));
    }