当前位置: 首页>>代码示例>>Java>>正文


Java SchedulerDriver类代码示例

本文整理汇总了Java中org.apache.mesos.SchedulerDriver的典型用法代码示例。如果您正苦于以下问题:Java SchedulerDriver类的具体用法?Java SchedulerDriver怎么用?Java SchedulerDriver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SchedulerDriver类属于org.apache.mesos包,在下文中一共展示了SchedulerDriver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSchedulerDriver

import org.apache.mesos.SchedulerDriver; //导入依赖的package包/类
private SchedulerDriver getSchedulerDriver(final TaskScheduler taskScheduler, final JobEventBus jobEventBus, final FrameworkIDService frameworkIDService) {
    Optional<String> frameworkIDOptional = frameworkIDService.fetch();
    Protos.FrameworkInfo.Builder builder = Protos.FrameworkInfo.newBuilder();
    if (frameworkIDOptional.isPresent()) {
        builder.setId(Protos.FrameworkID.newBuilder().setValue(frameworkIDOptional.get()).build());
    }
    Optional<String> role = env.getMesosRole();
    String frameworkName = MesosConfiguration.FRAMEWORK_NAME;
    if (role.isPresent()) {
        builder.setRole(role.get());
        frameworkName += "-" + role.get();
    }
    builder.addCapabilitiesBuilder().setType(Protos.FrameworkInfo.Capability.Type.PARTITION_AWARE);
    MesosConfiguration mesosConfig = env.getMesosConfiguration();
    Protos.FrameworkInfo frameworkInfo = builder.setUser(mesosConfig.getUser()).setName(frameworkName)
            .setHostname(mesosConfig.getHostname()).setFailoverTimeout(MesosConfiguration.FRAMEWORK_FAILOVER_TIMEOUT_SECONDS)
            .setWebuiUrl(WEB_UI_PROTOCOL + env.getFrameworkHostPort()).setCheckpoint(true).build();
    return new MesosSchedulerDriver(new SchedulerEngine(taskScheduler, facadeService, jobEventBus, frameworkIDService, statisticManager), frameworkInfo, mesosConfig.getUrl());
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:20,代码来源:SchedulerService.java

示例2: statusUpdate

import org.apache.mesos.SchedulerDriver; //导入依赖的package包/类
@Override
public void statusUpdate(SchedulerDriver driver, Protos.TaskStatus taskStatus) {

  final String taskId = taskStatus.getTaskId().getValue();

  logger.info("statusUpdate() task {} is in state {}",
      taskId, taskStatus.getState());

  switch (taskStatus.getState()) {
    case TASK_RUNNING:
      runningInstances.add(taskId);
      pendingInstances.remove(taskId);
      break;
    case TASK_FAILED:
    case TASK_LOST:
    case TASK_FINISHED:
      fenzoScheduler.getTaskUnAssigner().call(taskStatus.getTaskId().getValue(), launchedTaskHostMap.remove(taskId));
      pendingInstances.remove(taskId);
      runningInstances.remove(taskId);
      break;
  }

  logger.info("Post statusUpdate, Number of instances: pending={}, running={}, taskQueue={}, pendingTasks={}, desired={}",
      pendingInstances.size(), runningInstances.size(), taskQueue.size(), pendingTasksMap.size(), this.getDesiredInstances());
}
 
开发者ID:yanglei99,项目名称:Mesos_Auto_Scale,代码行数:26,代码来源:FenzoScheduler.java

示例3: startup

import org.apache.mesos.SchedulerDriver; //导入依赖的package包/类
private void startup(SchedulerDriver driver, MasterInfo masterInfo) throws Exception {
  Preconditions.checkState(state == SchedulerState.STARTUP, "Asked to startup - but in invalid state: %s", state.name());

  masterInfoHolder.set(masterInfo);

  startup.startup(masterInfo, driver);

  stateLock.lock(); // ensure we aren't adding queued updates. calls to status updates are now blocked.

  try {
    state = SchedulerState.RUNNING; // calls to resource offers will now block, since we are already scheduler locked.

    for (Protos.TaskStatus status : queuedUpdates) {
      scheduler.statusUpdate(driver, status);
    }

  } finally {
    stateLock.unlock();
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:21,代码来源:SingularityMesosSchedulerDelegator.java

示例4: statusUpdate

import org.apache.mesos.SchedulerDriver; //导入依赖的package包/类
@Override
public void statusUpdate(SchedulerDriver driver, Protos.TaskStatus status) {
    LOGGER.info("Received status update for taskId={} state={} message={} protobuf={}",
            status.getTaskId().getValue(),
            status.getState().toString(),
            status.getMessage(),
            TextFormat.shortDebugString(status));
    try {
        processStatusUpdate(status);
        reconciler.update(status);

        Metrics.record(status);
    } catch (Exception e) {
        LOGGER.warn("Failed to update TaskStatus received from Mesos. "
                + "This may be expected if Mesos sent stale status information: " + status, e);
    }

    taskCleaner.statusUpdate(status);
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:20,代码来源:AbstractScheduler.java

示例5: offerRescinded

import org.apache.mesos.SchedulerDriver; //导入依赖的package包/类
@Override
public void offerRescinded(SchedulerDriver driver, OfferID offerId) {
  if (!isRunning()) {
    LOG.info("Ignoring offer rescind message {} because scheduler isn't running ({})", offerId, state);
    return;
  }

  lock.lock();

  try {
    scheduler.offerRescinded(driver, offerId);
  } catch (Throwable t) {
    handleUncaughtSchedulerException(t);
  } finally {
    lock.unlock();
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:18,代码来源:SingularityMesosSchedulerDelegator.java

示例6: register

import org.apache.mesos.SchedulerDriver; //导入依赖的package包/类
public static Send register() {
    return new Send() {
        @Override
        public void send(ClusterState state, SchedulerDriver mockDriver, Scheduler scheduler) {
            scheduler.registered(
                    mockDriver,
                    Protos.FrameworkID.newBuilder()
                            .setValue("test-framework-id")
                            .build(),
                    Protos.MasterInfo.newBuilder()
                            .setId("test-master-id")
                            .setIp(1)
                            .setPort(2)
                            .build());
        }

        @Override
        public String getDescription() {
            return String.format("Framework registration completed");
        }
    };
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:23,代码来源:Send.java

示例7: frameworkMessage

import org.apache.mesos.SchedulerDriver; //导入依赖的package包/类
@Override
public void frameworkMessage(SchedulerDriver driver, ExecutorID executorId, SlaveID slaveId, byte[] data) {
  if (!isRunning()) {
    LOG.info("Ignoring framework message because scheduler isn't running ({})", state);
    return;
  }

  lock.lock();

  try {
    scheduler.frameworkMessage(driver, executorId, slaveId, data);
  } catch (Throwable t) {
    handleUncaughtSchedulerException(t);
  } finally {
    lock.unlock();
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:18,代码来源:SingularityMesosSchedulerDelegator.java

示例8: disconnected

import org.apache.mesos.SchedulerDriver; //导入依赖的package包/类
@Override
public void disconnected(SchedulerDriver driver) {
  if (!isRunning()) {
    LOG.info("Ignoring disconnect because scheduler isn't running ({})", state);
    return;
  }

  lock.lock();

  try {
    scheduler.disconnected(driver);
  } catch (Throwable t) {
    handleUncaughtSchedulerException(t);
  } finally {
    lock.unlock();
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:18,代码来源:SingularityMesosSchedulerDelegator.java

示例9: slaveLost

import org.apache.mesos.SchedulerDriver; //导入依赖的package包/类
@Override
public void slaveLost(SchedulerDriver driver, SlaveID slaveId) {
  if (!isRunning()) {
    LOG.info("Ignoring slave lost {} because scheduler isn't running ({})", slaveId, state);
    return;
  }

  lock.lock();

  try {
    scheduler.slaveLost(driver, slaveId);
  } catch (Throwable t) {
    handleUncaughtSchedulerException(t);
  } finally {
    lock.unlock();
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:18,代码来源:SingularityMesosSchedulerDelegator.java

示例10: executorLost

import org.apache.mesos.SchedulerDriver; //导入依赖的package包/类
@Override
public void executorLost(SchedulerDriver driver, ExecutorID executorId, SlaveID slaveId, int status) {
  if (!isRunning()) {
    LOG.info("Ignoring executor lost {} because scheduler isn't running ({})", executorId, state);
    return;
  }

  lock.lock();

  try {
    scheduler.executorLost(driver, executorId, slaveId, status);
  } catch (Throwable t) {
    handleUncaughtSchedulerException(t);
  } finally {
    lock.unlock();
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:18,代码来源:SingularityMesosSchedulerDelegator.java

示例11: error

import org.apache.mesos.SchedulerDriver; //导入依赖的package包/类
@Override
public void error(SchedulerDriver driver, String message) {
  if (!isRunning()) {
    LOG.info("Ignoring error {} because scheduler isn't running ({})", message, state);
    return;
  }

  lock.lock();

  try {
    scheduler.error(driver, message);

    LOG.error("Aborting due to error: {}", message);

    abort.abort(AbortReason.MESOS_ERROR, Optional.<Throwable>absent());
  } catch (Throwable t) {
    handleUncaughtSchedulerException(t);
  } finally {
    lock.unlock();
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:22,代码来源:SingularityMesosSchedulerDelegator.java

示例12: scheduleReconciliationCheck

import org.apache.mesos.SchedulerDriver; //导入依赖的package包/类
private void scheduleReconciliationCheck(final SchedulerDriver driver, final long reconciliationStart, final Collection<SingularityTaskId> remainingTaskIds, final int numTimes) {
  LOG.info("Scheduling reconciliation check #{} - {} tasks left - waiting {}", numTimes + 1, remainingTaskIds.size(), JavaUtils.durationFromMillis(configuration.getCheckReconcileWhenRunningEveryMillis()));

  executorService.schedule(new Runnable() {

    @Override
    public void run() {
      try {
        checkReconciliation(driver, reconciliationStart, remainingTaskIds, numTimes + 1);
      } catch (Throwable t) {
        LOG.error("While checking for reconciliation tasks", t);
        exceptionNotifier.notify(t);
        abort.abort(AbortReason.UNRECOVERABLE_ERROR, Optional.of(t));
      }
    }
  }, configuration.getCheckReconcileWhenRunningEveryMillis(), TimeUnit.MILLISECONDS);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:18,代码来源:SingularityTaskReconciliation.java

示例13: declineOffers

import org.apache.mesos.SchedulerDriver; //导入依赖的package包/类
/**
 * Decline unused {@link org.apache.mesos.Protos.Offer}s.
 *
 * @param driver The {@link SchedulerDriver} that will receive the declineOffer() calls
 * @param unusedOffers The collection of Offers to decline
 * @param refuseSeconds The number of seconds for which the offers should be refused
 */
private static void declineOffers(
        SchedulerDriver driver, Collection<Protos.Offer> unusedOffers, int refuseSeconds) {
    Collection<Protos.OfferID> offerIds = unusedOffers.stream()
            .map(offer -> offer.getId())
            .collect(Collectors.toList());
    LOGGER.info("Declining {} unused offer{} for {} seconds: {}",
            offerIds.size(),
            offerIds.size() == 1 ? "" : "s",
            refuseSeconds,
            offerIds.stream().map(Protos.OfferID::getValue).collect(Collectors.toList()));
    final Protos.Filters filters = Protos.Filters.newBuilder()
            .setRefuseSeconds(refuseSeconds)
            .build();
    offerIds.forEach(offerId -> driver.declineOffer(offerId, filters));
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:23,代码来源:OfferUtils.java

示例14: create

import org.apache.mesos.SchedulerDriver; //导入依赖的package包/类
@Override
public SchedulerDriver create(
    Scheduler scheduler,
    Optional<Protos.Credential> credentials,
    FrameworkInfo frameworkInfo,
    String master) {
  if (credentials.isPresent()) {
    return new MesosSchedulerDriver(
        scheduler,
        frameworkInfo,
        master,
        false, // Disable implicit acknowledgements.
        credentials.get());
  } else {
    return new MesosSchedulerDriver(
        scheduler,
        frameworkInfo,
        master,
        false); // Disable implicit acknowledgements.
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:22,代码来源:DriverFactoryImpl.java

示例15: allPlansComplete

import org.apache.mesos.SchedulerDriver; //导入依赖的package包/类
/**
 * Verifies that the scheduler's plans are all complete -- that there's no pending work.
 */
public static Expect allPlansComplete() {
    return new Expect() {
        @Override
        public void expect(ClusterState state, SchedulerDriver mockDriver) {
            Collection<Plan> plans = state.getPlans();
            for (Plan plan : plans) {
                if (!plan.isComplete()) {
                    Assert.fail(String.format(
                            "%s plan is not complete. Plans: %s",
                            plan.getName(),
                            plans.stream().map(p -> p.toString()).collect(Collectors.toList())));
                }
            }
        }

        @Override
        public String getDescription() {
            return "All plans complete";
        }
    };
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:25,代码来源:Expect.java


注:本文中的org.apache.mesos.SchedulerDriver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。