Java Code Examples for org.apache.mesos.Protos#ExecutorID

The following examples show how to use org.apache.mesos.Protos#ExecutorID . 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: ClusterState.java    From elasticsearch with Apache License 2.0 6 votes vote down vote up
public TaskInfo getTask(Protos.ExecutorID executorID) throws IllegalArgumentException {
    if (executorID.getValue().isEmpty()) {
        throw new IllegalArgumentException("ExecutorID.value() is blank. Cannot be blank.");
    }
    List<TaskInfo> taskInfoList = getTaskList();
    TaskInfo taskInfo = null;
    for (TaskInfo info : taskInfoList) {
        if (info.getExecutor().getExecutorId().getValue().equals(executorID.getValue())) {
            taskInfo = info;
            break;
        }
    }
    if (taskInfo == null) {
        throw new IllegalArgumentException("Could not find executor with that executor ID: " + executorID.getValue());
    }
    return taskInfo;
}
 
Example 2
Source File: MesosResourceManager.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void frameworkMessage(SchedulerDriver driver, final Protos.ExecutorID executorId, final Protos.SlaveID slaveId, final byte[] data) {
	runAsync(new Runnable() {
		@Override
		public void run() {
			MesosResourceManager.this.frameworkMessage(new FrameworkMessage(executorId, slaveId, data));
		}
	});
}
 
Example 3
Source File: MesosScheduler.java    From twister2 with Apache License 2.0 5 votes vote down vote up
@Override
public void frameworkMessage(SchedulerDriver schedulerDriver,
                             Protos.ExecutorID executorID, Protos.SlaveID slaveID, byte[] bytes) {
  // System.out.println("Received message (scheduler): " + new String(bytes)
  //    + " from " + executorID.getValue());
  LOG.info("Executor id:" + executorID.getValue()
      + " Time: " + Longs.fromByteArray(bytes));
}
 
Example 4
Source File: ExecutorEvaluationStage.java    From dcos-commons with Apache License 2.0 5 votes vote down vote up
@Override
public EvaluationOutcome evaluate(
    MesosResourcePool mesosResourcePool,
    PodInfoBuilder podInfoBuilder)
{
  if (!podInfoBuilder.getExecutorBuilder().isPresent()) {
    return EvaluationOutcome
        .pass(this, "No executor requirement defined")
        .build();
  }

  String idStr = id.isPresent() ? id.get().getValue() : "";

  if (!hasExpectedExecutorId(mesosResourcePool.getOffer())) {
    return EvaluationOutcome
        .fail(this, "Offer does not contain the needed Executor ID: '%s'", idStr)
        .build();
  }

  Protos.ExecutorInfo.Builder executorBuilder = podInfoBuilder.getExecutorBuilder().get();
  if (id.isPresent()) {
    executorBuilder.setExecutorId(id.get());
    return EvaluationOutcome.pass(
        this,
        "Offer contains the matching Executor ID: '%s'", idStr)
        .build();
  } else {
    Protos.ExecutorID executorID =
        CommonIdUtils.toExecutorId(serviceName, executorBuilder.getName());
    executorBuilder.setExecutorId(executorID);
    return EvaluationOutcome.pass(
        this,
        "No Executor ID required, generated: '%s'",
        executorID.getValue()).build();
  }
}
 
Example 5
Source File: CommonIdUtilsTest.java    From dcos-commons with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultiToUnderscoreExecutorName() throws Exception {
    Protos.ExecutorID validExecutorId = getExecutorId(TEST_OTHER_NAME + "___id");
    Assert.assertEquals(TEST_OTHER_NAME + "_", CommonIdUtils.toExecutorName(validExecutorId));
    Assert.assertFalse(CommonIdUtils.toSanitizedServiceName(validExecutorId).isPresent());

    validExecutorId = getExecutorId("_" + TEST_OTHER_NAME + "___id");
    Assert.assertEquals("_" + TEST_OTHER_NAME + "_", CommonIdUtils.toExecutorName(validExecutorId));
    Assert.assertFalse(CommonIdUtils.toSanitizedServiceName(validExecutorId).isPresent());
}
 
Example 6
Source File: MesosResourceManager.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void executorLost(SchedulerDriver driver, final Protos.ExecutorID executorId, final Protos.SlaveID slaveId, final int status) {
	runAsync(new Runnable() {
		@Override
		public void run() {
			MesosResourceManager.this.executorLost(new ExecutorLost(executorId, slaveId, status));
		}
	});
}
 
Example 7
Source File: CassandraCluster.java    From cassandra-mesos-deprecated with Apache License 2.0 5 votes vote down vote up
public void updateCassandraProcess(@NotNull final Protos.ExecutorID executorId, @NotNull final CassandraServerRunMetadata cassandraServerRunMetadata) {
    final Optional<CassandraNode> node = cassandraNodeForExecutorId(executorId.getValue());
    if (node.isPresent()) {
        clusterState.addOrSetNode(CassandraFrameworkProtos.CassandraNode.newBuilder(node.get())
            .setCassandraDaemonPid(cassandraServerRunMetadata.getPid())
            .build());
    }
}
 
Example 8
Source File: ExecutorUtils.java    From cassandra-mesos-deprecated with Apache License 2.0 5 votes vote down vote up
@NotNull
static Protos.TaskStatus taskStatus(
    @NotNull final Protos.ExecutorID executorId,
    @NotNull final Protos.TaskID taskId,
    @NotNull final Protos.TaskState state,
    @NotNull final CassandraFrameworkProtos.SlaveStatusDetails details
) {
    return Protos.TaskStatus.newBuilder()
        .setExecutorId(executorId)
        .setTaskId(taskId)
        .setState(state)
        .setSource(Protos.TaskStatus.Source.SOURCE_EXECUTOR)
        .setData(ByteString.copyFrom(details.toByteArray()))
        .build();
}
 
Example 9
Source File: FrameworkMessage.java    From flink with Apache License 2.0 4 votes vote down vote up
public Protos.ExecutorID executorId() {
	return executorId;
}
 
Example 10
Source File: OfferEvaluator.java    From dcos-commons with Apache License 2.0 4 votes vote down vote up
public List<OfferEvaluationStage> getEvaluationPipeline(
    PodInstanceRequirement podInstanceRequirement,
    Collection<Protos.TaskInfo> allTasks,
    Map<String, Protos.TaskInfo> thisPodTasks) throws IOException
{

  boolean noLaunchedTasksExist = thisPodTasks.values().stream()
      .flatMap(taskInfo -> taskInfo.getResourcesList().stream())
      .map(ResourceUtils::getResourceId)
      .filter(Optional::isPresent)
      .map(Optional::get)
      .allMatch(String::isEmpty);

  boolean allTasksPermanentlyFailed = thisPodTasks.size() > 0 &&
      thisPodTasks.values().stream().allMatch(FailureUtils::isPermanentlyFailed);

  final String description;
  final boolean shouldGetNewRequirement;
  if (podInstanceRequirement.getRecoveryType().equals(RecoveryType.PERMANENT) || allTasksPermanentlyFailed) {
    description = "failed";
    shouldGetNewRequirement = true;
  } else if (noLaunchedTasksExist) {
    description = "new";
    shouldGetNewRequirement = true;
  } else {
    description = "existing";
    shouldGetNewRequirement = false;
  }
  logger.info("Generating requirement for {} pod '{}' containing tasks: {}",
      description,
      podInstanceRequirement.getPodInstance().getName(),
      podInstanceRequirement.getTasksToLaunch());

  // Only create a TLS Evaluation Stage builder if the service actually uses TLS certs.
  // This avoids performing TLS cert generation in cases where the cluster may not support it (e.g. DC/OS Open).
  boolean anyTasksWithTLS = podInstanceRequirement.getPodInstance().getPod().getTasks().stream()
      .anyMatch(taskSpec -> !taskSpec.getTransportEncryption().isEmpty());
  Optional<TLSEvaluationStage.Builder> tlsStageBuilder = anyTasksWithTLS
      ? Optional.of(new TLSEvaluationStage.Builder(serviceName, schedulerConfig))
      : Optional.empty();

  List<OfferEvaluationStage> evaluationPipeline = new ArrayList<>();
  if (shouldGetNewRequirement) {
    evaluationPipeline.addAll(getNewEvaluationPipeline(podInstanceRequirement, allTasks, tlsStageBuilder));
  } else {
    Protos.ExecutorInfo executorInfo = getExecutorInfo(podInstanceRequirement, thisPodTasks.values());

    // An empty ExecutorID indicates we should use a new Executor, otherwise we should attempt to launch
    // tasks on an already running Executor.
    String executorIdString = executorInfo.getExecutorId().getValue();
    Optional<Protos.ExecutorID> executorID = executorIdString.isEmpty() ?
        Optional.empty() :
        Optional.of(executorInfo.getExecutorId());

    evaluationPipeline.add(new ExecutorEvaluationStage(serviceName, executorID));
    evaluationPipeline.addAll(getExistingEvaluationPipeline(
        podInstanceRequirement, thisPodTasks, allTasks, executorInfo, tlsStageBuilder));
  }

  return evaluationPipeline;
}
 
Example 11
Source File: SchedulerEngine.java    From shardingsphere-elasticjob-cloud with Apache License 2.0 4 votes vote down vote up
@Override
public void executorLost(final SchedulerDriver schedulerDriver, final Protos.ExecutorID executorID, final Protos.SlaveID slaveID, final int i) {
    log.warn("call executorLost slaveID is: {}, executorID is: {}", slaveID, executorID);
}
 
Example 12
Source File: SchedulerProxy.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void frameworkMessage(SchedulerDriver driver, Protos.ExecutorID executorId, Protos.SlaveID slaveId, byte[] data) {
	mesosActor.tell(new FrameworkMessage(executorId, slaveId, data), ActorRef.noSender());
}
 
Example 13
Source File: FrameworkMessage.java    From flink with Apache License 2.0 4 votes vote down vote up
public Protos.ExecutorID executorId() {
	return executorId;
}
 
Example 14
Source File: FrameworkMessage.java    From flink with Apache License 2.0 4 votes vote down vote up
public FrameworkMessage(Protos.ExecutorID executorId, Protos.SlaveID slaveId, byte[] data) {
	this.executorId = executorId;
	this.slaveId = slaveId;
	this.data = data;
}
 
Example 15
Source File: SimulatedLocalMesosSchedulerDriver.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
@Override
public Status sendFrameworkMessage(Protos.ExecutorID executorId, Protos.SlaveID slaveId, byte[] data) {
    throw new IllegalStateException("method not implemented");
}
 
Example 16
Source File: CommonIdUtilsTest.java    From dcos-commons with Apache License 2.0 4 votes vote down vote up
@Test
public void testMultiValidToEmptyExecutorName() throws Exception {
    Protos.ExecutorID validExecutorId = getExecutorId(TEST_OTHER_NAME + "____id");
    Assert.assertEquals("", CommonIdUtils.toExecutorName(validExecutorId));
    Assert.assertEquals(TEST_OTHER_NAME, CommonIdUtils.toSanitizedServiceName(validExecutorId).get());
}
 
Example 17
Source File: AbstractCassandraSchedulerTest.java    From cassandra-mesos-deprecated with Apache License 2.0 4 votes vote down vote up
protected static Protos.ExecutorID executorId(final Protos.TaskInfo taskInfo) {
    return taskInfo.getExecutor().getExecutorId();
}
 
Example 18
Source File: CommonIdUtils.java    From dcos-commons with Apache License 2.0 2 votes vote down vote up
/**
 * Converts the unique {@link Protos.ExecutorID} into a Framework defined executor name.
 * <p>
 * For example: "path.to.service__instance-0__aoeu5678" => "instance-0"
 *
 * @see #toExecutorId(String)
 */
public static String toExecutorName(Protos.ExecutorID executorId) throws TaskException {
  return extractTaskNameFromId(executorId.getValue());
}
 
Example 19
Source File: HelloWorldScheduler.java    From tutorials with MIT License 2 votes vote down vote up
@Override
public void executorLost(SchedulerDriver schedulerDriver, Protos.ExecutorID executorID, Protos.SlaveID slaveID, int i) {

}
 
Example 20
Source File: CommonIdUtils.java    From dcos-commons with Apache License 2.0 2 votes vote down vote up
/**
 * Converts the Framework defined Executor name into a unique {@link Protos.ExecutorID}.
 * <p>
 * For example: "/path/to/service" + "instance-0" => "path.to.service__instance-0__aoeu5678"
 *
 * @throws IllegalArgumentException if the provided {@code serviceName} or {@code taskName} contain "__"
 * @see #toExecutorName(org.apache.mesos.Protos.ExecutorID)
 * @see #toSanitizedServiceName(org.apache.mesos.Protos.ExecutorID)
 */
public static Protos.ExecutorID toExecutorId(String serviceName, String executorName)
    throws IllegalArgumentException
{
  return Protos.ExecutorID.newBuilder().setValue(toIdString(serviceName, executorName)).build();
}