org.apache.mesos.Protos.SlaveID Java Examples

The following examples show how to use org.apache.mesos.Protos.SlaveID. 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: LaunchTaskTest.java    From storm with Apache License 2.0 6 votes vote down vote up
/**
 * Setup testing target & sample data.
 */
public LaunchTaskTest()
{
  SlaveID slaveID = SlaveID.newBuilder().setValue("s1").build();
  this.sampleTaskInfo =
      TaskInfo.newBuilder()
              .setName("t1").setSlaveId(slaveID)
              .setTaskId(TaskID.newBuilder().setValue("id2"))
              .setExecutor(
                  ExecutorInfo.newBuilder()
                              .setExecutorId(ExecutorID.newBuilder().setValue("e1"))
                              .setCommand(CommandInfo.getDefaultInstance()))
              .build();
  this.sampleOffer =
      Offer.newBuilder()
           .setHostname("h1").setSlaveId(slaveID)
           .setId(OfferID.newBuilder().setValue("id1"))
           .setFrameworkId(FrameworkID.newBuilder().setValue("f1").build())
           .build();
  this.target = new LaunchTask(sampleTaskInfo, sampleOffer);
}
 
Example #2
Source File: CloudAppRestfulApi.java    From shardingsphere-elasticjob-cloud with Apache License 2.0 5 votes vote down vote up
private void stopExecutors(final String appName) {
    try {
        Collection<MesosStateService.ExecutorStateInfo> executorBriefInfo = mesosStateService.executors(appName);
        for (MesosStateService.ExecutorStateInfo each : executorBriefInfo) {
            producerManager.sendFrameworkMessage(ExecutorID.newBuilder().setValue(each.getId()).build(),
                    SlaveID.newBuilder().setValue(each.getSlaveId()).build(), "STOP".getBytes());
        }
    } catch (final JSONException ex) {
        throw new JobSystemException(ex);
    }
}
 
Example #3
Source File: ExecutorDriverContext.java    From jesos with Apache License 2.0 5 votes vote down vote up
ExecutorDriverContext(final String hostName,
                      final UPID slaveUpid,
                      final SlaveID slaveId,
                      final FrameworkID frameworkId,
                      final ExecutorID executorId)
                throws IOException
{
    this.slaveUpid = slaveUpid;
    this.slaveId = slaveId;
    this.frameworkId = frameworkId;
    this.executorId = executorId;

    this.driverUpid = UPID.fromParts(UUID.randomUUID().toString(),
        HostAndPort.fromParts(hostName, NetworkUtil.findUnusedPort()));
}
 
Example #4
Source File: InternalSchedulerDriver.java    From jesos with Apache License 2.0 5 votes vote down vote up
@Override
public Status sendFrameworkMessage(final ExecutorID executorId, final SlaveID slaveId, final byte[] data)
{
    checkNotNull(executorId, "executorId is null");
    checkNotNull(slaveId, "slaveId is null");
    checkNotNull(data, "data is null");

    if (!context.isStateMachine(DRIVER_RUNNING)) {
        return context.getStateMachine();
    }

    final FrameworkToExecutorMessage message = FrameworkToExecutorMessage.newBuilder()
        .setFrameworkId(context.getFrameworkId())
        .setExecutorId(executorId)
        .setSlaveId(slaveId)
        .setData(ByteString.copyFrom(data)).build();

    // If the UPID of that slave is known (from the slave cache, then send the message
    // directly to the slave, otherwise to the master and let the master sort it out.
    if (context.containsSlave(message.getSlaveId())) {
        final UPID slave = context.getSlaveUPID(message.getSlaveId());
        eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), slave, message));
    }
    else {
        eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getMasterUPID(), message));
    }

    return context.getStateMachine();
}
 
Example #5
Source File: LocalSchedulerMessageProcessor.java    From jesos with Apache License 2.0 5 votes vote down vote up
@Subscribe
public void frameworkLostSlave(final LostSlaveMessageEnvelope envelope)
{
    checkState(envelope.getRecipient().equals(context.getDriverUPID()), "Received a remote message for local delivery");

    final UPID sender = envelope.getSender();

    if (!driverIsConnected(sender)) {
        return;
    }

    final LostSlaveMessage lostSlaveMessage = envelope.getMessage();
    final SlaveID slaveId = lostSlaveMessage.getSlaveId();

    context.removeSlave(slaveId);

    eventBus.post(new SchedulerCallback() {
        @Override
        public Runnable getCallback(final Scheduler scheduler, final SchedulerDriver schedulerDriver)
        {
            return new Runnable() {
                @Override
                public void run()
                {
                    scheduler.slaveLost(schedulerDriver, slaveId);
                }
            };
        }
    });
}
 
Example #6
Source File: JesosExecutorDriver.java    From jesos with Apache License 2.0 5 votes vote down vote up
public JesosExecutorDriver(final Executor executor,
                           final UPID slaveUpid,
                           final SlaveID slaveId,
                           final FrameworkID frameworkId,
                           final ExecutorID executorId) throws IOException
{
    super(executor, slaveUpid, slaveId, frameworkId, executorId);
}
 
Example #7
Source File: JesosExecutorDriver.java    From jesos with Apache License 2.0 5 votes vote down vote up
public JesosExecutorDriver(final Executor executor) throws IOException
{
    this(executor,
         UPID.create(System.getenv("MESOS_SLAVE_PID")),
         SlaveID.newBuilder().setValue(System.getenv("MESOS_SLAVE_ID")).build(),
         FrameworkID.newBuilder().setValue(System.getenv("MESOS_FRAMEWORK_ID")).build(),
         ExecutorID.newBuilder().setValue(System.getenv("MESOS_EXECUTOR_ID")).build());
}
 
Example #8
Source File: OfferUtilsTest.java    From incubator-myriad with Apache License 2.0 5 votes vote down vote up
private List<Offer> generateOffers(List<Resource> resources) {
  FrameworkID fidOne = Protos.FrameworkID.newBuilder().setValue("framework-1").build();
  FrameworkID fidTwo = Protos.FrameworkID.newBuilder().setValue("framework-2").build();
  FrameworkID fidThree = Protos.FrameworkID.newBuilder().setValue("framework-3").build();
  FrameworkID fidFour = Protos.FrameworkID.newBuilder().setValue("framework-4").build();

  OfferID oidOne = Protos.OfferID.newBuilder().setValue("offer-1").build();
  OfferID oidTwo = Protos.OfferID.newBuilder().setValue("offer-2").build(); 
  OfferID oidThree = Protos.OfferID.newBuilder().setValue("offer-3").build(); 
  OfferID oidFour = Protos.OfferID.newBuilder().setValue("offer-4").build(); 

  SlaveID sidOne = Protos.SlaveID.newBuilder().setValue("slave-1").build();
  SlaveID sidTwo = Protos.SlaveID.newBuilder().setValue("slave-2").build();
  SlaveID sidThree = Protos.SlaveID.newBuilder().setValue("slave-3").build();
  SlaveID sidFour = Protos.SlaveID.newBuilder().setValue("slave-4").build();

  Offer offerOne = Protos.Offer.newBuilder().setFrameworkId(fidOne).setHostname("10.0.0.1").setId(oidOne).setSlaveId(sidOne).
      addResources(resources.get(0)).addResources(resources.get(1)).build();
  Offer offerTwo = Protos.Offer.newBuilder().setFrameworkId(fidTwo).setHostname("10.0.0.2").setId(oidTwo).setSlaveId(sidTwo).
      addResources(resources.get(2)).addResources(resources.get(3)).build();
  Offer offerThree = Protos.Offer.newBuilder().setFrameworkId(fidThree).setHostname("10.0.0.3").setId(oidThree).setSlaveId(sidThree).
      addResources(resources.get(0)).addResources(resources.get(3)).build();
  Offer offerFour = Protos.Offer.newBuilder().setFrameworkId(fidFour).setHostname("10.0.0.4").setId(oidFour).setSlaveId(sidFour).
      addResources(resources.get(2)).addResources(resources.get(1)).build();

  return Lists.newArrayList(offerOne, offerTwo, offerThree, offerFour);
}
 
Example #9
Source File: TestObjectFactory.java    From incubator-myriad with Apache License 2.0 5 votes vote down vote up
public static Offer getOffer(String host, String slaveId, String frameworkId, String offerId, double cpuCores, double memory) {
  Protos.SlaveID sid = SlaveID.newBuilder().setValue(slaveId).build();
  Protos.FrameworkID fid = FrameworkID.newBuilder().setValue(frameworkId).build();
  Protos.Value.Scalar cores = Protos.Value.Scalar.newBuilder().setValue(cpuCores).build();
  Protos.Value.Scalar mem = Protos.Value.Scalar.newBuilder().setValue(memory).build();
  Protos.Resource cpuResource = Protos.Resource.newBuilder().setName("cpus").setScalar(cores).setType(Type.SCALAR).build();
  Protos.Resource memResource  = Protos.Resource.newBuilder().setName("mem").setScalar(mem).setType(Type.SCALAR).build();
  return Protos.Offer.newBuilder().setHostname(host).setId(OfferID.newBuilder().setValue(offerId)).
      setSlaveId(sid).setFrameworkId(fid).addResources(cpuResource).addResources(memResource).build();  
}
 
Example #10
Source File: TestObjectFactory.java    From incubator-myriad with Apache License 2.0 5 votes vote down vote up
/**
* Returns a NodeTask given a ServiceResourceProfile and hostname
* 
* @param hostName
* @param profile
* @return
*/
public static NodeTask getNodeTask(String hostName, ServiceResourceProfile profile) {
  NodeTask task = new NodeTask(profile, new LikeConstraint(hostName, "host-[0-9]*.example.com"));
  task.setHostname(hostName);
  task.setTaskPrefix("nm");
  task.setSlaveId(SlaveID.newBuilder().setValue(profile.getName() + "-" + hostName).build());
  task.setExecutorInfo(ExecutorInfo.newBuilder().setExecutorId(ExecutorID.newBuilder().setValue("exec")).
       setCommand(org.apache.mesos.Protos.CommandInfo.newBuilder().setValue("command")).build());
  return task;
}
 
Example #11
Source File: ExecutorLostEventHandler.java    From incubator-myriad with Apache License 2.0 5 votes vote down vote up
@Override
public void onEvent(ExecutorLostEvent event, long sequence, boolean endOfBatch) throws Exception {
  ExecutorID executorId = event.getExecutorId();
  SlaveID slaveId = event.getSlaveId();
  int exitStatus = event.getExitStatus();
  LOGGER.info("Executor {} of slave {} lost with exit status: {}", executorId, slaveId, exitStatus);
}
 
Example #12
Source File: SchedulerState.java    From incubator-myriad with Apache License 2.0 5 votes vote down vote up
public synchronized NodeTask getNodeTask(SlaveID slaveId, String taskPrefix) {
  if (taskPrefix == null) {
    return null;
  }
  for (Map.Entry<Protos.TaskID, NodeTask> entry : tasks.entrySet()) {
    final NodeTask task = entry.getValue();
    if (task.getSlaveId() != null &&
        task.getSlaveId().equals(slaveId) &&
        taskPrefix.equals(task.getTaskPrefix())) {
      return entry.getValue();
    }
  }
  return null;
}
 
Example #13
Source File: ResourceMesosScheduler.java    From oodt with Apache License 2.0 5 votes vote down vote up
@Override
public void frameworkMessage(SchedulerDriver schedDriver, ExecutorID executor,
        SlaveID slave, byte[] bytes) {
    try {
        LOG.log(Level.INFO,"Mesos framework executor"+executor+" on slave "+slave+" issued message: "+
            new String(bytes,"ascii"));
    } catch (UnsupportedEncodingException e) {
        LOG.log(Level.WARNING,"Mesos framework message missed due to bad encoding: ascii. "+e.getMessage());
    }
}
 
Example #14
Source File: TaskTypeRuleTest.java    From dcos-commons with Apache License 2.0 5 votes vote down vote up
private static Offer getOffer(String agent) {
    Offer.Builder o = OfferTestUtils.getEmptyOfferBuilder()
            .setSlaveId(SlaveID.newBuilder().setValue(agent));
    OfferTestUtils.addResource(o, "a");
    OfferTestUtils.addResource(o, "b");
    return o.build();
}
 
Example #15
Source File: SchedulerState.java    From incubator-myriad with Apache License 2.0 5 votes vote down vote up
public synchronized Set<NodeTask> getNodeTasks(SlaveID slaveId) {
  Set<NodeTask> nodeTasks = Sets.newHashSet();
  for (Map.Entry<Protos.TaskID, NodeTask> entry : tasks.entrySet()) {
    final NodeTask task = entry.getValue();
    if (task.getSlaveId() != null && task.getSlaveId().equals(slaveId)) {
      nodeTasks.add(entry.getValue());
    }
  }
  return nodeTasks;
}
 
Example #16
Source File: MesosSchedulerImpl.java    From attic-aurora with Apache License 2.0 5 votes vote down vote up
@Override
public void frameworkMessage(
    SchedulerDriver driver,
    ExecutorID executorID,
    SlaveID slave,
    byte[] data) {
  handler.handleMessage(convert(executorID), convert(slave));
}
 
Example #17
Source File: BdsMesosScheduler.java    From BigDataScript with Apache License 2.0 5 votes vote down vote up
/**
 * Invoked when an executor sends a message. These messages are best
 * effort; do not expect a framework message to be retransmitted in
 * any reliable fashion.
 */
@Override
public void frameworkMessage(SchedulerDriver driver, ExecutorID executorId, SlaveID slaveId, byte[] data) {
	if (verbose) Gpr.debug("Scheduler: Framework message" //
			+ "\n\tExecutorId : " + executorId.getValue() //
			+ "\n\tSlaveId    : " + slaveId.getValue() //
			+ "\n\tMesssage   : '" + new String(data) + "'" //
	);
}
 
Example #18
Source File: MesosSchedulerImpl.java    From attic-aurora with Apache License 2.0 4 votes vote down vote up
@Override
public void executorLost(SchedulerDriver schedulerDriver, ExecutorID executorID, SlaveID slaveID,
    int status) {
  handler.handleLostExecutor(convert(executorID), convert(slaveID), status);
}
 
Example #19
Source File: SchedulerDriverContext.java    From jesos with Apache License 2.0 4 votes vote down vote up
UPID getSlaveUPID(final SlaveID slaveId)
{
    return slaveCache.get(slaveId);
}
 
Example #20
Source File: InternalExecutorDriver.java    From jesos with Apache License 2.0 4 votes vote down vote up
protected InternalExecutorDriver(final Executor executor,
                                 final UPID slaveUpid,
                                 final SlaveID slaveId,
                                 final FrameworkID frameworkId,
                                 final ExecutorID executorId) throws IOException
{
    this.executor = checkNotNull(executor, "executor is null");

    checkNotNull(slaveUpid, "slaveUpid is null");
    checkNotNull(slaveId, "slaveId is null");
    checkNotNull(frameworkId, "frameworkId is null");
    checkNotNull(executorId, "executorId is null");

    LOG.debug("Slave UPID:       %s", slaveUpid.asString());
    LOG.debug("Slave ID:         %s", slaveId.getValue());
    LOG.debug("Framework ID:     %s", frameworkId.getValue());
    LOG.debug("Executor ID:      %s", executorId.getValue());

    // Enforce using of the IP, when using the hostname this might "flap" between IPs which in turn
    // confuses the heck out of Mesos.
    final String hostName = NetworkUtil.findPublicIp();

    LOG.debug("Host name:        %s", hostName);

    this.context = new ExecutorDriverContext(hostName, slaveUpid, slaveId, frameworkId, executorId);

    this.eventBus = new ManagedEventBus("executor");

    this.localMessageProcessor = new LocalExecutorMessageProcessor(context, eventBus);

    // Closer closes in reverse registration order.

    // Close the callback executor last, so that everything that was still scheduled to be delivered to the framework still has a chance.
    this.callbackExecutor = closer.register(CloseableExecutors.decorate(Executors.newScheduledThreadPool(5, new ThreadFactoryBuilder().setDaemon(true).setNameFormat("executor-callback-%d").build())));

    this.receiver = closer.register(new HttpProtocolReceiver(context.getDriverUPID(), ExecutorMessageEnvelope.class, eventBus));

    // The sender is closed before the receiver, so that possible responses are still caught
    this.sender = closer.register(new HttpProtocolSender(context.getDriverUPID()));

    // Make sure that the event bus is drained first at shutdown.
    closer.register(eventBus);
}
 
Example #21
Source File: BdsMesosScheduler.java    From BigDataScript with Apache License 2.0 4 votes vote down vote up
/**
 * Invoked when a slave has been determined unreachable (e.g.,
 * machine failure, network partition). Most frameworks will need to
 * reschedule any tasks launched on this slave on a new slave.
 */
@Override
public void slaveLost(SchedulerDriver driver, SlaveID slaveId) {
	// Mark call tasks in that host fail?
	if (verbose) Gpr.debug("Scheduler: Slave Lost " + slaveId.getValue());
}
 
Example #22
Source File: ExecutorDriverContext.java    From jesos with Apache License 2.0 4 votes vote down vote up
SlaveID getSlaveId()
{
    return slaveId;
}
 
Example #23
Source File: NimbusMesosScheduler.java    From storm with Apache License 2.0 4 votes vote down vote up
@Override
public void frameworkMessage(SchedulerDriver driver, ExecutorID executorId, SlaveID slaveId, byte[] data) {
}
 
Example #24
Source File: FakeMaster.java    From attic-aurora with Apache License 2.0 4 votes vote down vote up
@Override
public Status sendFrameworkMessage(ExecutorID executorId, SlaveID slaveId, byte[] data) {
  throw new UnsupportedOperationException();
}
 
Example #25
Source File: NimbusMesosScheduler.java    From storm with Apache License 2.0 4 votes vote down vote up
@Override
public void slaveLost(SchedulerDriver driver, SlaveID id) {
  LOG.warn("Lost slave id: {}", id.getValue());
}
 
Example #26
Source File: MesosSchedulerImpl.java    From attic-aurora with Apache License 2.0 4 votes vote down vote up
@Override
public void slaveLost(SchedulerDriver schedulerDriver, SlaveID slaveId) {
  handler.handleLostAgent(convert(slaveId));
}
 
Example #27
Source File: ResourceMesosScheduler.java    From oodt with Apache License 2.0 4 votes vote down vote up
@Override
public void slaveLost(SchedulerDriver schedDriver, SlaveID slave) {
    LOG.log(Level.WARNING,"Mesos slave "+slave+" lost, reissuing jobs.");
    //TODO: reregister jobs
}
 
Example #28
Source File: NimbusMesosScheduler.java    From storm with Apache License 2.0 4 votes vote down vote up
@Override
public void executorLost(SchedulerDriver driver, ExecutorID executor, SlaveID slave, int status) {
  LOG.warn("Mesos Executor lost: executor: {} slave: {} status: {}", executor.getValue(), slave.getValue(), status);
}
 
Example #29
Source File: ResourceMesosScheduler.java    From oodt with Apache License 2.0 4 votes vote down vote up
@Override
public void executorLost(SchedulerDriver schedDriver, ExecutorID executor,SlaveID slave, int status) {
    //Tasks will have a "task lost" message automatically q.e.d no action necessary.
    //TODO: do we need to restart?
    LOG.log(Level.SEVERE,"Mesos executor "+executor+" on slave "+slave+" died with status "+status);
}
 
Example #30
Source File: SchedulerDriverContext.java    From jesos with Apache License 2.0 4 votes vote down vote up
void removeSlave(final SlaveID slaveId)
{
    slaveCache.remove(slaveId);
}