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


Java Protos.Offer方法代码示例

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


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

示例1: 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

示例2: 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

示例3: testSuccessKeystore

import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Test
public void testSuccessKeystore() throws Exception {
    ArrayList<TransportEncryptionSpec> transportEncryptionSpecs = new ArrayList<>();
    transportEncryptionSpecs.add(new DefaultTransportEncryptionSpec.Builder()
            .name("test-tls")
            .type(TransportEncryptionSpec.Type.KEYSTORE)
            .build());

    Protos.Offer offer = OfferTestUtils.getOffer(ResourceTestUtils.getUnreservedCpus(2.0));
    PodInfoBuilder podInfoBuilder = getPodInfoBuilderForTransportEncryption(transportEncryptionSpecs);

    EvaluationOutcome outcome = tlsEvaluationStage.evaluate(
            new MesosResourcePool(offer, Optional.of(Constants.ANY_ROLE)), podInfoBuilder);
    Assert.assertTrue(outcome.isPassing());

    // Check that TLS update was invoked
    verify(mockTLSArtifactsUpdater).update(Matchers.any(), Matchers.any(), Matchers.eq("test-tls"));

    Protos.ContainerInfo executorContainer =
            podInfoBuilder.getTaskBuilder(TestConstants.TASK_NAME).getExecutor().getContainer();
    Assert.assertEquals(0, executorContainer.getVolumesCount());

    Protos.ContainerInfo taskContainer = podInfoBuilder.getTaskBuilder(TestConstants.TASK_NAME).getContainer();
    assertKeystoreArtifacts(taskContainer, tlsArtifactPaths, "test-tls");
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:26,代码来源:TLSEvaluationStageTest.java

示例4: runReconcile

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private void runReconcile(QueuedSchedulerDriver driver) {
    while (!scheduler.getReconciler().isReconciled()) {

        final Protos.Offer offer = TestUtils.generateOffer(frameworkId.getValue(), 4, 10240, 10240);
        scheduler.resourceOffers(driver, Arrays.asList(offer));
        final Collection<Protos.TaskStatus> taskStatuses = driver.drainReconciling();
        if (taskStatuses.isEmpty()) {
            // All reconciled
            cassandraState.getTaskStatuses().forEach(status -> scheduler.statusUpdate(driver, status));
        } else {
            taskStatuses.forEach(status -> scheduler.statusUpdate(driver, status));
        }

        if (!scheduler.getReconciler().isReconciled()) {
            final Collection<Protos.OfferID> declined = driver.drainDeclined();
            assertEquals(1, declined.size());
            assertEquals(declined.iterator().next(), offer.getId());
        }
    }
}
 
开发者ID:mesosphere,项目名称:dcos-cassandra-service,代码行数:21,代码来源:CassandraSchedulerTest.java

示例5: testHealthCheckPortEnvvarIsCorrectOnOverlay

import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Test
public void testHealthCheckPortEnvvarIsCorrectOnOverlay() throws Exception {
    DefaultPodInstance podInstance = getPodInstance("valid-port-healthcheck-overlay.yml");
    PodInstanceRequirement podInstanceRequirement =
            PodInstanceRequirement.newBuilder(podInstance, TaskUtils.getTaskNames(podInstance))
                    .build();
    PodInfoBuilder podInfoBuilder = getPodInfoBuilder(podInstanceRequirement, true);
    Protos.Resource offeredPorts = ResourceTestUtils.getUnreservedPorts(10000, 10000);
    Protos.Offer offer = OfferTestUtils.getOffer(offeredPorts);
    PortEvaluationStage portEvaluationStage =
            new PortEvaluationStage(getPortSpec(podInstance), TestConstants.TASK_NAME, Optional.empty());
    EvaluationOutcome outcome = portEvaluationStage.evaluate(
            new MesosResourcePool(offer, Optional.of(Constants.ANY_ROLE)), podInfoBuilder);
    Assert.assertTrue(outcome.isPassing());
    Assert.assertEquals(0, outcome.getOfferRecommendations().size());
    Protos.TaskInfo.Builder taskBuilder = podInfoBuilder.getTaskBuilders().stream().findFirst().get();
    Assert.assertTrue(taskBuilder.getCommand().getEnvironment().getVariablesList().stream()
            .filter(variable -> variable.getName().equals("PORT_TEST_PORT") && variable.getValue().equals("10000"))
            .count() == 1);
    Assert.assertTrue(taskBuilder.getHealthCheck().getCommand().getEnvironment().getVariablesList().stream()
            .filter(variable -> variable.getName().equals("PORT_TEST_PORT") && variable.getValue().equals("10000"))
            .count() == 1);
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:24,代码来源:PortEvaluationStageTest.java

示例6: updateFaultDomainEnv

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private static void updateFaultDomainEnv(Protos.TaskInfo.Builder builder, Protos.Offer offer) {
    if (!offer.hasDomain() || !offer.getDomain().hasFaultDomain() || !builder.hasCommand()) {
        return;
    }

    Protos.Environment.Variable regionVar = Protos.Environment.Variable.newBuilder()
            .setName(EnvConstants.REGION_TASKENV)
            .setValue(offer.getDomain().getFaultDomain().getRegion().getName())
            .build();

    Protos.Environment.Variable zoneVar = Protos.Environment.Variable.newBuilder()
            .setName(EnvConstants.ZONE_TASKENV)
            .setValue(offer.getDomain().getFaultDomain().getZone().getName())
            .build();

    builder.getCommandBuilder()
            .getEnvironmentBuilder()
            .addVariables(regionVar)
            .addVariables(zoneVar);
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:21,代码来源:LaunchEvaluationStage.java

示例7: getTaskInfo

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private Protos.TaskInfo getTaskInfo(final Protos.Offer offer, final TaskAssignmentResult taskAssignmentResult) {
    TaskContext taskContext = TaskContext.from(taskAssignmentResult.getTaskId());
    Optional<CloudJobConfiguration> jobConfigOptional = facadeService.load(taskContext.getMetaInfo().getJobName());
    if (!jobConfigOptional.isPresent()) {
        return null;
    }
    CloudJobConfiguration jobConfig = jobConfigOptional.get();
    Optional<CloudAppConfiguration> appConfigOptional = facadeService.loadAppConfig(jobConfig.getAppName());
    if (!appConfigOptional.isPresent()) {
        return null;
    }
    CloudAppConfiguration appConfig = appConfigOptional.get();
    taskContext.setSlaveId(offer.getSlaveId().getValue());
    ShardingContexts shardingContexts = getShardingContexts(taskContext, appConfig, jobConfig);
    boolean isCommandExecutor = CloudJobExecutionType.TRANSIENT == jobConfig.getJobExecutionType() && JobType.SCRIPT == jobConfig.getTypeConfig().getJobType();
    String script = appConfig.getBootstrapScript();
    if (isCommandExecutor) {
        script = ((ScriptJobConfiguration) jobConfig.getTypeConfig()).getScriptCommandLine();
    }
    Protos.CommandInfo.URI uri = buildURI(appConfig, isCommandExecutor);
    Protos.CommandInfo command = buildCommand(uri, script, shardingContexts, isCommandExecutor);
    if (isCommandExecutor) {
        return buildCommandExecutorTaskInfo(taskContext, jobConfig, shardingContexts, offer, command);
    } else {
        return buildCustomizedExecutorTaskInfo(taskContext, appConfig, jobConfig, shardingContexts, offer, command);
    }
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:28,代码来源:TaskLaunchScheduledService.java

示例8: buildCommandExecutorTaskInfo

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private Protos.TaskInfo buildCommandExecutorTaskInfo(final TaskContext taskContext, 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()));
    return result.setCommand(command).build();
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:10,代码来源:TaskLaunchScheduledService.java

示例9: resourceOffers

import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public void resourceOffers(final SchedulerDriver schedulerDriver, final List<Protos.Offer> offers) {
    for (Protos.Offer offer: offers) {
        log.trace("Adding offer {} from host {}", offer.getId(), offer.getHostname());
        LeasesQueue.getInstance().offer(offer);
    }
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:8,代码来源:SchedulerEngine.java

示例10: createOffer

import org.apache.mesos.Protos; //导入方法依赖的package包/类
public static Protos.Offer createOffer(final String offerId) {
    return Protos.Offer.newBuilder()
            .setId(Protos.OfferID.newBuilder().setValue(offerId))
            .setFrameworkId(Protos.FrameworkID.newBuilder().setValue("elastic-job-cloud-test").build())
            .setSlaveId(Protos.SlaveID.newBuilder().setValue("slave-" + offerId).build())
            .setHostname("localhost")
            .addResources(Protos.Resource.newBuilder().setName("cpus").setType(Protos.Value.Type.SCALAR).setScalar(Protos.Value.Scalar.newBuilder().setValue(100d).build()).build())
            .addResources(Protos.Resource.newBuilder().setName("mem").setType(Protos.Value.Type.SCALAR).setScalar(Protos.Value.Scalar.newBuilder().setValue(128000d).build()).build())
            .build();
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:11,代码来源:OfferBuilder.java

示例11: assertResourceOffers

import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Test
public void assertResourceOffers() {
    SchedulerDriver schedulerDriver = mock(SchedulerDriver.class);
    List<Protos.Offer> offers = Arrays.asList(OfferBuilder.createOffer("offer_0"), OfferBuilder.createOffer("offer_1"));
    schedulerEngine.resourceOffers(schedulerDriver, offers);
    assertThat(LeasesQueue.getInstance().drainTo().size(), is(2));
}
 
开发者ID:elasticjob,项目名称:elastic-job-cloud,代码行数:8,代码来源:SchedulerEngineTest.java

示例12: create

import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public Protos.TaskInfo create(String taskId, Protos.Offer offer, List<Protos.Resource> resources, ExecutionParameters executionParameters) {
    logger.debug("Creating Mesos task for taskId={}", taskId);
    return Protos.TaskInfo.newBuilder()
            .setName(applicationName + ".task")
            .setSlaveId(offer.getSlaveId())
            .setTaskId(Protos.TaskID.newBuilder().setValue(taskId))
            .addAllResources(resources)
            .setData(ByteString.copyFromUtf8(String.join(";", humioHost, humioDataspace, humioIngesttoken,
                humioDataDir, defaultIfEmpty(filebeatConfigUrl, " "), defaultIfEmpty(metricbeatConfigUrl, " "))))
            .setLabels(Protos.Labels.newBuilder().addLabels(createLabel("HUMIO_IGNORE", "true")).build())
            .setDiscovery(Protos.DiscoveryInfo.newBuilder()
                .setName(applicationName)
                .setVisibility(Protos.DiscoveryInfo.Visibility.FRAMEWORK)
                .build())
            .setExecutor(Protos.ExecutorInfo.newBuilder()
                .setName("humioexecutor")
                    .setData(ByteString.copyFromUtf8(dcosAuthToken.concat(";").concat(enableContainerMetrics.toString())))
                .setExecutorId(Protos.ExecutorID.newBuilder().setValue("humioexecutor." + offer.getSlaveId()
                    .getValue()).build())
                .setCommand(Protos.CommandInfo.newBuilder()
                    .setValue("jre*/bin/java -jar executor-*.jar")
                    .addAllUris(mesosConfig.getUri().stream().map(uri -> Protos.CommandInfo.URI
                        .newBuilder().setValue(uri).build()).collect(Collectors.toList()))
                    .build())
                .build())
        .build();
}
 
开发者ID:humio,项目名称:dcos2humio,代码行数:29,代码来源:TaskInfoFactoryExecutor.java

示例13: Plan

import org.apache.mesos.Protos; //导入方法依赖的package包/类
public Plan(List<OfferAcceptor> offerAcceptors,
     List<Job> toKeep,
     List<Protos.Offer> toStock) {
    this.offerAcceptors = Objects.requireNonNull(offerAcceptors);
    this.toKeep = Objects.requireNonNull(toKeep);
    this.toStock = Objects.requireNonNull(toStock);
}
 
开发者ID:retz,项目名称:retz,代码行数:8,代码来源:Plan.java

示例14: testTakeOne

import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Test
public void testTakeOne() {
    OfferQueue offerQueue = new OfferQueue(TEST_CAPACITY);
    offerQueue.offer(getOffer());
    List<Protos.Offer> offers = offerQueue.takeAll();
    Assert.assertEquals(1, offers.size());
    Assert.assertEquals(TEST_CAPACITY, offerQueue.getRemainingCapacity());
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:9,代码来源:OfferQueueTest.java

示例15: installStep

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private Protos.TaskID installStep(int phaseIndex, int stepIndex, Protos.Offer offer) {
    // Get first Step associated with Task A-0
    List<Protos.Offer> offers = Arrays.asList(offer);
    Protos.OfferID offerId = offer.getId();
    Step step = getDeploymentPlan().getChildren().get(phaseIndex).getChildren().get(stepIndex);
    Assert.assertTrue(step.isPending());

    // Offer sufficient Resource and wait for its acceptance
    defaultScheduler.getMesosScheduler().get()
            .resourceOffers(mockSchedulerDriver, offers);
    verify(mockSchedulerDriver, times(1)).acceptOffers(
            Matchers.argThat(isACollectionThat(contains(offerId))),
            operationsCaptor.capture(),
            any());

    // Verify 2 Reserve and 1 Launch Operations were executed
    Collection<Protos.Offer.Operation> operations = operationsCaptor.getValue();
    Assert.assertEquals(8, operations.size());
    Assert.assertEquals(6, countOperationType(Protos.Offer.Operation.Type.RESERVE, operations));
    Assert.assertEquals(1, countOperationType(Protos.Offer.Operation.Type.CREATE, operations));
    Assert.assertEquals(1, countOperationType(Offer.Operation.Type.LAUNCH_GROUP, operations));
    Assert.assertTrue(step.isStarting());

    // Sent TASK_RUNNING status
    Protos.TaskID taskId = getTaskId(operations);
    statusUpdate(getTaskId(operations), Protos.TaskState.TASK_RUNNING);

    // Wait for the Step to become Complete
    Assert.assertTrue(step.isComplete());

    return taskId;
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:33,代码来源:DefaultSchedulerTest.java


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