Repository: zeppelin Updated Branches: refs/heads/master 5ae54ad51 -> e1f20ddda
[ZEPPELIN-2699] Helium REST API bug-fixes. Also updated documentation ### What is this PR for? Fixing bug on enabling Helium plugins (artifact is empty, not null) when sending curl command. After noticing out-of-date documentation, I updated it Also noticed issues on missing try/catch expressions and missing info messages on enable/disable packages. ### What type of PR is it? [Bug Fix | Documentation | Refactoring] ### What is the Jira issue? * https://issues.apache.org/jira/browse/ZEPPELIN-2699 ### How should this be tested? Run "curl -X POST http://localhost:8080/api/helium/enable/{packageName}" Check that the package gets enabled ### Questions: * Does the licenses files need update? N * Is there breaking changes for older versions? N * Does this needs documentation? Y (Done) Author: Nelson Costa <nelson.cost...@gmail.com> Closes #2446 from necosta/zeppelin2699 and squashes the following commits: 473f9b43 [Nelson Costa] [ZEPPELIN-2699] Fixed initialization issue 45b77513 [Nelson Costa] [ZEPPELIN-2699] More corrections c8230218 [Nelson Costa] [ZEPPELIN-2699] Bug-fix on gathering package info 2b1ff8ae [Nelson Costa] [ZEPPELIN-2699] Changes after code review a71b9fb9 [Nelson Costa] [ZEPPELIN-2699] Changes after code-review 5d179218 [Nelson Costa] [ZEPPELIN-2699] Helium REST API bug-fixes. Also updated documentation Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/e1f20ddd Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/e1f20ddd Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/e1f20ddd Branch: refs/heads/master Commit: e1f20ddda2d9795b28cfd61e9e03a86b398da9e3 Parents: 5ae54ad Author: Nelson Costa <nelson.cost...@gmail.com> Authored: Wed Jul 19 16:01:24 2017 +0100 Committer: 1ambda <1am...@gmail.com> Committed: Sat Jul 22 00:24:20 2017 +0900 ---------------------------------------------------------------------- docs/usage/rest_api/helium.md | 257 +++++++++++++++---- .../zeppelin/helium/HeliumPackageTest.java | 3 - .../org/apache/zeppelin/rest/HeliumRestApi.java | 87 ++++--- .../apache/zeppelin/rest/HeliumRestApiTest.java | 223 ++++++++++++++++ .../java/org/apache/zeppelin/helium/Helium.java | 126 ++++----- .../zeppelin/helium/HeliumBundleFactory.java | 2 +- .../org/apache/zeppelin/helium/HeliumConf.java | 7 +- .../zeppelin/helium/HeliumLocalRegistry.java | 3 +- .../zeppelin/helium/HeliumOnlineRegistry.java | 2 +- .../org/apache/zeppelin/helium/HeliumTest.java | 6 +- .../zeppelin/helium/HeliumTestApplication.java | 2 +- .../zeppelin/helium/HeliumTestRegistry.java | 2 +- 12 files changed, 549 insertions(+), 171 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e1f20ddd/docs/usage/rest_api/helium.md ---------------------------------------------------------------------- diff --git a/docs/usage/rest_api/helium.md b/docs/usage/rest_api/helium.md index 37f4bcb..763abb7 100644 --- a/docs/usage/rest_api/helium.md +++ b/docs/usage/rest_api/helium.md @@ -32,7 +32,7 @@ If you work with Apache Zeppelin and find a need for an additional REST API, ple ## Helium REST API List -### List of all available helium packages +### Get all available helium packages <table class="table-configuration"> <col width="200"> @@ -42,7 +42,7 @@ If you work with Apache Zeppelin and find a need for an additional REST API, ple </tr> <tr> <td>URL</td> - <td>```http://[zeppelin-server]:[zeppelin-port]/api/helium/all```</td> + <td>```http://[zeppelin-server]:[zeppelin-port]/api/helium/package```</td> </tr> <tr> <td>Success code</td> @@ -78,42 +78,115 @@ If you work with Apache Zeppelin and find a need for an additional REST API, ple }, "enabled": false } - ], - "zeppelin-bubblechart": [ - { - "registry": "local", - "pkg": { - "type": "VISUALIZATION", - "name": "zeppelin-bubblechart", - "description": "Animated bubble chart", - "artifact": ".\/..\/helium\/zeppelin-bubble", - "icon": "icon" - }, - "enabled": true - }, + ] + } +} + </pre> + </td> + </tr> + </table> +<br/> + +### Get all enabled helium packages + + <table class="table-configuration"> + <col width="200"> + <tr> + <td>Description</td> + <td>This ```GET``` method returns all enabled helium packages in configured registries.</td> + </tr> + <tr> + <td>URL</td> + <td>```http://[zeppelin-server]:[zeppelin-port]/api/helium/enabledPackage```</td> + </tr> + <tr> + <td>Success code</td> + <td>200</td> + </tr> + <tr> + <td>Fail code</td> + <td> 500 </td> + </tr> + <tr> + <td>Sample JSON response</td> + <td> + <pre> +{ + "status": "OK", + "message": "", + "body": { + "zeppelin.clock": [ { "registry": "local", "pkg": { - "type": "VISUALIZATION", - "name": "zeppelin-bubblechart", - "description": "Animated bubble chart", - "artifact": "zeppelin-bubblechart@0.0.2", + "type": "APPLICATION", + "name": "zeppelin.clock", + "description": "Clock (example)", + "artifact": "zeppelin-examples\/zeppelin-example-clock\/target\/zeppelin-example-clock-0.7.0-SNAPSHOT.jar", + "className": "org.apache.zeppelin.example.app.clock.Clock", + "resources": [ + [ + ":java.util.Date" + ] + ], "icon": "icon" }, "enabled": false } - ], - "zeppelin\_horizontalbar": [ + ] + } +} + </pre> + </td> + </tr> + </table> +<br/> + +### Get single helium package + + <table class="table-configuration"> + <col width="200"> + <tr> + <td>Description</td> + <td>This ```GET``` method returns specified helium package information</td> + </tr> + <tr> + <td>URL</td> + <td>```http://[zeppelin-server]:[zeppelin-port]/api/helium/package/[Package Name]```</td> + </tr> + <tr> + <td>Success code</td> + <td>200</td> + </tr> + <tr> + <td>Fail code</td> + <td> 500 </td> + </tr> + <tr> + <td>Sample JSON response</td> + <td> + <pre> +{ + "status": "OK", + "message": "", + "body": { + "zeppelin.clock": [ { "registry": "local", "pkg": { - "type": "VISUALIZATION", - "name": "zeppelin_horizontalbar", - "description": "Horizontal Bar chart (example)", - "artifact": ".\/zeppelin-examples\/zeppelin-example-horizontalbar", + "type": "APPLICATION", + "name": "zeppelin.clock", + "description": "Clock (example)", + "artifact": "zeppelin-examples\/zeppelin-example-clock\/target\/zeppelin-example-clock-0.7.0-SNAPSHOT.jar", + "className": "org.apache.zeppelin.example.app.clock.Clock", + "resources": [ + [ + ":java.util.Date" + ] + ], "icon": "icon" }, - "enabled": true + "enabled": false } ] } @@ -122,15 +195,15 @@ If you work with Apache Zeppelin and find a need for an additional REST API, ple </td> </tr> </table> - <br/> -### Suggest Helium application + +### Suggest Helium package on a paragraph <table class="table-configuration"> <col width="200"> <tr> <td>Description</td> - <td>This ```GET``` method returns suggested helium application for the paragraph.</td> + <td>This ```GET``` method returns suggested helium package for the paragraph.</td> </tr> <tr> <td>URL</td> @@ -180,15 +253,15 @@ If you work with Apache Zeppelin and find a need for an additional REST API, ple </td> </tr> </table> - <br/> -### Load helium Application on a paragraph + +### Load Helium package on a paragraph <table class="table-configuration"> <col width="200"> <tr> <td>Description</td> - <td>This ```GET``` method returns a helium Application id on success.</td> + <td>This ```POST``` method loads helium package to target paragraph.</td> </tr> <tr> <td>URL</td> @@ -201,8 +274,8 @@ If you work with Apache Zeppelin and find a need for an additional REST API, ple <tr> <td>Fail code</td> <td> - 404 on note or paragraph not exists <br/> - 500 for any other errors + 404 on note or paragraph not exists <br /> + 500 </td> </tr> <tr> @@ -218,19 +291,19 @@ If you work with Apache Zeppelin and find a need for an additional REST API, ple </td> </tr> </table> - <br/> + ### Load bundled visualization script <table class="table-configuration"> <col width="200"> <tr> <td>Description</td> - <td>This ```GET``` method returns bundled helium visualization javascript. When refresh=true (optional) is provided, Zeppelin rebuild bundle. otherwise, provided from cache</td> + <td>This ```GET``` method returns bundled helium visualization javascript. When refresh=true (optional) is provided, Zeppelin rebuilds bundle. Otherwise, it's provided from cache</td> </tr> <tr> <td>URL</td> - <td>```http://[zeppelin-server]:[zeppelin-port]/api/helium/visualizations/load[?refresh=true]```</td> + <td>```http://[zeppelin-server]:[zeppelin-port]/api/helium/bundle/load/[Package Name][?refresh=true]```</td> </tr> <tr> <td>Success code</td> @@ -243,8 +316,8 @@ If you work with Apache Zeppelin and find a need for an additional REST API, ple </td> </tr> </table> - <br/> + ### Enable package <table class="table-configuration"> <col width="200"> @@ -281,8 +354,8 @@ zeppelin-examples/zeppelin-example-clock/target/zeppelin-example-clock-0.7.0-SNA </td> </tr> </table> - <br/> + ### Disable package <table class="table-configuration"> @@ -310,7 +383,7 @@ zeppelin-examples/zeppelin-example-clock/target/zeppelin-example-clock-0.7.0-SNA </td> </tr> </table> -<br /> +<br/> ### Get visualization display order @@ -322,7 +395,7 @@ zeppelin-examples/zeppelin-example-clock/target/zeppelin-example-clock-0.7.0-SNA </tr> <tr> <td>URL</td> - <td>```http://[zeppelin-server]:[zeppelin-port]/api/helium/visualizationOrder```</td> + <td>```http://[zeppelin-server]:[zeppelin-port]/api/helium/order/visualization```</td> </tr> <tr> <td>Success code</td> @@ -339,9 +412,7 @@ zeppelin-examples/zeppelin-example-clock/target/zeppelin-example-clock-0.7.0-SNA </td> </tr> </table> - - -<br /> +<br/> ### Set visualization display order @@ -353,7 +424,7 @@ zeppelin-examples/zeppelin-example-clock/target/zeppelin-example-clock-0.7.0-SNA </tr> <tr> <td>URL</td> - <td>```http://[zeppelin-server]:[zeppelin-port]/api/helium/visualizationOrder```</td> + <td>```http://[zeppelin-server]:[zeppelin-port]/api/helium/order/visualization```</td> </tr> <tr> <td>Success code</td> @@ -375,4 +446,98 @@ zeppelin-examples/zeppelin-example-clock/target/zeppelin-example-clock-0.7.0-SNA <code>{"status":"OK"}</code> </td> </tr> - </table> \ No newline at end of file + </table> +<br/> + +### Get configuration for all Helium packages + + <table class="table-configuration"> + <col width="200"> + <tr> + <td>Description</td> + <td>This ```GET``` method returns configuration for all Helium packages</td> + </tr> + <tr> + <td>URL</td> + <td>```http://[zeppelin-server]:[zeppelin-port]/api/helium/config```</td> + </tr> + <tr> + <td>Success code</td> + <td>200</td> + </tr> + <tr> + <td> Fail code</td> + <td> 500 </td> + </tr> + </table> + <br/> + + ### Get configuration for specific package + + <table class="table-configuration"> + <col width="200"> + <tr> + <td>Description</td> + <td>This ```GET``` method returns configuration for the specified package name and artifact</td> + </tr> + <tr> + <td>URL</td> + <td>```http://[zeppelin-server]:[zeppelin-port]/api/helium/config/[Package Name]/[Artifact]```</td> + </tr> + <tr> + <td>Success code</td> + <td>200</td> + </tr> + <tr> + <td> Fail code</td> + <td> 500 </td> + </tr> + </table> +<br/> + +### Set configuration for specific package + + <table class="table-configuration"> + <col width="200"> + <tr> + <td>Description</td> + <td>This ```POST``` method updates configuration for specified package name and artifact</td> + </tr> + <tr> + <td>URL</td> + <td>```http://[zeppelin-server]:[zeppelin-port]/api/helium/config/[Package Name]/[Artifact]```</td> + </tr> + <tr> + <td>Success code</td> + <td>200</td> + </tr> + <tr> + <td> Fail code</td> + <td> 500 </td> + </tr> + </table> + <br/> + + ### Get Spell configuration for single package + + <table class="table-configuration"> + <col width="200"> + <tr> + <td>Description</td> + <td>This ```GET``` method returns specified package Spell configuration</td> + </tr> + <tr> + <td>URL</td> + <td>```http://[zeppelin-server]:[zeppelin-port]/api/helium/spell/config/[Package Name]```</td> + </tr> + <tr> + <td>Success code</td> + <td>200</td> + </tr> + <tr> + <td> Fail code</td> + <td> 500 </td> + </tr> + </table> + <br/> + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e1f20ddd/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/HeliumPackageTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/HeliumPackageTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/HeliumPackageTest.java index 4b91c82..ad427e9 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/HeliumPackageTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/HeliumPackageTest.java @@ -17,7 +17,6 @@ package org.apache.zeppelin.helium; -import com.google.gson.Gson; import org.junit.Test; import java.util.Map; @@ -26,8 +25,6 @@ import static org.junit.Assert.*; public class HeliumPackageTest { - private Gson gson = new Gson(); - @Test public void parseSpellPackageInfo() { String examplePackage = "{\n" + http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e1f20ddd/zeppelin-server/src/main/java/org/apache/zeppelin/rest/HeliumRestApi.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/HeliumRestApi.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/HeliumRestApi.java index c8cd79a..1c8f44f 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/HeliumRestApi.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/HeliumRestApi.java @@ -51,32 +51,37 @@ public class HeliumRestApi { private Notebook notebook; private Gson gson = new Gson(); - public HeliumRestApi() { - } - public HeliumRestApi(Helium helium, Notebook notebook) { this.helium = helium; this.notebook = notebook; } /** - * Get all package infos + * Get all packages info */ @GET @Path("package") public Response getAllPackageInfo() { - return new JsonResponse( - Response.Status.OK, "", helium.getAllPackageInfo()).build(); + try { + return new JsonResponse<>(Response.Status.OK, "", helium.getAllPackageInfo()).build(); + } catch (RuntimeException e) { + logger.error(e.getMessage(), e); + return new JsonResponse(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage()).build(); + } } /** - * Get all enabled package infos + * Get all enabled packages info */ @GET @Path("enabledPackage") public Response getAllEnabledPackageInfo() { - return new JsonResponse( - Response.Status.OK, "", helium.getAllEnabledPackages()).build(); + try { + return new JsonResponse<>(Response.Status.OK, "", helium.getAllEnabledPackages()).build(); + } catch (RuntimeException e) { + logger.error(e.getMessage(), e); + return new JsonResponse(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage()).build(); + } } /** @@ -92,7 +97,7 @@ public class HeliumRestApi { } try { - return new JsonResponse( + return new JsonResponse<>( Response.Status.OK, "", helium.getSinglePackageInfo(packageName)).build(); } catch (RuntimeException e) { logger.error(e.getMessage(), e); @@ -114,13 +119,19 @@ public class HeliumRestApi { return new JsonResponse(Response.Status.NOT_FOUND, "Paragraph " + paragraphId + " not found") .build(); } + try { + return new JsonResponse<>(Response.Status.OK, "", helium.suggestApp(paragraph)).build(); + } + catch (RuntimeException e) { + logger.error(e.getMessage(), e); + return new JsonResponse(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage()).build(); + } - return new JsonResponse(Response.Status.OK, "", helium.suggestApp(paragraph)).build(); } @POST @Path("load/{noteId}/{paragraphId}") - public Response suggest(@PathParam("noteId") String noteId, + public Response load(@PathParam("noteId") String noteId, @PathParam("paragraphId") String paragraphId, String heliumPackage) { @@ -135,9 +146,14 @@ public class HeliumRestApi { .build(); } HeliumPackage pkg = HeliumPackage.fromJson(heliumPackage); - - String appId = helium.getApplicationFactory().loadAndRun(pkg, paragraph); - return new JsonResponse(Response.Status.OK, "", appId).build(); + try { + return new JsonResponse<>(Response.Status.OK, "", + helium.getApplicationFactory().loadAndRun(pkg, paragraph)).build(); + } + catch (RuntimeException e) { + logger.error(e.getMessage(), e); + return new JsonResponse(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage()).build(); + } } @GET @@ -190,8 +206,12 @@ public class HeliumRestApi { public Response enablePackage(@PathParam("packageName") String packageName, String artifact) { try { - helium.enable(packageName, artifact); - return new JsonResponse(Response.Status.OK).build(); + if (helium.enable(packageName, artifact)) { + return new JsonResponse(Response.Status.OK).build(); + } + else { + return new JsonResponse(Response.Status.NOT_FOUND).build(); + } } catch (IOException e) { logger.error(e.getMessage(), e); return new JsonResponse(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage()).build(); @@ -202,8 +222,12 @@ public class HeliumRestApi { @Path("disable/{packageName}") public Response disablePackage(@PathParam("packageName") String packageName) { try { - helium.disable(packageName); - return new JsonResponse(Response.Status.OK).build(); + if (helium.disable(packageName)) { + return new JsonResponse(Response.Status.OK).build(); + } + else { + return new JsonResponse(Response.Status.NOT_FOUND).build(); + } } catch (IOException e) { logger.error(e.getMessage(), e); return new JsonResponse(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage()).build(); @@ -227,7 +251,7 @@ public class HeliumRestApi { "Failed to find enabled package for " + packageName).build(); } - return new JsonResponse(Response.Status.OK, config).build(); + return new JsonResponse<>(Response.Status.OK, config).build(); } catch (RuntimeException e) { logger.error(e.getMessage(), e); return new JsonResponse(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage()).build(); @@ -239,7 +263,7 @@ public class HeliumRestApi { public Response getAllPackageConfigs() { try { Map<String, Map<String, Object>> config = helium.getAllPackageConfig(); - return new JsonResponse(Response.Status.OK, config).build(); + return new JsonResponse<>(Response.Status.OK, config).build(); } catch (RuntimeException e) { logger.error(e.getMessage(), e); return new JsonResponse(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage()).build(); @@ -265,7 +289,7 @@ public class HeliumRestApi { "Failed to find package for " + artifact).build(); } - return new JsonResponse(Response.Status.OK, config).build(); + return new JsonResponse<>(Response.Status.OK, config).build(); } catch (RuntimeException e) { logger.error(e.getMessage(), e); return new JsonResponse(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage()).build(); @@ -284,12 +308,11 @@ public class HeliumRestApi { ).build(); } - Map<String, Object> packageConfig = null; - try { - packageConfig = gson.fromJson( + Map<String, Object> packageConfig = gson.fromJson( rawConfig, new TypeToken<Map<String, Object>>(){}.getType()); helium.updatePackageConfig(artifact, packageConfig); + return new JsonResponse<>(Response.Status.OK, packageConfig).build(); } catch (JsonParseException e) { logger.error(e.getMessage(), e); return new JsonResponse(Response.Status.BAD_REQUEST, @@ -298,15 +321,18 @@ public class HeliumRestApi { return new JsonResponse(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage()).build(); } - - return new JsonResponse(Response.Status.OK, packageConfig).build(); } @GET @Path("order/visualization") public Response getVisualizationPackageOrder() { - List<String> order = helium.getVisualizationPackageOrder(); - return new JsonResponse(Response.Status.OK, order).build(); + try { + List<String> order = helium.getVisualizationPackageOrder(); + return new JsonResponse<>(Response.Status.OK, order).build(); + } catch (RuntimeException e) { + logger.error(e.getMessage(), e); + return new JsonResponse(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage()).build(); + } } @POST @@ -314,13 +340,12 @@ public class HeliumRestApi { public Response setVisualizationPackageOrder(String orderedPackageNameList) { List<String> orderedList = gson.fromJson( orderedPackageNameList, new TypeToken<List<String>>(){}.getType()); - try { helium.setVisualizationPackageOrder(orderedList); + return new JsonResponse(Response.Status.OK).build(); } catch (IOException e) { logger.error(e.getMessage(), e); return new JsonResponse(Response.Status.INTERNAL_SERVER_ERROR, e.getMessage()).build(); } - return new JsonResponse(Response.Status.OK).build(); } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e1f20ddd/zeppelin-server/src/test/java/org/apache/zeppelin/rest/HeliumRestApiTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/HeliumRestApiTest.java b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/HeliumRestApiTest.java new file mode 100644 index 0000000..f63f207 --- /dev/null +++ b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/HeliumRestApiTest.java @@ -0,0 +1,223 @@ +/* + * 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.rest; + +import com.google.gson.Gson; +import com.google.gson.internal.StringMap; +import com.google.gson.reflect.TypeToken; +import org.apache.commons.httpclient.methods.GetMethod; +import org.apache.commons.httpclient.methods.PostMethod; +import org.apache.zeppelin.helium.*; +import org.apache.zeppelin.server.ZeppelinServer; +import org.junit.*; + +import java.io.IOException; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static org.junit.Assert.*; + +public class HeliumRestApiTest extends AbstractTestRestApi { + Gson gson = new Gson(); + + @BeforeClass + public static void init() throws Exception { + AbstractTestRestApi.startUp(); + } + + @AfterClass + public static void destroy() throws Exception { + AbstractTestRestApi.shutDown(); + } + + @Before + public void setUp() throws IOException { + HeliumTestRegistry registry = new HeliumTestRegistry("r1", "r1"); + ZeppelinServer.helium.clear(); + ZeppelinServer.helium.addRegistry(registry); + + registry.add(new HeliumPackage( + HeliumType.APPLICATION, + "name1", + "desc1", + "artifact1", + "className1", + new String[][]{}, + "", + "")); + + registry.add(new HeliumPackage( + HeliumType.APPLICATION, + "name2", + "desc2", + "artifact2", + "className2", + new String[][]{}, + "", + "")); + } + + @After + public void tearDown() throws Exception { + ZeppelinServer.helium.clear(); + } + + @Test + public void testGetAllPackageInfo() throws IOException { + GetMethod get = httpGet("/helium/package"); + assertThat(get, isAllowed()); + Map<String, Object> resp = gson.fromJson(get.getResponseBodyAsString(), + new TypeToken<Map<String, Object>>() { }.getType()); + Map<String, Set<String>> body = (Map<String, Set<String>>) resp.get("body"); + + assertEquals(body.size(), 2); + assertTrue(body.containsKey("name1")); + assertTrue(body.containsKey("name2")); + } + + @Test + public void testGetAllEnabledPackageInfo() throws IOException { + // No enabled packages initially + GetMethod get1 = httpGet("/helium/enabledPackage"); + assertThat(get1, isAllowed()); + Map<String, Object> resp1 = gson.fromJson(get1.getResponseBodyAsString(), + new TypeToken<Map<String, Object>>() { }.getType()); + List<StringMap<Object>> body1 = (List<StringMap<Object>>) resp1.get("body"); + assertEquals(body1.size(), 0); + + // Enable "name1" package + ZeppelinServer.helium.enable("name1","artifact1"); + + GetMethod get2 = httpGet("/helium/enabledPackage"); + assertThat(get2, isAllowed()); + Map<String, Object> resp2 = gson.fromJson(get2.getResponseBodyAsString(), + new TypeToken<Map<String, Object>>() { }.getType()); + List<StringMap<Object>> body2 = (List<StringMap<Object>>) resp2.get("body"); + + assertEquals(body2.size(), 1); + StringMap<Object> pkg = (StringMap<Object>) body2.get(0).get("pkg"); + assertEquals(pkg.get("name"), "name1"); + } + + @Test + public void testGetSinglePackageInfo() throws IOException { + String packageName = "name1"; + GetMethod get = httpGet("/helium/package/" + packageName); + assertThat(get, isAllowed()); + Map<String, Object> resp = gson.fromJson(get.getResponseBodyAsString(), + new TypeToken<Map<String, Object>>() { }.getType()); + List<StringMap<Object>> body = (List<StringMap<Object>>) resp.get("body"); + + assertEquals(body.size(), 1); + StringMap<Object> pkg = (StringMap<Object>) body.get(0).get("pkg"); + assertEquals(pkg.get("name"), "name1"); + } + + @Test + public void testGetAllPackageConfigs() throws IOException { + GetMethod get = httpGet("/helium/config/"); + assertThat(get, isAllowed()); + Map<String, Object> resp = gson.fromJson(get.getResponseBodyAsString(), + new TypeToken<Map<String, Object>>() { }.getType()); + StringMap<Object> body = (StringMap<Object>) resp.get("body"); + // ToDo: Apply config with POST command and check update + assertEquals(body.size(), 0); + } + + @Test + public void testGetPackageConfig() throws IOException { + String packageName = "name1"; + String artifact = "artifact1"; + GetMethod get = httpGet("/helium/config/" + packageName + "/" + artifact); + assertThat(get, isAllowed()); + Map<String, Object> resp = gson.fromJson(get.getResponseBodyAsString(), + new TypeToken<Map<String, Object>>() { }.getType()); + StringMap<Object> body = (StringMap<Object>) resp.get("body"); + assertTrue(body.containsKey("confPersisted")); + } + + @Test + public void testEnableDisablePackage() throws IOException { + String packageName = "name1"; + PostMethod post1 = httpPost("/helium/enable/" + packageName, ""); + assertThat(post1, isAllowed()); + post1.releaseConnection(); + + GetMethod get1 = httpGet("/helium/package/" + packageName); + Map<String, Object> resp1 = gson.fromJson(get1.getResponseBodyAsString(), + new TypeToken<Map<String, Object>>() { }.getType()); + List<StringMap<Object>> body1 = (List<StringMap<Object>>) resp1.get("body"); + assertEquals(body1.get(0).get("enabled"), true); + + PostMethod post2 = httpPost("/helium/disable/" + packageName, ""); + assertThat(post2, isAllowed()); + post2.releaseConnection(); + + GetMethod get2 = httpGet("/helium/package/" + packageName); + Map<String, Object> resp2 = gson.fromJson(get2.getResponseBodyAsString(), + new TypeToken<Map<String, Object>>() { }.getType()); + List<StringMap<Object>> body2 = (List<StringMap<Object>>) resp2.get("body"); + assertEquals(body2.get(0).get("enabled"), false); + } + + @Test + public void testVisualizationPackageOrder() throws IOException { + GetMethod get1 = httpGet("/helium/order/visualization"); + assertThat(get1, isAllowed()); + Map<String, Object> resp1 = gson.fromJson(get1.getResponseBodyAsString(), + new TypeToken<Map<String, Object>>() { }.getType()); + List<Object> body1 = (List<Object>) resp1.get("body"); + assertEquals(body1.size(), 0); + + //We assume allPackages list has been refreshed before sorting + ZeppelinServer.helium.getAllPackageInfo(); + + String postRequestJson = "[name2, name1]"; + PostMethod post = httpPost("/helium/order/visualization", postRequestJson); + assertThat(post, isAllowed()); + post.releaseConnection(); + + GetMethod get2 = httpGet("/helium/order/visualization"); + assertThat(get2, isAllowed()); + Map<String, Object> resp2 = gson.fromJson(get2.getResponseBodyAsString(), + new TypeToken<Map<String, Object>>() { }.getType()); + List<Object> body2 = (List<Object>) resp2.get("body"); + assertEquals(body2.size(), 2); + assertEquals(body2.get(0), "name2"); + assertEquals(body2.get(1), "name1"); + } +} + +class HeliumTestRegistry extends HeliumRegistry { + private List<HeliumPackage> infos = new LinkedList<>(); + + public HeliumTestRegistry(String name, String uri) { + super(name, uri); + } + + @Override + public List<HeliumPackage> getAll() throws IOException { + return infos; + } + + public void add(HeliumPackage info) { + infos.add(info); + } +} http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e1f20ddd/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/Helium.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/Helium.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/Helium.java index 2b9e320..17a3529 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/Helium.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/Helium.java @@ -16,11 +16,8 @@ */ package org.apache.zeppelin.helium; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.zeppelin.common.JsonSerializable; import org.apache.zeppelin.interpreter.Interpreter; import org.apache.zeppelin.notebook.Paragraph; import org.apache.zeppelin.resource.DistributedResourcePool; @@ -38,10 +35,12 @@ import java.util.*; * Manages helium packages */ public class Helium { - Logger logger = LoggerFactory.getLogger(Helium.class); + private Logger logger = LoggerFactory.getLogger(Helium.class); private List<HeliumRegistry> registry = new LinkedList<>(); - private final HeliumConf heliumConf; + private HeliumConf heliumConf; + private Map<String, List<HeliumPackageSearchResult>> allPackages = new HashMap<>(); + private final String heliumConfPath; private final String registryPaths; private final File registryCacheDir; @@ -49,8 +48,6 @@ public class Helium { private final HeliumBundleFactory bundleFactory; private final HeliumApplicationFactory applicationFactory; - Map<String, List<HeliumPackageSearchResult>> allPackages; - public Helium( String heliumConfPath, String registryPaths, @@ -64,6 +61,7 @@ public class Helium { this.bundleFactory = bundleFactory; this.applicationFactory = applicationFactory; heliumConf = loadConf(heliumConfPath); + allPackages = getAllPackageInfo(); } /** @@ -77,24 +75,16 @@ public class Helium { } } - public List<HeliumRegistry> getAllRegistry() { - synchronized (this.registry) { - List list = new LinkedList<>(); - for (HeliumRegistry r : registry) { - list.add(r); - } - return list; - } + public void clear() { + this.registry.clear(); + this.heliumConf = new HeliumConf(); + this.allPackages = new HashMap<>(); } public HeliumApplicationFactory getApplicationFactory() { return applicationFactory; } - public HeliumBundleFactory getBundleFactory() { - return bundleFactory; - } - private synchronized HeliumConf loadConf(String path) throws IOException { // add registry if (registryPaths != null && !registryPaths.isEmpty()) { @@ -113,16 +103,14 @@ public class Helium { File heliumConfFile = new File(path); if (!heliumConfFile.isFile()) { logger.warn("{} does not exists", path); - HeliumConf conf = new HeliumConf(); - return conf; + return new HeliumConf(); } else { String jsonString = FileUtils.readFileToString(heliumConfFile); - HeliumConf conf = HeliumConf.fromJson(jsonString); - return conf; + return HeliumConf.fromJson(jsonString); } } - public synchronized void save() throws IOException { + public synchronized void saveConfig() throws IOException { String jsonString; synchronized (registry) { clearNotExistsPackages(); @@ -138,13 +126,11 @@ public class Helium { } private void clearNotExistsPackages() { - Map<String, List<HeliumPackageSearchResult>> all = getAllPackageInfoWithoutRefresh(); - // clear visualization display order List<String> packageOrder = heliumConf.getBundleDisplayOrder(); List<String> clearedOrder = new LinkedList<>(); for (String pkgName : packageOrder) { - if (all.containsKey(pkgName)) { + if (allPackages.containsKey(pkgName)) { clearedOrder.add(pkgName); } } @@ -153,16 +139,12 @@ public class Helium { // clear enabled package Map<String, String> enabledPackages = heliumConf.getEnabledPackages(); for (String pkgName : enabledPackages.keySet()) { - if (!all.containsKey(pkgName)) { + if (!allPackages.containsKey(pkgName)) { heliumConf.disablePackage(pkgName); } } } - public Map<String, List<HeliumPackageSearchResult>> getAllPackageInfoWithoutRefresh() { - return getAllPackageInfo(false, null); - } - public Map<String, List<HeliumPackageSearchResult>> getAllPackageInfo() { return getAllPackageInfo(true, null); } @@ -176,8 +158,7 @@ public class Helium { Map<String, String> enabledPackageInfo = heliumConf.getEnabledPackages(); synchronized (registry) { - if (refresh || allPackages == null) { - allPackages = new HashMap<>(); + if (refresh || !allPackages.containsKey(packageName)) { for (HeliumRegistry r : registry) { try { for (HeliumPackage pkg : r.getAll()) { @@ -188,12 +169,11 @@ public class Helium { continue; } - String artifact = enabledPackageInfo.get(name); - boolean enabled = (artifact != null && artifact.equals(pkg.getArtifact())); - - if (!allPackages.containsKey(name)) { - allPackages.put(name, new LinkedList<HeliumPackageSearchResult>()); + if (allPackages.containsKey(name)) { + allPackages.remove(name); } + allPackages.put(name, new LinkedList<HeliumPackageSearchResult>()); + boolean enabled = enabledPackageInfo.containsKey(pkg.getName()); allPackages.get(name).add(new HeliumPackageSearchResult(r.name(), pkg, enabled)); } } catch (IOException e) { @@ -208,12 +188,10 @@ public class Helium { } List<HeliumPackageSearchResult> pkgs = allPackages.get(name); - String artifact = enabledPackageInfo.get(name); - LinkedList<HeliumPackageSearchResult> newResults = - new LinkedList<HeliumPackageSearchResult>(); + LinkedList<HeliumPackageSearchResult> newResults = new LinkedList<>(); for (HeliumPackageSearchResult pkg : pkgs) { - boolean enabled = (artifact != null && artifact.equals(pkg.getPkg().getArtifact())); + boolean enabled = enabledPackageInfo.containsKey(pkg.getPkg().getName()); newResults.add(new HeliumPackageSearchResult(pkg.getRegistry(), pkg.getPkg(), enabled)); } @@ -236,34 +214,31 @@ public class Helium { } public List<HeliumPackageSearchResult> getAllEnabledPackages() { - Map<String, List<HeliumPackageSearchResult>> allPackages = getAllPackageInfoWithoutRefresh(); + Map<String, String> enabledInfo = heliumConf.getEnabledPackages(); List<HeliumPackageSearchResult> enabledPackages = new ArrayList<>(); for (List<HeliumPackageSearchResult> versionedPackages : allPackages.values()) { for (HeliumPackageSearchResult psr : versionedPackages) { - if (psr.isEnabled()) { + if (enabledInfo.containsKey(psr.getPkg().getName())) { enabledPackages.add(psr); break; } } } - return enabledPackages; } public List<HeliumPackageSearchResult> getSinglePackageInfo(String packageName) { - Map<String, List<HeliumPackageSearchResult>> result = getAllPackageInfo(false, packageName); + Map<String, List<HeliumPackageSearchResult>> result = getAllPackageInfo(true, packageName); if (!result.containsKey(packageName)) { return new ArrayList<>(); } - return result.get(packageName); } - public HeliumPackageSearchResult getEnabledPackageInfo(String packageName) { - Map<String, List<HeliumPackageSearchResult>> infos = getAllPackageInfoWithoutRefresh(); - List<HeliumPackageSearchResult> packages = infos.get(packageName); + private HeliumPackageSearchResult getEnabledPackageInfo(String packageName) { + List<HeliumPackageSearchResult> packages = allPackages.get(packageName); for (HeliumPackageSearchResult pkgSearchResult : packages) { if (pkgSearchResult.isEnabled()) { @@ -274,10 +249,10 @@ public class Helium { return null; } - public HeliumPackageSearchResult getPackageInfo(String pkgName, String artifact) { + private HeliumPackageSearchResult getPackageInfo(String pkgName, String artifact) { Map<String, List<HeliumPackageSearchResult>> infos = getAllPackageInfo(false, pkgName); List<HeliumPackageSearchResult> packages = infos.get(pkgName); - if (artifact == null) { + if (StringUtils.isBlank(artifact)) { return packages.get(0); /** return the FIRST package */ } else { for (HeliumPackageSearchResult pkg : packages) { @@ -286,7 +261,6 @@ public class Helium { } } } - return null; } @@ -294,12 +268,12 @@ public class Helium { return bundleFactory.buildPackage(pkg, rebuild, true); } - public void enable(String name, String artifact) throws IOException { + public boolean enable(String name, String artifact) throws IOException { HeliumPackageSearchResult pkgInfo = getPackageInfo(name, artifact); - // no package found. if (pkgInfo == null) { - return; + logger.info("Package {} not found", name); + return false; } // if package is bundle, rebuild bundle @@ -317,17 +291,19 @@ public class Helium { } } - save(); + saveConfig(); + return true; } - public void disable(String name) throws IOException { - String artifact = heliumConf.getEnabledPackages().get(name); + public boolean disable(String name) throws IOException { + String pkg = heliumConf.getEnabledPackages().get(name); - if (artifact == null) { - return; + if (pkg == null) { + logger.info("Package {} not found", name); + return false; } - HeliumPackageSearchResult pkgInfo = getPackageInfo(name, artifact); + HeliumPackageSearchResult pkgInfo = getPackageInfo(name, pkg); // set `enable` field heliumConf.disablePackage(name); @@ -337,21 +313,22 @@ public class Helium { currentDisplayOrder.remove(name); } } - save(); + saveConfig(); + return true; } public void updatePackageConfig(String artifact, Map<String, Object> pkgConfig) throws IOException { heliumConf.updatePackageConfig(artifact, pkgConfig); - save(); + saveConfig(); } public Map<String, Map<String, Object>> getAllPackageConfig() { return heliumConf.getAllPackageConfigs(); } - public Map<String, Object> getPackagePersistedConfig(String artifact) { + private Map<String, Object> getPackagePersistedConfig(String artifact) { return heliumConf.getPackagePersistedConfig(artifact); } @@ -376,7 +353,7 @@ public class Helium { allResources = ResourcePoolUtils.getAllResources(); } - for (List<HeliumPackageSearchResult> pkgs : getAllPackageInfoWithoutRefresh().values()) { + for (List<HeliumPackageSearchResult> pkgs : allPackages.values()) { for (HeliumPackageSearchResult pkg : pkgs) { if (pkg.getPkg().getType() == HeliumType.APPLICATION && pkg.isEnabled()) { ResourceSet resources = ApplicationLoader.findRequiredResourceSet( @@ -404,10 +381,10 @@ public class Helium { * @return ordered list of enabled buildBundle package */ public List<HeliumPackage> getBundlePackagesToBundle() { - Map<String, List<HeliumPackageSearchResult>> allPackages = getAllPackageInfoWithoutRefresh(); List<String> visOrder = heliumConf.getBundleDisplayOrder(); - List<HeliumPackage> orderedBundlePackages = new LinkedList<>(); + Set<HeliumPackage> orderedBundlePackages = new HashSet<>(); + List<HeliumPackage> output = new LinkedList<>(); // add enabled packages in visOrder for (String name : visOrder) { @@ -418,7 +395,6 @@ public class Helium { for (HeliumPackageSearchResult pkgInfo : versions) { if (canBundle(pkgInfo)) { orderedBundlePackages.add(pkgInfo.getPkg()); - allPackages.remove(name); break; } } @@ -433,11 +409,11 @@ public class Helium { } } } - - return orderedBundlePackages; + new LinkedList<>().addAll(orderedBundlePackages); + return output; } - public boolean canBundle(HeliumPackageSearchResult pkgInfo) { + private boolean canBundle(HeliumPackageSearchResult pkgInfo) { return (pkgInfo.isEnabled() && HeliumPackage.isBundleType(pkgInfo.getPkg().getType())); } @@ -453,7 +429,7 @@ public class Helium { public void setVisualizationPackageOrder(List<String> orderedPackageList) throws IOException { heliumConf.setBundleDisplayOrder(orderedPackageList); - save(); + saveConfig(); } /** @@ -494,7 +470,7 @@ public class Helium { return createMixedConfig(configPersisted, configSpec); } - public static Map<String, Map<String, Object>> createMixedConfig(Map<String, Object> persisted, + private static Map<String, Map<String, Object>> createMixedConfig(Map<String, Object> persisted, Map<String, Object> spec) { Map<String, Map<String, Object>> mixed = new HashMap<>(); mixed.put("confPersisted", persisted); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e1f20ddd/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumBundleFactory.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumBundleFactory.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumBundleFactory.java index 1ab14ba..3b5aa3b 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumBundleFactory.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumBundleFactory.java @@ -402,7 +402,7 @@ public class HeliumBundleFactory { String[] moduleNameVersion = getNpmModuleNameAndVersion(pkg); if (moduleNameVersion == null) { - logger.error("Can't get module name and version of package " + pkg.getName()); + logger.warn("Can't get module name and version of package " + pkg.getName()); return null; } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e1f20ddd/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumConf.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumConf.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumConf.java index 80d5356..c7fec86 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumConf.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumConf.java @@ -47,10 +47,6 @@ public class HeliumConf implements JsonSerializable { return new HashMap<>(enabled); } - public void enablePackage(HeliumPackage pkg) { - enablePackage(pkg.getName(), pkg.getArtifact()); - } - public void enablePackage(String name, String artifact) { enabled.put(name, artifact); } @@ -61,7 +57,6 @@ public class HeliumConf implements JsonSerializable { packageConfig.put(artifact, Collections.synchronizedMap(new HashMap<String, Object>())); } - packageConfig.put(artifact, newConfig); } @@ -91,7 +86,7 @@ public class HeliumConf implements JsonSerializable { public List<String> getBundleDisplayOrder() { if (bundleDisplayOrder == null) { - return new LinkedList<String>(); + return new LinkedList<>(); } else { return bundleDisplayOrder; } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e1f20ddd/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumLocalRegistry.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumLocalRegistry.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumLocalRegistry.java index dc4de44..7328dca 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumLocalRegistry.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumLocalRegistry.java @@ -25,7 +25,6 @@ import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; import java.io.StringReader; -import java.net.URI; import java.util.LinkedList; import java.util.List; @@ -33,7 +32,7 @@ import java.util.List; * Simple Helium registry on local filesystem */ public class HeliumLocalRegistry extends HeliumRegistry { - Logger logger = LoggerFactory.getLogger(HeliumLocalRegistry.class); + private Logger logger = LoggerFactory.getLogger(HeliumLocalRegistry.class); private final Gson gson; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e1f20ddd/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumOnlineRegistry.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumOnlineRegistry.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumOnlineRegistry.java index 1ea1982..3e511b2 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumOnlineRegistry.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/helium/HeliumOnlineRegistry.java @@ -51,7 +51,7 @@ import java.util.UUID; * ] */ public class HeliumOnlineRegistry extends HeliumRegistry { - Logger logger = LoggerFactory.getLogger(HeliumOnlineRegistry.class); + private Logger logger = LoggerFactory.getLogger(HeliumOnlineRegistry.class); private final Gson gson; private final File registryCacheFile; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e1f20ddd/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTest.java index 6c01974..6b4932d 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTest.java @@ -56,7 +56,7 @@ public class HeliumTest { assertFalse(heliumConf.exists()); // when - helium.save(); + helium.saveConfig(); // then assertTrue(heliumConf.exists()); @@ -101,7 +101,6 @@ public class HeliumTest { assertEquals(2, helium.getAllPackageInfo().size()); } - @Test public void testRefresh() throws IOException, URISyntaxException, TaskRunnerException { File heliumConf = new File(tmpDir, "helium.conf"); @@ -122,7 +121,7 @@ public class HeliumTest { "")); // then - assertEquals(1, helium.getAllPackageInfoWithoutRefresh().size()); + assertEquals(1, helium.getAllPackageInfo().size()); // when registry1.add(new HeliumPackage( @@ -136,7 +135,6 @@ public class HeliumTest { "")); // then - assertEquals(1, helium.getAllPackageInfoWithoutRefresh().size()); assertEquals(2, helium.getAllPackageInfo(true, null).size()); } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e1f20ddd/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTestApplication.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTestApplication.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTestApplication.java index 8b1d14f..2e66a3f 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTestApplication.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTestApplication.java @@ -22,7 +22,7 @@ import java.io.IOException; import java.util.concurrent.atomic.AtomicInteger; public class HeliumTestApplication extends Application { - AtomicInteger numRun = new AtomicInteger(0); + private AtomicInteger numRun = new AtomicInteger(0); public HeliumTestApplication(ApplicationContext context) { super(context); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e1f20ddd/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTestRegistry.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTestRegistry.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTestRegistry.java index 873ab27..a7b1538 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTestRegistry.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/helium/HeliumTestRegistry.java @@ -22,7 +22,7 @@ import java.util.LinkedList; import java.util.List; public class HeliumTestRegistry extends HeliumRegistry { - List<HeliumPackage> infos = new LinkedList<>(); + private List<HeliumPackage> infos = new LinkedList<>(); public HeliumTestRegistry(String name, String uri) { super(name, uri);