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


Java Protos类代码示例

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


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

示例1: explicitReconcile

import org.apache.mesos.Protos; //导入依赖的package包/类
/**
 * 全量的显示协调.
 */
public void explicitReconcile() {
    lock.lock();
    try {
        Set<TaskContext> runningTask = new HashSet<>();
        for (Set<TaskContext> each : facadeService.getAllRunningTasks().values()) {
            runningTask.addAll(each);
        }
        if (runningTask.isEmpty()) {
            return;
        }
        log.info("Requesting {} tasks reconciliation with the Mesos master", runningTask.size());
        schedulerDriver.reconcileTasks(Collections2.transform(runningTask, new Function<TaskContext, Protos.TaskStatus>() {
            @Override
            public Protos.TaskStatus apply(final TaskContext input) {
                return Protos.TaskStatus.newBuilder()
                        .setTaskId(Protos.TaskID.newBuilder().setValue(input.getId()).build())
                        .setSlaveId(Protos.SlaveID.newBuilder().setValue(input.getSlaveId()).build())
                        .setState(Protos.TaskState.TASK_RUNNING).build();
            }
        }));
    } finally {
        lock.unlock();
    }
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:28,代码来源:ReconcileService.java

示例2: getTaskInfoList

import org.apache.mesos.Protos; //导入依赖的package包/类
private List<Protos.TaskInfo> getTaskInfoList(final Collection<String> integrityViolationJobs, final VMAssignmentResult vmAssignmentResult, final String hostname, final Protos.Offer offer) {
    List<Protos.TaskInfo> result = new ArrayList<>(vmAssignmentResult.getTasksAssigned().size());
    for (TaskAssignmentResult each: vmAssignmentResult.getTasksAssigned()) {
        TaskContext taskContext = TaskContext.from(each.getTaskId());
        String jobName = taskContext.getMetaInfo().getJobName();
        if (!integrityViolationJobs.contains(jobName) && !facadeService.isRunning(taskContext) && !facadeService.isJobDisabled(jobName)) {
            Protos.TaskInfo taskInfo = getTaskInfo(offer, each);
            if (null != taskInfo) {
                result.add(taskInfo);
                facadeService.addMapping(taskInfo.getTaskId().getValue(), hostname);
                taskScheduler.getTaskAssigner().call(each.getRequest(), hostname);
            }
        }
    }
    return result;
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:17,代码来源:TaskLaunchScheduledService.java

示例3: buildCustomizedExecutorTaskInfo

import org.apache.mesos.Protos; //导入依赖的package包/类
private Protos.TaskInfo buildCustomizedExecutorTaskInfo(final TaskContext taskContext, final CloudAppConfiguration appConfig, final CloudJobConfiguration jobConfig, 
                                                        final ShardingContexts shardingContexts, final Protos.Offer offer, final Protos.CommandInfo command) {
    Protos.TaskInfo.Builder result = Protos.TaskInfo.newBuilder().setTaskId(Protos.TaskID.newBuilder().setValue(taskContext.getId()).build())
            .setName(taskContext.getTaskName()).setSlaveId(offer.getSlaveId())
            .addResources(buildResource("cpus", jobConfig.getCpuCount(), offer.getResourcesList()))
            .addResources(buildResource("mem", jobConfig.getMemoryMB(), offer.getResourcesList()))
            .setData(ByteString.copyFrom(new TaskInfoData(shardingContexts, jobConfig).serialize()));
    Protos.ExecutorInfo.Builder executorBuilder = Protos.ExecutorInfo.newBuilder().setExecutorId(Protos.ExecutorID.newBuilder()
            .setValue(taskContext.getExecutorId(jobConfig.getAppName()))).setCommand(command)
            .addResources(buildResource("cpus", appConfig.getCpuCount(), offer.getResourcesList()))
            .addResources(buildResource("mem", appConfig.getMemoryMB(), offer.getResourcesList()));
    if (env.getJobEventRdbConfiguration().isPresent()) {
        executorBuilder.setData(ByteString.copyFrom(SerializationUtils.serialize(env.getJobEventRdbConfigurationMap()))).build();
    }
    return result.setExecutor(executorBuilder.build()).build();
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:17,代码来源:TaskLaunchScheduledService.java

示例4: getSchedulerDriver

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

示例5: run

import org.apache.mesos.Protos; //导入依赖的package包/类
@Override
public void run() {
    Thread.currentThread().setContextClassLoader(TaskThread.class.getClassLoader());
    executorDriver.sendStatusUpdate(Protos.TaskStatus.newBuilder().setTaskId(taskInfo.getTaskId()).setState(Protos.TaskState.TASK_RUNNING).build());
    Map<String, Object> data = SerializationUtils.deserialize(taskInfo.getData().toByteArray());
    ShardingContexts shardingContexts = (ShardingContexts) data.get("shardingContext");
    @SuppressWarnings("unchecked")
    JobConfigurationContext jobConfig = new JobConfigurationContext((Map<String, String>) data.get("jobConfigContext"));
    try {
        ElasticJob elasticJob = getElasticJobInstance(jobConfig);
        final CloudJobFacade jobFacade = new CloudJobFacade(shardingContexts, jobConfig, jobEventBus);
        if (jobConfig.isTransient()) {
            JobExecutorFactory.getJobExecutor(elasticJob, jobFacade).execute();
            executorDriver.sendStatusUpdate(Protos.TaskStatus.newBuilder().setTaskId(taskInfo.getTaskId()).setState(Protos.TaskState.TASK_FINISHED).build());
        } else {
            new DaemonTaskScheduler(elasticJob, jobConfig, jobFacade, executorDriver, taskInfo.getTaskId()).init();
        }
        // CHECKSTYLE:OFF
    } catch (final Throwable ex) {
        // CHECKSTYLE:ON
        log.error("Elastic-Job-Cloud-Executor error", ex);
        executorDriver.sendStatusUpdate(Protos.TaskStatus.newBuilder().setTaskId(taskInfo.getTaskId()).setState(Protos.TaskState.TASK_ERROR).setMessage(ExceptionUtil.transform(ex)).build());
        executorDriver.stop();
        throw ex;
    }
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:27,代码来源:TaskExecutor.java

示例6: execute

import org.apache.mesos.Protos; //导入依赖的package包/类
@Override
public void execute(final JobExecutionContext context) throws JobExecutionException {
    ShardingContexts shardingContexts = jobFacade.getShardingContexts();
    int jobEventSamplingCount = shardingContexts.getJobEventSamplingCount();
    int currentJobEventSamplingCount = shardingContexts.getCurrentJobEventSamplingCount();
    if (jobEventSamplingCount > 0 && ++currentJobEventSamplingCount < jobEventSamplingCount) {
        shardingContexts.setCurrentJobEventSamplingCount(currentJobEventSamplingCount);
        jobFacade.getShardingContexts().setAllowSendJobEvent(false);
        JobExecutorFactory.getJobExecutor(elasticJob, jobFacade).execute();
    } else {
        jobFacade.getShardingContexts().setAllowSendJobEvent(true);
        executorDriver.sendStatusUpdate(Protos.TaskStatus.newBuilder().setTaskId(taskId).setState(Protos.TaskState.TASK_RUNNING).setMessage("BEGIN").build());
        JobExecutorFactory.getJobExecutor(elasticJob, jobFacade).execute();
        executorDriver.sendStatusUpdate(Protos.TaskStatus.newBuilder().setTaskId(taskId).setState(Protos.TaskState.TASK_RUNNING).setMessage("COMPLETE").build());
        shardingContexts.setCurrentJobEventSamplingCount(0);
    }
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:18,代码来源:DaemonTaskScheduler.java

示例7: main

import org.apache.mesos.Protos; //导入依赖的package包/类
public static void main(String[] args) {
    System.out.println("Starting executor");

    if (new File("config").mkdir()) {
        System.out.println("Created config directory");
    }

    MustacheFactory mustacheFactory = new DefaultMustacheFactory();
    final Mustache filebeatMustache = mustacheFactory.compile("filebeat.yaml.mustache");
    final Mustache metricbeatMustache = mustacheFactory.compile("metricbeat.yaml.mustache");
    try {
        MesosExecutorDriver driver = new MesosExecutorDriver(new HumioExecutor(filebeatMustache, metricbeatMustache));
        final Protos.Status status = driver.run();

        System.out.println("status = " + status);
        if (status.equals(Protos.Status.DRIVER_STOPPED)) {
            System.exit(0);
        } else {
            System.err.println("Error: " + status);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:humio,项目名称:dcos2humio,代码行数:25,代码来源:ExecutorApplication.java

示例8: build

import org.apache.mesos.Protos; //导入依赖的package包/类
/**
 * Builds a set of {@link HostOffer} for the current configuration.
 *
 * @param hostAttributes Host attributes to initialize offers from.
 * @return Set of offers.
 */
Set<HostOffer> build(Set<IHostAttributes> hostAttributes) {
  ImmutableSet.Builder<HostOffer> offers = ImmutableSet.builder();
  int id = 0;
  for (IHostAttributes attributes : hostAttributes) {
    Protos.Offer offer = Protos.Offer.newBuilder()
        .addAllResources(new ResourceSlot(cpu, ram, disk, ports)
            .toResourceList(DEV_TIER))
        .setId(Protos.OfferID.newBuilder().setValue(String.format(OFFER_ID_FORMAT, id++)))
        .setFrameworkId(Protos.FrameworkID.newBuilder().setValue(FRAMEWORK_ID))
        .setSlaveId(Protos.SlaveID.newBuilder().setValue(attributes.getSlaveId()))
        .setHostname(String.format(attributes.getHost()))
        .build();

    offers.add(new HostOffer(offer, attributes));
  }

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

示例9: stepWithDifferentNameLaunches

import org.apache.mesos.Protos; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void stepWithDifferentNameLaunches() throws Exception {
    final List<Offer> offers = getOffers();
    final Protos.TaskStatus status = TaskTestUtils.generateStatus(taskInfo.getTaskId(), Protos.TaskState.TASK_FAILED);
    final Step step = mock(Step.class);

    launchConstrainer.setCanLaunch(true);
    stateStore.storeTasks(taskInfos);
    stateStore.storeStatus(taskInfo.getName(), status);
    stateStore.storeFrameworkId(TestConstants.FRAMEWORK_ID);
    when(offerAccepter.accept(any(), any())).thenReturn(Arrays.asList(offers.get(0).getId()));
    when(step.getName()).thenReturn("different-name");
    when(mockDeployManager.getCandidates(Collections.emptyList())).thenReturn((Collection) Arrays.asList(step));

    recoveryManager.update(status);
    Collection<Protos.OfferID> acceptedOffers = planScheduler.resourceOffers(
            schedulerDriver,
            getOffers(),
            planCoordinator.getCandidates());

    assertEquals(1, acceptedOffers.size());
    reset(mockDeployManager);
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:25,代码来源:DefaultRecoveryPlanManagerTest.java

示例10: newTaskID

import org.apache.mesos.Protos; //导入依赖的package包/类
/**
 * Generates a new task ID.
 */
@Override
public Protos.TaskID newTaskID() throws Exception {
	synchronized (startStopLock) {
		verifyIsRunning();

		int nextCount;
		boolean success;
		do {
			ZooKeeperVersionedValue<Integer> count = totalTaskCountInZooKeeper.getVersionedValue();
			nextCount = count.getValue() + 1;
			success = totalTaskCountInZooKeeper.trySetCount(count, nextCount);
		}
		while (!success);

		Protos.TaskID taskID = Protos.TaskID.newBuilder().setValue(TASKID_FORMAT.format(nextCount)).build();
		return taskID;
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:22,代码来源:ZooKeeperMesosWorkerStore.java

示例11: getHostState

import org.apache.mesos.Protos; //导入依赖的package包/类
private SingularityHostState getHostState() {
  final boolean master = isMaster();
  final Protos.Status driverStatus = getCurrentStatus();

  final RuntimeMXBean mxBean = ManagementFactory.getRuntimeMXBean();
  final long uptime = mxBean.getUptime();

  final long now = System.currentTimeMillis();
  final Optional<Long> lastOfferTimestamp = getLastOfferTimestamp();
  final Optional<Long> millisSinceLastOfferTimestamp = lastOfferTimestamp.isPresent() ? Optional.of(now - lastOfferTimestamp.get()) : Optional.<Long> absent();

  String mesosMaster = null;
  Optional<MasterInfo> mesosMasterInfo = getMaster();

  if (mesosMasterInfo.isPresent()) {
    mesosMaster = MesosUtils.getMasterHostAndPort(mesosMasterInfo.get());
  }

  return new SingularityHostState(master, uptime, driverStatus.name(), millisSinceLastOfferTimestamp, hostAndPort.getHostText(), hostAndPort.getHostText(), mesosMaster, scheduler.isConnected());
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:21,代码来源:SingularityLeaderController.java

示例12: run

import org.apache.mesos.Protos; //导入依赖的package包/类
public Protos.Status run() {
  LOG.info("{} starting MesosExecutorDriver...", name);

  final MesosExecutorDriver driver = new MesosExecutorDriver(singularityExecutor);

  Runtime.getRuntime().addShutdownHook(new Thread("SingularityExecutorRunnerGracefulShutdown") {

    @Override
    public void run() {
      LOG.info("Executor is shutting down, ensuring shutdown via shutdown hook");
      monitor.shutdown(Optional.of((ExecutorDriver) driver));
    }

  });

  return driver.run();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:18,代码来源:SingularityExecutorRunner.java

示例13: generateStatusMap

import org.apache.mesos.Protos; //导入依赖的package包/类
private Map<String, Protos.TaskStatus> generateStatusMap(Collection<String> oldTaskNames,
                                                         ServiceSpec newServiceSpec)
        throws KafkaConfigUpgradeException{
    Map<String, Protos.TaskStatus> taskStatusMap = new HashMap<>();

    for (String oldTaskName : oldTaskNames) {
        int brokerId = oldTaskName2BrokerId(oldTaskName);
        String newName = getNewTaskName(brokerId,
                newServiceSpec.getPods().get(0).getType(),
                newServiceSpec.getPods().get(0).getTasks().get(0).getName());

        Optional<Protos.TaskStatus> optionalStatus = stateStore.fetchStatus(oldTaskName);
        if (!optionalStatus.isPresent()){
            throw new KafkaConfigUpgradeException("Can not fetch status for Task " + oldTaskName);
        }
        taskStatusMap.put(newName, optionalStatus.get());
    }
    return taskStatusMap;
}
 
开发者ID:mesosphere,项目名称:dcos-kafka-service,代码行数:20,代码来源:KafkaConfigUpgrade.java

示例14: resourceOffers

import org.apache.mesos.Protos; //导入依赖的package包/类
public void resourceOffers(SchedulerDriver driver, List<Protos.Offer> offers) {
  synchronized (_offersLock) {
    if (_offers == null) {
      return;
    }
    LOG.debug("resourceOffers: Currently have {} offers buffered {}",
              _offers.size(), (_offers.size() > 0 ? (":" + offerMapToString(_offers)) : ""));

    for (Protos.Offer offer : offers) {
      if (isHostAccepted(offer.getHostname())) {
        LOG.debug("resourceOffers: Recording offer from host: {}, offerId: {}",
                  offer.getHostname(), offer.getId().getValue());
        _offers.put(offer.getId(), offer);
      } else {
        LOG.debug("resourceOffers: Declining offer from host: {}, offerId: {}",
                  offer.getHostname(), offer.getId().getValue());
        driver.declineOffer(offer.getId());
      }
    }
    LOG.debug("resourceOffers: After processing offers, now have {} offers buffered: {}",
              _offers.size(), offerMapToString(_offers));
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:24,代码来源:MesosNimbus.java

示例15: getCredentials

import org.apache.mesos.Protos; //导入依赖的package包/类
private static Optional<Protos.Credential> getCredentials() {
  if (FRAMEWORK_AUTHENTICATION_FILE.hasAppliedValue()) {
    Properties properties;
    try {
      properties = parseCredentials(new FileInputStream(FRAMEWORK_AUTHENTICATION_FILE.get()));
    } catch (FileNotFoundException e) {
      LOG.error("Authentication File not Found");
      throw Throwables.propagate(e);
    }

    LOG.info(
        "Connecting to master using authentication (principal: {}).",
        properties.get(PRINCIPAL_KEY));

    return Optional.of(Protos.Credential.newBuilder()
        .setPrincipal(properties.getProperty(PRINCIPAL_KEY))
        .setSecret(properties.getProperty(SECRET_KEY))
        .build());
  } else {
    return Optional.absent();
  }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:23,代码来源:CommandLineDriverSettingsModule.java


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