Return-Path: X-Original-To: apmail-zeppelin-commits-archive@minotaur.apache.org Delivered-To: apmail-zeppelin-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 16A7A17BA8 for ; Thu, 30 Apr 2015 10:56:06 +0000 (UTC) Received: (qmail 23688 invoked by uid 500); 30 Apr 2015 10:56:06 -0000 Delivered-To: apmail-zeppelin-commits-archive@zeppelin.apache.org Received: (qmail 23654 invoked by uid 500); 30 Apr 2015 10:56:06 -0000 Mailing-List: contact commits-help@zeppelin.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zeppelin.incubator.apache.org Delivered-To: mailing list commits@zeppelin.incubator.apache.org Received: (qmail 23644 invoked by uid 99); 30 Apr 2015 10:56:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Apr 2015 10:56:05 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [54.164.171.186] (HELO mx1-us-east.apache.org) (54.164.171.186) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Apr 2015 10:56:01 +0000 Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id 5E64342AD3 for ; Thu, 30 Apr 2015 10:55:40 +0000 (UTC) Received: (qmail 19999 invoked by uid 99); 30 Apr 2015 10:54:24 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Apr 2015 10:54:24 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B91E4E0061; Thu, 30 Apr 2015 10:54:24 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: moon@apache.org To: commits@zeppelin.incubator.apache.org Message-Id: <19cda74ac74249838ff10217aff11242@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-zeppelin git commit: Fix process creation behavior Date: Thu, 30 Apr 2015 10:54:24 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org Repository: incubator-zeppelin Updated Branches: refs/heads/master a0428f06d -> b33bf5000 Fix process creation behavior #52 introduces new side effect around creation of interpreter process. As a result, some functions, such as 'z.run(2)' wouldn't able to run. This includes fix and unit test. Author: Lee moon soo Closes #57 from Leemoonsoo/fix_process_creation and squashes the following commits: 018af91 [Lee moon soo] make code clean 0379410 [Lee moon soo] Fix process creation behavior Project: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/commit/b33bf500 Tree: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/tree/b33bf500 Diff: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/diff/b33bf500 Branch: refs/heads/master Commit: b33bf5000f667c6e258477b66b6fc0b3615516dd Parents: a0428f0 Author: Lee moon soo Authored: Thu Apr 30 10:15:08 2015 +0900 Committer: Lee moon soo Committed: Thu Apr 30 19:54:15 2015 +0900 ---------------------------------------------------------------------- .../interpreter/remote/RemoteInterpreter.java | 23 ++++++++++---------- .../remote/RemoteInterpreterTest.java | 21 ++++++++++++++++++ 2 files changed, 33 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/b33bf500/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java index fbadce9..4f1e262 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java @@ -324,18 +324,19 @@ public class RemoteInterpreter extends Interpreter { super.setInterpreterGroup(interpreterGroup); synchronized (interpreterGroupReference) { - if (interpreterGroupReference - .containsKey(getInterpreterGroupKey(interpreterGroup))) { - interpreterGroupReference.remove(getInterpreterGroupKey(interpreterGroup)); + RemoteInterpreterProcess intpProcess = interpreterGroupReference + .get(getInterpreterGroupKey(interpreterGroup)); + + // when interpreter process is not created or terminated + if (intpProcess == null || (!intpProcess.isRunning() && intpProcess.getPort() > 0)) { + interpreterGroupReference.put(getInterpreterGroupKey(interpreterGroup), + new RemoteInterpreterProcess(interpreterRunner, + interpreterPath, env, interpreterContextRunnerPool)); + + logger.info("setInterpreterGroup = " + + getInterpreterGroupKey(interpreterGroup) + " class=" + className + + ", path=" + interpreterPath); } - - interpreterGroupReference.put(getInterpreterGroupKey(interpreterGroup), - new RemoteInterpreterProcess(interpreterRunner, - interpreterPath, env, interpreterContextRunnerPool)); - - logger.info("setInterpreterGroup = " - + getInterpreterGroupKey(interpreterGroup) + " class=" + className - + ", path=" + interpreterPath); } } http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/b33bf500/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java index e743eab..0661bfa 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java @@ -457,4 +457,25 @@ public class RemoteInterpreterTest { intpA.close(); } + + @Test + public void testProcessCreation() { + Properties p = new Properties(); + + RemoteInterpreter intpA = new RemoteInterpreter( + p, + MockInterpreterA.class.getName(), + new File("../bin/interpreter.sh").getAbsolutePath(), + "fake", + env + ); + + intpA.setInterpreterGroup(intpGroup); + RemoteInterpreterProcess processA = intpA.getInterpreterProcess(); + + intpA.setInterpreterGroup(new InterpreterGroup(intpA.getInterpreterGroup().getId())); + RemoteInterpreterProcess processB = intpA.getInterpreterProcess(); + + assertEquals(processA.hashCode(), processB.hashCode()); + } }