mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
[ZEPPELIN-2699] Changes after code review
This commit is contained in:
parent
a71b9fb998
commit
2b1ff8ae82
2 changed files with 13 additions and 10 deletions
|
|
@ -17,13 +17,13 @@
|
|||
|
||||
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.apache.zeppelin.user.AuthenticationInfo;
|
||||
import org.junit.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -35,6 +35,8 @@ 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();
|
||||
|
|
@ -185,6 +187,9 @@ public class HeliumRestApiTest extends AbstractTestRestApi {
|
|||
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());
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ 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 HeliumConf heliumConf;
|
||||
|
|
@ -117,12 +117,10 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -142,7 +140,7 @@ public class Helium {
|
|||
}
|
||||
|
||||
private void clearNotExistsPackages() {
|
||||
Map<String, List<HeliumPackageSearchResult>> all = getAllPackageInfo();
|
||||
Map<String, List<HeliumPackageSearchResult>> all = getAllPackageInfoWithoutRefresh();
|
||||
|
||||
// clear visualization display order
|
||||
List<String> packageOrder = heliumConf.getBundleDisplayOrder();
|
||||
|
|
@ -236,7 +234,7 @@ public class Helium {
|
|||
}
|
||||
|
||||
public List<HeliumPackageSearchResult> getAllEnabledPackages() {
|
||||
Map<String, List<HeliumPackageSearchResult>> allPackages = getAllPackageInfo();
|
||||
Map<String, List<HeliumPackageSearchResult>> allPackages = getAllPackageInfoWithoutRefresh();
|
||||
List<HeliumPackageSearchResult> enabledPackages = new ArrayList<>();
|
||||
|
||||
for (List<HeliumPackageSearchResult> versionedPackages : allPackages.values()) {
|
||||
|
|
@ -261,7 +259,7 @@ public class Helium {
|
|||
}
|
||||
|
||||
private HeliumPackageSearchResult getEnabledPackageInfo(String packageName) {
|
||||
Map<String, List<HeliumPackageSearchResult>> infos = getAllPackageInfo();
|
||||
Map<String, List<HeliumPackageSearchResult>> infos = getAllPackageInfoWithoutRefresh();
|
||||
List<HeliumPackageSearchResult> packages = infos.get(packageName);
|
||||
|
||||
for (HeliumPackageSearchResult pkgSearchResult : packages) {
|
||||
|
|
@ -377,7 +375,7 @@ public class Helium {
|
|||
allResources = ResourcePoolUtils.getAllResources();
|
||||
}
|
||||
|
||||
for (List<HeliumPackageSearchResult> pkgs : getAllPackageInfo().values()) {
|
||||
for (List<HeliumPackageSearchResult> pkgs : getAllPackageInfoWithoutRefresh().values()) {
|
||||
for (HeliumPackageSearchResult pkg : pkgs) {
|
||||
if (pkg.getPkg().getType() == HeliumType.APPLICATION && pkg.isEnabled()) {
|
||||
ResourceSet resources = ApplicationLoader.findRequiredResourceSet(
|
||||
|
|
|
|||
Loading…
Reference in a new issue