本文整理汇总了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;
}
示例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());
}
示例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;
}
示例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());
}
示例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);
}
示例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());
}
示例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());
}
示例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);
}
}
}
示例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();
}
示例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;
}
示例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();
}
示例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());
}
示例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());
}
示例14: getContainerVolumes
import org.apache.mesos.Protos; //导入方法依赖的package包/类
public List<Protos.Volume> getContainerVolumes() {
return taskInfo.getContainer().getVolumesList();
}
示例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;
}