http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/socket/Message.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/socket/Message.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/socket/Message.java index 0e8c4ed..06499f3 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/socket/Message.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/socket/Message.java @@ -18,33 +18,38 @@ package org.apache.zeppelin.notebook.socket; import com.google.gson.Gson; -import java.util.HashMap; -import java.util.Map; import org.apache.zeppelin.common.JsonSerializable; import org.slf4j.Logger; -/** Zeppelin websocket massage template class. */ +import java.util.HashMap; +import java.util.Map; + +/** + * Zeppelin websocket massage template class. + */ public class Message implements JsonSerializable { - /** Representation of event type. */ + /** + * Representation of event type. + */ public static enum OP { - GET_HOME_NOTE, // [c-s] load note for home screen + GET_HOME_NOTE, // [c-s] load note for home screen - GET_NOTE, // [c-s] client load note - // @param id note id + GET_NOTE, // [c-s] client load note + // @param id note id - NOTE, // [s-c] note info - // @param note serialized Note object + NOTE, // [s-c] note info + // @param note serialized Note object - PARAGRAPH, // [s-c] paragraph info - // @param paragraph serialized paragraph object + PARAGRAPH, // [s-c] paragraph info + // @param paragraph serialized paragraph object - PROGRESS, // [s-c] progress update - // @param id paragraph id - // @param progress percentage progress + PROGRESS, // [s-c] progress update + // @param id paragraph id + // @param progress percentage progress - NEW_NOTE, // [c-s] create new notebook - DEL_NOTE, // [c-s] delete notebook - // @param id note id + NEW_NOTE, // [c-s] create new notebook + DEL_NOTE, // [c-s] delete notebook + // @param id note id REMOVE_FOLDER, MOVE_NOTE_TO_TRASH, MOVE_FOLDER_TO_TRASH, @@ -52,143 +57,143 @@ public class Message implements JsonSerializable { RESTORE_NOTE, RESTORE_ALL, EMPTY_TRASH, - CLONE_NOTE, // [c-s] clone new notebook - // @param id id of note to clone - // @param name name for the cloned note - IMPORT_NOTE, // [c-s] import notebook - // @param object notebook + CLONE_NOTE, // [c-s] clone new notebook + // @param id id of note to clone + // @param name name for the cloned note + IMPORT_NOTE, // [c-s] import notebook + // @param object notebook NOTE_UPDATE, NOTE_RENAME, UPDATE_PERSONALIZED_MODE, // [c-s] update personalized mode (boolean) - // @param note id and boolean personalized mode value + // @param note id and boolean personalized mode value FOLDER_RENAME, - RUN_PARAGRAPH, // [c-s] run paragraph - // @param id paragraph id - // @param paragraph paragraph content.ie. script - // @param config paragraph config - // @param params paragraph params + RUN_PARAGRAPH, // [c-s] run paragraph + // @param id paragraph id + // @param paragraph paragraph content.ie. script + // @param config paragraph config + // @param params paragraph params COMMIT_PARAGRAPH, // [c-s] commit paragraph - // @param id paragraph id - // @param title paragraph title - // @param paragraph paragraph content.ie. script - // @param config paragraph config - // @param params paragraph params + // @param id paragraph id + // @param title paragraph title + // @param paragraph paragraph content.ie. script + // @param config paragraph config + // @param params paragraph params CANCEL_PARAGRAPH, // [c-s] cancel paragraph run - // @param id paragraph id + // @param id paragraph id - MOVE_PARAGRAPH, // [c-s] move paragraph order - // @param id paragraph id - // @param index index the paragraph want to go + MOVE_PARAGRAPH, // [c-s] move paragraph order + // @param id paragraph id + // @param index index the paragraph want to go INSERT_PARAGRAPH, // [c-s] create new paragraph below current paragraph - // @param target index + // @param target index - COPY_PARAGRAPH, // [c-s] create new para below current para as a copy of current para - // @param target index - // @param title paragraph title - // @param paragraph paragraph content.ie. script - // @param config paragraph config - // @param params paragraph params + COPY_PARAGRAPH, // [c-s] create new para below current para as a copy of current para + // @param target index + // @param title paragraph title + // @param paragraph paragraph content.ie. script + // @param config paragraph config + // @param params paragraph params - EDITOR_SETTING, // [c-s] ask paragraph editor setting - // @param magic magic keyword written in paragraph - // ex) spark.spark or spark + EDITOR_SETTING, // [c-s] ask paragraph editor setting + // @param magic magic keyword written in paragraph + // ex) spark.spark or spark - COMPLETION, // [c-s] ask completion candidates - // @param id - // @param buf current code - // @param cursor cursor position in code + COMPLETION, // [c-s] ask completion candidates + // @param id + // @param buf current code + // @param cursor cursor position in code - COMPLETION_LIST, // [s-c] send back completion candidates list - // @param id - // @param completions list of string + COMPLETION_LIST, // [s-c] send back completion candidates list + // @param id + // @param completions list of string - LIST_NOTES, // [c-s] ask list of note - RELOAD_NOTES_FROM_REPO, // [c-s] reload notes from repo + LIST_NOTES, // [c-s] ask list of note + RELOAD_NOTES_FROM_REPO, // [c-s] reload notes from repo - NOTES_INFO, // [s-c] list of note infos - // @param notes serialized List<NoteInfo> object + NOTES_INFO, // [s-c] list of note infos + // @param notes serialized List<NoteInfo> object PARAGRAPH_REMOVE, - PARAGRAPH_CLEAR_OUTPUT, // [c-s] clear output of paragraph - PARAGRAPH_CLEAR_ALL_OUTPUT, // [c-s] clear output of all paragraphs - PARAGRAPH_APPEND_OUTPUT, // [s-c] append output - PARAGRAPH_UPDATE_OUTPUT, // [s-c] update (replace) output + PARAGRAPH_CLEAR_OUTPUT, // [c-s] clear output of paragraph + PARAGRAPH_CLEAR_ALL_OUTPUT, // [c-s] clear output of all paragraphs + PARAGRAPH_APPEND_OUTPUT, // [s-c] append output + PARAGRAPH_UPDATE_OUTPUT, // [s-c] update (replace) output PING, AUTH_INFO, - ANGULAR_OBJECT_UPDATE, // [s-c] add/update angular object - ANGULAR_OBJECT_REMOVE, // [s-c] add angular object del + ANGULAR_OBJECT_UPDATE, // [s-c] add/update angular object + ANGULAR_OBJECT_REMOVE, // [s-c] add angular object del + + ANGULAR_OBJECT_UPDATED, // [c-s] angular object value updated, - ANGULAR_OBJECT_UPDATED, // [c-s] angular object value updated, - - ANGULAR_OBJECT_CLIENT_BIND, // [c-s] angular object updated from AngularJS z object + ANGULAR_OBJECT_CLIENT_BIND, // [c-s] angular object updated from AngularJS z object ANGULAR_OBJECT_CLIENT_UNBIND, // [c-s] angular object unbind from AngularJS z object - LIST_CONFIGURATIONS, // [c-s] ask all key/value pairs of configurations - CONFIGURATIONS_INFO, // [s-c] all key/value pairs of configurations - // @param settings serialized Map<String, String> object - - CHECKPOINT_NOTE, // [c-s] checkpoint note to storage repository - // @param noteId - // @param checkpointName - - LIST_REVISION_HISTORY, // [c-s] list revision history of the notebook - // @param noteId - NOTE_REVISION, // [c-s] get certain revision of note - // @param noteId - // @param revisionId - SET_NOTE_REVISION, // [c-s] set current notebook head to this revision - // @param noteId - // @param revisionId - NOTE_REVISION_FOR_COMPARE, // [c-s] get certain revision of note for compare - // @param noteId - // @param revisionId - // @param position - APP_APPEND_OUTPUT, // [s-c] append output - APP_UPDATE_OUTPUT, // [s-c] update (replace) output - APP_LOAD, // [s-c] on app load - APP_STATUS_CHANGE, // [s-c] on app status change - - LIST_NOTE_JOBS, // [c-s] get note job management information - LIST_UPDATE_NOTE_JOBS, // [c-s] get job management information for until unixtime + LIST_CONFIGURATIONS, // [c-s] ask all key/value pairs of configurations + CONFIGURATIONS_INFO, // [s-c] all key/value pairs of configurations + // @param settings serialized Map<String, String> object + + CHECKPOINT_NOTE, // [c-s] checkpoint note to storage repository + // @param noteId + // @param checkpointName + + LIST_REVISION_HISTORY, // [c-s] list revision history of the notebook + // @param noteId + NOTE_REVISION, // [c-s] get certain revision of note + // @param noteId + // @param revisionId + SET_NOTE_REVISION, // [c-s] set current notebook head to this revision + // @param noteId + // @param revisionId + NOTE_REVISION_FOR_COMPARE, // [c-s] get certain revision of note for compare + // @param noteId + // @param revisionId + // @param position + APP_APPEND_OUTPUT, // [s-c] append output + APP_UPDATE_OUTPUT, // [s-c] update (replace) output + APP_LOAD, // [s-c] on app load + APP_STATUS_CHANGE, // [s-c] on app status change + + LIST_NOTE_JOBS, // [c-s] get note job management information + LIST_UPDATE_NOTE_JOBS, // [c-s] get job management information for until unixtime UNSUBSCRIBE_UPDATE_NOTE_JOBS, // [c-s] unsubscribe job information for job management // @param unixTime - GET_INTERPRETER_BINDINGS, // [c-s] get interpreter bindings - INTERPRETER_BINDINGS, // [s-c] interpreter bindings - - GET_INTERPRETER_SETTINGS, // [c-s] get interpreter settings - INTERPRETER_SETTINGS, // [s-c] interpreter settings - ERROR_INFO, // [s-c] error information to be sent - SESSION_LOGOUT, // [s-c] error information to be sent - WATCHER, // [s-c] Change websocket to watcher mode. - PARAGRAPH_ADDED, // [s-c] paragraph is added - PARAGRAPH_REMOVED, // [s-c] paragraph deleted - PARAGRAPH_MOVED, // [s-c] paragraph moved - NOTE_UPDATED, // [s-c] paragraph updated(name, config) - RUN_ALL_PARAGRAPHS, // [c-s] run all paragraphs - PARAGRAPH_EXECUTED_BY_SPELL, // [c-s] paragraph was executed by spell - RUN_PARAGRAPH_USING_SPELL, // [s-c] run paragraph using spell - PARAS_INFO, // [s-c] paragraph runtime infos - SAVE_NOTE_FORMS, // save note forms - REMOVE_NOTE_FORMS, // remove note forms - INTERPRETER_INSTALL_STARTED, // [s-c] start to download an interpreter - INTERPRETER_INSTALL_RESULT, // [s-c] Status of an interpreter installation - COLLABORATIVE_MODE_STATUS, // [s-c] collaborative mode status - PATCH_PARAGRAPH, // [c-s][s-c] patch editor text - NOTICE // [s-c] Notice + GET_INTERPRETER_BINDINGS, // [c-s] get interpreter bindings + INTERPRETER_BINDINGS, // [s-c] interpreter bindings + + GET_INTERPRETER_SETTINGS, // [c-s] get interpreter settings + INTERPRETER_SETTINGS, // [s-c] interpreter settings + ERROR_INFO, // [s-c] error information to be sent + SESSION_LOGOUT, // [s-c] error information to be sent + WATCHER, // [s-c] Change websocket to watcher mode. + PARAGRAPH_ADDED, // [s-c] paragraph is added + PARAGRAPH_REMOVED, // [s-c] paragraph deleted + PARAGRAPH_MOVED, // [s-c] paragraph moved + NOTE_UPDATED, // [s-c] paragraph updated(name, config) + RUN_ALL_PARAGRAPHS, // [c-s] run all paragraphs + PARAGRAPH_EXECUTED_BY_SPELL, // [c-s] paragraph was executed by spell + RUN_PARAGRAPH_USING_SPELL, // [s-c] run paragraph using spell + PARAS_INFO, // [s-c] paragraph runtime infos + SAVE_NOTE_FORMS, // save note forms + REMOVE_NOTE_FORMS, // remove note forms + INTERPRETER_INSTALL_STARTED, // [s-c] start to download an interpreter + INTERPRETER_INSTALL_RESULT, // [s-c] Status of an interpreter installation + COLLABORATIVE_MODE_STATUS, // [s-c] collaborative mode status + PATCH_PARAGRAPH, // [c-s][s-c] patch editor text + NOTICE // [s-c] Notice } private static final Gson gson = new Gson(); public static final Message EMPTY = new Message(null); - + public OP op; public Map<String, Object> data = new HashMap<>(); public String ticket = "anonymous"; @@ -216,7 +221,7 @@ public class Message implements JsonSerializable { try { return getType(key); } catch (ClassCastException e) { - LOG.error("Failed to get " + key + " from message (Invalid type). ", e); + LOG.error("Failed to get " + key + " from message (Invalid type). " , e); return null; } }
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/socket/WatcherMessage.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/socket/WatcherMessage.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/socket/WatcherMessage.java index 9445c38..c982ca7 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/socket/WatcherMessage.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/socket/WatcherMessage.java @@ -19,25 +19,27 @@ package org.apache.zeppelin.notebook.socket; import com.google.gson.Gson; import org.apache.zeppelin.common.JsonSerializable; -/** Zeppelin websocket massage template class for watcher socket. */ +/** + * Zeppelin websocket massage template class for watcher socket. + */ public class WatcherMessage implements JsonSerializable { public String message; public String noteId; public String subject; - + private static final Gson gson = new Gson(); - + public static Builder builder(String noteId) { return new Builder(noteId); } - + private WatcherMessage(Builder builder) { this.noteId = builder.noteId; this.message = builder.message; this.subject = builder.subject; } - + public String toJson() { return gson.toJson(this); } @@ -46,21 +48,23 @@ public class WatcherMessage implements JsonSerializable { return gson.fromJson(json, WatcherMessage.class); } - /** Simple builder. */ + /** + * Simple builder. + */ public static class Builder { private final String noteId; private String subject; private String message; - + public Builder(String noteId) { this.noteId = noteId; } - + public Builder subject(String subject) { this.subject = subject; return this; } - + public Builder message(String message) { this.message = message; return this; @@ -70,4 +74,5 @@ public class WatcherMessage implements JsonSerializable { return new WatcherMessage(this); } } + } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/utility/IdHashes.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/utility/IdHashes.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/utility/IdHashes.java index add4a3a..7b0d804 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/utility/IdHashes.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/utility/IdHashes.java @@ -22,13 +22,13 @@ import java.security.SecureRandom; import java.util.ArrayList; import java.util.List; -/** Generate Tiny ID. */ +/** + * Generate Tiny ID. + */ public class IdHashes { - private static final char[] DICTIONARY = - new char[] { - '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', - 'K', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' - }; + private static final char[] DICTIONARY = new char[] {'1', '2', '3', '4', '5', '6', '7', '8', '9', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', + 'W', 'X', 'Y', 'Z'}; /** * encodes the given string into the base of the dictionary provided in the constructor. http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/main/java/org/apache/zeppelin/plugin/PluginManager.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/plugin/PluginManager.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/plugin/PluginManager.java index 4bf8ade..5f7dc1d 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/plugin/PluginManager.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/plugin/PluginManager.java @@ -18,6 +18,13 @@ package org.apache.zeppelin.plugin; import com.google.common.annotations.VisibleForTesting; +import org.apache.zeppelin.conf.ZeppelinConfiguration; +import org.apache.zeppelin.interpreter.launcher.InterpreterLauncher; +import org.apache.zeppelin.interpreter.recovery.RecoveryStorage; +import org.apache.zeppelin.notebook.repo.NotebookRepo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; @@ -27,14 +34,11 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.zeppelin.conf.ZeppelinConfiguration; -import org.apache.zeppelin.interpreter.launcher.InterpreterLauncher; -import org.apache.zeppelin.interpreter.recovery.RecoveryStorage; -import org.apache.zeppelin.notebook.repo.NotebookRepo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import java.util.concurrent.ConcurrentHashMap; -/** Class for loading Plugins */ +/** + * Class for loading Plugins + */ public class PluginManager { private static final Logger LOGGER = LoggerFactory.getLogger(PluginManager.class); @@ -59,30 +63,24 @@ public class PluginManager { String isTest = System.getenv("IS_ZEPPELIN_TEST"); if (isTest != null && isTest.equals("true")) { try { - NotebookRepo notebookRepo = - (NotebookRepo) (Class.forName(notebookRepoClassName).newInstance()); + NotebookRepo notebookRepo = (NotebookRepo) + (Class.forName(notebookRepoClassName).newInstance()); return notebookRepo; } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { - LOGGER.warn( - "Fail to instantiate notebookrepo from classpath directly:" + notebookRepoClassName, e); + LOGGER.warn("Fail to instantiate notebookrepo from classpath directly:" + notebookRepoClassName, e); } } - String simpleClassName = - notebookRepoClassName.substring(notebookRepoClassName.lastIndexOf(".") + 1); - URLClassLoader pluginClassLoader = - getPluginClassLoader(pluginsDir, "NotebookRepo", simpleClassName); + String simpleClassName = notebookRepoClassName.substring(notebookRepoClassName.lastIndexOf(".") + 1); + URLClassLoader pluginClassLoader = getPluginClassLoader(pluginsDir, "NotebookRepo", simpleClassName); if (pluginClassLoader == null) { return null; } NotebookRepo notebookRepo = null; try { - notebookRepo = - (NotebookRepo) - (Class.forName(notebookRepoClassName, true, pluginClassLoader)).newInstance(); + notebookRepo = (NotebookRepo) (Class.forName(notebookRepoClassName, true, pluginClassLoader)).newInstance(); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { - LOGGER.warn( - "Fail to instantiate notebookrepo from plugin classpath:" + notebookRepoClassName, e); + LOGGER.warn("Fail to instantiate notebookrepo from plugin classpath:" + notebookRepoClassName, e); } if (notebookRepo == null) { @@ -91,8 +89,9 @@ public class PluginManager { return notebookRepo; } - public synchronized InterpreterLauncher loadInterpreterLauncher( - String launcherPlugin, RecoveryStorage recoveryStorage) throws IOException { + public synchronized InterpreterLauncher loadInterpreterLauncher(String launcherPlugin, + RecoveryStorage recoveryStorage) + throws IOException { if (cachedLaunchers.containsKey(launcherPlugin)) { return cachedLaunchers.get(launcherPlugin); @@ -102,16 +101,11 @@ public class PluginManager { String pluginClass = "org.apache.zeppelin.interpreter.launcher." + launcherPlugin; InterpreterLauncher launcher = null; try { - launcher = - (InterpreterLauncher) - (Class.forName(pluginClass, true, pluginClassLoader)) - .getConstructor(ZeppelinConfiguration.class, RecoveryStorage.class) - .newInstance(zConf, recoveryStorage); - } catch (InstantiationException - | IllegalAccessException - | ClassNotFoundException - | NoSuchMethodException - | InvocationTargetException e) { + launcher = (InterpreterLauncher) (Class.forName(pluginClass, true, pluginClassLoader)) + .getConstructor(ZeppelinConfiguration.class, RecoveryStorage.class) + .newInstance(zConf, recoveryStorage); + } catch (InstantiationException | IllegalAccessException | ClassNotFoundException + | NoSuchMethodException | InvocationTargetException e) { LOGGER.warn("Fail to instantiate Launcher from plugin classpath:" + launcherPlugin, e); } @@ -122,29 +116,25 @@ public class PluginManager { return launcher; } - private URLClassLoader getPluginClassLoader( - String pluginsDir, String pluginType, String pluginName) throws IOException { + private URLClassLoader getPluginClassLoader(String pluginsDir, + String pluginType, + String pluginName) throws IOException { File pluginFolder = new File(pluginsDir + "/" + pluginType + "/" + pluginName); if (!pluginFolder.exists() || pluginFolder.isFile()) { - LOGGER.warn( - "PluginFolder " - + pluginFolder.getAbsolutePath() - + " doesn't exist or is not a directory"); + LOGGER.warn("PluginFolder " + pluginFolder.getAbsolutePath() + + " doesn't exist or is not a directory"); return null; } List<URL> urls = new ArrayList<>(); for (File file : pluginFolder.listFiles()) { - LOGGER.debug("Add file " + file.getAbsolutePath() + " to classpath of plugin: " + pluginName); + LOGGER.debug("Add file " + file.getAbsolutePath() + " to classpath of plugin: " + + pluginName); urls.add(file.toURI().toURL()); } if (urls.isEmpty()) { - LOGGER.warn( - "Can not load plugin " - + pluginName - + ", because the plugin folder " - + pluginFolder - + " is empty."); + LOGGER.warn("Can not load plugin " + pluginName + + ", because the plugin folder " + pluginFolder + " is empty."); return null; } return new URLClassLoader(urls.toArray(new URL[0])); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/main/java/org/apache/zeppelin/scheduler/RemoteScheduler.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/scheduler/RemoteScheduler.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/scheduler/RemoteScheduler.java index 5a47299..d6d1df7 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/scheduler/RemoteScheduler.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/scheduler/RemoteScheduler.java @@ -17,11 +17,6 @@ package org.apache.zeppelin.scheduler; -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.concurrent.ExecutorService; import org.apache.zeppelin.interpreter.InterpreterResult; import org.apache.zeppelin.interpreter.InterpreterResult.Code; import org.apache.zeppelin.interpreter.remote.RemoteInterpreter; @@ -29,7 +24,16 @@ import org.apache.zeppelin.scheduler.Job.Status; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** RemoteScheduler runs in ZeppelinServer and proxies Scheduler running on RemoteInterpreter */ +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.ExecutorService; + +/** + * RemoteScheduler runs in ZeppelinServer and proxies Scheduler running on RemoteInterpreter + * + */ public class RemoteScheduler implements Scheduler { Logger logger = LoggerFactory.getLogger(RemoteScheduler.class); @@ -43,13 +47,9 @@ public class RemoteScheduler implements Scheduler { private final String sessionId; private RemoteInterpreter remoteInterpreter; - public RemoteScheduler( - String name, - ExecutorService executor, - String sessionId, - RemoteInterpreter remoteInterpreter, - SchedulerListener listener, - int maxConcurrency) { + public RemoteScheduler(String name, ExecutorService executor, String sessionId, + RemoteInterpreter remoteInterpreter, SchedulerListener listener, + int maxConcurrency) { this.name = name; this.executor = executor; this.listener = listener; @@ -88,10 +88,8 @@ public class RemoteScheduler implements Scheduler { try { queue.wait(500); } catch (InterruptedException e) { - logger.error( - "Exception in RemoteScheduler while jobRunner.isJobSubmittedInRemote " - + "queue.wait", - e); + logger.error("Exception in RemoteScheduler while jobRunner.isJobSubmittedInRemote " + + "queue.wait", e); } } } @@ -160,7 +158,10 @@ public class RemoteScheduler implements Scheduler { } } - /** Role of the class is get status info from remote process from PENDING to RUNNING status. */ + /** + * 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; @@ -170,11 +171,8 @@ public class RemoteScheduler implements Scheduler { private Job job; volatile Status lastStatus; - public JobStatusPoller( - long initialPeriodMsec, - long initialPeriodCheckIntervalMsec, - long checkIntervalMsec, - Job job, + public JobStatusPoller(long initialPeriodMsec, + long initialPeriodCheckIntervalMsec, long checkIntervalMsec, Job job, JobListener listener) { setName("JobStatusPoller-" + job.getId()); this.initialPeriodMsec = initialPeriodMsec; @@ -230,13 +228,14 @@ public class RemoteScheduler implements Scheduler { } } + private Status getLastStatus() { if (terminate == true) { if (job.getErrorMessage() != null) { return Status.ERROR; - } else if (lastStatus != Status.FINISHED - && lastStatus != Status.ERROR - && lastStatus != Status.ABORT) { + } else if (lastStatus != Status.FINISHED && + lastStatus != Status.ERROR && + lastStatus != Status.ABORT) { return Status.FINISHED; } else { return (lastStatus == null) ? Status.FINISHED : lastStatus; @@ -262,7 +261,7 @@ public class RemoteScheduler implements Scheduler { } } - // TODO(zjffdu) need to refactor the schdule module which is too complicated + //TODO(zjffdu) need to refactor the schdule module which is too complicated private class JobRunner implements Runnable, JobListener { private final Logger logger = LoggerFactory.getLogger(JobRunner.class); private Scheduler scheduler; @@ -296,7 +295,8 @@ public class RemoteScheduler implements Scheduler { return; } - JobStatusPoller jobStatusPoller = new JobStatusPoller(1500, 100, 500, job, this); + JobStatusPoller jobStatusPoller = new JobStatusPoller(1500, 100, 500, + job, this); jobStatusPoller.start(); if (listener != null) { @@ -321,8 +321,7 @@ public class RemoteScheduler implements Scheduler { } else if (job.getException() != null) { logger.debug("Job ABORT, " + job.getId() + ", " + job.getErrorMessage()); job.setStatus(Status.ERROR); - } else if (jobResult != null - && jobResult instanceof InterpreterResult + } else if (jobResult != null && jobResult instanceof InterpreterResult && ((InterpreterResult) jobResult).code() == Code.ERROR) { logger.debug("Job Error, " + job.getId() + ", " + job.getErrorMessage()); job.setStatus(Status.ERROR); @@ -345,13 +344,15 @@ public class RemoteScheduler implements Scheduler { } @Override - public void onProgressUpdate(Job job, int progress) {} + public void onProgressUpdate(Job job, int progress) { + } @Override public void onStatusChange(Job job, Status before, Status after) { // Update remoteStatus if (jobExecuted == false) { - if (after == Status.FINISHED || after == Status.ABORT || after == Status.ERROR) { + if (after == Status.FINISHED || after == Status.ABORT + || after == Status.ERROR) { // it can be status of last run. // so not updating the remoteStatus return; @@ -377,5 +378,7 @@ public class RemoteScheduler implements Scheduler { synchronized (queue) { queue.notify(); } + } + } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/main/java/org/apache/zeppelin/search/SearchService.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/search/SearchService.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/search/SearchService.java index dfa9212..0b86ac6 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/search/SearchService.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/search/SearchService.java @@ -20,14 +20,16 @@ import java.io.IOException; import java.util.Collection; import java.util.List; import java.util.Map; + import org.apache.zeppelin.notebook.Note; import org.apache.zeppelin.notebook.Paragraph; /** * Search (both, indexing and query) the notes. - * - * <p>Intended to have multiple implementation, i.e: - local Lucene (in-memory, on-disk) - remote - * Elasticsearch + * + * Intended to have multiple implementation, i.e: + * - local Lucene (in-memory, on-disk) + * - remote Elasticsearch */ public interface SearchService { @@ -40,7 +42,9 @@ public interface SearchService { public List<Map<String, String>> query(String queryStr); /** - * Updates all documents in index for the given note: - name - all paragraphs + * Updates all documents in index for the given note: + * - name + * - all paragraphs * * @param note a Note to update index for * @throws IOException @@ -61,7 +65,9 @@ public interface SearchService { */ public void addIndexDoc(Note note); - /** Deletes all docs on given Note from index */ + /** + * Deletes all docs on given Note from index + */ public void deleteIndexDocs(Note note); /** @@ -73,6 +79,9 @@ public interface SearchService { */ public void deleteIndexDoc(Note note, Paragraph p); - /** Frees the recourses used by index */ + /** + * Frees the recourses used by index + */ public void close(); + } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/main/java/org/apache/zeppelin/storage/ConfigStorage.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/storage/ConfigStorage.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/storage/ConfigStorage.java index d697473..b3175e5 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/storage/ConfigStorage.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/storage/ConfigStorage.java @@ -15,22 +15,31 @@ * limitations under the License. */ + package org.apache.zeppelin.storage; import com.google.common.annotations.VisibleForTesting; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import java.io.IOException; import org.apache.zeppelin.conf.ZeppelinConfiguration; +import org.apache.zeppelin.helium.HeliumConf; import org.apache.zeppelin.interpreter.InterpreterInfoSaving; import org.apache.zeppelin.interpreter.InterpreterSetting; import org.apache.zeppelin.notebook.NotebookAuthorizationInfoSaving; +import org.apache.zeppelin.user.Credentials; +import org.apache.zeppelin.user.CredentialsInfoSaving; import org.apache.zeppelin.util.ReflectionUtils; +import java.io.IOException; + /** * Interface for storing zeppelin configuration. * - * <p>1. interpreter-setting.json 2. helium.json 3. notebook-authorization.json 4. credentials.json + * 1. interpreter-setting.json + * 2. helium.json + * 3. notebook-authorization.json + * 4. credentials.json + * */ public abstract class ConfigStorage { @@ -49,10 +58,11 @@ public abstract class ConfigStorage { private static ConfigStorage createConfigStorage(ZeppelinConfiguration zConf) throws IOException { String configStorageClass = zConf.getString(ZeppelinConfiguration.ConfVars.ZEPPELIN_CONFIG_STORAGE_CLASS); - return ReflectionUtils.createClazzInstance( - configStorageClass, new Class[] {ZeppelinConfiguration.class}, new Object[] {zConf}); + return ReflectionUtils.createClazzInstance(configStorageClass, + new Class[] {ZeppelinConfiguration.class}, new Object[] {zConf}); } + public ConfigStorage(ZeppelinConfiguration zConf) { this.zConf = zConf; } @@ -71,7 +81,7 @@ public abstract class ConfigStorage { public abstract void saveCredentials(String credentials) throws IOException; protected InterpreterInfoSaving buildInterpreterInfoSaving(String json) { - // TODO(zjffdu) This kind of post processing is ugly. + //TODO(zjffdu) This kind of post processing is ugly. JsonParser jsonParser = new JsonParser(); JsonObject jsonObject = jsonParser.parse(json).getAsJsonObject(); InterpreterInfoSaving infoSaving = InterpreterInfoSaving.fromJson(json); @@ -82,8 +92,7 @@ public abstract class ConfigStorage { // previously created setting should turn this feature on here. interpreterSetting.getOption(); interpreterSetting.convertPermissionsFromUsersToOwners( - jsonObject - .getAsJsonObject("interpreterSettings") + jsonObject.getAsJsonObject("interpreterSettings") .getAsJsonObject(interpreterSetting.getId())); } return infoSaving; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/main/java/org/apache/zeppelin/storage/FileSystemConfigStorage.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/storage/FileSystemConfigStorage.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/storage/FileSystemConfigStorage.java index fa62753..20c19b6 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/storage/FileSystemConfigStorage.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/storage/FileSystemConfigStorage.java @@ -15,20 +15,28 @@ * limitations under the License. */ + package org.apache.zeppelin.storage; -import java.io.IOException; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import org.apache.hadoop.fs.Path; import org.apache.zeppelin.conf.ZeppelinConfiguration; +import org.apache.zeppelin.helium.HeliumConf; import org.apache.zeppelin.interpreter.InterpreterInfoSaving; +import org.apache.zeppelin.interpreter.InterpreterSetting; import org.apache.zeppelin.notebook.FileSystemStorage; import org.apache.zeppelin.notebook.NotebookAuthorizationInfoSaving; +import org.apache.zeppelin.user.CredentialsInfoSaving; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.IOException; + /** - * It could be used either local file system or hadoop distributed file system, because FileSystem - * support both local file system and hdfs. + * It could be used either local file system or hadoop distributed file system, + * because FileSystem support both local file system and hdfs. + * */ public class FileSystemConfigStorage extends ConfigStorage { @@ -42,8 +50,8 @@ public class FileSystemConfigStorage extends ConfigStorage { public FileSystemConfigStorage(ZeppelinConfiguration zConf) throws IOException { super(zConf); this.fs = new FileSystemStorage(zConf, zConf.getConfigFSDir()); - LOGGER.info( - "Creating FileSystem: " + this.fs.getFs().getClass().getName() + " for Zeppelin Config"); + LOGGER.info("Creating FileSystem: " + this.fs.getFs().getClass().getName() + + " for Zeppelin Config"); Path configPath = this.fs.makeQualified(new Path(zConf.getConfigFSDir())); this.fs.tryMkDir(configPath); LOGGER.info("Using folder {} to store Zeppelin Config", configPath); @@ -100,4 +108,5 @@ public class FileSystemConfigStorage extends ConfigStorage { LOGGER.info("Save Credentials to file: " + credentialPath); fs.writeFile(credentials, credentialPath, false); } + } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/main/java/org/apache/zeppelin/storage/LocalConfigStorage.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/storage/LocalConfigStorage.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/storage/LocalConfigStorage.java index fb967c9..b91ded4 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/storage/LocalConfigStorage.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/storage/LocalConfigStorage.java @@ -17,23 +17,26 @@ package org.apache.zeppelin.storage; +import org.apache.commons.io.IOUtils; +import org.apache.zeppelin.conf.ZeppelinConfiguration; +import org.apache.zeppelin.interpreter.InterpreterInfoSaving; +import org.apache.zeppelin.notebook.NotebookAuthorizationInfoSaving; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; -import java.nio.file.FileSystem; -import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.FileSystems; +import java.nio.file.FileSystem; import java.nio.file.StandardCopyOption; -import org.apache.commons.io.IOUtils; -import org.apache.zeppelin.conf.ZeppelinConfiguration; -import org.apache.zeppelin.interpreter.InterpreterInfoSaving; -import org.apache.zeppelin.notebook.NotebookAuthorizationInfoSaving; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -/** Storing config in local file system */ +/** + * Storing config in local file system + */ public class LocalConfigStorage extends ConfigStorage { private static Logger LOGGER = LoggerFactory.getLogger(LocalConfigStorage.class); @@ -128,4 +131,5 @@ public class LocalConfigStorage extends ConfigStorage { throw iox; } } -} + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/main/java/org/apache/zeppelin/ticket/TicketContainer.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/ticket/TicketContainer.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/ticket/TicketContainer.java index fc0844a..8c4b170 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/ticket/TicketContainer.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/ticket/TicketContainer.java @@ -25,10 +25,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Very simple ticket container No cleanup is done, since the same user accross different devices - * share the same ticket The Map size is at most the number of different user names having access to - * a Zeppelin instance + * Very simple ticket container + * No cleanup is done, since the same user accross different devices share the same ticket + * The Map size is at most the number of different user names having access to a Zeppelin instance */ + + public class TicketContainer { private static final Logger LOGGER = LoggerFactory.getLogger(TicketContainer.class); @@ -50,21 +52,20 @@ public class TicketContainer { /** * For test use - * * @param principal * @param ticket * @return true if ticket assigned to principal. */ public boolean isValid(String principal, String ticket) { - if ("anonymous".equals(principal) && "anonymous".equals(ticket)) return true; + if ("anonymous".equals(principal) && "anonymous".equals(ticket)) + return true; Entry entry = sessions.get(principal); return entry != null && entry.ticket.equals(ticket); } /** - * get or create ticket for Websocket authentication assigned to authenticated shiro user For - * unathenticated user (anonymous), always return ticket value "anonymous" - * + * get or create ticket for Websocket authentication assigned to authenticated shiro user + * For unathenticated user (anonymous), always return ticket value "anonymous" * @param principal * @return */ @@ -72,8 +73,10 @@ public class TicketContainer { Entry entry = sessions.get(principal); String ticket; if (entry == null) { - if (principal.equals("anonymous")) ticket = "anonymous"; - else ticket = UUID.randomUUID().toString(); + if (principal.equals("anonymous")) + ticket = "anonymous"; + else + ticket = UUID.randomUUID().toString(); } else { ticket = entry.ticket; } @@ -84,7 +87,6 @@ public class TicketContainer { /** * Remove ticket from session cache. - * * @param principal */ public synchronized void removeTicket(String principal) { http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/main/java/org/apache/zeppelin/user/Credentials.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/user/Credentials.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/user/Credentials.java index 21b265f..61f7fff 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/user/Credentials.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/user/Credentials.java @@ -1,27 +1,28 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ package org.apache.zeppelin.user; -import static java.nio.file.attribute.PosixFilePermission.OWNER_READ; -import static java.nio.file.attribute.PosixFilePermission.OWNER_WRITE; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -35,10 +36,13 @@ import java.util.EnumSet; import java.util.HashMap; import java.util.Map; import java.util.Set; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -/** Class defining credentials for data source authorization */ +import static java.nio.file.attribute.PosixFilePermission.OWNER_READ; +import static java.nio.file.attribute.PosixFilePermission.OWNER_WRITE; + +/** + * Class defining credentials for data source authorization + */ public class Credentials { private static final Logger LOG = LoggerFactory.getLogger(Credentials.class); @@ -48,7 +52,7 @@ public class Credentials { File credentialsFile; private Encryptor encryptor; - + /** * Wrapper fro user credentials. It can load credentials from a file if credentialsPath is * supplied, and will encrypt the file if an encryptKey is supplied. http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/main/java/org/apache/zeppelin/user/CredentialsInfoSaving.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/user/CredentialsInfoSaving.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/user/CredentialsInfoSaving.java index c8e71ac..48bb24d 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/user/CredentialsInfoSaving.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/user/CredentialsInfoSaving.java @@ -18,10 +18,13 @@ package org.apache.zeppelin.user; import com.google.gson.Gson; -import java.util.Map; import org.apache.zeppelin.common.JsonSerializable; -/** Helper class to save credentials */ +import java.util.Map; + +/** + * Helper class to save credentials + */ public class CredentialsInfoSaving implements JsonSerializable { private static final Gson gson = new Gson(); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/main/java/org/apache/zeppelin/user/Encryptor.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/user/Encryptor.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/user/Encryptor.java index 39c55b6..ee24090 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/user/Encryptor.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/user/Encryptor.java @@ -17,7 +17,6 @@ package org.apache.zeppelin.user; -import java.io.IOException; import org.bouncycastle.crypto.BufferedBlockCipher; import org.bouncycastle.crypto.InvalidCipherTextException; import org.bouncycastle.crypto.engines.AESEngine; @@ -26,7 +25,11 @@ import org.bouncycastle.crypto.paddings.ZeroBytePadding; import org.bouncycastle.crypto.params.KeyParameter; import org.bouncycastle.util.encoders.Base64; -/** Encrypt/decrypt arrays of bytes! */ +import java.io.IOException; + +/** + * Encrypt/decrypt arrays of bytes! + */ public class Encryptor { private final BufferedBlockCipher encryptCipher; private final BufferedBlockCipher decryptCipher; @@ -39,6 +42,7 @@ public class Encryptor { decryptCipher.init(false, new KeyParameter(encryptKey.getBytes())); } + public String encrypt(String inputString) throws IOException { byte[] input = inputString.getBytes(); byte[] result = new byte[encryptCipher.getOutputSize(input.length)]; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/main/java/org/apache/zeppelin/util/ReflectionUtils.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/util/ReflectionUtils.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/util/ReflectionUtils.java index 8da79ca..ca09992 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/util/ReflectionUtils.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/util/ReflectionUtils.java @@ -20,7 +20,11 @@ import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -/** Utility class for creating instances via java reflection. */ + +/** + * Utility class for creating instances via java reflection. + * + */ public class ReflectionUtils { public static Class<?> getClazz(String className) throws IOException { @@ -39,47 +43,39 @@ public class ReflectionUtils { try { instance = clazz.newInstance(); } catch (InstantiationException e) { - throw new IOException("Unable to instantiate class with 0 arguments: " + clazz.getName(), e); + throw new IOException( + "Unable to instantiate class with 0 arguments: " + clazz.getName(), e); } catch (IllegalAccessException e) { - throw new IOException("Unable to instantiate class with 0 arguments: " + clazz.getName(), e); + throw new IOException( + "Unable to instantiate class with 0 arguments: " + clazz.getName(), e); } return instance; } - private static <T> T getNewInstance( - Class<T> clazz, Class<?>[] parameterTypes, Object[] parameters) throws IOException { + private static <T> T getNewInstance(Class<T> clazz, + Class<?>[] parameterTypes, + Object[] parameters) + throws IOException { T instance; try { Constructor<T> constructor = clazz.getConstructor(parameterTypes); instance = constructor.newInstance(parameters); } catch (InstantiationException e) { throw new IOException( - "Unable to instantiate class with " - + parameters.length - + " arguments: " - + clazz.getName(), - e); + "Unable to instantiate class with " + parameters.length + " arguments: " + + clazz.getName(), e); } catch (IllegalAccessException e) { throw new IOException( - "Unable to instantiate class with " - + parameters.length - + " arguments: " - + clazz.getName(), - e); + "Unable to instantiate class with " + parameters.length + " arguments: " + + clazz.getName(), e); } catch (NoSuchMethodException e) { throw new IOException( - "Unable to instantiate class with " - + parameters.length - + " arguments: " - + clazz.getName(), - e); + "Unable to instantiate class with " + parameters.length + " arguments: " + + clazz.getName(), e); } catch (InvocationTargetException e) { throw new IOException( - "Unable to instantiate class with " - + parameters.length - + " arguments: " - + clazz.getName(), - e); + "Unable to instantiate class with " + parameters.length + " arguments: " + + clazz.getName(), e); } return instance; } @@ -91,10 +87,13 @@ public class ReflectionUtils { return instance; } - public static <T> T createClazzInstance( - String className, Class<?>[] parameterTypes, Object[] parameters) throws IOException { + public static <T> T createClazzInstance(String className, + Class<?>[] parameterTypes, + Object[] parameters) throws IOException { Class<?> clazz = getClazz(className); T instance = (T) getNewInstance(clazz, parameterTypes, parameters); return instance; } + + } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/main/java/org/apache/zeppelin/util/WatcherSecurityKey.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/util/WatcherSecurityKey.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/util/WatcherSecurityKey.java index 533719e..f0c3ad2 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/util/WatcherSecurityKey.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/util/WatcherSecurityKey.java @@ -19,8 +19,8 @@ package org.apache.zeppelin.util; import java.util.UUID; /** - * Simple implementation of a auto-generated key for websocket watcher. This is a LAZY - * implementation, we might want to update this later on :) + * Simple implementation of a auto-generated key for websocket watcher. + * This is a LAZY implementation, we might want to update this later on :) */ public class WatcherSecurityKey { public static final String HTTP_HEADER = "X-Watcher-Key"; @@ -31,4 +31,5 @@ public class WatcherSecurityKey { public static String getKey() { return KEY; } + } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/test/java/org/apache/zeppelin/conf/ZeppelinConfigurationTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/conf/ZeppelinConfigurationTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/conf/ZeppelinConfigurationTest.java index b1aef0b..1771fd3 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/conf/ZeppelinConfigurationTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/conf/ZeppelinConfigurationTest.java @@ -16,17 +16,19 @@ */ package org.apache.zeppelin.conf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.net.MalformedURLException; -import java.util.List; import junit.framework.Assert; import org.apache.commons.configuration.ConfigurationException; import org.apache.zeppelin.conf.ZeppelinConfiguration.ConfVars; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.net.MalformedURLException; +import java.util.List; + + public class ZeppelinConfigurationTest { @Before public void clearSystemVariables() { @@ -36,8 +38,7 @@ public class ZeppelinConfigurationTest { @Test public void getAllowedOrigins2Test() throws MalformedURLException, ConfigurationException { - ZeppelinConfiguration conf = - new ZeppelinConfiguration(this.getClass().getResource("/test-zeppelin-site2.xml")); + ZeppelinConfiguration conf = new ZeppelinConfiguration(this.getClass().getResource("/test-zeppelin-site2.xml")); List<String> origins = conf.getAllowedOrigins(); Assert.assertEquals(2, origins.size()); Assert.assertEquals("http://onehost:8080", origins.get(0)); @@ -47,8 +48,7 @@ public class ZeppelinConfigurationTest { @Test public void getAllowedOrigins1Test() throws MalformedURLException, ConfigurationException { - ZeppelinConfiguration conf = - new ZeppelinConfiguration(this.getClass().getResource("/test-zeppelin-site1.xml")); + ZeppelinConfiguration conf = new ZeppelinConfiguration(this.getClass().getResource("/test-zeppelin-site1.xml")); List<String> origins = conf.getAllowedOrigins(); Assert.assertEquals(1, origins.size()); Assert.assertEquals("http://onehost:8080", origins.get(0)); @@ -57,8 +57,7 @@ public class ZeppelinConfigurationTest { @Test public void getAllowedOriginsNoneTest() throws MalformedURLException, ConfigurationException { - ZeppelinConfiguration conf = - new ZeppelinConfiguration(this.getClass().getResource("/zeppelin-site.xml")); + ZeppelinConfiguration conf = new ZeppelinConfiguration(this.getClass().getResource("/zeppelin-site.xml")); List<String> origins = conf.getAllowedOrigins(); Assert.assertEquals(1, origins.size()); } @@ -66,8 +65,7 @@ public class ZeppelinConfigurationTest { @Test public void isWindowsPathTestTrue() throws ConfigurationException { - ZeppelinConfiguration conf = - new ZeppelinConfiguration(this.getClass().getResource("/zeppelin-site.xml")); + ZeppelinConfiguration conf = new ZeppelinConfiguration(this.getClass().getResource("/zeppelin-site.xml")); Boolean isIt = conf.isWindowsPath("c:\\test\\file.txt"); Assert.assertTrue(isIt); } @@ -75,8 +73,7 @@ public class ZeppelinConfigurationTest { @Test public void isWindowsPathTestFalse() throws ConfigurationException { - ZeppelinConfiguration conf = - new ZeppelinConfiguration(this.getClass().getResource("/zeppelin-site.xml")); + ZeppelinConfiguration conf = new ZeppelinConfiguration(this.getClass().getResource("/zeppelin-site.xml")); Boolean isIt = conf.isWindowsPath("~/test/file.xml"); Assert.assertFalse(isIt); } @@ -84,8 +81,7 @@ public class ZeppelinConfigurationTest { @Test public void getNotebookDirTest() throws ConfigurationException { - ZeppelinConfiguration conf = - new ZeppelinConfiguration(this.getClass().getResource("/zeppelin-site.xml")); + ZeppelinConfiguration conf = new ZeppelinConfiguration(this.getClass().getResource("/zeppelin-site.xml")); String notebookLocation = conf.getNotebookDir(); Assert.assertEquals("notebook", notebookLocation); } @@ -93,8 +89,7 @@ public class ZeppelinConfigurationTest { @Test public void isNotebookPublicTest() throws ConfigurationException { - ZeppelinConfiguration conf = - new ZeppelinConfiguration(this.getClass().getResource("/zeppelin-site.xml")); + ZeppelinConfiguration conf = new ZeppelinConfiguration(this.getClass().getResource("/zeppelin-site.xml")); boolean isIt = conf.isNotebookPublic(); assertTrue(isIt); } @@ -102,8 +97,7 @@ public class ZeppelinConfigurationTest { @Test public void getPathTest() throws ConfigurationException { System.setProperty(ConfVars.ZEPPELIN_HOME.getVarName(), "/usr/lib/zeppelin"); - ZeppelinConfiguration conf = - new ZeppelinConfiguration(this.getClass().getResource("/zeppelin-site.xml")); + ZeppelinConfiguration conf = new ZeppelinConfiguration(this.getClass().getResource("/zeppelin-site.xml")); Assert.assertEquals("/usr/lib/zeppelin", conf.getZeppelinHome()); Assert.assertEquals("/usr/lib/zeppelin/conf", conf.getConfDir()); } @@ -112,13 +106,10 @@ public class ZeppelinConfigurationTest { public void getConfigFSPath() throws ConfigurationException { System.setProperty(ConfVars.ZEPPELIN_HOME.getVarName(), "/usr/lib/zeppelin"); System.setProperty(ConfVars.ZEPPELIN_CONFIG_FS_DIR.getVarName(), "conf"); - ZeppelinConfiguration conf = - new ZeppelinConfiguration(this.getClass().getResource("/zeppelin-site.xml")); + ZeppelinConfiguration conf = new ZeppelinConfiguration(this.getClass().getResource("/zeppelin-site.xml")); assertEquals("/usr/lib/zeppelin/conf", conf.getConfigFSDir()); - System.setProperty( - ConfVars.ZEPPELIN_CONFIG_STORAGE_CLASS.getVarName(), - "org.apache.zeppelin.storage.FileSystemConfigStorage"); + System.setProperty(ConfVars.ZEPPELIN_CONFIG_STORAGE_CLASS.getVarName(), "org.apache.zeppelin.storage.FileSystemConfigStorage"); assertEquals("conf", conf.getConfigFSDir()); } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/test/java/org/apache/zeppelin/display/AngularObjectBuilder.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/display/AngularObjectBuilder.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/display/AngularObjectBuilder.java index 8a9365c..c201858 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/display/AngularObjectBuilder.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/display/AngularObjectBuilder.java @@ -19,8 +19,8 @@ package org.apache.zeppelin.display; public class AngularObjectBuilder { - public static <T> AngularObject<T> build( - String varName, T value, String noteId, String paragraphId) { - return new AngularObject<>(varName, value, noteId, paragraphId, null); - } -} + public static <T> AngularObject<T> build(String varName, T value, String noteId, + String paragraphId) { + return new AngularObject<>(varName, value, noteId, paragraphId, null); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumApplicationFactoryTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumApplicationFactoryTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumApplicationFactoryTest.java index 322a300..bc6f0ec 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumApplicationFactoryTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumApplicationFactoryTest.java @@ -16,12 +16,6 @@ */ package org.apache.zeppelin.helium; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.mock; - -import java.io.IOException; -import java.util.List; import org.apache.zeppelin.interpreter.AbstractInterpreterTest; import org.apache.zeppelin.interpreter.Interpreter; import org.apache.zeppelin.interpreter.InterpreterException; @@ -44,6 +38,14 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import java.io.IOException; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.mock; + + public class HeliumApplicationFactoryTest extends AbstractInterpreterTest implements ParagraphJobListener { @@ -67,17 +69,16 @@ public class HeliumApplicationFactoryTest extends AbstractInterpreterTest SearchService search = mock(SearchService.class); notebookRepo = mock(NotebookRepo.class); NotebookAuthorization notebookAuthorization = NotebookAuthorization.init(conf); - notebook = - new Notebook( - conf, - notebookRepo, - schedulerFactory, - interpreterFactory, - interpreterSettingManager, - this, - search, - notebookAuthorization, - new Credentials(false, null, null)); + notebook = new Notebook( + conf, + notebookRepo, + schedulerFactory, + interpreterFactory, + interpreterSettingManager, + this, + search, + notebookAuthorization, + new Credentials(false, null, null)); heliumAppFactory.setNotebook(notebook); @@ -91,20 +92,18 @@ public class HeliumApplicationFactoryTest extends AbstractInterpreterTest super.tearDown(); } + @Test public void testLoadRunUnloadApplication() throws IOException, ApplicationException, InterruptedException { // given - HeliumPackage pkg1 = - new HeliumPackage( - HeliumType.APPLICATION, - "name1", - "desc1", - "", - HeliumTestApplication.class.getName(), - new String[][] {}, - "", - ""); + HeliumPackage pkg1 = new HeliumPackage(HeliumType.APPLICATION, + "name1", + "desc1", + "", + HeliumTestApplication.class.getName(), + new String[][]{}, + "", ""); Note note1 = notebook.createNote(anonymous); @@ -114,7 +113,7 @@ public class HeliumApplicationFactoryTest extends AbstractInterpreterTest p1.setText("%mock1 job"); p1.setAuthenticationInfo(anonymous); note1.run(p1.getId()); - while (p1.isTerminated() == false || p1.getReturn() == null) Thread.yield(); + while(p1.isTerminated()==false || p1.getReturn()==null) Thread.yield(); assertEquals("repl1: job", p1.getReturn().message().get(0).getData()); @@ -143,16 +142,13 @@ public class HeliumApplicationFactoryTest extends AbstractInterpreterTest @Test public void testUnloadOnParagraphRemove() throws IOException { // given - HeliumPackage pkg1 = - new HeliumPackage( - HeliumType.APPLICATION, - "name1", - "desc1", - "", - HeliumTestApplication.class.getName(), - new String[][] {}, - "", - ""); + HeliumPackage pkg1 = new HeliumPackage(HeliumType.APPLICATION, + "name1", + "desc1", + "", + HeliumTestApplication.class.getName(), + new String[][]{}, + "", ""); Note note1 = notebook.createNote(anonymous); @@ -162,7 +158,7 @@ public class HeliumApplicationFactoryTest extends AbstractInterpreterTest p1.setText("%mock1 job"); p1.setAuthenticationInfo(anonymous); note1.run(p1.getId()); - while (p1.isTerminated() == false || p1.getReturn() == null) Thread.yield(); + while(p1.isTerminated()==false || p1.getReturn()==null) Thread.yield(); assertEquals(0, p1.getAllApplicationStates().size()); String appId = heliumAppFactory.loadAndRun(pkg1, p1); @@ -181,19 +177,17 @@ public class HeliumApplicationFactoryTest extends AbstractInterpreterTest notebook.removeNote(note1.getId(), anonymous); } + @Test public void testUnloadOnInterpreterUnbind() throws IOException { // given - HeliumPackage pkg1 = - new HeliumPackage( - HeliumType.APPLICATION, - "name1", - "desc1", - "", - HeliumTestApplication.class.getName(), - new String[][] {}, - "", - ""); + HeliumPackage pkg1 = new HeliumPackage(HeliumType.APPLICATION, + "name1", + "desc1", + "", + HeliumTestApplication.class.getName(), + new String[][]{}, + "", ""); Note note1 = notebook.createNote(anonymous); @@ -203,7 +197,7 @@ public class HeliumApplicationFactoryTest extends AbstractInterpreterTest p1.setText("%mock1 job"); p1.setAuthenticationInfo(anonymous); note1.run(p1.getId()); - while (p1.isTerminated() == false || p1.getReturn() == null) Thread.yield(); + while(p1.isTerminated()==false || p1.getReturn()==null) Thread.yield(); assertEquals(0, p1.getAllApplicationStates().size()); String appId = heliumAppFactory.loadAndRun(pkg1, p1); @@ -241,19 +235,17 @@ public class HeliumApplicationFactoryTest extends AbstractInterpreterTest notebook.removeNote(note1.getId(), anonymous); } + @Test public void testUnloadOnInterpreterRestart() throws IOException, InterpreterException { // given - HeliumPackage pkg1 = - new HeliumPackage( - HeliumType.APPLICATION, - "name1", - "desc1", - "", - HeliumTestApplication.class.getName(), - new String[][] {}, - "", - ""); + HeliumPackage pkg1 = new HeliumPackage(HeliumType.APPLICATION, + "name1", + "desc1", + "", + HeliumTestApplication.class.getName(), + new String[][]{}, + "", ""); Note note1 = notebook.createNote(anonymous); String mock1IntpSettingId = null; @@ -270,7 +262,7 @@ public class HeliumApplicationFactoryTest extends AbstractInterpreterTest p1.setText("%mock1 job"); p1.setAuthenticationInfo(anonymous); note1.run(p1.getId()); - while (p1.isTerminated() == false || p1.getReturn() == null) Thread.yield(); + while(p1.isTerminated()==false || p1.getReturn()==null) Thread.yield(); assertEquals(0, p1.getAllApplicationStates().size()); String appId = heliumAppFactory.loadAndRun(pkg1, p1); ApplicationState app = p1.getApplicationState(appId); @@ -293,18 +285,29 @@ public class HeliumApplicationFactoryTest extends AbstractInterpreterTest notebook.removeNote(note1.getId(), anonymous); } - @Override - public void onOutputAppend(Paragraph paragraph, int idx, String output) {} - @Override - public void onOutputUpdate(Paragraph paragraph, int idx, InterpreterResultMessage msg) {} + @Override + public void onOutputAppend(Paragraph paragraph, int idx, String output) { + + } + + @Override + public void onOutputUpdate(Paragraph paragraph, int idx, InterpreterResultMessage msg) { + + } + + @Override + public void onOutputUpdateAll(Paragraph paragraph, List<InterpreterResultMessage> msgs) { - @Override - public void onOutputUpdateAll(Paragraph paragraph, List<InterpreterResultMessage> msgs) {} + } - @Override - public void onProgressUpdate(Paragraph paragraph, int progress) {} + @Override + public void onProgressUpdate(Paragraph paragraph, int progress) { - @Override - public void onStatusChange(Paragraph paragraph, Job.Status before, Job.Status after) {} + } + + @Override + public void onStatusChange(Paragraph paragraph, Job.Status before, Job.Status after) { + + } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumBundleFactoryTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumBundleFactoryTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumBundleFactoryTest.java index feecb1b..1dafee1 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumBundleFactoryTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumBundleFactoryTest.java @@ -16,40 +16,40 @@ */ package org.apache.zeppelin.helium; -import static org.junit.Assert.*; - import com.github.eirslett.maven.plugins.frontend.lib.InstallationException; import com.github.eirslett.maven.plugins.frontend.lib.TaskRunnerException; import com.google.common.io.Resources; +import org.apache.commons.io.FileUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + import java.io.File; import java.io.IOException; import java.net.URL; import java.util.LinkedList; import java.util.List; -import org.apache.commons.io.FileUtils; + import org.apache.zeppelin.conf.ZeppelinConfiguration; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; + +import static org.junit.Assert.*; public class HeliumBundleFactoryTest { private File tmpDir; private ZeppelinConfiguration conf; private HeliumBundleFactory hbf; - private static File nodeInstallationDir = - new File(System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_nodeCache"); + private static File nodeInstallationDir = new File( + System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_nodeCache"); @BeforeClass - public static void beforeAll() throws IOException { + static public void beforeAll() throws IOException { FileUtils.deleteDirectory(nodeInstallationDir); } @Before public void setUp() throws InstallationException, TaskRunnerException, IOException { - tmpDir = - new File( - System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_" + System.currentTimeMillis()); + tmpDir = new File(System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_" + System.currentTimeMillis()); tmpDir.mkdirs(); // get module dir @@ -59,14 +59,12 @@ public class HeliumBundleFactoryTest { conf = new ZeppelinConfiguration(); - hbf = - new HeliumBundleFactory( - conf, - nodeInstallationDir, - tmpDir, - new File(moduleDir, "tabledata"), - new File(moduleDir, "visualization"), - new File(moduleDir, "spell")); + hbf = new HeliumBundleFactory(conf, + nodeInstallationDir, + tmpDir, + new File(moduleDir, "tabledata"), + new File(moduleDir, "visualization"), + new File(moduleDir, "spell")); hbf.installNodeAndNpm(); hbf.copyFrameworkModulesToInstallPath(true); } @@ -85,34 +83,33 @@ public class HeliumBundleFactoryTest { @Test public void downloadPackage() throws TaskRunnerException { - HeliumPackage pkg = - new HeliumPackage( - HeliumType.VISUALIZATION, - "lodash", - "lodash", - "[email protected]", - "", - null, - "license", - "icon"); + HeliumPackage pkg = new HeliumPackage( + HeliumType.VISUALIZATION, + "lodash", + "lodash", + "[email protected]", + "", + null, + "license", + "icon" + ); hbf.install(pkg); - assertTrue( - new File(tmpDir, HeliumBundleFactory.HELIUM_LOCAL_REPO + "/node_modules/lodash") - .isDirectory()); + assertTrue(new File(tmpDir, + HeliumBundleFactory.HELIUM_LOCAL_REPO + "/node_modules/lodash").isDirectory()); } @Test public void bundlePackage() throws IOException, TaskRunnerException { - HeliumPackage pkg = - new HeliumPackage( - HeliumType.VISUALIZATION, - "zeppelin-bubblechart", - "zeppelin-bubblechart", - "[email protected]", - "", - null, - "license", - "icon"); + HeliumPackage pkg = new HeliumPackage( + HeliumType.VISUALIZATION, + "zeppelin-bubblechart", + "zeppelin-bubblechart", + "[email protected]", + "", + null, + "license", + "icon" + ); File bundle = hbf.buildPackage(pkg, true, true); assertTrue(bundle.isFile()); long lastModified = bundle.lastModified(); @@ -128,16 +125,16 @@ public class HeliumBundleFactoryTest { String resDir = new File(res.getFile()).getParent(); String localPkg = resDir + "/../../../src/test/resources/helium/vis1"; - HeliumPackage pkg = - new HeliumPackage( - HeliumType.VISUALIZATION, - "vis1", - "vis1", - localPkg, - "", - null, - "license", - "fa fa-coffee"); + HeliumPackage pkg = new HeliumPackage( + HeliumType.VISUALIZATION, + "vis1", + "vis1", + localPkg, + "", + null, + "license", + "fa fa-coffee" + ); File bundle = hbf.buildPackage(pkg, true, true); assertTrue(bundle.isFile()); } @@ -148,16 +145,16 @@ public class HeliumBundleFactoryTest { String resDir = new File(res.getFile()).getParent(); String localPkg = resDir + "/../../../src/test/resources/helium/vis2"; - HeliumPackage pkg = - new HeliumPackage( - HeliumType.VISUALIZATION, - "vis2", - "vis2", - localPkg, - "", - null, - "license", - "fa fa-coffee"); + HeliumPackage pkg = new HeliumPackage( + HeliumType.VISUALIZATION, + "vis2", + "vis2", + localPkg, + "", + null, + "license", + "fa fa-coffee" + ); File bundle = null; try { bundle = hbf.buildPackage(pkg, true, true); @@ -174,27 +171,27 @@ public class HeliumBundleFactoryTest { URL res = Resources.getResource("helium/webpack.config.js"); String resDir = new File(res.getFile()).getParent(); - HeliumPackage pkgV1 = - new HeliumPackage( - HeliumType.VISUALIZATION, - "zeppelin-bubblechart", - "zeppelin-bubblechart", - "[email protected]", - "", - null, - "license", - "icon"); - - HeliumPackage pkgV2 = - new HeliumPackage( - HeliumType.VISUALIZATION, - "zeppelin-bubblechart", - "zeppelin-bubblechart", - "[email protected]", - "", - null, - "license", - "icon"); + HeliumPackage pkgV1 = new HeliumPackage( + HeliumType.VISUALIZATION, + "zeppelin-bubblechart", + "zeppelin-bubblechart", + "[email protected]", + "", + null, + "license", + "icon" + ); + + HeliumPackage pkgV2 = new HeliumPackage( + HeliumType.VISUALIZATION, + "zeppelin-bubblechart", + "zeppelin-bubblechart", + "[email protected]", + "", + null, + "license", + "icon" + ); List<HeliumPackage> pkgsV1 = new LinkedList<>(); pkgsV1.add(pkgV1); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumLocalRegistryTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumLocalRegistryTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumLocalRegistryTest.java index a9f2476..0f490d1 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumLocalRegistryTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumLocalRegistryTest.java @@ -16,24 +16,23 @@ */ package org.apache.zeppelin.helium; -import static org.junit.Assert.assertEquals; - import com.google.gson.Gson; -import java.io.File; -import java.io.IOException; import org.apache.commons.io.FileUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; +import java.io.File; +import java.io.IOException; + +import static org.junit.Assert.assertEquals; + public class HeliumLocalRegistryTest { private File tmpDir; @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(); } @@ -51,16 +50,14 @@ public class HeliumLocalRegistryTest { // when Gson gson = new Gson(); - HeliumPackage pkg1 = - new HeliumPackage( - HeliumType.APPLICATION, - "app1", - "desc1", - "artifact1", - "classname1", - new String[][] {}, - "license", - ""); + HeliumPackage pkg1 = new HeliumPackage(HeliumType.APPLICATION, + "app1", + "desc1", + "artifact1", + "classname1", + new String[][]{}, + "license", + ""); FileUtils.writeStringToFile(new File(r1Path, "pkg1.json"), gson.toJson(pkg1)); // then http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumOnlineRegistryTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumOnlineRegistryTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumOnlineRegistryTest.java index ea69f4b..dea0c20 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumOnlineRegistryTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumOnlineRegistryTest.java @@ -18,14 +18,14 @@ package org.apache.zeppelin.helium; import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.io.IOException; import org.apache.commons.io.FileUtils; -import org.apache.zeppelin.conf.ZeppelinConfiguration; import org.junit.After; import org.junit.Before; import org.junit.Test; +import java.io.File; +import java.io.IOException; +import org.apache.zeppelin.conf.ZeppelinConfiguration; + public class HeliumOnlineRegistryTest { // ip 192.168.65.17 belongs to private network @@ -37,9 +37,11 @@ public class HeliumOnlineRegistryTest { @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() + ); } @After @@ -50,22 +52,33 @@ public class HeliumOnlineRegistryTest { @Test public void zeppelinNotebookS3TimeoutPropertyTest() throws IOException { System.setProperty( - ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_S3_TIMEOUT.getVarName(), TIMEOUT); + ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_S3_TIMEOUT.getVarName(), + TIMEOUT + ); System.setProperty( - ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_S3_ENDPOINT.getVarName(), IP); - HeliumOnlineRegistry heliumOnlineRegistry = - new HeliumOnlineRegistry("https://" + IP, "https://" + IP, tmpDir); + ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_S3_ENDPOINT.getVarName(), + IP + ); + HeliumOnlineRegistry heliumOnlineRegistry = new HeliumOnlineRegistry( + "https://" + IP, + "https://" + IP, + tmpDir + ); long start = System.currentTimeMillis(); heliumOnlineRegistry.getAll(); long processTime = System.currentTimeMillis() - start; - long basicTimeout = - Long.valueOf(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_S3_TIMEOUT.getStringValue()); + long basicTimeout = Long.valueOf( + ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_S3_TIMEOUT.getStringValue() + ); assertTrue( - String.format( - "Wrong timeout during connection: expected %s, actual is about %d", - TIMEOUT, processTime), - basicTimeout > processTime); + String.format( + "Wrong timeout during connection: expected %s, actual is about %d", + TIMEOUT, + processTime + ), + basicTimeout > processTime + ); } }
