Search in sources :

Example 1 with ExecutorPort

use of com.twitter.heron.scheduler.utils.SchedulerUtils.ExecutorPort in project incubator-heron by apache.

the class AppsV1beta1Controller method getExecutorCommand.

protected List<String> getExecutorCommand(String containerId) {
    final Map<ExecutorPort, String> ports = KubernetesConstants.EXECUTOR_PORTS.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().toString()));
    final Config configuration = getConfiguration();
    final Config runtimeConfiguration = getRuntimeConfiguration();
    final String[] executorCommand = SchedulerUtils.getExecutorCommand(configuration, runtimeConfiguration, containerId, ports);
    return Arrays.asList("sh", "-c", KubernetesUtils.getFetchCommand(configuration, runtimeConfiguration) + " && " + setShardIdEnvironmentVariableCommand() + " && " + String.join(" ", executorCommand));
}
Also used : IntStream(java.util.stream.IntStream) JsonObject(com.google.gson.JsonObject) Arrays(java.util.Arrays) ApiException(io.kubernetes.client.ApiException) V1Container(io.kubernetes.client.models.V1Container) Response(com.squareup.okhttp.Response) HashMap(java.util.HashMap) V1ObjectFieldSelector(io.kubernetes.client.models.V1ObjectFieldSelector) ApiClient(io.kubernetes.client.ApiClient) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) AppsV1beta1Api(io.kubernetes.client.apis.AppsV1beta1Api) JsonElement(com.google.gson.JsonElement) TopologySubmissionException(com.twitter.heron.scheduler.TopologySubmissionException) SchedulerUtils(com.twitter.heron.scheduler.utils.SchedulerUtils) Gson(com.google.gson.Gson) V1EnvVarSource(io.kubernetes.client.models.V1EnvVarSource) Map(java.util.Map) Runtime(com.twitter.heron.scheduler.utils.Runtime) V1ObjectMeta(io.kubernetes.client.models.V1ObjectMeta) ExecutorPort(com.twitter.heron.scheduler.utils.SchedulerUtils.ExecutorPort) V1beta1StatefulSet(io.kubernetes.client.models.V1beta1StatefulSet) Config(com.twitter.heron.spi.common.Config) V1ContainerPort(io.kubernetes.client.models.V1ContainerPort) V1EnvVar(io.kubernetes.client.models.V1EnvVar) V1PodTemplateSpec(io.kubernetes.client.models.V1PodTemplateSpec) V1Volume(io.kubernetes.client.models.V1Volume) Set(java.util.Set) IOException(java.io.IOException) TopologyRuntimeManagementException(com.twitter.heron.scheduler.TopologyRuntimeManagementException) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) PackingPlan(com.twitter.heron.spi.packing.PackingPlan) V1LabelSelector(io.kubernetes.client.models.V1LabelSelector) V1ResourceRequirements(io.kubernetes.client.models.V1ResourceRequirements) List(java.util.List) Resource(com.twitter.heron.spi.packing.Resource) V1beta1StatefulSetSpec(io.kubernetes.client.models.V1beta1StatefulSetSpec) V1Toleration(io.kubernetes.client.models.V1Toleration) V1DeleteOptions(io.kubernetes.client.models.V1DeleteOptions) Collections(java.util.Collections) V1PodSpec(io.kubernetes.client.models.V1PodSpec) V1VolumeMount(io.kubernetes.client.models.V1VolumeMount) TopologyUtils(com.twitter.heron.api.utils.TopologyUtils) Config(com.twitter.heron.spi.common.Config) ExecutorPort(com.twitter.heron.scheduler.utils.SchedulerUtils.ExecutorPort) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with ExecutorPort

use of com.twitter.heron.scheduler.utils.SchedulerUtils.ExecutorPort in project incubator-heron by apache.

the class MarathonScheduler method getPorts.

protected ArrayNode getPorts(ObjectMapper mapper) {
    ArrayNode ports = mapper.createArrayNode();
    for (Map.Entry<ExecutorPort, String> entry : MarathonConstants.EXECUTOR_PORTS.entrySet()) {
        ObjectNode port = mapper.createObjectNode();
        port.put(MarathonConstants.DOCKER_CONTAINER_PORT, 0);
        port.put(MarathonConstants.PROTOCOL, MarathonConstants.TCP);
        port.put(MarathonConstants.HOST_PORT, 0);
        port.put(MarathonConstants.PORT_NAME, entry.getKey().getName());
        ports.add(port);
    }
    return ports;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) ExecutorPort(com.twitter.heron.scheduler.utils.SchedulerUtils.ExecutorPort) Map(java.util.Map)

Example 3 with ExecutorPort

use of com.twitter.heron.scheduler.utils.SchedulerUtils.ExecutorPort in project incubator-heron by apache.

the class LocalScheduler method getExecutorCommand.

private String[] getExecutorCommand(int container, Set<PackingPlan.InstancePlan> instances) {
    Map<ExecutorPort, String> ports = new HashMap<>();
    for (ExecutorPort executorPort : ExecutorPort.getRequiredPorts()) {
        int port = SysUtils.getFreePort();
        if (port == -1) {
            throw new RuntimeException("Failed to find available ports for executor");
        }
        ports.put(executorPort, String.valueOf(port));
    }
    if (TopologyUtils.getTopologyRemoteDebuggingEnabled(Runtime.topology(runtime)) && instances != null) {
        List<String> remoteDebuggingPorts = new LinkedList<>();
        int portsForRemoteDebugging = instances.size();
        for (int i = 0; i < portsForRemoteDebugging; i++) {
            int port = SysUtils.getFreePort();
            if (port == -1) {
                throw new RuntimeException("Failed to find available ports for executor");
            }
            remoteDebuggingPorts.add(String.valueOf(port));
        }
        ports.put(ExecutorPort.JVM_REMOTE_DEBUGGER_PORTS, String.join(",", remoteDebuggingPorts));
    }
    String[] executorCmd = SchedulerUtils.getExecutorCommand(config, runtime, container, ports);
    LOG.info("Executor command line: " + Arrays.toString(executorCmd));
    return executorCmd;
}
Also used : HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ExecutorPort(com.twitter.heron.scheduler.utils.SchedulerUtils.ExecutorPort) LinkedList(java.util.LinkedList)

Example 4 with ExecutorPort

use of com.twitter.heron.scheduler.utils.SchedulerUtils.ExecutorPort in project incubator-heron by apache.

the class HeronExecutorTask method getExecutorCommand.

String[] getExecutorCommand() throws InvalidTopologyException {
    String topologyDefFile = getTopologyDefnFile();
    Topology topology = getTopology(topologyDefFile);
    Config config = SchedulerConfigUtils.loadConfig(cluster, role, env, topologyJar, topologyDefFile, verboseMode, topology);
    Config runtime = Config.newBuilder().put(Key.COMPONENT_RAMMAP, componentRamMap).put(Key.TOPOLOGY_DEFINITION, topology).build();
    Map<ExecutorPort, String> ports = new HashMap<>();
    for (ExecutorPort executorPort : ExecutorPort.getRequiredPorts()) {
        int port = SysUtils.getFreePort();
        if (port == -1) {
            throw new RuntimeException("Failed to find available ports for executor");
        }
        ports.put(executorPort, String.valueOf(port));
    }
    String[] executorCmd = SchedulerUtils.getExecutorCommand(config, runtime, heronExecutorId, ports);
    LOG.info("Executor command line: " + Arrays.toString(executorCmd));
    return executorCmd;
}
Also used : HashMap(java.util.HashMap) Config(com.twitter.heron.spi.common.Config) Topology(com.twitter.heron.api.generated.TopologyAPI.Topology) ExecutorPort(com.twitter.heron.scheduler.utils.SchedulerUtils.ExecutorPort)

Example 5 with ExecutorPort

use of com.twitter.heron.scheduler.utils.SchedulerUtils.ExecutorPort in project incubator-heron by apache.

the class SlurmScheduler method getExecutorCommand.

protected String[] getExecutorCommand(PackingPlan packing) {
    Map<ExecutorPort, String> ports = new HashMap<>();
    for (ExecutorPort executorPort : ExecutorPort.getRequiredPorts()) {
        int port = SysUtils.getFreePort();
        if (port == -1) {
            throw new RuntimeException("Failed to find available ports for executor");
        }
        ports.put(executorPort, String.valueOf(port));
    }
    String[] executorCmd = SchedulerUtils.executorCommandArgs(this.config, this.runtime, ports, null);
    LOG.log(Level.FINE, "Executor command line: ", Arrays.toString(executorCmd));
    return executorCmd;
}
Also used : HashMap(java.util.HashMap) ExecutorPort(com.twitter.heron.scheduler.utils.SchedulerUtils.ExecutorPort)

Aggregations

ExecutorPort (com.twitter.heron.scheduler.utils.SchedulerUtils.ExecutorPort)5 HashMap (java.util.HashMap)4 Config (com.twitter.heron.spi.common.Config)2 Map (java.util.Map)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Gson (com.google.gson.Gson)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 Response (com.squareup.okhttp.Response)1 Topology (com.twitter.heron.api.generated.TopologyAPI.Topology)1 TopologyUtils (com.twitter.heron.api.utils.TopologyUtils)1 TopologyRuntimeManagementException (com.twitter.heron.scheduler.TopologyRuntimeManagementException)1 TopologySubmissionException (com.twitter.heron.scheduler.TopologySubmissionException)1 Runtime (com.twitter.heron.scheduler.utils.Runtime)1 SchedulerUtils (com.twitter.heron.scheduler.utils.SchedulerUtils)1 PackingPlan (com.twitter.heron.spi.packing.PackingPlan)1 Resource (com.twitter.heron.spi.packing.Resource)1 ApiClient (io.kubernetes.client.ApiClient)1 ApiException (io.kubernetes.client.ApiException)1