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


Java SlaveID类代码示例

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


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

示例1: frameworkMessage

import org.apache.mesos.Protos.SlaveID; //导入依赖的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

示例2: slaveLost

import org.apache.mesos.Protos.SlaveID; //导入依赖的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

示例3: executorLost

import org.apache.mesos.Protos.SlaveID; //导入依赖的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

示例4: createMocks

import org.apache.mesos.Protos.SlaveID; //导入依赖的package包/类
@Before
public void createMocks() {
  pendingTask = new SingularityPendingTask(new SingularityPendingTaskId("test", "1", 0, 1, PendingType.IMMEDIATE, 0), Optional.<List<String>> absent(),
      Optional.<String> absent(), Optional.<String> absent(), Optional.<Boolean> absent(), Optional.<String> absent());

  final SingularitySlaveAndRackHelper slaveAndRackHelper = mock(SingularitySlaveAndRackHelper.class);
  final ExecutorIdGenerator idGenerator = mock(ExecutorIdGenerator.class);

  when(idGenerator.getNextExecutorId()).then(new CreateFakeId());

  builder = new SingularityMesosTaskBuilder(new ObjectMapper(), slaveAndRackHelper, idGenerator, new SingularityConfiguration());

  taskResources = new Resources(1, 1, 0);
  executorResources = new Resources(0.1, 1, 0);

  offer = Offer.newBuilder()
      .setSlaveId(SlaveID.newBuilder().setValue("1"))
      .setId(OfferID.newBuilder().setValue("1"))
      .setFrameworkId(FrameworkID.newBuilder().setValue("1"))
      .setHostname("test")
      .build();

  when(slaveAndRackHelper.getRackId(offer)).thenReturn(Optional.<String> absent());
  when(slaveAndRackHelper.getMaybeTruncatedHost(offer)).thenReturn("host");
  when(slaveAndRackHelper.getRackIdOrDefault(offer)).thenReturn("DEFAULT");
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:27,代码来源:SingularityMesosTaskBuilderTest.java

示例5: getValidOffers

import org.apache.mesos.Protos.SlaveID; //导入依赖的package包/类
/**
 * Creates given amount of offers with adequate resources
 *
 * @param amount amount of offers to create
 * @return given amount of offers with adequate resources
 */
public static List<Offer> getValidOffers(int amount) {
    List<Offer> offers = new ArrayList<>();
    SchedulerConfiguration config = new SchedulerConfiguration();
    for (int i = 0; i < amount; i++) {
        Offer offer = Offer.newBuilder()
                .setId(OfferID.newBuilder().setValue("valid-offer-" + i).build())
                .setSlaveId(SlaveID.newBuilder().setValue("slave-" + i).build())
                .setFrameworkId(FrameworkID.newBuilder().setValue("kibana").build())
                .setHostname("localhost")
                .addResources(Resources.buildCpuResource(config.getRequiredCpu()))
                .addResources(Resources.buildMemResource(config.getRequiredMem()))
                .addResources(Resources.buildDiskResource(config.getRequiredDisk()))
                .addResources(Resources.buildPortResource(9000, (long) (8999 + SchedulerConfiguration.getRequiredPortCount())))
                .build();
        offers.add(offer);
    }
    return offers;
}
 
开发者ID:Praqma,项目名称:mesos-kibana,代码行数:25,代码来源:TestUtils.java

示例6: getInvalidOffers

import org.apache.mesos.Protos.SlaveID; //导入依赖的package包/类
/**
 * Creates given amount of offers with inadequate resources
 *
 * @param amount amount of offers to create
 * @return given amount of offers with inadequate resources
 */
public static List<Offer> getInvalidOffers(int amount) {
    List<Offer> offers = new ArrayList<>();
    SchedulerConfiguration config = new SchedulerConfiguration();
    for (int i = 0; i < amount; i++) {
        Offer offer = Offer.newBuilder()
                .setId(OfferID.newBuilder().setValue("invalid-offer-" + i).build())
                .setSlaveId(SlaveID.newBuilder().setValue("slave-" + i).build())
                .setFrameworkId(FrameworkID.newBuilder().setValue("kibana").build())
                .setHostname("localhost")
                .addResources(Resources.buildCpuResource(config.getRequiredCpu() / 2))
                .addResources(Resources.buildMemResource(config.getRequiredMem() / 2))
                .addResources(Resources.buildDiskResource(config.getRequiredDisk() / 2))
                .build();
        offers.add(offer);
    }
    return offers;
}
 
开发者ID:Praqma,项目名称:mesos-kibana,代码行数:24,代码来源:TestUtils.java

示例7: stopExecutors

import org.apache.mesos.Protos.SlaveID; //导入依赖的package包/类
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);
    }
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:12,代码来源:CloudAppRestfulApi.java

示例8: slaveLost

import org.apache.mesos.Protos.SlaveID; //导入依赖的package包/类
public void slaveLost(SlaveID slaveIdObj) {
  final String slaveId = slaveIdObj.getValue();

  Optional<SingularitySlave> slave = slaveManager.getObject(slaveId);

  if (slave.isPresent()) {
    slaveManager.changeState(slave.get(), MachineState.DEAD, Optional.<String> absent(), Optional.<String> absent());

    checkRackAfterSlaveLoss(slave.get());
  } else {
    LOG.warn("Lost a slave {}, but didn't know about it", slaveId);
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:14,代码来源:SingularitySlaveAndRackManager.java

示例9: checkReconciliation

import org.apache.mesos.Protos.SlaveID; //导入依赖的package包/类
private void checkReconciliation(final SchedulerDriver driver, final long reconciliationStart, final Collection<SingularityTaskId> remainingTaskIds, final int numTimes) {
  final List<SingularityTaskStatusHolder> taskStatusHolders = taskManager.getLastActiveTaskStatusesFor(remainingTaskIds);
  final List<TaskStatus> taskStatuses = Lists.newArrayListWithCapacity(taskStatusHolders.size());

  for (SingularityTaskStatusHolder taskStatusHolder : taskStatusHolders) {
    if (taskStatusHolder.getServerId().equals(serverId) && taskStatusHolder.getServerTimestamp() > reconciliationStart) {
      continue;
    }

    if (taskStatusHolder.getTaskStatus().isPresent()) {
      LOG.debug("Re-requesting task status for {}", taskStatusHolder.getTaskId());
      taskStatuses.add(taskStatusHolder.getTaskStatus().get());
    } else {
      TaskStatus.Builder fakeTaskStatusBuilder = TaskStatus.newBuilder()
          .setTaskId(TaskID.newBuilder().setValue(taskStatusHolder.getTaskId().getId()))
          .setState(TaskState.TASK_STARTING);

      if (taskStatusHolder.getSlaveId().isPresent()) {
        fakeTaskStatusBuilder.setSlaveId(SlaveID.newBuilder().setValue(taskStatusHolder.getSlaveId().get()));
      }

      LOG.info("Task {} didn't have a TaskStatus yet, submitting fake status", taskStatusHolder.getTaskId());
      taskStatuses.add(fakeTaskStatusBuilder.build());
    }
  }

  if (taskStatuses.isEmpty()) {
    LOG.info("Task reconciliation ended after {} checks and {}", numTimes, JavaUtils.duration(reconciliationStart));

    isRunningReconciliation.set(false);

    return;
  }

  LOG.info("Requesting reconciliation of {} taskStatuses, task reconciliation has been running for {}", taskStatuses.size(), JavaUtils.duration(reconciliationStart));

  driver.reconcileTasks(taskStatuses);

  scheduleReconciliationCheck(driver, reconciliationStart, remainingTaskIds, numTimes);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:41,代码来源:SingularityTaskReconciliation.java

示例10: runActionOnPoll

import org.apache.mesos.Protos.SlaveID; //导入依赖的package包/类
@Override
public void runActionOnPoll() {
  final long start = System.currentTimeMillis();

  final List<SingularityTaskShellCommandRequest> shellRequests = taskManager.getAllQueuedTaskShellCommandRequests();

  Optional<SchedulerDriver> driver = schedulerDriverSupplier.get();

  if (!driver.isPresent()) {
    LOG.warn("Unable to process shell requests because scheduler driver isn't present ({} tasks waiting)", shellRequests.size());
    return;
  }

  if (shellRequests.isEmpty()) {
    LOG.trace("No shell requests to send.");
    return;
  }

  for (SingularityTaskShellCommandRequest shellRequest : shellRequests) {
    Optional<SingularityTask> task = taskManager.getTask(shellRequest.getTaskId());

    if (!task.isPresent() || !taskManager.isActiveTask(shellRequest.getTaskId().getId())) {
      LOG.info("Skipping shell request {} because {} didn't exist or isn't active", shellRequest, shellRequest.getTaskId());
      continue;
    }

    final ExecutorID executorId = task.get().getMesosTask().getExecutor().getExecutorId();
    final SlaveID slaveId = task.get().getMesosTask().getSlaveId();
    final byte[] bytes = transcoder.toBytes(shellRequest);

    final Status status = driver.get().sendFrameworkMessage(executorId, slaveId, bytes);

    LOG.info("Sent {} ({} bytes) to {} on {} ({})", shellRequest, bytes.length, executorId, slaveId, status);

    taskManager.saveTaskShellCommandRequestToTask(shellRequest);
    taskManager.deleteTaskShellCommandRequestFromQueue(shellRequest);
  }

  LOG.info("Sent {} shell requests to executors in {}", shellRequests.size(), JavaUtils.duration(start));
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:41,代码来源:SingularityTaskShellCommandDispatchPoller.java

示例11: createOffer

import org.apache.mesos.Protos.SlaveID; //导入依赖的package包/类
protected Offer createOffer(double cpus, double memory, String slave, String host, Optional<String> rack, Map<String, String> attributes, String[] portRanges) {
  SlaveID slaveId = SlaveID.newBuilder().setValue(slave).build();
  FrameworkID frameworkId = FrameworkID.newBuilder().setValue("framework1").build();

  Random r = new Random();

  List<Attribute> attributesList = new ArrayList<>();
  for (Map.Entry<String, String> entry : attributes.entrySet()) {
    attributesList.add(Attribute.newBuilder()
        .setType(Type.TEXT)
        .setName(entry.getKey())
        .setText(Text.newBuilder().setValue(entry.getValue()).build())
        .build());
  }

  return Offer.newBuilder()
      .setId(OfferID.newBuilder().setValue("offer" + r.nextInt(1000)).build())
      .setFrameworkId(frameworkId)
      .setSlaveId(slaveId)
      .setHostname(host)
      .addAttributes(Attribute.newBuilder().setType(Type.TEXT).setText(Text.newBuilder().setValue(rack.or(configuration.getMesosConfiguration().getDefaultRackId()))).setName(configuration.getMesosConfiguration().getRackIdAttributeKey()))
      .addResources(Resource.newBuilder().setType(Type.SCALAR).setName(MesosUtils.CPUS).setScalar(Scalar.newBuilder().setValue(cpus)))
      .addResources(Resource.newBuilder().setType(Type.SCALAR).setName(MesosUtils.MEMORY).setScalar(Scalar.newBuilder().setValue(memory)))
      .addResources(MesosUtilsTest.buildPortRanges(portRanges))
      .addAllAttributes(attributesList)
      .build();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:28,代码来源:SingularitySchedulerTestBase.java

示例12: testTaskOddities

import org.apache.mesos.Protos.SlaveID; //导入依赖的package包/类
@Test
public void testTaskOddities() {
  // test unparseable status update
  TaskStatus.Builder bldr = TaskStatus.newBuilder()
      .setTaskId(TaskID.newBuilder().setValue("task"))
      .setSlaveId(SlaveID.newBuilder().setValue("slave1"))
      .setState(TaskState.TASK_RUNNING);

  // should not throw exception:
  sms.statusUpdate(driver, bldr.build());

  initRequest();
  initFirstDeploy();

  SingularityTask taskOne = launchTask(request, firstDeploy, 1, TaskState.TASK_STARTING);

  taskManager.deleteTaskHistory(taskOne.getTaskId());

  Assert.assertTrue(taskManager.isActiveTask(taskOne.getTaskId().getId()));

  statusUpdate(taskOne, TaskState.TASK_RUNNING);
  statusUpdate(taskOne, TaskState.TASK_FAILED);

  Assert.assertTrue(!taskManager.isActiveTask(taskOne.getTaskId().getId()));

  Assert.assertEquals(2, taskManager.getTaskHistoryUpdates(taskOne.getTaskId()).size());
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:28,代码来源:SingularitySchedulerTest.java

示例13: buildOffer

import org.apache.mesos.Protos.SlaveID; //导入依赖的package包/类
private Offer buildOffer(String... ranges) {
  Offer.Builder offer = Offer.newBuilder()
      .setId(OfferID.newBuilder().setValue("offerid").build())
      .setFrameworkId(FrameworkID.newBuilder().setValue("frameworkid").build())
      .setHostname("hostname")
      .setSlaveId(SlaveID.newBuilder().setValue("slaveid").build());

  offer.addResources(buildPortRanges(ranges));

  return offer.build();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:12,代码来源:MesosUtilsTest.java

示例14: executorLost

import org.apache.mesos.Protos.SlaveID; //导入依赖的package包/类
@Override
public void executorLost(SchedulerDriver schedulerDriver, ExecutorID executorID, SlaveID slaveID,
    int status) {

  log.warn("Lost executor " + executorID);
  counters.get("scheduler_lost_executors").incrementAndGet();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:8,代码来源:MesosSchedulerImpl.java

示例15: frameworkMessage

import org.apache.mesos.Protos.SlaveID; //导入依赖的package包/类
@Timed("scheduler_framework_message")
@Override
public void frameworkMessage(
    SchedulerDriver driver,
    ExecutorID executorID,
    SlaveID slave,
    byte[] data) {

  log.warn("Ignoring framework message.");
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:11,代码来源:MesosSchedulerImpl.java


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