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


Java Protos.HealthCheck方法代码示例

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


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

示例1: testReadinessCheckTagging

import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Test
public void testReadinessCheckTagging() throws TaskException {
    Protos.HealthCheck inReadinessCheck = Protos.HealthCheck.newBuilder()
            .setDelaySeconds(1.0)
            .build();
    Protos.TaskInfo.Builder builder = getTestTaskInfo().toBuilder();
    builder.setLabels(new TaskLabelWriter(builder)
            .setReadinessCheck(inReadinessCheck)
            .toProto());
    Protos.HealthCheck outReadinessCheck = new TaskLabelWriter(builder.build()) {
        @Override
        public Optional<HealthCheck> getReadinessCheck() throws TaskException {
            return super.getReadinessCheck();
        }
    }.getReadinessCheck().get();

    Assert.assertEquals(inReadinessCheck.getDelaySeconds(), outReadinessCheck.getDelaySeconds(), 0.0);
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:19,代码来源:TaskLabelReaderWriterTest.java

示例2: create

import org.apache.mesos.Protos; //导入方法依赖的package包/类
public static CheckHandler create(
        ExecutorDriver executorDriver,
        Protos.TaskInfo taskInfo,
        LaunchedTask launchedTask,
        Protos.HealthCheck healthCheck,
        ScheduledExecutorService scheduledExecutorService,
        CheckStats healthCheckStats,
        String checkType)
        throws CheckValidationException {
    return new CheckHandler(
            executorDriver,
            taskInfo,
            launchedTask,
            new ProcessRunner(),
            healthCheck,
            scheduledExecutorService,
            healthCheckStats,
            checkType);
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:20,代码来源:CheckHandler.java

示例3: CheckHandler

import org.apache.mesos.Protos; //导入方法依赖的package包/类
/**
 * Allows providing a custom {@link ProcessRunner} for testing.
 */
@VisibleForTesting
CheckHandler(
        ExecutorDriver executorDriver,
        Protos.TaskInfo taskInfo,
        LaunchedTask launchedTask,
        ProcessRunner processRunner,
        Protos.HealthCheck healthCheck,
        ScheduledExecutorService scheduledExecutorService,
        CheckStats healthCheckStats,
        String checkType)
        throws CheckValidationException {
    validate(healthCheck);
    this.healthCheck = healthCheck;
    this.scheduledExecutorService = scheduledExecutorService;
    this.healthCheckRunner = new CheckRunner(
            executorDriver,
            taskInfo,
            launchedTask,
            processRunner,
            healthCheck,
            healthCheckStats,
            checkType);
    this.checkType = checkType;
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:28,代码来源:CheckHandler.java

示例4: validate

import org.apache.mesos.Protos; //导入方法依赖的package包/类
/**
 * Custom Executors are responsible for implementing HealthChecks.  This Custom Executor implements a subset of
 * all possible Health Checks describable by a HealthCheckInfo object.
 * <p>
 * They must be command HealthChecks as HTTP is not recommended by Mesos yet and is unneeded from a completeness
 * perspective.  `curl -f` normally is sufficient.  Since all HealthChecks as currently implemented by this Custom
 * Executor are excuted as sub-processes we further require that the HealthCheck specifies that it is a "shell"
 * command to avoid unexpected behavior.
 *
 * @param healthCheck The HealthCheck to be executed
 * @throws CheckValidationException when a HealthCheck does not adhere to the HealthChecks supported
 *                                        by this Custom Executor
 */
private void validate(Protos.HealthCheck healthCheck) throws CheckValidationException {
    // Validate HealthCheck
    if (healthCheck.hasHttp()) {
        throw new CheckValidationException(String.format(
                "The following %s check contains an unsupported HTTP configuration: %s", checkType, healthCheck));
    }

    if (!healthCheck.hasCommand()) {
        throw new CheckValidationException(String.format(
                "The following %s check does not contain a Command: %s", checkType, healthCheck));
    }

    // Validate Command
    Protos.CommandInfo commandInfo = healthCheck.getCommand();
    if (!Boolean.valueOf(commandInfo.getShell())) {
        throw new CheckValidationException(String.format(
                "Only shell based %s checks are supported for commmand: %s", checkType, commandInfo));
    }
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:33,代码来源:CheckHandler.java

示例5: CheckRunner

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private CheckRunner(
        ExecutorDriver executorDriver,
        Protos.TaskInfo taskInfo,
        LaunchedTask launchedTask,
        ProcessRunner processRunner,
        Protos.HealthCheck healthCheck,
        CheckStats healthCheckStats,
        String checkType) {
    this.executorDriver = executorDriver;
    this.taskInfo = taskInfo;
    this.launchedTask = launchedTask;
    this.processRunner = processRunner;
    this.healthCheck = healthCheck;
    this.healthCheckStats = healthCheckStats;
    this.checkType = checkType;
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:17,代码来源:CheckHandler.java

示例6: scheduleReadinessCheck

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private void scheduleReadinessCheck(
        ExecutorDriver executorDriver,
        Protos.TaskInfo taskInfo,
        LaunchedTask launchedTask) {

    Optional<Protos.HealthCheck> readinessCheckOptional = Optional.empty();
    try {
        readinessCheckOptional = new ExecutorTaskLabelReader(taskInfo).getReadinessCheck();
    } catch (TaskException e) {
        LOGGER.error(String.format(
                "Failed to extract readiness check from task: %s", taskInfo.getTaskId().getValue()), e);
        return;
    }

    if (!readinessCheckOptional.isPresent()) {
        return;
    }

    scheduleCheck(executorDriver, taskInfo, readinessCheckOptional.get(), launchedTask, "Readiness");
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:21,代码来源:CustomExecutor.java

示例7: create

import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public Protos.HealthCheck create(List<Protos.Resource> resources) {
    // Dev note: HealthCheck does not work in 0.25: https://issues.apache.org/jira/browse/MESOS-3738
    Protos.HealthCheck healthDefault = Protos.HealthCheck.getDefaultInstance();
    if (mesosConfig.getHealthCheck() == null) {
        return healthDefault;
    } else {
        return Protos.HealthCheck.newBuilder()
                .setCommand(
                        Protos.CommandInfo.newBuilder()
                                .setValue(mesosConfig.getHealthCheck().getOrDefault("command", "echo Success"))
                )
                .setTimeoutSeconds(Double.valueOf(mesosConfig.getHealthCheck().getOrDefault("timeout", Double.toString(healthDefault.getTimeoutSeconds()))))
                .setDelaySeconds(Double.valueOf(mesosConfig.getHealthCheck().getOrDefault("delay", Double.toString(healthDefault.getDelaySeconds()))))
                .setConsecutiveFailures(Integer.valueOf(mesosConfig.getHealthCheck().getOrDefault("consecutiveFailures", Integer.toString(healthDefault.getConsecutiveFailures()))))
                .setGracePeriodSeconds(Double.valueOf(mesosConfig.getHealthCheck().getOrDefault("gracePeriod", Double.toString(healthDefault.getGracePeriodSeconds()))))
                .setIntervalSeconds(Double.valueOf(mesosConfig.getHealthCheck().getOrDefault("interval", Double.toString(healthDefault.getIntervalSeconds()))))
                .build();
    }
}
 
开发者ID:ContainerSolutions,项目名称:mesosframework,代码行数:21,代码来源:HealthCheckFactory.java

示例8: CheckMonitor

import org.apache.mesos.Protos; //导入方法依赖的package包/类
public CheckMonitor(
        Protos.HealthCheck healthCheck,
        CheckHandler healthCheckHandler,
        LaunchedTask launchedTask,
        String checkType) {
    this.healthCheck = healthCheck;
    this.healthCheckHandler = healthCheckHandler;
    this.launchedTask = launchedTask;
    this.checkType = checkType;
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:11,代码来源:CheckMonitor.java

示例9: getHealthCheck

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private static Protos.HealthCheck getHealthCheck(int maxConsecutiveFailures) {
    return Protos.HealthCheck.newBuilder()
            .setIntervalSeconds(SHORT_INTERVAL_S)
            .setDelaySeconds(SHORT_DELAY_S)
            .setGracePeriodSeconds(SHORT_GRACE_PERIOD_S)
            .setTimeoutSeconds(TIMEOUT_S)
            .setConsecutiveFailures(maxConsecutiveFailures)
            .setCommand(Protos.CommandInfo.newBuilder()
                    .setValue("this_command_should_not_be_run")
                    .build())
            .build();
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:13,代码来源:CheckHandlerTest.java

示例10: scheduleCheck

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private void scheduleCheck(
        ExecutorDriver executorDriver,
        Protos.TaskInfo taskInfo,
        Protos.HealthCheck check,
        LaunchedTask launchedTask,
        String checkType) {

    try {
        CheckMonitor healthCheckMonitor =
                new CheckMonitor(
                        check,
                        CheckHandler.create(
                                executorDriver,
                                taskInfo,
                                launchedTask,
                                check,
                                HEALTH_CHECK_THREAD_POOL,
                                new CheckStats(taskInfo.getName()),
                                checkType),
                        launchedTask,
                        checkType);
        LOGGER.info("Submitting {} check monitor.", checkType);
        Future<Optional<CheckStats>> futureOptionalHealthCheckStats =
                executorService.submit(healthCheckMonitor);

        executorService.submit(new Runnable() {
            @Override
            public void run() {
                try {
                    Optional<CheckStats> optionalHealthCheckStats = futureOptionalHealthCheckStats.get();
                    if (optionalHealthCheckStats.isPresent()) {
                        LOGGER.info("{} check exited with statistics: {}",
                                checkType, optionalHealthCheckStats.get());
                    }
                } catch (InterruptedException | ExecutionException e) {
                    LOGGER.error(String.format("Failed to get %s check stats with exception: ", checkType), e);
                }
            }
        });
    } catch (CheckHandler.CheckValidationException ex) {
        LOGGER.error(String.format("Task did not generate a %s check with exception: ", checkType), ex);
    }

}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:45,代码来源:CustomExecutor.java

示例11: getReadinessCheck

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private static Protos.HealthCheck getReadinessCheck() {
    return getHealthCheck(0);
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:4,代码来源:CheckHandlerTest.java


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