diff --git a/bin/common.sh b/bin/common.sh index 24b1f2e8..607f358a 100644 --- a/bin/common.sh +++ b/bin/common.sh @@ -79,6 +79,7 @@ function addJarInDir(){ addJarInDir "${ZEPPELIN_HOME}" addJarInDir "${ZEPPELIN_HOME}/lib" +addJarInDir "${ZEPPELIN_HOME}/zeppelin-interpreter/target/lib" addJarInDir "${ZEPPELIN_HOME}/zeppelin-zengine/target/lib" addJarInDir "${ZEPPELIN_HOME}/zeppelin-server/target/lib" addJarInDir "${ZEPPELIN_HOME}/zeppelin-web/target/lib" @@ -118,9 +119,22 @@ if [[ -z "$ZEPPELIN_MEM" ]]; then export ZEPPELIN_MEM="-Xmx1024m -XX:MaxPermSize=512m" fi -JAVA_OPTS+="${ZEPPELIN_JAVA_OPTS} -Dfile.encoding=${ZEPPELIN_ENCODING} ${ZEPPELIN_MEM}" +JAVA_OPTS+=" ${ZEPPELIN_JAVA_OPTS} -Dfile.encoding=${ZEPPELIN_ENCODING} ${ZEPPELIN_MEM}" export JAVA_OPTS +# jvm options for interpreter process +if [[ -z "${ZEPPELIN_INTP_JAVA_OPTS}" ]]; then + export ZEPPELIN_INTP_JAVA_OPTS="${ZEPPELIN_JAVA_OPTS}" +fi + +if [[ -z "${ZEPPELIN_INTP_MEM}" ]]; then + export ZEPPELIN_INTP_MEM="${ZEPPELIN_MEM}" +fi + +JAVA_INTP_OPTS+=" ${ZEPPELIN_INTP_JAVA_OPTS} -Dfile.encoding=${ZEPPELIN_ENCODING} ${ZEPPELIN_INTP_MEM}" +export JAVA_INTP_OPTS + + if [[ -n "${JAVA_HOME}" ]]; then ZEPPELIN_RUNNER="${JAVA_HOME}/bin/java" else diff --git a/bin/interpreter.sh b/bin/interpreter.sh new file mode 100755 index 00000000..4aa3ca08 --- /dev/null +++ b/bin/interpreter.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +bin=$(dirname "${BASH_SOURCE-$0}") +bin=$(cd "${bin}">/dev/null; pwd) + + +function usage() { + echo "usage) $0 -p -d " +} + +while getopts "hp:d:" o; do + case ${o} in + h) + usage + exit 0 + ;; + d) + INTERPRETER_DIR=${OPTARG} + ;; + p) + PORT=${OPTARG} + ;; + esac +done + + +if [ -z "${PORT}" ] || [ -z "${INTERPRETER_DIR}" ]; then + usage + exit 1 +fi + +. "${bin}/common.sh" + +ZEPPELIN_CLASSPATH+=":${ZEPPELIN_CONF_DIR}" + +addJarInDir "${ZEPPELIN_HOME}/zeppelin-interpreter/target/lib" +addJarInDir "${INTERPRETER_DIR}" + +export CLASSPATH+=":${ZEPPELIN_CLASSPATH}" + +HOSTNAME=$(hostname) +ZEPPELIN_SERVER=com.nflabs.zeppelin.interpreter.remote.RemoteInterpreterServer + +INTERPRETER_ID=$(basename "${INTERPRETER_DIR}") +ZEPPELIN_PID="${ZEPPELIN_PID_DIR}/zeppelin-interpreter-${INTERPRETER_ID}-${ZEPPELIN_IDENT_STRING}-${HOSTNAME}.pid" +ZEPPELIN_LOGFILE="${ZEPPELIN_LOG_DIR}/zeppelin-interpreter-${INTERPRETER_ID}-${ZEPPELIN_IDENT_STRING}-${HOSTNAME}.log" +JAVA_INTP_OPTS+=" -Dzeppelin.log.file=${ZEPPELIN_LOGFILE}" + +if [[ ! -d "${ZEPPELIN_LOG_DIR}" ]]; then + echo "Log dir doesn't exist, create ${ZEPPELIN_LOG_DIR}" + $(mkdir -p "${ZEPPELIN_LOG_DIR}") +fi + + + +${ZEPPELIN_RUNNER} ${JAVA_INTP_OPTS} -cp ${CLASSPATH} ${ZEPPELIN_SERVER} ${PORT} & +pid=$! +if [[ -z "${pid}" ]]; then + return 1; +else + echo ${pid} > ${ZEPPELIN_PID} +fi + + +trap 'shutdown_hook;' SIGTERM SIGINT SIGQUIT +function shutdown_hook() { + local count + count=0 + while [[ "${count}" -lt 10 ]]; do + $(kill ${pid} > /dev/null 2> /dev/null) + if kill -0 ${pid} > /dev/null 2>&1; then + sleep 3 + let "count+=1" + else + rm -f "${ZEPPELIN_PID}" + break + fi + if [[ "${count}" == "5" ]]; then + $(kill -9 ${pid} > /dev/null 2> /dev/null) + rm -f "${ZEPPELIN_PID}" + fi + done +} + +wait diff --git a/bin/zeppelin-daemon.sh b/bin/zeppelin-daemon.sh index 91067861..6dd1ca7b 100755 --- a/bin/zeppelin-daemon.sh +++ b/bin/zeppelin-daemon.sh @@ -137,18 +137,32 @@ function start() { function stop() { local pid + + # zeppelin daemon kill if [[ ! -f "${ZEPPELIN_PID}" ]]; then echo "${ZEPPELIN_NAME} is not running" - return 0 - fi - pid=$(cat ${ZEPPELIN_PID}) - if [[ -z "${pid}" ]]; then - echo "${ZEPPELIN_NAME} is not running" else - wait_for_zeppelin_to_die $pid - $(rm -f ${ZEPPELIN_PID}) - action_msg "${ZEPPELIN_NAME} stop" "${SET_OK}" + pid=$(cat ${ZEPPELIN_PID}) + if [[ -z "${pid}" ]]; then + echo "${ZEPPELIN_NAME} is not running" + else + wait_for_zeppelin_to_die $pid + $(rm -f ${ZEPPELIN_PID}) + action_msg "${ZEPPELIN_NAME} stop" "${SET_OK}" + fi fi + + # list all pid that used in remote interpreter and kill them + for f in ${ZEPPELIN_PID_DIR}/*.pid; do + if [[ ! -f ${f} ]]; then + continue; + fi + + pid=$(cat ${f}) + wait_for_zeppelin_to_die $pid + $(rm -f ${f}) + done + } function find_zeppelin_process() { diff --git a/conf/zeppelin-env.sh.template b/conf/zeppelin-env.sh.template index 704ffe53..576fc061 100644 --- a/conf/zeppelin-env.sh.template +++ b/conf/zeppelin-env.sh.template @@ -4,6 +4,8 @@ # export MASTER= # Spark master url. eg. spark://master_addr:7077. Leave empty if you want to use local mode # export ZEPPELIN_JAVA_OPTS # Additional jvm options. for example, export ZEPPELIN_JAVA_OPTS="-Dspark.executor.memory=8g -Dspark.cores.max=16" # export ZEPPELIN_MEM # Zeppelin jvm mem options Default -Xmx1024m -XX:MaxPermSize=512m +# export ZEPPELIN_INTP_MEM # zeppelin interpreter process jvm mem options. Defualt = ZEPPELIN_MEM +# export ZEPPELIN_INTP_JAVA_OPTS # zeppelin interpreter process jvm options. Default = ZEPPELIN_JAVA_OPTS # export ZEPPELIN_CONF_DIR # Alternate zeppelin conf dir. Default is ${ZEPPELIN_HOME}/conf. # export ZEPPELIN_LOG_DIR # Where log files are stored. PWD by default. diff --git a/markdown/pom.xml b/markdown/pom.xml index d60dfd2b..3b6cdeff 100644 --- a/markdown/pom.xml +++ b/markdown/pom.xml @@ -18,7 +18,7 @@ ${project.groupId} - zeppelin-zengine + zeppelin-interpreter ${project.version} provided diff --git a/markdown/src/main/java/com/nflabs/zeppelin/markdown/Markdown.java b/markdown/src/main/java/com/nflabs/zeppelin/markdown/Markdown.java index 67b8365b..1cbf7ed6 100644 --- a/markdown/src/main/java/com/nflabs/zeppelin/markdown/Markdown.java +++ b/markdown/src/main/java/com/nflabs/zeppelin/markdown/Markdown.java @@ -39,11 +39,6 @@ public void open() { @Override public void close() {} - @Override - public Object getValue(String name) { - return null; - } - @Override public InterpreterResult interpret(String st, InterpreterContext interpreterContext) { String html; @@ -58,9 +53,6 @@ public InterpreterResult interpret(String st, InterpreterContext interpreterCont @Override public void cancel(InterpreterContext context) {} - @Override - public void bindValue(String name, Object o) {} - @Override public FormType getFormType() { return FormType.SIMPLE; diff --git a/pom.xml b/pom.xml index 62196820..4a60516c 100644 --- a/pom.xml +++ b/pom.xml @@ -67,6 +67,7 @@ 2013 + zeppelin-interpreter zeppelin-zengine spark markdown @@ -878,6 +879,7 @@ true + com/nflabs/zeppelin/interpreter/thrift/* diff --git a/shell/pom.xml b/shell/pom.xml index 9b1f83bd..d2ea7540 100644 --- a/shell/pom.xml +++ b/shell/pom.xml @@ -18,7 +18,7 @@ ${project.groupId} - zeppelin-zengine + zeppelin-interpreter ${project.version} provided diff --git a/shell/src/main/java/com/nflabs/zeppelin/shell/ShellInterpreter.java b/shell/src/main/java/com/nflabs/zeppelin/shell/ShellInterpreter.java index 36ea880c..d1762f66 100644 --- a/shell/src/main/java/com/nflabs/zeppelin/shell/ShellInterpreter.java +++ b/shell/src/main/java/com/nflabs/zeppelin/shell/ShellInterpreter.java @@ -45,10 +45,6 @@ public void open() {} @Override public void close() {} - @Override - public Object getValue(String name) { - return null; - } @Override public InterpreterResult interpret(String cmd, InterpreterContext contextInterpreter) { @@ -77,9 +73,6 @@ public InterpreterResult interpret(String cmd, InterpreterContext contextInterpr @Override public void cancel(InterpreterContext context) {} - @Override - public void bindValue(String name, Object o) {} - @Override public FormType getFormType() { return FormType.SIMPLE; diff --git a/spark/pom.xml b/spark/pom.xml index 3e2a0bda..b35bf720 100644 --- a/spark/pom.xml +++ b/spark/pom.xml @@ -30,10 +30,11 @@ ${project.groupId} - zeppelin-zengine + zeppelin-interpreter ${project.version} + provided - + com.google.code.gson gson diff --git a/spark/src/main/java/com/nflabs/zeppelin/spark/DepInterpreter.java b/spark/src/main/java/com/nflabs/zeppelin/spark/DepInterpreter.java index d7414413..de097728 100644 --- a/spark/src/main/java/com/nflabs/zeppelin/spark/DepInterpreter.java +++ b/spark/src/main/java/com/nflabs/zeppelin/spark/DepInterpreter.java @@ -51,6 +51,7 @@ public class DepInterpreter extends Interpreter { "spark", DepInterpreter.class.getName(), new InterpreterPropertyBuilder() + .add("zeppelin.dep.localrepo", "local-repo", "local repository for dependency loader") .build()); } @@ -129,7 +130,7 @@ private void createIMain() { intp.setContextClassLoader(); intp.initializeSynchronous(); - depc = new DependencyContext(); + depc = new DependencyContext(getProperty("zeppelin.dep.localrepo")); completor = new SparkJLineCompletion(intp); intp.interpret("@transient var _binder = new java.util.HashMap[String, Object]()"); @@ -141,7 +142,6 @@ private void createIMain() { } - @Override public Object getValue(String name) { Object ret = intp.valueOfTerm(name); if (ret instanceof None) { @@ -160,11 +160,8 @@ public InterpreterResult interpret(String st, InterpreterContext context) { out.reset(); SparkInterpreter sparkInterpreter = getSparkInterpreter(); - if (sparkInterpreter == null) { - return new InterpreterResult(Code.ERROR, - "Must be used with SparkInterpreter"); - } - if (sparkInterpreter.isSparkContextInitialized()) { + + if (sparkInterpreter != null && sparkInterpreter.isSparkContextInitialized()) { return new InterpreterResult(Code.ERROR, "Must be used before SparkInterpreter (%spark) initialized"); } @@ -202,13 +199,10 @@ private Code getResultCode(scala.tools.nsc.interpreter.Results.Result r) { public void cancel(InterpreterContext context) { } - @Override - public void bindValue(String name, Object o) { - } @Override public FormType getFormType() { - return null; + return FormType.NATIVE; } @Override @@ -257,13 +251,15 @@ private SparkInterpreter getSparkInterpreter() { if (intpGroup == null) { return null; } - for (Interpreter intp : intpGroup){ - if (intp.getClassName().equals(SparkInterpreter.class.getName())) { - Interpreter p = intp; - while (p instanceof WrappedInterpreter) { - p = ((WrappedInterpreter) p).getInnerInterpreter(); + synchronized (intpGroup) { + for (Interpreter intp : intpGroup){ + if (intp.getClassName().equals(SparkInterpreter.class.getName())) { + Interpreter p = intp; + while (p instanceof WrappedInterpreter) { + p = ((WrappedInterpreter) p).getInnerInterpreter(); + } + return (SparkInterpreter) p; } - return (SparkInterpreter) p; } } return null; diff --git a/spark/src/main/java/com/nflabs/zeppelin/spark/SparkInterpreter.java b/spark/src/main/java/com/nflabs/zeppelin/spark/SparkInterpreter.java index 68dad25c..4ba5cd26 100644 --- a/spark/src/main/java/com/nflabs/zeppelin/spark/SparkInterpreter.java +++ b/spark/src/main/java/com/nflabs/zeppelin/spark/SparkInterpreter.java @@ -54,7 +54,6 @@ import com.nflabs.zeppelin.interpreter.InterpreterResult; import com.nflabs.zeppelin.interpreter.InterpreterResult.Code; import com.nflabs.zeppelin.interpreter.WrappedInterpreter; -import com.nflabs.zeppelin.notebook.form.Setting; import com.nflabs.zeppelin.scheduler.Scheduler; import com.nflabs.zeppelin.scheduler.SchedulerFactory; import com.nflabs.zeppelin.spark.dep.DependencyContext; @@ -155,7 +154,7 @@ public HiveContext getHiveContext() { public DependencyResolver getDependencyResolver() { if (dep == null) { - dep = new DependencyResolver(intp, sc); + dep = new DependencyResolver(intp, sc, getProperty("zeppelin.dep.localrepo")); } return dep; } @@ -163,13 +162,15 @@ public DependencyResolver getDependencyResolver() { private DepInterpreter getDepInterpreter() { InterpreterGroup intpGroup = getInterpreterGroup(); if (intpGroup == null) return null; - for (Interpreter intp : intpGroup) { - if (intp.getClassName().equals(DepInterpreter.class.getName())) { - Interpreter p = intp; - while (p instanceof WrappedInterpreter) { - p = ((WrappedInterpreter) p).getInnerInterpreter(); + synchronized (intpGroup) { + for (Interpreter intp : intpGroup) { + if (intp.getClassName().equals(DepInterpreter.class.getName())) { + Interpreter p = intp; + while (p instanceof WrappedInterpreter) { + p = ((WrappedInterpreter) p).getInnerInterpreter(); + } + return (DepInterpreter) p; } - return (DepInterpreter) p; } } return null; @@ -420,16 +421,10 @@ public List completion(String buf, int cursor) { return scala.collection.JavaConversions.asJavaList(ret.candidates()); } - @Override public void bindValue(String name, Object o) { - if ("form".equals(name) && o instanceof Setting) { // form controller injection from - // Paragraph.jobRun - z.setFormSetting((Setting) o); - } getResultCode(intp.bindValue(name, o)); } - @Override public Object getValue(String name) { Object ret = intp.valueOfTerm(name); if (ret instanceof None) { @@ -442,7 +437,7 @@ public Object getValue(String name) { } private String getJobGroup(InterpreterContext context){ - return "zeppelin-" + this.hashCode() + "-" + context.getParagraph().getId(); + return "zeppelin-" + this.hashCode() + "-" + context.getParagraphId(); } /** @@ -459,6 +454,7 @@ public InterpreterResult interpret(String line, InterpreterContext context) { public InterpreterResult interpret(String[] lines, InterpreterContext context) { synchronized (this) { + z.setGui(context.getGui()); sc.setJobGroup(getJobGroup(context), "Zeppelin", false); InterpreterResult r = interpretInput(lines); sc.clearJobGroup(); @@ -659,6 +655,6 @@ public JobProgressListener getJobProgressListener() { @Override public Scheduler getScheduler() { return SchedulerFactory.singleton().createOrGetFIFOScheduler( - SparkInterpreter.class.getName() + this.hashCode()); + SparkInterpreter.class.getName() + this.hashCode()); } } diff --git a/spark/src/main/java/com/nflabs/zeppelin/spark/SparkSqlInterpreter.java b/spark/src/main/java/com/nflabs/zeppelin/spark/SparkSqlInterpreter.java index aff3de47..3cdce038 100644 --- a/spark/src/main/java/com/nflabs/zeppelin/spark/SparkSqlInterpreter.java +++ b/spark/src/main/java/com/nflabs/zeppelin/spark/SparkSqlInterpreter.java @@ -26,14 +26,14 @@ import scala.collection.mutable.HashMap; import scala.collection.mutable.HashSet; -import com.nflabs.zeppelin.conf.ZeppelinConfiguration; import com.nflabs.zeppelin.interpreter.Interpreter; import com.nflabs.zeppelin.interpreter.InterpreterContext; +import com.nflabs.zeppelin.interpreter.InterpreterException; import com.nflabs.zeppelin.interpreter.InterpreterPropertyBuilder; import com.nflabs.zeppelin.interpreter.InterpreterResult; import com.nflabs.zeppelin.interpreter.InterpreterResult.Code; -import com.nflabs.zeppelin.interpreter.WrappedInterpreter; import com.nflabs.zeppelin.interpreter.LazyOpenInterpreter; +import com.nflabs.zeppelin.interpreter.WrappedInterpreter; import com.nflabs.zeppelin.scheduler.Scheduler; import com.nflabs.zeppelin.scheduler.SchedulerFactory; @@ -62,7 +62,7 @@ public class SparkSqlInterpreter extends Interpreter { } private String getJobGroup(InterpreterContext context){ - return "zeppelin-" + this.hashCode() + "-" + context.getParagraph().getId(); + return "zeppelin-" + this.hashCode() + "-" + context.getParagraphId(); } private int maxResult; @@ -73,10 +73,7 @@ public SparkSqlInterpreter(Properties property) { @Override public void open() { - ZeppelinConfiguration conf = ZeppelinConfiguration.create(); - this.maxResult = conf.getInt("ZEPPELIN_SPARK_MAX_RESULT", - "zeppelin.spark.maxResult", - Integer.parseInt(getProperty("zeppelin.spark.maxResult"))); + this.maxResult = Integer.parseInt(getProperty("zeppelin.spark.maxResult")); } private SparkInterpreter getSparkInterpreter() { @@ -98,7 +95,7 @@ private SparkInterpreter getSparkInterpreter() { private boolean useHiveContext() { return Boolean.parseBoolean(getProperty("zeppelin.spark.useHiveContext")); } - + public boolean concurrentSQL() { return Boolean.parseBoolean(getProperty("zeppelin.spark.concurrentSQL")); } @@ -106,10 +103,6 @@ public boolean concurrentSQL() { @Override public void close() {} - @Override - public Object getValue(String name) { - return null; - } @Override public InterpreterResult interpret(String st, InterpreterContext context) { @@ -190,11 +183,6 @@ public void cancel(InterpreterContext context) { sc.cancelJobGroup(getJobGroup(context)); } - @Override - public void bindValue(String name, Object o) { - - } - @Override public FormType getFormType() { return FormType.SIMPLE; @@ -317,8 +305,23 @@ public Scheduler getScheduler() { int maxConcurrency = 10; return SchedulerFactory.singleton().createOrGetParallelScheduler( SparkSqlInterpreter.class.getName() + this.hashCode(), maxConcurrency); + } else { + // getSparkInterpreter() calls open() inside. + // That means if SparkInterpreter is not opened, it'll wait until SparkInterpreter open. + // In this moment UI displays 'READY' or 'FINISHED' instead of 'PENDING' or 'RUNNING'. + // It's because of scheduler is not created yet, and scheduler is created by this function. + // Therefore, we can still use getSparkInterpreter() here, but it's better and safe + // to getSparkInterpreter without opening it. + for (Interpreter intp : getInterpreterGroup()) { + if (intp.getClassName().equals(SparkInterpreter.class.getName())) { + Interpreter p = intp; + return p.getScheduler(); + } else { + continue; + } + } + throw new InterpreterException("Can't find SparkInterpreter"); } - return getSparkInterpreter().getScheduler(); } @Override diff --git a/spark/src/main/java/com/nflabs/zeppelin/spark/ZeppelinContext.java b/spark/src/main/java/com/nflabs/zeppelin/spark/ZeppelinContext.java index df7a0d96..e475de61 100644 --- a/spark/src/main/java/com/nflabs/zeppelin/spark/ZeppelinContext.java +++ b/spark/src/main/java/com/nflabs/zeppelin/spark/ZeppelinContext.java @@ -16,12 +16,9 @@ import scala.Tuple2; import scala.collection.Iterable; -import com.nflabs.zeppelin.interpreter.Interpreter; +import com.nflabs.zeppelin.display.GUI; +import com.nflabs.zeppelin.display.Input.ParamOption; import com.nflabs.zeppelin.interpreter.InterpreterContext; -import com.nflabs.zeppelin.interpreter.InterpreterResult; -import com.nflabs.zeppelin.notebook.Paragraph; -import com.nflabs.zeppelin.notebook.form.Input.ParamOption; -import com.nflabs.zeppelin.notebook.form.Setting; import com.nflabs.zeppelin.spark.dep.DependencyResolver; /** @@ -50,7 +47,7 @@ public ZeppelinContext(SparkContext sc, SQLContext sql, public SparkContext sc; public SQLContext sqlContext; public HiveContext hiveContext; - private Setting form; + private GUI gui; public SchemaRDD sql(String sql) { return sqlContext.sql(sql); @@ -182,7 +179,7 @@ public Object input(String name) { } public Object input(String name, Object defaultValue) { - return form.input(name, defaultValue); + return gui.input(name, defaultValue); } public Object select(String name, scala.collection.Iterable> options) { @@ -201,14 +198,15 @@ public Object select(String name, Object defaultValue, paramOptions[i++] = new ParamOption(valueAndDisplayValue._1(), valueAndDisplayValue._2()); } - return form.select(name, "", paramOptions); + return gui.select(name, "", paramOptions); } - public void setFormSetting(Setting o) { - this.form = o; + public void setGui(GUI o) { + this.gui = o; } public void run(String lines) { + /* String intpName = Paragraph.getRequiredReplName(lines); String scriptBody = Paragraph.getScriptBody(lines); Interpreter intp = interpreterContext.getParagraph().getRepl(intpName); @@ -222,6 +220,8 @@ public void run(String lines) { } else { out.println("Unknown error"); } + */ + throw new RuntimeException("Missing implementation"); } private void restartInterpreter() { diff --git a/spark/src/main/java/com/nflabs/zeppelin/spark/dep/Booter.java b/spark/src/main/java/com/nflabs/zeppelin/spark/dep/Booter.java index 6b812f09..10c5bc25 100644 --- a/spark/src/main/java/com/nflabs/zeppelin/spark/dep/Booter.java +++ b/spark/src/main/java/com/nflabs/zeppelin/spark/dep/Booter.java @@ -1,16 +1,16 @@ package com.nflabs.zeppelin.spark.dep; +import java.io.File; + import org.apache.maven.repository.internal.MavenRepositorySystemSession; import org.sonatype.aether.RepositorySystem; import org.sonatype.aether.RepositorySystemSession; import org.sonatype.aether.repository.LocalRepository; import org.sonatype.aether.repository.RemoteRepository; -import com.nflabs.zeppelin.conf.ZeppelinConfiguration; - /** * Manage mvn repository. - * + * * @author anthonycorbacho * */ @@ -19,13 +19,23 @@ public static RepositorySystem newRepositorySystem() { return RepositorySystemFactory.newRepositorySystem(); } - public static RepositorySystemSession newRepositorySystemSession(RepositorySystem system) { + public static RepositorySystemSession newRepositorySystemSession( + RepositorySystem system, String localRepoPath) { MavenRepositorySystemSession session = new MavenRepositorySystemSession(); - ZeppelinConfiguration conf = ZeppelinConfiguration.create(); + // find homedir + String home = System.getenv("ZEPPELIN_HOME"); + if (home == null) { + home = System.getProperty("zeppelin.home"); + } + if (home == null) { + home = ".."; + } + + String path = home + "/" + localRepoPath; + LocalRepository localRepo = - new LocalRepository(conf.getRelativeDir(conf.getString("ZEPPELIN_DEP_LOCAL_REPO", - "zeppelin.dep.localrepo", "local-repo"))); + new LocalRepository(new File(path).getAbsolutePath()); session.setLocalRepositoryManager(system.newLocalRepositoryManager(localRepo)); // session.setTransferListener(new ConsoleTransferListener()); diff --git a/spark/src/main/java/com/nflabs/zeppelin/spark/dep/DependencyContext.java b/spark/src/main/java/com/nflabs/zeppelin/spark/dep/DependencyContext.java index e6dedf04..58268eb1 100644 --- a/spark/src/main/java/com/nflabs/zeppelin/spark/dep/DependencyContext.java +++ b/spark/src/main/java/com/nflabs/zeppelin/spark/dep/DependencyContext.java @@ -31,12 +31,16 @@ public class DependencyContext { List files = new LinkedList(); List filesDist = new LinkedList(); private RepositorySystem system = Booter.newRepositorySystem(); - private RepositorySystemSession session = Booter.newRepositorySystemSession(system); + private RepositorySystemSession session; private RemoteRepository mavenCentral = new RemoteRepository("central", "default", "http://repo1.maven.org/maven2/"); private RemoteRepository mavenLocal = new RemoteRepository("local", "default", "file://" + System.getProperty("user.home") + "/.m2/repository"); + public DependencyContext(String localRepoPath) { + session = Booter.newRepositorySystemSession(system, localRepoPath); + } + public Dependency load(String lib) { Dependency dep = new Dependency(lib); diff --git a/spark/src/main/java/com/nflabs/zeppelin/spark/dep/DependencyResolver.java b/spark/src/main/java/com/nflabs/zeppelin/spark/dep/DependencyResolver.java index aacb4d66..4800e1a1 100644 --- a/spark/src/main/java/com/nflabs/zeppelin/spark/dep/DependencyResolver.java +++ b/spark/src/main/java/com/nflabs/zeppelin/spark/dep/DependencyResolver.java @@ -51,7 +51,7 @@ public class DependencyResolver { private SparkContext sc; private RepositorySystem system = Booter.newRepositorySystem(); private List repos = new LinkedList(); - private RepositorySystemSession session = Booter.newRepositorySystemSession(system); + private RepositorySystemSession session; private DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter( JavaScopes.COMPILE, JavaScopes.PROVIDED, @@ -66,10 +66,11 @@ public class DependencyResolver { "com.nflabs.zeppelin:zeppelin-spark", "com.nflabs.zeppelin:zeppelin-server"}; - public DependencyResolver(SparkIMain intp, SparkContext sc) { + public DependencyResolver(SparkIMain intp, SparkContext sc, String localRepoPath) { this.intp = intp; this.global = intp.global(); this.sc = sc; + session = Booter.newRepositorySystemSession(system, localRepoPath); repos.add(Booter.newCentralRepository()); // add maven central repos.add(new RemoteRepository("local", "default", "file://" + System.getProperty("user.home") + "/.m2/repository")); diff --git a/spark/src/test/java/com/nflabs/zeppelin/spark/DepInterpreterTest.java b/spark/src/test/java/com/nflabs/zeppelin/spark/DepInterpreterTest.java index aecb8c3b..7fe8aaeb 100644 --- a/spark/src/test/java/com/nflabs/zeppelin/spark/DepInterpreterTest.java +++ b/spark/src/test/java/com/nflabs/zeppelin/spark/DepInterpreterTest.java @@ -3,17 +3,18 @@ import static org.junit.Assert.assertEquals; import java.io.File; +import java.util.HashMap; import java.util.Properties; import org.junit.After; import org.junit.Before; import org.junit.Test; +import com.nflabs.zeppelin.display.GUI; import com.nflabs.zeppelin.interpreter.InterpreterContext; import com.nflabs.zeppelin.interpreter.InterpreterGroup; import com.nflabs.zeppelin.interpreter.InterpreterResult; import com.nflabs.zeppelin.interpreter.InterpreterResult.Code; -import com.nflabs.zeppelin.notebook.Paragraph; public class DepInterpreterTest { private DepInterpreter dep; @@ -38,7 +39,7 @@ public void setUp() throws Exception { intpGroup.add(dep); dep.setInterpreterGroup(intpGroup); - context = new InterpreterContext(new Paragraph(null, null)); + context = new InterpreterContext("id", "title", "text", new HashMap(), new GUI()); } @After diff --git a/spark/src/test/java/com/nflabs/zeppelin/spark/SparkInterpreterTest.java b/spark/src/test/java/com/nflabs/zeppelin/spark/SparkInterpreterTest.java index a7e40a59..ae9fb73e 100644 --- a/spark/src/test/java/com/nflabs/zeppelin/spark/SparkInterpreterTest.java +++ b/spark/src/test/java/com/nflabs/zeppelin/spark/SparkInterpreterTest.java @@ -4,6 +4,7 @@ import static org.junit.Assert.assertTrue; import java.io.File; +import java.util.HashMap; import java.util.Properties; import org.junit.After; @@ -12,10 +13,10 @@ import org.junit.Test; import org.junit.runners.MethodSorters; +import com.nflabs.zeppelin.display.GUI; import com.nflabs.zeppelin.interpreter.InterpreterContext; import com.nflabs.zeppelin.interpreter.InterpreterResult; import com.nflabs.zeppelin.interpreter.InterpreterResult.Code; -import com.nflabs.zeppelin.notebook.Paragraph; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class SparkInterpreterTest { @@ -37,7 +38,7 @@ public void setUp() throws Exception { repl.open(); } - context = new InterpreterContext(new Paragraph(null, null)); + context = new InterpreterContext("id", "title", "text", new HashMap(), new GUI()); } @After diff --git a/spark/src/test/java/com/nflabs/zeppelin/spark/SparkSqlInterpreterTest.java b/spark/src/test/java/com/nflabs/zeppelin/spark/SparkSqlInterpreterTest.java index 6e962ef6..d29deb8d 100644 --- a/spark/src/test/java/com/nflabs/zeppelin/spark/SparkSqlInterpreterTest.java +++ b/spark/src/test/java/com/nflabs/zeppelin/spark/SparkSqlInterpreterTest.java @@ -2,17 +2,18 @@ import static org.junit.Assert.assertEquals; +import java.util.HashMap; import java.util.Properties; import org.junit.After; import org.junit.Before; import org.junit.Test; +import com.nflabs.zeppelin.display.GUI; import com.nflabs.zeppelin.interpreter.InterpreterContext; import com.nflabs.zeppelin.interpreter.InterpreterGroup; import com.nflabs.zeppelin.interpreter.InterpreterResult; import com.nflabs.zeppelin.interpreter.InterpreterResult.Type; -import com.nflabs.zeppelin.notebook.Paragraph; public class SparkSqlInterpreterTest { @@ -42,7 +43,7 @@ public void setUp() throws Exception { sql.setInterpreterGroup(intpGroup); sql.open(); } - context = new InterpreterContext(new Paragraph(null, null)); + context = new InterpreterContext("id", "title", "text", new HashMap(), new GUI()); } @After diff --git a/zeppelin-interpreter/pom.xml b/zeppelin-interpreter/pom.xml new file mode 100644 index 00000000..26c2bbae --- /dev/null +++ b/zeppelin-interpreter/pom.xml @@ -0,0 +1,60 @@ + + + + 4.0.0 + + + zeppelin + com.nflabs.zeppelin + 0.5.0-SNAPSHOT + + + com.nflabs.zeppelin + zeppelin-interpreter + jar + 0.5.0-SNAPSHOT + Zeppelin: Interpreter + Zeppelin Interpreter + http://zeppelin-project.org + + + + org.apache.thrift + libthrift + 0.9.0 + + + + com.google.code.gson + gson + + + + org.apache.commons + commons-exec + 1.1 + + + + org.apache.commons + commons-pool2 + 2.3 + + + + org.slf4j + slf4j-api + + + + org.slf4j + slf4j-log4j12 + + + + junit + junit + test + + + diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/notebook/form/Setting.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/display/GUI.java similarity index 86% rename from zeppelin-zengine/src/main/java/com/nflabs/zeppelin/notebook/form/Setting.java rename to zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/display/GUI.java index af708c63..51ae2220 100644 --- a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/notebook/form/Setting.java +++ b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/display/GUI.java @@ -1,24 +1,24 @@ -package com.nflabs.zeppelin.notebook.form; +package com.nflabs.zeppelin.display; import java.io.Serializable; import java.util.HashMap; import java.util.Map; import java.util.TreeMap; -import com.nflabs.zeppelin.notebook.form.Input.ParamOption; +import com.nflabs.zeppelin.display.Input.ParamOption; /** - * Settings of a form. - * + * Settings of a form. + * * @author Leemoonsoo * */ -public class Setting implements Serializable { +public class GUI implements Serializable { Map params = new HashMap(); // form parameters from client Map forms = new TreeMap(); // form configuration - public Setting() { + public GUI() { } @@ -30,8 +30,6 @@ public Map getParams() { return params; } - - public Map getForms() { return forms; } diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/notebook/form/Input.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/display/Input.java similarity index 99% rename from zeppelin-zengine/src/main/java/com/nflabs/zeppelin/notebook/form/Input.java rename to zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/display/Input.java index 27dc3a87..54ef717b 100644 --- a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/notebook/form/Input.java +++ b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/display/Input.java @@ -1,4 +1,4 @@ -package com.nflabs.zeppelin.notebook.form; +package com.nflabs.zeppelin.display; import java.io.Serializable; import java.util.ArrayList; diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/ClassloaderInterpreter.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/ClassloaderInterpreter.java similarity index 89% rename from zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/ClassloaderInterpreter.java rename to zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/ClassloaderInterpreter.java index 05eaaac9..f8d8bbf3 100644 --- a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/ClassloaderInterpreter.java +++ b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/ClassloaderInterpreter.java @@ -32,20 +32,6 @@ public ClassLoader getClassloader() { return cl; } - @Override - public Object getValue(String name) { - ClassLoader oldcl = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader(cl); - try { - return intp.getValue(name); - } catch (Exception e) { - throw new InterpreterException(e); - } finally { - cl = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader(oldcl); - } - } - @Override public InterpreterResult interpret(String st, InterpreterContext context) { ClassLoader oldcl = Thread.currentThread().getContextClassLoader(); @@ -61,19 +47,6 @@ public InterpreterResult interpret(String st, InterpreterContext context) { } } - @Override - public void bindValue(String name, Object o) { - ClassLoader oldcl = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader(cl); - try { - intp.bindValue(name, o); - } catch (Exception e) { - throw new InterpreterException(e); - } finally { - cl = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader(oldcl); - } - } @Override public void open() { diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/Interpreter.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/Interpreter.java similarity index 66% rename from zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/Interpreter.java rename to zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/Interpreter.java index b5cd4562..acb62a28 100644 --- a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/Interpreter.java +++ b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/Interpreter.java @@ -16,8 +16,102 @@ /** * Interface for interpreters. + * If you want to implement new Zeppelin interpreter, extend this class + * + * Please see, + * http://zeppelin.incubator.apache.org/docs/development/writingzeppelininterpreter.html + * + * open(), close(), interpreter() is three the most important method you need to implement. + * cancel(), getProgress(), completion() is good to have + * getFormType(), getScheduler() determine Zeppelin's behavior + * */ public abstract class Interpreter { + + /** + * Opens interpreter. You may want to place your initialize routine here. + * open() is called only once + */ + public abstract void open(); + + /** + * Closes interpreter. You may want to free your resources up here. + * close() is called only once + */ + public abstract void close(); + + /** + * Run code and return result, in synchronous way. + * + * @param st statements to run + * @param context + * @return + */ + public abstract InterpreterResult interpret(String st, InterpreterContext context); + + /** + * Optionally implement the canceling routine to abort interpret() method + * + * @param context + */ + public abstract void cancel(InterpreterContext context); + + /** + * Dynamic form handling + * see http://zeppelin.incubator.apache.org/docs/dynamicform.html + * + * @return FormType.SIMPLE enables simple pattern replacement (eg. Hello ${name=world}), + * FormType.NATIVE handles form in API + */ + public abstract FormType getFormType(); + + /** + * get interpret() method running process in percentage. + * + * @param context + * @return number between 0-100 + */ + public abstract int getProgress(InterpreterContext context); + + /** + * Get completion list based on cursor position. + * By implementing this method, it enables auto-completion. + * + * @param buf statements + * @param cursor cursor position in statements + * @return list of possible completion. Return empty list if there're nothing to return. + */ + public abstract List completion(String buf, int cursor); + + /** + * Interpreter can implements it's own scheduler by overriding this method. + * There're two default scheduler provided, FIFO, Parallel. + * If your interpret() can handle concurrent request, use Parallel or use FIFO. + * + * You can get default scheduler by using + * SchedulerFactory.singleton().createOrGetFIFOScheduler() + * SchedulerFactory.singleton().createOrGetParallelScheduler() + * + * + * @return return scheduler instance. + * This method can be called multiple times and have to return the same instance. + * Can not return null. + */ + public Scheduler getScheduler() { + return SchedulerFactory.singleton().createOrGetFIFOScheduler("interpreter_" + this.hashCode()); + } + + /** + * Called when interpreter is no longer used. + */ + public void destroy() { + getScheduler().stop(); + } + + + + + static Logger logger = LoggerFactory.getLogger(Interpreter.class); private InterpreterGroup interpreterGroup; private URL [] classloaderUrls; @@ -64,6 +158,27 @@ public String getProperty(String key) { } + public String getClassName() { + return this.getClass().getName(); + } + + public void setInterpreterGroup(InterpreterGroup interpreterGroup) { + this.interpreterGroup = interpreterGroup; + } + + public InterpreterGroup getInterpreterGroup() { + return this.interpreterGroup; + } + + public URL[] getClassloaderUrls() { + return classloaderUrls; + } + + public void setClassloaderUrls(URL[] classloaderUrls) { + this.classloaderUrls = classloaderUrls; + } + + /** * Type of interpreter. */ @@ -79,6 +194,7 @@ public static class RegisteredInterpreter { private String group; private String className; private Map properties; + private String path; public RegisteredInterpreter(String name, String group, String className, Map properties) { @@ -105,6 +221,14 @@ public Map getProperties() { return properties; } + public void setPath(String path) { + this.path = path; + } + + public String getPath() { + return path; + } + } /** @@ -139,49 +263,5 @@ public static RegisteredInterpreter findRegisteredInterpreterByClassName(String return null; } - public abstract void open(); - - public abstract void close(); - - public abstract Object getValue(String name); - - public abstract InterpreterResult interpret(String st, InterpreterContext context); - - public abstract void cancel(InterpreterContext context); - - public abstract void bindValue(String name, Object o); - - public abstract FormType getFormType(); - - public abstract int getProgress(InterpreterContext context); - - public Scheduler getScheduler() { - return SchedulerFactory.singleton().createOrGetFIFOScheduler("interpreter_" + this.hashCode()); - } - - public void destroy() { - getScheduler().stop(); - } - - public abstract List completion(String buf, int cursor); - - public String getClassName() { - return this.getClass().getName(); - } - - public void setInterpreterGroup(InterpreterGroup interpreterGroup) { - this.interpreterGroup = interpreterGroup; - } - - public InterpreterGroup getInterpreterGroup() { - return this.interpreterGroup; - } - public URL[] getClassloaderUrls() { - return classloaderUrls; - } - - public void setClassloaderUrls(URL[] classloaderUrls) { - this.classloaderUrls = classloaderUrls; - } } diff --git a/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterContext.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterContext.java new file mode 100644 index 00000000..d99e8b07 --- /dev/null +++ b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterContext.java @@ -0,0 +1,51 @@ +package com.nflabs.zeppelin.interpreter; + +import java.util.Map; + +import com.nflabs.zeppelin.display.GUI; + +/** + * Interpreter context + */ +public class InterpreterContext { + private final String paragraphTitle; + private final String paragraphId; + private final String paragraphText; + private final Map config; + private GUI gui; + + + public InterpreterContext(String paragraphId, + String paragraphTitle, + String paragraphText, + Map config, + GUI gui + ) { + this.paragraphId = paragraphId; + this.paragraphTitle = paragraphTitle; + this.paragraphText = paragraphText; + this.config = config; + this.gui = gui; + } + + public String getParagraphId() { + return paragraphId; + } + + public String getParagraphText() { + return paragraphText; + } + + public String getParagraphTitle() { + return paragraphTitle; + } + + public Map getConfig() { + return config; + } + + public GUI getGui() { + return gui; + } + +} diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterException.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterException.java similarity index 100% rename from zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterException.java rename to zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterException.java diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterGroup.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterGroup.java similarity index 59% rename from zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterGroup.java rename to zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterGroup.java index 3639672a..ad2b3480 100644 --- a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterGroup.java +++ b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterGroup.java @@ -2,12 +2,29 @@ import java.util.LinkedList; import java.util.Properties; +import java.util.Random; /** * InterpreterGroup is list of interpreters in the same group. - * And unit of interpreter instantiate, restart, bind, unbind. + * And unit of interpreter instantiate, restart, bind, unbind. */ public class InterpreterGroup extends LinkedList{ + String id; + + private static String generateId() { + return "InterpreterGroup_" + System.currentTimeMillis() + "_" + + new Random().nextInt(); + } + + public String getId() { + synchronized (this) { + if (id == null) { + id = generateId(); + } + return id; + } + } + public Properties getProperty() { Properties p = new Properties(); @@ -20,12 +37,12 @@ public Properties getProperty() { public void close() { for (Interpreter intp : this) { intp.close(); - } + } } public void destroy() { for (Interpreter intp : this) { intp.destroy(); - } + } } } diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterProperty.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterProperty.java similarity index 100% rename from zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterProperty.java rename to zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterProperty.java diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterPropertyBuilder.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterPropertyBuilder.java similarity index 100% rename from zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterPropertyBuilder.java rename to zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterPropertyBuilder.java diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterResult.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterResult.java similarity index 92% rename from zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterResult.java rename to zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterResult.java index 607733a6..94bf673c 100644 --- a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterResult.java +++ b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterResult.java @@ -4,15 +4,15 @@ /** * Interpreter result template. - * + * * @author Leemoonsoo * */ public class InterpreterResult implements Serializable { - + /** * Type of result after code execution. - * + * * @author Leemoonsoo * */ @@ -24,7 +24,7 @@ public static enum Code { /** * Type of Data. - * + * * @author Leemoonsoo * */ @@ -53,9 +53,15 @@ public InterpreterResult(Code code, String msg) { this.type = getType(msg); } + public InterpreterResult(Code code, Type type, String msg) { + this.code = code; + this.msg = msg; + this.type = type; + } + /** * Magic is like %html %text. - * + * * @param msg * @return */ diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/LazyOpenInterpreter.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/LazyOpenInterpreter.java similarity index 90% rename from zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/LazyOpenInterpreter.java rename to zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/LazyOpenInterpreter.java index 2d9a224b..07033208 100644 --- a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/LazyOpenInterpreter.java +++ b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/LazyOpenInterpreter.java @@ -12,7 +12,6 @@ public class LazyOpenInterpreter extends Interpreter implements WrappedInterpreter { - private Interpreter intp; boolean opened = false; @@ -47,7 +46,7 @@ public void open() { return; } - synchronized (this) { + synchronized (intp) { if (opened == false) { intp.open(); opened = true; @@ -57,7 +56,7 @@ public void open() { @Override public void close() { - synchronized (this) { + synchronized (intp) { if (opened == true) { intp.close(); opened = false; @@ -65,10 +64,10 @@ public void close() { } } - @Override - public Object getValue(String name) { - open(); - return intp.getValue(name); + public boolean isOpen() { + synchronized (intp) { + return opened; + } } @Override @@ -83,14 +82,9 @@ public void cancel(InterpreterContext context) { intp.cancel(context); } - @Override - public void bindValue(String name, Object o) { - open(); - intp.bindValue(name, o); - } - @Override public FormType getFormType() { + open(); return intp.getFormType(); } diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/WrappedInterpreter.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/WrappedInterpreter.java similarity index 100% rename from zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/WrappedInterpreter.java rename to zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/WrappedInterpreter.java diff --git a/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/remote/ClientFactory.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/remote/ClientFactory.java new file mode 100644 index 00000000..670dc2e9 --- /dev/null +++ b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/remote/ClientFactory.java @@ -0,0 +1,63 @@ +package com.nflabs.zeppelin.interpreter.remote; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.commons.pool2.BasePooledObjectFactory; +import org.apache.commons.pool2.PooledObject; +import org.apache.commons.pool2.impl.DefaultPooledObject; +import org.apache.thrift.protocol.TBinaryProtocol; +import org.apache.thrift.protocol.TProtocol; +import org.apache.thrift.transport.TSocket; +import org.apache.thrift.transport.TTransportException; + +import com.nflabs.zeppelin.interpreter.InterpreterException; +import com.nflabs.zeppelin.interpreter.thrift.RemoteInterpreterService; +import com.nflabs.zeppelin.interpreter.thrift.RemoteInterpreterService.Client; + +/** + * + */ +public class ClientFactory extends BasePooledObjectFactory{ + private String host; + private int port; + Map clientSocketMap = new HashMap(); + + public ClientFactory(String host, int port) { + this.host = host; + this.port = port; + } + + @Override + public Client create() throws Exception { + TSocket transport = new TSocket(host, port); + try { + transport.open(); + } catch (TTransportException e) { + throw new InterpreterException(e); + } + + TProtocol protocol = new TBinaryProtocol(transport); + Client client = new RemoteInterpreterService.Client(protocol); + + synchronized (clientSocketMap) { + clientSocketMap.put(client, transport); + } + return client; + } + + @Override + public PooledObject wrap(Client client) { + return new DefaultPooledObject(client); + } + + @Override + public void destroyObject(PooledObject p) { + synchronized (clientSocketMap) { + if (clientSocketMap.containsKey(p)) { + clientSocketMap.get(p).close(); + clientSocketMap.remove(p); + } + } + } +} diff --git a/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreter.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreter.java new file mode 100644 index 00000000..240e861c --- /dev/null +++ b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreter.java @@ -0,0 +1,337 @@ +package com.nflabs.zeppelin.interpreter.remote; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import org.apache.thrift.TException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.nflabs.zeppelin.display.GUI; +import com.nflabs.zeppelin.interpreter.Interpreter; +import com.nflabs.zeppelin.interpreter.InterpreterContext; +import com.nflabs.zeppelin.interpreter.InterpreterException; +import com.nflabs.zeppelin.interpreter.InterpreterGroup; +import com.nflabs.zeppelin.interpreter.InterpreterResult; +import com.nflabs.zeppelin.interpreter.InterpreterResult.Type; +import com.nflabs.zeppelin.interpreter.thrift.RemoteInterpreterContext; +import com.nflabs.zeppelin.interpreter.thrift.RemoteInterpreterResult; +import com.nflabs.zeppelin.interpreter.thrift.RemoteInterpreterService.Client; +import com.nflabs.zeppelin.scheduler.Scheduler; +import com.nflabs.zeppelin.scheduler.SchedulerFactory; + +/** + * + */ +public class RemoteInterpreter extends Interpreter { + Logger logger = LoggerFactory.getLogger(RemoteInterpreter.class); + Gson gson = new Gson(); + private String interpreterRunner; + private String interpreterPath; + private String className; + FormType formType; + private Map env; + static Map interpreterGroupReference + = new HashMap(); + + public RemoteInterpreter(Properties property, + String className, + String interpreterRunner, + String interpreterPath) { + super(property); + + this.className = className; + this.interpreterRunner = interpreterRunner; + this.interpreterPath = interpreterPath; + env = new HashMap(); + } + + public RemoteInterpreter(Properties property, + String className, + String interpreterRunner, + String interpreterPath, + Map env) { + super(property); + + this.className = className; + this.interpreterRunner = interpreterRunner; + this.interpreterPath = interpreterPath; + this.env = env; + } + + @Override + public String getClassName() { + return className; + } + + public RemoteInterpreterProcess getInterpreterProcess() { + synchronized (interpreterGroupReference) { + if (interpreterGroupReference.containsKey(getInterpreterGroupKey(getInterpreterGroup()))) { + RemoteInterpreterProcess interpreterProcess = interpreterGroupReference + .get(getInterpreterGroupKey(getInterpreterGroup())); + try { + return interpreterProcess; + } catch (Exception e) { + throw new InterpreterException(e); + } + } else { + throw new InterpreterException("Unexpected error"); + } + } + } + + private void init() { + RemoteInterpreterProcess interpreterProcess = null; + + synchronized (interpreterGroupReference) { + if (interpreterGroupReference.containsKey(getInterpreterGroupKey(getInterpreterGroup()))) { + interpreterProcess = interpreterGroupReference + .get(getInterpreterGroupKey(getInterpreterGroup())); + } else { + throw new InterpreterException("Unexpected error"); + } + } + + int rc = interpreterProcess.reference(); + + synchronized (interpreterProcess) { + // when first process created + if (rc == 1) { + // create all interpreter class in this interpreter group + Client client = null; + try { + client = interpreterProcess.getClient(); + } catch (Exception e1) { + throw new InterpreterException(e1); + } + + try { + for (Interpreter intp : this.getInterpreterGroup()) { + logger.info("Create remote interpreter {}", intp.getClassName()); + client.createInterpreter(intp.getClassName(), (Map) property); + + } + } catch (TException e) { + throw new InterpreterException(e); + } finally { + interpreterProcess.releaseClient(client); + } + } + } + } + + + + @Override + public void open() { + init(); + + RemoteInterpreterProcess interpreterProcess = getInterpreterProcess(); + + Client client = null; + try { + client = interpreterProcess.getClient(); + } catch (Exception e1) { + throw new InterpreterException(e1); + } + + try { + logger.info("open remote interpreter {}", className); + client.open(className); + } catch (TException e) { + throw new InterpreterException(e); + } finally { + interpreterProcess.releaseClient(client); + } + } + + @Override + public void close() { + RemoteInterpreterProcess interpreterProcess = getInterpreterProcess(); + Client client = null; + try { + client = interpreterProcess.getClient(); + } catch (Exception e1) { + throw new InterpreterException(e1); + } + + try { + client.close(className); + } catch (TException e) { + throw new InterpreterException(e); + } finally { + interpreterProcess.releaseClient(client); + } + + interpreterProcess.dereference(); + } + + @Override + public InterpreterResult interpret(String st, InterpreterContext context) { + FormType form = getFormType(); + RemoteInterpreterProcess interpreterProcess = getInterpreterProcess(); + Client client = null; + try { + client = interpreterProcess.getClient(); + } catch (Exception e1) { + throw new InterpreterException(e1); + } + + try { + GUI settings = context.getGui(); + RemoteInterpreterResult remoteResult = client.interpret(className, st, convert(context)); + + Map remoteConfig = (Map) gson.fromJson( + remoteResult.getConfig(), new TypeToken>() { + }.getType()); + context.getConfig().clear(); + context.getConfig().putAll(remoteConfig); + + if (form == FormType.NATIVE) { + GUI remoteGui = gson.fromJson(remoteResult.getGui(), GUI.class); + context.getGui().clear(); + context.getGui().setParams(remoteGui.getParams()); + context.getGui().setForms(remoteGui.getForms()); + } + + return convert(remoteResult); + } catch (TException e) { + throw new InterpreterException(e); + } finally { + interpreterProcess.releaseClient(client); + } + } + + @Override + public void cancel(InterpreterContext context) { + RemoteInterpreterProcess interpreterProcess = getInterpreterProcess(); + Client client = null; + try { + client = interpreterProcess.getClient(); + } catch (Exception e1) { + throw new InterpreterException(e1); + } + + try { + client.cancel(className, convert(context)); + } catch (TException e) { + throw new InterpreterException(e); + } finally { + interpreterProcess.releaseClient(client); + } + } + + + @Override + public FormType getFormType() { + if (formType != null) { + return formType; + } + + RemoteInterpreterProcess interpreterProcess = getInterpreterProcess(); + Client client = null; + try { + client = interpreterProcess.getClient(); + } catch (Exception e1) { + throw new InterpreterException(e1); + } + + try { + formType = FormType.valueOf(client.getFormType(className)); + return formType; + } catch (TException e) { + throw new InterpreterException(e); + } finally { + interpreterProcess.releaseClient(client); + } + } + + @Override + public int getProgress(InterpreterContext context) { + RemoteInterpreterProcess interpreterProcess = getInterpreterProcess(); + Client client = null; + try { + client = interpreterProcess.getClient(); + } catch (Exception e1) { + throw new InterpreterException(e1); + } + + try { + return client.getProgress(className, convert(context)); + } catch (TException e) { + throw new InterpreterException(e); + } finally { + interpreterProcess.releaseClient(client); + } + } + + + @Override + public List completion(String buf, int cursor) { + RemoteInterpreterProcess interpreterProcess = getInterpreterProcess(); + Client client = null; + try { + client = interpreterProcess.getClient(); + } catch (Exception e1) { + throw new InterpreterException(e1); + } + + try { + return client.completion(className, buf, cursor); + } catch (TException e) { + throw new InterpreterException(e); + } finally { + interpreterProcess.releaseClient(client); + } + } + + @Override + public Scheduler getScheduler() { + int maxConcurrency = 10; + + return SchedulerFactory.singleton().createOrGetRemoteScheduler( + "remoteinterpreter_" + this.hashCode(), getInterpreterProcess(), maxConcurrency); + } + + @Override + public void setInterpreterGroup(InterpreterGroup interpreterGroup) { + super.setInterpreterGroup(interpreterGroup); + + synchronized (interpreterGroupReference) { + if (!interpreterGroupReference + .containsKey(getInterpreterGroupKey(interpreterGroup))) { + interpreterGroupReference.put(getInterpreterGroupKey(interpreterGroup), + new RemoteInterpreterProcess(interpreterRunner, + interpreterPath, env)); + + logger.info("setInterpreterGroup = " + + getInterpreterGroupKey(interpreterGroup) + " class=" + className + + ", path=" + interpreterPath); + } + } + } + + private String getInterpreterGroupKey(InterpreterGroup interpreterGroup) { + return interpreterGroup.getId(); + } + + private RemoteInterpreterContext convert(InterpreterContext ic) { + return new RemoteInterpreterContext( + ic.getParagraphId(), + ic.getParagraphTitle(), + ic.getParagraphText(), + gson.toJson(ic.getConfig()), + gson.toJson(ic.getGui())); + } + + private InterpreterResult convert(RemoteInterpreterResult result) { + return new InterpreterResult( + InterpreterResult.Code.valueOf(result.getCode()), + Type.valueOf(result.getType()), + result.getMsg()); + } +} diff --git a/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreterProcess.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreterProcess.java new file mode 100644 index 00000000..38296185 --- /dev/null +++ b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreterProcess.java @@ -0,0 +1,192 @@ +package com.nflabs.zeppelin.interpreter.remote; + +import java.io.IOException; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; + +import org.apache.commons.exec.CommandLine; +import org.apache.commons.exec.DefaultExecutor; +import org.apache.commons.exec.ExecuteException; +import org.apache.commons.exec.ExecuteResultHandler; +import org.apache.commons.exec.ExecuteWatchdog; +import org.apache.commons.exec.environment.EnvironmentUtils; +import org.apache.commons.pool2.impl.GenericObjectPool; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.nflabs.zeppelin.interpreter.InterpreterException; +import com.nflabs.zeppelin.interpreter.thrift.RemoteInterpreterService.Client; + +/** + * + */ +public class RemoteInterpreterProcess implements ExecuteResultHandler { + Logger logger = LoggerFactory.getLogger(RemoteInterpreterProcess.class); + AtomicInteger referenceCount; + private DefaultExecutor executor; + private ExecuteWatchdog watchdog; + boolean running = false; + int port = -1; + private String interpreterRunner; + private String interpreterDir; + + private GenericObjectPool clientPool; + private Map env; + + public RemoteInterpreterProcess(String intpRunner, String intpDir, Map env) { + this.interpreterRunner = intpRunner; + this.interpreterDir = intpDir; + this.env = env; + referenceCount = new AtomicInteger(0); + } + + public int getPort() { + return port; + } + + public int reference() { + synchronized (referenceCount) { + if (executor == null) { + // start server process + try { + port = RemoteInterpreterUtils.findRandomAvailablePortOnAllLocalInterfaces(); + } catch (IOException e1) { + throw new InterpreterException(e1); + } + + + CommandLine cmdLine = CommandLine.parse(interpreterRunner); + cmdLine.addArgument("-d", false); + cmdLine.addArgument(interpreterDir, false); + cmdLine.addArgument("-p", false); + cmdLine.addArgument(Integer.toString(port), false); + + executor = new DefaultExecutor(); + + watchdog = new ExecuteWatchdog(ExecuteWatchdog.INFINITE_TIMEOUT); + executor.setWatchdog(watchdog); + + running = true; + try { + Map procEnv = EnvironmentUtils.getProcEnvironment(); + procEnv.putAll(env); + + logger.info("Run interpreter process {}", cmdLine); + executor.execute(cmdLine, procEnv, this); + } catch (IOException e) { + running = false; + throw new InterpreterException(e); + } + + + long startTime = System.currentTimeMillis(); + while (System.currentTimeMillis() - startTime < 5 * 1000) { + if (RemoteInterpreterUtils.checkIfRemoteEndpointAccessible("localhost", port)) { + break; + } else { + try { + Thread.sleep(500); + } catch (InterruptedException e) { + } + } + } + + clientPool = new GenericObjectPool(new ClientFactory("localhost", port)); + } + return referenceCount.incrementAndGet(); + } + } + + public Client getClient() throws Exception { + return clientPool.borrowObject(); + } + + public void releaseClient(Client client) { + clientPool.returnObject(client); + } + + public int dereference() { + synchronized (referenceCount) { + int r = referenceCount.decrementAndGet(); + if (r == 0) { + logger.info("shutdown interpreter process"); + // first try shutdown + try { + Client client = getClient(); + client.shutdown(); + releaseClient(client); + } catch (Exception e) { + logger.error("Error", e); + watchdog.destroyProcess(); + } + + clientPool.clear(); + clientPool.close(); + + // wait for 3 sec and force kill + // remote process server.serve() loop is not always finishing gracefully + long startTime = System.currentTimeMillis(); + while (System.currentTimeMillis() - startTime < 3 * 1000) { + if (this.isRunning()) { + try { + Thread.sleep(500); + } catch (InterruptedException e) { + } + } else { + break; + } + } + + if (isRunning()) { + logger.info("kill interpreter process"); + watchdog.destroyProcess(); + } + + executor = null; + watchdog = null; + running = false; + logger.info("Remote process terminated"); + } + return r; + } + } + + public int referenceCount() { + synchronized (referenceCount) { + return referenceCount.get(); + } + } + + @Override + public void onProcessComplete(int exitValue) { + logger.info("Interpreter process exited {}", exitValue); + running = false; + + } + + @Override + public void onProcessFailed(ExecuteException e) { + logger.info("Interpreter process failed {}", e); + running = false; + } + + public boolean isRunning() { + return running; + } + + public int getNumActiveClient() { + if (clientPool == null) { + return 0; + } else { + return clientPool.getNumActive(); + } + } + + public int getNumIdleClient() { + if (clientPool == null) { + return 0; + } else { + return clientPool.getNumIdle(); + } + } +} diff --git a/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreterServer.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreterServer.java new file mode 100644 index 00000000..8ab13a4d --- /dev/null +++ b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreterServer.java @@ -0,0 +1,323 @@ +package com.nflabs.zeppelin.interpreter.remote; + + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import org.apache.thrift.TException; +import org.apache.thrift.server.TThreadPoolServer; +import org.apache.thrift.transport.TServerSocket; +import org.apache.thrift.transport.TTransportException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.nflabs.zeppelin.display.GUI; +import com.nflabs.zeppelin.interpreter.ClassloaderInterpreter; +import com.nflabs.zeppelin.interpreter.Interpreter; +import com.nflabs.zeppelin.interpreter.Interpreter.FormType; +import com.nflabs.zeppelin.interpreter.InterpreterContext; +import com.nflabs.zeppelin.interpreter.InterpreterException; +import com.nflabs.zeppelin.interpreter.InterpreterGroup; +import com.nflabs.zeppelin.interpreter.InterpreterResult; +import com.nflabs.zeppelin.interpreter.thrift.RemoteInterpreterContext; +import com.nflabs.zeppelin.interpreter.thrift.RemoteInterpreterResult; +import com.nflabs.zeppelin.interpreter.thrift.RemoteInterpreterService; +import com.nflabs.zeppelin.scheduler.Job; +import com.nflabs.zeppelin.scheduler.Job.Status; +import com.nflabs.zeppelin.scheduler.JobListener; +import com.nflabs.zeppelin.scheduler.JobProgressPoller; +import com.nflabs.zeppelin.scheduler.Scheduler; + + +/** + * + */ +public class RemoteInterpreterServer + extends Thread + implements RemoteInterpreterService.Iface { + Logger logger = LoggerFactory.getLogger(RemoteInterpreterServer.class); + + InterpreterGroup interpreterGroup = new InterpreterGroup(); + Gson gson = new Gson(); + + RemoteInterpreterService.Processor processor; + RemoteInterpreterServer handler; + private int port; + private TThreadPoolServer server; + + public RemoteInterpreterServer(int port) throws TTransportException { + this.port = port; + processor = new RemoteInterpreterService.Processor(this); + TServerSocket serverTransport = new TServerSocket(port); + server = new TThreadPoolServer( + new TThreadPoolServer.Args(serverTransport).processor(processor)); + } + + @Override + public void run() { + logger.info("Starting remote interpreter server on port {}", port); + server.serve(); + } + + @Override + public void shutdown() throws TException { + // server.stop() does not always finish server.serve() loop + // sometimes server.serve() is hanging even after server.stop() call. + // this case, need to force kill the process + server.stop(); + } + + public int getPort() { + return port; + } + + public boolean isRunning() { + if (server == null) { + return false; + } else { + return server.isServing(); + } + } + + + public static void main(String[] args) + throws TTransportException, InterruptedException { + int port = Integer.parseInt(args[0]); + RemoteInterpreterServer remoteInterpreterServer = new RemoteInterpreterServer(port); + remoteInterpreterServer.start(); + remoteInterpreterServer.join(); + System.exit(0); + } + + + @Override + public void createInterpreter(String className, Map properties) + throws TException { + try { + Class replClass = (Class) Object.class.forName(className); + Properties p = new Properties(); + p.putAll(properties); + + Constructor constructor = + replClass.getConstructor(new Class[] {Properties.class}); + Interpreter repl = constructor.newInstance(p); + + ClassLoader cl = ClassLoader.getSystemClassLoader(); + repl.setClassloaderUrls(new URL[]{}); + + synchronized (interpreterGroup) { + interpreterGroup.add(new ClassloaderInterpreter(repl, cl)); + } + + logger.info("Instantiate interpreter {}", className); + repl.setInterpreterGroup(interpreterGroup); + } catch (ClassNotFoundException | NoSuchMethodException | SecurityException + | InstantiationException | IllegalAccessException + | IllegalArgumentException | InvocationTargetException e) { + e.printStackTrace(); + throw new TException(e); + } + } + + private Interpreter getInterpreter(String className) throws TException { + synchronized (interpreterGroup) { + for (Interpreter inp : interpreterGroup) { + if (inp.getClassName().equals(className)) { + return inp; + } + } + } + throw new TException(new InterpreterException("Interpreter instance " + + className + " not found")); + } + + @Override + public void open(String className) throws TException { + Interpreter intp = getInterpreter(className); + intp.open(); + } + + @Override + public void close(String className) throws TException { + Interpreter intp = getInterpreter(className); + intp.close(); + } + + + @Override + public RemoteInterpreterResult interpret(String className, String st, + RemoteInterpreterContext interpreterContext) throws TException { + Interpreter intp = getInterpreter(className); + InterpreterContext context = convert(interpreterContext); + + Scheduler scheduler = intp.getScheduler(); + InterpretJobListener jobListener = new InterpretJobListener(); + InterpretJob job = new InterpretJob( + interpreterContext.getParagraphId(), + "remoteInterpretJob_" + System.currentTimeMillis(), + jobListener, + JobProgressPoller.DEFAULT_INTERVAL_MSEC, + intp, + st, + context); + + scheduler.submit(job); + + while (!job.isTerminated()) { + synchronized (jobListener) { + try { + jobListener.wait(1000); + } catch (InterruptedException e) { + } + } + } + + if (job.getStatus() == Status.ERROR) { + throw new TException(job.getException()); + } else { + if (intp.getFormType() == FormType.NATIVE) { + // serialize dynamic form + + } + + return convert((InterpreterResult) job.getReturn(), + context.getConfig(), + context.getGui()); + } + } + + class InterpretJobListener implements JobListener { + + @Override + public void onProgressUpdate(Job job, int progress) { + } + + @Override + public void beforeStatusChange(Job job, Status before, Status after) { + } + + @Override + public void afterStatusChange(Job job, Status before, Status after) { + synchronized (this) { + notifyAll(); + } + } + } + + class InterpretJob extends Job { + + private Interpreter interpreter; + private String script; + private InterpreterContext context; + + public InterpretJob( + String jobId, + String jobName, + JobListener listener, + long progressUpdateIntervalMsec, + Interpreter interpreter, + String script, + InterpreterContext context) { + super(jobId, jobName, listener, progressUpdateIntervalMsec); + this.interpreter = interpreter; + this.script = script; + this.context = context; + } + + @Override + public int progress() { + return 0; + } + + @Override + public Map info() { + return null; + } + + @Override + protected Object jobRun() throws Throwable { + InterpreterResult result = interpreter.interpret(script, context); + return result; + } + + @Override + protected boolean jobAbort() { + return false; + } + } + + + @Override + public void cancel(String className, RemoteInterpreterContext interpreterContext) + throws TException { + Interpreter intp = getInterpreter(className); + intp.cancel(convert(interpreterContext)); + } + + @Override + public int getProgress(String className, RemoteInterpreterContext interpreterContext) + throws TException { + Interpreter intp = getInterpreter(className); + return intp.getProgress(convert(interpreterContext)); + } + + + @Override + public String getFormType(String className) throws TException { + Interpreter intp = getInterpreter(className); + return intp.getFormType().toString(); + } + + @Override + public List completion(String className, String buf, int cursor) throws TException { + Interpreter intp = getInterpreter(className); + return intp.completion(buf, cursor); + } + + private InterpreterContext convert(RemoteInterpreterContext ric) { + return new InterpreterContext( + ric.getParagraphId(), + ric.getParagraphTitle(), + ric.getParagraphText(), + (Map) gson.fromJson(ric.getConfig(), + new TypeToken>() {}.getType()), + gson.fromJson(ric.getGui(), GUI.class)); + } + + private RemoteInterpreterResult convert(InterpreterResult result, + Map config, GUI gui) { + return new RemoteInterpreterResult( + result.code().name(), + result.type().name(), + result.message(), + gson.toJson(config), + gson.toJson(gui)); + } + + @Override + public String getStatus(String jobId) + throws TException { + synchronized (interpreterGroup) { + for (Interpreter intp : interpreterGroup) { + for (Job job : intp.getScheduler().getJobsRunning()) { + if (jobId.equals(job.getId())) { + return job.getStatus().name(); + } + } + + for (Job job : intp.getScheduler().getJobsWaiting()) { + if (jobId.equals(job.getId())) { + return job.getStatus().name(); + } + } + } + } + return "Unknown"; + } +} diff --git a/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreterUtils.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreterUtils.java new file mode 100644 index 00000000..0c8a5054 --- /dev/null +++ b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreterUtils.java @@ -0,0 +1,32 @@ +package com.nflabs.zeppelin.interpreter.remote; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.ServerSocket; +import java.net.Socket; + +/** + * + */ +public class RemoteInterpreterUtils { + public static int findRandomAvailablePortOnAllLocalInterfaces() throws IOException { + int port; + try (ServerSocket socket = new ServerSocket(0);) { + port = socket.getLocalPort(); + socket.close(); + } + return port; + } + + public static boolean checkIfRemoteEndpointAccessible(String host, int port) { + try { + Socket discover = new Socket(); + discover.setSoTimeout(1000); + discover.connect(new InetSocketAddress(host, port), 1000); + discover.close(); + return true; + } catch (IOException e) { + return false; + } + } +} diff --git a/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/thrift/RemoteInterpreterContext.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/thrift/RemoteInterpreterContext.java new file mode 100644 index 00000000..3d141850 --- /dev/null +++ b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/thrift/RemoteInterpreterContext.java @@ -0,0 +1,786 @@ +/** + * Autogenerated by Thrift Compiler (0.9.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package com.nflabs.zeppelin.interpreter.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class RemoteInterpreterContext implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("RemoteInterpreterContext"); + + private static final org.apache.thrift.protocol.TField PARAGRAPH_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("paragraphId", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField PARAGRAPH_TITLE_FIELD_DESC = new org.apache.thrift.protocol.TField("paragraphTitle", org.apache.thrift.protocol.TType.STRING, (short)2); + private static final org.apache.thrift.protocol.TField PARAGRAPH_TEXT_FIELD_DESC = new org.apache.thrift.protocol.TField("paragraphText", org.apache.thrift.protocol.TType.STRING, (short)3); + private static final org.apache.thrift.protocol.TField CONFIG_FIELD_DESC = new org.apache.thrift.protocol.TField("config", org.apache.thrift.protocol.TType.STRING, (short)4); + private static final org.apache.thrift.protocol.TField GUI_FIELD_DESC = new org.apache.thrift.protocol.TField("gui", org.apache.thrift.protocol.TType.STRING, (short)5); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new RemoteInterpreterContextStandardSchemeFactory()); + schemes.put(TupleScheme.class, new RemoteInterpreterContextTupleSchemeFactory()); + } + + public String paragraphId; // required + public String paragraphTitle; // required + public String paragraphText; // required + public String config; // required + public String gui; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + PARAGRAPH_ID((short)1, "paragraphId"), + PARAGRAPH_TITLE((short)2, "paragraphTitle"), + PARAGRAPH_TEXT((short)3, "paragraphText"), + CONFIG((short)4, "config"), + GUI((short)5, "gui"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // PARAGRAPH_ID + return PARAGRAPH_ID; + case 2: // PARAGRAPH_TITLE + return PARAGRAPH_TITLE; + case 3: // PARAGRAPH_TEXT + return PARAGRAPH_TEXT; + case 4: // CONFIG + return CONFIG; + case 5: // GUI + return GUI; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.PARAGRAPH_ID, new org.apache.thrift.meta_data.FieldMetaData("paragraphId", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.PARAGRAPH_TITLE, new org.apache.thrift.meta_data.FieldMetaData("paragraphTitle", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.PARAGRAPH_TEXT, new org.apache.thrift.meta_data.FieldMetaData("paragraphText", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.CONFIG, new org.apache.thrift.meta_data.FieldMetaData("config", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.GUI, new org.apache.thrift.meta_data.FieldMetaData("gui", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(RemoteInterpreterContext.class, metaDataMap); + } + + public RemoteInterpreterContext() { + } + + public RemoteInterpreterContext( + String paragraphId, + String paragraphTitle, + String paragraphText, + String config, + String gui) + { + this(); + this.paragraphId = paragraphId; + this.paragraphTitle = paragraphTitle; + this.paragraphText = paragraphText; + this.config = config; + this.gui = gui; + } + + /** + * Performs a deep copy on other. + */ + public RemoteInterpreterContext(RemoteInterpreterContext other) { + if (other.isSetParagraphId()) { + this.paragraphId = other.paragraphId; + } + if (other.isSetParagraphTitle()) { + this.paragraphTitle = other.paragraphTitle; + } + if (other.isSetParagraphText()) { + this.paragraphText = other.paragraphText; + } + if (other.isSetConfig()) { + this.config = other.config; + } + if (other.isSetGui()) { + this.gui = other.gui; + } + } + + public RemoteInterpreterContext deepCopy() { + return new RemoteInterpreterContext(this); + } + + @Override + public void clear() { + this.paragraphId = null; + this.paragraphTitle = null; + this.paragraphText = null; + this.config = null; + this.gui = null; + } + + public String getParagraphId() { + return this.paragraphId; + } + + public RemoteInterpreterContext setParagraphId(String paragraphId) { + this.paragraphId = paragraphId; + return this; + } + + public void unsetParagraphId() { + this.paragraphId = null; + } + + /** Returns true if field paragraphId is set (has been assigned a value) and false otherwise */ + public boolean isSetParagraphId() { + return this.paragraphId != null; + } + + public void setParagraphIdIsSet(boolean value) { + if (!value) { + this.paragraphId = null; + } + } + + public String getParagraphTitle() { + return this.paragraphTitle; + } + + public RemoteInterpreterContext setParagraphTitle(String paragraphTitle) { + this.paragraphTitle = paragraphTitle; + return this; + } + + public void unsetParagraphTitle() { + this.paragraphTitle = null; + } + + /** Returns true if field paragraphTitle is set (has been assigned a value) and false otherwise */ + public boolean isSetParagraphTitle() { + return this.paragraphTitle != null; + } + + public void setParagraphTitleIsSet(boolean value) { + if (!value) { + this.paragraphTitle = null; + } + } + + public String getParagraphText() { + return this.paragraphText; + } + + public RemoteInterpreterContext setParagraphText(String paragraphText) { + this.paragraphText = paragraphText; + return this; + } + + public void unsetParagraphText() { + this.paragraphText = null; + } + + /** Returns true if field paragraphText is set (has been assigned a value) and false otherwise */ + public boolean isSetParagraphText() { + return this.paragraphText != null; + } + + public void setParagraphTextIsSet(boolean value) { + if (!value) { + this.paragraphText = null; + } + } + + public String getConfig() { + return this.config; + } + + public RemoteInterpreterContext setConfig(String config) { + this.config = config; + return this; + } + + public void unsetConfig() { + this.config = null; + } + + /** Returns true if field config is set (has been assigned a value) and false otherwise */ + public boolean isSetConfig() { + return this.config != null; + } + + public void setConfigIsSet(boolean value) { + if (!value) { + this.config = null; + } + } + + public String getGui() { + return this.gui; + } + + public RemoteInterpreterContext setGui(String gui) { + this.gui = gui; + return this; + } + + public void unsetGui() { + this.gui = null; + } + + /** Returns true if field gui is set (has been assigned a value) and false otherwise */ + public boolean isSetGui() { + return this.gui != null; + } + + public void setGuiIsSet(boolean value) { + if (!value) { + this.gui = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case PARAGRAPH_ID: + if (value == null) { + unsetParagraphId(); + } else { + setParagraphId((String)value); + } + break; + + case PARAGRAPH_TITLE: + if (value == null) { + unsetParagraphTitle(); + } else { + setParagraphTitle((String)value); + } + break; + + case PARAGRAPH_TEXT: + if (value == null) { + unsetParagraphText(); + } else { + setParagraphText((String)value); + } + break; + + case CONFIG: + if (value == null) { + unsetConfig(); + } else { + setConfig((String)value); + } + break; + + case GUI: + if (value == null) { + unsetGui(); + } else { + setGui((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case PARAGRAPH_ID: + return getParagraphId(); + + case PARAGRAPH_TITLE: + return getParagraphTitle(); + + case PARAGRAPH_TEXT: + return getParagraphText(); + + case CONFIG: + return getConfig(); + + case GUI: + return getGui(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case PARAGRAPH_ID: + return isSetParagraphId(); + case PARAGRAPH_TITLE: + return isSetParagraphTitle(); + case PARAGRAPH_TEXT: + return isSetParagraphText(); + case CONFIG: + return isSetConfig(); + case GUI: + return isSetGui(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof RemoteInterpreterContext) + return this.equals((RemoteInterpreterContext)that); + return false; + } + + public boolean equals(RemoteInterpreterContext that) { + if (that == null) + return false; + + boolean this_present_paragraphId = true && this.isSetParagraphId(); + boolean that_present_paragraphId = true && that.isSetParagraphId(); + if (this_present_paragraphId || that_present_paragraphId) { + if (!(this_present_paragraphId && that_present_paragraphId)) + return false; + if (!this.paragraphId.equals(that.paragraphId)) + return false; + } + + boolean this_present_paragraphTitle = true && this.isSetParagraphTitle(); + boolean that_present_paragraphTitle = true && that.isSetParagraphTitle(); + if (this_present_paragraphTitle || that_present_paragraphTitle) { + if (!(this_present_paragraphTitle && that_present_paragraphTitle)) + return false; + if (!this.paragraphTitle.equals(that.paragraphTitle)) + return false; + } + + boolean this_present_paragraphText = true && this.isSetParagraphText(); + boolean that_present_paragraphText = true && that.isSetParagraphText(); + if (this_present_paragraphText || that_present_paragraphText) { + if (!(this_present_paragraphText && that_present_paragraphText)) + return false; + if (!this.paragraphText.equals(that.paragraphText)) + return false; + } + + boolean this_present_config = true && this.isSetConfig(); + boolean that_present_config = true && that.isSetConfig(); + if (this_present_config || that_present_config) { + if (!(this_present_config && that_present_config)) + return false; + if (!this.config.equals(that.config)) + return false; + } + + boolean this_present_gui = true && this.isSetGui(); + boolean that_present_gui = true && that.isSetGui(); + if (this_present_gui || that_present_gui) { + if (!(this_present_gui && that_present_gui)) + return false; + if (!this.gui.equals(that.gui)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(RemoteInterpreterContext other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + RemoteInterpreterContext typedOther = (RemoteInterpreterContext)other; + + lastComparison = Boolean.valueOf(isSetParagraphId()).compareTo(typedOther.isSetParagraphId()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetParagraphId()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.paragraphId, typedOther.paragraphId); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetParagraphTitle()).compareTo(typedOther.isSetParagraphTitle()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetParagraphTitle()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.paragraphTitle, typedOther.paragraphTitle); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetParagraphText()).compareTo(typedOther.isSetParagraphText()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetParagraphText()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.paragraphText, typedOther.paragraphText); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetConfig()).compareTo(typedOther.isSetConfig()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetConfig()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.config, typedOther.config); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetGui()).compareTo(typedOther.isSetGui()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetGui()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.gui, typedOther.gui); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("RemoteInterpreterContext("); + boolean first = true; + + sb.append("paragraphId:"); + if (this.paragraphId == null) { + sb.append("null"); + } else { + sb.append(this.paragraphId); + } + first = false; + if (!first) sb.append(", "); + sb.append("paragraphTitle:"); + if (this.paragraphTitle == null) { + sb.append("null"); + } else { + sb.append(this.paragraphTitle); + } + first = false; + if (!first) sb.append(", "); + sb.append("paragraphText:"); + if (this.paragraphText == null) { + sb.append("null"); + } else { + sb.append(this.paragraphText); + } + first = false; + if (!first) sb.append(", "); + sb.append("config:"); + if (this.config == null) { + sb.append("null"); + } else { + sb.append(this.config); + } + first = false; + if (!first) sb.append(", "); + sb.append("gui:"); + if (this.gui == null) { + sb.append("null"); + } else { + sb.append(this.gui); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class RemoteInterpreterContextStandardSchemeFactory implements SchemeFactory { + public RemoteInterpreterContextStandardScheme getScheme() { + return new RemoteInterpreterContextStandardScheme(); + } + } + + private static class RemoteInterpreterContextStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, RemoteInterpreterContext struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // PARAGRAPH_ID + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.paragraphId = iprot.readString(); + struct.setParagraphIdIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // PARAGRAPH_TITLE + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.paragraphTitle = iprot.readString(); + struct.setParagraphTitleIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // PARAGRAPH_TEXT + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.paragraphText = iprot.readString(); + struct.setParagraphTextIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 4: // CONFIG + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.config = iprot.readString(); + struct.setConfigIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 5: // GUI + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.gui = iprot.readString(); + struct.setGuiIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, RemoteInterpreterContext struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.paragraphId != null) { + oprot.writeFieldBegin(PARAGRAPH_ID_FIELD_DESC); + oprot.writeString(struct.paragraphId); + oprot.writeFieldEnd(); + } + if (struct.paragraphTitle != null) { + oprot.writeFieldBegin(PARAGRAPH_TITLE_FIELD_DESC); + oprot.writeString(struct.paragraphTitle); + oprot.writeFieldEnd(); + } + if (struct.paragraphText != null) { + oprot.writeFieldBegin(PARAGRAPH_TEXT_FIELD_DESC); + oprot.writeString(struct.paragraphText); + oprot.writeFieldEnd(); + } + if (struct.config != null) { + oprot.writeFieldBegin(CONFIG_FIELD_DESC); + oprot.writeString(struct.config); + oprot.writeFieldEnd(); + } + if (struct.gui != null) { + oprot.writeFieldBegin(GUI_FIELD_DESC); + oprot.writeString(struct.gui); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class RemoteInterpreterContextTupleSchemeFactory implements SchemeFactory { + public RemoteInterpreterContextTupleScheme getScheme() { + return new RemoteInterpreterContextTupleScheme(); + } + } + + private static class RemoteInterpreterContextTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, RemoteInterpreterContext struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetParagraphId()) { + optionals.set(0); + } + if (struct.isSetParagraphTitle()) { + optionals.set(1); + } + if (struct.isSetParagraphText()) { + optionals.set(2); + } + if (struct.isSetConfig()) { + optionals.set(3); + } + if (struct.isSetGui()) { + optionals.set(4); + } + oprot.writeBitSet(optionals, 5); + if (struct.isSetParagraphId()) { + oprot.writeString(struct.paragraphId); + } + if (struct.isSetParagraphTitle()) { + oprot.writeString(struct.paragraphTitle); + } + if (struct.isSetParagraphText()) { + oprot.writeString(struct.paragraphText); + } + if (struct.isSetConfig()) { + oprot.writeString(struct.config); + } + if (struct.isSetGui()) { + oprot.writeString(struct.gui); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, RemoteInterpreterContext struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(5); + if (incoming.get(0)) { + struct.paragraphId = iprot.readString(); + struct.setParagraphIdIsSet(true); + } + if (incoming.get(1)) { + struct.paragraphTitle = iprot.readString(); + struct.setParagraphTitleIsSet(true); + } + if (incoming.get(2)) { + struct.paragraphText = iprot.readString(); + struct.setParagraphTextIsSet(true); + } + if (incoming.get(3)) { + struct.config = iprot.readString(); + struct.setConfigIsSet(true); + } + if (incoming.get(4)) { + struct.gui = iprot.readString(); + struct.setGuiIsSet(true); + } + } + } + +} + diff --git a/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/thrift/RemoteInterpreterResult.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/thrift/RemoteInterpreterResult.java new file mode 100644 index 00000000..2e53e30e --- /dev/null +++ b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/thrift/RemoteInterpreterResult.java @@ -0,0 +1,786 @@ +/** + * Autogenerated by Thrift Compiler (0.9.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package com.nflabs.zeppelin.interpreter.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class RemoteInterpreterResult implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("RemoteInterpreterResult"); + + private static final org.apache.thrift.protocol.TField CODE_FIELD_DESC = new org.apache.thrift.protocol.TField("code", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("type", org.apache.thrift.protocol.TType.STRING, (short)2); + private static final org.apache.thrift.protocol.TField MSG_FIELD_DESC = new org.apache.thrift.protocol.TField("msg", org.apache.thrift.protocol.TType.STRING, (short)3); + private static final org.apache.thrift.protocol.TField CONFIG_FIELD_DESC = new org.apache.thrift.protocol.TField("config", org.apache.thrift.protocol.TType.STRING, (short)4); + private static final org.apache.thrift.protocol.TField GUI_FIELD_DESC = new org.apache.thrift.protocol.TField("gui", org.apache.thrift.protocol.TType.STRING, (short)5); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new RemoteInterpreterResultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new RemoteInterpreterResultTupleSchemeFactory()); + } + + public String code; // required + public String type; // required + public String msg; // required + public String config; // required + public String gui; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + CODE((short)1, "code"), + TYPE((short)2, "type"), + MSG((short)3, "msg"), + CONFIG((short)4, "config"), + GUI((short)5, "gui"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // CODE + return CODE; + case 2: // TYPE + return TYPE; + case 3: // MSG + return MSG; + case 4: // CONFIG + return CONFIG; + case 5: // GUI + return GUI; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.CODE, new org.apache.thrift.meta_data.FieldMetaData("code", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.TYPE, new org.apache.thrift.meta_data.FieldMetaData("type", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.MSG, new org.apache.thrift.meta_data.FieldMetaData("msg", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.CONFIG, new org.apache.thrift.meta_data.FieldMetaData("config", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.GUI, new org.apache.thrift.meta_data.FieldMetaData("gui", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(RemoteInterpreterResult.class, metaDataMap); + } + + public RemoteInterpreterResult() { + } + + public RemoteInterpreterResult( + String code, + String type, + String msg, + String config, + String gui) + { + this(); + this.code = code; + this.type = type; + this.msg = msg; + this.config = config; + this.gui = gui; + } + + /** + * Performs a deep copy on other. + */ + public RemoteInterpreterResult(RemoteInterpreterResult other) { + if (other.isSetCode()) { + this.code = other.code; + } + if (other.isSetType()) { + this.type = other.type; + } + if (other.isSetMsg()) { + this.msg = other.msg; + } + if (other.isSetConfig()) { + this.config = other.config; + } + if (other.isSetGui()) { + this.gui = other.gui; + } + } + + public RemoteInterpreterResult deepCopy() { + return new RemoteInterpreterResult(this); + } + + @Override + public void clear() { + this.code = null; + this.type = null; + this.msg = null; + this.config = null; + this.gui = null; + } + + public String getCode() { + return this.code; + } + + public RemoteInterpreterResult setCode(String code) { + this.code = code; + return this; + } + + public void unsetCode() { + this.code = null; + } + + /** Returns true if field code is set (has been assigned a value) and false otherwise */ + public boolean isSetCode() { + return this.code != null; + } + + public void setCodeIsSet(boolean value) { + if (!value) { + this.code = null; + } + } + + public String getType() { + return this.type; + } + + public RemoteInterpreterResult setType(String type) { + this.type = type; + return this; + } + + public void unsetType() { + this.type = null; + } + + /** Returns true if field type is set (has been assigned a value) and false otherwise */ + public boolean isSetType() { + return this.type != null; + } + + public void setTypeIsSet(boolean value) { + if (!value) { + this.type = null; + } + } + + public String getMsg() { + return this.msg; + } + + public RemoteInterpreterResult setMsg(String msg) { + this.msg = msg; + return this; + } + + public void unsetMsg() { + this.msg = null; + } + + /** Returns true if field msg is set (has been assigned a value) and false otherwise */ + public boolean isSetMsg() { + return this.msg != null; + } + + public void setMsgIsSet(boolean value) { + if (!value) { + this.msg = null; + } + } + + public String getConfig() { + return this.config; + } + + public RemoteInterpreterResult setConfig(String config) { + this.config = config; + return this; + } + + public void unsetConfig() { + this.config = null; + } + + /** Returns true if field config is set (has been assigned a value) and false otherwise */ + public boolean isSetConfig() { + return this.config != null; + } + + public void setConfigIsSet(boolean value) { + if (!value) { + this.config = null; + } + } + + public String getGui() { + return this.gui; + } + + public RemoteInterpreterResult setGui(String gui) { + this.gui = gui; + return this; + } + + public void unsetGui() { + this.gui = null; + } + + /** Returns true if field gui is set (has been assigned a value) and false otherwise */ + public boolean isSetGui() { + return this.gui != null; + } + + public void setGuiIsSet(boolean value) { + if (!value) { + this.gui = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case CODE: + if (value == null) { + unsetCode(); + } else { + setCode((String)value); + } + break; + + case TYPE: + if (value == null) { + unsetType(); + } else { + setType((String)value); + } + break; + + case MSG: + if (value == null) { + unsetMsg(); + } else { + setMsg((String)value); + } + break; + + case CONFIG: + if (value == null) { + unsetConfig(); + } else { + setConfig((String)value); + } + break; + + case GUI: + if (value == null) { + unsetGui(); + } else { + setGui((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case CODE: + return getCode(); + + case TYPE: + return getType(); + + case MSG: + return getMsg(); + + case CONFIG: + return getConfig(); + + case GUI: + return getGui(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case CODE: + return isSetCode(); + case TYPE: + return isSetType(); + case MSG: + return isSetMsg(); + case CONFIG: + return isSetConfig(); + case GUI: + return isSetGui(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof RemoteInterpreterResult) + return this.equals((RemoteInterpreterResult)that); + return false; + } + + public boolean equals(RemoteInterpreterResult that) { + if (that == null) + return false; + + boolean this_present_code = true && this.isSetCode(); + boolean that_present_code = true && that.isSetCode(); + if (this_present_code || that_present_code) { + if (!(this_present_code && that_present_code)) + return false; + if (!this.code.equals(that.code)) + return false; + } + + boolean this_present_type = true && this.isSetType(); + boolean that_present_type = true && that.isSetType(); + if (this_present_type || that_present_type) { + if (!(this_present_type && that_present_type)) + return false; + if (!this.type.equals(that.type)) + return false; + } + + boolean this_present_msg = true && this.isSetMsg(); + boolean that_present_msg = true && that.isSetMsg(); + if (this_present_msg || that_present_msg) { + if (!(this_present_msg && that_present_msg)) + return false; + if (!this.msg.equals(that.msg)) + return false; + } + + boolean this_present_config = true && this.isSetConfig(); + boolean that_present_config = true && that.isSetConfig(); + if (this_present_config || that_present_config) { + if (!(this_present_config && that_present_config)) + return false; + if (!this.config.equals(that.config)) + return false; + } + + boolean this_present_gui = true && this.isSetGui(); + boolean that_present_gui = true && that.isSetGui(); + if (this_present_gui || that_present_gui) { + if (!(this_present_gui && that_present_gui)) + return false; + if (!this.gui.equals(that.gui)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(RemoteInterpreterResult other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + RemoteInterpreterResult typedOther = (RemoteInterpreterResult)other; + + lastComparison = Boolean.valueOf(isSetCode()).compareTo(typedOther.isSetCode()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCode()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.code, typedOther.code); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetType()).compareTo(typedOther.isSetType()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetType()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.type, typedOther.type); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetMsg()).compareTo(typedOther.isSetMsg()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetMsg()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.msg, typedOther.msg); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetConfig()).compareTo(typedOther.isSetConfig()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetConfig()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.config, typedOther.config); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetGui()).compareTo(typedOther.isSetGui()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetGui()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.gui, typedOther.gui); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("RemoteInterpreterResult("); + boolean first = true; + + sb.append("code:"); + if (this.code == null) { + sb.append("null"); + } else { + sb.append(this.code); + } + first = false; + if (!first) sb.append(", "); + sb.append("type:"); + if (this.type == null) { + sb.append("null"); + } else { + sb.append(this.type); + } + first = false; + if (!first) sb.append(", "); + sb.append("msg:"); + if (this.msg == null) { + sb.append("null"); + } else { + sb.append(this.msg); + } + first = false; + if (!first) sb.append(", "); + sb.append("config:"); + if (this.config == null) { + sb.append("null"); + } else { + sb.append(this.config); + } + first = false; + if (!first) sb.append(", "); + sb.append("gui:"); + if (this.gui == null) { + sb.append("null"); + } else { + sb.append(this.gui); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class RemoteInterpreterResultStandardSchemeFactory implements SchemeFactory { + public RemoteInterpreterResultStandardScheme getScheme() { + return new RemoteInterpreterResultStandardScheme(); + } + } + + private static class RemoteInterpreterResultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, RemoteInterpreterResult struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // CODE + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.code = iprot.readString(); + struct.setCodeIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // TYPE + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.type = iprot.readString(); + struct.setTypeIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // MSG + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.msg = iprot.readString(); + struct.setMsgIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 4: // CONFIG + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.config = iprot.readString(); + struct.setConfigIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 5: // GUI + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.gui = iprot.readString(); + struct.setGuiIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, RemoteInterpreterResult struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.code != null) { + oprot.writeFieldBegin(CODE_FIELD_DESC); + oprot.writeString(struct.code); + oprot.writeFieldEnd(); + } + if (struct.type != null) { + oprot.writeFieldBegin(TYPE_FIELD_DESC); + oprot.writeString(struct.type); + oprot.writeFieldEnd(); + } + if (struct.msg != null) { + oprot.writeFieldBegin(MSG_FIELD_DESC); + oprot.writeString(struct.msg); + oprot.writeFieldEnd(); + } + if (struct.config != null) { + oprot.writeFieldBegin(CONFIG_FIELD_DESC); + oprot.writeString(struct.config); + oprot.writeFieldEnd(); + } + if (struct.gui != null) { + oprot.writeFieldBegin(GUI_FIELD_DESC); + oprot.writeString(struct.gui); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class RemoteInterpreterResultTupleSchemeFactory implements SchemeFactory { + public RemoteInterpreterResultTupleScheme getScheme() { + return new RemoteInterpreterResultTupleScheme(); + } + } + + private static class RemoteInterpreterResultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, RemoteInterpreterResult struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetCode()) { + optionals.set(0); + } + if (struct.isSetType()) { + optionals.set(1); + } + if (struct.isSetMsg()) { + optionals.set(2); + } + if (struct.isSetConfig()) { + optionals.set(3); + } + if (struct.isSetGui()) { + optionals.set(4); + } + oprot.writeBitSet(optionals, 5); + if (struct.isSetCode()) { + oprot.writeString(struct.code); + } + if (struct.isSetType()) { + oprot.writeString(struct.type); + } + if (struct.isSetMsg()) { + oprot.writeString(struct.msg); + } + if (struct.isSetConfig()) { + oprot.writeString(struct.config); + } + if (struct.isSetGui()) { + oprot.writeString(struct.gui); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, RemoteInterpreterResult struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(5); + if (incoming.get(0)) { + struct.code = iprot.readString(); + struct.setCodeIsSet(true); + } + if (incoming.get(1)) { + struct.type = iprot.readString(); + struct.setTypeIsSet(true); + } + if (incoming.get(2)) { + struct.msg = iprot.readString(); + struct.setMsgIsSet(true); + } + if (incoming.get(3)) { + struct.config = iprot.readString(); + struct.setConfigIsSet(true); + } + if (incoming.get(4)) { + struct.gui = iprot.readString(); + struct.setGuiIsSet(true); + } + } + } + +} + diff --git a/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/thrift/RemoteInterpreterService.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/thrift/RemoteInterpreterService.java new file mode 100644 index 00000000..eed35c49 --- /dev/null +++ b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/interpreter/thrift/RemoteInterpreterService.java @@ -0,0 +1,8174 @@ +/** + * Autogenerated by Thrift Compiler (0.9.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package com.nflabs.zeppelin.interpreter.thrift; + +import org.apache.thrift.scheme.IScheme; +import org.apache.thrift.scheme.SchemeFactory; +import org.apache.thrift.scheme.StandardScheme; + +import org.apache.thrift.scheme.TupleScheme; +import org.apache.thrift.protocol.TTupleProtocol; +import org.apache.thrift.protocol.TProtocolException; +import org.apache.thrift.EncodingUtils; +import org.apache.thrift.TException; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; +import java.util.HashMap; +import java.util.EnumMap; +import java.util.Set; +import java.util.HashSet; +import java.util.EnumSet; +import java.util.Collections; +import java.util.BitSet; +import java.nio.ByteBuffer; +import java.util.Arrays; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class RemoteInterpreterService { + + public interface Iface { + + public void createInterpreter(String className, Map properties) throws org.apache.thrift.TException; + + public void open(String className) throws org.apache.thrift.TException; + + public void close(String className) throws org.apache.thrift.TException; + + public RemoteInterpreterResult interpret(String className, String st, RemoteInterpreterContext interpreterContext) throws org.apache.thrift.TException; + + public void cancel(String className, RemoteInterpreterContext interpreterContext) throws org.apache.thrift.TException; + + public int getProgress(String className, RemoteInterpreterContext interpreterContext) throws org.apache.thrift.TException; + + public String getFormType(String className) throws org.apache.thrift.TException; + + public List completion(String className, String buf, int cursor) throws org.apache.thrift.TException; + + public void shutdown() throws org.apache.thrift.TException; + + public String getStatus(String jobId) throws org.apache.thrift.TException; + + } + + public interface AsyncIface { + + public void createInterpreter(String className, Map properties, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + public void open(String className, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + public void close(String className, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + public void interpret(String className, String st, RemoteInterpreterContext interpreterContext, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + public void cancel(String className, RemoteInterpreterContext interpreterContext, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + public void getProgress(String className, RemoteInterpreterContext interpreterContext, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + public void getFormType(String className, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + public void completion(String className, String buf, int cursor, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + public void shutdown(org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + public void getStatus(String jobId, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + } + + public static class Client extends org.apache.thrift.TServiceClient implements Iface { + public static class Factory implements org.apache.thrift.TServiceClientFactory { + public Factory() {} + public Client getClient(org.apache.thrift.protocol.TProtocol prot) { + return new Client(prot); + } + public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { + return new Client(iprot, oprot); + } + } + + public Client(org.apache.thrift.protocol.TProtocol prot) + { + super(prot, prot); + } + + public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { + super(iprot, oprot); + } + + public void createInterpreter(String className, Map properties) throws org.apache.thrift.TException + { + send_createInterpreter(className, properties); + recv_createInterpreter(); + } + + public void send_createInterpreter(String className, Map properties) throws org.apache.thrift.TException + { + createInterpreter_args args = new createInterpreter_args(); + args.setClassName(className); + args.setProperties(properties); + sendBase("createInterpreter", args); + } + + public void recv_createInterpreter() throws org.apache.thrift.TException + { + createInterpreter_result result = new createInterpreter_result(); + receiveBase(result, "createInterpreter"); + return; + } + + public void open(String className) throws org.apache.thrift.TException + { + send_open(className); + recv_open(); + } + + public void send_open(String className) throws org.apache.thrift.TException + { + open_args args = new open_args(); + args.setClassName(className); + sendBase("open", args); + } + + public void recv_open() throws org.apache.thrift.TException + { + open_result result = new open_result(); + receiveBase(result, "open"); + return; + } + + public void close(String className) throws org.apache.thrift.TException + { + send_close(className); + recv_close(); + } + + public void send_close(String className) throws org.apache.thrift.TException + { + close_args args = new close_args(); + args.setClassName(className); + sendBase("close", args); + } + + public void recv_close() throws org.apache.thrift.TException + { + close_result result = new close_result(); + receiveBase(result, "close"); + return; + } + + public RemoteInterpreterResult interpret(String className, String st, RemoteInterpreterContext interpreterContext) throws org.apache.thrift.TException + { + send_interpret(className, st, interpreterContext); + return recv_interpret(); + } + + public void send_interpret(String className, String st, RemoteInterpreterContext interpreterContext) throws org.apache.thrift.TException + { + interpret_args args = new interpret_args(); + args.setClassName(className); + args.setSt(st); + args.setInterpreterContext(interpreterContext); + sendBase("interpret", args); + } + + public RemoteInterpreterResult recv_interpret() throws org.apache.thrift.TException + { + interpret_result result = new interpret_result(); + receiveBase(result, "interpret"); + if (result.isSetSuccess()) { + return result.success; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "interpret failed: unknown result"); + } + + public void cancel(String className, RemoteInterpreterContext interpreterContext) throws org.apache.thrift.TException + { + send_cancel(className, interpreterContext); + recv_cancel(); + } + + public void send_cancel(String className, RemoteInterpreterContext interpreterContext) throws org.apache.thrift.TException + { + cancel_args args = new cancel_args(); + args.setClassName(className); + args.setInterpreterContext(interpreterContext); + sendBase("cancel", args); + } + + public void recv_cancel() throws org.apache.thrift.TException + { + cancel_result result = new cancel_result(); + receiveBase(result, "cancel"); + return; + } + + public int getProgress(String className, RemoteInterpreterContext interpreterContext) throws org.apache.thrift.TException + { + send_getProgress(className, interpreterContext); + return recv_getProgress(); + } + + public void send_getProgress(String className, RemoteInterpreterContext interpreterContext) throws org.apache.thrift.TException + { + getProgress_args args = new getProgress_args(); + args.setClassName(className); + args.setInterpreterContext(interpreterContext); + sendBase("getProgress", args); + } + + public int recv_getProgress() throws org.apache.thrift.TException + { + getProgress_result result = new getProgress_result(); + receiveBase(result, "getProgress"); + if (result.isSetSuccess()) { + return result.success; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getProgress failed: unknown result"); + } + + public String getFormType(String className) throws org.apache.thrift.TException + { + send_getFormType(className); + return recv_getFormType(); + } + + public void send_getFormType(String className) throws org.apache.thrift.TException + { + getFormType_args args = new getFormType_args(); + args.setClassName(className); + sendBase("getFormType", args); + } + + public String recv_getFormType() throws org.apache.thrift.TException + { + getFormType_result result = new getFormType_result(); + receiveBase(result, "getFormType"); + if (result.isSetSuccess()) { + return result.success; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getFormType failed: unknown result"); + } + + public List completion(String className, String buf, int cursor) throws org.apache.thrift.TException + { + send_completion(className, buf, cursor); + return recv_completion(); + } + + public void send_completion(String className, String buf, int cursor) throws org.apache.thrift.TException + { + completion_args args = new completion_args(); + args.setClassName(className); + args.setBuf(buf); + args.setCursor(cursor); + sendBase("completion", args); + } + + public List recv_completion() throws org.apache.thrift.TException + { + completion_result result = new completion_result(); + receiveBase(result, "completion"); + if (result.isSetSuccess()) { + return result.success; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "completion failed: unknown result"); + } + + public void shutdown() throws org.apache.thrift.TException + { + send_shutdown(); + recv_shutdown(); + } + + public void send_shutdown() throws org.apache.thrift.TException + { + shutdown_args args = new shutdown_args(); + sendBase("shutdown", args); + } + + public void recv_shutdown() throws org.apache.thrift.TException + { + shutdown_result result = new shutdown_result(); + receiveBase(result, "shutdown"); + return; + } + + public String getStatus(String jobId) throws org.apache.thrift.TException + { + send_getStatus(jobId); + return recv_getStatus(); + } + + public void send_getStatus(String jobId) throws org.apache.thrift.TException + { + getStatus_args args = new getStatus_args(); + args.setJobId(jobId); + sendBase("getStatus", args); + } + + public String recv_getStatus() throws org.apache.thrift.TException + { + getStatus_result result = new getStatus_result(); + receiveBase(result, "getStatus"); + if (result.isSetSuccess()) { + return result.success; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "getStatus failed: unknown result"); + } + + } + public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface { + public static class Factory implements org.apache.thrift.async.TAsyncClientFactory { + private org.apache.thrift.async.TAsyncClientManager clientManager; + private org.apache.thrift.protocol.TProtocolFactory protocolFactory; + public Factory(org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.protocol.TProtocolFactory protocolFactory) { + this.clientManager = clientManager; + this.protocolFactory = protocolFactory; + } + public AsyncClient getAsyncClient(org.apache.thrift.transport.TNonblockingTransport transport) { + return new AsyncClient(protocolFactory, clientManager, transport); + } + } + + public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.transport.TNonblockingTransport transport) { + super(protocolFactory, clientManager, transport); + } + + public void createInterpreter(String className, Map properties, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + createInterpreter_call method_call = new createInterpreter_call(className, properties, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class createInterpreter_call extends org.apache.thrift.async.TAsyncMethodCall { + private String className; + private Map properties; + public createInterpreter_call(String className, Map properties, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.className = className; + this.properties = properties; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("createInterpreter", org.apache.thrift.protocol.TMessageType.CALL, 0)); + createInterpreter_args args = new createInterpreter_args(); + args.setClassName(className); + args.setProperties(properties); + args.write(prot); + prot.writeMessageEnd(); + } + + public void getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + (new Client(prot)).recv_createInterpreter(); + } + } + + public void open(String className, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + open_call method_call = new open_call(className, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class open_call extends org.apache.thrift.async.TAsyncMethodCall { + private String className; + public open_call(String className, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.className = className; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("open", org.apache.thrift.protocol.TMessageType.CALL, 0)); + open_args args = new open_args(); + args.setClassName(className); + args.write(prot); + prot.writeMessageEnd(); + } + + public void getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + (new Client(prot)).recv_open(); + } + } + + public void close(String className, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + close_call method_call = new close_call(className, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class close_call extends org.apache.thrift.async.TAsyncMethodCall { + private String className; + public close_call(String className, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.className = className; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("close", org.apache.thrift.protocol.TMessageType.CALL, 0)); + close_args args = new close_args(); + args.setClassName(className); + args.write(prot); + prot.writeMessageEnd(); + } + + public void getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + (new Client(prot)).recv_close(); + } + } + + public void interpret(String className, String st, RemoteInterpreterContext interpreterContext, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + interpret_call method_call = new interpret_call(className, st, interpreterContext, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class interpret_call extends org.apache.thrift.async.TAsyncMethodCall { + private String className; + private String st; + private RemoteInterpreterContext interpreterContext; + public interpret_call(String className, String st, RemoteInterpreterContext interpreterContext, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.className = className; + this.st = st; + this.interpreterContext = interpreterContext; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("interpret", org.apache.thrift.protocol.TMessageType.CALL, 0)); + interpret_args args = new interpret_args(); + args.setClassName(className); + args.setSt(st); + args.setInterpreterContext(interpreterContext); + args.write(prot); + prot.writeMessageEnd(); + } + + public RemoteInterpreterResult getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_interpret(); + } + } + + public void cancel(String className, RemoteInterpreterContext interpreterContext, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + cancel_call method_call = new cancel_call(className, interpreterContext, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class cancel_call extends org.apache.thrift.async.TAsyncMethodCall { + private String className; + private RemoteInterpreterContext interpreterContext; + public cancel_call(String className, RemoteInterpreterContext interpreterContext, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.className = className; + this.interpreterContext = interpreterContext; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("cancel", org.apache.thrift.protocol.TMessageType.CALL, 0)); + cancel_args args = new cancel_args(); + args.setClassName(className); + args.setInterpreterContext(interpreterContext); + args.write(prot); + prot.writeMessageEnd(); + } + + public void getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + (new Client(prot)).recv_cancel(); + } + } + + public void getProgress(String className, RemoteInterpreterContext interpreterContext, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + getProgress_call method_call = new getProgress_call(className, interpreterContext, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class getProgress_call extends org.apache.thrift.async.TAsyncMethodCall { + private String className; + private RemoteInterpreterContext interpreterContext; + public getProgress_call(String className, RemoteInterpreterContext interpreterContext, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.className = className; + this.interpreterContext = interpreterContext; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getProgress", org.apache.thrift.protocol.TMessageType.CALL, 0)); + getProgress_args args = new getProgress_args(); + args.setClassName(className); + args.setInterpreterContext(interpreterContext); + args.write(prot); + prot.writeMessageEnd(); + } + + public int getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_getProgress(); + } + } + + public void getFormType(String className, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + getFormType_call method_call = new getFormType_call(className, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class getFormType_call extends org.apache.thrift.async.TAsyncMethodCall { + private String className; + public getFormType_call(String className, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.className = className; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getFormType", org.apache.thrift.protocol.TMessageType.CALL, 0)); + getFormType_args args = new getFormType_args(); + args.setClassName(className); + args.write(prot); + prot.writeMessageEnd(); + } + + public String getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_getFormType(); + } + } + + public void completion(String className, String buf, int cursor, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + completion_call method_call = new completion_call(className, buf, cursor, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class completion_call extends org.apache.thrift.async.TAsyncMethodCall { + private String className; + private String buf; + private int cursor; + public completion_call(String className, String buf, int cursor, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.className = className; + this.buf = buf; + this.cursor = cursor; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("completion", org.apache.thrift.protocol.TMessageType.CALL, 0)); + completion_args args = new completion_args(); + args.setClassName(className); + args.setBuf(buf); + args.setCursor(cursor); + args.write(prot); + prot.writeMessageEnd(); + } + + public List getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_completion(); + } + } + + public void shutdown(org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + shutdown_call method_call = new shutdown_call(resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class shutdown_call extends org.apache.thrift.async.TAsyncMethodCall { + public shutdown_call(org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("shutdown", org.apache.thrift.protocol.TMessageType.CALL, 0)); + shutdown_args args = new shutdown_args(); + args.write(prot); + prot.writeMessageEnd(); + } + + public void getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + (new Client(prot)).recv_shutdown(); + } + } + + public void getStatus(String jobId, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + getStatus_call method_call = new getStatus_call(jobId, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class getStatus_call extends org.apache.thrift.async.TAsyncMethodCall { + private String jobId; + public getStatus_call(String jobId, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.jobId = jobId; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("getStatus", org.apache.thrift.protocol.TMessageType.CALL, 0)); + getStatus_args args = new getStatus_args(); + args.setJobId(jobId); + args.write(prot); + prot.writeMessageEnd(); + } + + public String getResult() throws org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_getStatus(); + } + } + + } + + public static class Processor extends org.apache.thrift.TBaseProcessor implements org.apache.thrift.TProcessor { + private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName()); + public Processor(I iface) { + super(iface, getProcessMap(new HashMap>())); + } + + protected Processor(I iface, Map> processMap) { + super(iface, getProcessMap(processMap)); + } + + private static Map> getProcessMap(Map> processMap) { + processMap.put("createInterpreter", new createInterpreter()); + processMap.put("open", new open()); + processMap.put("close", new close()); + processMap.put("interpret", new interpret()); + processMap.put("cancel", new cancel()); + processMap.put("getProgress", new getProgress()); + processMap.put("getFormType", new getFormType()); + processMap.put("completion", new completion()); + processMap.put("shutdown", new shutdown()); + processMap.put("getStatus", new getStatus()); + return processMap; + } + + public static class createInterpreter extends org.apache.thrift.ProcessFunction { + public createInterpreter() { + super("createInterpreter"); + } + + public createInterpreter_args getEmptyArgsInstance() { + return new createInterpreter_args(); + } + + protected boolean isOneway() { + return false; + } + + public createInterpreter_result getResult(I iface, createInterpreter_args args) throws org.apache.thrift.TException { + createInterpreter_result result = new createInterpreter_result(); + iface.createInterpreter(args.className, args.properties); + return result; + } + } + + public static class open extends org.apache.thrift.ProcessFunction { + public open() { + super("open"); + } + + public open_args getEmptyArgsInstance() { + return new open_args(); + } + + protected boolean isOneway() { + return false; + } + + public open_result getResult(I iface, open_args args) throws org.apache.thrift.TException { + open_result result = new open_result(); + iface.open(args.className); + return result; + } + } + + public static class close extends org.apache.thrift.ProcessFunction { + public close() { + super("close"); + } + + public close_args getEmptyArgsInstance() { + return new close_args(); + } + + protected boolean isOneway() { + return false; + } + + public close_result getResult(I iface, close_args args) throws org.apache.thrift.TException { + close_result result = new close_result(); + iface.close(args.className); + return result; + } + } + + public static class interpret extends org.apache.thrift.ProcessFunction { + public interpret() { + super("interpret"); + } + + public interpret_args getEmptyArgsInstance() { + return new interpret_args(); + } + + protected boolean isOneway() { + return false; + } + + public interpret_result getResult(I iface, interpret_args args) throws org.apache.thrift.TException { + interpret_result result = new interpret_result(); + result.success = iface.interpret(args.className, args.st, args.interpreterContext); + return result; + } + } + + public static class cancel extends org.apache.thrift.ProcessFunction { + public cancel() { + super("cancel"); + } + + public cancel_args getEmptyArgsInstance() { + return new cancel_args(); + } + + protected boolean isOneway() { + return false; + } + + public cancel_result getResult(I iface, cancel_args args) throws org.apache.thrift.TException { + cancel_result result = new cancel_result(); + iface.cancel(args.className, args.interpreterContext); + return result; + } + } + + public static class getProgress extends org.apache.thrift.ProcessFunction { + public getProgress() { + super("getProgress"); + } + + public getProgress_args getEmptyArgsInstance() { + return new getProgress_args(); + } + + protected boolean isOneway() { + return false; + } + + public getProgress_result getResult(I iface, getProgress_args args) throws org.apache.thrift.TException { + getProgress_result result = new getProgress_result(); + result.success = iface.getProgress(args.className, args.interpreterContext); + result.setSuccessIsSet(true); + return result; + } + } + + public static class getFormType extends org.apache.thrift.ProcessFunction { + public getFormType() { + super("getFormType"); + } + + public getFormType_args getEmptyArgsInstance() { + return new getFormType_args(); + } + + protected boolean isOneway() { + return false; + } + + public getFormType_result getResult(I iface, getFormType_args args) throws org.apache.thrift.TException { + getFormType_result result = new getFormType_result(); + result.success = iface.getFormType(args.className); + return result; + } + } + + public static class completion extends org.apache.thrift.ProcessFunction { + public completion() { + super("completion"); + } + + public completion_args getEmptyArgsInstance() { + return new completion_args(); + } + + protected boolean isOneway() { + return false; + } + + public completion_result getResult(I iface, completion_args args) throws org.apache.thrift.TException { + completion_result result = new completion_result(); + result.success = iface.completion(args.className, args.buf, args.cursor); + return result; + } + } + + public static class shutdown extends org.apache.thrift.ProcessFunction { + public shutdown() { + super("shutdown"); + } + + public shutdown_args getEmptyArgsInstance() { + return new shutdown_args(); + } + + protected boolean isOneway() { + return false; + } + + public shutdown_result getResult(I iface, shutdown_args args) throws org.apache.thrift.TException { + shutdown_result result = new shutdown_result(); + iface.shutdown(); + return result; + } + } + + public static class getStatus extends org.apache.thrift.ProcessFunction { + public getStatus() { + super("getStatus"); + } + + public getStatus_args getEmptyArgsInstance() { + return new getStatus_args(); + } + + protected boolean isOneway() { + return false; + } + + public getStatus_result getResult(I iface, getStatus_args args) throws org.apache.thrift.TException { + getStatus_result result = new getStatus_result(); + result.success = iface.getStatus(args.jobId); + return result; + } + } + + } + + public static class createInterpreter_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("createInterpreter_args"); + + private static final org.apache.thrift.protocol.TField CLASS_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("className", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField PROPERTIES_FIELD_DESC = new org.apache.thrift.protocol.TField("properties", org.apache.thrift.protocol.TType.MAP, (short)2); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new createInterpreter_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new createInterpreter_argsTupleSchemeFactory()); + } + + public String className; // required + public Map properties; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + CLASS_NAME((short)1, "className"), + PROPERTIES((short)2, "properties"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // CLASS_NAME + return CLASS_NAME; + case 2: // PROPERTIES + return PROPERTIES; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.CLASS_NAME, new org.apache.thrift.meta_data.FieldMetaData("className", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.PROPERTIES, new org.apache.thrift.meta_data.FieldMetaData("properties", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING), + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(createInterpreter_args.class, metaDataMap); + } + + public createInterpreter_args() { + } + + public createInterpreter_args( + String className, + Map properties) + { + this(); + this.className = className; + this.properties = properties; + } + + /** + * Performs a deep copy on other. + */ + public createInterpreter_args(createInterpreter_args other) { + if (other.isSetClassName()) { + this.className = other.className; + } + if (other.isSetProperties()) { + Map __this__properties = new HashMap(); + for (Map.Entry other_element : other.properties.entrySet()) { + + String other_element_key = other_element.getKey(); + String other_element_value = other_element.getValue(); + + String __this__properties_copy_key = other_element_key; + + String __this__properties_copy_value = other_element_value; + + __this__properties.put(__this__properties_copy_key, __this__properties_copy_value); + } + this.properties = __this__properties; + } + } + + public createInterpreter_args deepCopy() { + return new createInterpreter_args(this); + } + + @Override + public void clear() { + this.className = null; + this.properties = null; + } + + public String getClassName() { + return this.className; + } + + public createInterpreter_args setClassName(String className) { + this.className = className; + return this; + } + + public void unsetClassName() { + this.className = null; + } + + /** Returns true if field className is set (has been assigned a value) and false otherwise */ + public boolean isSetClassName() { + return this.className != null; + } + + public void setClassNameIsSet(boolean value) { + if (!value) { + this.className = null; + } + } + + public int getPropertiesSize() { + return (this.properties == null) ? 0 : this.properties.size(); + } + + public void putToProperties(String key, String val) { + if (this.properties == null) { + this.properties = new HashMap(); + } + this.properties.put(key, val); + } + + public Map getProperties() { + return this.properties; + } + + public createInterpreter_args setProperties(Map properties) { + this.properties = properties; + return this; + } + + public void unsetProperties() { + this.properties = null; + } + + /** Returns true if field properties is set (has been assigned a value) and false otherwise */ + public boolean isSetProperties() { + return this.properties != null; + } + + public void setPropertiesIsSet(boolean value) { + if (!value) { + this.properties = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case CLASS_NAME: + if (value == null) { + unsetClassName(); + } else { + setClassName((String)value); + } + break; + + case PROPERTIES: + if (value == null) { + unsetProperties(); + } else { + setProperties((Map)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case CLASS_NAME: + return getClassName(); + + case PROPERTIES: + return getProperties(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case CLASS_NAME: + return isSetClassName(); + case PROPERTIES: + return isSetProperties(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof createInterpreter_args) + return this.equals((createInterpreter_args)that); + return false; + } + + public boolean equals(createInterpreter_args that) { + if (that == null) + return false; + + boolean this_present_className = true && this.isSetClassName(); + boolean that_present_className = true && that.isSetClassName(); + if (this_present_className || that_present_className) { + if (!(this_present_className && that_present_className)) + return false; + if (!this.className.equals(that.className)) + return false; + } + + boolean this_present_properties = true && this.isSetProperties(); + boolean that_present_properties = true && that.isSetProperties(); + if (this_present_properties || that_present_properties) { + if (!(this_present_properties && that_present_properties)) + return false; + if (!this.properties.equals(that.properties)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(createInterpreter_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + createInterpreter_args typedOther = (createInterpreter_args)other; + + lastComparison = Boolean.valueOf(isSetClassName()).compareTo(typedOther.isSetClassName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetClassName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.className, typedOther.className); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetProperties()).compareTo(typedOther.isSetProperties()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetProperties()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.properties, typedOther.properties); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("createInterpreter_args("); + boolean first = true; + + sb.append("className:"); + if (this.className == null) { + sb.append("null"); + } else { + sb.append(this.className); + } + first = false; + if (!first) sb.append(", "); + sb.append("properties:"); + if (this.properties == null) { + sb.append("null"); + } else { + sb.append(this.properties); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class createInterpreter_argsStandardSchemeFactory implements SchemeFactory { + public createInterpreter_argsStandardScheme getScheme() { + return new createInterpreter_argsStandardScheme(); + } + } + + private static class createInterpreter_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, createInterpreter_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // CLASS_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.className = iprot.readString(); + struct.setClassNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // PROPERTIES + if (schemeField.type == org.apache.thrift.protocol.TType.MAP) { + { + org.apache.thrift.protocol.TMap _map0 = iprot.readMapBegin(); + struct.properties = new HashMap(2*_map0.size); + for (int _i1 = 0; _i1 < _map0.size; ++_i1) + { + String _key2; // required + String _val3; // required + _key2 = iprot.readString(); + _val3 = iprot.readString(); + struct.properties.put(_key2, _val3); + } + iprot.readMapEnd(); + } + struct.setPropertiesIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, createInterpreter_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.className != null) { + oprot.writeFieldBegin(CLASS_NAME_FIELD_DESC); + oprot.writeString(struct.className); + oprot.writeFieldEnd(); + } + if (struct.properties != null) { + oprot.writeFieldBegin(PROPERTIES_FIELD_DESC); + { + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, struct.properties.size())); + for (Map.Entry _iter4 : struct.properties.entrySet()) + { + oprot.writeString(_iter4.getKey()); + oprot.writeString(_iter4.getValue()); + } + oprot.writeMapEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class createInterpreter_argsTupleSchemeFactory implements SchemeFactory { + public createInterpreter_argsTupleScheme getScheme() { + return new createInterpreter_argsTupleScheme(); + } + } + + private static class createInterpreter_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, createInterpreter_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetClassName()) { + optionals.set(0); + } + if (struct.isSetProperties()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); + if (struct.isSetClassName()) { + oprot.writeString(struct.className); + } + if (struct.isSetProperties()) { + { + oprot.writeI32(struct.properties.size()); + for (Map.Entry _iter5 : struct.properties.entrySet()) + { + oprot.writeString(_iter5.getKey()); + oprot.writeString(_iter5.getValue()); + } + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, createInterpreter_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(2); + if (incoming.get(0)) { + struct.className = iprot.readString(); + struct.setClassNameIsSet(true); + } + if (incoming.get(1)) { + { + org.apache.thrift.protocol.TMap _map6 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.properties = new HashMap(2*_map6.size); + for (int _i7 = 0; _i7 < _map6.size; ++_i7) + { + String _key8; // required + String _val9; // required + _key8 = iprot.readString(); + _val9 = iprot.readString(); + struct.properties.put(_key8, _val9); + } + } + struct.setPropertiesIsSet(true); + } + } + } + + } + + public static class createInterpreter_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("createInterpreter_result"); + + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new createInterpreter_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new createInterpreter_resultTupleSchemeFactory()); + } + + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { +; + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(createInterpreter_result.class, metaDataMap); + } + + public createInterpreter_result() { + } + + /** + * Performs a deep copy on other. + */ + public createInterpreter_result(createInterpreter_result other) { + } + + public createInterpreter_result deepCopy() { + return new createInterpreter_result(this); + } + + @Override + public void clear() { + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof createInterpreter_result) + return this.equals((createInterpreter_result)that); + return false; + } + + public boolean equals(createInterpreter_result that) { + if (that == null) + return false; + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(createInterpreter_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + createInterpreter_result typedOther = (createInterpreter_result)other; + + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("createInterpreter_result("); + boolean first = true; + + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class createInterpreter_resultStandardSchemeFactory implements SchemeFactory { + public createInterpreter_resultStandardScheme getScheme() { + return new createInterpreter_resultStandardScheme(); + } + } + + private static class createInterpreter_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, createInterpreter_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, createInterpreter_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class createInterpreter_resultTupleSchemeFactory implements SchemeFactory { + public createInterpreter_resultTupleScheme getScheme() { + return new createInterpreter_resultTupleScheme(); + } + } + + private static class createInterpreter_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, createInterpreter_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, createInterpreter_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + } + } + + } + + public static class open_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("open_args"); + + private static final org.apache.thrift.protocol.TField CLASS_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("className", org.apache.thrift.protocol.TType.STRING, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new open_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new open_argsTupleSchemeFactory()); + } + + public String className; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + CLASS_NAME((short)1, "className"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // CLASS_NAME + return CLASS_NAME; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.CLASS_NAME, new org.apache.thrift.meta_data.FieldMetaData("className", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(open_args.class, metaDataMap); + } + + public open_args() { + } + + public open_args( + String className) + { + this(); + this.className = className; + } + + /** + * Performs a deep copy on other. + */ + public open_args(open_args other) { + if (other.isSetClassName()) { + this.className = other.className; + } + } + + public open_args deepCopy() { + return new open_args(this); + } + + @Override + public void clear() { + this.className = null; + } + + public String getClassName() { + return this.className; + } + + public open_args setClassName(String className) { + this.className = className; + return this; + } + + public void unsetClassName() { + this.className = null; + } + + /** Returns true if field className is set (has been assigned a value) and false otherwise */ + public boolean isSetClassName() { + return this.className != null; + } + + public void setClassNameIsSet(boolean value) { + if (!value) { + this.className = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case CLASS_NAME: + if (value == null) { + unsetClassName(); + } else { + setClassName((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case CLASS_NAME: + return getClassName(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case CLASS_NAME: + return isSetClassName(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof open_args) + return this.equals((open_args)that); + return false; + } + + public boolean equals(open_args that) { + if (that == null) + return false; + + boolean this_present_className = true && this.isSetClassName(); + boolean that_present_className = true && that.isSetClassName(); + if (this_present_className || that_present_className) { + if (!(this_present_className && that_present_className)) + return false; + if (!this.className.equals(that.className)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(open_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + open_args typedOther = (open_args)other; + + lastComparison = Boolean.valueOf(isSetClassName()).compareTo(typedOther.isSetClassName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetClassName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.className, typedOther.className); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("open_args("); + boolean first = true; + + sb.append("className:"); + if (this.className == null) { + sb.append("null"); + } else { + sb.append(this.className); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class open_argsStandardSchemeFactory implements SchemeFactory { + public open_argsStandardScheme getScheme() { + return new open_argsStandardScheme(); + } + } + + private static class open_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, open_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // CLASS_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.className = iprot.readString(); + struct.setClassNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, open_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.className != null) { + oprot.writeFieldBegin(CLASS_NAME_FIELD_DESC); + oprot.writeString(struct.className); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class open_argsTupleSchemeFactory implements SchemeFactory { + public open_argsTupleScheme getScheme() { + return new open_argsTupleScheme(); + } + } + + private static class open_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, open_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetClassName()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetClassName()) { + oprot.writeString(struct.className); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, open_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.className = iprot.readString(); + struct.setClassNameIsSet(true); + } + } + } + + } + + public static class open_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("open_result"); + + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new open_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new open_resultTupleSchemeFactory()); + } + + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { +; + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(open_result.class, metaDataMap); + } + + public open_result() { + } + + /** + * Performs a deep copy on other. + */ + public open_result(open_result other) { + } + + public open_result deepCopy() { + return new open_result(this); + } + + @Override + public void clear() { + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof open_result) + return this.equals((open_result)that); + return false; + } + + public boolean equals(open_result that) { + if (that == null) + return false; + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(open_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + open_result typedOther = (open_result)other; + + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("open_result("); + boolean first = true; + + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class open_resultStandardSchemeFactory implements SchemeFactory { + public open_resultStandardScheme getScheme() { + return new open_resultStandardScheme(); + } + } + + private static class open_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, open_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, open_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class open_resultTupleSchemeFactory implements SchemeFactory { + public open_resultTupleScheme getScheme() { + return new open_resultTupleScheme(); + } + } + + private static class open_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, open_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, open_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + } + } + + } + + public static class close_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("close_args"); + + private static final org.apache.thrift.protocol.TField CLASS_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("className", org.apache.thrift.protocol.TType.STRING, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new close_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new close_argsTupleSchemeFactory()); + } + + public String className; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + CLASS_NAME((short)1, "className"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // CLASS_NAME + return CLASS_NAME; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.CLASS_NAME, new org.apache.thrift.meta_data.FieldMetaData("className", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(close_args.class, metaDataMap); + } + + public close_args() { + } + + public close_args( + String className) + { + this(); + this.className = className; + } + + /** + * Performs a deep copy on other. + */ + public close_args(close_args other) { + if (other.isSetClassName()) { + this.className = other.className; + } + } + + public close_args deepCopy() { + return new close_args(this); + } + + @Override + public void clear() { + this.className = null; + } + + public String getClassName() { + return this.className; + } + + public close_args setClassName(String className) { + this.className = className; + return this; + } + + public void unsetClassName() { + this.className = null; + } + + /** Returns true if field className is set (has been assigned a value) and false otherwise */ + public boolean isSetClassName() { + return this.className != null; + } + + public void setClassNameIsSet(boolean value) { + if (!value) { + this.className = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case CLASS_NAME: + if (value == null) { + unsetClassName(); + } else { + setClassName((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case CLASS_NAME: + return getClassName(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case CLASS_NAME: + return isSetClassName(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof close_args) + return this.equals((close_args)that); + return false; + } + + public boolean equals(close_args that) { + if (that == null) + return false; + + boolean this_present_className = true && this.isSetClassName(); + boolean that_present_className = true && that.isSetClassName(); + if (this_present_className || that_present_className) { + if (!(this_present_className && that_present_className)) + return false; + if (!this.className.equals(that.className)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(close_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + close_args typedOther = (close_args)other; + + lastComparison = Boolean.valueOf(isSetClassName()).compareTo(typedOther.isSetClassName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetClassName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.className, typedOther.className); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("close_args("); + boolean first = true; + + sb.append("className:"); + if (this.className == null) { + sb.append("null"); + } else { + sb.append(this.className); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class close_argsStandardSchemeFactory implements SchemeFactory { + public close_argsStandardScheme getScheme() { + return new close_argsStandardScheme(); + } + } + + private static class close_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, close_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // CLASS_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.className = iprot.readString(); + struct.setClassNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, close_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.className != null) { + oprot.writeFieldBegin(CLASS_NAME_FIELD_DESC); + oprot.writeString(struct.className); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class close_argsTupleSchemeFactory implements SchemeFactory { + public close_argsTupleScheme getScheme() { + return new close_argsTupleScheme(); + } + } + + private static class close_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, close_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetClassName()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetClassName()) { + oprot.writeString(struct.className); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, close_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.className = iprot.readString(); + struct.setClassNameIsSet(true); + } + } + } + + } + + public static class close_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("close_result"); + + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new close_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new close_resultTupleSchemeFactory()); + } + + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { +; + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(close_result.class, metaDataMap); + } + + public close_result() { + } + + /** + * Performs a deep copy on other. + */ + public close_result(close_result other) { + } + + public close_result deepCopy() { + return new close_result(this); + } + + @Override + public void clear() { + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof close_result) + return this.equals((close_result)that); + return false; + } + + public boolean equals(close_result that) { + if (that == null) + return false; + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(close_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + close_result typedOther = (close_result)other; + + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("close_result("); + boolean first = true; + + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class close_resultStandardSchemeFactory implements SchemeFactory { + public close_resultStandardScheme getScheme() { + return new close_resultStandardScheme(); + } + } + + private static class close_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, close_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, close_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class close_resultTupleSchemeFactory implements SchemeFactory { + public close_resultTupleScheme getScheme() { + return new close_resultTupleScheme(); + } + } + + private static class close_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, close_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, close_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + } + } + + } + + public static class interpret_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("interpret_args"); + + private static final org.apache.thrift.protocol.TField CLASS_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("className", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField ST_FIELD_DESC = new org.apache.thrift.protocol.TField("st", org.apache.thrift.protocol.TType.STRING, (short)2); + private static final org.apache.thrift.protocol.TField INTERPRETER_CONTEXT_FIELD_DESC = new org.apache.thrift.protocol.TField("interpreterContext", org.apache.thrift.protocol.TType.STRUCT, (short)3); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new interpret_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new interpret_argsTupleSchemeFactory()); + } + + public String className; // required + public String st; // required + public RemoteInterpreterContext interpreterContext; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + CLASS_NAME((short)1, "className"), + ST((short)2, "st"), + INTERPRETER_CONTEXT((short)3, "interpreterContext"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // CLASS_NAME + return CLASS_NAME; + case 2: // ST + return ST; + case 3: // INTERPRETER_CONTEXT + return INTERPRETER_CONTEXT; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.CLASS_NAME, new org.apache.thrift.meta_data.FieldMetaData("className", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.ST, new org.apache.thrift.meta_data.FieldMetaData("st", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.INTERPRETER_CONTEXT, new org.apache.thrift.meta_data.FieldMetaData("interpreterContext", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, RemoteInterpreterContext.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(interpret_args.class, metaDataMap); + } + + public interpret_args() { + } + + public interpret_args( + String className, + String st, + RemoteInterpreterContext interpreterContext) + { + this(); + this.className = className; + this.st = st; + this.interpreterContext = interpreterContext; + } + + /** + * Performs a deep copy on other. + */ + public interpret_args(interpret_args other) { + if (other.isSetClassName()) { + this.className = other.className; + } + if (other.isSetSt()) { + this.st = other.st; + } + if (other.isSetInterpreterContext()) { + this.interpreterContext = new RemoteInterpreterContext(other.interpreterContext); + } + } + + public interpret_args deepCopy() { + return new interpret_args(this); + } + + @Override + public void clear() { + this.className = null; + this.st = null; + this.interpreterContext = null; + } + + public String getClassName() { + return this.className; + } + + public interpret_args setClassName(String className) { + this.className = className; + return this; + } + + public void unsetClassName() { + this.className = null; + } + + /** Returns true if field className is set (has been assigned a value) and false otherwise */ + public boolean isSetClassName() { + return this.className != null; + } + + public void setClassNameIsSet(boolean value) { + if (!value) { + this.className = null; + } + } + + public String getSt() { + return this.st; + } + + public interpret_args setSt(String st) { + this.st = st; + return this; + } + + public void unsetSt() { + this.st = null; + } + + /** Returns true if field st is set (has been assigned a value) and false otherwise */ + public boolean isSetSt() { + return this.st != null; + } + + public void setStIsSet(boolean value) { + if (!value) { + this.st = null; + } + } + + public RemoteInterpreterContext getInterpreterContext() { + return this.interpreterContext; + } + + public interpret_args setInterpreterContext(RemoteInterpreterContext interpreterContext) { + this.interpreterContext = interpreterContext; + return this; + } + + public void unsetInterpreterContext() { + this.interpreterContext = null; + } + + /** Returns true if field interpreterContext is set (has been assigned a value) and false otherwise */ + public boolean isSetInterpreterContext() { + return this.interpreterContext != null; + } + + public void setInterpreterContextIsSet(boolean value) { + if (!value) { + this.interpreterContext = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case CLASS_NAME: + if (value == null) { + unsetClassName(); + } else { + setClassName((String)value); + } + break; + + case ST: + if (value == null) { + unsetSt(); + } else { + setSt((String)value); + } + break; + + case INTERPRETER_CONTEXT: + if (value == null) { + unsetInterpreterContext(); + } else { + setInterpreterContext((RemoteInterpreterContext)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case CLASS_NAME: + return getClassName(); + + case ST: + return getSt(); + + case INTERPRETER_CONTEXT: + return getInterpreterContext(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case CLASS_NAME: + return isSetClassName(); + case ST: + return isSetSt(); + case INTERPRETER_CONTEXT: + return isSetInterpreterContext(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof interpret_args) + return this.equals((interpret_args)that); + return false; + } + + public boolean equals(interpret_args that) { + if (that == null) + return false; + + boolean this_present_className = true && this.isSetClassName(); + boolean that_present_className = true && that.isSetClassName(); + if (this_present_className || that_present_className) { + if (!(this_present_className && that_present_className)) + return false; + if (!this.className.equals(that.className)) + return false; + } + + boolean this_present_st = true && this.isSetSt(); + boolean that_present_st = true && that.isSetSt(); + if (this_present_st || that_present_st) { + if (!(this_present_st && that_present_st)) + return false; + if (!this.st.equals(that.st)) + return false; + } + + boolean this_present_interpreterContext = true && this.isSetInterpreterContext(); + boolean that_present_interpreterContext = true && that.isSetInterpreterContext(); + if (this_present_interpreterContext || that_present_interpreterContext) { + if (!(this_present_interpreterContext && that_present_interpreterContext)) + return false; + if (!this.interpreterContext.equals(that.interpreterContext)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(interpret_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + interpret_args typedOther = (interpret_args)other; + + lastComparison = Boolean.valueOf(isSetClassName()).compareTo(typedOther.isSetClassName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetClassName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.className, typedOther.className); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetSt()).compareTo(typedOther.isSetSt()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSt()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.st, typedOther.st); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetInterpreterContext()).compareTo(typedOther.isSetInterpreterContext()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetInterpreterContext()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.interpreterContext, typedOther.interpreterContext); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("interpret_args("); + boolean first = true; + + sb.append("className:"); + if (this.className == null) { + sb.append("null"); + } else { + sb.append(this.className); + } + first = false; + if (!first) sb.append(", "); + sb.append("st:"); + if (this.st == null) { + sb.append("null"); + } else { + sb.append(this.st); + } + first = false; + if (!first) sb.append(", "); + sb.append("interpreterContext:"); + if (this.interpreterContext == null) { + sb.append("null"); + } else { + sb.append(this.interpreterContext); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + if (interpreterContext != null) { + interpreterContext.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class interpret_argsStandardSchemeFactory implements SchemeFactory { + public interpret_argsStandardScheme getScheme() { + return new interpret_argsStandardScheme(); + } + } + + private static class interpret_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, interpret_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // CLASS_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.className = iprot.readString(); + struct.setClassNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // ST + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.st = iprot.readString(); + struct.setStIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // INTERPRETER_CONTEXT + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.interpreterContext = new RemoteInterpreterContext(); + struct.interpreterContext.read(iprot); + struct.setInterpreterContextIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, interpret_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.className != null) { + oprot.writeFieldBegin(CLASS_NAME_FIELD_DESC); + oprot.writeString(struct.className); + oprot.writeFieldEnd(); + } + if (struct.st != null) { + oprot.writeFieldBegin(ST_FIELD_DESC); + oprot.writeString(struct.st); + oprot.writeFieldEnd(); + } + if (struct.interpreterContext != null) { + oprot.writeFieldBegin(INTERPRETER_CONTEXT_FIELD_DESC); + struct.interpreterContext.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class interpret_argsTupleSchemeFactory implements SchemeFactory { + public interpret_argsTupleScheme getScheme() { + return new interpret_argsTupleScheme(); + } + } + + private static class interpret_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, interpret_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetClassName()) { + optionals.set(0); + } + if (struct.isSetSt()) { + optionals.set(1); + } + if (struct.isSetInterpreterContext()) { + optionals.set(2); + } + oprot.writeBitSet(optionals, 3); + if (struct.isSetClassName()) { + oprot.writeString(struct.className); + } + if (struct.isSetSt()) { + oprot.writeString(struct.st); + } + if (struct.isSetInterpreterContext()) { + struct.interpreterContext.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, interpret_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(3); + if (incoming.get(0)) { + struct.className = iprot.readString(); + struct.setClassNameIsSet(true); + } + if (incoming.get(1)) { + struct.st = iprot.readString(); + struct.setStIsSet(true); + } + if (incoming.get(2)) { + struct.interpreterContext = new RemoteInterpreterContext(); + struct.interpreterContext.read(iprot); + struct.setInterpreterContextIsSet(true); + } + } + } + + } + + public static class interpret_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("interpret_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new interpret_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new interpret_resultTupleSchemeFactory()); + } + + public RemoteInterpreterResult success; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, RemoteInterpreterResult.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(interpret_result.class, metaDataMap); + } + + public interpret_result() { + } + + public interpret_result( + RemoteInterpreterResult success) + { + this(); + this.success = success; + } + + /** + * Performs a deep copy on other. + */ + public interpret_result(interpret_result other) { + if (other.isSetSuccess()) { + this.success = new RemoteInterpreterResult(other.success); + } + } + + public interpret_result deepCopy() { + return new interpret_result(this); + } + + @Override + public void clear() { + this.success = null; + } + + public RemoteInterpreterResult getSuccess() { + return this.success; + } + + public interpret_result setSuccess(RemoteInterpreterResult success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((RemoteInterpreterResult)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof interpret_result) + return this.equals((interpret_result)that); + return false; + } + + public boolean equals(interpret_result that) { + if (that == null) + return false; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(interpret_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + interpret_result typedOther = (interpret_result)other; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, typedOther.success); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("interpret_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + if (success != null) { + success.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class interpret_resultStandardSchemeFactory implements SchemeFactory { + public interpret_resultStandardScheme getScheme() { + return new interpret_resultStandardScheme(); + } + } + + private static class interpret_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, interpret_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.success = new RemoteInterpreterResult(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, interpret_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + struct.success.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class interpret_resultTupleSchemeFactory implements SchemeFactory { + public interpret_resultTupleScheme getScheme() { + return new interpret_resultTupleScheme(); + } + } + + private static class interpret_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, interpret_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + struct.success.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, interpret_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.success = new RemoteInterpreterResult(); + struct.success.read(iprot); + struct.setSuccessIsSet(true); + } + } + } + + } + + public static class cancel_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("cancel_args"); + + private static final org.apache.thrift.protocol.TField CLASS_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("className", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField INTERPRETER_CONTEXT_FIELD_DESC = new org.apache.thrift.protocol.TField("interpreterContext", org.apache.thrift.protocol.TType.STRUCT, (short)2); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new cancel_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new cancel_argsTupleSchemeFactory()); + } + + public String className; // required + public RemoteInterpreterContext interpreterContext; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + CLASS_NAME((short)1, "className"), + INTERPRETER_CONTEXT((short)2, "interpreterContext"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // CLASS_NAME + return CLASS_NAME; + case 2: // INTERPRETER_CONTEXT + return INTERPRETER_CONTEXT; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.CLASS_NAME, new org.apache.thrift.meta_data.FieldMetaData("className", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.INTERPRETER_CONTEXT, new org.apache.thrift.meta_data.FieldMetaData("interpreterContext", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, RemoteInterpreterContext.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(cancel_args.class, metaDataMap); + } + + public cancel_args() { + } + + public cancel_args( + String className, + RemoteInterpreterContext interpreterContext) + { + this(); + this.className = className; + this.interpreterContext = interpreterContext; + } + + /** + * Performs a deep copy on other. + */ + public cancel_args(cancel_args other) { + if (other.isSetClassName()) { + this.className = other.className; + } + if (other.isSetInterpreterContext()) { + this.interpreterContext = new RemoteInterpreterContext(other.interpreterContext); + } + } + + public cancel_args deepCopy() { + return new cancel_args(this); + } + + @Override + public void clear() { + this.className = null; + this.interpreterContext = null; + } + + public String getClassName() { + return this.className; + } + + public cancel_args setClassName(String className) { + this.className = className; + return this; + } + + public void unsetClassName() { + this.className = null; + } + + /** Returns true if field className is set (has been assigned a value) and false otherwise */ + public boolean isSetClassName() { + return this.className != null; + } + + public void setClassNameIsSet(boolean value) { + if (!value) { + this.className = null; + } + } + + public RemoteInterpreterContext getInterpreterContext() { + return this.interpreterContext; + } + + public cancel_args setInterpreterContext(RemoteInterpreterContext interpreterContext) { + this.interpreterContext = interpreterContext; + return this; + } + + public void unsetInterpreterContext() { + this.interpreterContext = null; + } + + /** Returns true if field interpreterContext is set (has been assigned a value) and false otherwise */ + public boolean isSetInterpreterContext() { + return this.interpreterContext != null; + } + + public void setInterpreterContextIsSet(boolean value) { + if (!value) { + this.interpreterContext = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case CLASS_NAME: + if (value == null) { + unsetClassName(); + } else { + setClassName((String)value); + } + break; + + case INTERPRETER_CONTEXT: + if (value == null) { + unsetInterpreterContext(); + } else { + setInterpreterContext((RemoteInterpreterContext)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case CLASS_NAME: + return getClassName(); + + case INTERPRETER_CONTEXT: + return getInterpreterContext(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case CLASS_NAME: + return isSetClassName(); + case INTERPRETER_CONTEXT: + return isSetInterpreterContext(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof cancel_args) + return this.equals((cancel_args)that); + return false; + } + + public boolean equals(cancel_args that) { + if (that == null) + return false; + + boolean this_present_className = true && this.isSetClassName(); + boolean that_present_className = true && that.isSetClassName(); + if (this_present_className || that_present_className) { + if (!(this_present_className && that_present_className)) + return false; + if (!this.className.equals(that.className)) + return false; + } + + boolean this_present_interpreterContext = true && this.isSetInterpreterContext(); + boolean that_present_interpreterContext = true && that.isSetInterpreterContext(); + if (this_present_interpreterContext || that_present_interpreterContext) { + if (!(this_present_interpreterContext && that_present_interpreterContext)) + return false; + if (!this.interpreterContext.equals(that.interpreterContext)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(cancel_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + cancel_args typedOther = (cancel_args)other; + + lastComparison = Boolean.valueOf(isSetClassName()).compareTo(typedOther.isSetClassName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetClassName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.className, typedOther.className); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetInterpreterContext()).compareTo(typedOther.isSetInterpreterContext()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetInterpreterContext()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.interpreterContext, typedOther.interpreterContext); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("cancel_args("); + boolean first = true; + + sb.append("className:"); + if (this.className == null) { + sb.append("null"); + } else { + sb.append(this.className); + } + first = false; + if (!first) sb.append(", "); + sb.append("interpreterContext:"); + if (this.interpreterContext == null) { + sb.append("null"); + } else { + sb.append(this.interpreterContext); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + if (interpreterContext != null) { + interpreterContext.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class cancel_argsStandardSchemeFactory implements SchemeFactory { + public cancel_argsStandardScheme getScheme() { + return new cancel_argsStandardScheme(); + } + } + + private static class cancel_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, cancel_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // CLASS_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.className = iprot.readString(); + struct.setClassNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // INTERPRETER_CONTEXT + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.interpreterContext = new RemoteInterpreterContext(); + struct.interpreterContext.read(iprot); + struct.setInterpreterContextIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, cancel_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.className != null) { + oprot.writeFieldBegin(CLASS_NAME_FIELD_DESC); + oprot.writeString(struct.className); + oprot.writeFieldEnd(); + } + if (struct.interpreterContext != null) { + oprot.writeFieldBegin(INTERPRETER_CONTEXT_FIELD_DESC); + struct.interpreterContext.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class cancel_argsTupleSchemeFactory implements SchemeFactory { + public cancel_argsTupleScheme getScheme() { + return new cancel_argsTupleScheme(); + } + } + + private static class cancel_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, cancel_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetClassName()) { + optionals.set(0); + } + if (struct.isSetInterpreterContext()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); + if (struct.isSetClassName()) { + oprot.writeString(struct.className); + } + if (struct.isSetInterpreterContext()) { + struct.interpreterContext.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, cancel_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(2); + if (incoming.get(0)) { + struct.className = iprot.readString(); + struct.setClassNameIsSet(true); + } + if (incoming.get(1)) { + struct.interpreterContext = new RemoteInterpreterContext(); + struct.interpreterContext.read(iprot); + struct.setInterpreterContextIsSet(true); + } + } + } + + } + + public static class cancel_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("cancel_result"); + + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new cancel_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new cancel_resultTupleSchemeFactory()); + } + + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { +; + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(cancel_result.class, metaDataMap); + } + + public cancel_result() { + } + + /** + * Performs a deep copy on other. + */ + public cancel_result(cancel_result other) { + } + + public cancel_result deepCopy() { + return new cancel_result(this); + } + + @Override + public void clear() { + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof cancel_result) + return this.equals((cancel_result)that); + return false; + } + + public boolean equals(cancel_result that) { + if (that == null) + return false; + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(cancel_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + cancel_result typedOther = (cancel_result)other; + + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("cancel_result("); + boolean first = true; + + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class cancel_resultStandardSchemeFactory implements SchemeFactory { + public cancel_resultStandardScheme getScheme() { + return new cancel_resultStandardScheme(); + } + } + + private static class cancel_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, cancel_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, cancel_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class cancel_resultTupleSchemeFactory implements SchemeFactory { + public cancel_resultTupleScheme getScheme() { + return new cancel_resultTupleScheme(); + } + } + + private static class cancel_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, cancel_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, cancel_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + } + } + + } + + public static class getProgress_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getProgress_args"); + + private static final org.apache.thrift.protocol.TField CLASS_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("className", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField INTERPRETER_CONTEXT_FIELD_DESC = new org.apache.thrift.protocol.TField("interpreterContext", org.apache.thrift.protocol.TType.STRUCT, (short)2); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new getProgress_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new getProgress_argsTupleSchemeFactory()); + } + + public String className; // required + public RemoteInterpreterContext interpreterContext; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + CLASS_NAME((short)1, "className"), + INTERPRETER_CONTEXT((short)2, "interpreterContext"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // CLASS_NAME + return CLASS_NAME; + case 2: // INTERPRETER_CONTEXT + return INTERPRETER_CONTEXT; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.CLASS_NAME, new org.apache.thrift.meta_data.FieldMetaData("className", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.INTERPRETER_CONTEXT, new org.apache.thrift.meta_data.FieldMetaData("interpreterContext", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, RemoteInterpreterContext.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getProgress_args.class, metaDataMap); + } + + public getProgress_args() { + } + + public getProgress_args( + String className, + RemoteInterpreterContext interpreterContext) + { + this(); + this.className = className; + this.interpreterContext = interpreterContext; + } + + /** + * Performs a deep copy on other. + */ + public getProgress_args(getProgress_args other) { + if (other.isSetClassName()) { + this.className = other.className; + } + if (other.isSetInterpreterContext()) { + this.interpreterContext = new RemoteInterpreterContext(other.interpreterContext); + } + } + + public getProgress_args deepCopy() { + return new getProgress_args(this); + } + + @Override + public void clear() { + this.className = null; + this.interpreterContext = null; + } + + public String getClassName() { + return this.className; + } + + public getProgress_args setClassName(String className) { + this.className = className; + return this; + } + + public void unsetClassName() { + this.className = null; + } + + /** Returns true if field className is set (has been assigned a value) and false otherwise */ + public boolean isSetClassName() { + return this.className != null; + } + + public void setClassNameIsSet(boolean value) { + if (!value) { + this.className = null; + } + } + + public RemoteInterpreterContext getInterpreterContext() { + return this.interpreterContext; + } + + public getProgress_args setInterpreterContext(RemoteInterpreterContext interpreterContext) { + this.interpreterContext = interpreterContext; + return this; + } + + public void unsetInterpreterContext() { + this.interpreterContext = null; + } + + /** Returns true if field interpreterContext is set (has been assigned a value) and false otherwise */ + public boolean isSetInterpreterContext() { + return this.interpreterContext != null; + } + + public void setInterpreterContextIsSet(boolean value) { + if (!value) { + this.interpreterContext = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case CLASS_NAME: + if (value == null) { + unsetClassName(); + } else { + setClassName((String)value); + } + break; + + case INTERPRETER_CONTEXT: + if (value == null) { + unsetInterpreterContext(); + } else { + setInterpreterContext((RemoteInterpreterContext)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case CLASS_NAME: + return getClassName(); + + case INTERPRETER_CONTEXT: + return getInterpreterContext(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case CLASS_NAME: + return isSetClassName(); + case INTERPRETER_CONTEXT: + return isSetInterpreterContext(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof getProgress_args) + return this.equals((getProgress_args)that); + return false; + } + + public boolean equals(getProgress_args that) { + if (that == null) + return false; + + boolean this_present_className = true && this.isSetClassName(); + boolean that_present_className = true && that.isSetClassName(); + if (this_present_className || that_present_className) { + if (!(this_present_className && that_present_className)) + return false; + if (!this.className.equals(that.className)) + return false; + } + + boolean this_present_interpreterContext = true && this.isSetInterpreterContext(); + boolean that_present_interpreterContext = true && that.isSetInterpreterContext(); + if (this_present_interpreterContext || that_present_interpreterContext) { + if (!(this_present_interpreterContext && that_present_interpreterContext)) + return false; + if (!this.interpreterContext.equals(that.interpreterContext)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(getProgress_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + getProgress_args typedOther = (getProgress_args)other; + + lastComparison = Boolean.valueOf(isSetClassName()).compareTo(typedOther.isSetClassName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetClassName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.className, typedOther.className); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetInterpreterContext()).compareTo(typedOther.isSetInterpreterContext()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetInterpreterContext()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.interpreterContext, typedOther.interpreterContext); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("getProgress_args("); + boolean first = true; + + sb.append("className:"); + if (this.className == null) { + sb.append("null"); + } else { + sb.append(this.className); + } + first = false; + if (!first) sb.append(", "); + sb.append("interpreterContext:"); + if (this.interpreterContext == null) { + sb.append("null"); + } else { + sb.append(this.interpreterContext); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + if (interpreterContext != null) { + interpreterContext.validate(); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class getProgress_argsStandardSchemeFactory implements SchemeFactory { + public getProgress_argsStandardScheme getScheme() { + return new getProgress_argsStandardScheme(); + } + } + + private static class getProgress_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, getProgress_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // CLASS_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.className = iprot.readString(); + struct.setClassNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // INTERPRETER_CONTEXT + if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { + struct.interpreterContext = new RemoteInterpreterContext(); + struct.interpreterContext.read(iprot); + struct.setInterpreterContextIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, getProgress_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.className != null) { + oprot.writeFieldBegin(CLASS_NAME_FIELD_DESC); + oprot.writeString(struct.className); + oprot.writeFieldEnd(); + } + if (struct.interpreterContext != null) { + oprot.writeFieldBegin(INTERPRETER_CONTEXT_FIELD_DESC); + struct.interpreterContext.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class getProgress_argsTupleSchemeFactory implements SchemeFactory { + public getProgress_argsTupleScheme getScheme() { + return new getProgress_argsTupleScheme(); + } + } + + private static class getProgress_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, getProgress_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetClassName()) { + optionals.set(0); + } + if (struct.isSetInterpreterContext()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); + if (struct.isSetClassName()) { + oprot.writeString(struct.className); + } + if (struct.isSetInterpreterContext()) { + struct.interpreterContext.write(oprot); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, getProgress_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(2); + if (incoming.get(0)) { + struct.className = iprot.readString(); + struct.setClassNameIsSet(true); + } + if (incoming.get(1)) { + struct.interpreterContext = new RemoteInterpreterContext(); + struct.interpreterContext.read(iprot); + struct.setInterpreterContextIsSet(true); + } + } + } + + } + + public static class getProgress_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getProgress_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.I32, (short)0); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new getProgress_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new getProgress_resultTupleSchemeFactory()); + } + + public int success; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __SUCCESS_ISSET_ID = 0; + private byte __isset_bitfield = 0; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getProgress_result.class, metaDataMap); + } + + public getProgress_result() { + } + + public getProgress_result( + int success) + { + this(); + this.success = success; + setSuccessIsSet(true); + } + + /** + * Performs a deep copy on other. + */ + public getProgress_result(getProgress_result other) { + __isset_bitfield = other.__isset_bitfield; + this.success = other.success; + } + + public getProgress_result deepCopy() { + return new getProgress_result(this); + } + + @Override + public void clear() { + setSuccessIsSet(false); + this.success = 0; + } + + public int getSuccess() { + return this.success; + } + + public getProgress_result setSuccess(int success) { + this.success = success; + setSuccessIsSet(true); + return this; + } + + public void unsetSuccess() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __SUCCESS_ISSET_ID); + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return EncodingUtils.testBit(__isset_bitfield, __SUCCESS_ISSET_ID); + } + + public void setSuccessIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value); + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((Integer)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return Integer.valueOf(getSuccess()); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof getProgress_result) + return this.equals((getProgress_result)that); + return false; + } + + public boolean equals(getProgress_result that) { + if (that == null) + return false; + + boolean this_present_success = true; + boolean that_present_success = true; + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (this.success != that.success) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(getProgress_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + getProgress_result typedOther = (getProgress_result)other; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, typedOther.success); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("getProgress_result("); + boolean first = true; + + sb.append("success:"); + sb.append(this.success); + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class getProgress_resultStandardSchemeFactory implements SchemeFactory { + public getProgress_resultStandardScheme getScheme() { + return new getProgress_resultStandardScheme(); + } + } + + private static class getProgress_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, getProgress_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.success = iprot.readI32(); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, getProgress_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.isSetSuccess()) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + oprot.writeI32(struct.success); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class getProgress_resultTupleSchemeFactory implements SchemeFactory { + public getProgress_resultTupleScheme getScheme() { + return new getProgress_resultTupleScheme(); + } + } + + private static class getProgress_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, getProgress_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + oprot.writeI32(struct.success); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, getProgress_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.success = iprot.readI32(); + struct.setSuccessIsSet(true); + } + } + } + + } + + public static class getFormType_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getFormType_args"); + + private static final org.apache.thrift.protocol.TField CLASS_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("className", org.apache.thrift.protocol.TType.STRING, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new getFormType_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new getFormType_argsTupleSchemeFactory()); + } + + public String className; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + CLASS_NAME((short)1, "className"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // CLASS_NAME + return CLASS_NAME; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.CLASS_NAME, new org.apache.thrift.meta_data.FieldMetaData("className", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getFormType_args.class, metaDataMap); + } + + public getFormType_args() { + } + + public getFormType_args( + String className) + { + this(); + this.className = className; + } + + /** + * Performs a deep copy on other. + */ + public getFormType_args(getFormType_args other) { + if (other.isSetClassName()) { + this.className = other.className; + } + } + + public getFormType_args deepCopy() { + return new getFormType_args(this); + } + + @Override + public void clear() { + this.className = null; + } + + public String getClassName() { + return this.className; + } + + public getFormType_args setClassName(String className) { + this.className = className; + return this; + } + + public void unsetClassName() { + this.className = null; + } + + /** Returns true if field className is set (has been assigned a value) and false otherwise */ + public boolean isSetClassName() { + return this.className != null; + } + + public void setClassNameIsSet(boolean value) { + if (!value) { + this.className = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case CLASS_NAME: + if (value == null) { + unsetClassName(); + } else { + setClassName((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case CLASS_NAME: + return getClassName(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case CLASS_NAME: + return isSetClassName(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof getFormType_args) + return this.equals((getFormType_args)that); + return false; + } + + public boolean equals(getFormType_args that) { + if (that == null) + return false; + + boolean this_present_className = true && this.isSetClassName(); + boolean that_present_className = true && that.isSetClassName(); + if (this_present_className || that_present_className) { + if (!(this_present_className && that_present_className)) + return false; + if (!this.className.equals(that.className)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(getFormType_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + getFormType_args typedOther = (getFormType_args)other; + + lastComparison = Boolean.valueOf(isSetClassName()).compareTo(typedOther.isSetClassName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetClassName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.className, typedOther.className); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("getFormType_args("); + boolean first = true; + + sb.append("className:"); + if (this.className == null) { + sb.append("null"); + } else { + sb.append(this.className); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class getFormType_argsStandardSchemeFactory implements SchemeFactory { + public getFormType_argsStandardScheme getScheme() { + return new getFormType_argsStandardScheme(); + } + } + + private static class getFormType_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, getFormType_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // CLASS_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.className = iprot.readString(); + struct.setClassNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, getFormType_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.className != null) { + oprot.writeFieldBegin(CLASS_NAME_FIELD_DESC); + oprot.writeString(struct.className); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class getFormType_argsTupleSchemeFactory implements SchemeFactory { + public getFormType_argsTupleScheme getScheme() { + return new getFormType_argsTupleScheme(); + } + } + + private static class getFormType_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, getFormType_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetClassName()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetClassName()) { + oprot.writeString(struct.className); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, getFormType_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.className = iprot.readString(); + struct.setClassNameIsSet(true); + } + } + } + + } + + public static class getFormType_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getFormType_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRING, (short)0); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new getFormType_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new getFormType_resultTupleSchemeFactory()); + } + + public String success; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getFormType_result.class, metaDataMap); + } + + public getFormType_result() { + } + + public getFormType_result( + String success) + { + this(); + this.success = success; + } + + /** + * Performs a deep copy on other. + */ + public getFormType_result(getFormType_result other) { + if (other.isSetSuccess()) { + this.success = other.success; + } + } + + public getFormType_result deepCopy() { + return new getFormType_result(this); + } + + @Override + public void clear() { + this.success = null; + } + + public String getSuccess() { + return this.success; + } + + public getFormType_result setSuccess(String success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof getFormType_result) + return this.equals((getFormType_result)that); + return false; + } + + public boolean equals(getFormType_result that) { + if (that == null) + return false; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(getFormType_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + getFormType_result typedOther = (getFormType_result)other; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, typedOther.success); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("getFormType_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class getFormType_resultStandardSchemeFactory implements SchemeFactory { + public getFormType_resultStandardScheme getScheme() { + return new getFormType_resultStandardScheme(); + } + } + + private static class getFormType_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, getFormType_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.success = iprot.readString(); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, getFormType_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + oprot.writeString(struct.success); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class getFormType_resultTupleSchemeFactory implements SchemeFactory { + public getFormType_resultTupleScheme getScheme() { + return new getFormType_resultTupleScheme(); + } + } + + private static class getFormType_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, getFormType_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + oprot.writeString(struct.success); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, getFormType_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.success = iprot.readString(); + struct.setSuccessIsSet(true); + } + } + } + + } + + public static class completion_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("completion_args"); + + private static final org.apache.thrift.protocol.TField CLASS_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("className", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField BUF_FIELD_DESC = new org.apache.thrift.protocol.TField("buf", org.apache.thrift.protocol.TType.STRING, (short)2); + private static final org.apache.thrift.protocol.TField CURSOR_FIELD_DESC = new org.apache.thrift.protocol.TField("cursor", org.apache.thrift.protocol.TType.I32, (short)3); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new completion_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new completion_argsTupleSchemeFactory()); + } + + public String className; // required + public String buf; // required + public int cursor; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + CLASS_NAME((short)1, "className"), + BUF((short)2, "buf"), + CURSOR((short)3, "cursor"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // CLASS_NAME + return CLASS_NAME; + case 2: // BUF + return BUF; + case 3: // CURSOR + return CURSOR; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __CURSOR_ISSET_ID = 0; + private byte __isset_bitfield = 0; + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.CLASS_NAME, new org.apache.thrift.meta_data.FieldMetaData("className", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.BUF, new org.apache.thrift.meta_data.FieldMetaData("buf", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.CURSOR, new org.apache.thrift.meta_data.FieldMetaData("cursor", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(completion_args.class, metaDataMap); + } + + public completion_args() { + } + + public completion_args( + String className, + String buf, + int cursor) + { + this(); + this.className = className; + this.buf = buf; + this.cursor = cursor; + setCursorIsSet(true); + } + + /** + * Performs a deep copy on other. + */ + public completion_args(completion_args other) { + __isset_bitfield = other.__isset_bitfield; + if (other.isSetClassName()) { + this.className = other.className; + } + if (other.isSetBuf()) { + this.buf = other.buf; + } + this.cursor = other.cursor; + } + + public completion_args deepCopy() { + return new completion_args(this); + } + + @Override + public void clear() { + this.className = null; + this.buf = null; + setCursorIsSet(false); + this.cursor = 0; + } + + public String getClassName() { + return this.className; + } + + public completion_args setClassName(String className) { + this.className = className; + return this; + } + + public void unsetClassName() { + this.className = null; + } + + /** Returns true if field className is set (has been assigned a value) and false otherwise */ + public boolean isSetClassName() { + return this.className != null; + } + + public void setClassNameIsSet(boolean value) { + if (!value) { + this.className = null; + } + } + + public String getBuf() { + return this.buf; + } + + public completion_args setBuf(String buf) { + this.buf = buf; + return this; + } + + public void unsetBuf() { + this.buf = null; + } + + /** Returns true if field buf is set (has been assigned a value) and false otherwise */ + public boolean isSetBuf() { + return this.buf != null; + } + + public void setBufIsSet(boolean value) { + if (!value) { + this.buf = null; + } + } + + public int getCursor() { + return this.cursor; + } + + public completion_args setCursor(int cursor) { + this.cursor = cursor; + setCursorIsSet(true); + return this; + } + + public void unsetCursor() { + __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __CURSOR_ISSET_ID); + } + + /** Returns true if field cursor is set (has been assigned a value) and false otherwise */ + public boolean isSetCursor() { + return EncodingUtils.testBit(__isset_bitfield, __CURSOR_ISSET_ID); + } + + public void setCursorIsSet(boolean value) { + __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __CURSOR_ISSET_ID, value); + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case CLASS_NAME: + if (value == null) { + unsetClassName(); + } else { + setClassName((String)value); + } + break; + + case BUF: + if (value == null) { + unsetBuf(); + } else { + setBuf((String)value); + } + break; + + case CURSOR: + if (value == null) { + unsetCursor(); + } else { + setCursor((Integer)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case CLASS_NAME: + return getClassName(); + + case BUF: + return getBuf(); + + case CURSOR: + return Integer.valueOf(getCursor()); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case CLASS_NAME: + return isSetClassName(); + case BUF: + return isSetBuf(); + case CURSOR: + return isSetCursor(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof completion_args) + return this.equals((completion_args)that); + return false; + } + + public boolean equals(completion_args that) { + if (that == null) + return false; + + boolean this_present_className = true && this.isSetClassName(); + boolean that_present_className = true && that.isSetClassName(); + if (this_present_className || that_present_className) { + if (!(this_present_className && that_present_className)) + return false; + if (!this.className.equals(that.className)) + return false; + } + + boolean this_present_buf = true && this.isSetBuf(); + boolean that_present_buf = true && that.isSetBuf(); + if (this_present_buf || that_present_buf) { + if (!(this_present_buf && that_present_buf)) + return false; + if (!this.buf.equals(that.buf)) + return false; + } + + boolean this_present_cursor = true; + boolean that_present_cursor = true; + if (this_present_cursor || that_present_cursor) { + if (!(this_present_cursor && that_present_cursor)) + return false; + if (this.cursor != that.cursor) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(completion_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + completion_args typedOther = (completion_args)other; + + lastComparison = Boolean.valueOf(isSetClassName()).compareTo(typedOther.isSetClassName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetClassName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.className, typedOther.className); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetBuf()).compareTo(typedOther.isSetBuf()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetBuf()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.buf, typedOther.buf); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetCursor()).compareTo(typedOther.isSetCursor()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCursor()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.cursor, typedOther.cursor); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("completion_args("); + boolean first = true; + + sb.append("className:"); + if (this.className == null) { + sb.append("null"); + } else { + sb.append(this.className); + } + first = false; + if (!first) sb.append(", "); + sb.append("buf:"); + if (this.buf == null) { + sb.append("null"); + } else { + sb.append(this.buf); + } + first = false; + if (!first) sb.append(", "); + sb.append("cursor:"); + sb.append(this.cursor); + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class completion_argsStandardSchemeFactory implements SchemeFactory { + public completion_argsStandardScheme getScheme() { + return new completion_argsStandardScheme(); + } + } + + private static class completion_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, completion_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // CLASS_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.className = iprot.readString(); + struct.setClassNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // BUF + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.buf = iprot.readString(); + struct.setBufIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 3: // CURSOR + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.cursor = iprot.readI32(); + struct.setCursorIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, completion_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.className != null) { + oprot.writeFieldBegin(CLASS_NAME_FIELD_DESC); + oprot.writeString(struct.className); + oprot.writeFieldEnd(); + } + if (struct.buf != null) { + oprot.writeFieldBegin(BUF_FIELD_DESC); + oprot.writeString(struct.buf); + oprot.writeFieldEnd(); + } + oprot.writeFieldBegin(CURSOR_FIELD_DESC); + oprot.writeI32(struct.cursor); + oprot.writeFieldEnd(); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class completion_argsTupleSchemeFactory implements SchemeFactory { + public completion_argsTupleScheme getScheme() { + return new completion_argsTupleScheme(); + } + } + + private static class completion_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, completion_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetClassName()) { + optionals.set(0); + } + if (struct.isSetBuf()) { + optionals.set(1); + } + if (struct.isSetCursor()) { + optionals.set(2); + } + oprot.writeBitSet(optionals, 3); + if (struct.isSetClassName()) { + oprot.writeString(struct.className); + } + if (struct.isSetBuf()) { + oprot.writeString(struct.buf); + } + if (struct.isSetCursor()) { + oprot.writeI32(struct.cursor); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, completion_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(3); + if (incoming.get(0)) { + struct.className = iprot.readString(); + struct.setClassNameIsSet(true); + } + if (incoming.get(1)) { + struct.buf = iprot.readString(); + struct.setBufIsSet(true); + } + if (incoming.get(2)) { + struct.cursor = iprot.readI32(); + struct.setCursorIsSet(true); + } + } + } + + } + + public static class completion_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("completion_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.LIST, (short)0); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new completion_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new completion_resultTupleSchemeFactory()); + } + + public List success; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(completion_result.class, metaDataMap); + } + + public completion_result() { + } + + public completion_result( + List success) + { + this(); + this.success = success; + } + + /** + * Performs a deep copy on other. + */ + public completion_result(completion_result other) { + if (other.isSetSuccess()) { + List __this__success = new ArrayList(); + for (String other_element : other.success) { + __this__success.add(other_element); + } + this.success = __this__success; + } + } + + public completion_result deepCopy() { + return new completion_result(this); + } + + @Override + public void clear() { + this.success = null; + } + + public int getSuccessSize() { + return (this.success == null) ? 0 : this.success.size(); + } + + public java.util.Iterator getSuccessIterator() { + return (this.success == null) ? null : this.success.iterator(); + } + + public void addToSuccess(String elem) { + if (this.success == null) { + this.success = new ArrayList(); + } + this.success.add(elem); + } + + public List getSuccess() { + return this.success; + } + + public completion_result setSuccess(List success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((List)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof completion_result) + return this.equals((completion_result)that); + return false; + } + + public boolean equals(completion_result that) { + if (that == null) + return false; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(completion_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + completion_result typedOther = (completion_result)other; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, typedOther.success); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("completion_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class completion_resultStandardSchemeFactory implements SchemeFactory { + public completion_resultStandardScheme getScheme() { + return new completion_resultStandardScheme(); + } + } + + private static class completion_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, completion_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list10 = iprot.readListBegin(); + struct.success = new ArrayList(_list10.size); + for (int _i11 = 0; _i11 < _list10.size; ++_i11) + { + String _elem12; // required + _elem12 = iprot.readString(); + struct.success.add(_elem12); + } + iprot.readListEnd(); + } + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, completion_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, struct.success.size())); + for (String _iter13 : struct.success) + { + oprot.writeString(_iter13); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class completion_resultTupleSchemeFactory implements SchemeFactory { + public completion_resultTupleScheme getScheme() { + return new completion_resultTupleScheme(); + } + } + + private static class completion_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, completion_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + { + oprot.writeI32(struct.success.size()); + for (String _iter14 : struct.success) + { + oprot.writeString(_iter14); + } + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, completion_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + { + org.apache.thrift.protocol.TList _list15 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, iprot.readI32()); + struct.success = new ArrayList(_list15.size); + for (int _i16 = 0; _i16 < _list15.size; ++_i16) + { + String _elem17; // required + _elem17 = iprot.readString(); + struct.success.add(_elem17); + } + } + struct.setSuccessIsSet(true); + } + } + } + + } + + public static class shutdown_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("shutdown_args"); + + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new shutdown_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new shutdown_argsTupleSchemeFactory()); + } + + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { +; + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(shutdown_args.class, metaDataMap); + } + + public shutdown_args() { + } + + /** + * Performs a deep copy on other. + */ + public shutdown_args(shutdown_args other) { + } + + public shutdown_args deepCopy() { + return new shutdown_args(this); + } + + @Override + public void clear() { + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof shutdown_args) + return this.equals((shutdown_args)that); + return false; + } + + public boolean equals(shutdown_args that) { + if (that == null) + return false; + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(shutdown_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + shutdown_args typedOther = (shutdown_args)other; + + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("shutdown_args("); + boolean first = true; + + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class shutdown_argsStandardSchemeFactory implements SchemeFactory { + public shutdown_argsStandardScheme getScheme() { + return new shutdown_argsStandardScheme(); + } + } + + private static class shutdown_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, shutdown_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, shutdown_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class shutdown_argsTupleSchemeFactory implements SchemeFactory { + public shutdown_argsTupleScheme getScheme() { + return new shutdown_argsTupleScheme(); + } + } + + private static class shutdown_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, shutdown_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, shutdown_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + } + } + + } + + public static class shutdown_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("shutdown_result"); + + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new shutdown_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new shutdown_resultTupleSchemeFactory()); + } + + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { +; + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(shutdown_result.class, metaDataMap); + } + + public shutdown_result() { + } + + /** + * Performs a deep copy on other. + */ + public shutdown_result(shutdown_result other) { + } + + public shutdown_result deepCopy() { + return new shutdown_result(this); + } + + @Override + public void clear() { + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof shutdown_result) + return this.equals((shutdown_result)that); + return false; + } + + public boolean equals(shutdown_result that) { + if (that == null) + return false; + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(shutdown_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + shutdown_result typedOther = (shutdown_result)other; + + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("shutdown_result("); + boolean first = true; + + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class shutdown_resultStandardSchemeFactory implements SchemeFactory { + public shutdown_resultStandardScheme getScheme() { + return new shutdown_resultStandardScheme(); + } + } + + private static class shutdown_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, shutdown_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, shutdown_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class shutdown_resultTupleSchemeFactory implements SchemeFactory { + public shutdown_resultTupleScheme getScheme() { + return new shutdown_resultTupleScheme(); + } + } + + private static class shutdown_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, shutdown_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, shutdown_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + } + } + + } + + public static class getStatus_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getStatus_args"); + + private static final org.apache.thrift.protocol.TField JOB_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("jobId", org.apache.thrift.protocol.TType.STRING, (short)1); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new getStatus_argsStandardSchemeFactory()); + schemes.put(TupleScheme.class, new getStatus_argsTupleSchemeFactory()); + } + + public String jobId; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + JOB_ID((short)1, "jobId"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // JOB_ID + return JOB_ID; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.JOB_ID, new org.apache.thrift.meta_data.FieldMetaData("jobId", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getStatus_args.class, metaDataMap); + } + + public getStatus_args() { + } + + public getStatus_args( + String jobId) + { + this(); + this.jobId = jobId; + } + + /** + * Performs a deep copy on other. + */ + public getStatus_args(getStatus_args other) { + if (other.isSetJobId()) { + this.jobId = other.jobId; + } + } + + public getStatus_args deepCopy() { + return new getStatus_args(this); + } + + @Override + public void clear() { + this.jobId = null; + } + + public String getJobId() { + return this.jobId; + } + + public getStatus_args setJobId(String jobId) { + this.jobId = jobId; + return this; + } + + public void unsetJobId() { + this.jobId = null; + } + + /** Returns true if field jobId is set (has been assigned a value) and false otherwise */ + public boolean isSetJobId() { + return this.jobId != null; + } + + public void setJobIdIsSet(boolean value) { + if (!value) { + this.jobId = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case JOB_ID: + if (value == null) { + unsetJobId(); + } else { + setJobId((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case JOB_ID: + return getJobId(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case JOB_ID: + return isSetJobId(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof getStatus_args) + return this.equals((getStatus_args)that); + return false; + } + + public boolean equals(getStatus_args that) { + if (that == null) + return false; + + boolean this_present_jobId = true && this.isSetJobId(); + boolean that_present_jobId = true && that.isSetJobId(); + if (this_present_jobId || that_present_jobId) { + if (!(this_present_jobId && that_present_jobId)) + return false; + if (!this.jobId.equals(that.jobId)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(getStatus_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + getStatus_args typedOther = (getStatus_args)other; + + lastComparison = Boolean.valueOf(isSetJobId()).compareTo(typedOther.isSetJobId()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetJobId()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.jobId, typedOther.jobId); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("getStatus_args("); + boolean first = true; + + sb.append("jobId:"); + if (this.jobId == null) { + sb.append("null"); + } else { + sb.append(this.jobId); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class getStatus_argsStandardSchemeFactory implements SchemeFactory { + public getStatus_argsStandardScheme getScheme() { + return new getStatus_argsStandardScheme(); + } + } + + private static class getStatus_argsStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, getStatus_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // JOB_ID + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.jobId = iprot.readString(); + struct.setJobIdIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, getStatus_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.jobId != null) { + oprot.writeFieldBegin(JOB_ID_FIELD_DESC); + oprot.writeString(struct.jobId); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class getStatus_argsTupleSchemeFactory implements SchemeFactory { + public getStatus_argsTupleScheme getScheme() { + return new getStatus_argsTupleScheme(); + } + } + + private static class getStatus_argsTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, getStatus_args struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetJobId()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetJobId()) { + oprot.writeString(struct.jobId); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, getStatus_args struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.jobId = iprot.readString(); + struct.setJobIdIsSet(true); + } + } + } + + } + + public static class getStatus_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("getStatus_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRING, (short)0); + + private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>(); + static { + schemes.put(StandardScheme.class, new getStatus_resultStandardSchemeFactory()); + schemes.put(TupleScheme.class, new getStatus_resultTupleSchemeFactory()); + } + + public String success; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(getStatus_result.class, metaDataMap); + } + + public getStatus_result() { + } + + public getStatus_result( + String success) + { + this(); + this.success = success; + } + + /** + * Performs a deep copy on other. + */ + public getStatus_result(getStatus_result other) { + if (other.isSetSuccess()) { + this.success = other.success; + } + } + + public getStatus_result deepCopy() { + return new getStatus_result(this); + } + + @Override + public void clear() { + this.success = null; + } + + public String getSuccess() { + return this.success; + } + + public getStatus_result setSuccess(String success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof getStatus_result) + return this.equals((getStatus_result)that); + return false; + } + + public boolean equals(getStatus_result that) { + if (that == null) + return false; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + return 0; + } + + public int compareTo(getStatus_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + getStatus_result typedOther = (getStatus_result)other; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, typedOther.success); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + schemes.get(iprot.getScheme()).getScheme().read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + schemes.get(oprot.getScheme()).getScheme().write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("getStatus_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class getStatus_resultStandardSchemeFactory implements SchemeFactory { + public getStatus_resultStandardScheme getScheme() { + return new getStatus_resultStandardScheme(); + } + } + + private static class getStatus_resultStandardScheme extends StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, getStatus_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.success = iprot.readString(); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, getStatus_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + oprot.writeString(struct.success); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class getStatus_resultTupleSchemeFactory implements SchemeFactory { + public getStatus_resultTupleScheme getScheme() { + return new getStatus_resultTupleScheme(); + } + } + + private static class getStatus_resultTupleScheme extends TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, getStatus_result struct) throws org.apache.thrift.TException { + TTupleProtocol oprot = (TTupleProtocol) prot; + BitSet optionals = new BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + oprot.writeString(struct.success); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, getStatus_result struct) throws org.apache.thrift.TException { + TTupleProtocol iprot = (TTupleProtocol) prot; + BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.success = iprot.readString(); + struct.setSuccessIsSet(true); + } + } + } + + } + +} diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/scheduler/FIFOScheduler.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/scheduler/FIFOScheduler.java similarity index 73% rename from zeppelin-zengine/src/main/java/com/nflabs/zeppelin/scheduler/FIFOScheduler.java rename to zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/scheduler/FIFOScheduler.java index 13b23556..078cd3cd 100644 --- a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/scheduler/FIFOScheduler.java +++ b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/scheduler/FIFOScheduler.java @@ -9,7 +9,7 @@ /** * TODO(moon) : add description. - * + * * @author Leemoonsoo * */ @@ -27,10 +27,12 @@ public FIFOScheduler(String name, ExecutorService executor, SchedulerListener li this.listener = listener; } + @Override public String getName() { return name; } + @Override public Collection getJobsWaiting() { List ret = new LinkedList(); synchronized (queue) { @@ -41,6 +43,7 @@ public Collection getJobsWaiting() { return ret; } + @Override public Collection getJobsRunning() { List ret = new LinkedList(); Job job = runningJob; @@ -54,6 +57,7 @@ public Collection getJobsRunning() { + @Override public void submit(Job job) { job.setStatus(Status.PENDING); synchronized (queue) { @@ -62,6 +66,7 @@ public void submit(Job job) { } } + @Override public void run() { synchronized (queue) { @@ -78,14 +83,36 @@ public void run() { final Scheduler scheduler = this; this.executor.execute(new Runnable() { + @Override public void run() { + if (runningJob.isAborted()) { + runningJob.setStatus(Status.ABORT); + runningJob.aborted = false; + synchronized (queue) { + queue.notify(); + } + return; + } + + runningJob.setStatus(Status.RUNNING); if (listener != null) { listener.jobStarted(scheduler, runningJob); } runningJob.run(); + if (runningJob.isAborted()) { + runningJob.setStatus(Status.ABORT); + } else { + if (runningJob.getException() != null) { + runningJob.setStatus(Status.ERROR); + } else { + runningJob.setStatus(Status.FINISHED); + } + } if (listener != null) { listener.jobFinished(scheduler, runningJob); } + // reset aborted flag to allow retry + runningJob.aborted = false; runningJob = null; synchronized (queue) { queue.notify(); @@ -96,6 +123,7 @@ public void run() { } } + @Override public void stop() { terminate = true; synchronized (queue) { diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/scheduler/Job.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/scheduler/Job.java similarity index 92% rename from zeppelin-zengine/src/main/java/com/nflabs/zeppelin/scheduler/Job.java rename to zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/scheduler/Job.java index 0ca73f8b..00465b36 100644 --- a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/scheduler/Job.java +++ b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/scheduler/Job.java @@ -14,11 +14,11 @@ * - should be run on a separate thread * - maintains internal state: it's status * - supports listeners who are updated on status change - * + * * Job class is serialized/deserialized and used server<->client communication * and saving/loading jobs from disk. * Changing/adding/deleting non transitive field name need consideration of that. - * + * * @author Leemoonsoo */ public abstract class Job { @@ -68,10 +68,6 @@ boolean isPending() { private transient JobListener listener; private long progressUpdateIntervalMs; - public Job(String jobName, JobListener listener) { - this(jobName, listener, JobProgressPoller.DEFAULT_INTERVAL_MSEC); - } - public Job(String jobName, JobListener listener, long progressUpdateIntervalMs) { this.jobName = jobName; this.listener = listener; @@ -84,14 +80,30 @@ public Job(String jobName, JobListener listener, long progressUpdateIntervalMs) setStatus(Status.READY); } + public Job(String jobName, JobListener listener) { + this(jobName, listener, JobProgressPoller.DEFAULT_INTERVAL_MSEC); + } + + public Job(String jobId, String jobName, JobListener listener, long progressUpdateIntervalMs) { + this.jobName = jobName; + this.listener = listener; + this.progressUpdateIntervalMs = progressUpdateIntervalMs; + + id = jobId; + + setStatus(Status.READY); + } + public String getId() { return id; } + @Override public int hashCode() { return id.hashCode(); } + @Override public boolean equals(Object o) { return ((Job) o).hashCode() == hashCode(); } @@ -132,26 +144,16 @@ public boolean isRunning() { } public void run() { - if (aborted) { - setStatus(Status.ABORT); - aborted = false; - return; - } JobProgressPoller progressUpdator = null; try { - - setStatus(Status.RUNNING); progressUpdator = new JobProgressPoller(this, progressUpdateIntervalMs); progressUpdator.start(); dateStarted = new Date(); result = jobRun(); + this.exception = null; + errorMessage = null; dateFinished = new Date(); progressUpdator.terminate(); - if (aborted) { - setStatus(Status.ABORT); - } else { - setStatus(Status.FINISHED); - } } catch (NullPointerException e) { logger().error("Job failed", e); progressUpdator.terminate(); @@ -159,7 +161,6 @@ public void run() { result = e.getMessage(); errorMessage = getStack(e); dateFinished = new Date(); - setStatus(Status.ERROR); } catch (Throwable e) { logger().error("Job failed", e); progressUpdator.terminate(); @@ -167,9 +168,8 @@ public void run() { result = e.getMessage(); errorMessage = getStack(e); dateFinished = new Date(); - setStatus(Status.ERROR); } finally { - aborted = false; + //aborted = false; } } diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/scheduler/JobListener.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/scheduler/JobListener.java similarity index 100% rename from zeppelin-zengine/src/main/java/com/nflabs/zeppelin/scheduler/JobListener.java rename to zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/scheduler/JobListener.java diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/scheduler/JobProgressPoller.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/scheduler/JobProgressPoller.java similarity index 100% rename from zeppelin-zengine/src/main/java/com/nflabs/zeppelin/scheduler/JobProgressPoller.java rename to zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/scheduler/JobProgressPoller.java diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/scheduler/ParallelScheduler.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/scheduler/ParallelScheduler.java similarity index 80% rename from zeppelin-zengine/src/main/java/com/nflabs/zeppelin/scheduler/ParallelScheduler.java rename to zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/scheduler/ParallelScheduler.java index 39bb3f76..d28e125c 100644 --- a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/scheduler/ParallelScheduler.java +++ b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/scheduler/ParallelScheduler.java @@ -9,7 +9,7 @@ /** * TODO(moon) : add description. - * + * * @author Leemoonsoo * */ @@ -30,10 +30,12 @@ public ParallelScheduler(String name, ExecutorService executor, SchedulerListene this.maxConcurrency = maxConcurrency; } + @Override public String getName() { return name; } + @Override public Collection getJobsWaiting() { List ret = new LinkedList(); synchronized (queue) { @@ -44,6 +46,7 @@ public Collection getJobsWaiting() { return ret; } + @Override public Collection getJobsRunning() { List ret = new LinkedList(); synchronized (queue) { @@ -56,6 +59,7 @@ public Collection getJobsRunning() { + @Override public void submit(Job job) { job.setStatus(Status.PENDING); synchronized (queue) { @@ -64,6 +68,7 @@ public void submit(Job job) { } } + @Override public void run() { synchronized (queue) { @@ -103,14 +108,41 @@ public JobRunner(Scheduler scheduler, Job job) { this.job = job; } + @Override public void run() { + if (job.isAborted()) { + job.setStatus(Status.ABORT); + job.aborted = false; + + synchronized (queue) { + running.remove(job); + queue.notify(); + } + + return; + } + + job.setStatus(Status.RUNNING); if (listener != null) { listener.jobStarted(scheduler, job); } job.run(); + if (job.isAborted()) { + job.setStatus(Status.ABORT); + } else { + if (job.getException() != null) { + job.setStatus(Status.ERROR); + } else { + job.setStatus(Status.FINISHED); + } + } + if (listener != null) { listener.jobFinished(scheduler, job); } + + // reset aborted flag to allow retry + job.aborted = false; synchronized (queue) { running.remove(job); queue.notify(); @@ -119,6 +151,7 @@ public void run() { } + @Override public void stop() { terminate = true; synchronized (queue) { diff --git a/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/scheduler/RemoteScheduler.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/scheduler/RemoteScheduler.java new file mode 100644 index 00000000..bb02f130 --- /dev/null +++ b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/scheduler/RemoteScheduler.java @@ -0,0 +1,286 @@ +package com.nflabs.zeppelin.scheduler; + +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.ExecutorService; + +import org.apache.thrift.TException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.nflabs.zeppelin.interpreter.remote.RemoteInterpreterProcess; +import com.nflabs.zeppelin.interpreter.thrift.RemoteInterpreterService.Client; +import com.nflabs.zeppelin.scheduler.Job.Status; + +/** + * + */ +public class RemoteScheduler implements Scheduler { + Logger logger = LoggerFactory.getLogger(RemoteScheduler.class); + + List queue = new LinkedList(); + List running = new LinkedList(); + private ExecutorService executor; + private SchedulerListener listener; + boolean terminate = false; + private String name; + private int maxConcurrency; + private RemoteInterpreterProcess interpreterProcess; + + public RemoteScheduler(String name, + ExecutorService executor, + RemoteInterpreterProcess interpreterProcess, + SchedulerListener listener, + int maxConcurrency) { + this.name = name; + this.executor = executor; + this.listener = listener; + this.interpreterProcess = interpreterProcess; + this.maxConcurrency = maxConcurrency; + } + + @Override + public void run() { + synchronized (queue) { + while (terminate == false) { + if (running.size() >= maxConcurrency || queue.isEmpty() == true) { + try { + queue.wait(500); + } catch (InterruptedException e) { + } + continue; + } + + + Job job = queue.remove(0); + running.add(job); + + // run and + Scheduler scheduler = this; + executor.execute(new JobRunner(scheduler, job)); + } + } + } + + @Override + public String getName() { + return name; + } + + @Override + public Collection getJobsWaiting() { + return null; + } + + @Override + public Collection getJobsRunning() { + return null; + } + + @Override + public void submit(Job job) { + job.setStatus(Status.PENDING); + + synchronized (queue) { + queue.add(job); + queue.notify(); + } + } + + public void setMaxConcurrency(int maxConcurrency) { + this.maxConcurrency = maxConcurrency; + synchronized (queue) { + queue.notify(); + } + } + + /** + * Role of the class is get status info from remote process + * from PENDING to RUNNING status. + */ + private class JobStatusPoller extends Thread { + private long initialPeriodMsec; + private long initialPeriodCheckIntervalMsec; + private long checkIntervalMsec; + private boolean terminate; + private JobListener listener; + private Job job; + + public JobStatusPoller( + long initialPeriodMsec, + long initialPeriodCheckIntervalMsec, + long checkIntervalMsec, + Job job, + JobListener listener + ) { + this.initialPeriodMsec = initialPeriodMsec; + this.initialPeriodCheckIntervalMsec = initialPeriodCheckIntervalMsec; + this.checkIntervalMsec = checkIntervalMsec; + this.job = job; + this.listener = listener; + this.terminate = false; + } + + @Override + public void run() { + long started = System.currentTimeMillis(); + while (terminate == false) { + long current = System.currentTimeMillis(); + long interval; + if (current - started < initialPeriodMsec) { + interval = initialPeriodCheckIntervalMsec; + } else { + interval = checkIntervalMsec; + } + + synchronized (this) { + try { + this.wait(interval); + } catch (InterruptedException e) { + } + } + + Status newStatus = getStatus(); + if (newStatus == null) { + continue; + } + + // update only RUNNING + if (newStatus == Status.RUNNING) { + listener.afterStatusChange(job, null, newStatus); + break; + } + + if (newStatus != Status.READY && + newStatus != Status.PENDING) { + // we don't need more + continue; + } + } + } + + public void shutdown() { + terminate = true; + synchronized (this) { + this.notify(); + } + } + + public synchronized Job.Status getStatus() { + if (interpreterProcess.referenceCount() <= 0) { + return null; + } + + Client client; + try { + client = interpreterProcess.getClient(); + } catch (Exception e) { + logger.error("Can't get status information", e); + return Status.FINISHED; + } + + try { + Status status = Status.valueOf(client.getStatus(job.getId())); + logger.info("getStatus from remote {}", status); + return status; + } catch (TException e) { + logger.error("Can't get status information", e); + return Status.FINISHED; + } catch (Exception e) { + // unknown status + return Status.FINISHED; + } finally { + interpreterProcess.releaseClient(client); + } + } + } + + + private class JobRunner implements Runnable, JobListener { + private Scheduler scheduler; + private Job job; + + public JobRunner(Scheduler scheduler, Job job) { + this.scheduler = scheduler; + this.job = job; + } + + @Override + public void run() { + if (job.isAborted()) { + job.setStatus(Status.ABORT); + job.aborted = false; + + synchronized (queue) { + running.remove(job); + queue.notify(); + } + + return; + } + + + JobStatusPoller jobStatusPoller = new JobStatusPoller( + 1500, + 100, + 500, + job, + this + ); + logger.info("*********** Start job status poller"); + jobStatusPoller.start(); + + if (listener != null) { + listener.jobStarted(scheduler, job); + } + job.run(); + + jobStatusPoller.shutdown(); + + job.setStatus(jobStatusPoller.getStatus()); + + if (listener != null) { + listener.jobFinished(scheduler, job); + } + + // reset aborted flag to allow retry + job.aborted = false; + + synchronized (queue) { + running.remove(job); + queue.notify(); + } + } + + @Override + public void onProgressUpdate(Job job, int progress) { + } + + @Override + public void beforeStatusChange(Job job, Status before, Status after) { + } + + @Override + public void afterStatusChange(Job job, Status before, Status after) { + // status polled by status poller + if (job.getStatus() == after) { + return; + } + + job.setStatus(after); + } + } + + + @Override + public void stop() { + terminate = true; + synchronized (queue) { + queue.notify(); + } + + + } + +} diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/scheduler/Scheduler.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/scheduler/Scheduler.java similarity index 100% rename from zeppelin-zengine/src/main/java/com/nflabs/zeppelin/scheduler/Scheduler.java rename to zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/scheduler/Scheduler.java diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/scheduler/SchedulerFactory.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/scheduler/SchedulerFactory.java similarity index 81% rename from zeppelin-zengine/src/main/java/com/nflabs/zeppelin/scheduler/SchedulerFactory.java rename to zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/scheduler/SchedulerFactory.java index c79f8e2e..115e2b13 100644 --- a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/scheduler/SchedulerFactory.java +++ b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/scheduler/SchedulerFactory.java @@ -11,9 +11,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.nflabs.zeppelin.interpreter.remote.RemoteInterpreterProcess; + /** * TODO(moon) : add description. - * + * * @author Leemoonsoo * */ @@ -70,6 +72,26 @@ public Scheduler createOrGetParallelScheduler(String name, int maxConcurrency) { } } + public Scheduler createOrGetRemoteScheduler( + String name, + RemoteInterpreterProcess interpreterProcess, + int maxConcurrency) { + + synchronized (schedulers) { + if (schedulers.containsKey(name) == false) { + Scheduler s = new RemoteScheduler( + name, + executor, + interpreterProcess, + this, + maxConcurrency); + schedulers.put(name, s); + executor.execute(s); + } + return schedulers.get(name); + } + } + public Scheduler removeScheduler(String name) { synchronized (schedulers) { Scheduler s = schedulers.remove(name); @@ -90,11 +112,13 @@ public Collection listScheduler(String name) { return s; } + @Override public void jobStarted(Scheduler scheduler, Job job) { logger.info("Job " + job.getJobName() + " started by scheduler " + scheduler.getName()); } + @Override public void jobFinished(Scheduler scheduler, Job job) { logger.info("Job " + job.getJobName() + " finished by scheduler " + scheduler.getName()); diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/scheduler/SchedulerListener.java b/zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/scheduler/SchedulerListener.java similarity index 100% rename from zeppelin-zengine/src/main/java/com/nflabs/zeppelin/scheduler/SchedulerListener.java rename to zeppelin-interpreter/src/main/java/com/nflabs/zeppelin/scheduler/SchedulerListener.java diff --git a/zeppelin-interpreter/src/main/thrift/RemoteInterpreterService.thrift b/zeppelin-interpreter/src/main/thrift/RemoteInterpreterService.thrift new file mode 100644 index 00000000..bbb54b18 --- /dev/null +++ b/zeppelin-interpreter/src/main/thrift/RemoteInterpreterService.thrift @@ -0,0 +1,33 @@ +namespace java com.nflabs.zeppelin.interpreter.thrift + + +struct RemoteInterpreterContext { + 1: string paragraphId, + 2: string paragraphTitle, + 3: string paragraphText, + 4: string config, // json serialized config + 5: string gui // json serialized gui +} + +struct RemoteInterpreterResult { + 1: string code, + 2: string type, + 3: string msg, + 4: string config, // json serialized config + 5: string gui // json serialized gui +} + +service RemoteInterpreterService { + void createInterpreter(1: string className, 2: map properties); + + void open(1: string className); + void close(1: string className); + RemoteInterpreterResult interpret(1: string className, 2: string st, 3: RemoteInterpreterContext interpreterContext); + void cancel(1: string className, 2: RemoteInterpreterContext interpreterContext); + i32 getProgress(1: string className, 2: RemoteInterpreterContext interpreterContext); + string getFormType(1: string className); + list completion(1: string className, 2: string buf, 3: i32 cursor); + void shutdown(); + + string getStatus(1:string jobId); +} \ No newline at end of file diff --git a/zeppelin-zengine/src/test/java/com/nflabs/zeppelin/notebook/form/InputTest.java b/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/display/InputTest.java similarity index 88% rename from zeppelin-zengine/src/test/java/com/nflabs/zeppelin/notebook/form/InputTest.java rename to zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/display/InputTest.java index 63bfccd2..091473b3 100644 --- a/zeppelin-zengine/src/test/java/com/nflabs/zeppelin/notebook/form/InputTest.java +++ b/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/display/InputTest.java @@ -1,4 +1,4 @@ -package com.nflabs.zeppelin.notebook.form; +package com.nflabs.zeppelin.display; import static org.junit.Assert.*; diff --git a/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreterProcessTest.java b/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreterProcessTest.java new file mode 100644 index 00000000..181b1b0a --- /dev/null +++ b/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreterProcessTest.java @@ -0,0 +1,46 @@ +package com.nflabs.zeppelin.interpreter.remote; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +import java.util.HashMap; + +import org.junit.Test; + +import com.nflabs.zeppelin.interpreter.thrift.RemoteInterpreterService.Client; + +public class RemoteInterpreterProcessTest { + + @Test + public void testStartStop() { + RemoteInterpreterProcess rip = new RemoteInterpreterProcess("../bin/interpreter.sh", "nonexists", new HashMap()); + assertFalse(rip.isRunning()); + assertEquals(0, rip.referenceCount()); + assertEquals(1, rip.reference()); + assertEquals(2, rip.reference()); + assertEquals(true, rip.isRunning()); + assertEquals(1, rip.dereference()); + assertEquals(true, rip.isRunning()); + assertEquals(0, rip.dereference()); + assertEquals(false, rip.isRunning()); + } + + @Test + public void testClientFactory() throws Exception { + RemoteInterpreterProcess rip = new RemoteInterpreterProcess("../bin/interpreter.sh", "nonexists", new HashMap()); + rip.reference(); + assertEquals(0, rip.getNumActiveClient()); + assertEquals(0, rip.getNumIdleClient()); + + Client client = rip.getClient(); + assertEquals(1, rip.getNumActiveClient()); + assertEquals(0, rip.getNumIdleClient()); + + rip.releaseClient(client); + assertEquals(0, rip.getNumActiveClient()); + assertEquals(1, rip.getNumIdleClient()); + + rip.dereference(); + } + +} diff --git a/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreterServerTest.java b/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreterServerTest.java new file mode 100644 index 00000000..809c76e4 --- /dev/null +++ b/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreterServerTest.java @@ -0,0 +1,57 @@ +package com.nflabs.zeppelin.interpreter.remote; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; + +import org.apache.thrift.TException; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class RemoteInterpreterServerTest { + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testStartStop() throws InterruptedException, IOException, TException { + RemoteInterpreterServer server = new RemoteInterpreterServer( + RemoteInterpreterUtils.findRandomAvailablePortOnAllLocalInterfaces()); + assertEquals(false, server.isRunning()); + + server.start(); + long startTime = System.currentTimeMillis(); + boolean running = false; + + while (System.currentTimeMillis() - startTime < 10 * 1000) { + if (server.isRunning()) { + running = true; + break; + } else { + Thread.sleep(200); + } + } + + assertEquals(true, running); + assertEquals(true, RemoteInterpreterUtils.checkIfRemoteEndpointAccessible("localhost", server.getPort())); + + server.shutdown(); + + while (System.currentTimeMillis() - startTime < 10 * 1000) { + if (server.isRunning()) { + Thread.sleep(200); + } else { + running = false; + break; + } + } + assertEquals(false, running); + } + + +} diff --git a/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreterTest.java b/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreterTest.java new file mode 100644 index 00000000..5ec6a324 --- /dev/null +++ b/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreterTest.java @@ -0,0 +1,156 @@ +package com.nflabs.zeppelin.interpreter.remote; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import org.apache.thrift.transport.TTransportException; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.nflabs.zeppelin.display.GUI; +import com.nflabs.zeppelin.interpreter.InterpreterContext; +import com.nflabs.zeppelin.interpreter.InterpreterGroup; +import com.nflabs.zeppelin.interpreter.remote.mock.MockInterpreterA; +import com.nflabs.zeppelin.interpreter.remote.mock.MockInterpreterB; + +public class RemoteInterpreterTest { + + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testRemoteInterperterCall() throws TTransportException, IOException { + Properties p = new Properties(); + InterpreterGroup intpGroup = new InterpreterGroup(); + Map env = new HashMap(); + env.put("ZEPPELIN_CLASSPATH", new File("./target/test-classes").getAbsolutePath()); + + RemoteInterpreter intpA = new RemoteInterpreter( + p, + MockInterpreterA.class.getName(), + new File("../bin/interpreter.sh").getAbsolutePath(), + "fake", + env + ); + + intpGroup.add(intpA); + intpA.setInterpreterGroup(intpGroup); + + RemoteInterpreter intpB = new RemoteInterpreter( + p, + MockInterpreterB.class.getName(), + new File("../bin/interpreter.sh").getAbsolutePath(), + "fake", + env + ); + + intpGroup.add(intpB); + intpB.setInterpreterGroup(intpGroup); + + + RemoteInterpreterProcess process = intpA.getInterpreterProcess(); + process.equals(intpB.getInterpreterProcess()); + + assertFalse(process.isRunning()); + assertEquals(0, process.getNumIdleClient()); + assertEquals(0, process.referenceCount()); + + intpA.open(); + assertTrue(process.isRunning()); + assertEquals(1, process.getNumIdleClient()); + assertEquals(1, process.referenceCount()); + + intpA.interpret("1", + new InterpreterContext( + "id", + "title", + "text", + new HashMap(), + new GUI())); + + intpB.open(); + assertEquals(2, process.referenceCount()); + + intpA.close(); + assertEquals(1, process.referenceCount()); + intpB.close(); + assertEquals(0, process.referenceCount()); + + assertFalse(process.isRunning()); + + } + + @Test + public void testRemoteSchedulerSharing() throws TTransportException, IOException { + Properties p = new Properties(); + InterpreterGroup intpGroup = new InterpreterGroup(); + Map env = new HashMap(); + env.put("ZEPPELIN_CLASSPATH", new File("./target/test-classes").getAbsolutePath()); + + RemoteInterpreter intpA = new RemoteInterpreter( + p, + MockInterpreterA.class.getName(), + new File("../bin/interpreter.sh").getAbsolutePath(), + "fake", + env + ); + + intpGroup.add(intpA); + intpA.setInterpreterGroup(intpGroup); + + RemoteInterpreter intpB = new RemoteInterpreter( + p, + MockInterpreterB.class.getName(), + new File("../bin/interpreter.sh").getAbsolutePath(), + "fake", + env + ); + + intpGroup.add(intpB); + intpB.setInterpreterGroup(intpGroup); + + intpA.open(); + intpB.open(); + + long start = System.currentTimeMillis(); + intpA.interpret("500", + new InterpreterContext( + "id", + "title", + "text", + new HashMap(), + new GUI())); + + intpB.interpret("500", + new InterpreterContext( + "id", + "title", + "text", + new HashMap(), + new GUI())); + long end = System.currentTimeMillis(); + assertTrue(end - start >= 1000); + + + intpA.close(); + intpB.close(); + + RemoteInterpreterProcess process = intpA.getInterpreterProcess(); + assertFalse(process.isRunning()); + + } +} diff --git a/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreterUtilsTest.java b/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreterUtilsTest.java new file mode 100644 index 00000000..3035cf20 --- /dev/null +++ b/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/interpreter/remote/RemoteInterpreterUtilsTest.java @@ -0,0 +1,16 @@ +package com.nflabs.zeppelin.interpreter.remote; + +import static org.junit.Assert.assertTrue; + +import java.io.IOException; + +import org.junit.Test; + +public class RemoteInterpreterUtilsTest { + + @Test + public void testFindRandomAvailablePortOnAllLocalInterfaces() throws IOException { + assertTrue(RemoteInterpreterUtils.findRandomAvailablePortOnAllLocalInterfaces() > 0); + } + +} diff --git a/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/interpreter/remote/mock/MockInterpreterA.java b/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/interpreter/remote/mock/MockInterpreterA.java new file mode 100644 index 00000000..10b6ec95 --- /dev/null +++ b/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/interpreter/remote/mock/MockInterpreterA.java @@ -0,0 +1,72 @@ +package com.nflabs.zeppelin.interpreter.remote.mock; + +import java.util.List; +import java.util.Properties; + +import com.nflabs.zeppelin.interpreter.Interpreter; +import com.nflabs.zeppelin.interpreter.InterpreterContext; +import com.nflabs.zeppelin.interpreter.InterpreterException; +import com.nflabs.zeppelin.interpreter.InterpreterPropertyBuilder; +import com.nflabs.zeppelin.interpreter.InterpreterResult; +import com.nflabs.zeppelin.interpreter.InterpreterResult.Code; +import com.nflabs.zeppelin.scheduler.Scheduler; +import com.nflabs.zeppelin.scheduler.SchedulerFactory; + +public class MockInterpreterA extends Interpreter { + static { + Interpreter.register( + "interpreterA", + "group1", + MockInterpreterA.class.getName(), + new InterpreterPropertyBuilder() + .add("p1", "v1", "property1").build()); + + } + public MockInterpreterA(Properties property) { + super(property); + } + + @Override + public void open() { + + } + + @Override + public void close() { + } + + @Override + public InterpreterResult interpret(String st, InterpreterContext context) { + try { + Thread.sleep(Long.parseLong(st)); + } catch (NumberFormatException | InterruptedException e) { + throw new InterpreterException(e); + } + return new InterpreterResult(Code.SUCCESS, st); + } + + @Override + public void cancel(InterpreterContext context) { + + } + + @Override + public FormType getFormType() { + return FormType.NATIVE; + } + + @Override + public int getProgress(InterpreterContext context) { + return 0; + } + + @Override + public List completion(String buf, int cursor) { + return null; + } + + @Override + public Scheduler getScheduler() { + return SchedulerFactory.singleton().createOrGetFIFOScheduler("interpreter_" + this.hashCode()); + } +} diff --git a/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/interpreter/remote/mock/MockInterpreterB.java b/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/interpreter/remote/mock/MockInterpreterB.java new file mode 100644 index 00000000..d8b2ce9a --- /dev/null +++ b/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/interpreter/remote/mock/MockInterpreterB.java @@ -0,0 +1,80 @@ +package com.nflabs.zeppelin.interpreter.remote.mock; + +import java.util.List; +import java.util.Properties; + +import com.nflabs.zeppelin.interpreter.Interpreter; +import com.nflabs.zeppelin.interpreter.InterpreterContext; +import com.nflabs.zeppelin.interpreter.InterpreterException; +import com.nflabs.zeppelin.interpreter.InterpreterGroup; +import com.nflabs.zeppelin.interpreter.InterpreterPropertyBuilder; +import com.nflabs.zeppelin.interpreter.InterpreterResult; +import com.nflabs.zeppelin.interpreter.InterpreterResult.Code; +import com.nflabs.zeppelin.scheduler.Scheduler; + +public class MockInterpreterB extends Interpreter { + static { + Interpreter.register( + "interpreterB", + "group1", + MockInterpreterA.class.getName(), + new InterpreterPropertyBuilder() + .add("p1", "v1", "property1").build()); + + } + public MockInterpreterB(Properties property) { + super(property); + } + + @Override + public void open() { + + } + + @Override + public void close() { + } + + @Override + public InterpreterResult interpret(String st, InterpreterContext context) { + try { + Thread.sleep(Long.parseLong(st)); + } catch (NumberFormatException | InterruptedException e) { + throw new InterpreterException(e); + } + return new InterpreterResult(Code.SUCCESS, st); + } + + @Override + public void cancel(InterpreterContext context) { + + } + + @Override + public FormType getFormType() { + return FormType.NATIVE; + } + + @Override + public int getProgress(InterpreterContext context) { + return 0; + } + + @Override + public List completion(String buf, int cursor) { + return null; + } + + @Override + public Scheduler getScheduler() { + InterpreterGroup interpreterGroup = getInterpreterGroup(); + for (Interpreter intp : interpreterGroup) { + if (intp.getClassName().equals(MockInterpreterA.class.getName())) { + return intp.getScheduler(); + } + } + + return null; + } + +} diff --git a/zeppelin-zengine/src/test/java/com/nflabs/zeppelin/scheduler/FIFOSchedulerTest.java b/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/scheduler/FIFOSchedulerTest.java similarity index 91% rename from zeppelin-zengine/src/test/java/com/nflabs/zeppelin/scheduler/FIFOSchedulerTest.java rename to zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/scheduler/FIFOSchedulerTest.java index e9dc65ad..37a29d14 100644 --- a/zeppelin-zengine/src/test/java/com/nflabs/zeppelin/scheduler/FIFOSchedulerTest.java +++ b/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/scheduler/FIFOSchedulerTest.java @@ -1,29 +1,31 @@ package com.nflabs.zeppelin.scheduler; -import com.nflabs.zeppelin.scheduler.Job.Status; - import junit.framework.TestCase; -public class FIFOSchedulerTest extends TestCase{ +import com.nflabs.zeppelin.scheduler.Job.Status; + +public class FIFOSchedulerTest extends TestCase { private SchedulerFactory schedulerSvc; - public void setUp() throws Exception{ + @Override + public void setUp() throws Exception{ schedulerSvc = new SchedulerFactory(); } - - public void tearDown(){ - + + @Override + public void tearDown(){ + } - + public void testRun() throws InterruptedException{ Scheduler s = schedulerSvc.createOrGetFIFOScheduler("test"); assertEquals(0, s.getJobsRunning().size()); assertEquals(0, s.getJobsWaiting().size()); - + Job job1 = new SleepingJob("job1", null, 500); Job job2 = new SleepingJob("job2", null, 500); - + s.submit(job1); s.submit(job2); Thread.sleep(200); @@ -40,33 +42,33 @@ public void testRun() throws InterruptedException{ assertTrue((500 < (Long)job1.getReturn())); assertEquals(1, s.getJobsRunning().size()); assertEquals(0, s.getJobsWaiting().size()); - + } - + public void testAbort() throws InterruptedException{ Scheduler s = schedulerSvc.createOrGetFIFOScheduler("test"); assertEquals(0, s.getJobsRunning().size()); assertEquals(0, s.getJobsWaiting().size()); - + Job job1 = new SleepingJob("job1", null, 500); Job job2 = new SleepingJob("job2", null, 500); - + s.submit(job1); s.submit(job2); - + Thread.sleep(200); - + job1.abort(); job2.abort(); - + Thread.sleep(200); - + assertEquals(Status.ABORT, job1.getStatus()); assertEquals(Status.ABORT, job2.getStatus()); - + assertTrue((500 > (Long)job1.getReturn())); assertEquals(null, job2.getReturn()); - - + + } } \ No newline at end of file diff --git a/zeppelin-zengine/src/test/java/com/nflabs/zeppelin/scheduler/ParallelSchedulerTest.java b/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/scheduler/ParallelSchedulerTest.java similarity index 100% rename from zeppelin-zengine/src/test/java/com/nflabs/zeppelin/scheduler/ParallelSchedulerTest.java rename to zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/scheduler/ParallelSchedulerTest.java diff --git a/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/scheduler/RemoteSchedulerTest.java b/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/scheduler/RemoteSchedulerTest.java new file mode 100644 index 00000000..8695038f --- /dev/null +++ b/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/scheduler/RemoteSchedulerTest.java @@ -0,0 +1,90 @@ +package com.nflabs.zeppelin.scheduler; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.nflabs.zeppelin.display.GUI; +import com.nflabs.zeppelin.interpreter.InterpreterContext; +import com.nflabs.zeppelin.interpreter.InterpreterGroup; +import com.nflabs.zeppelin.interpreter.remote.RemoteInterpreter; +import com.nflabs.zeppelin.interpreter.remote.mock.MockInterpreterA; + +public class RemoteSchedulerTest { + + private SchedulerFactory schedulerSvc; + + @Before + public void setUp() throws Exception{ + schedulerSvc = new SchedulerFactory(); + } + + @After + public void tearDown(){ + + } + + @Test + public void test() throws Exception { + Properties p = new Properties(); + InterpreterGroup intpGroup = new InterpreterGroup(); + Map env = new HashMap(); + env.put("ZEPPELIN_CLASSPATH", new File("./target/test-classes").getAbsolutePath()); + + final RemoteInterpreter intpA = new RemoteInterpreter( + p, + MockInterpreterA.class.getName(), + new File("../bin/interpreter.sh").getAbsolutePath(), + "fake", + env + ); + + intpGroup.add(intpA); + intpA.setInterpreterGroup(intpGroup); + + intpA.open(); + + Scheduler scheduler = schedulerSvc.createOrGetRemoteScheduler("test", + intpA.getInterpreterProcess(), + 10); + + scheduler.submit(new Job("jobName", null) { + + @Override + public int progress() { + return 0; + } + + @Override + public Map info() { + return null; + } + + @Override + protected Object jobRun() throws Throwable { + intpA.interpret("500", new InterpreterContext( + "id", + "title", + "text", + new HashMap(), + new GUI())); + return "500"; + } + + @Override + protected boolean jobAbort() { + return false; + } + + }); + + intpA.close(); + schedulerSvc.removeScheduler("test"); + } + +} diff --git a/zeppelin-zengine/src/test/java/com/nflabs/zeppelin/scheduler/SleepingJob.java b/zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/scheduler/SleepingJob.java similarity index 100% rename from zeppelin-zengine/src/test/java/com/nflabs/zeppelin/scheduler/SleepingJob.java rename to zeppelin-interpreter/src/test/java/com/nflabs/zeppelin/scheduler/SleepingJob.java diff --git a/zeppelin-interpreter/src/test/resources/log4j.properties b/zeppelin-interpreter/src/test/resources/log4j.properties new file mode 100644 index 00000000..361ca2dd --- /dev/null +++ b/zeppelin-interpreter/src/test/resources/log4j.properties @@ -0,0 +1,12 @@ +# Direct log messages to stdout +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c:%L - %m%n +#log4j.appender.stdout.layout.ConversionPattern= +#%5p [%t] (%F:%L) - %m%n +#%-4r [%t] %-5p %c %x - %m%n +# + +# Root logger option +log4j.rootLogger=INFO, stdout \ No newline at end of file diff --git a/zeppelin-server/src/main/java/com/nflabs/zeppelin/rest/InterpreterRestApi.java b/zeppelin-server/src/main/java/com/nflabs/zeppelin/rest/InterpreterRestApi.java index 0bdbfb0c..582ba322 100644 --- a/zeppelin-server/src/main/java/com/nflabs/zeppelin/rest/InterpreterRestApi.java +++ b/zeppelin-server/src/main/java/com/nflabs/zeppelin/rest/InterpreterRestApi.java @@ -25,6 +25,7 @@ import com.nflabs.zeppelin.interpreter.InterpreterFactory; import com.nflabs.zeppelin.interpreter.InterpreterSetting; import com.nflabs.zeppelin.rest.message.NewInterpreterSettingRequest; +import com.nflabs.zeppelin.rest.message.UpdateInterpreterSettingRequest; import com.nflabs.zeppelin.server.JsonResponse; import com.wordnik.swagger.annotations.Api; import com.wordnik.swagger.annotations.ApiOperation; @@ -83,7 +84,7 @@ public Response newSettings(String message) throws InterpreterException, IOExcep NewInterpreterSettingRequest.class); Properties p = new Properties(); p.putAll(request.getProperties()); - interpreterFactory.add(request.getName(), request.getGroup(), p); + interpreterFactory.add(request.getName(), request.getGroup(), request.getOption(), p); return new JsonResponse(Status.CREATED, "").build(); } @@ -91,11 +92,15 @@ public Response newSettings(String message) throws InterpreterException, IOExcep @Path("setting/{settingId}") public Response updateSetting(String message, @PathParam("settingId") String settingId) { logger.info("Update interpreterSetting {}", settingId); + try { - Properties p = gson.fromJson(message, Properties.class); - interpreterFactory.setPropertyAndRestart(settingId, p); + UpdateInterpreterSettingRequest p = gson.fromJson(message, + UpdateInterpreterSettingRequest.class); + interpreterFactory.setPropertyAndRestart(settingId, p.getOption(), p.getProperties()); } catch (InterpreterException e) { return new JsonResponse(Status.NOT_FOUND, e.getMessage(), e).build(); + } catch (IOException e) { + return new JsonResponse(Status.INTERNAL_SERVER_ERROR, e.getMessage(), e).build(); } InterpreterSetting setting = interpreterFactory.get(settingId); if (setting == null) { diff --git a/zeppelin-server/src/main/java/com/nflabs/zeppelin/rest/message/NewInterpreterSettingRequest.java b/zeppelin-server/src/main/java/com/nflabs/zeppelin/rest/message/NewInterpreterSettingRequest.java index ba4b6310..4817507a 100644 --- a/zeppelin-server/src/main/java/com/nflabs/zeppelin/rest/message/NewInterpreterSettingRequest.java +++ b/zeppelin-server/src/main/java/com/nflabs/zeppelin/rest/message/NewInterpreterSettingRequest.java @@ -2,6 +2,8 @@ import java.util.Map; +import com.nflabs.zeppelin.interpreter.InterpreterOption; + /** * NewInterpreterSetting rest api request message * @@ -9,10 +11,11 @@ public class NewInterpreterSettingRequest { String name; String group; + InterpreterOption option; Map properties; - + public NewInterpreterSettingRequest() { - + } public String getName() { @@ -26,4 +29,8 @@ public String getGroup() { public Map getProperties() { return properties; } + + public InterpreterOption getOption() { + return option; + } } diff --git a/zeppelin-server/src/main/java/com/nflabs/zeppelin/rest/message/UpdateInterpreterSettingRequest.java b/zeppelin-server/src/main/java/com/nflabs/zeppelin/rest/message/UpdateInterpreterSettingRequest.java new file mode 100644 index 00000000..5f18a462 --- /dev/null +++ b/zeppelin-server/src/main/java/com/nflabs/zeppelin/rest/message/UpdateInterpreterSettingRequest.java @@ -0,0 +1,28 @@ +package com.nflabs.zeppelin.rest.message; + +import java.util.Properties; + +import com.nflabs.zeppelin.interpreter.InterpreterOption; + +/** + * + */ +public class UpdateInterpreterSettingRequest { + InterpreterOption option; + Properties properties; + + public UpdateInterpreterSettingRequest(InterpreterOption option, + Properties properties) { + super(); + this.option = option; + this.properties = properties; + } + public InterpreterOption getOption() { + return option; + } + public Properties getProperties() { + return properties; + } + + +} diff --git a/zeppelin-server/src/main/java/com/nflabs/zeppelin/server/ZeppelinServer.java b/zeppelin-server/src/main/java/com/nflabs/zeppelin/server/ZeppelinServer.java index c00c6ae5..9bd5d69d 100644 --- a/zeppelin-server/src/main/java/com/nflabs/zeppelin/server/ZeppelinServer.java +++ b/zeppelin-server/src/main/java/com/nflabs/zeppelin/server/ZeppelinServer.java @@ -1,5 +1,15 @@ package com.nflabs.zeppelin.server; +import java.io.File; +import java.io.IOException; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.Set; + +import javax.net.ssl.SSLContext; +import javax.servlet.DispatcherType; +import javax.ws.rs.core.Application; + import org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; @@ -23,23 +33,14 @@ import com.nflabs.zeppelin.rest.InterpreterRestApi; import com.nflabs.zeppelin.rest.NotebookRestApi; import com.nflabs.zeppelin.rest.ZeppelinRestApi; +import com.nflabs.zeppelin.scheduler.SchedulerFactory; import com.nflabs.zeppelin.socket.NotebookServer; import com.nflabs.zeppelin.socket.SslWebSocketServerFactory; -import com.nflabs.zeppelin.scheduler.SchedulerFactory; import com.wordnik.swagger.jersey.config.JerseyJaxrsConfig; -import java.io.File; -import java.util.EnumSet; -import java.util.HashSet; -import java.util.Set; - -import javax.net.ssl.SSLContext; -import javax.servlet.DispatcherType; -import javax.ws.rs.core.Application; - /** * Main class of Zeppelin. - * + * * @author Leemoonsoo * */ @@ -88,6 +89,8 @@ public static void main(String[] args) throws Exception { @Override public void run() { LOG.info("Shutting down Zeppelin Server ... "); try { + notebook.getInterpreterFactory().close(); + jettyServer.stop(); notebookServer.stop(); } catch (Exception e) { @@ -96,6 +99,18 @@ public static void main(String[] args) throws Exception { LOG.info("Bye"); } }); + + + // when zeppelin is started inside of ide (especially for eclipse) + // for graceful shutdown, input any key in console window + if (System.getenv("ZEPPELIN_IDENT_STRING") == null) { + try { + System.in.read(); + } catch (IOException e) { + } + System.exit(0); + } + jettyServer.join(); } @@ -181,7 +196,7 @@ private static ServletContextHandler setupRestApiContextHandler() { cxfContext.setSessionHandler(new SessionHandler()); cxfContext.setContextPath("/api"); cxfContext.addServlet(cxfServletHolder, "/*"); - + cxfContext.addFilter(new FilterHolder(CorsFilter.class), "/*", EnumSet.allOf(DispatcherType.class)); return cxfContext; @@ -194,14 +209,14 @@ private static ServletContextHandler setupRestApiContextHandler() { */ private static ServletContextHandler setupSwaggerContextHandler( ZeppelinConfiguration conf) { - + // Configure Swagger-core final ServletHolder swaggerServlet = new ServletHolder(new JerseyJaxrsConfig()); swaggerServlet.setName("JerseyJaxrsConfig"); swaggerServlet.setInitParameter("api.version", "1.0.0"); swaggerServlet.setInitParameter( - "swagger.api.basepath", + "swagger.api.basepath", "http://localhost:" + conf.getServerPort() + "/api"); swaggerServlet.setInitOrder(2); @@ -217,7 +232,7 @@ private static ServletContextHandler setupSwaggerContextHandler( private static WebAppContext setupWebAppContext( ZeppelinConfiguration conf) { - + WebAppContext webApp = new WebAppContext(); File warPath = new File(conf.getString(ConfVars.ZEPPELIN_WAR)); if (warPath.isDirectory()) { @@ -283,7 +298,7 @@ public java.util.Set getSingletons() { /** Rest-api root endpoint */ ZeppelinRestApi root = new ZeppelinRestApi(); singletons.add(root); - + NotebookRestApi notebookApi = new NotebookRestApi(notebook); singletons.add(notebookApi); diff --git a/zeppelin-server/src/main/java/com/nflabs/zeppelin/socket/NotebookServer.java b/zeppelin-server/src/main/java/com/nflabs/zeppelin/socket/NotebookServer.java index d86f8601..f38dc652 100644 --- a/zeppelin-server/src/main/java/com/nflabs/zeppelin/socket/NotebookServer.java +++ b/zeppelin-server/src/main/java/com/nflabs/zeppelin/socket/NotebookServer.java @@ -272,7 +272,7 @@ private void updateNote(WebSocket conn, Notebook notebook, Message fromMessage) notebook.refreshCron(note.id()); } note.persist(); - + broadcastNote(note); broadcastNoteList(); } diff --git a/zeppelin-web/app/scripts/controllers/interpreter.js b/zeppelin-web/app/scripts/controllers/interpreter.js index 2cb0299f..083f3e91 100644 --- a/zeppelin-web/app/scripts/controllers/interpreter.js +++ b/zeppelin-web/app/scripts/controllers/interpreter.js @@ -36,6 +36,7 @@ angular.module('zeppelinWebApp').controller('InterpreterCtrl', function($scope, id : settingId, name : setting.name, group : setting.group, + option : angular.copy(setting.option), properties : property, interpreters : setting.interpreterGroup }; @@ -89,6 +90,7 @@ angular.module('zeppelinWebApp').controller('InterpreterCtrl', function($scope, var setting = $scope.interpreterSettings[i]; if(setting.id === settingId) { angular.copy(setting.properties, $scope.interpreterSettingProperties); + angular.copy(setting.option, $scope.interpreterSettingOption); break; } } @@ -103,18 +105,25 @@ angular.module('zeppelinWebApp').controller('InterpreterCtrl', function($scope, $scope.addNewInterpreterProperty(settingId); - var properties = {}; + var request = { + option : { + remote : true + }, + properties : {}, + }; + for (var i=0; i < $scope.interpreterSettings.length; i++) { var setting = $scope.interpreterSettings[i]; if(setting.id === settingId) { + request.option = angular.copy(setting.option); for (var p in setting.properties) { - properties[p] = setting.properties[p].value; + request.properties[p] = setting.properties[p].value; } break; } } - $http.put(getRestApiBase()+'/interpreter/setting/'+settingId, properties). + $http.put(getRestApiBase()+'/interpreter/setting/'+settingId, request). success(function(data, status, headers, config) { for (var i=0; i < $scope.interpreterSettings.length; i++) { var setting = $scope.interpreterSettings[i]; @@ -133,8 +142,9 @@ angular.module('zeppelinWebApp').controller('InterpreterCtrl', function($scope, $scope.resetInterpreterSetting = function(settingId){ for (var i=0; i<$scope.interpreterSettings.length; i++) { var setting = $scope.interpreterSettings[i]; - if (setting.id ===settingId) { + if (setting.id === settingId) { angular.copy($scope.interpreterSettingProperties, setting.properties); + angular.copy($scope.interpreterSettingOption, setting.option); break; } } @@ -218,6 +228,7 @@ angular.module('zeppelinWebApp').controller('InterpreterCtrl', function($scope, var newSetting = { name : $scope.newInterpreterSetting.name, group : $scope.newInterpreterSetting.group, + option : angular.copy($scope.newInterpreterSetting.option), properties : {} }; @@ -241,6 +252,7 @@ angular.module('zeppelinWebApp').controller('InterpreterCtrl', function($scope, $scope.newInterpreterSetting = { name : undefined, group : undefined, + option : { remote : true }, properties : {} }; $scope.newInterpreterSetting.propertyValue = ''; diff --git a/zeppelin-zengine/pom.xml b/zeppelin-zengine/pom.xml index 378dba79..616d7674 100644 --- a/zeppelin-zengine/pom.xml +++ b/zeppelin-zengine/pom.xml @@ -28,6 +28,12 @@ + + ${project.groupId} + zeppelin-interpreter + ${project.version} + + org.slf4j slf4j-api diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/conf/ZeppelinConfiguration.java b/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/conf/ZeppelinConfiguration.java index cb7f1d65..b30ab6a1 100644 --- a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/conf/ZeppelinConfiguration.java +++ b/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/conf/ZeppelinConfiguration.java @@ -314,6 +314,10 @@ public String getInterpreterSettingPath() { return getRelativeDir("conf/interpreter.json"); } + public String getInterpreterRemoteRunnerPath() { + return getRelativeDir(ConfVars.ZEPPELIN_INTERPRETER_REMOTE_RUNNER); + } + public String getRelativeDir(ConfVars c) { return getRelativeDir(getString(c)); } @@ -357,6 +361,7 @@ public static enum ConfVars { ZEPPELIN_INTERPRETER_DIR("zeppelin.interpreter.dir", "interpreter"), ZEPPELIN_ENCODING("zeppelin.encoding", "UTF-8"), ZEPPELIN_NOTEBOOK_DIR("zeppelin.notebook.dir", "notebook"), + ZEPPELIN_INTERPRETER_REMOTE_RUNNER("zeppelin.interpreter.remoterunner", "bin/interpreter.sh"), // Decide when new note is created, interpreter settings will be binded automatically or not. ZEPPELIN_NOTEBOOK_AUTO_INTERPRETER_BINDING("zeppelin.notebook.autoInterpreterBinding", true); diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterContext.java b/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterContext.java deleted file mode 100644 index 4f28f84f..00000000 --- a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterContext.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.nflabs.zeppelin.interpreter; - -import com.nflabs.zeppelin.notebook.Paragraph; - -/** - * Interpreter context - */ -public class InterpreterContext { - Paragraph paragraph; - - public InterpreterContext(Paragraph paragraph) { - super(); - this.paragraph = paragraph; - } - - public Paragraph getParagraph() { - return paragraph; - } - public void setParagraph(Paragraph paragraph) { - this.paragraph = paragraph; - } -} diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterFactory.java b/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterFactory.java index 05aee62d..5d654055 100644 --- a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterFactory.java +++ b/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterFactory.java @@ -12,6 +12,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; @@ -28,10 +29,10 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; import com.nflabs.zeppelin.conf.ZeppelinConfiguration; import com.nflabs.zeppelin.conf.ZeppelinConfiguration.ConfVars; import com.nflabs.zeppelin.interpreter.Interpreter.RegisteredInterpreter; +import com.nflabs.zeppelin.interpreter.remote.RemoteInterpreter; /** * Manage interpreters. @@ -53,8 +54,17 @@ public class InterpreterFactory { private Gson gson; + private InterpreterOption defaultOption; + public InterpreterFactory(ZeppelinConfiguration conf) throws InterpreterException, IOException { + this(conf, new InterpreterOption(true)); + } + + + public InterpreterFactory(ZeppelinConfiguration conf, InterpreterOption defaultOption) + throws InterpreterException, IOException { this.conf = conf; + this.defaultOption = defaultOption; String replsConf = conf.getString(ConfVars.ZEPPELIN_INTERPRETERS); interpreterClassList = replsConf.split(","); @@ -66,7 +76,6 @@ public InterpreterFactory(ZeppelinConfiguration conf) throws InterpreterExceptio init(); } - private void init() throws InterpreterException, IOException { ClassLoader oldcl = Thread.currentThread().getContextClassLoader(); @@ -90,8 +99,9 @@ private void init() throws InterpreterException, IOException { for (String intName : keys) { if (className.equals( Interpreter.registeredInterpreters.get(intName).getClassName())) { + Interpreter.registeredInterpreters.get(intName).setPath(path.getAbsolutePath()); logger.info("Interpreter " + intName + " found. class=" + className); - cleanCl.put(intName, ccl); + cleanCl.put(path.getAbsolutePath(), ccl); } } } catch (ClassNotFoundException e) { @@ -137,7 +147,7 @@ private void init() throws InterpreterException, IOException { if (found) { // add all interpreters in group - add(groupName, groupName, p); + add(groupName, groupName, defaultOption, p); groupClassNameMap.remove(groupName); break; } @@ -179,29 +189,33 @@ private void loadFromFile() throws IOException { fis.close(); String json = sb.toString(); - Map savedObject = gson.fromJson(json, - new TypeToken>() {}.getType()); + InterpreterInfoSaving info = gson.fromJson(json, InterpreterInfoSaving.class); + + for (String k : info.interpreterSettings.keySet()) { + InterpreterSetting setting = info.interpreterSettings.get(k); - Map> settings = (Map>) savedObject - .get("interpreterSettings"); - Map> bindings = (Map>) savedObject - .get("interpreterBindings"); + // Always use separate interpreter process + // While we decided to turn this feature on always (without providing + // enable/disable option on GUI). + // previously created setting should turn this feature on here. + setting.getOption().setRemote(true); - for (String k : settings.keySet()) { - Map set = settings.get(k); + InterpreterGroup interpreterGroup = createInterpreterGroup( + setting.getGroup(), + setting.getOption(), + setting.getProperties()); - String id = (String) set.get("id"); - String name = (String) set.get("name"); - String group = (String) set.get("group"); - Properties properties = new Properties(); - properties.putAll((Map) set.get("properties")); + InterpreterSetting intpSetting = new InterpreterSetting( + setting.id(), + setting.getName(), + setting.getGroup(), + setting.getOption(), + interpreterGroup); - InterpreterGroup interpreterGroup = createInterpreterGroup(group, properties); - InterpreterSetting intpSetting = new InterpreterSetting(id, name, group, interpreterGroup); interpreterSettings.put(k, intpSetting); } - this.interpreterBindings = bindings; + this.interpreterBindings = info.interpreterBindings; } @@ -209,11 +223,11 @@ private void saveToFile() throws IOException { String jsonString; synchronized (interpreterSettings) { - Map saveObject = new HashMap(); - saveObject.put("interpreterSettings", interpreterSettings); - saveObject.put("interpreterBindings", interpreterBindings); + InterpreterInfoSaving info = new InterpreterInfoSaving(); + info.interpreterBindings = interpreterBindings; + info.interpreterSettings = interpreterSettings; - jsonString = gson.toJson(saveObject); + jsonString = gson.toJson(info); } File settingFile = new File(conf.getInterpreterSettingPath()); @@ -285,14 +299,16 @@ public List getRegisteredInterpreterList() { * @throws InterpreterException * @throws IOException */ - public InterpreterGroup add(String name, String groupName, Properties properties) + public InterpreterGroup add(String name, String groupName, + InterpreterOption option, Properties properties) throws InterpreterException, IOException { synchronized (interpreterSettings) { - InterpreterGroup interpreterGroup = createInterpreterGroup(groupName, properties); + InterpreterGroup interpreterGroup = createInterpreterGroup(groupName, option, properties); InterpreterSetting intpSetting = new InterpreterSetting( name, groupName, + option, interpreterGroup); interpreterSettings.put(intpSetting.id(), intpSetting); @@ -301,7 +317,9 @@ public InterpreterGroup add(String name, String groupName, Properties properties } } - private InterpreterGroup createInterpreterGroup(String groupName, Properties properties) + private InterpreterGroup createInterpreterGroup(String groupName, + InterpreterOption option, + Properties properties) throws InterpreterException { InterpreterGroup interpreterGroup = new InterpreterGroup(); @@ -312,11 +330,19 @@ private InterpreterGroup createInterpreterGroup(String groupName, Properties pro .get(intName); if (info.getClassName().equals(className) && info.getGroup().equals(groupName)) { - Interpreter intp = createRepl(info.getName(), - info.getClassName(), - properties, - interpreterGroup); + Interpreter intp; + + if (option.isRemote()) { + intp = createRemoteRepl(info.getPath(), + info.getClassName(), + properties); + } else { + intp = createRepl(info.getPath(), + info.getClassName(), + properties); + } interpreterGroup.add(intp); + intp.setInterpreterGroup(interpreterGroup); break; } } @@ -424,17 +450,22 @@ public List getNoteInterpreterSettingBinding(String noteId) { * Change interpreter property and restart * @param name * @param properties + * @throws IOException */ - public void setPropertyAndRestart(String id, Properties properties) { + public void setPropertyAndRestart(String id, InterpreterOption option, + Properties properties) throws IOException { synchronized (interpreterSettings) { InterpreterSetting intpsetting = interpreterSettings.get(id); if (intpsetting != null) { intpsetting.getInterpreterGroup().close(); intpsetting.getInterpreterGroup().destroy(); + intpsetting.setOption(option); + InterpreterGroup interpreterGroup = createInterpreterGroup( - intpsetting.getGroup(), properties); + intpsetting.getGroup(), option, properties); intpsetting.setInterpreterGroup(interpreterGroup); + saveToFile(); } else { throw new InterpreterException("Interpreter setting id " + id + " not found"); @@ -451,7 +482,7 @@ public void restart(String id) { intpsetting.getInterpreterGroup().destroy(); InterpreterGroup interpreterGroup = createInterpreterGroup( - intpsetting.getGroup(), intpsetting.getProperties()); + intpsetting.getGroup(), intpsetting.getOption(), intpsetting.getProperties()); intpsetting.setInterpreterGroup(interpreterGroup); } else { throw new InterpreterException("Interpreter setting id " + id @@ -461,8 +492,21 @@ public void restart(String id) { } } + + public void close() { + synchronized (interpreterSettings) { + synchronized (interpreterSettings) { + Collection intpsettings = interpreterSettings.values(); + for (InterpreterSetting intpsetting : intpsettings) { + intpsetting.getInterpreterGroup().close(); + intpsetting.getInterpreterGroup().destroy(); + } + } + } + } + private Interpreter createRepl(String dirName, String className, - Properties property, InterpreterGroup interpreterGroup) + Properties property) throws InterpreterException { logger.info("Create repl {} from {}", className, dirName); @@ -501,7 +545,6 @@ private Interpreter createRepl(String dirName, String className, repl.setClassloaderUrls(ccl.getURLs()); LazyOpenInterpreter intp = new LazyOpenInterpreter( new ClassloaderInterpreter(repl, cl)); - intp.setInterpreterGroup(interpreterGroup); return intp; } catch (SecurityException e) { throw new InterpreterException(e); @@ -522,6 +565,16 @@ private Interpreter createRepl(String dirName, String className, } } + + private Interpreter createRemoteRepl(String interpreterPath, String className, + Properties property) { + + LazyOpenInterpreter intp = new LazyOpenInterpreter(new RemoteInterpreter( + property, className, conf.getInterpreterRemoteRunnerPath(), interpreterPath)); + return intp; + } + + private URL[] recursiveBuildLibList(File path) throws MalformedURLException { URL[] urls = new URL[0]; if (path == null || path.exists() == false) { diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterInfoSaving.java b/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterInfoSaving.java new file mode 100644 index 00000000..02335aec --- /dev/null +++ b/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterInfoSaving.java @@ -0,0 +1,12 @@ +package com.nflabs.zeppelin.interpreter; + +import java.util.List; +import java.util.Map; + +/** + * + */ +public class InterpreterInfoSaving { + public Map interpreterSettings; + public Map> interpreterBindings; +} diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterOption.java b/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterOption.java new file mode 100644 index 00000000..614cc797 --- /dev/null +++ b/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterOption.java @@ -0,0 +1,24 @@ +package com.nflabs.zeppelin.interpreter; + +/** + * + */ +public class InterpreterOption { + boolean remote; + + public InterpreterOption() { + remote = false; + } + + public InterpreterOption(boolean remote) { + this.remote = remote; + } + + public boolean isRemote() { + return remote; + } + + public void setRemote(boolean remote) { + this.remote = remote; + } +} diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterSerializer.java b/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterSerializer.java index 69fd6e53..4d70ccd5 100644 --- a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterSerializer.java +++ b/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterSerializer.java @@ -2,17 +2,21 @@ import java.lang.reflect.Type; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; import com.google.gson.JsonSerializationContext; import com.google.gson.JsonSerializer; /** - * Interpreter class serializer for gson + * Interpreter class serializer for gson * */ -public class InterpreterSerializer implements JsonSerializer { +public class InterpreterSerializer implements JsonSerializer, + JsonDeserializer { @Override public JsonElement serialize(Interpreter interpreter, Type type, @@ -26,4 +30,10 @@ public JsonElement serialize(Interpreter interpreter, Type type, return json; } + @Override + public Interpreter deserialize(JsonElement json, Type typeOfT, + JsonDeserializationContext context) throws JsonParseException { + return null; + } + } diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterSetting.java b/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterSetting.java index dea22a3d..3d0a0178 100644 --- a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterSetting.java +++ b/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/interpreter/InterpreterSetting.java @@ -1,6 +1,5 @@ package com.nflabs.zeppelin.interpreter; -import java.util.Map; import java.util.Properties; import java.util.Random; @@ -16,21 +15,25 @@ public class InterpreterSetting { private String description; private Properties properties; private InterpreterGroup interpreterGroup; - + private InterpreterOption option; + public InterpreterSetting(String id, String name, String group, + InterpreterOption option, InterpreterGroup interpreterGroup) { this.id = id; this.name = name; this.group = group; this.properties = interpreterGroup.getProperty(); + this.option = option; this.interpreterGroup = interpreterGroup; } public InterpreterSetting(String name, String group, + InterpreterOption option, InterpreterGroup interpreterGroup) { - this(generateId(), name, group, interpreterGroup); + this(generateId(), name, group, option, interpreterGroup); } public String id() { @@ -39,7 +42,7 @@ public String id() { private static String generateId() { return IdHashes.encode(System.currentTimeMillis() + new Random().nextInt()); - } + } public String getName() { return name; @@ -73,4 +76,16 @@ public void setInterpreterGroup(InterpreterGroup interpreterGroup) { public Properties getProperties() { return properties; } + + public InterpreterOption getOption() { + if (option == null) { + option = new InterpreterOption(); + } + + return option; + } + + public void setOption(InterpreterOption option) { + this.option = option; + } } diff --git a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/notebook/Paragraph.java b/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/notebook/Paragraph.java index 8b45b125..78e3b875 100644 --- a/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/notebook/Paragraph.java +++ b/zeppelin-zengine/src/main/java/com/nflabs/zeppelin/notebook/Paragraph.java @@ -9,12 +9,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.nflabs.zeppelin.display.GUI; +import com.nflabs.zeppelin.display.Input; import com.nflabs.zeppelin.interpreter.Interpreter; import com.nflabs.zeppelin.interpreter.Interpreter.FormType; import com.nflabs.zeppelin.interpreter.InterpreterContext; import com.nflabs.zeppelin.interpreter.InterpreterResult; -import com.nflabs.zeppelin.notebook.form.Input; -import com.nflabs.zeppelin.notebook.form.Setting; import com.nflabs.zeppelin.scheduler.Job; import com.nflabs.zeppelin.scheduler.JobListener; @@ -30,14 +30,14 @@ public class Paragraph extends Job implements Serializable { String title; String text; private Map config; // paragraph configs like isOpen, colWidth, etc - public final Setting settings; // form and parameter settings + public final GUI settings; // form and parameter settings public Paragraph(JobListener listener, NoteInterpreterLoader replLoader) { super(generateId(), listener); this.replLoader = replLoader; title = null; text = null; - settings = new Setting(); + settings = new GUI(); config = new HashMap(); } @@ -147,7 +147,7 @@ public int progress() { String replName = getRequiredReplName(); Interpreter repl = getRepl(replName); if (repl != null) { - return repl.getProgress(new InterpreterContext(this)); + return repl.getProgress(getInterpreterContext()); } else { return 0; } @@ -172,7 +172,6 @@ protected Object jobRun() throws Throwable { // inject form if (repl.getFormType() == FormType.NATIVE) { settings.clear(); - repl.bindValue("form", settings); // user code will dynamically create inputs } else if (repl.getFormType() == FormType.SIMPLE) { String scriptBody = getScriptBody(); Map inputs = Input.extractSimpleQueryParam(scriptBody); // inputs will be built @@ -181,17 +180,26 @@ protected Object jobRun() throws Throwable { script = Input.getSimpleQuery(settings.getParams(), scriptBody); } logger().info("RUN : " + script); - InterpreterResult ret = repl.interpret(script, new InterpreterContext(this)); + InterpreterResult ret = repl.interpret(script, getInterpreterContext()); return ret; } @Override protected boolean jobAbort() { Interpreter repl = getRepl(getRequiredReplName()); - repl.cancel(new InterpreterContext(this)); + repl.cancel(getInterpreterContext()); return true; } + private InterpreterContext getInterpreterContext() { + InterpreterContext interpreterContext = new InterpreterContext(getId(), + this.getTitle(), + this.getText(), + this.getConfig(), + this.settings); + return interpreterContext; + } + private Logger logger() { Logger logger = LoggerFactory.getLogger(Paragraph.class); return logger; diff --git a/zeppelin-zengine/src/test/java/com/nflabs/zeppelin/interpreter/InterpreterFactoryTest.java b/zeppelin-zengine/src/test/java/com/nflabs/zeppelin/interpreter/InterpreterFactoryTest.java index e0b8c264..dbb65ea4 100644 --- a/zeppelin-zengine/src/test/java/com/nflabs/zeppelin/interpreter/InterpreterFactoryTest.java +++ b/zeppelin-zengine/src/test/java/com/nflabs/zeppelin/interpreter/InterpreterFactoryTest.java @@ -1,6 +1,9 @@ package com.nflabs.zeppelin.interpreter; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; @@ -13,8 +16,6 @@ import com.nflabs.zeppelin.conf.ZeppelinConfiguration; import com.nflabs.zeppelin.conf.ZeppelinConfiguration.ConfVars; -import com.nflabs.zeppelin.interpreter.Interpreter; -import com.nflabs.zeppelin.interpreter.InterpreterFactory; import com.nflabs.zeppelin.interpreter.mock.MockInterpreter1; import com.nflabs.zeppelin.interpreter.mock.MockInterpreter2; @@ -23,6 +24,7 @@ public class InterpreterFactoryTest { private InterpreterFactory factory; private File tmpDir; private ZeppelinConfiguration conf; + private InterpreterContext context; @Before public void setUp() throws Exception { @@ -36,7 +38,9 @@ public void setUp() throws Exception { System.setProperty(ConfVars.ZEPPELIN_HOME.getVarName(), tmpDir.getAbsolutePath()); System.setProperty(ConfVars.ZEPPELIN_INTERPRETERS.getVarName(), "com.nflabs.zeppelin.interpreter.mock.MockInterpreter1,com.nflabs.zeppelin.interpreter.mock.MockInterpreter2"); conf = new ZeppelinConfiguration(); - factory = new InterpreterFactory(conf); + factory = new InterpreterFactory(conf, new InterpreterOption(false)); + context = new InterpreterContext("id", "title", "text", null, null); + } @After @@ -60,11 +64,12 @@ else if(file.isDirectory()){ @Test public void testBasic() { List all = factory.getDefaultInterpreterSettingList(); - + // get interpreter Interpreter repl1 = factory.get(all.get(0)).getInterpreterGroup().getFirst(); - repl1.bindValue("a", 1); - assertEquals(repl1.getValue("a"), 1); + assertFalse(((LazyOpenInterpreter) repl1).isOpen()); + repl1.interpret("repl1", context); + assertTrue(((LazyOpenInterpreter) repl1).isOpen()); // try to get unavailable interpreter assertNull(factory.get("unknown")); @@ -72,7 +77,7 @@ public void testBasic() { // restart interpreter factory.restart(all.get(0)); repl1 = factory.get(all.get(0)).getInterpreterGroup().getFirst(); - assertEquals(repl1.getValue("a"), null); + assertFalse(((LazyOpenInterpreter) repl1).isOpen()); } @Test @@ -83,13 +88,13 @@ public void testFactoryDefaultList() throws InterpreterException, IOException { assertEquals(factory.get(all.get(0)).getInterpreterGroup().getFirst().getClassName(), "com.nflabs.zeppelin.interpreter.mock.MockInterpreter1"); // add setting - factory.add("a mock", "mock2", new Properties()); + factory.add("a mock", "mock2", new InterpreterOption(false), new Properties()); all = factory.getDefaultInterpreterSettingList(); assertEquals(2, all.size()); assertEquals("mock1", factory.get(all.get(0)).getName()); assertEquals("a mock", factory.get(all.get(1)).getName()); } - + @Test public void testSaveLoad() throws InterpreterException, IOException { // interpreter settings @@ -98,7 +103,7 @@ public void testSaveLoad() throws InterpreterException, IOException { // check if file saved assertTrue(new File(conf.getInterpreterSettingPath()).exists()); - factory.add("newsetting", "mock1", new Properties()); + factory.add("newsetting", "mock1", new InterpreterOption(false), new Properties()); assertEquals(3, factory.get().size()); InterpreterFactory factory2 = new InterpreterFactory(conf); diff --git a/zeppelin-zengine/src/test/java/com/nflabs/zeppelin/interpreter/mock/MockInterpreter1.java b/zeppelin-zengine/src/test/java/com/nflabs/zeppelin/interpreter/mock/MockInterpreter1.java index af029c05..dfdfea76 100644 --- a/zeppelin-zengine/src/test/java/com/nflabs/zeppelin/interpreter/mock/MockInterpreter1.java +++ b/zeppelin-zengine/src/test/java/com/nflabs/zeppelin/interpreter/mock/MockInterpreter1.java @@ -26,11 +26,6 @@ public void open() { public void close() { } - @Override - public Object getValue(String name) { - return vars.get(name); - } - @Override public InterpreterResult interpret(String st, InterpreterContext context) { return new InterpreterResult(InterpreterResult.Code.SUCCESS, "repl1: "+st); @@ -40,11 +35,6 @@ public InterpreterResult interpret(String st, InterpreterContext context) { public void cancel(InterpreterContext context) { } - @Override - public void bindValue(String name, Object o) { - vars.put(name, o); - } - @Override public FormType getFormType() { return FormType.SIMPLE; diff --git a/zeppelin-zengine/src/test/java/com/nflabs/zeppelin/interpreter/mock/MockInterpreter2.java b/zeppelin-zengine/src/test/java/com/nflabs/zeppelin/interpreter/mock/MockInterpreter2.java index e649863a..c5db6548 100644 --- a/zeppelin-zengine/src/test/java/com/nflabs/zeppelin/interpreter/mock/MockInterpreter2.java +++ b/zeppelin-zengine/src/test/java/com/nflabs/zeppelin/interpreter/mock/MockInterpreter2.java @@ -26,11 +26,6 @@ public void open() { public void close() { } - @Override - public Object getValue(String name) { - return vars.get(name); - } - @Override public InterpreterResult interpret(String st, InterpreterContext context) { return new InterpreterResult(InterpreterResult.Code.SUCCESS, "repl2: "+st); @@ -40,11 +35,6 @@ public InterpreterResult interpret(String st, InterpreterContext context) { public void cancel(InterpreterContext context) { } - @Override - public void bindValue(String name, Object o) { - vars.put(name, o); - } - @Override public FormType getFormType() { return FormType.SIMPLE; diff --git a/zeppelin-zengine/src/test/java/com/nflabs/zeppelin/notebook/NotebookTest.java b/zeppelin-zengine/src/test/java/com/nflabs/zeppelin/notebook/NotebookTest.java index 09e9c8e2..0539b081 100644 --- a/zeppelin-zengine/src/test/java/com/nflabs/zeppelin/notebook/NotebookTest.java +++ b/zeppelin-zengine/src/test/java/com/nflabs/zeppelin/notebook/NotebookTest.java @@ -1,6 +1,8 @@ package com.nflabs.zeppelin.notebook; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import java.io.File; import java.io.IOException; @@ -15,11 +17,9 @@ import com.nflabs.zeppelin.conf.ZeppelinConfiguration; import com.nflabs.zeppelin.conf.ZeppelinConfiguration.ConfVars; import com.nflabs.zeppelin.interpreter.InterpreterFactory; +import com.nflabs.zeppelin.interpreter.InterpreterOption; import com.nflabs.zeppelin.interpreter.mock.MockInterpreter1; import com.nflabs.zeppelin.interpreter.mock.MockInterpreter2; -import com.nflabs.zeppelin.notebook.Note; -import com.nflabs.zeppelin.notebook.Notebook; -import com.nflabs.zeppelin.notebook.Paragraph; import com.nflabs.zeppelin.scheduler.Job; import com.nflabs.zeppelin.scheduler.Job.Status; import com.nflabs.zeppelin.scheduler.JobListener; @@ -36,7 +36,7 @@ public class NotebookTest implements JobListenerFactory{ @Before public void setUp() throws Exception { - tmpDir = new File(System.getProperty("java.io.tmpdir")+"/ZeppelinLTest_"+System.currentTimeMillis()); + tmpDir = new File(System.getProperty("java.io.tmpdir")+"/ZeppelinLTest_"+System.currentTimeMillis()); tmpDir.mkdirs(); new File(tmpDir, "conf").mkdirs(); notebookDir = new File(System.getProperty("java.io.tmpdir")+"/ZeppelinLTest_"+System.currentTimeMillis()+"/notebook"); @@ -45,16 +45,16 @@ public void setUp() throws Exception { System.setProperty(ConfVars.ZEPPELIN_HOME.getVarName(), tmpDir.getAbsolutePath()); System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), notebookDir.getAbsolutePath()); System.setProperty(ConfVars.ZEPPELIN_INTERPRETERS.getVarName(), "com.nflabs.zeppelin.interpreter.mock.MockInterpreter1,com.nflabs.zeppelin.interpreter.mock.MockInterpreter2"); - + conf = ZeppelinConfiguration.create(); - + this.schedulerFactory = new SchedulerFactory(); - + MockInterpreter1.register("mock1", "com.nflabs.zeppelin.interpreter.mock.MockInterpreter1"); MockInterpreter2.register("mock2", "com.nflabs.zeppelin.interpreter.mock.MockInterpreter2"); - - factory = new InterpreterFactory(conf); - + + factory = new InterpreterFactory(conf, new InterpreterOption(false)); + notebook = new Notebook(conf, schedulerFactory, factory, this); } @@ -67,14 +67,14 @@ public void tearDown() throws Exception { public void testSelectingReplImplementation() throws IOException { Note note = notebook.createNote(); note.getNoteReplLoader().setInterpreters(factory.getDefaultInterpreterSettingList()); - + // run with defatul repl Paragraph p1 = note.addParagraph(); p1.setText("hello world"); note.run(p1.getId()); while(p1.isTerminated()==false || p1.getResult()==null) Thread.yield(); assertEquals("repl1: hello world", p1.getResult().message()); - + // run with specific repl Paragraph p2 = note.addParagraph(); p2.setText("%mock2 hello world"); @@ -82,20 +82,20 @@ public void testSelectingReplImplementation() throws IOException { while(p2.isTerminated()==false || p2.getResult()==null) Thread.yield(); assertEquals("repl2: hello world", p2.getResult().message()); } - + @Test public void testPersist() throws IOException, SchedulerException{ Note note = notebook.createNote(); - + // run with default repl Paragraph p1 = note.addParagraph(); p1.setText("hello world"); note.persist(); - + Notebook notebook2 = new Notebook(conf, schedulerFactory, new InterpreterFactory(conf), this); assertEquals(1, notebook2.getAllNotes().size()); } - + @Test public void testRunAll() throws IOException { Note note = notebook.createNote(); @@ -107,11 +107,11 @@ public void testRunAll() throws IOException { p2.setText("p2"); assertEquals(null, p2.getResult()); note.runAll(); - + while(p2.isTerminated()==false || p2.getResult()==null) Thread.yield(); assertEquals("repl1: p2", p2.getResult().message()); } - + @Test public void testSchedule() throws InterruptedException, IOException{ // create a note and a paragraph @@ -122,7 +122,7 @@ public void testSchedule() throws InterruptedException, IOException{ p.setText("p1"); Date dateFinished = p.getDateFinished(); assertNull(dateFinished); - + // set cron scheduler, once a second Map config = note.getConfig(); config.put("cron", "* * * * * ?"); @@ -131,7 +131,7 @@ public void testSchedule() throws InterruptedException, IOException{ Thread.sleep(1*1000); dateFinished = p.getDateFinished(); assertNotNull(dateFinished); - + // remove cron scheduler. config.put("cron", null); note.setConfig(config); @@ -139,7 +139,7 @@ public void testSchedule() throws InterruptedException, IOException{ Thread.sleep(1*1000); assertEquals(dateFinished, p.getDateFinished()); } - + private void delete(File file){ if(file.isFile()) file.delete(); else if(file.isDirectory()){ @@ -167,7 +167,7 @@ public void beforeStatusChange(Job job, Status before, Status after) { @Override public void afterStatusChange(Job job, Status before, Status after) { - } + } }; } }