[ZEPPELIN-1012] Support Interpreter Aliases ### What is this PR for? Supporting aliases for same interpreter group and enabling running two interpreters in same group.
### What type of PR is it? [Feature] ### Todos * [x] - Add InterpreterSettingRef * [x] - Add aliases feature ### What is the Jira issue? * https://issues.apache.org/jira/browse/ZEPPELIN-1012 ### How should this be tested? 1. Create spark2 interpreter in a interpreter tab 1. Add that interpreter in a notebook 1. run `%spark` and `%spark2` ### Screenshots (if appropriate) ### Questions: * Does the licenses files need update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Author: Jongyoul Lee <[email protected]> Closes #1145 from jongyoul/ZEPPELIN-1012 and squashes the following commits: 4d38462 [Jongyoul Lee] Reverted modifier of CronJob back to public 2fab2f2 [Jongyoul Lee] Reverted default constructor 7f9f72d [Jongyoul Lee] Fixed the style 4dd8f6e [Jongyoul Lee] Reverted style into original to avoid checkstyle 5eff48f [Jongyoul Lee] Reverted style into original to avoid checkstyle 5e50864 [Jongyoul Lee] Reverted refName to group fac0b86 [Jongyoul Lee] Reformatted files related to this PR without test classes 5bb15a0 [Jongyoul Lee] Removed some console.log added for debugging 334634a [Jongyoul Lee] Fixed the description of parameter of add method ca20889 [Jongyoul Lee] Changed setting.group to setting.name Removed meaningless super constructor dde2232 [Jongyoul Lee] Added catching IOE from caller of createNewSetting cb7dde5 [Jongyoul Lee] Fixed wrong test to save to file after Zeppelin calls createNewSetting d59029b [Jongyoul Lee] Removed unused code Fixed the type of variables Adjusted diamond operator 9b05ca2 [Jongyoul Lee] Fixed some style e585791 [Jongyoul Lee] Fixed some style 634cc21 [Jongyoul Lee] Fixed usage of getGroup c100f76 [Jongyoul Lee] Removed deprecated method 240c8af [Jongyoul Lee] Removed debugging message 4ff493b [Jongyoul Lee] Fixed test case d5a4c44 [Jongyoul Lee] Refactored InterpreterSetting Changed menu for creating new InterpreterSetting 16b56c3 [Jongyoul Lee] Fixed broken tests for InterpreterRestApiTest fccdd9b [Jongyoul Lee] Fixed the style 5159a84 [Jongyoul Lee] Added feature for Interpreter aliases Extracted InterpreterInfo from InterpreterSetting c4b016e [Jongyoul Lee] Refactored getInterpreter method not to use RegisteredInterpreter Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/b11b6ec2 Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/b11b6ec2 Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/b11b6ec2 Branch: refs/heads/master Commit: b11b6ec24edf884c4d485acbe0aa02dc790f0b54 Parents: d8b54cf Author: Jongyoul Lee <[email protected]> Authored: Thu Jul 14 22:35:03 2016 +0900 Committer: Jongyoul Lee <[email protected]> Committed: Fri Jul 15 22:54:50 2016 +0900 ---------------------------------------------------------------------- .../zeppelin/rest/InterpreterRestApi.java | 125 ++-- .../apache/zeppelin/rest/NotebookRestApi.java | 272 ++++---- .../InterpreterSettingListForNoteBind.java | 57 +- .../message/NewInterpreterSettingRequest.java | 13 +- .../zeppelin/rest/AbstractTestRestApi.java | 26 +- .../zeppelin/rest/InterpreterRestApiTest.java | 5 +- .../zeppelin/rest/ZeppelinSparkClusterTest.java | 10 +- .../interpreter-create/interpreter-create.html | 6 +- .../app/interpreter/interpreter.controller.js | 5 +- .../src/app/interpreter/interpreter.html | 4 +- .../src/app/notebook/notebook.controller.js | 4 +- zeppelin-web/src/app/notebook/notebook.html | 2 +- .../helium/HeliumApplicationFactory.java | 5 +- .../interpreter/InterpreterFactory.java | 634 +++++++++++-------- .../zeppelin/interpreter/InterpreterInfo.java | 69 ++ .../interpreter/InterpreterSetting.java | 130 ++-- .../java/org/apache/zeppelin/notebook/Note.java | 133 ++-- .../org/apache/zeppelin/notebook/Notebook.java | 174 +++-- .../zeppelin/notebook/utility/IdHashes.java | 13 +- .../helium/HeliumApplicationFactoryTest.java | 5 +- .../interpreter/InterpreterFactoryTest.java | 34 +- .../org/apache/zeppelin/notebook/NoteTest.java | 6 +- .../apache/zeppelin/notebook/NotebookTest.java | 10 +- 23 files changed, 908 insertions(+), 834 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/b11b6ec2/zeppelin-server/src/main/java/org/apache/zeppelin/rest/InterpreterRestApi.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/InterpreterRestApi.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/InterpreterRestApi.java index 9af0a60..8f5a441 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/InterpreterRestApi.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/InterpreterRestApi.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.util.List; import java.util.Map; import java.util.Properties; - import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; @@ -32,36 +31,35 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +import com.google.gson.Gson; import org.apache.commons.lang.exception.ExceptionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.sonatype.aether.RepositoryException; +import org.sonatype.aether.repository.RemoteRepository; + import org.apache.zeppelin.annotation.ZeppelinApi; import org.apache.zeppelin.dep.Repository; -import org.apache.zeppelin.interpreter.*; -import org.apache.zeppelin.interpreter.Interpreter.RegisteredInterpreter; +import org.apache.zeppelin.interpreter.InterpreterException; +import org.apache.zeppelin.interpreter.InterpreterFactory; +import org.apache.zeppelin.interpreter.InterpreterSetting; import org.apache.zeppelin.rest.message.NewInterpreterSettingRequest; import org.apache.zeppelin.rest.message.UpdateInterpreterSettingRequest; import org.apache.zeppelin.server.JsonResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.gson.Gson; -import org.sonatype.aether.RepositoryException; -import org.sonatype.aether.repository.RemoteRepository; /** * Interpreter Rest API - * */ @Path("/interpreter") @Produces("application/json") public class InterpreterRestApi { - Logger logger = LoggerFactory.getLogger(InterpreterRestApi.class); + private static final Logger logger = LoggerFactory.getLogger(InterpreterRestApi.class); private InterpreterFactory interpreterFactory; Gson gson = new Gson(); public InterpreterRestApi() { - } public InterpreterRestApi(InterpreterFactory interpreterFactory) { @@ -70,52 +68,39 @@ public class InterpreterRestApi { /** * List all interpreter settings - * @return */ @GET @Path("setting") @ZeppelinApi public Response listSettings() { - List<InterpreterSetting> interpreterSettings = null; + List<InterpreterSetting> interpreterSettings; interpreterSettings = interpreterFactory.get(); - return new JsonResponse(Status.OK, "", interpreterSettings).build(); + return new JsonResponse<>(Status.OK, "", interpreterSettings).build(); } /** * Add new interpreter setting - * @param message - * @return - * @throws IOException - * @throws InterpreterException + * + * @param message NewInterpreterSettingRequest */ @POST @Path("setting") @ZeppelinApi public Response newSettings(String message) { try { - NewInterpreterSettingRequest request = gson.fromJson(message, - NewInterpreterSettingRequest.class); + NewInterpreterSettingRequest request = + gson.fromJson(message, NewInterpreterSettingRequest.class); Properties p = new Properties(); p.putAll(request.getProperties()); - InterpreterSetting interpreterSetting = interpreterFactory.add(request.getName(), - request.getGroup(), - request.getDependencies(), - request.getOption(), - p); - logger.info("new setting created with {}", interpreterSetting.id()); - return new JsonResponse(Status.CREATED, "", interpreterSetting).build(); - } catch (InterpreterException e) { + InterpreterSetting interpreterSetting = interpreterFactory + .createNewSetting(request.getName(), request.getGroup(), request.getDependencies(), + request.getOption(), p); + logger.info("new setting created with {}", interpreterSetting.getId()); + return new JsonResponse<>(Status.CREATED, "", interpreterSetting).build(); + } catch (InterpreterException | IOException e) { logger.error("Exception in InterpreterRestApi while creating ", e); - return new JsonResponse( - Status.NOT_FOUND, - e.getMessage(), - ExceptionUtils.getStackTrace(e)).build(); - } catch (IOException | RepositoryException e) { - logger.error("Exception in InterpreterRestApi while creating ", e); - return new JsonResponse( - Status.INTERNAL_SERVER_ERROR, - e.getMessage(), - ExceptionUtils.getStackTrace(e)).build(); + return new JsonResponse<>(Status.NOT_FOUND, e.getMessage(), ExceptionUtils.getStackTrace(e)) + .build(); } } @@ -126,26 +111,25 @@ public class InterpreterRestApi { logger.info("Update interpreterSetting {}", settingId); try { - UpdateInterpreterSettingRequest request = gson.fromJson(message, - UpdateInterpreterSettingRequest.class); - interpreterFactory.setPropertyAndRestart(settingId, - request.getOption(), - request.getProperties(), - request.getDependencies()); + UpdateInterpreterSettingRequest request = + gson.fromJson(message, UpdateInterpreterSettingRequest.class); + interpreterFactory + .setPropertyAndRestart(settingId, request.getOption(), request.getProperties(), + request.getDependencies()); } catch (InterpreterException e) { logger.error("Exception in InterpreterRestApi while updateSetting ", e); - return new JsonResponse( - Status.NOT_FOUND, e.getMessage(), ExceptionUtils.getStackTrace(e)).build(); + return new JsonResponse<>(Status.NOT_FOUND, e.getMessage(), ExceptionUtils.getStackTrace(e)) + .build(); } catch (IOException | RepositoryException e) { logger.error("Exception in InterpreterRestApi while updateSetting ", e); - return new JsonResponse( - Status.INTERNAL_SERVER_ERROR, e.getMessage(), ExceptionUtils.getStackTrace(e)).build(); + return new JsonResponse<>(Status.INTERNAL_SERVER_ERROR, e.getMessage(), + ExceptionUtils.getStackTrace(e)).build(); } InterpreterSetting setting = interpreterFactory.get(settingId); if (setting == null) { - return new JsonResponse(Status.NOT_FOUND, "", settingId).build(); + return new JsonResponse<>(Status.NOT_FOUND, "", settingId).build(); } - return new JsonResponse(Status.OK, "", setting).build(); + return new JsonResponse<>(Status.OK, "", setting).build(); } /** @@ -172,14 +156,14 @@ public class InterpreterRestApi { interpreterFactory.restart(settingId); } catch (InterpreterException e) { logger.error("Exception in InterpreterRestApi while restartSetting ", e); - return new JsonResponse( - Status.NOT_FOUND, e.getMessage(), ExceptionUtils.getStackTrace(e)).build(); + return new JsonResponse<>(Status.NOT_FOUND, e.getMessage(), ExceptionUtils.getStackTrace(e)) + .build(); } InterpreterSetting setting = interpreterFactory.get(settingId); if (setting == null) { - return new JsonResponse(Status.NOT_FOUND, "", settingId).build(); + return new JsonResponse<>(Status.NOT_FOUND, "", settingId).build(); } - return new JsonResponse(Status.OK, "", setting).build(); + return new JsonResponse<>(Status.OK, "", setting).build(); } /** @@ -188,27 +172,25 @@ public class InterpreterRestApi { @GET @ZeppelinApi public Response listInterpreter(String message) { - Map<String, RegisteredInterpreter> m = Interpreter.registeredInterpreters; - return new JsonResponse(Status.OK, "", m).build(); + Map<String, InterpreterSetting> m = interpreterFactory.getAvailableInterpreterSettings(); + return new JsonResponse<>(Status.OK, "", m).build(); } /** * List of dependency resolving repositories - * @return */ @GET @Path("repository") @ZeppelinApi public Response listRepositories() { - List<RemoteRepository> interpreterRepositories = null; - interpreterRepositories = interpreterFactory.getRepositories(); - return new JsonResponse(Status.OK, "", interpreterRepositories).build(); + List<RemoteRepository> interpreterRepositories = interpreterFactory.getRepositories(); + return new JsonResponse<>(Status.OK, "", interpreterRepositories).build(); } /** * Add new repository - * @param message - * @return + * + * @param message Repository */ @POST @Path("repository") @@ -216,24 +198,21 @@ public class InterpreterRestApi { public Response addRepository(String message) { try { Repository request = gson.fromJson(message, Repository.class); - interpreterFactory.addRepository( - request.getId(), - request.getUrl(), - request.isSnapshot(), + interpreterFactory.addRepository(request.getId(), request.getUrl(), request.isSnapshot(), request.getAuthentication()); logger.info("New repository {} added", request.getId()); } catch (Exception e) { logger.error("Exception in InterpreterRestApi while adding repository ", e); - return new JsonResponse( - Status.INTERNAL_SERVER_ERROR, e.getMessage(), ExceptionUtils.getStackTrace(e)).build(); + return new JsonResponse<>(Status.INTERNAL_SERVER_ERROR, e.getMessage(), + ExceptionUtils.getStackTrace(e)).build(); } return new JsonResponse(Status.CREATED).build(); } /** * Delete repository - * @param repoId - * @return + * + * @param repoId ID of repository */ @DELETE @Path("repository/{repoId}") @@ -244,8 +223,8 @@ public class InterpreterRestApi { interpreterFactory.removeRepository(repoId); } catch (Exception e) { logger.error("Exception in InterpreterRestApi while removing repository ", e); - return new JsonResponse( - Status.INTERNAL_SERVER_ERROR, e.getMessage(), ExceptionUtils.getStackTrace(e)).build(); + return new JsonResponse<>(Status.INTERNAL_SERVER_ERROR, e.getMessage(), + ExceptionUtils.getStackTrace(e)).build(); } return new JsonResponse(Status.OK).build(); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/b11b6ec2/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java index c10dee8..700fe1a 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java @@ -18,8 +18,12 @@ package org.apache.zeppelin.rest; import java.io.IOException; -import java.util.*; - +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; @@ -31,7 +35,14 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +import com.google.common.collect.Sets; +import com.google.common.reflect.TypeToken; +import com.google.gson.Gson; import org.apache.commons.lang3.StringUtils; +import org.quartz.CronExpression; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.apache.zeppelin.annotation.ZeppelinApi; import org.apache.zeppelin.interpreter.InterpreterSetting; import org.apache.zeppelin.notebook.Note; @@ -48,16 +59,7 @@ import org.apache.zeppelin.server.JsonResponse; import org.apache.zeppelin.socket.NotebookServer; import org.apache.zeppelin.user.AuthenticationInfo; import org.apache.zeppelin.utils.SecurityUtils; -import org.quartz.CronExpression; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import com.google.common.collect.Sets; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; -import com.google.gson.GsonBuilder; -import com.google.gson.stream.JsonReader; -import java.io.StringReader; /** * Rest api endpoint for the noteBook. */ @@ -71,7 +73,8 @@ public class NotebookRestApi { private SearchService notebookIndex; private NotebookAuthorization notebookAuthorization; - public NotebookRestApi() {} + public NotebookRestApi() { + } public NotebookRestApi(Notebook notebook, NotebookServer notebookServer, SearchService search) { this.notebook = notebook; @@ -87,21 +90,19 @@ public class NotebookRestApi { @Path("{noteId}/permissions") @ZeppelinApi public Response getNotePermissions(@PathParam("noteId") String noteId) { - Note note = notebook.getNote(noteId); - HashMap<String, Set<String>> permissionsMap = new HashMap(); + HashMap<String, Set<String>> permissionsMap = new HashMap<>(); permissionsMap.put("owners", notebookAuthorization.getOwners(noteId)); permissionsMap.put("readers", notebookAuthorization.getReaders(noteId)); permissionsMap.put("writers", notebookAuthorization.getWriters(noteId)); return new JsonResponse<>(Status.OK, "", permissionsMap).build(); } - String ownerPermissionError(Set<String> current, - Set<String> allowed) throws IOException { + private String ownerPermissionError(Set<String> current, Set<String> allowed) throws IOException { LOG.info("Cannot change permissions. Connection owners {}. Allowed owners {}", - current.toString(), allowed.toString()); + current.toString(), allowed.toString()); return "Insufficient privileges to change permissions.\n\n" + - "Allowed owners: " + allowed.toString() + "\n\n" + - "User belongs to: " + current.toString(); + "Allowed owners: " + allowed.toString() + "\n\n" + + "User belongs to: " + current.toString(); } /** @@ -112,25 +113,25 @@ public class NotebookRestApi { @ZeppelinApi public Response putNotePermissions(@PathParam("noteId") String noteId, String req) throws IOException { - HashMap<String, HashSet> permMap = gson.fromJson(req, - new TypeToken<HashMap<String, HashSet>>(){}.getType()); + /** + * TODO(jl): Fixed the type of HashSet + * https://issues.apache.org/jira/browse/ZEPPELIN-1162 + */ + HashMap<String, HashSet> permMap = + gson.fromJson(req, new TypeToken<HashMap<String, HashSet>>() { + }.getType()); Note note = notebook.getNote(noteId); String principal = SecurityUtils.getPrincipal(); HashSet<String> roles = SecurityUtils.getRoles(); - LOG.info("Set permissions {} {} {} {} {}", - noteId, - principal, - permMap.get("owners"), - permMap.get("readers"), - permMap.get("writers") - ); - - HashSet<String> userAndRoles = new HashSet<String>(); + LOG.info("Set permissions {} {} {} {} {}", noteId, principal, permMap.get("owners"), + permMap.get("readers"), permMap.get("writers")); + + HashSet<String> userAndRoles = new HashSet<>(); userAndRoles.add(principal); userAndRoles.addAll(roles); if (!notebookAuthorization.isOwner(noteId, userAndRoles)) { - return new JsonResponse<>(Status.FORBIDDEN, ownerPermissionError(userAndRoles, - notebookAuthorization.getOwners(noteId))).build(); + return new JsonResponse<>(Status.FORBIDDEN, + ownerPermissionError(userAndRoles, notebookAuthorization.getOwners(noteId))).build(); } HashSet readers = permMap.get("readers"); @@ -146,7 +147,7 @@ public class NotebookRestApi { } } // Set writers, if owners is empty -> set to user requesting the change - if ( writers != null && !writers.isEmpty()) { + if (writers != null && !writers.isEmpty()) { if (owners.isEmpty()) { owners = Sets.newHashSet(SecurityUtils.getPrincipal()); } @@ -155,10 +156,8 @@ public class NotebookRestApi { notebookAuthorization.setReaders(noteId, readers); notebookAuthorization.setWriters(noteId, writers); notebookAuthorization.setOwners(noteId, owners); - LOG.debug("After set permissions {} {} {}", - notebookAuthorization.getOwners(noteId), - notebookAuthorization.getReaders(noteId), - notebookAuthorization.getWriters(noteId)); + LOG.debug("After set permissions {} {} {}", notebookAuthorization.getOwners(noteId), + notebookAuthorization.getReaders(noteId), notebookAuthorization.getWriters(noteId)); AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal()); note.persist(subject); notebookServer.broadcastNote(note); @@ -167,13 +166,15 @@ public class NotebookRestApi { /** * bind a setting to note + * * @throws IOException */ @PUT @Path("interpreter/bind/{noteId}") @ZeppelinApi public Response bind(@PathParam("noteId") String noteId, String req) throws IOException { - List<String> settingIdList = gson.fromJson(req, new TypeToken<List<String>>(){}.getType()); + List<String> settingIdList = gson.fromJson(req, new TypeToken<List<String>>() { + }.getType()); notebook.bindInterpretersToNote(noteId, settingIdList); return new JsonResponse<>(Status.OK).build(); } @@ -185,38 +186,27 @@ public class NotebookRestApi { @Path("interpreter/bind/{noteId}") @ZeppelinApi public Response bind(@PathParam("noteId") String noteId) { - List<InterpreterSettingListForNoteBind> settingList - = new LinkedList<InterpreterSettingListForNoteBind>(); + List<InterpreterSettingListForNoteBind> settingList = new LinkedList<>(); List<InterpreterSetting> selectedSettings = notebook.getBindedInterpreterSettings(noteId); for (InterpreterSetting setting : selectedSettings) { - settingList.add(new InterpreterSettingListForNoteBind( - setting.id(), - setting.getName(), - setting.getGroup(), - setting.getInterpreterInfos(), - true) - ); + settingList.add(new InterpreterSettingListForNoteBind(setting.getId(), setting.getName(), + setting.getInterpreterInfos(), true)); } List<InterpreterSetting> availableSettings = notebook.getInterpreterFactory().get(); for (InterpreterSetting setting : availableSettings) { boolean selected = false; for (InterpreterSetting selectedSetting : selectedSettings) { - if (selectedSetting.id().equals(setting.id())) { + if (selectedSetting.getId().equals(setting.getId())) { selected = true; break; } } if (!selected) { - settingList.add(new InterpreterSettingListForNoteBind( - setting.id(), - setting.getName(), - setting.getGroup(), - setting.getInterpreterInfos(), - false) - ); + settingList.add(new InterpreterSettingListForNoteBind(setting.getId(), setting.getName(), + setting.getInterpreterInfos(), false)); } } return new JsonResponse<>(Status.OK, "", settingList).build(); @@ -228,7 +218,7 @@ public class NotebookRestApi { public Response getNotebookList() throws IOException { AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal()); List<Map<String, String>> notesInfo = notebookServer.generateNotebooksInfo(false, subject); - return new JsonResponse<>(Status.OK, "", notesInfo ).build(); + return new JsonResponse<>(Status.OK, "", notesInfo).build(); } @GET @@ -245,8 +235,8 @@ public class NotebookRestApi { /** * export note REST API - * - * @param + * + * @param noteId ID of Note * @return note JSON with status.OK * @throws IOException */ @@ -255,12 +245,12 @@ public class NotebookRestApi { @ZeppelinApi public Response exportNoteBook(@PathParam("id") String noteId) throws IOException { String exportJson = notebook.exportNote(noteId); - return new JsonResponse(Status.OK, "", exportJson).build(); + return new JsonResponse<>(Status.OK, "", exportJson).build(); } /** * import new note REST API - * + * * @param req - notebook Json * @return JSON with new note ID * @throws IOException @@ -273,9 +263,10 @@ public class NotebookRestApi { Note newNote = notebook.importNote(req, null, subject); return new JsonResponse<>(Status.CREATED, "", newNote.getId()).build(); } - + /** * Create new note REST API + * * @param message - JSON with new note name * @return JSON with new note ID * @throws IOException @@ -284,9 +275,8 @@ public class NotebookRestApi { @Path("/") @ZeppelinApi public Response createNote(String message) throws IOException { - LOG.info("Create new notebook by JSON {}" , message); - NewNotebookRequest request = gson.fromJson(message, - NewNotebookRequest.class); + LOG.info("Create new notebook by JSON {}", message); + NewNotebookRequest request = gson.fromJson(message, NewNotebookRequest.class); AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal()); Note note = notebook.createNote(subject); List<NewParagraphRequest> initialParagraphs = request.getParagraphs(); @@ -307,12 +297,13 @@ public class NotebookRestApi { note.persist(subject); notebookServer.broadcastNote(note); notebookServer.broadcastNoteList(subject); - return new JsonResponse<>(Status.CREATED, "", note.getId() ).build(); + return new JsonResponse<>(Status.CREATED, "", note.getId()).build(); } /** * Delete note REST API - * @param + * + * @param notebookId ID of Notebook * @return JSON with status.OK * @throws IOException */ @@ -332,21 +323,21 @@ public class NotebookRestApi { notebookServer.broadcastNoteList(subject); return new JsonResponse<>(Status.OK, "").build(); } - + /** * Clone note REST API - * @param + * + * @param notebookId ID of Notebook * @return JSON with status.CREATED * @throws IOException, CloneNotSupportedException, IllegalArgumentException */ @POST @Path("{notebookId}") @ZeppelinApi - public Response cloneNote(@PathParam("notebookId") String notebookId, String message) throws - IOException, CloneNotSupportedException, IllegalArgumentException { - LOG.info("clone notebook by JSON {}" , message); - NewNotebookRequest request = gson.fromJson(message, - NewNotebookRequest.class); + public Response cloneNote(@PathParam("notebookId") String notebookId, String message) + throws IOException, CloneNotSupportedException, IllegalArgumentException { + LOG.info("clone notebook by JSON {}", message); + NewNotebookRequest request = gson.fromJson(message, NewNotebookRequest.class); String newNoteName = request.getName(); AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal()); Note newNote = notebook.cloneNote(notebookId, newNoteName, subject); @@ -357,6 +348,7 @@ public class NotebookRestApi { /** * Insert paragraph REST API + * * @param message - JSON containing paragraph's information * @return JSON with status.OK * @throws IOException @@ -370,7 +362,7 @@ public class NotebookRestApi { Note note = notebook.getNote(notebookId); if (note == null) { - return new JsonResponse(Status.NOT_FOUND, "note not found.").build(); + return new JsonResponse<>(Status.NOT_FOUND, "note not found.").build(); } NewParagraphRequest request = gson.fromJson(message, NewParagraphRequest.class); @@ -388,12 +380,13 @@ public class NotebookRestApi { AuthenticationInfo subject = new AuthenticationInfo(SecurityUtils.getPrincipal()); note.persist(subject); notebookServer.broadcastNote(note); - return new JsonResponse(Status.CREATED, "", p.getId()).build(); + return new JsonResponse<>(Status.CREATED, "", p.getId()).build(); } /** * Get paragraph REST API - * @param + * + * @param notebookId ID of Notebook * @return JSON with information of the paragraph * @throws IOException */ @@ -401,7 +394,7 @@ public class NotebookRestApi { @Path("{notebookId}/paragraph/{paragraphId}") @ZeppelinApi public Response getParagraph(@PathParam("notebookId") String notebookId, - @PathParam("paragraphId") String paragraphId) throws IOException { + @PathParam("paragraphId") String paragraphId) throws IOException { LOG.info("get paragraph {} {}", notebookId, paragraphId); Note note = notebook.getNote(notebookId); @@ -414,11 +407,12 @@ public class NotebookRestApi { return new JsonResponse(Status.NOT_FOUND, "paragraph not found.").build(); } - return new JsonResponse(Status.OK, "", p).build(); + return new JsonResponse<>(Status.OK, "", p).build(); } /** * Move paragraph REST API + * * @param newIndex - new index to move * @return JSON with status.OK * @throws IOException @@ -427,8 +421,8 @@ public class NotebookRestApi { @Path("{notebookId}/paragraph/{paragraphId}/move/{newIndex}") @ZeppelinApi public Response moveParagraph(@PathParam("notebookId") String notebookId, - @PathParam("paragraphId") String paragraphId, - @PathParam("newIndex") String newIndex) throws IOException { + @PathParam("paragraphId") String paragraphId, @PathParam("newIndex") String newIndex) + throws IOException { LOG.info("move paragraph {} {} {}", notebookId, paragraphId, newIndex); Note note = notebook.getNote(notebookId); @@ -456,7 +450,8 @@ public class NotebookRestApi { /** * Delete paragraph REST API - * @param + * + * @param notebookId ID of Notebook * @return JSON with status.OK * @throws IOException */ @@ -464,7 +459,7 @@ public class NotebookRestApi { @Path("{notebookId}/paragraph/{paragraphId}") @ZeppelinApi public Response deleteParagraph(@PathParam("notebookId") String notebookId, - @PathParam("paragraphId") String paragraphId) throws IOException { + @PathParam("paragraphId") String paragraphId) throws IOException { LOG.info("delete paragraph {} {}", notebookId, paragraphId); Note note = notebook.getNote(notebookId); @@ -487,36 +482,38 @@ public class NotebookRestApi { /** * Run notebook jobs REST API - * @param + * + * @param notebookId ID of Notebook * @return JSON with status.OK * @throws IOException, IllegalArgumentException */ @POST @Path("job/{notebookId}") @ZeppelinApi - public Response runNoteJobs(@PathParam("notebookId") String notebookId) throws - IOException, IllegalArgumentException { + public Response runNoteJobs(@PathParam("notebookId") String notebookId) + throws IOException, IllegalArgumentException { LOG.info("run notebook jobs {} ", notebookId); Note note = notebook.getNote(notebookId); if (note == null) { return new JsonResponse<>(Status.NOT_FOUND, "note not found.").build(); } - + note.runAll(); return new JsonResponse<>(Status.OK).build(); } /** * Stop(delete) notebook jobs REST API - * @param + * + * @param notebookId ID of Notebook * @return JSON with status.OK * @throws IOException, IllegalArgumentException */ @DELETE @Path("job/{notebookId}") @ZeppelinApi - public Response stopNoteJobs(@PathParam("notebookId") String notebookId) throws - IOException, IllegalArgumentException { + public Response stopNoteJobs(@PathParam("notebookId") String notebookId) + throws IOException, IllegalArgumentException { LOG.info("stop notebook jobs {} ", notebookId); Note note = notebook.getNote(notebookId); if (note == null) { @@ -530,18 +527,19 @@ public class NotebookRestApi { } return new JsonResponse<>(Status.OK).build(); } - + /** * Get notebook job status REST API - * @param + * + * @param notebookId ID of Notebook * @return JSON with status.OK * @throws IOException, IllegalArgumentException */ @GET @Path("job/{notebookId}") @ZeppelinApi - public Response getNoteJobStatus(@PathParam("notebookId") String notebookId) throws - IOException, IllegalArgumentException { + public Response getNoteJobStatus(@PathParam("notebookId") String notebookId) + throws IOException, IllegalArgumentException { LOG.info("get notebook job status."); Note note = notebook.getNote(notebookId); if (note == null) { @@ -550,23 +548,21 @@ public class NotebookRestApi { return new JsonResponse<>(Status.OK, null, note.generateParagraphsInfo()).build(); } - + /** * Run paragraph job REST API - * + * * @param message - JSON with params if user wants to update dynamic form's value * null, empty string, empty json if user doesn't want to update - * * @return JSON with status.OK * @throws IOException, IllegalArgumentException */ @POST @Path("job/{notebookId}/{paragraphId}") @ZeppelinApi - public Response runParagraph(@PathParam("notebookId") String notebookId, - @PathParam("paragraphId") String paragraphId, - String message) throws - IOException, IllegalArgumentException { + public Response runParagraph(@PathParam("notebookId") String notebookId, + @PathParam("paragraphId") String paragraphId, String message) + throws IOException, IllegalArgumentException { LOG.info("run paragraph job {} {} {}", notebookId, paragraphId, message); Note note = notebook.getNote(notebookId); @@ -581,8 +577,8 @@ public class NotebookRestApi { // handle params if presented if (!StringUtils.isEmpty(message)) { - RunParagraphWithParametersRequest request = gson.fromJson(message, - RunParagraphWithParametersRequest.class); + RunParagraphWithParametersRequest request = + gson.fromJson(message, RunParagraphWithParametersRequest.class); Map<String, Object> paramsForUpdating = request.getParams(); if (paramsForUpdating != null) { paragraph.settings.getParams().putAll(paramsForUpdating); @@ -598,16 +594,21 @@ public class NotebookRestApi { /** * Stop(delete) paragraph job REST API - * @param + * + * @param notebookId ID of Notebook + * @param paragraphId ID of Paragraph * @return JSON with status.OK * @throws IOException, IllegalArgumentException */ @DELETE @Path("job/{notebookId}/{paragraphId}") @ZeppelinApi - public Response stopParagraph(@PathParam("notebookId") String notebookId, - @PathParam("paragraphId") String paragraphId) throws - IOException, IllegalArgumentException { + public Response stopParagraph(@PathParam("notebookId") String notebookId, + @PathParam("paragraphId") String paragraphId) throws IOException, IllegalArgumentException { + /** + * TODO(jl): Fixed notebookId to noteId + * https://issues.apache.org/jira/browse/ZEPPELIN-1163 + */ LOG.info("stop paragraph job {} ", notebookId); Note note = notebook.getNote(notebookId); if (note == null) { @@ -621,9 +622,10 @@ public class NotebookRestApi { p.abort(); return new JsonResponse<>(Status.OK).build(); } - + /** * Register cron job REST API + * * @param message - JSON with cron expressions. * @return JSON with status.OK * @throws IOException, IllegalArgumentException @@ -631,18 +633,18 @@ public class NotebookRestApi { @POST @Path("cron/{notebookId}") @ZeppelinApi - public Response registerCronJob(@PathParam("notebookId") String notebookId, String message) throws - IOException, IllegalArgumentException { + public Response registerCronJob(@PathParam("notebookId") String notebookId, String message) + throws IOException, IllegalArgumentException { + // TODO(jl): Fixed notebookId to noteId LOG.info("Register cron job note={} request cron msg={}", notebookId, message); - CronRequest request = gson.fromJson(message, - CronRequest.class); - + CronRequest request = gson.fromJson(message, CronRequest.class); + Note note = notebook.getNote(notebookId); if (note == null) { return new JsonResponse<>(Status.NOT_FOUND, "note not found.").build(); } - + if (!CronExpression.isValidExpression(request.getCronString())) { return new JsonResponse<>(Status.BAD_REQUEST, "wrong cron expressions.").build(); } @@ -651,60 +653,64 @@ public class NotebookRestApi { config.put("cron", request.getCronString()); note.setConfig(config); notebook.refreshCron(note.id()); - + return new JsonResponse<>(Status.OK).build(); } - + /** * Remove cron job REST API - * @param + * + * @param notebookId ID of Notebook * @return JSON with status.OK * @throws IOException, IllegalArgumentException */ @DELETE @Path("cron/{notebookId}") @ZeppelinApi - public Response removeCronJob(@PathParam("notebookId") String notebookId) throws - IOException, IllegalArgumentException { + public Response removeCronJob(@PathParam("notebookId") String notebookId) + throws IOException, IllegalArgumentException { + // TODO(jl): Fixed notebookId to noteId LOG.info("Remove cron job note {}", notebookId); Note note = notebook.getNote(notebookId); if (note == null) { return new JsonResponse<>(Status.NOT_FOUND, "note not found.").build(); } - + Map<String, Object> config = note.getConfig(); config.put("cron", null); note.setConfig(config); notebook.refreshCron(note.id()); - + return new JsonResponse<>(Status.OK).build(); - } - + } + /** * Get cron job REST API - * @param + * + * @param notebookId ID of Notebook * @return JSON with status.OK * @throws IOException, IllegalArgumentException */ @GET @Path("cron/{notebookId}") @ZeppelinApi - public Response getCronJob(@PathParam("notebookId") String notebookId) throws - IOException, IllegalArgumentException { + public Response getCronJob(@PathParam("notebookId") String notebookId) + throws IOException, IllegalArgumentException { + // TODO(jl): Fixed notebookId to noteId LOG.info("Get cron job note {}", notebookId); Note note = notebook.getNote(notebookId); if (note == null) { return new JsonResponse<>(Status.NOT_FOUND, "note not found.").build(); } - + return new JsonResponse<>(Status.OK, note.getConfig().get("cron")).build(); } /** * Get notebook jobs for job manager - * @param + * * @return JSON with status.OK * @throws IOException, IllegalArgumentException */ @@ -726,7 +732,7 @@ public class NotebookRestApi { /** * Get updated notebook jobs for job manager - * @param + * * @return JSON with status.OK * @throws IOException, IllegalArgumentException */ @@ -734,8 +740,8 @@ public class NotebookRestApi { @Path("jobmanager/{lastUpdateUnixtime}/") @ZeppelinApi public Response getUpdatedJobListforNotebook( - @PathParam("lastUpdateUnixtime") long lastUpdateUnixTime) throws - IOException, IllegalArgumentException { + @PathParam("lastUpdateUnixtime") long lastUpdateUnixTime) + throws IOException, IllegalArgumentException { LOG.info("Get updated notebook jobs lastUpdateTime {}", lastUpdateUnixTime); List<Map<String, Object>> notebookJobs; @@ -759,7 +765,7 @@ public class NotebookRestApi { LOG.info("Searching notebooks for: {}", queryTerm); String principal = SecurityUtils.getPrincipal(); HashSet<String> roles = SecurityUtils.getRoles(); - HashSet<String> userAndRoles = new HashSet<String>(); + HashSet<String> userAndRoles = new HashSet<>(); userAndRoles.add(principal); userAndRoles.addAll(roles); List<Map<String, String>> notebooksFound = notebookIndex.query(queryTerm); @@ -767,8 +773,8 @@ public class NotebookRestApi { String[] Id = notebooksFound.get(i).get("id").split("/", 2); String noteId = Id[0]; if (!notebookAuthorization.isOwner(noteId, userAndRoles) && - !notebookAuthorization.isReader(noteId, userAndRoles) && - !notebookAuthorization.isWriter(noteId, userAndRoles)) { + !notebookAuthorization.isReader(noteId, userAndRoles) && + !notebookAuthorization.isWriter(noteId, userAndRoles)) { notebooksFound.remove(i); i--; } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/b11b6ec2/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/InterpreterSettingListForNoteBind.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/InterpreterSettingListForNoteBind.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/InterpreterSettingListForNoteBind.java index e0ddacb..6ec5a54 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/InterpreterSettingListForNoteBind.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/InterpreterSettingListForNoteBind.java @@ -19,69 +19,22 @@ package org.apache.zeppelin.rest.message; import java.util.List; -import org.apache.zeppelin.interpreter.Interpreter; -import org.apache.zeppelin.interpreter.InterpreterSetting; +import org.apache.zeppelin.interpreter.InterpreterInfo; /** * InterpreterSetting information for binding */ public class InterpreterSettingListForNoteBind { - String id; - String name; - String group; + private String id; + private String name; private boolean selected; - private List<InterpreterSetting.InterpreterInfo> interpreters; + private List<InterpreterInfo> interpreters; public InterpreterSettingListForNoteBind(String id, String name, - String group, - List<InterpreterSetting.InterpreterInfo> interpreters, - boolean selected) { - super(); + List<InterpreterInfo> interpreters, boolean selected) { this.id = id; this.name = name; - this.group = group; this.interpreters = interpreters; this.selected = selected; } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getGroup() { - return group; - } - - public void setGroup(String group) { - this.group = group; - } - - public List<InterpreterSetting.InterpreterInfo> getInterpreterNames() { - return interpreters; - } - - public void setInterpreterNames(List<InterpreterSetting.InterpreterInfo> interpreters) { - this.interpreters = interpreters; - } - - public boolean isSelected() { - return selected; - } - - public void setSelected(boolean selected) { - this.selected = selected; - } - } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/b11b6ec2/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewInterpreterSettingRequest.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewInterpreterSettingRequest.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewInterpreterSettingRequest.java index a559fb5..7e3a414 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewInterpreterSettingRequest.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewInterpreterSettingRequest.java @@ -24,16 +24,15 @@ import org.apache.zeppelin.dep.Dependency; import org.apache.zeppelin.interpreter.InterpreterOption; /** - * NewInterpreterSetting rest api request message - * + * NewInterpreterSetting rest api request message */ public class NewInterpreterSettingRequest { - String name; - String group; + private String name; + private String group; - Map<String, String> properties; - List<Dependency> dependencies; - InterpreterOption option; + private Map<String, String> properties; + private List<Dependency> dependencies; + private InterpreterOption option; public NewInterpreterSettingRequest() { http://git-wip-us.apache.org/repos/asf/zeppelin/blob/b11b6ec2/zeppelin-server/src/test/java/org/apache/zeppelin/rest/AbstractTestRestApi.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/AbstractTestRestApi.java b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/AbstractTestRestApi.java index cb77ae7..6cfd961 100644 --- a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/AbstractTestRestApi.java +++ b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/AbstractTestRestApi.java @@ -22,9 +22,7 @@ import java.io.IOException; import java.lang.ref.WeakReference; import java.net.InetAddress; import java.net.UnknownHostException; -import java.util.LinkedList; import java.util.List; -import java.util.Properties; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -37,9 +35,6 @@ import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.methods.PutMethod; import org.apache.commons.httpclient.methods.RequestEntity; import org.apache.zeppelin.conf.ZeppelinConfiguration; -import org.apache.zeppelin.dep.Dependency; -import org.apache.zeppelin.interpreter.InterpreterGroup; -import org.apache.zeppelin.interpreter.InterpreterOption; import org.apache.zeppelin.interpreter.InterpreterSetting; import org.apache.zeppelin.server.ZeppelinServer; import org.hamcrest.Description; @@ -51,7 +46,6 @@ import org.slf4j.LoggerFactory; import com.google.gson.JsonElement; import com.google.gson.JsonParseException; import com.google.gson.JsonParser; -import org.sonatype.aether.RepositoryException; public abstract class AbstractTestRestApi { @@ -149,7 +143,7 @@ public abstract class AbstractTestRestApi { // assume first one is spark InterpreterSetting sparkIntpSetting = null; for(InterpreterSetting intpSetting : ZeppelinServer.notebook.getInterpreterFactory().get()) { - if (intpSetting.getGroup().equals("spark")) { + if (intpSetting.getName().equals("spark")) { sparkIntpSetting = intpSetting; } } @@ -162,12 +156,12 @@ public abstract class AbstractTestRestApi { sparkIntpSetting.getProperties().setProperty("spark.home", getSparkHome()); pySpark = true; sparkR = true; - ZeppelinServer.notebook.getInterpreterFactory().restart(sparkIntpSetting.id()); + ZeppelinServer.notebook.getInterpreterFactory().restart(sparkIntpSetting.getId()); } else { // assume first one is spark InterpreterSetting sparkIntpSetting = null; for(InterpreterSetting intpSetting : ZeppelinServer.notebook.getInterpreterFactory().get()) { - if (intpSetting.getGroup().equals("spark")) { + if (intpSetting.getName().equals("spark")) { sparkIntpSetting = intpSetting; } } @@ -180,7 +174,7 @@ public abstract class AbstractTestRestApi { sparkR = true; } - ZeppelinServer.notebook.getInterpreterFactory().restart(sparkIntpSetting.id()); + ZeppelinServer.notebook.getInterpreterFactory().restart(sparkIntpSetting.getId()); } } } @@ -401,18 +395,6 @@ public abstract class AbstractTestRestApi { }; } - //Create new Setting and return Setting ID - protected String createTempSetting(String tempName) - throws IOException, RepositoryException { - InterpreterSetting setting = ZeppelinServer.notebook.getInterpreterFactory() - .add(tempName, - "newGroup", - new LinkedList<Dependency>(), - new InterpreterOption(false), - new Properties()); - return setting.id(); - } - protected TypeSafeMatcher<? super JsonElement> hasRootElementNamed(final String memberName) { return new TypeSafeMatcher<JsonElement>() { @Override http://git-wip-us.apache.org/repos/asf/zeppelin/blob/b11b6ec2/zeppelin-server/src/test/java/org/apache/zeppelin/rest/InterpreterRestApiTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/InterpreterRestApiTest.java b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/InterpreterRestApiTest.java index 4d7caf1..e92432f 100644 --- a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/InterpreterRestApiTest.java +++ b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/InterpreterRestApiTest.java @@ -25,7 +25,6 @@ import org.apache.commons.httpclient.methods.DeleteMethod; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.methods.PutMethod; -import org.apache.commons.lang3.StringUtils; import org.apache.zeppelin.interpreter.InterpreterSetting; import org.apache.zeppelin.notebook.Note; import org.apache.zeppelin.notebook.Paragraph; @@ -69,7 +68,7 @@ public class InterpreterRestApiTest extends AbstractTestRestApi { Map<String, Object> resp = gson.fromJson(get.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() { }.getType()); Map<String, Object> body = (Map<String, Object>) resp.get("body"); - assertEquals(ZeppelinServer.notebook.getInterpreterFactory().getRegisteredInterpreterList().size(), body.size()); + assertEquals(ZeppelinServer.notebook.getInterpreterFactory().getAvailableInterpreterSettings().size(), body.size()); get.releaseConnection(); } @@ -162,7 +161,7 @@ public class InterpreterRestApiTest extends AbstractTestRestApi { for (InterpreterSetting setting : ZeppelinServer.notebook.getInterpreterFactory().getInterpreterSettings(note.getId())) { if (setting.getName().equals("md")) { // Call Restart Interpreter REST API - PutMethod put = httpPut("/interpreter/setting/restart/" + setting.id(), ""); + PutMethod put = httpPut("/interpreter/setting/restart/" + setting.getId(), ""); assertThat("test interpreter restart:", put, isAllowed()); put.releaseConnection(); break; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/b11b6ec2/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinSparkClusterTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinSparkClusterTest.java b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinSparkClusterTest.java index 3c77b45..24a1b90 100644 --- a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinSparkClusterTest.java +++ b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinSparkClusterTest.java @@ -20,16 +20,10 @@ import static org.junit.Assert.assertEquals; import java.io.File; import java.io.IOException; -import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.commons.exec.CommandLine; -import org.apache.commons.exec.DefaultExecutor; -import org.apache.commons.exec.ExecuteWatchdog; -import org.apache.commons.exec.PumpStreamHandler; import org.apache.commons.io.FileUtils; -import org.apache.commons.io.output.ByteArrayOutputStream; import org.apache.zeppelin.interpreter.InterpreterSetting; import org.apache.zeppelin.notebook.Note; import org.apache.zeppelin.notebook.Paragraph; @@ -204,8 +198,8 @@ public class ZeppelinSparkClusterTest extends AbstractTestRestApi { ZeppelinServer.notebook.getBindedInterpreterSettings(note.id()); for (InterpreterSetting setting : settings) { - if (setting.getGroup().equals("spark")) { - ZeppelinServer.notebook.getInterpreterFactory().restart(setting.id()); + if (setting.getName().equals("spark")) { + ZeppelinServer.notebook.getInterpreterFactory().restart(setting.getId()); break; } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/b11b6ec2/zeppelin-web/src/app/interpreter/interpreter-create/interpreter-create.html ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/interpreter/interpreter-create/interpreter-create.html b/zeppelin-web/src/app/interpreter/interpreter-create/interpreter-create.html index 97e3103..599248b 100644 --- a/zeppelin-web/src/app/interpreter/interpreter-create/interpreter-create.html +++ b/zeppelin-web/src/app/interpreter/interpreter-create/interpreter-create.html @@ -19,7 +19,7 @@ limitations under the License. <h4>Create new interpreter</h4> <div class="form-group" style="width:200px"> - <b>Name</b> + <b>Interpreter Name</b> <input id="newInterpreterSettingName" input pu-elastic-input pu-elastic-input-minwidth="180px" ng-model="newInterpreterSetting.name" /> </div> @@ -29,8 +29,8 @@ limitations under the License. style="width:180px"> <select class="form-control input-sm" ng-model="newInterpreterSetting.group" ng-change="newInterpreterGroupChange()"> - <option ng-repeat="availableInterpreter in availableInterpreters | unique: 'group'| orderBy: 'group'" value="{{availableInterpreter.group}}"> - {{availableInterpreter.group}} + <option ng-repeat="availableInterpreter in availableInterpreters | unique: 'name'| orderBy: 'name'" value="{{availableInterpreter.name}}"> + {{availableInterpreter.name}} </option> </select> </div> http://git-wip-us.apache.org/repos/asf/zeppelin/blob/b11b6ec2/zeppelin-web/src/app/interpreter/interpreter.controller.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/interpreter/interpreter.controller.js b/zeppelin-web/src/app/interpreter/interpreter.controller.js index be64c78..affd9bd 100644 --- a/zeppelin-web/src/app/interpreter/interpreter.controller.js +++ b/zeppelin-web/src/app/interpreter/interpreter.controller.js @@ -194,15 +194,14 @@ angular.module('zeppelinWebApp').controller('InterpreterCtrl', }; $scope.newInterpreterGroupChange = function() { - var el = _.pluck(_.filter($scope.availableInterpreters, {'group': $scope.newInterpreterSetting.group}), + var el = _.pluck(_.filter($scope.availableInterpreters, {'name': $scope.newInterpreterSetting.group}), 'properties'); - var properties = {}; for (var i = 0; i < el.length; i++) { var intpInfo = el[i]; for (var key in intpInfo) { properties[key] = { - value: intpInfo[key].defaultValue, + value: intpInfo[key], description: intpInfo[key].description }; } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/b11b6ec2/zeppelin-web/src/app/interpreter/interpreter.html ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/interpreter/interpreter.html b/zeppelin-web/src/app/interpreter/interpreter.html index d96fadf..088359a 100644 --- a/zeppelin-web/src/app/interpreter/interpreter.html +++ b/zeppelin-web/src/app/interpreter/interpreter.html @@ -84,7 +84,7 @@ limitations under the License. </div> <div class="box width-full" - ng-repeat="setting in interpreterSettings | orderBy: 'group' | filter: searchInterpreter"> + ng-repeat="setting in interpreterSettings | orderBy: 'name' | filter: searchInterpreter"> <div id="{{setting.name | lowercase}}"> <div class="row interpreter"> <div class="col-md-12"> @@ -93,7 +93,7 @@ limitations under the License. <span style="display:inline-block" ng-repeat="interpreter in setting.interpreterGroup" title="{{interpreter.class}}"> <span ng-show="!$first">, </span> - %<span ng-show="!$parent.$first || $first">{{setting.group}}</span + %<span ng-show="!$parent.$first || $first">{{setting.name}}</span ><span ng-show="(!$parent.$first || $first) && !$first">.</span ><span ng-show="!$first">{{interpreter.name}}</span> <span ng-show="$parent.$first && $first">(default)</span> http://git-wip-us.apache.org/repos/asf/zeppelin/blob/b11b6ec2/zeppelin-web/src/app/notebook/notebook.controller.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/notebook/notebook.controller.js b/zeppelin-web/src/app/notebook/notebook.controller.js index 7e0bd7e..eea8a10 100644 --- a/zeppelin-web/src/app/notebook/notebook.controller.js +++ b/zeppelin-web/src/app/notebook/notebook.controller.js @@ -588,9 +588,9 @@ angular.module('zeppelinWebApp').controller('NotebookCtrl', function($scope, $ro var selectedIntp = {}; for (key in $scope.interpreterBindings) { setting = $scope.interpreterBindings[key]; - if (!selectedIntp[setting.group]) { + if (!selectedIntp[setting.name]) { setting.selected = true; - selectedIntp[setting.group] = true; + selectedIntp[setting.name] = true; } } $scope.showSetting = true; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/b11b6ec2/zeppelin-web/src/app/notebook/notebook.html ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/app/notebook/notebook.html b/zeppelin-web/src/app/notebook/notebook.html index f0e87a7..00fcacd 100644 --- a/zeppelin-web/src/app/notebook/notebook.html +++ b/zeppelin-web/src/app/notebook/notebook.html @@ -40,7 +40,7 @@ limitations under the License. <small> <span style="display:inline-block" ng-repeat="intp in item.interpreters"> <span ng-show="!$first">, </span> - %<span ng-show="!$parent.$first || $first">{{item.group}}</span + %<span ng-show="!$parent.$first || $first">{{item.name}}</span ><span ng-show="(!$parent.$first || $first) && !$first">.</span ><span ng-show="!$first">{{intp.name}}</span> <span ng-show="$parent.$first && $first">(default)</span> http://git-wip-us.apache.org/repos/asf/zeppelin/blob/b11b6ec2/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumApplicationFactory.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumApplicationFactory.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumApplicationFactory.java index 6759f97..e051488 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumApplicationFactory.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumApplicationFactory.java @@ -20,6 +20,7 @@ import com.google.gson.Gson; import org.apache.thrift.TException; import org.apache.zeppelin.interpreter.Interpreter; import org.apache.zeppelin.interpreter.InterpreterGroup; +import org.apache.zeppelin.interpreter.InterpreterInfo; import org.apache.zeppelin.interpreter.InterpreterSetting; import org.apache.zeppelin.interpreter.remote.RemoteAngularObjectRegistry; import org.apache.zeppelin.interpreter.remote.RemoteInterpreterProcess; @@ -442,8 +443,8 @@ public class HeliumApplicationFactory implements ApplicationEventListener, Noteb public void onUnbindInterpreter(Note note, InterpreterSetting setting) { for (Paragraph p : note.getParagraphs()) { Interpreter currentInterpreter = p.getCurrentRepl(); - List<InterpreterSetting.InterpreterInfo> infos = setting.getInterpreterInfos(); - for (InterpreterSetting.InterpreterInfo info : infos) { + List<InterpreterInfo> infos = setting.getInterpreterInfos(); + for (InterpreterInfo info : infos) { if (info.getClassName().equals(currentInterpreter.getClassName())) { onParagraphRemove(p); break;
