{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-zeppelin/pulls/comments/41248023","id":41248023,"diff_hunk":"@@ -0,0 +1,150 @@\n+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one or more\n+ * contributor license agreements.  See the NOTICE file distributed with\n+ * this work for additional information regarding copyright ownership.\n+ * The ASF licenses this file to You under the Apache License, Version 2.0\n+ * (the \"License\"); you may not use this file except in compliance with\n+ * the License.  You may obtain a copy of the License at\n+ *\n+ *    http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package org.apache.zeppelin.pig;\n+\n+import java.io.ByteArrayOutputStream;\n+import java.io.IOException;\n+import java.util.List;\n+import java.util.Properties;\n+import java.util.Arrays;\n+import org.apache.commons.exec.CommandLine;\n+import org.apache.commons.exec.DefaultExecutor;\n+import org.apache.commons.exec.ExecuteException;\n+import org.apache.commons.exec.ExecuteWatchdog;\n+import org.apache.commons.exec.PumpStreamHandler;\n+import org.apache.zeppelin.interpreter.Interpreter;\n+import org.apache.zeppelin.interpreter.InterpreterContext;\n+import org.apache.zeppelin.interpreter.InterpreterResult;\n+import org.apache.zeppelin.interpreter.InterpreterResult.Code;\n+import org.apache.zeppelin.interpreter.InterpreterPropertyBuilder;\n+import org.apache.zeppelin.scheduler.Scheduler;\n+import org.apache.zeppelin.scheduler.SchedulerFactory;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+/**\n+ * Pig interpreter for Zeppelin.\n+ * Closely follows code for shell interpreter\n+ * @author abajwa-hw\n+ *\n+ */\n+public class PigInterpreter extends Interpreter {\n+  Logger logger = LoggerFactory.getLogger(PigInterpreter.class);\n+\n+  //Executable name used to start grunt shell \n+  static final String PIG_START_EXE = \"pig.executable\";\n+  static final String DEFAULT_START_EXE = \"pig\";\n+\n+  //Arguments to start pig with. More details available via 'pig -help'\n+  static final String PIG_START_ARGS = \"pig.start.args\";\n+  static final String DEFAULT_START_ARGS = \"-useHCatalog -exectype tez\";\n+\n+  //How long to wait before timing out (ms)\n+  static final String PIG_TIMEOUT_MS = \"pig.timeout.ms\";\n+  static final String DEFAULT_TIMEOUT_MS = \"600000\";\n+\n+  static {\n+    Interpreter.register(\n+      \"pig\",\n+      \"pig\",\n+      PigInterpreter.class.getName(),\n+      new InterpreterPropertyBuilder()\n+        .add(PIG_START_EXE, DEFAULT_START_EXE, \"Pig executable used to start grunt shell\")\n+        .add(PIG_START_ARGS, DEFAULT_START_ARGS, \"Starting arguments\")\n+        .add(PIG_TIMEOUT_MS, DEFAULT_TIMEOUT_MS, \"Timeout (ms)\")\n+        .build()\n+    );\n+  }\n+\n+  public PigInterpreter(Properties property) {\n+    super(property);\n+  }\n+\n+  @Override\n+  public void open() {}\n+\n+  @Override\n+  public void close() {}\n+\n+\n+  @Override\n+  public InterpreterResult interpret(String cmd, InterpreterContext contextInterpreter) {\n+    // use commandline to store string corresponding to pig shell command\n+    // start with pig exectable name (or full path if provided)...\n+    CommandLine cmdLine = CommandLine.parse(getProperty(PIG_START_EXE).trim());\n+\n+    // ...add any CLI arguments specified by user in interpreter settings\n+    String startArgs = getProperty(PIG_START_ARGS).trim();\n+    if (startArgs.length() > 0){\n+      logger.info(\"Start arguments passed to pig: \" + startArgs);\n+      List<String> argList = Arrays.asList(startArgs.split(\"\\\\s+\"));\n+      for (String arg : argList) {\n+        cmdLine.addArgument(arg, false);\n+      }\n+    }\n+    // ...finally add contents of pig cell after the -e flag \n+    logger.info(\"Run pig command '\" + cmd + \"'\");\n+    long start = System.currentTimeMillis();\n+    cmdLine.addArgument(\"-e\", false);\n+    cmdLine.addArgument(cmd, false);\n+\n+    // execute command and return success/failure based on its exit value\n+    DefaultExecutor executor = new DefaultExecutor();\n+    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();\n+    executor.setStreamHandler(new PumpStreamHandler(outputStream));\n+\n+    int commandTimeOut = Integer.parseInt(getProperty(PIG_TIMEOUT_MS));\n+    executor.setWatchdog(new ExecuteWatchdog(commandTimeOut));\n+    try {\n+      int exitValue = executor.execute(cmdLine);\n+      return new InterpreterResult(InterpreterResult.Code.SUCCESS, outputStream.toString());\n+    } catch (ExecuteException e) {\n+      logger.error(\"Can not run \" + cmd, e);\n+      return new InterpreterResult(Code.ERROR, e.getMessage());\n+    } catch (IOException e) {\n+      logger.error(\"Can not run \" + cmd, e);\n+      return new InterpreterResult(Code.ERROR, e.getMessage());\n+    }\n+  }\n+\n+  @Override\n+  public void cancel(InterpreterContext context) {}\n+\n+  @Override\n+  public FormType getFormType() {\n+    return FormType.SIMPLE;\n+  }\n+\n+  @Override\n+  public int getProgress(InterpreterContext context) {","path":"pig/src/main/java/org/apache/zeppelin/pig/PigInterpreter.java","position":134,"original_position":134,"commit_id":"656329d00a766570b25970506aa9e7a95edd8f8a","original_commit_id":"656329d00a766570b25970506aa9e7a95edd8f8a","user":{"login":"bzz","id":5582506,"avatar_url":"https://avatars.githubusercontent.com/u/5582506?v=3","gravatar_id":"","url":"https://api.github.com/users/bzz","html_url":"https://github.com/bzz","followers_url":"https://api.github.com/users/bzz/followers","following_url":"https://api.github.com/users/bzz/following{/other_user}","gists_url":"https://api.github.com/users/bzz/gists{/gist_id}","starred_url":"https://api.github.com/users/bzz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bzz/subscriptions","organizations_url":"https://api.github.com/users/bzz/orgs","repos_url":"https://api.github.com/users/bzz/repos","events_url":"https://api.github.com/users/bzz/events{/privacy}","received_events_url":"https://api.github.com/users/bzz/received_events","type":"User","site_admin":false},"body":"Do you plan to add task cancel\\progress indicator later on? Otherwise we better explicitly document the supported features, as users might expect this behaviour.","created_at":"2015-10-06T10:25:59Z","updated_at":"2015-10-06T10:25:59Z","html_url":"https://github.com/apache/incubator-zeppelin/pull/338#discussion_r41248023","pull_request_url":"https://api.github.com/repos/apache/incubator-zeppelin/pulls/338","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-zeppelin/pulls/comments/41248023"},"html":{"href":"https://github.com/apache/incubator-zeppelin/pull/338#discussion_r41248023"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-zeppelin/pulls/338"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-zeppelin/pulls/338","id":46867010,"html_url":"https://github.com/apache/incubator-zeppelin/pull/338","diff_url":"https://github.com/apache/incubator-zeppelin/pull/338.diff","patch_url":"https://github.com/apache/incubator-zeppelin/pull/338.patch","issue_url":"https://api.github.com/repos/apache/incubator-zeppelin/issues/338","number":338,"state":"open","locked":false,"title":"ZEPPELIN-335: Apache Pig interpreter","user":{"login":"abajwa-hw","id":8890151,"avatar_url":"https://avatars.githubusercontent.com/u/8890151?v=3","gravatar_id":"","url":"https://api.github.com/users/abajwa-hw","html_url":"https://github.com/abajwa-hw","followers_url":"https://api.github.com/users/abajwa-hw/followers","following_url":"https://api.github.com/users/abajwa-hw/following{/other_user}","gists_url":"https://api.github.com/users/abajwa-hw/gists{/gist_id}","starred_url":"https://api.github.com/users/abajwa-hw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abajwa-hw/subscriptions","organizations_url":"https://api.github.com/users/abajwa-hw/orgs","repos_url":"https://api.github.com/users/abajwa-hw/repos","events_url":"https://api.github.com/users/abajwa-hw/events{/privacy}","received_events_url":"https://api.github.com/users/abajwa-hw/received_events","type":"User","site_admin":false},"body":"Added an interpreter for Apache Pig. Based closely on Shell interpreter.\r\nAssumes that pig client is installed on the same node as Zeppelin (similar to how the Spark interpreter assumes that Spark is installed on Zeppelin node)","created_at":"2015-10-06T06:39:11Z","updated_at":"2015-10-06T10:25:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1cd0b5bd9da1d7e4adde95dae4783355b9c49d8a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-zeppelin/pulls/338/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-zeppelin/pulls/338/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-zeppelin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-zeppelin/issues/338/comments","statuses_url":"https://api.github.com/repos/apache/incubator-zeppelin/statuses/656329d00a766570b25970506aa9e7a95edd8f8a","head":{"label":"abajwa-hw:master","ref":"master","sha":"656329d00a766570b25970506aa9e7a95edd8f8a","user":{"login":"abajwa-hw","id":8890151,"avatar_url":"https://avatars.githubusercontent.com/u/8890151?v=3","gravatar_id":"","url":"https://api.github.com/users/abajwa-hw","html_url":"https://github.com/abajwa-hw","followers_url":"https://api.github.com/users/abajwa-hw/followers","following_url":"https://api.github.com/users/abajwa-hw/following{/other_user}","gists_url":"https://api.github.com/users/abajwa-hw/gists{/gist_id}","starred_url":"https://api.github.com/users/abajwa-hw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abajwa-hw/subscriptions","organizations_url":"https://api.github.com/users/abajwa-hw/orgs","repos_url":"https://api.github.com/users/abajwa-hw/repos","events_url":"https://api.github.com/users/abajwa-hw/events{/privacy}","received_events_url":"https://api.github.com/users/abajwa-hw/received_events","type":"User","site_admin":false},"repo":{"id":43731570,"name":"incubator-zeppelin","full_name":"abajwa-hw/incubator-zeppelin","owner":{"login":"abajwa-hw","id":8890151,"avatar_url":"https://avatars.githubusercontent.com/u/8890151?v=3","gravatar_id":"","url":"https://api.github.com/users/abajwa-hw","html_url":"https://github.com/abajwa-hw","followers_url":"https://api.github.com/users/abajwa-hw/followers","following_url":"https://api.github.com/users/abajwa-hw/following{/other_user}","gists_url":"https://api.github.com/users/abajwa-hw/gists{/gist_id}","starred_url":"https://api.github.com/users/abajwa-hw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abajwa-hw/subscriptions","organizations_url":"https://api.github.com/users/abajwa-hw/orgs","repos_url":"https://api.github.com/users/abajwa-hw/repos","events_url":"https://api.github.com/users/abajwa-hw/events{/privacy}","received_events_url":"https://api.github.com/users/abajwa-hw/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/abajwa-hw/incubator-zeppelin","description":"Mirror of Apache Zeppelin (Incubating)","fork":true,"url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin","forks_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/forks","keys_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/teams","hooks_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/hooks","issue_events_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/issues/events{/number}","events_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/events","assignees_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/assignees{/user}","branches_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/branches{/branch}","tags_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/tags","blobs_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/git/refs{/sha}","trees_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/statuses/{sha}","languages_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/languages","stargazers_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/stargazers","contributors_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/contributors","subscribers_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/subscribers","subscription_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/subscription","commits_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/commits{/sha}","git_commits_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/git/commits{/sha}","comments_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/comments{/number}","issue_comment_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/issues/comments{/number}","contents_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/contents/{+path}","compare_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/merges","archive_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/downloads","issues_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/issues{/number}","pulls_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/pulls{/number}","milestones_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/milestones{/number}","notifications_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/labels{/name}","releases_url":"https://api.github.com/repos/abajwa-hw/incubator-zeppelin/releases{/id}","created_at":"2015-10-06T05:25:20Z","updated_at":"2015-10-06T05:25:24Z","pushed_at":"2015-10-06T06:25:54Z","git_url":"git://github.com/abajwa-hw/incubator-zeppelin.git","ssh_url":"git@github.com:abajwa-hw/incubator-zeppelin.git","clone_url":"https://github.com/abajwa-hw/incubator-zeppelin.git","svn_url":"https://github.com/abajwa-hw/incubator-zeppelin","homepage":null,"size":73096,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"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":"81e823eb141cb0766c604f18c3bbfdb0bb8746d3","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":32848140,"name":"incubator-zeppelin","full_name":"apache/incubator-zeppelin","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-zeppelin","description":"Mirror of Apache Zeppelin (Incubating)","fork":false,"url":"https://api.github.com/repos/apache/incubator-zeppelin","forks_url":"https://api.github.com/repos/apache/incubator-zeppelin/forks","keys_url":"https://api.github.com/repos/apache/incubator-zeppelin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-zeppelin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-zeppelin/teams","hooks_url":"https://api.github.com/repos/apache/incubator-zeppelin/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-zeppelin/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-zeppelin/events","assignees_url":"https://api.github.com/repos/apache/incubator-zeppelin/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-zeppelin/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-zeppelin/tags","blobs_url":"https://api.github.com/repos/apache/incubator-zeppelin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-zeppelin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-zeppelin/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-zeppelin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-zeppelin/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-zeppelin/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-zeppelin/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-zeppelin/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-zeppelin/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-zeppelin/subscription","commits_url":"https://api.github.com/repos/apache/incubator-zeppelin/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-zeppelin/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-zeppelin/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-zeppelin/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-zeppelin/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-zeppelin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-zeppelin/merges","archive_url":"https://api.github.com/repos/apache/incubator-zeppelin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-zeppelin/downloads","issues_url":"https://api.github.com/repos/apache/incubator-zeppelin/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-zeppelin/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-zeppelin/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-zeppelin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-zeppelin/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-zeppelin/releases{/id}","created_at":"2015-03-25T07:00:06Z","updated_at":"2015-10-05T14:38:44Z","pushed_at":"2015-10-06T06:50:44Z","git_url":"git://github.com/apache/incubator-zeppelin.git","ssh_url":"git@github.com:apache/incubator-zeppelin.git","clone_url":"https://github.com/apache/incubator-zeppelin.git","svn_url":"https://github.com/apache/incubator-zeppelin","homepage":null,"size":73096,"stargazers_count":711,"watchers_count":711,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":324,"mirror_url":"git://git.apache.org/incubator-zeppelin.git","open_issues_count":67,"forks":324,"open_issues":67,"watchers":711,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-zeppelin/pulls/338"},"html":{"href":"https://github.com/apache/incubator-zeppelin/pull/338"},"issue":{"href":"https://api.github.com/repos/apache/incubator-zeppelin/issues/338"},"comments":{"href":"https://api.github.com/repos/apache/incubator-zeppelin/issues/338/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-zeppelin/pulls/338/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-zeppelin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-zeppelin/pulls/338/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-zeppelin/statuses/656329d00a766570b25970506aa9e7a95edd8f8a"}}}}