@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()); assertEquals(0, MesosTaskManagerParameters.buildVolumes(Option.<String>apply("")).size()); }
public static List<Protos.Volume> buildVolumes(Option<String> containerVolumes) { if (containerVolumes.isEmpty()) { return Collections.emptyList(); } else { String[] volumeSpecifications = containerVolumes.get().split(","); List<Protos.Volume> volumes = new ArrayList<>(volumeSpecifications.length); for (String volumeSpecification : volumeSpecifications) { if (!volumeSpecification.trim().isEmpty()) { Protos.Volume.Builder volume = Protos.Volume.newBuilder(); volume.setMode(Protos.Volume.Mode.RW); String[] parts = volumeSpecification.split(":"); switch (parts.length) { case 1: volume.setContainerPath(parts[0]); break; case 2: try { Protos.Volume.Mode mode = Protos.Volume.Mode.valueOf(parts[1].trim().toUpperCase()); volume.setMode(mode) .setContainerPath(parts[0]); } catch (IllegalArgumentException e) { volume.setHostPath(parts[0]) .setContainerPath(parts[1]); } break; case 3: Protos.Volume.Mode mode = Protos.Volume.Mode.valueOf(parts[2].trim().toUpperCase()); volume.setMode(mode) .setHostPath(parts[0]) .setContainerPath(parts[1]); break; default: throw new IllegalArgumentException("volume specification is invalid, given: " + volumeSpecification); } volumes.add(volume.build()); } } return volumes; } }
MesosTaskManagerParameters { public static List<Protos.Volume> buildVolumes(Option<String> containerVolumes) { if (containerVolumes.isEmpty()) { return Collections.emptyList(); } else { String[] volumeSpecifications = containerVolumes.get().split(","); List<Protos.Volume> volumes = new ArrayList<>(volumeSpecifications.length); for (String volumeSpecification : volumeSpecifications) { if (!volumeSpecification.trim().isEmpty()) { Protos.Volume.Builder volume = Protos.Volume.newBuilder(); volume.setMode(Protos.Volume.Mode.RW); String[] parts = volumeSpecification.split(":"); switch (parts.length) { case 1: volume.setContainerPath(parts[0]); break; case 2: try { Protos.Volume.Mode mode = Protos.Volume.Mode.valueOf(parts[1].trim().toUpperCase()); volume.setMode(mode) .setContainerPath(parts[0]); } catch (IllegalArgumentException e) { volume.setHostPath(parts[0]) .setContainerPath(parts[1]); } break; case 3: Protos.Volume.Mode mode = Protos.Volume.Mode.valueOf(parts[2].trim().toUpperCase()); volume.setMode(mode) .setHostPath(parts[0]) .setContainerPath(parts[1]); break; default: throw new IllegalArgumentException("volume specification is invalid, given: " + volumeSpecification); } volumes.add(volume.build()); } } return volumes; } } }
MesosTaskManagerParameters { public static List<Protos.Volume> buildVolumes(Option<String> containerVolumes) { if (containerVolumes.isEmpty()) { return Collections.emptyList(); } else { String[] volumeSpecifications = containerVolumes.get().split(","); List<Protos.Volume> volumes = new ArrayList<>(volumeSpecifications.length); for (String volumeSpecification : volumeSpecifications) { if (!volumeSpecification.trim().isEmpty()) { Protos.Volume.Builder volume = Protos.Volume.newBuilder(); volume.setMode(Protos.Volume.Mode.RW); String[] parts = volumeSpecification.split(":"); switch (parts.length) { case 1: volume.setContainerPath(parts[0]); break; case 2: try { Protos.Volume.Mode mode = Protos.Volume.Mode.valueOf(parts[1].trim().toUpperCase()); volume.setMode(mode) .setContainerPath(parts[0]); } catch (IllegalArgumentException e) { volume.setHostPath(parts[0]) .setContainerPath(parts[1]); } break; case 3: Protos.Volume.Mode mode = Protos.Volume.Mode.valueOf(parts[2].trim().toUpperCase()); volume.setMode(mode) .setHostPath(parts[0]) .setContainerPath(parts[1]); break; default: throw new IllegalArgumentException("volume specification is invalid, given: " + volumeSpecification); } volumes.add(volume.build()); } } return volumes; } } MesosTaskManagerParameters(
			double cpus,
			int gpus,
			ContainerType containerType,
			Option<String> containerImageName,
			ContaineredTaskManagerParameters containeredParameters,
			List<Protos.Volume> containerVolumes,
			List<Protos.Parameter> dockerParameters,
			boolean dockerForcePullImage,
			List<ConstraintEvaluator> constraints,
			String command,
			Option<String> bootstrapCommand,
			Option<String> taskManagerHostname,
			List<String> uris); }
MesosTaskManagerParameters { public static List<Protos.Volume> buildVolumes(Option<String> containerVolumes) { if (containerVolumes.isEmpty()) { return Collections.emptyList(); } else { String[] volumeSpecifications = containerVolumes.get().split(","); List<Protos.Volume> volumes = new ArrayList<>(volumeSpecifications.length); for (String volumeSpecification : volumeSpecifications) { if (!volumeSpecification.trim().isEmpty()) { Protos.Volume.Builder volume = Protos.Volume.newBuilder(); volume.setMode(Protos.Volume.Mode.RW); String[] parts = volumeSpecification.split(":"); switch (parts.length) { case 1: volume.setContainerPath(parts[0]); break; case 2: try { Protos.Volume.Mode mode = Protos.Volume.Mode.valueOf(parts[1].trim().toUpperCase()); volume.setMode(mode) .setContainerPath(parts[0]); } catch (IllegalArgumentException e) { volume.setHostPath(parts[0]) .setContainerPath(parts[1]); } break; case 3: Protos.Volume.Mode mode = Protos.Volume.Mode.valueOf(parts[2].trim().toUpperCase()); volume.setMode(mode) .setHostPath(parts[0]) .setContainerPath(parts[1]); break; default: throw new IllegalArgumentException("volume specification is invalid, given: " + volumeSpecification); } volumes.add(volume.build()); } } return volumes; } } MesosTaskManagerParameters(
			double cpus,
			int gpus,
			ContainerType containerType,
			Option<String> containerImageName,
			ContaineredTaskManagerParameters containeredParameters,
			List<Protos.Volume> containerVolumes,
			List<Protos.Parameter> dockerParameters,
			boolean dockerForcePullImage,
			List<ConstraintEvaluator> constraints,
			String command,
			Option<String> bootstrapCommand,
			Option<String> taskManagerHostname,
			List<String> uris); double cpus(); int gpus(); ContainerType containerType(); Option<String> containerImageName(); ContaineredTaskManagerParameters containeredParameters(); List<Protos.Volume> containerVolumes(); List<Protos.Parameter> dockerParameters(); boolean dockerForcePullImage(); List<ConstraintEvaluator> constraints(); Option<String> getTaskManagerHostname(); String command(); Option<String> bootstrapCommand(); List<String> uris(); @Override String toString(); static MesosTaskManagerParameters create(Configuration flinkConfig); static List<Protos.Volume> buildVolumes(Option<String> containerVolumes); static List<Protos.Parameter> buildDockerParameters(Option<String> dockerParameters); static List<String> buildUris(Option<String> uris); }
MesosTaskManagerParameters { public static List<Protos.Volume> buildVolumes(Option<String> containerVolumes) { if (containerVolumes.isEmpty()) { return Collections.emptyList(); } else { String[] volumeSpecifications = containerVolumes.get().split(","); List<Protos.Volume> volumes = new ArrayList<>(volumeSpecifications.length); for (String volumeSpecification : volumeSpecifications) { if (!volumeSpecification.trim().isEmpty()) { Protos.Volume.Builder volume = Protos.Volume.newBuilder(); volume.setMode(Protos.Volume.Mode.RW); String[] parts = volumeSpecification.split(":"); switch (parts.length) { case 1: volume.setContainerPath(parts[0]); break; case 2: try { Protos.Volume.Mode mode = Protos.Volume.Mode.valueOf(parts[1].trim().toUpperCase()); volume.setMode(mode) .setContainerPath(parts[0]); } catch (IllegalArgumentException e) { volume.setHostPath(parts[0]) .setContainerPath(parts[1]); } break; case 3: Protos.Volume.Mode mode = Protos.Volume.Mode.valueOf(parts[2].trim().toUpperCase()); volume.setMode(mode) .setHostPath(parts[0]) .setContainerPath(parts[1]); break; default: throw new IllegalArgumentException("volume specification is invalid, given: " + volumeSpecification); } volumes.add(volume.build()); } } return volumes; } } MesosTaskManagerParameters(
			double cpus,
			int gpus,
			ContainerType containerType,
			Option<String> containerImageName,
			ContaineredTaskManagerParameters containeredParameters,
			List<Protos.Volume> containerVolumes,
			List<Protos.Parameter> dockerParameters,
			boolean dockerForcePullImage,
			List<ConstraintEvaluator> constraints,
			String command,
			Option<String> bootstrapCommand,
			Option<String> taskManagerHostname,
			List<String> uris); double cpus(); int gpus(); ContainerType containerType(); Option<String> containerImageName(); ContaineredTaskManagerParameters containeredParameters(); List<Protos.Volume> containerVolumes(); List<Protos.Parameter> dockerParameters(); boolean dockerForcePullImage(); List<ConstraintEvaluator> constraints(); Option<String> getTaskManagerHostname(); String command(); Option<String> bootstrapCommand(); List<String> uris(); @Override String toString(); static MesosTaskManagerParameters create(Configuration flinkConfig); static List<Protos.Volume> buildVolumes(Option<String> containerVolumes); static List<Protos.Parameter> buildDockerParameters(Option<String> dockerParameters); static List<String> buildUris(Option<String> uris); static final Pattern TASK_ID_PATTERN; static final ConfigOption<Integer> MESOS_RM_TASKS_SLOTS; static final ConfigOption<Integer> MESOS_RM_TASKS_MEMORY_MB; static final ConfigOption<Double> MESOS_RM_TASKS_CPUS; static final ConfigOption<Integer> MESOS_RM_TASKS_GPUS; static final ConfigOption<String> MESOS_RM_CONTAINER_TYPE; static final ConfigOption<String> MESOS_RM_CONTAINER_IMAGE_NAME; static final ConfigOption<String> MESOS_TM_HOSTNAME; static final ConfigOption<String> MESOS_TM_CMD; static final ConfigOption<String> MESOS_TM_BOOTSTRAP_CMD; static final ConfigOption<String> MESOS_TM_URIS; static final ConfigOption<String> MESOS_RM_CONTAINER_VOLUMES; static final ConfigOption<String> MESOS_RM_CONTAINER_DOCKER_PARAMETERS; static final ConfigOption<Boolean> MESOS_RM_CONTAINER_DOCKER_FORCE_PULL_IMAGE; static final ConfigOption<String> MESOS_CONSTRAINTS_HARD_HOSTATTR; static final String MESOS_RESOURCEMANAGER_TASKS_CONTAINER_TYPE_MESOS; static final String MESOS_RESOURCEMANAGER_TASKS_CONTAINER_TYPE_DOCKER; }