Github user zentol commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3481#discussion_r104780260
  
    --- Diff: 
flink-mesos/src/main/java/org/apache/flink/mesos/runtime/clusterframework/LaunchableMesosWorker.java
 ---
    @@ -262,9 +265,67 @@ public String toString() {
                        taskInfo.setContainer(containerInfo);
                }
     
    +           containerInfo.addAllVolumes(volumes(params.containerVolumes()));
    +
                return taskInfo.build();
        }
     
    +   /**
    +    * Used to build volume specs for mesos. This allows for mounting 
additional volumes into a container
    +    *
    +    * @param containerVolumes a comma delimited optional string of 
[host_path:]container_path[:RO|RW] that
    +    *                         defines mount points for a container volume. 
If None or empty string, returns
    +    *                         an empty iterator
    +    */
    +   public List<Protos.Volume> volumes(Option<String> containerVolumes) {
    +           if (containerVolumes.isEmpty()) {
    +                   return new ArrayList<Protos.Volume>();
    +           }
    +           String[] specs = containerVolumes.get().split(",");
    +           List<Protos.Volume> vols = new ArrayList<Protos.Volume>();
    +           for (int i = 0; i < specs.length; i++) {
    +                   String s = specs[i];
    +                   if (s.isEmpty()) {
    +                           continue;
    +                   }
    +                   Protos.Volume.Builder vol = Protos.Volume.newBuilder();
    +                   vol.setMode(Protos.Volume.Mode.RW);
    +
    +                   List<String> parts = Arrays.asList(s.split(":"));
    +                   switch (parts.size()) {
    +                           case 1:
    +                                   vol.setContainerPath(parts.get(0));
    +                                   break;
    +                           case 2:
    +                                   String modeOrPath = 
parts.get(1).trim().toUpperCase();
    +                                   if (modeOrPath.equals("RW")) {
    +                                           
vol.setContainerPath(parts.get(0));
    +                                           
vol.setMode(Protos.Volume.Mode.RW);
    +                                   } else if (modeOrPath.equals("RO")) {
    +                                           
vol.setContainerPath(parts.get(0));
    +                                           
vol.setMode(Protos.Volume.Mode.RO);
    +                                   } else {
    +                                           
vol.setHostPath(parts.get(0)).setContainerPath(modeOrPath);
    +                                   }
    +                                   break;
    +                           case 3:
    +                                   Protos.Volume.Mode mode = 
Protos.Volume.Mode.valueOf(parts.get(2).trim().toUpperCase());
    +                                   if (mode.equals(Protos.Volume.Mode.RW)) 
{
    +                                           
vol.setMode(Protos.Volume.Mode.RW);
    --- End diff --
    
    this block can be simplified to ```vol.setMode(mode)```.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to