.setExecutorId(ExecutorID.newBuilder().setValue(task.getDeploy().getCustomExecutorId().or(idGenerator.getNextExecutorId())))
.setSource(task.getDeploy().getCustomExecutorSource().or(task.getPendingTask().getPendingTaskId().getId()))
);
if (task.getDeploy().getExecutorData().isPresent()) {
ExecutorData executorData = task.getDeploy().getExecutorData().get();
if (task.getPendingTask().getMaybeCmdLineArgs().isPresent()) {
LOG.trace("Adding cmd line args {} to task {} executorData", task.getPendingTask().getMaybeCmdLineArgs().get(), taskId.getId());
ExecutorDataBuilder executorDataBldr = executorData.toBuilder();
final ImmutableList.Builder<String> extraCmdLineArgsBuilder = ImmutableList.builder();
if (executorDataBldr.getExtraCmdLineArgs() != null && !executorDataBldr.getExtraCmdLineArgs().isEmpty()) {
extraCmdLineArgsBuilder.addAll(executorDataBldr.getExtraCmdLineArgs());
}
extraCmdLineArgsBuilder.add(task.getPendingTask().getMaybeCmdLineArgs().get());
executorDataBldr.setExtraCmdLineArgs(extraCmdLineArgsBuilder.build());
executorData = executorDataBldr.build();
}
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 {
bldr.setData(ByteString.copyFromUtf8(getCommand(taskId, task)));
}
}