org.apache.mesos.Protos.MasterInfo Java Examples

The following examples show how to use org.apache.mesos.Protos.MasterInfo. 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: LocalSchedulerMessageProcessor.java    From jesos with Apache License 2.0 6 votes vote down vote up
private boolean driverIsConnected(final UPID messageSender)
{
    final MasterInfo master = context.connectedMaster();

    if (master == null) {
        LOG.warn("Received message from  %s, but no master is leading, ignoring!", messageSender);
        return false;
    }

    // Master PID may have changed in the context in the meantime. Don't rely on the context
    // to be up to date but resolve the MasterInfo that was retrieved earlier.
    final UPID masterUpid = UPID.create(master.getPid());

    if (!masterUpid.equals(messageSender)) {
        LOG.warn("Received message from %s, leading master is %s, ignoring!", messageSender, masterUpid);
        return false;
    }

    return true;
}
 
Example #2
Source File: LocalSchedulerMessageProcessor.java    From jesos with Apache License 2.0 6 votes vote down vote up
private boolean masterIsValid(final MasterInfo masterInfo)
{
    checkNotNull(masterInfo, "masterInfo is null");

    if (context.isStateMachine(DRIVER_ABORTED)) {
        LOG.warn("driver is aborted!");
        return false;
    }

    final MasterInfo currentMaster = context.getMaster();

    if (currentMaster == null) {
        LOG.warn("Received registration from  %s, but no master is leading, ignoring!", masterInfo.getId());
        return false;
    }

    if (!masterInfo.equals(currentMaster)) {
        LOG.warn("Received registration from %s, leading master is %s, ignoring!", masterInfo, currentMaster);
        return false;
    }

    return true;
}
 
Example #3
Source File: ZookeeperMasterDetector.java    From jesos with Apache License 2.0 6 votes vote down vote up
@Subscribe
public void processDetect(final DetectMessage message)
{
    final SettableFuture<MasterInfo> future = message.getFuture();
    final MasterInfo previous = message.getPrevious();
    final MasterInfo currentLeader = getMaster();

    if (!Objects.equal(currentLeader, previous)) {
        LOG.debug("Master has changed: %s -> %s", previous, currentLeader);
        future.set(currentLeader);
    }
    else {
        LOG.debug("Master unchanged, queueing");
        futures.add(message);
    }
}
 
Example #4
Source File: ZookeeperMasterDetector.java    From jesos with Apache License 2.0 5 votes vote down vote up
private MasterInfo getMaster()
{
    if (nodeCache.isEmpty()) {
        return null;
    }
    final String key = nodeCache.firstKey();
    return nodeCache.get(key);
}
 
Example #5
Source File: SchedulerDriverContext.java    From jesos with Apache License 2.0 5 votes vote down vote up
synchronized MasterInfo connectedMaster()
{
    if (isStateMachine(DRIVER_ABORTED)) {
        LOG.debug("driver is aborted!");
        return null;
    }

    if (!isConnected()) {
        LOG.debug("Not connected!");
        return null;
    }

    return masterInfo.get();
}
 
Example #6
Source File: NimbusMesosScheduler.java    From storm with Apache License 2.0 5 votes vote down vote up
@Override
public void registered(final SchedulerDriver driver, FrameworkID id, MasterInfo masterInfo) {
  mesosNimbus.doRegistration(driver, id);

  // Completed registration, let anything waiting for us to do so continue
  _registeredLatch.countDown();
}
 
Example #7
Source File: MesosSchedulerCallbackHandler.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
@Override
public void registered(SchedulerDriver driver, FrameworkID frameworkID, MasterInfo masterInfo) {
    logMesosCallbackInfo("Mesos registered: %s, ID=%s, masterInfo=%s", driver, frameworkID.getValue(), masterInfo.getId());
    initializeNewDriver(driver);
    numMesosRegistered.increment();
    connected = true;
}
 
Example #8
Source File: ZookeeperMasterDetector.java    From jesos with Apache License 2.0 5 votes vote down vote up
@Override
public Object deserialize(final byte[] bytes) throws ZkMarshallingError
{
    checkNotNull(bytes, "bytes is null");
    try {
        return MasterInfo.parseFrom(bytes);
    }
    catch (final InvalidProtocolBufferException e) {
        return new ZkMarshallingError(e);
    }
}
 
Example #9
Source File: ZookeeperMasterDetector.java    From jesos with Apache License 2.0 5 votes vote down vote up
public ListenableFuture<MasterInfo> detect(final MasterInfo previous)
{
    checkState(running.get(), "not running");

    final SettableFuture<MasterInfo> result = SettableFuture.create();
    eventBus.post(new DetectMessage(result, previous));
    return result;
}
 
Example #10
Source File: MesosSchedulerImpl.java    From attic-aurora with Apache License 2.0 5 votes vote down vote up
@Override
public void registered(
    SchedulerDriver driver,
    final FrameworkID frameworkId,
    MasterInfo masterInfo) {
  handler.handleRegistration(convert(frameworkId), convert(masterInfo));
  isRegistered = true;
}
 
Example #11
Source File: FakeMaster.java    From attic-aurora with Apache License 2.0 5 votes vote down vote up
@Override
public Status start() {
  assertNotStopped();

  Futures.getUnchecked(schedulerFuture).registered(this,
      FrameworkID.newBuilder().setValue("local").build(),
      MasterInfo.getDefaultInstance());

  eventBus.post(new Started());

  executor.scheduleAtFixedRate(
      () -> {
        List<Offer> allOffers;
        synchronized (sentOffers) {
          synchronized (idleOffers) {
            sentOffers.putAll(idleOffers);
            allOffers = ImmutableList.copyOf(idleOffers.values());
            idleOffers.clear();
          }
        }

        if (allOffers.isEmpty()) {
          LOG.info("All offers consumed, suppressing offer cycle.");
        } else {
          Futures.getUnchecked(schedulerFuture).resourceOffers(this, allOffers);
        }
      },
      1,
      5,
      TimeUnit.SECONDS);

  return Status.DRIVER_RUNNING;
}
 
Example #12
Source File: MesosSchedulerCallbackHandler.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
@Override
public void reregistered(SchedulerDriver driver, MasterInfo masterInfo) {
    logMesosCallbackWarn("Mesos re-registered: %s, masterInfo=%s", driver, masterInfo.getId());
    initializeNewDriver(driver);
    numMesosRegistered.increment();
    connected = true;
}
 
Example #13
Source File: InternalSchedulerDriver.java    From jesos with Apache License 2.0 4 votes vote down vote up
private void doLaunchTasks(final LaunchTasksMessage message)
{
    final MasterInfo masterInfo = context.connectedMaster();

    if (masterInfo == null) {
        loseAllTasks(message.getTasksList(), "Master disconnected");
        return;
    }

    final ImmutableList.Builder<TaskInfo> builder = ImmutableList.builder();

    for (TaskInfo taskInfo : message.getTasksList()) {
        if (taskInfo.hasExecutor() == taskInfo.hasCommand()) {
            loseTask(taskInfo, "TaskInfo must have either an 'executor' or a 'command'");
            continue; // for(...
        }

        if (taskInfo.hasExecutor()) {
            if (taskInfo.getExecutor().hasFrameworkId()) {
                final FrameworkID executorFrameworkId = taskInfo.getExecutor().getFrameworkId();
                if (!executorFrameworkId.equals(context.getFrameworkId())) {
                    loseTask(taskInfo, format("ExecutorInfo has an invalid FrameworkID (Actual: %s vs Expected: %s)", executorFrameworkId.getValue(), context.getFrameworkId().getValue()));
                    continue; // for(...
                }
            }
            else {
                // Executor present but not framework id. Set the framework id.
                taskInfo = TaskInfo.newBuilder(taskInfo)
                    .setExecutor(ExecutorInfo.newBuilder(taskInfo.getExecutor()).setFrameworkId(context.getFrameworkId()))
                    .build();
            }
        }

        builder.add(taskInfo);
    }

    final List<TaskInfo> launchTasks = builder.build();

    for (final OfferID offer : message.getOfferIdsList()) {
        if (!context.hasOffers(offer)) {
            LOG.warn("Unknown offer %s ignored!", offer.getValue());
        }

        for (final TaskInfo launchTask : launchTasks) {
            if (context.hasOffer(offer, launchTask.getSlaveId())) {
                context.addSlave(launchTask.getSlaveId(), context.getOffer(offer, launchTask.getSlaveId()));
            }
        }
        context.removeAllOffers(offer);
    }

    final LaunchTasksMessage launchMessage = LaunchTasksMessage.newBuilder(message)
        .setFrameworkId(context.getFrameworkId())
        .clearTasks()
        .addAllTasks(launchTasks)
        .build();

    eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getMasterUPID(), launchMessage));
}
 
Example #14
Source File: NimbusMesosScheduler.java    From storm with Apache License 2.0 4 votes vote down vote up
@Override
public void reregistered(SchedulerDriver sd, MasterInfo info) {
}
 
Example #15
Source File: ResourceMesosScheduler.java    From oodt with Apache License 2.0 4 votes vote down vote up
@Override
public void registered(SchedulerDriver schedDriver, FrameworkID framework,
        MasterInfo masterInfo) {
    LOG.log(Level.INFO,"Mesos framework registered: "+framework.getValue()+" with master: "+masterInfo.getId());
}
 
Example #16
Source File: ResourceMesosScheduler.java    From oodt with Apache License 2.0 4 votes vote down vote up
@Override
public void reregistered(SchedulerDriver schedDriver, MasterInfo masterInfo) {
    LOG.log(Level.INFO,"Mesos framework re-registered with: "+masterInfo.getId());
    //TODO: call start, we are registered.

}
 
Example #17
Source File: MesosSchedulerImpl.java    From attic-aurora with Apache License 2.0 4 votes vote down vote up
@Override
public void reregistered(SchedulerDriver schedulerDriver, MasterInfo masterInfo) {
  handler.handleReregistration(convert(masterInfo));
}
 
Example #18
Source File: SchedulerDriverContext.java    From jesos with Apache License 2.0 4 votes vote down vote up
synchronized void setMaster(final MasterInfo newMasterInfo)
{
    masterInfo.set(newMasterInfo);
    masterUpid.set(newMasterInfo == null ? null : UPID.create(newMasterInfo.getPid()));
}
 
Example #19
Source File: SchedulerDriverContext.java    From jesos with Apache License 2.0 4 votes vote down vote up
synchronized MasterInfo getMaster()
{
    return masterInfo.get();
}
 
Example #20
Source File: InternalSchedulerDriver.java    From jesos with Apache License 2.0 4 votes vote down vote up
@Override
public void onSuccess(final MasterInfo masterInfo)
{
    masterChanged(masterInfo);
}
 
Example #21
Source File: ZookeeperMasterDetector.java    From jesos with Apache License 2.0 4 votes vote down vote up
@Override
public byte[] serialize(final Object data) throws ZkMarshallingError
{
    checkState(data instanceof MasterInfo, "%s is not a MasterInfo!", data.getClass().getSimpleName());
    return ((MasterInfo) data).toByteArray();
}
 
Example #22
Source File: DetectMessage.java    From jesos with Apache License 2.0 4 votes vote down vote up
public MasterInfo getPrevious()
{
    return previous;
}
 
Example #23
Source File: DetectMessage.java    From jesos with Apache License 2.0 4 votes vote down vote up
public SettableFuture<MasterInfo> getFuture()
{
    return future;
}
 
Example #24
Source File: DetectMessage.java    From jesos with Apache License 2.0 4 votes vote down vote up
DetectMessage(final SettableFuture<MasterInfo> future, final MasterInfo previous)
{
    this.future = checkNotNull(future, "future is null");
    this.previous = previous;
}
 
Example #25
Source File: SchedulerDriverFactoryTest.java    From dcos-commons with Apache License 2.0 4 votes vote down vote up
@Override
public void reregistered(SchedulerDriver driver, MasterInfo masterInfo) { }
 
Example #26
Source File: SchedulerDriverFactoryTest.java    From dcos-commons with Apache License 2.0 4 votes vote down vote up
@Override
public void registered(SchedulerDriver driver, FrameworkID frameworkId, MasterInfo masterInfo) { }
 
Example #27
Source File: BdsMesosScheduler.java    From BigDataScript with Apache License 2.0 2 votes vote down vote up
/**
 * Invoked when the scheduler successfully registers with a Mesos
 * master. A unique ID (generated by the master) used for
 * distinguishing this framework from others and MasterInfo
 * with the ip and port of the current master are provided as arguments.
 */
@Override
public void registered(SchedulerDriver driver, FrameworkID frameworkId, MasterInfo masterInfo) {
	if (verbose) Gpr.debug("Scheduler: Registered framework " + frameworkId.getValue() + ", master " + masterInfo.getHostname());
}
 
Example #28
Source File: BdsMesosScheduler.java    From BigDataScript with Apache License 2.0 2 votes vote down vote up
/**
 * Invoked when the scheduler re-registers with a newly elected Mesos master.
 * This is only called when the scheduler has previously been registered.
 * MasterInfo containing the updated information about the elected master
 * is provided as an argument.
 */
@Override
public void reregistered(SchedulerDriver driver, MasterInfo masterInfo) {
	if (verbose) Gpr.debug("Scheduler: Re-Registered " + masterInfo.getHostname());
}