• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Protos类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getFrameworkId

import org.apache.mesos.v1.Protos; //导入依赖的package包/类
public static FrameworkID getFrameworkId() {
    JuiceFramework frameworkInfo = null;
    try {
        frameworkInfo = daoUtils.queryFramework(MESOS_FRAMEWORK_TAG);
    } catch (DataBaseException ex) {
        log.error("get frameworkId from db failed {cause : db operation error}!");
        throw ex;
    }

    if (null == frameworkInfo || StringUtils.isBlank(frameworkInfo.getFrameworkId())) {
        return genFrameworkId();
    } else {
        log.info("get framework id from db, id : " + frameworkInfo.getFrameworkId());
        return Protos.FrameworkID.newBuilder().setValue(frameworkInfo.getFrameworkId()).build();
    }
}
 
开发者ID:HujiangTechnology,项目名称:Juice,代码行数:17,代码来源:SchedulerService.java


示例2: addTask

import org.apache.mesos.v1.Protos; //导入依赖的package包/类
private static void addTask(@NotNull Map<Long, String> killMap, @NotNull Protos.AgentID agentId, @NotNull Task task, @NotNull List<Protos.TaskInfo> tasks, boolean isRetryTask, Address address) {
    boolean isToKilled = false;
    try {
        isToKilled = killMap.containsKey(task.getTaskId());
        //update db set taskAgentRel
        AuxiliaryService.updateTask(killMap, task.getTaskId(), agentId.getValue(), isToKilled, address);
        if(!isToKilled){
            tasks.add(task.getTask(agentId));
            log.info("resourceAllocation --> add task : " + task.getTaskId());
        }
    } catch (Exception e) {
        if(!isToKilled) {
            taskReserve(task, isRetryTask);
        }
    }
}
 
开发者ID:HujiangTechnology,项目名称:Juice,代码行数:17,代码来源:SchedulerService.java


示例3: getTask

import org.apache.mesos.v1.Protos; //导入依赖的package包/类
public @NotNull
Protos.TaskInfo getTask(
        final @NotNull Protos.AgentID agentID
) {
    Protos.TaskInfo.Builder taskInfoBuilder = Protos.TaskInfo.newBuilder();
    taskInfoBuilder.setName(taskName);
    taskInfoBuilder.setTaskId(Protos.TaskID.newBuilder().setValue(generateTaskNameId(taskName, taskId, retry)));
    taskInfoBuilder.setAgentId(agentID);
    taskInfoBuilder.addAllResources(resources.protos());

    if(null != command && StringUtils.isNotBlank(command.getValue())) {
        //  run shell
        return taskInfoBuilder.setCommand(command.protos(true)).build();
    } else {
        //  run docker
        return taskInfoBuilder.setContainer(container.protos()).setCommand(command.protos(false)).build();
    }
}
 
开发者ID:HujiangTechnology,项目名称:Juice,代码行数:19,代码来源:Task.java


示例4: protos

import org.apache.mesos.v1.Protos; //导入依赖的package包/类
public @NotNull Protos.ContainerInfo protos() {

        Protos.ContainerInfo.Builder builder
                = Protos.ContainerInfo.newBuilder()
                .setDocker(docker.protos())
                .setType(getType());

        if(null != volumes && !volumes.isEmpty()) {
            volumes.forEach(
                    volume -> {
                        builder.addVolumes(Protos.Volume.newBuilder()
                                .setContainerPath(volume.getContainerPath())
                                .setHostPath(volume.getHostPath())
                                .setMode(volume.getMode())
                                .build());
                    }
            );
        }

        return builder.build();
    }
 
开发者ID:HujiangTechnology,项目名称:Juice,代码行数:22,代码来源:Container.java


示例5: protos

import org.apache.mesos.v1.Protos; //导入依赖的package包/类
public @NotNull Protos.CommandInfo protos(boolean isShell) {

        Protos.CommandInfo.Builder builder = Protos.CommandInfo.newBuilder();
        if(isShell) {
            builder.setValue(value);
        } else {
            builder.setShell(false);
            if (null != args && !args.isEmpty()) {
                builder.addAllArguments(args);
            }
        }

        if(null != uris && !uris.isEmpty()) {
            builder.addAllUris(uris.stream().map(uri -> Protos.CommandInfo.URI.newBuilder().setValue(uri).build()).collect(Collectors.toList()));
        }

        if(null != envs && !envs.isEmpty()) {
            Protos.Environment.Builder envBuilder = Protos.Environment.newBuilder();
            envBuilder.addAllVariables(envs.stream().map(env -> Protos.Environment.Variable.newBuilder().setName(env.getName()).setValue(env.getValue()).build()).collect(Collectors.toList()));
            builder.setEnvironment(envBuilder).build();
        }

        return builder.build();
    }
 
开发者ID:HujiangTechnology,项目名称:Juice,代码行数:25,代码来源:Command.java


示例6: ackUpdate

import org.apache.mesos.v1.Protos; //导入依赖的package包/类
/**
 * Utility method to more succinctly construct a {@link Call Call} of type {@link Type#ACKNOWLEDGE ACKNOWLEDGE}.
 * <p>
 *
 * @param frameworkId    The {@link Protos.FrameworkID} to be set on the {@link Call}
 * @param uuid           The {@link Protos.TaskStatus#getUuid() uuid} from the
 *                       {@link org.apache.mesos.v1.scheduler.Protos.Event.Update#getStatus() TaskStatus} received from Mesos.
 * @param agentId        The {@link Protos.TaskStatus#getAgentId() agentId} from the
 *                       {@link org.apache.mesos.v1.scheduler.Protos.Event.Update#getStatus() TaskStatus} received from Mesos.
 * @param taskId         The {@link Protos.TaskStatus#getTaskId() taskId} from the
 *                       {@link org.apache.mesos.v1.scheduler.Protos.Event.Update#getStatus() TaskStatus} received from Mesos.
 * @return  A {@link Call} with a configured {@link Acknowledge}.
 */
@NotNull
public static Call ackUpdate(
    @NotNull final Protos.FrameworkID frameworkId,
    @NotNull final ByteString uuid,
    @NotNull final Protos.AgentID agentId,
    @NotNull final Protos.TaskID taskId
) {
    return newBuilder()
        .setFrameworkId(frameworkId)
        .setType(Type.ACKNOWLEDGE)
        .setAcknowledge(
            Acknowledge.newBuilder()
                .setUuid(uuid)
                .setAgentId(agentId)
                .setTaskId(taskId)
                .build()
        )
        .build();
}
 
开发者ID:mesosphere,项目名称:mesos-rxjava,代码行数:33,代码来源:SchedulerCalls.java


示例7: subscribe

import org.apache.mesos.v1.Protos; //导入依赖的package包/类
/**
 * Utility method to more succinctly construct a {@link Call Call} of type {@link Type#SUBSCRIBE SUBSCRIBE}.
 * <p>
 *
 * @param frameworkId               The frameworkId to set on the {@link Protos.FrameworkInfo FrameworkInfo} and
 *                                  {@link Call Call} messages.
 * @param user                      The user to set on the {@link Protos.FrameworkInfo FrameworkInfo} message.
 * @param frameworkName             The name to set on the {@link Protos.FrameworkInfo FrameworkInfo} message.
 * @param failoverTimeoutSeconds    The failoverTimeoutSeconds to set on the
 *                                  {@link Protos.FrameworkInfo FrameworkInfo} message.
 * @return An {@link Call Call} of type {@link Type#SUBSCRIBE SUBSCRIBE} with the configured
 * {@link Subscribe Subscribe} sub-message.
 */
@NotNull
public static Call subscribe(
    @NotNull final Protos.FrameworkID frameworkId,
    @NotNull final String user,
    @NotNull final String frameworkName,
    final long failoverTimeoutSeconds
) {
    final Protos.FrameworkInfo frameworkInfo = Protos.FrameworkInfo.newBuilder()
        .setId(frameworkId)
        .setUser(user)
        .setName(frameworkName)
        .setFailoverTimeout(failoverTimeoutSeconds)
        .build();
    return subscribe(frameworkId, frameworkInfo);
}
 
开发者ID:mesosphere,项目名称:mesos-rxjava,代码行数:29,代码来源:SchedulerCalls.java


示例8: getStatusMessage

import org.apache.mesos.v1.Protos; //导入依赖的package包/类
private Optional<String> getStatusMessage(Protos.TaskStatus status, Optional<SingularityTask> task) {
  if (status.hasMessage() && !Strings.isNullOrEmpty(status.getMessage())) {
    return Optional.of(status.getMessage());
  } else if (status.hasReason() && status.getReason() == Reason.REASON_CONTAINER_LIMITATION_MEMORY) {
    if (task.isPresent() && task.get().getTaskRequest().getDeploy().getResources().isPresent()) {
      if (task.get().getTaskRequest().getDeploy().getResources().get().getDiskMb() > 0) {
        return Optional.of(String.format("Task exceeded one or more memory limits (%s MB mem, %s MB disk).", task.get().getTaskRequest().getDeploy().getResources().get().getMemoryMb(),
            task.get().getTaskRequest().getDeploy().getResources().get().getDiskMb()));
      } else {
        return Optional.of(String.format("Task exceeded memory limit (%s MB mem).", task.get().getTaskRequest().getDeploy().getResources().get().getMemoryMb()));
      }

    }
    return Optional.of("Task exceeded memory limit.");
  } else if (status.hasReason() && status.getReason() == Reason.REASON_CONTAINER_LIMITATION_DISK) {
    if (task.isPresent() && task.get().getTaskRequest().getDeploy().getResources().isPresent()) {
      return Optional.of(String.format("Task exceeded disk limit (%s MB disk).", task.get().getTaskRequest().getDeploy().getResources().get().getDiskMb()));
    } else {
      return Optional.of("Task exceeded disk limit.");
    }
  }

  return Optional.absent();
}
 
开发者ID:HubSpot,项目名称:Singularity,代码行数:25,代码来源:SingularityMesosStatusUpdateHandler.java


示例9: handleCompletedTask

import org.apache.mesos.v1.Protos; //导入依赖的package包/类
@Timed
public void handleCompletedTask(Optional<SingularityTask> task, SingularityTaskId taskId, boolean wasActive, long timestamp, ExtendedTaskState state,
  SingularityCreateResult taskHistoryUpdateCreateResult, Protos.TaskStatus status) {
  final SingularityDeployStatistics deployStatistics = getDeployStatistics(taskId.getRequestId(), taskId.getDeployId());

  if (wasActive) {
    taskManager.deleteActiveTask(taskId.getId());
  }

  if (!task.isPresent() || task.get().getTaskRequest().getRequest().isLoadBalanced()) {
    taskManager.createLBCleanupTask(taskId);
  }

  final Optional<PendingType> scheduleResult = handleCompletedTaskWithStatistics(task, taskId, timestamp, state, deployStatistics, taskHistoryUpdateCreateResult, status);

  if (taskHistoryUpdateCreateResult == SingularityCreateResult.EXISTED) {
    return;
  }

  updateDeployStatistics(deployStatistics, taskId, task, timestamp, state, scheduleResult);
}
 
开发者ID:HubSpot,项目名称:Singularity,代码行数:22,代码来源:SingularityScheduler.java


示例10: testGetPortByIndex

import org.apache.mesos.v1.Protos; //导入依赖的package包/类
@Test
public void testGetPortByIndex() throws Exception{
  taskResources = new Resources(1, 1, 4, 0);

  final Protos.Resource portsResource = Protos.Resource.newBuilder()
      .setName("ports")
      .setType(Protos.Value.Type.RANGES)
      .setRanges(Protos.Value.Ranges.newBuilder()
          .addRange(Protos.Value.Range.newBuilder()
              .setBegin(31003)
              .setEnd(31004).build())
          .addRange(Protos.Value.Range.newBuilder()
              .setBegin(31000)
              .setEnd(31001).build())
          .build()).build();

  final SingularityRequest request = new SingularityRequestBuilder("test", RequestType.WORKER).build();
  final SingularityDeploy deploy = new SingularityDeployBuilder("test", "1")
      .setCommand(Optional.of("/bin/echo"))
      .setArguments(Optional.of(Collections.singletonList("wat")))
      .build();
  final SingularityTaskRequest taskRequest = new SingularityTaskRequest(request, deploy, pendingTask);
  final SingularityMesosTaskHolder task = builder.buildTask(offerHolder, Collections.singletonList(portsResource), taskRequest, taskResources, executorResources);
  assertEquals(31003L, task.getTask().getPortByIndex(2).get().longValue());
}
 
开发者ID:HubSpot,项目名称:Singularity,代码行数:26,代码来源:SingularityMesosTaskBuilderTest.java


示例11: testDockerMinimalNetworking

import org.apache.mesos.v1.Protos; //导入依赖的package包/类
@Test
public void testDockerMinimalNetworking() {
  taskResources = new Resources(1, 1, 0, 0);

  final SingularityRequest request = new SingularityRequestBuilder("test", RequestType.WORKER).build();
  final SingularityContainerInfo containerInfo = new SingularityContainerInfo(
      SingularityContainerType.DOCKER,
      Optional.absent(),
      Optional.of(new SingularityDockerInfo("docker-image", true, SingularityDockerNetworkType.NONE,
          Optional.absent(),
          Optional.absent(),
          Optional.absent(),
          Optional.absent())));
  final SingularityDeploy deploy = new SingularityDeployBuilder("test", "1")
      .setContainerInfo(Optional.of(containerInfo))
      .build();
  final SingularityTaskRequest taskRequest = new SingularityTaskRequest(request, deploy, pendingTask);
  final SingularityMesosTaskHolder task = builder.buildTask(offerHolder, Collections.emptyList(), taskRequest, taskResources, executorResources);

  assertEquals(Type.DOCKER, task.getMesosTask().getContainer().getType());
  assertEquals(Protos.ContainerInfo.DockerInfo.Network.NONE, task.getMesosTask().getContainer().getDocker().getNetwork());
}
 
开发者ID:HubSpot,项目名称:Singularity,代码行数:23,代码来源:SingularityMesosTaskBuilderTest.java


示例12: generatorFacts

import org.apache.mesos.v1.Protos; //导入依赖的package包/类
private static Map<String, Set<String>> generatorFacts(@NotNull Protos.Offer offer, Set<String> attributes) {
    Map<String, Set<String>> facts = Maps.newHashMap();
    //  add host
    if (StringUtils.isNotBlank(offer.getHostname())) {
        facts.put(Constraints.FIELD.HOSTNAME.getField(), Sets.newHashSet());
        facts.get(Constraints.FIELD.HOSTNAME.getField()).add(offer.getHostname());
    }
    //  add attr
    if (null != attributes && !attributes.isEmpty()) {
        facts.put(Constraints.FIELD.RACK_ID.getField(), Sets.newHashSet());
        facts.get(Constraints.FIELD.RACK_ID.getField()).addAll(attributes);
    }

    return facts;
}
 
开发者ID:HujiangTechnology,项目名称:Juice,代码行数:16,代码来源:SchedulerService.java


示例13: allocatingUntilExhausted

import org.apache.mesos.v1.Protos; //导入依赖的package包/类
private static boolean allocatingUntilExhausted(Map<Long, String> killMap, Protos.AgentID agentId, Map<String, Set<String>> facts, ResourcesUtils hardware, List<Protos.TaskInfo> tasks, Address address) {

        long cacheTries = CACHE_TRIES;
        //  when either cpu or memory reach the picket line, will stop allocation task
        while (hardware.isAvailable()) {
            if (cacheTries > 0) {
                cacheTries = taskOrResourceExhausted(killMap, agentId, facts, hardware, tasks, true, address) ? 0 : cacheTries - 1;
            } else {
                if (taskOrResourceExhausted(killMap, agentId, facts, hardware, tasks, false, address)) {
                    return true;
                }
            }
        }
        return false;
    }
 
开发者ID:HujiangTechnology,项目名称:Juice,代码行数:16,代码来源:SchedulerService.java


示例14: taskOrResourceExhausted

import org.apache.mesos.v1.Protos; //导入依赖的package包/类
private static boolean taskOrResourceExhausted(@NotNull Map<Long, String> killMap, Protos.AgentID agentId, Map<String, Set<String>> facts, ResourcesUtils hardware, List<Protos.TaskInfo> tasks, boolean isRetryTask,  Address address) {

        //  is task in cache exhausted ?
        String tskStr = isRetryTask ? cacheUtils.popFromQueue(TASK_RETRY_QUEUE) : cacheUtils.popFromQueue(TASK_QUEUE);
        if (StringUtils.isBlank(tskStr)) {
            return true;
        }

        //  is resource exhausted ?
        com.hujiang.juice.common.model.Task task = gson.fromJson(tskStr, Task.class);

        //  current offer not match task, try next
        if (!availableConstraints(task.getConstraints(), facts)) {
            task.getExpire().incrementOfferLack();
            taskReserve(task, isRetryTask);
        } else {
            if (hardware.allocating(task.getResources())) {
                //  accept task
                addTask(killMap, agentId, task, tasks, isRetryTask, address);
            } else {
                //  resources is exhausted
                task.getExpire().incrementResourceLack();
                taskReserve(task, isRetryTask);
                return true;
            }
        }
        return false;

    }
 
开发者ID:HujiangTechnology,项目名称:Juice,代码行数:30,代码来源:SchedulerService.java


示例15: addResource

import org.apache.mesos.v1.Protos; //导入依赖的package包/类
private
@NotNull
Protos.Resource addResource(@NotNull String name, @NotNull double value) {
    return Protos.Resource.newBuilder()
            .setName(name)
            .setRole(role)
            .setType(Protos.Value.Type.SCALAR)
            .setScalar(Protos.Value.Scalar.newBuilder().setValue(value).build())
            .build();
}
 
开发者ID:HujiangTechnology,项目名称:Juice,代码行数:11,代码来源:Resources.java


示例16: protos

import org.apache.mesos.v1.Protos; //导入依赖的package包/类
public
@NotNull
List<Protos.Resource> protos() {
    List<Protos.Resource> resources = new ArrayList<>();
    resources.add(addResource(CPUS, cpu));
    resources.add(addResource(MEMS, mem));
    return resources;
}
 
开发者ID:HujiangTechnology,项目名称:Juice,代码行数:9,代码来源:Resources.java


示例17: protos

import org.apache.mesos.v1.Protos; //导入依赖的package包/类
public @NotNull
Protos.ContainerInfo.DockerInfo protos() {

    Protos.ContainerInfo.DockerInfo.Builder dockerBuild = Protos.ContainerInfo.DockerInfo.newBuilder()
            .setImage(image)
            .setForcePullImage(forcePullImage)
            .setPrivileged(privileged)
            .setNetwork(exchange());


    if (null != parameters) {
        parameters.forEach(
                par -> {
                    dockerBuild.addParameters(Protos.Parameter.newBuilder().setKey(par.getKey()).setValue(par.getValue()));
                }
        );
    }
    if (null != portMappings) {
        portMappings.forEach(
                por -> {
                    dockerBuild.addPortMappings(Protos.ContainerInfo.DockerInfo.PortMapping.newBuilder()
                            .setContainerPort(por.getContainerPort())
                            .setHostPort(por.getHostPort())
                            .setProtocol(por.getProtocol()));
                }
        );
    }
    return dockerBuild.build();
}
 
开发者ID:HujiangTechnology,项目名称:Juice,代码行数:30,代码来源:Docker.java


示例18: exchange

import org.apache.mesos.v1.Protos; //导入依赖的package包/类
private Protos.ContainerInfo.DockerInfo.Network exchange() {
    if(null == net) {
        return Protos.ContainerInfo.DockerInfo.Network.BRIDGE;
    }
    switch (net) {
        case HOST: return Protos.ContainerInfo.DockerInfo.Network.HOST;
        case NONE: return Protos.ContainerInfo.DockerInfo.Network.NONE;
        case USER: return Protos.ContainerInfo.DockerInfo.Network.USER;
        default: return Protos.ContainerInfo.DockerInfo.Network.BRIDGE;
    }
}
 
开发者ID:HujiangTechnology,项目名称:Juice,代码行数:12,代码来源:Docker.java


示例19: testFrameworkInfoEvolve

import org.apache.mesos.v1.Protos; //导入依赖的package包/类
@Test
public void testFrameworkInfoEvolve() {
    org.apache.mesos.Protos.FrameworkInfo.Builder frameworkBuilder = org.apache.mesos.Protos.FrameworkInfo.newBuilder()
        .setUser(user)
        .setName(name);

    Protos.FrameworkInfo frameworkInfo = EvolverDevolver.evolve(frameworkBuilder.buildPartial());

    assertEquals(user, frameworkInfo.getUser());
    assertEquals(name, frameworkInfo.getName());
}
 
开发者ID:mesosphere,项目名称:mesos-http-adapter,代码行数:12,代码来源:EvolverDevolverTest.java


示例20: testFrameworkInfoDevolve

import org.apache.mesos.v1.Protos; //导入依赖的package包/类
@Test
public void testFrameworkInfoDevolve() {
    Protos.FrameworkInfo.Builder frameworkBuilder = Protos.FrameworkInfo.newBuilder()
            .setUser(user)
            .setName(name);

    org.apache.mesos.Protos.FrameworkInfo frameworkInfo = EvolverDevolver.devolve(frameworkBuilder.buildPartial());

    assertEquals(user, frameworkInfo.getUser());
    assertEquals(name, frameworkInfo.getName());
}
 
开发者ID:mesosphere,项目名称:mesos-http-adapter,代码行数:12,代码来源:EvolverDevolverTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ChecksumValidator类代码示例发布时间:2022-05-23
下一篇:
Java IntsRefBuilder类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap