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

The following examples show how to use org.apache.mesos.Protos#FrameworkID . 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: MesosFrameworkTest.java    From incubator-heron with Apache License 2.0 6 votes vote down vote up
@Before
public void before() throws Exception {
  config = Mockito.mock(Config.class);
  Mockito.when(config.getStringValue(Key.TOPOLOGY_NAME)).thenReturn(TOPOLOGY_NAME);
  Mockito.when(config.getStringValue(Key.ROLE)).thenReturn(ROLE);
  Mockito.when(config.getStringValue(Key.CORE_PACKAGE_URI)).thenReturn(CORE_PACKAGE_URI);

  runtime = Mockito.mock(Config.class);
  Mockito.when(runtime.getLongValue(Key.NUM_CONTAINERS)).thenReturn(NUM_CONTAINER);
  Properties properties = new Properties();
  properties.put(Key.TOPOLOGY_PACKAGE_URI.value(), TOPOLOGY_PACKAGE_URI);
  Mockito.when(runtime.get(Key.SCHEDULER_PROPERTIES)).thenReturn(properties);

  mesosFramework = Mockito.spy(new MesosFramework(config, runtime));
  SchedulerDriver driver = Mockito.mock(SchedulerDriver.class);

  // Register the mesos framework
  Protos.FrameworkID frameworkID =
      Protos.FrameworkID.newBuilder().setValue("framework-id").build();
  mesosFramework.registered(driver, frameworkID, Protos.MasterInfo.getDefaultInstance());
}
 
Example 2
Source File: MesosResourceManager.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void registered(SchedulerDriver driver, final Protos.FrameworkID frameworkId, final Protos.MasterInfo masterInfo) {
	runAsync(new Runnable() {
		@Override
		public void run() {
			MesosResourceManager.this.registered(new Registered(frameworkId, masterInfo));
		}
	});
}
 
Example 3
Source File: NMTaskFactory.java    From incubator-myriad with Apache License 2.0 5 votes vote down vote up
@Override
public Protos.ExecutorInfo getExecutorInfoForSlave(ResourceOfferContainer resourceOfferContainer, Protos.FrameworkID frameworkId, Protos.CommandInfo commandInfo) {
  Protos.ExecutorID executorId = Protos.ExecutorID.newBuilder()
      .setValue(EXECUTOR_PREFIX + frameworkId.getValue() + resourceOfferContainer.getOfferId() +
          resourceOfferContainer.getSlaveId().getValue())
      .build();
  Protos.ExecutorInfo.Builder executorInfo = Protos.ExecutorInfo.newBuilder().setCommand(commandInfo).setName(EXECUTOR_NAME).setExecutorId(executorId)
      .addAllResources(resourceOfferContainer.consumeCpus(taskUtils.getExecutorCpus()))
      .addAllResources(resourceOfferContainer.consumeMem(taskUtils.getExecutorMemory()));
  if (cfg.getContainerInfo().isPresent()) {
    executorInfo.setContainer(getContainerInfo());
  }
  return executorInfo.build();

}
 
Example 4
Source File: ZooKeeperMesosWorkerStore.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * Update the persisted framework ID.
 * @param frameworkID the new ID or empty to remove the persisted ID.
 * @throws Exception on ZK failures, interruptions.
 */
@Override
public void setFrameworkID(Option<Protos.FrameworkID> frameworkID) throws Exception {
	synchronized (startStopLock) {
		verifyIsRunning();

		byte[] value = frameworkID.isDefined() ? frameworkID.get().getValue().getBytes(ConfigConstants.DEFAULT_CHARSET) :
			new byte[0];
		frameworkIdInZooKeeper.setValue(value);
	}
}
 
Example 5
Source File: CassandraScheduler.java    From dcos-cassandra-service with Apache License 2.0 5 votes vote down vote up
public void registerFramework() throws IOException {
    final SchedulerDriverFactory factory = new SchedulerDriverFactory();
    final CassandraSchedulerConfiguration targetConfig =
            (CassandraSchedulerConfiguration) defaultConfigurationManager.getTargetConfig();
    final ServiceConfig serviceConfig = targetConfig.getServiceConfig();
    final Optional<ByteString> secretBytes = serviceConfig.readSecretBytes();
    final Protos.FrameworkInfo.Builder builder = Protos.FrameworkInfo.newBuilder()
            .setRole(serviceConfig.getRole())
            .setUser(serviceConfig.getUser())
            .setName(targetConfig.getServiceConfig().getName())
            .setPrincipal(serviceConfig.getPrincipal())
            .setCheckpoint(serviceConfig.isCheckpoint())
            .setFailoverTimeout(serviceConfig.getFailoverTimeoutS());

    Optional<Protos.FrameworkID> frameworkID = stateStore.fetchFrameworkId();
    if (frameworkID.isPresent() && frameworkID.get().hasValue()) {
        builder.setId(frameworkID.get());
    } else {
        LOGGER.info("No framework id found");
    }

    final Protos.FrameworkInfo frameworkInfo = builder.build();

    if (secretBytes.isPresent()) {
        // Authenticated if a non empty secret is provided.
        setSchedulerDriver(factory.create(
                this,
                frameworkInfo,
                mesosConfig.toZooKeeperUrl(),
                secretBytes.get().toByteArray()));
    } else {
        setSchedulerDriver(factory.create(
                this,
                frameworkInfo,
                mesosConfig.toZooKeeperUrl()));
    }
    LOGGER.info("Starting driver...");
    final Protos.Status startStatus = this.driver.start();
    LOGGER.info("Driver started with status: {}", startStatus);
}
 
Example 6
Source File: HealthResource.java    From dcos-commons with Apache License 2.0 5 votes vote down vote up
private ServiceStatusEvaluationStage isServiceInitializing() {
  String reason;
  Optional<ServiceStatusCode> statusCode;
  Optional<Protos.FrameworkID> frameworkId;
  ServiceStatusCode initializing = ServiceStatusCode.INITIALIZING;
  if (frameworkStore.isPresent()) {
    try {
      // fetchFrameWorkId can throw a StateStoreException.
      frameworkId = frameworkStore.get().fetchFrameworkId();
    } catch (StateStoreException e) {
      // regardless of the exception thrown, consider service as not-initialized.
      frameworkId = Optional.empty();
    }
  } else {
    frameworkId = Optional.empty();
  }

  if (frameworkId.isPresent()) {
    reason = String.format("Priority %d. Status Code %s is FALSE. Registered with Framework ID %s.",
            initializing.priority,
            initializing.statusCode,
            frameworkId.get().getValue());
    statusCode = Optional.empty();
  } else {
    reason = String.format("Priority %d. Status Code %s is TRUE. Mesos registration pending, no Framework ID found.",
            initializing.priority,
            initializing.statusCode);
    statusCode = Optional.of(initializing);
  }

  return new ServiceStatusEvaluationStage(statusCode, reason);
}
 
Example 7
Source File: MesosResourceManager.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void registered(SchedulerDriver driver, final Protos.FrameworkID frameworkId, final Protos.MasterInfo masterInfo) {
	runAsync(new Runnable() {
		@Override
		public void run() {
			MesosResourceManager.this.registered(new Registered(frameworkId, masterInfo));
		}
	});
}
 
Example 8
Source File: MesosResourceManager.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void registered(SchedulerDriver driver, final Protos.FrameworkID frameworkId, final Protos.MasterInfo masterInfo) {
	runAsync(new Runnable() {
		@Override
		public void run() {
			MesosResourceManager.this.registered(new Registered(frameworkId, masterInfo));
		}
	});
}
 
Example 9
Source File: SchedulerProxy.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public void registered(SchedulerDriver driver, Protos.FrameworkID frameworkId, Protos.MasterInfo masterInfo) {
	mesosActor.tell(new Registered(frameworkId, masterInfo), ActorRef.noSender());
}
 
Example 10
Source File: PodInfoBuilder.java    From dcos-commons with Apache License 2.0 4 votes vote down vote up
public PodInfoBuilder(
    PodInstanceRequirement podInstanceRequirement,
    String serviceName,
    UUID targetConfigId,
    ArtifactQueries.TemplateUrlFactory templateUrlFactory,
    SchedulerConfig schedulerConfig,
    Collection<Protos.TaskInfo> currentPodTasks,
    Protos.FrameworkID frameworkID,
    Map<TaskSpec, GoalStateOverride> overrideMap) throws InvalidRequirementException
{
  PodInstance podInstance = podInstanceRequirement.getPodInstance();

  // Generate new TaskInfos based on the task spec. To keep things consistent, we always generate new TaskInfos
  // from scratch, with the only carry-over being any dynamic ports that were previously reserved, which is to
  // avoid having dynamic ports bounce around across relaunches.
  for (TaskSpec taskSpec : podInstance.getPod().getTasks()) {
    Protos.TaskInfo.Builder taskInfoBuilder = createTaskInfo(
        podInstance,
        taskSpec,
        podInstanceRequirement.getEnvironment(),
        serviceName,
        targetConfigId,
        templateUrlFactory,
        schedulerConfig,
        overrideMap.get(taskSpec));
    // Store tasks against the task spec name 'node' instead of 'broker-0-node': the pod segment is redundant
    // as we're only looking at tasks within a given pod
    this.taskBuilders.put(taskSpec.getName(), taskInfoBuilder);

    taskSpec.getResourceSet().getResources().stream()
        .filter(resourceSpec -> resourceSpec.getName().equals(Constants.PORTS_RESOURCE_TYPE))
        .filter(resourceSpec -> resourceSpec.getValue().getRanges().getRange(0).getBegin() > 0)
        .forEach(resourceSpec -> assignedOverlayPorts
            .add(resourceSpec.getValue().getRanges().getRange(0).getBegin()));

  }

  this.executorBuilder = getExecutorInfoBuilder(
      podInstance, frameworkID, targetConfigId, templateUrlFactory, schedulerConfig);

  this.podInstance = podInstance;
  this.portsByTask = new HashMap<>();
  for (Protos.TaskInfo currentTask : currentPodTasks) {
    // Just store against the full TaskInfo name ala 'broker-0-node'. The task spec name will be mapped to the
    // TaskInfo name in the getter function below. This is easier than extracting the task spec name from the
    // TaskInfo name, e.g. what if the pod type has dashes in it?

    // If the pod was replaced, discard any previously used ports. We want dynamic ports to re-roll.
    if (!FailureUtils.isPermanentlyFailed(currentTask)) {
      portsByTask.put(currentTask.getName(), new TaskPortLookup(currentTask));
    }
  }

  for (Protos.TaskInfo.Builder taskBuilder : taskBuilders.values()) {
    validateTaskInfo(taskBuilder);
  }
}
 
Example 11
Source File: ServiceTaskFactory.java    From incubator-myriad with Apache License 2.0 4 votes vote down vote up
@Override
public Protos.ExecutorInfo getExecutorInfoForSlave(ResourceOfferContainer resourceOfferContainer, Protos.FrameworkID frameworkId, Protos.CommandInfo commandInfo) {
  return null;
}
 
Example 12
Source File: StoreContext.java    From incubator-myriad with Apache License 2.0 4 votes vote down vote up
/**
 * Serialize the Protos.FrameworkID into a ByteBuffer.
 */
public void setFrameworkId(Protos.FrameworkID frameworkId) {
  if (frameworkId != null) {
    this.frameworkId = ByteBufferSupport.toByteBuffer(frameworkId);
  }
}
 
Example 13
Source File: TaskFactory.java    From incubator-myriad with Apache License 2.0 4 votes vote down vote up
public abstract Protos.TaskInfo createTask(ResourceOfferContainer resourceOfferContainer, Protos.FrameworkID frameworkId,
Protos.TaskID taskId, NodeTask nodeTask);
 
Example 14
Source File: Registered.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public Protos.FrameworkID frameworkId() {
	return frameworkId;
}
 
Example 15
Source File: FrameworkRunner.java    From dcos-commons with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
Protos.FrameworkInfo getFrameworkInfo(Optional<Protos.FrameworkID> frameworkId) {
  Protos.FrameworkInfo.Builder fwkInfoBuilder = Protos.FrameworkInfo.newBuilder()
      .setName(frameworkConfig.getFrameworkName())
      .setPrincipal(frameworkConfig.getPrincipal())
      .setUser(frameworkConfig.getUser())
      .setFailoverTimeout(TWO_WEEK_SEC)
      .setCheckpoint(true);

  // The framework ID is not available when we're being started for the first time.
  frameworkId.ifPresent(fwkInfoBuilder::setId);

  if (getResourceRoles().size() > 1) {
    // We have more than one role, set to MULTI_ROLE by default and add all the necessary roles.
    fwkInfoBuilder.addCapabilitiesBuilder()
      .setType(Protos.FrameworkInfo.Capability.Type.MULTI_ROLE);
    fwkInfoBuilder.addAllRoles(getResourceRoles());
  } else {
    fwkInfoBuilder.setRole(frameworkConfig.getRole());
  }

  if (!StringUtils.isEmpty(frameworkConfig.getWebUrl())) {
    fwkInfoBuilder.setWebuiUrl(frameworkConfig.getWebUrl());
  }

  Capabilities capabilities = Capabilities.getInstance();

  if (capabilities.supportsPartitionAwareness()) {
    //required to receive TASK_GONE_BY_OPERATOR and other messages
    fwkInfoBuilder.addCapabilitiesBuilder()
        .setType(Protos.FrameworkInfo.Capability.Type.PARTITION_AWARE);
  }

  if (usingGpus && capabilities.supportsGpuResource()) {
    fwkInfoBuilder.addCapabilitiesBuilder()
        .setType(Protos.FrameworkInfo.Capability.Type.GPU_RESOURCES);
  }
  if (capabilities.supportsPreReservedResources()) {
    fwkInfoBuilder.addCapabilitiesBuilder()
        .setType(Protos.FrameworkInfo.Capability.Type.RESERVATION_REFINEMENT);
  }

  // Only enable if opted-in by the developer or user.
  if (usingRegions && capabilities.supportsDomains()) {
    fwkInfoBuilder.addCapabilitiesBuilder()
        .setType(Protos.FrameworkInfo.Capability.Type.REGION_AWARE);
  }

  return fwkInfoBuilder.build();
}
 
Example 16
Source File: StandaloneMesosWorkerStore.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public Option<Protos.FrameworkID> getFrameworkID() throws Exception {
	return frameworkID;
}
 
Example 17
Source File: REEFScheduler.java    From reef with Apache License 2.0 4 votes vote down vote up
@Override
public void registered(final SchedulerDriver driver,
                       final Protos.FrameworkID frameworkId,
                       final Protos.MasterInfo masterInfo) {
  LOG.log(Level.INFO, "Framework ID={0} registration succeeded", frameworkId);
}
 
Example 18
Source File: MesosWorkerStore.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Get the stored Mesos framework ID.
 */
Option<Protos.FrameworkID> getFrameworkID() throws Exception;
 
Example 19
Source File: MesosWorkerStore.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Set the stored Mesos framework ID.
 */
void setFrameworkID(Option<Protos.FrameworkID> frameworkID) throws Exception;
 
Example 20
Source File: MesosWorkerStore.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Get the stored Mesos framework ID.
 */
Option<Protos.FrameworkID> getFrameworkID() throws Exception;