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

    https://github.com/apache/flink/pull/2315#discussion_r75272248
  
    --- Diff: 
flink-mesos/src/main/java/org/apache/flink/mesos/runtime/clusterframework/LaunchableMesosWorker.java
 ---
    @@ -0,0 +1,205 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.flink.mesos.runtime.clusterframework;
    +
    +import com.netflix.fenzo.ConstraintEvaluator;
    +import com.netflix.fenzo.TaskAssignmentResult;
    +import com.netflix.fenzo.TaskRequest;
    +import com.netflix.fenzo.VMTaskFitnessCalculator;
    +import org.apache.flink.configuration.Configuration;
    +import org.apache.flink.mesos.cli.FlinkMesosSessionCli;
    +import org.apache.flink.mesos.scheduler.LaunchableTask;
    +import org.apache.mesos.Protos;
    +
    +import java.util.Collections;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.concurrent.atomic.AtomicReference;
    +
    +import static org.apache.flink.mesos.Utils.variable;
    +import static org.apache.flink.mesos.Utils.range;
    +import static org.apache.flink.mesos.Utils.ranges;
    +import static org.apache.flink.mesos.Utils.scalar;
    +
    +/**
    + * Specifies how to launch a Mesos worker.
    + */
    +public class LaunchableMesosWorker implements LaunchableTask {
    +
    +   /**
    +    * The set of configuration keys to be dynamically configured with a 
port allocated from Mesos.
    +    */
    +   private static String[] TM_PORT_KEYS = {
    +           "taskmanager.rpc.port",
    +           "taskmanager.data.port" };
    +
    +   private final MesosTaskManagerParameters params;
    +   private final Protos.TaskInfo.Builder template;
    +   private final Protos.TaskID taskID;
    +   private final Request taskRequest;
    +
    +   /**
    +    * Construct a launchable Mesos worker.
    +    * @param params the TM parameters such as memory, cpu to acquire.
    +    * @param template a template for the TaskInfo to be constructed at 
launch time.
    +    * @param taskID the taskID for this worker.
    +     */
    +   public LaunchableMesosWorker(MesosTaskManagerParameters params, 
Protos.TaskInfo.Builder template, Protos.TaskID taskID) {
    +           this.params = params;
    +           this.template = template;
    +           this.taskID = taskID;
    +           this.taskRequest = new Request();
    +   }
    +
    +   public Protos.TaskID taskID() {
    +           return taskID;
    +   }
    +
    +   @Override
    +   public TaskRequest taskRequest() {
    +           return taskRequest;
    +   }
    +
    +   class Request implements TaskRequest {
    +           private final AtomicReference<TaskRequest.AssignedResources> 
assignedResources = new AtomicReference<>();
    +
    +           @Override
    +           public String getId() {
    +                   return taskID.getValue();
    +           }
    +
    +           @Override
    +           public String taskGroupName() {
    +                   return "";
    +           }
    +
    +           @Override
    +           public double getCPUs() {
    +                   return params.cpus();
    +           }
    +
    +           @Override
    +           public double getMemory() {
    +                   return 
params.containeredParameters().taskManagerTotalMemoryMB();
    +           }
    +
    +           @Override
    +           public double getNetworkMbps() {
    +                   return 0.0;
    +           }
    +
    +           @Override
    +           public double getDisk() {
    +                   return 0.0;
    --- End diff --
    
    I would rather throw an exception here if the value is not in use.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to