From 0cd63461021cc7cac39e7cc2bfaafd609c82fc79 Mon Sep 17 00:00:00 2001 From: Sunil G Date: Fri, 21 Sep 2018 23:39:22 +0530 Subject: [PATCH] YARN-8769. [Submarine] Allow user to specify customized quicklink(s) when submit Submarine job. Contributed by Wangda Tan. --- .../submarine/client/cli/CliConstants.java | 1 + .../yarn/submarine/client/cli/RunJobCli.java | 8 ++ .../submarine/client/cli/param/Quicklink.java | 71 +++++++++++++ .../client/cli/param/RunJobParameters.java | 18 ++++ .../yarnservice/YarnServiceJobSubmitter.java | 99 ++++++++++++++----- .../yarnservice/YarnServiceUtils.java | 47 +++++++-- .../yarnservice/TestYarnServiceRunJobCli.java | 94 ++++++++++++++++++ 7 files changed, 303 insertions(+), 35 deletions(-) create mode 100644 hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/client/cli/param/Quicklink.java diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/client/cli/CliConstants.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/client/cli/CliConstants.java index d51ffc7bd2c..454ff1cc1be 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/client/cli/CliConstants.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/client/cli/CliConstants.java @@ -49,6 +49,7 @@ public class CliConstants { public static final String WAIT_JOB_FINISH = "wait_job_finish"; public static final String PS_DOCKER_IMAGE = "ps_docker_image"; public static final String WORKER_DOCKER_IMAGE = "worker_docker_image"; + public static final String QUICKLINK = "quicklink"; public static final String TENSORBOARD_DOCKER_IMAGE = "tensorboard_docker_image"; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/client/cli/RunJobCli.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/client/cli/RunJobCli.java index faa22d38cb4..5054a94c7bb 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/client/cli/RunJobCli.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/client/cli/RunJobCli.java @@ -117,6 +117,14 @@ public class RunJobCli extends AbstractCli { options.addOption(CliConstants.WORKER_DOCKER_IMAGE, true, "Specify docker image for WORKER, when this is not specified, WORKER " + "uses --" + CliConstants.DOCKER_IMAGE + " as default."); + options.addOption(CliConstants.QUICKLINK, true, "Specify quicklink so YARN" + + "web UI shows link to given role instance and port. When " + + "--tensorboard is speciied, quicklink to tensorboard instance will " + + "be added automatically. The format of quick link is: " + + "Quick_link_label=http(or https)://role-name:port. For example, " + + "if want to link to first worker's 7070 port, and text of quicklink " + + "is Notebook_UI, user need to specify --quicklink " + + "Notebook_UI=https://master-0:7070"); options.addOption("h", "help", false, "Print help"); return options; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/client/cli/param/Quicklink.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/client/cli/param/Quicklink.java new file mode 100644 index 00000000000..ea8732ce507 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-submarine/src/main/java/org/apache/hadoop/yarn/submarine/client/cli/param/Quicklink.java @@ -0,0 +1,71 @@ +/** + * Licensed 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. See accompanying LICENSE file. + */ + +package org.apache.hadoop.yarn.submarine.client.cli.param; + +import org.apache.commons.cli.ParseException; + +/** + * A class represents quick links to a web page. + */ +public class Quicklink { + private String label; + private String componentInstanceName; + private String protocol; + private int port; + + public void parse(String quicklinkStr) throws ParseException { + if (!quicklinkStr.contains("=")) { + throw new ParseException("Should be