Prepare a parallel UDP Task.

@param command
the command
@return the parallel task builder
965025
public ParallelTaskBuilder prepareUdp(String command) {
        reinitIfClosed();
        ParallelTaskBuilder cb = new ParallelTaskBuilder();
        cb.setProtocol(RequestProtocol.UDP);
        cb.getUdpMeta().setCommand(command);
        return cb;
    }
1211682
public <T> CompletableFuture<T> submit(Command<T> command) {
    State state = state();
    if (state == State.CLOSED || state == State.EXPIRED) {
      return Futures.exceptionalFuture(new ClosedSessionException("session closed"));
    }
    return submitter.submit(command);
  }
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());
        }
    }
803920
public static String[] partitionCommandLine(final String command) {
    final ArrayList<String> commands = new ArrayList<>();

    int index = 0;

    StringBuffer buffer = new StringBuffer(command.length());

    boolean isApos = false;
    boolean isQuote = false;
    while (index < command.length()) {
      final char c = command.charAt(index);

      switch (c) {
        case ' ':
          if (!isQuote && !isApos) {
            final String arg = buffer.toString();
            buffer = new StringBuffer(command.length() - index);
            if (arg.length() > 0) {
              commands.add(arg);
            }
          } else {
            buffer.append(c);
          }
          break;
        case '\'':
          if (!isQuote) {
            isApos = !isApos;
          } else {
            buffer.append(c);
          }
          break;
        case '"':
          if (!isApos) {
            isQuote = !isQuote;
          } else {
            buffer.append(c);
          }
          break;
        default:
          buffer.append(c);
      }

      index++;
    }

    if (buffer.length() > 0) {
      final String arg = buffer.toString();
      commands.add(arg);
    }

    return commands.toArray(new String[commands.size()]);
  }
880417
public void enqueue(TargetTransportPort port, Command command)
   {
      long lun = command.getNexus().getLogicalUnitNumber();

      if (lun < 0)
      {
         try
         {
            Task task = this.taskFactory.getInstance(port, command);
            assert task != null : "improper task factory implementation returned null task";
            this.targetTaskSet.offer(task); // non-blocking, sends any errors to transport port
            if (_logger.isDebugEnabled())
               _logger.debug("successfully enqueued target command with TaskRouter: " + command);
         }
         catch (IllegalRequestException e)
         {
            _logger.error("error when parsing command: " + e);
            port.writeResponse(command.getNexus(), command.getCommandReferenceNumber(),
                  Status.CHECK_CONDITION, ByteBuffer.wrap(e.encode()));
         }
      }
      else if (logicalUnitMap.containsKey(lun))
      {
         logicalUnitMap.get(lun).enqueue(port, command);
         if (_logger.isDebugEnabled())
            _logger.debug("successfully enqueued command to logical unit with TaskRouter: "
                  + command);
      }
      else
      {
         port.writeResponse(command.getNexus(), command.getCommandReferenceNumber(),
               Status.CHECK_CONDITION,
               ByteBuffer.wrap((new LogicalUnitNotSupportedException()).encode()));
      }
   }
1047176
private void prepareCustomExecutor(final TaskInfo.Builder bldr, final SingularityTaskId taskId, final SingularityTaskRequest task, final SingularityOfferHolder offerHolder,
      final Optional<long[]> ports, final Resources desiredExecutorResources) {
    CommandInfo.Builder commandBuilder = CommandInfo.newBuilder().setValue(task.getDeploy().getCustomExecutorCmd().get());

    prepareEnvironment(task, taskId, commandBuilder, offerHolder, ports);

    if (task.getDeploy().getUser().isPresent()) {
      commandBuilder.setUser(task.getDeploy().getUser().get());
    }

    prepareMesosUriDownloads(task.getPendingTask().getExtraArtifacts(), commandBuilder);

    bldr.setExecutor(ExecutorInfo.newBuilder()
        .setCommand(commandBuilder.build())
        .setExecutorId(ExecutorID.newBuilder().setValue(task.getDeploy().getCustomExecutorId().or(idGenerator.getNextExecutorId())))
        .setSource(task.getDeploy().getCustomExecutorSource().or(taskId.getId())) // set source to taskId for use in statistics endpoint, TODO: remove
        .setLabels(Labels.newBuilder().addLabels(Label.newBuilder().setKey("taskId").setValue(taskId.getId())))
        .addAllResources(buildMesosResources(desiredExecutorResources, task.getRequest().getRequiredRole()))
        .build()
        );

    if (task.getDeploy().getExecutorData().isPresent()) {
      final ExecutorDataBuilder executorDataBldr = task.getDeploy().getExecutorData().get().toBuilder();

      String defaultS3Bucket = "";
      String s3UploaderKeyPattern = "";

      if (configuration.getS3ConfigurationOptional().isPresent()) {
        if (task.getRequest().getGroup().isPresent() && configuration.getS3ConfigurationOptional().get().getGroupOverrides().containsKey(task.getRequest().getGroup().get())) {
          defaultS3Bucket = configuration.getS3ConfigurationOptional().get().getGroupOverrides().get(task.getRequest().getGroup().get()).getS3Bucket();
          LOG.trace("Setting defaultS3Bucket to {} for task {} executorData", defaultS3Bucket, taskId.getId());
        } else {
          defaultS3Bucket = configuration.getS3ConfigurationOptional().get().getS3Bucket();
        }
        s3UploaderKeyPattern = configuration.getS3ConfigurationOptional().get().getS3KeyFormat();
      }

      if (task.getPendingTask().getCmdLineArgsList().isPresent() && !task.getPendingTask().getCmdLineArgsList().get().isEmpty()) {
        LOG.trace("Adding cmd line args {} to task {} executorData", task.getPendingTask().getCmdLineArgsList(), taskId.getId());

        final ImmutableList.Builder<String> extraCmdLineArgsBuilder = ImmutableList.builder();
        if (executorDataBldr.getExtraCmdLineArgs() != null && !executorDataBldr.getExtraCmdLineArgs().isEmpty()) {
          extraCmdLineArgsBuilder.addAll(executorDataBldr.getExtraCmdLineArgs());
        }
        extraCmdLineArgsBuilder.addAll(task.getPendingTask().getCmdLineArgsList().get());
        executorDataBldr.setExtraCmdLineArgs(extraCmdLineArgsBuilder.build());
      }

      List<SingularityS3UploaderFile> uploaderAdditionalFiles = new ArrayList<>();
      if (configuration.getS3ConfigurationOptional().isPresent()) {
        uploaderAdditionalFiles.addAll(configuration.getS3ConfigurationOptional().get().getS3UploaderAdditionalFiles());
      }
      uploaderAdditionalFiles.addAll(task.getPendingTask().getS3UploaderAdditionalFiles());
      uploaderAdditionalFiles.addAll(task.getDeploy().getS3UploaderAdditionalFiles());

      Optional<String> maybeS3StorageClass = configuration.getS3ConfigurationOptional().isPresent() ? configuration.getS3ConfigurationOptional().get().getS3StorageClass() : Optional.<String>absent();
      Optional<Long> maybeApplyAfterBytes = configuration.getS3ConfigurationOptional().isPresent() ? configuration.getS3ConfigurationOptional().get().getApplyS3StorageClassAfterBytes() : Optional.<Long>absent();

      if (task.getPendingTask().getRunAsUserOverride().isPresent()) {
        executorDataBldr.setUser(task.getPendingTask().getRunAsUserOverride());
      }

      Optional<HealthcheckOptions> healthcheckOptions = task.getRequest().getSkipHealthchecks().or(false) ? Optional.absent() : task.getDeploy().getHealthcheck();
      final SingularityTaskExecutorData executorData = new SingularityTaskExecutorData(executorDataBldr.build(), uploaderAdditionalFiles, defaultS3Bucket, s3UploaderKeyPattern,
          configuration.getCustomExecutorConfiguration().getServiceLog(), configuration.getCustomExecutorConfiguration().getServiceFinishedTailLog(), task.getRequest().getGroup(),
          maybeS3StorageClass, maybeApplyAfterBytes, getCpuHardLimit(task), healthcheckOptions);

      try {
        bldr.setData(ByteString.copyFromUtf8(objectMapper.writeValueAsString(executorData)));
      } catch (JsonProcessingException e) {
        LOG.warn("Unable to process executor data {} for task {} as json (trying as string)", executorData, taskId.getId(), e);

        bldr.setData(ByteString.copyFromUtf8(executorData.toString()));
      }
    } else if (task.getDeploy().getCommand().isPresent()) {
      bldr.setData(ByteString.copyFromUtf8(task.getDeploy().getCommand().get()));
    }
  }
1227326
public ParallelTaskBuilder prepareHttpHead(String url) {
        reinitIfClosed();
        ParallelTaskBuilder cb = new ParallelTaskBuilder();
        cb.getHttpMeta().setHttpMethod(HttpMethod.HEAD);
        cb.getHttpMeta().setRequestUrlPostfix(url);
        return cb;
    }
609946
public static KubernetesMessage response(String command, KubernetesResource<?> result) {
        KubernetesResponse response = new KubernetesResponse();
        response.setCommand(command);
        response.setResult(result);

        return new KubernetesMessage(response);
    }
97963
public static FtpMessage command(FTPCmd command) {
        Command cmd = new Command();
        cmd.setSignal(command.getCommand());
        return new FtpMessage(cmd);
    }
930898
public ProcessExecutor command(Iterable<String> command) {
    List<String> list = new ArrayList<String>();
    Iterator<String> it = command.iterator();
    while (it.hasNext()) {
      list.add(it.next());
    }
    return command(list);
  }
316159
public static LazyReact parallelBuilder(final int parallelism) {
        return LazyReact.builder()
                        .executor(Executors.newFixedThreadPool(parallelism))
                        .build();
    }
1123657
public function addTasks($command)
	{
		$this->addSection('Tasks');

		$class = new \ReflectionClass($command);
		$tasks = $class->getMethods(\ReflectionMethod::IS_PUBLIC);

		if ($tasks && count($tasks) > 0)
		{
			$list = [];
			$max  = 0;

			foreach ($tasks as $task)
			{
				if (!$task->isConstructor() && $task->name != 'execute' && $task->name != 'help')
				{
					$comment     = $task->getDocComment();
					$description = 'no description available';

					// Check for help ignore flag
					preg_match('/@museDescription ([[:alnum:] ,\.()\-\'\/]*)/', $comment, $matched);

					if ($matched && isset($matched[1]))
					{
						$description = trim($matched[1]);
					}

					$list[] = [
						'name'        => $task->name,
						'description' => $description
					];

					$max    = ($max > strlen($task->name)) ? $max : strlen($task->name);
				}
			}

			if (count($list) > 0)
			{
				foreach ($list as $item)
				{
					$this->addString($item['name'], [
						'color'       => 'blue',
						'indentation' => 2
					]);

					$this->addString(str_repeat(' ', ($max - strlen($item['name']))) . '   ');
					$this->addLine($item['description']);
				}
			}
			else
			{
				$this->addLine('There are no tasks available for this command', [
					'color'       => 'red',
					'indentation' => 2
				]);
			}
		}

		$this->addSpacer();

		return $this;
	}
341612
protected int runCommand(final CCTask task, final File workingDir, final String[] cmdline) throws BuildException {
    return CUtil.runCommand(task, workingDir, cmdline, this.newEnvironment, this.env);
  }
1226955
public synchronized void addCommand(final CommandImpl command) throws DevFailed {
        CommandImpl result = null;
        for (final CommandImpl cmd : commandList) {
            if (command.getName().equalsIgnoreCase(cmd.getName())) {
                result = command;
                break;
            }
        }
        if (result == null) {
            commandList.add(command);
            // set default polling configuration
            if (cmdPollRingDepth.containsKey(command.getName().toLowerCase(Locale.ENGLISH))) {
                command.setPollRingDepth(cmdPollRingDepth.get(command.getName().toLowerCase(Locale.ENGLISH)));
            } else {
                command.setPollRingDepth(pollRingDepth);
            }
        }
    }
1273280
public ProcessExecutor command(String... command) {
    builder.command(fixArguments(Arrays.asList(command)));
    return this;
  }
243073
public String execute(String... command) {
        return commandProcessor.run(aCommand("VBoxManage").withArguments(command)).getOutput();
    }
344214
public ScheduledFuture<?> schedule(Runnable command, TemporalAccessor time)
    {
        ensureWaiterRunning();
        log(logLevel, "schedule(%s, %s)", command, time);
        RunnableScheduledFutureImpl future = new RunnableScheduledFutureImpl(command, Instant.from(time), null, false);
        delayQueue.add(future);
        return future;
    }