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


Java Protos.Volume方法代码示例

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


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

示例1: createVolumesBuilder

import org.apache.mesos.Protos; //导入方法依赖的package包/类
public static List<Protos.Volume> createVolumesBuilder(final Map<String, Object> configuration)
{
    List<Protos.Volume> volumes = new ArrayList<>();

    String mesosFetcher = configuration.get("docker_volumes").toString();
    if (!mesosFetcher.isEmpty()) {
        String[] split = mesosFetcher.split("\\r?\\n");
        for (String lineVolume : split) {
            String[] volumeArray = lineVolume.split(":");
            if (volumeArray.length == 2) {
                Protos.Volume volume = Protos.Volume.newBuilder()
                        .setHostPath(volumeArray[0])
                        .setContainerPath(volumeArray[1])
                        .setMode(Protos.Volume.Mode.RW)
                        .build();

                volumes.add(volume);
            }
        }
    }

    return volumes;
}
 
开发者ID:farmapromlab,项目名称:rundeck-mesos-plugin,代码行数:24,代码来源:VolumesHelper.java

示例2: DockerScheduler

import org.apache.mesos.Protos; //导入方法依赖的package包/类
DockerScheduler(
        LoggerWrapper loggerWrapper,
        int desiredInstances,
        Protos.CommandInfo.Builder commandInfoBuilder,
        List<Protos.Volume> volumes,
        List<Protos.Parameter> parameters,
        final Map<String, Object> configuration,
        PluginStepContext context

) {
    this.loggerWrapper = loggerWrapper;
    this.desiredInstances = desiredInstances;
    this.commandInfoBuilder = commandInfoBuilder;
    this.volumes = volumes;
    this.parameters = parameters;
    this.context = context;

    this.imageName = configuration.get("docker_image").toString();
    this.cpu = Double.parseDouble(configuration.get("docker_cpus").toString());
    this.memory = Double.parseDouble(configuration.get("docker_memory").toString());
    this.forcePullImage = Boolean.parseBoolean(configuration.get("docker_force_pull").toString());
    this.constraints = new ConstraintsChecker(configuration.get("mesos_constraints").toString());
}
 
开发者ID:farmapromlab,项目名称:rundeck-mesos-plugin,代码行数:24,代码来源:DockerScheduler.java

示例3: getExecutorInfoSecretVolumes

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private static Collection<Protos.Volume> getExecutorInfoSecretVolumes(Collection<SecretSpec> secretSpecs) {
    Collection<Protos.Volume> volumes = new ArrayList<>();

    for (SecretSpec secretSpec: secretSpecs) {
        if (secretSpec.getFilePath().isPresent()) {
            volumes.add(Protos.Volume.newBuilder()
                    .setSource(Protos.Volume.Source.newBuilder()
                            .setType(Protos.Volume.Source.Type.SECRET)
                            .setSecret(getReferenceSecret(secretSpec.getSecretPath()))
                            .build())
                    .setContainerPath(secretSpec.getFilePath().get())
                    .setMode(Protos.Volume.Mode.RO)
                    .build());
        }
    }
    return volumes;
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:18,代码来源:PodInfoBuilder.java

示例4: assertTLSArtifacts

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private void assertTLSArtifacts(Protos.ContainerInfo container, TLSArtifactPaths secretPaths, String encryptionSpecName) {
    Protos.Volume volume = findVolumeWithContainerPath(container, TLSArtifact.CERTIFICATE.getMountPath(encryptionSpecName)).get();
    Assert.assertEquals(
            volume.getSource().getSecret().getReference().getName(),
            secretPaths.getSecretStorePath(TLSArtifact.CERTIFICATE, encryptionSpecName));

    volume = findVolumeWithContainerPath(container, TLSArtifact.CA_CERTIFICATE.getMountPath(encryptionSpecName)).get();
    Assert.assertEquals(
            volume.getSource().getSecret().getReference().getName(),
            secretPaths.getSecretStorePath(TLSArtifact.CA_CERTIFICATE, encryptionSpecName));

    volume = findVolumeWithContainerPath(container, TLSArtifact.PRIVATE_KEY.getMountPath(encryptionSpecName)).get();
    Assert.assertEquals(
            volume.getSource().getSecret().getReference().getName(),
            secretPaths.getSecretStorePath(TLSArtifact.PRIVATE_KEY, encryptionSpecName));

    Assert.assertFalse(findVolumeWithContainerPath(container, TLSArtifact.KEYSTORE.getMountPath(encryptionSpecName)).isPresent());
    Assert.assertFalse(findVolumeWithContainerPath(container, TLSArtifact.TRUSTSTORE.getMountPath(encryptionSpecName)).isPresent());
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:20,代码来源:TLSEvaluationStageTest.java

示例5: MesosTaskManagerParameters

import org.apache.mesos.Protos; //导入方法依赖的package包/类
public MesosTaskManagerParameters(
		double cpus,
		ContainerType containerType,
		Option<String> containerImageName,
		ContaineredTaskManagerParameters containeredParameters,
		List<Protos.Volume> containerVolumes,
		List<ConstraintEvaluator> constraints,
		String command,
		Option<String> bootstrapCommand,
		Option<String> taskManagerHostname) {

	this.cpus = cpus;
	this.containerType = Preconditions.checkNotNull(containerType);
	this.containerImageName = Preconditions.checkNotNull(containerImageName);
	this.containeredParameters = Preconditions.checkNotNull(containeredParameters);
	this.containerVolumes = Preconditions.checkNotNull(containerVolumes);
	this.constraints = Preconditions.checkNotNull(constraints);
	this.command = Preconditions.checkNotNull(command);
	this.bootstrapCommand = Preconditions.checkNotNull(bootstrapCommand);
	this.taskManagerHostname = Preconditions.checkNotNull(taskManagerHostname);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:22,代码来源:MesosTaskManagerParameters.java

示例6: testBuildVolumes

import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Test
public void testBuildVolumes() throws Exception {
	List<Protos.Volume> vols;
	assertEquals(MesosTaskManagerParameters.buildVolumes(Option.<String>apply(null)).size(), 0);
	String spec1 = "/host/path:/container/path:RO,/container/path:ro,/host/path:/container/path,/container/path";
	vols = MesosTaskManagerParameters.buildVolumes(Option.<String>apply(spec1));
	assertEquals(vols.size(), 4);
	assertEquals("/container/path", vols.get(0).getContainerPath());
	assertEquals("/host/path", vols.get(0).getHostPath());
	assertEquals(Protos.Volume.Mode.RO, vols.get(0).getMode());
	assertEquals("/container/path", vols.get(1).getContainerPath());
	assertEquals(Protos.Volume.Mode.RO, vols.get(1).getMode());
	assertEquals("/container/path", vols.get(2).getContainerPath());
	assertEquals("/host/path", vols.get(2).getHostPath());
	assertEquals(Protos.Volume.Mode.RW, vols.get(2).getMode());
	assertEquals("/container/path", vols.get(3).getContainerPath());
	assertEquals(Protos.Volume.Mode.RW, vols.get(3).getMode());

	// should handle empty strings, but not error
	assertEquals(0, MesosTaskManagerParameters.buildVolumes(Option.<String>apply("")).size());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:22,代码来源:MesosTaskManagerParametersTest.java

示例7: makeThermosExecutorSettings

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private static ExecutorSettings makeThermosExecutorSettings()  {
  List<Protos.Volume> volumeMounts =
      ImmutableList.<Protos.Volume>builder()
          .add(Protos.Volume.newBuilder()
              .setHostPath(THERMOS_OBSERVER_ROOT.get())
              .setContainerPath(THERMOS_OBSERVER_ROOT.get())
              .setMode(Protos.Volume.Mode.RW)
              .build())
          .addAll(Iterables.transform(
              GLOBAL_CONTAINER_MOUNTS.get(),
              v -> Protos.Volume.newBuilder()
                  .setHostPath(v.getHostPath())
                  .setContainerPath(v.getContainerPath())
                  .setMode(Protos.Volume.Mode.valueOf(v.getMode().getValue()))
                  .build()))
          .build();

  return new ExecutorSettings(
      new ExecutorConfig(
          ExecutorInfo.newBuilder()
              .setName("aurora.task")
              // Necessary as executorId is a required field.
              .setExecutorId(Executors.PLACEHOLDER_EXECUTOR_ID)
              .setCommand(
                  makeExecutorCommand(
                      THERMOS_EXECUTOR_PATH.get(),
                      THERMOS_EXECUTOR_RESOURCES.get(),
                      THERMOS_HOME_IN_SANDBOX.get(),
                      THERMOS_EXECUTOR_FLAGS.get()))
              .addResources(makeResource(CPUS, EXECUTOR_OVERHEAD_CPUS.get()))
              .addResources(makeResource(RAM_MB, EXECUTOR_OVERHEAD_RAM.get().as(Data.MB)))
              .build(),
          volumeMounts),
      POPULATE_DISCOVERY_INFO.get());
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:36,代码来源:ExecutorModule.java

示例8: setExecutorVolume

import org.apache.mesos.Protos; //导入方法依赖的package包/类
public void setExecutorVolume(VolumeSpec volumeSpec) {
    // Volumes on the executor must be declared in each TaskInfo.ContainerInfo to be shared among them.
    if (useDefaultExecutor) {
        Protos.Volume executorVolume = getVolume(volumeSpec);

        for (Protos.TaskInfo.Builder t : getTaskBuilders()) {
            t.getContainerBuilder()
                    .setType(Protos.ContainerInfo.Type.MESOS)
                    .addVolumes(executorVolume);
        }
    }
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:13,代码来源:PodInfoBuilder.java

示例9: getVolume

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private static Protos.Volume getVolume(VolumeSpec volumeSpec) {
    Protos.Volume.Builder builder = Protos.Volume.newBuilder();
    builder.setMode(Protos.Volume.Mode.RW)
            .setContainerPath(volumeSpec.getContainerPath())
            .setSource(Protos.Volume.Source.newBuilder()
                    .setType(Protos.Volume.Source.Type.SANDBOX_PATH)
                    .setSandboxPath(Protos.Volume.Source.SandboxPath.newBuilder()
                            .setType(Protos.Volume.Source.SandboxPath.Type.PARENT)
                            .setPath(volumeSpec.getContainerPath())));

    return builder.build();
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:13,代码来源:PodInfoBuilder.java

示例10: getExecutorInfoSecretVolumes

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private static Collection<Protos.Volume> getExecutorInfoSecretVolumes(
        TransportEncryptionSpec spec, TLSArtifactPaths tlsArtifactPaths) {
    Collection<Protos.Volume> volumes = new ArrayList<>();
    for (TLSArtifactPaths.Entry entry : tlsArtifactPaths.getPathsForType(spec.getType(), spec.getName())) {
        volumes.add(getSecretVolume(entry));
    }
    return volumes;
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:9,代码来源:TLSEvaluationStage.java

示例11: getSecretVolume

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private static Protos.Volume getSecretVolume(TLSArtifactPaths.Entry entry) {
    Protos.Volume.Builder volumeBuilder = Protos.Volume.newBuilder()
            .setContainerPath(entry.mountPath)
            .setMode(Protos.Volume.Mode.RO);
    Protos.Volume.Source.Builder sourceBuilder = volumeBuilder.getSourceBuilder()
            .setType(Protos.Volume.Source.Type.SECRET);
    sourceBuilder.getSecretBuilder()
            .setType(Protos.Secret.Type.REFERENCE)
            .getReferenceBuilder().setName(entry.secretStorePath);
    return volumeBuilder.build();
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:12,代码来源:TLSEvaluationStage.java

示例12: validateDisk

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private void validateDisk(Protos.Resource resource) {
    Assert.assertTrue(resource.hasDisk());

    Protos.Resource.DiskInfo diskInfo = resource.getDisk();
    Assert.assertTrue(diskInfo.hasPersistence());

    Protos.Resource.DiskInfo.Persistence persistence = diskInfo.getPersistence();
    Assert.assertEquals(36, persistence.getId().length());
    Assert.assertEquals(TestConstants.PRINCIPAL, persistence.getPrincipal());

    Assert.assertTrue(diskInfo.hasVolume());
    Protos.Volume volume = diskInfo.getVolume();
    Assert.assertEquals(TestConstants.CONTAINER_PATH, volume.getContainerPath());
    Assert.assertEquals(Protos.Volume.Mode.RW, volume.getMode());
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:16,代码来源:ResourceBuilderTest.java

示例13: assertKeystoreArtifacts

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private void assertKeystoreArtifacts(Protos.ContainerInfo container, TLSArtifactPaths secretPaths, String encryptionSpecName) {
    Protos.Volume volume = findVolumeWithContainerPath(container, TLSArtifact.KEYSTORE.getMountPath(encryptionSpecName)).get();
    Assert.assertEquals(
            volume.getSource().getSecret().getReference().getName(),
            secretPaths.getSecretStorePath(TLSArtifact.KEYSTORE, encryptionSpecName));

    volume = findVolumeWithContainerPath(container, TLSArtifact.TRUSTSTORE.getMountPath(encryptionSpecName)).get();
    Assert.assertEquals(
            volume.getSource().getSecret().getReference().getName(),
            secretPaths.getSecretStorePath(TLSArtifact.TRUSTSTORE, encryptionSpecName));

    Assert.assertFalse(findVolumeWithContainerPath(container, TLSArtifact.CERTIFICATE.getMountPath(encryptionSpecName)).isPresent());
    Assert.assertFalse(findVolumeWithContainerPath(container, TLSArtifact.CA_CERTIFICATE.getMountPath(encryptionSpecName)).isPresent());
    Assert.assertFalse(findVolumeWithContainerPath(container, TLSArtifact.PRIVATE_KEY.getMountPath(encryptionSpecName)).isPresent());
}
 
开发者ID:mesosphere,项目名称:dcos-commons,代码行数:16,代码来源:TLSEvaluationStageTest.java

示例14: getContainerVolumes

import org.apache.mesos.Protos; //导入方法依赖的package包/类
public List<Protos.Volume> getContainerVolumes() {
  return taskInfo.getContainer().getVolumesList();
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:4,代码来源:EnvironmentContext.java

示例15: generateTaskInfos

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private Collection<Protos.TaskInfo> generateTaskInfos(Collection<String> oldTaskNames,
                             ServiceSpec newServiceSpec) throws  KafkaConfigUpgradeException {
    List<Protos.TaskInfo> taskInfoList = new ArrayList<>();

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

        Optional<Protos.TaskInfo> oldTaskInfo = stateStore.fetchTask(oldTaskName);
        if (!oldTaskInfo.isPresent()){
            throw new KafkaConfigUpgradeException("Can not fetch task info " + oldTaskName);
        }

        LOGGER.info("Task {} old TaskInfo: ", oldTaskInfo.get().getName(), oldTaskInfo);

        Protos.TaskInfo.Builder taskInfoBuilder = oldTaskInfo.get().toBuilder();
        taskInfoBuilder.setName(newName);
        taskInfoBuilder = CommonTaskUtils.setIndex(taskInfoBuilder, brokerId);
        taskInfoBuilder = CommonTaskUtils.setType(taskInfoBuilder, "kafka");
        taskInfoBuilder = TaskUtils.setGoalState(taskInfoBuilder,
                newServiceSpec.getPods().get(0).getTasks().get(0));
        taskInfoBuilder = CommonTaskUtils.setTargetConfiguration(taskInfoBuilder, newTargetId);

        List<Protos.Resource> resourcesList = new ArrayList<>();
        for (Protos.Resource resource : oldTaskInfo.get().getResourcesList()) {
            if (!resource.hasDisk()){
                resourcesList.add(resource);
                continue;
            }

            LOGGER.info("old disk resource : {}", resource);

            //volume.toBuilder() was complaining that mode is not set, so setting everything manually
            Protos.Resource.DiskInfo diskInfo = resource.getDisk();
            Protos.Volume volume = diskInfo.getVolume();
            Protos.Volume.Builder volumeBuilder = volume.toBuilder();
            Protos.Volume newVolume = volumeBuilder.setSource(volume.getSource())
                    .setContainerPath(this.newPath) //kafka-broker-data
                    .setMode(volume.getMode())
                    .build();

            Protos.Resource.DiskInfo.Builder newDiskInfoBuilder = diskInfo.toBuilder();
            Protos.Resource.DiskInfo newDiskInfo = newDiskInfoBuilder.setVolume(newVolume)
                    .setPersistence(diskInfo.getPersistence())
                    .build();

            Protos.Resource.Builder resourceBuilder = resource.toBuilder();
            Protos.Resource newResource = resourceBuilder.setDisk(newDiskInfo)
                    .setName(resource.getName())
                    .setReservation(resource.getReservation())
                    .setRole(resource.getRole())
                    .setScalar(resource.getScalar())
                    .build();

            LOGGER.info("new disk resource : {}", newResource);

            resourcesList.add(newResource);
        }
        taskInfoBuilder.clearResources();
        taskInfoBuilder.addAllResources(resourcesList);

        Protos.TaskInfo newTaskInfo = taskInfoBuilder.build();
        LOGGER.info("Task {} new TaskInfo: ", newTaskInfo.getName(), newTaskInfo);
        taskInfoList.add(newTaskInfo);
    }
    return taskInfoList;
}
 
开发者ID:mesosphere,项目名称:dcos-kafka-service,代码行数:71,代码来源:KafkaConfigUpgrade.java


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