{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-myriad/pulls/comments/67171120","id":67171120,"diff_hunk":"@@ -19,11 +19,148 @@\n \n package org.apache.myriad.scheduler;\n \n+import com.google.common.base.Preconditions;\n+import com.google.common.base.Strings;\n+import org.apache.commons.lang3.StringUtils;\n+import org.apache.hadoop.yarn.conf.YarnConfiguration;\n+import org.apache.mesos.Protos;\n+import org.apache.myriad.configuration.MyriadConfiguration;\n+import org.apache.myriad.configuration.MyriadExecutorConfiguration;\n+import org.apache.myriad.configuration.ServiceConfiguration;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import java.util.ArrayList;\n+import java.util.List;\n+\n /**\n  * Interface to plugin multiple implementations for executor command generation\n  */\n-public interface ExecutorCommandLineGenerator {\n-  String generateCommandLine(ServiceResourceProfile profile, Ports ports);\n+public abstract class ExecutorCommandLineGenerator {\n+\n+  protected static final Logger LOGGER = LoggerFactory.getLogger(NMExecutorCommandLineGenerator.class);\n+\n+  public static final String KEY_YARN_RM_HOSTNAME = \"yarn.resourcemanager.hostname\";\n+  public static final String KEY_YARN_HOME = \"yarn.home\";\n+\n+  protected static final String ALL_LOCAL_IPV4ADDR = \"0.0.0.0:\";\n+\n+  protected static final String PROPERTY_FORMAT = \" -D%s=%s \";\n+  protected static final String CMD_FORMAT = \"echo \\\"%1$s\\\" && %1$s\";\n+\n+  protected Protos.CommandInfo staticCommandInfo;\n+\n+  protected MyriadConfiguration myriadConfiguration;\n+  protected MyriadExecutorConfiguration myriadExecutorConfiguration;\n+  protected YarnConfiguration yarnConfiguration = new YarnConfiguration();\n+\n+  abstract Protos.CommandInfo generateCommandLine(ServiceResourceProfile profile, ServiceConfiguration serviceConfiguration, AbstractPorts ports);\n+\n+  protected void appendDistroExtractionCommands(StringBuilder cmdLine) {\n+    /*\n+    TODO(darinj): Overall this is messier than I'd like. We can't let mesos untar the distribution, since\n+    it will change the permissions.  Instead we simply download the tarball and execute tar -xvpf. We also\n+    pull the config from the resource manager and put them in the yarnConfiguration dir.  This is also why we need\n+    frameworkSuperUser. This will be refactored after Mesos-1790 is resolved.\n+   */\n+\n+    //TODO(DarinJ) support other compression, as this is a temp fix for Mesos 1760 may not get to it.\n+    if (myriadExecutorConfiguration.getNodeManagerUri().isPresent()) {\n+      //Extract tarball keeping permissions, necessary to keep HADOOP_HOME/bin/container-executor suidbit set.\n+      //If SudoUser not enable LinuxExecutor will not work\n+      appendSudo(cmdLine);\n+      cmdLine.append(\"tar -zxpf \").append(getFileName(myriadExecutorConfiguration.getNodeManagerUri().get()));\n+      cmdLine.append(\" && \");\n+      //Place the hadoop config where in the HADOOP_CONF_DIR where it will be read by the NodeManager\n+      //The url for the resource manager config is: http(s)://hostname:port/yarnConfiguration so fetcher.cpp downloads the\n+      //config file to yarnConfiguration, It's an xml file with the parameters of yarn-site.xml, core-site.xml and hdfs.xml.\n+      if (!myriadExecutorConfiguration.getConfigUri().isPresent()) {\n+        appendSudo(cmdLine);\n+        cmdLine.append(\" cp yarnConfiguration \");\n+        cmdLine.append(myriadConfiguration.getYarnEnvironment().get(\"YARN_HOME\"));\n+        cmdLine.append(\"/etc/hadoop/yarn-site.xml && \");\n+      }\n+    }\n+  }\n+\n+  protected void addJavaOpt(StringBuilder opts, String propertyName, String propertyValue) {\n+    String envOpt = String.format(PROPERTY_FORMAT, propertyName, propertyValue);\n+    opts.append(envOpt);\n+  }\n+\n+  protected void appendSudo(StringBuilder cmdLine) {\n+    if (myriadConfiguration.getFrameworkSuperUser().isPresent()) {\n+      cmdLine.append(\" sudo \");\n+    }\n+  }\n+\n+  protected void appendUserSudo(StringBuilder cmdLine) {\n+    if (myriadConfiguration.getFrameworkSuperUser().isPresent()) {\n+      cmdLine.append(\" sudo -E -u \");\n+      cmdLine.append(myriadConfiguration.getFrameworkUser().get());\n+      cmdLine.append(\" -H \");\n+    }\n+  }\n+\n+  public String getConfigurationUrl() {\n+    String httpPolicy = yarnConfiguration.get(TaskFactory.YARN_HTTP_POLICY);\n+    String address = StringUtils.EMPTY;\n+    if (httpPolicy != null && httpPolicy.equals(TaskFactory.YARN_HTTP_POLICY_HTTPS_ONLY)) {\n+      address = yarnConfiguration.get(TaskFactory.YARN_RESOURCEMANAGER_WEBAPP_HTTPS_ADDRESS);\n+      if (StringUtils.isEmpty(address)) {\n+        address = yarnConfiguration.get(TaskFactory.YARN_RESOURCEMANAGER_HOSTNAME) + \":8090\";\n+      }\n+    } else {\n+      address = yarnConfiguration.get(TaskFactory.YARN_RESOURCEMANAGER_WEBAPP_ADDRESS);\n+      if (StringUtils.isEmpty(address)) {\n+        address = yarnConfiguration.get(TaskFactory.YARN_RESOURCEMANAGER_HOSTNAME) + \":8088\";\n+      }\n+    }\n+\n+    return \"http://\" + address + \"/yarnConfiguration\";\n+  }\n+\n+  private static String getFileName(String uri) {","path":"myriad-scheduler/src/main/java/org/apache/myriad/scheduler/ExecutorCommandLineGenerator.java","position":107,"original_position":107,"commit_id":"8a3b6d65810c4ab24022f5ab4c858f6ccc8c7e7c","original_commit_id":"8a3b6d65810c4ab24022f5ab4c858f6ccc8c7e7c","user":{"login":"hokiegeek2","id":10785153,"avatar_url":"https://avatars.githubusercontent.com/u/10785153?v=3","gravatar_id":"","url":"https://api.github.com/users/hokiegeek2","html_url":"https://github.com/hokiegeek2","followers_url":"https://api.github.com/users/hokiegeek2/followers","following_url":"https://api.github.com/users/hokiegeek2/following{/other_user}","gists_url":"https://api.github.com/users/hokiegeek2/gists{/gist_id}","starred_url":"https://api.github.com/users/hokiegeek2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hokiegeek2/subscriptions","organizations_url":"https://api.github.com/users/hokiegeek2/orgs","repos_url":"https://api.github.com/users/hokiegeek2/repos","events_url":"https://api.github.com/users/hokiegeek2/events{/privacy}","received_events_url":"https://api.github.com/users/hokiegeek2/received_events","type":"User","site_admin":false},"body":"Recommend throwing an unchecked exception such as IllegalArgumentException if the filename is invalid. I may be missing something, but it seems like we don't want the command line generation to continue for invalid file names","created_at":"2016-06-15T14:23:58Z","updated_at":"2016-06-15T14:23:58Z","html_url":"https://github.com/apache/incubator-myriad/pull/79#discussion_r67171120","pull_request_url":"https://api.github.com/repos/apache/incubator-myriad/pulls/79","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-myriad/pulls/comments/67171120"},"html":{"href":"https://github.com/apache/incubator-myriad/pull/79#discussion_r67171120"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-myriad/pulls/79"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-myriad/pulls/79","id":73256503,"html_url":"https://github.com/apache/incubator-myriad/pull/79","diff_url":"https://github.com/apache/incubator-myriad/pull/79.diff","patch_url":"https://github.com/apache/incubator-myriad/pull/79.patch","issue_url":"https://api.github.com/repos/apache/incubator-myriad/issues/79","number":79,"state":"open","locked":false,"title":"WIP - Addresses Myriad 213, 214, and 136.","user":{"login":"DarinJ","id":6180638,"avatar_url":"https://avatars.githubusercontent.com/u/6180638?v=3","gravatar_id":"","url":"https://api.github.com/users/DarinJ","html_url":"https://github.com/DarinJ","followers_url":"https://api.github.com/users/DarinJ/followers","following_url":"https://api.github.com/users/DarinJ/following{/other_user}","gists_url":"https://api.github.com/users/DarinJ/gists{/gist_id}","starred_url":"https://api.github.com/users/DarinJ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DarinJ/subscriptions","organizations_url":"https://api.github.com/users/DarinJ/orgs","repos_url":"https://api.github.com/users/DarinJ/repos","events_url":"https://api.github.com/users/DarinJ/events{/privacy}","received_events_url":"https://api.github.com/users/DarinJ/received_events","type":"User","site_admin":false},"body":"Resolve NMPorts (Still exists temporarily until 213 is fully resolved) by adding a more general Ports container class, Refactor ExecutorCommandLineGenerator classes to use this class (resolves Myriad-214 in the process). Refactor TackFactory classes as necessary to work with this. This adds a few methods to TaskUtils to get port Resources.\r\n\r\nThis significantly reduces the amount of code in the TaskFactories.","created_at":"2016-06-09T17:47:19Z","updated_at":"2016-06-15T14:23:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9f68a62cbc6d7391b3c027a2ee80a079c891728f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-myriad/pulls/79/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-myriad/pulls/79/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-myriad/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-myriad/issues/79/comments","statuses_url":"https://api.github.com/repos/apache/incubator-myriad/statuses/8a3b6d65810c4ab24022f5ab4c858f6ccc8c7e7c","head":{"label":"DarinJ:RefactorExecutorCommandLineGenerator","ref":"RefactorExecutorCommandLineGenerator","sha":"8a3b6d65810c4ab24022f5ab4c858f6ccc8c7e7c","user":{"login":"DarinJ","id":6180638,"avatar_url":"https://avatars.githubusercontent.com/u/6180638?v=3","gravatar_id":"","url":"https://api.github.com/users/DarinJ","html_url":"https://github.com/DarinJ","followers_url":"https://api.github.com/users/DarinJ/followers","following_url":"https://api.github.com/users/DarinJ/following{/other_user}","gists_url":"https://api.github.com/users/DarinJ/gists{/gist_id}","starred_url":"https://api.github.com/users/DarinJ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DarinJ/subscriptions","organizations_url":"https://api.github.com/users/DarinJ/orgs","repos_url":"https://api.github.com/users/DarinJ/repos","events_url":"https://api.github.com/users/DarinJ/events{/privacy}","received_events_url":"https://api.github.com/users/DarinJ/received_events","type":"User","site_admin":false},"repo":{"id":43473289,"name":"incubator-myriad","full_name":"DarinJ/incubator-myriad","owner":{"login":"DarinJ","id":6180638,"avatar_url":"https://avatars.githubusercontent.com/u/6180638?v=3","gravatar_id":"","url":"https://api.github.com/users/DarinJ","html_url":"https://github.com/DarinJ","followers_url":"https://api.github.com/users/DarinJ/followers","following_url":"https://api.github.com/users/DarinJ/following{/other_user}","gists_url":"https://api.github.com/users/DarinJ/gists{/gist_id}","starred_url":"https://api.github.com/users/DarinJ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DarinJ/subscriptions","organizations_url":"https://api.github.com/users/DarinJ/orgs","repos_url":"https://api.github.com/users/DarinJ/repos","events_url":"https://api.github.com/users/DarinJ/events{/privacy}","received_events_url":"https://api.github.com/users/DarinJ/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DarinJ/incubator-myriad","description":"Mirror of Apache Myriad (Incubating)","fork":true,"url":"https://api.github.com/repos/DarinJ/incubator-myriad","forks_url":"https://api.github.com/repos/DarinJ/incubator-myriad/forks","keys_url":"https://api.github.com/repos/DarinJ/incubator-myriad/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DarinJ/incubator-myriad/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DarinJ/incubator-myriad/teams","hooks_url":"https://api.github.com/repos/DarinJ/incubator-myriad/hooks","issue_events_url":"https://api.github.com/repos/DarinJ/incubator-myriad/issues/events{/number}","events_url":"https://api.github.com/repos/DarinJ/incubator-myriad/events","assignees_url":"https://api.github.com/repos/DarinJ/incubator-myriad/assignees{/user}","branches_url":"https://api.github.com/repos/DarinJ/incubator-myriad/branches{/branch}","tags_url":"https://api.github.com/repos/DarinJ/incubator-myriad/tags","blobs_url":"https://api.github.com/repos/DarinJ/incubator-myriad/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DarinJ/incubator-myriad/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DarinJ/incubator-myriad/git/refs{/sha}","trees_url":"https://api.github.com/repos/DarinJ/incubator-myriad/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DarinJ/incubator-myriad/statuses/{sha}","languages_url":"https://api.github.com/repos/DarinJ/incubator-myriad/languages","stargazers_url":"https://api.github.com/repos/DarinJ/incubator-myriad/stargazers","contributors_url":"https://api.github.com/repos/DarinJ/incubator-myriad/contributors","subscribers_url":"https://api.github.com/repos/DarinJ/incubator-myriad/subscribers","subscription_url":"https://api.github.com/repos/DarinJ/incubator-myriad/subscription","commits_url":"https://api.github.com/repos/DarinJ/incubator-myriad/commits{/sha}","git_commits_url":"https://api.github.com/repos/DarinJ/incubator-myriad/git/commits{/sha}","comments_url":"https://api.github.com/repos/DarinJ/incubator-myriad/comments{/number}","issue_comment_url":"https://api.github.com/repos/DarinJ/incubator-myriad/issues/comments{/number}","contents_url":"https://api.github.com/repos/DarinJ/incubator-myriad/contents/{+path}","compare_url":"https://api.github.com/repos/DarinJ/incubator-myriad/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DarinJ/incubator-myriad/merges","archive_url":"https://api.github.com/repos/DarinJ/incubator-myriad/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DarinJ/incubator-myriad/downloads","issues_url":"https://api.github.com/repos/DarinJ/incubator-myriad/issues{/number}","pulls_url":"https://api.github.com/repos/DarinJ/incubator-myriad/pulls{/number}","milestones_url":"https://api.github.com/repos/DarinJ/incubator-myriad/milestones{/number}","notifications_url":"https://api.github.com/repos/DarinJ/incubator-myriad/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DarinJ/incubator-myriad/labels{/name}","releases_url":"https://api.github.com/repos/DarinJ/incubator-myriad/releases{/id}","deployments_url":"https://api.github.com/repos/DarinJ/incubator-myriad/deployments","created_at":"2015-10-01T01:51:43Z","updated_at":"2016-02-23T02:54:52Z","pushed_at":"2016-06-09T18:41:06Z","git_url":"git://github.com/DarinJ/incubator-myriad.git","ssh_url":"git@github.com:DarinJ/incubator-myriad.git","clone_url":"https://github.com/DarinJ/incubator-myriad.git","svn_url":"https://github.com/DarinJ/incubator-myriad","homepage":null,"size":8828,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"cbdcbbe0349f7a10a3fba98ccd120e228982a193","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":33397227,"name":"incubator-myriad","full_name":"apache/incubator-myriad","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/incubator-myriad","description":"Mirror of Apache Myriad (Incubating)","fork":false,"url":"https://api.github.com/repos/apache/incubator-myriad","forks_url":"https://api.github.com/repos/apache/incubator-myriad/forks","keys_url":"https://api.github.com/repos/apache/incubator-myriad/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-myriad/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-myriad/teams","hooks_url":"https://api.github.com/repos/apache/incubator-myriad/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-myriad/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-myriad/events","assignees_url":"https://api.github.com/repos/apache/incubator-myriad/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-myriad/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-myriad/tags","blobs_url":"https://api.github.com/repos/apache/incubator-myriad/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-myriad/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-myriad/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-myriad/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-myriad/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-myriad/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-myriad/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-myriad/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-myriad/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-myriad/subscription","commits_url":"https://api.github.com/repos/apache/incubator-myriad/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-myriad/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-myriad/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-myriad/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-myriad/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-myriad/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-myriad/merges","archive_url":"https://api.github.com/repos/apache/incubator-myriad/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-myriad/downloads","issues_url":"https://api.github.com/repos/apache/incubator-myriad/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-myriad/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-myriad/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-myriad/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-myriad/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-myriad/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-myriad/deployments","created_at":"2015-04-04T07:00:05Z","updated_at":"2016-06-11T14:04:00Z","pushed_at":"2016-06-13T13:58:35Z","git_url":"git://github.com/apache/incubator-myriad.git","ssh_url":"git@github.com:apache/incubator-myriad.git","clone_url":"https://github.com/apache/incubator-myriad.git","svn_url":"https://github.com/apache/incubator-myriad","homepage":null,"size":9157,"stargazers_count":55,"watchers_count":55,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":40,"mirror_url":"git://git.apache.org/incubator-myriad.git","open_issues_count":4,"forks":40,"open_issues":4,"watchers":55,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-myriad/pulls/79"},"html":{"href":"https://github.com/apache/incubator-myriad/pull/79"},"issue":{"href":"https://api.github.com/repos/apache/incubator-myriad/issues/79"},"comments":{"href":"https://api.github.com/repos/apache/incubator-myriad/issues/79/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-myriad/pulls/79/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-myriad/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-myriad/pulls/79/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-myriad/statuses/8a3b6d65810c4ab24022f5ab4c858f6ccc8c7e7c"}}}}
{"actor":{"display_login":"hokiegeek2"}}