mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Change HeliumRegistry constructor argument type
This commit is contained in:
parent
7aeb64addf
commit
134bbe640a
6 changed files with 14 additions and 19 deletions
|
|
@ -35,7 +35,7 @@ public class HeliumLocalRegistry extends HeliumRegistry {
|
|||
|
||||
private final Gson gson;
|
||||
|
||||
public HeliumLocalRegistry(String name, URI uri) {
|
||||
public HeliumLocalRegistry(String name, String uri) {
|
||||
super(name, uri);
|
||||
gson = new Gson();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,16 +25,16 @@ import java.util.List;
|
|||
*/
|
||||
public abstract class HeliumRegistry {
|
||||
private final String name;
|
||||
private final URI uri;
|
||||
private final String uri;
|
||||
|
||||
public HeliumRegistry(String name, URI uri) {
|
||||
public HeliumRegistry(String name, String uri) {
|
||||
this.name = name;
|
||||
this.uri = uri;
|
||||
}
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
public URI uri() {
|
||||
public String uri() {
|
||||
return uri;
|
||||
}
|
||||
public abstract List<HeliumPackage> getAll() throws IOException;
|
||||
|
|
|
|||
|
|
@ -40,19 +40,14 @@ public class HeliumRegistrySerializer
|
|||
throws JsonParseException {
|
||||
JsonObject jsonObject = json.getAsJsonObject();
|
||||
String className = jsonObject.get("class").getAsString();
|
||||
URI uri = null;
|
||||
try {
|
||||
uri = new URI(jsonObject.get("uri").getAsString());
|
||||
} catch (URISyntaxException e) {
|
||||
new JsonParseException(e);
|
||||
}
|
||||
String uri = jsonObject.get("uri").getAsString();
|
||||
String name = jsonObject.get("name").getAsString();
|
||||
|
||||
try {
|
||||
logger.info("Restore helium registry {} {} {}", name, className, uri);
|
||||
Class<HeliumRegistry> cls =
|
||||
(Class<HeliumRegistry>) getClass().getClassLoader().loadClass(className);
|
||||
Constructor<HeliumRegistry> constructor = cls.getConstructor(String.class, URI.class);
|
||||
Constructor<HeliumRegistry> constructor = cls.getConstructor(String.class, String.class);
|
||||
HeliumRegistry registry = constructor.newInstance(name, uri);
|
||||
return registry;
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException |
|
||||
|
|
@ -68,7 +63,7 @@ public class HeliumRegistrySerializer
|
|||
JsonSerializationContext jsonSerializationContext) {
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("class", heliumRegistry.getClass().getName());
|
||||
json.addProperty("uri", heliumRegistry.uri().toString());
|
||||
json.addProperty("uri", heliumRegistry.uri());
|
||||
json.addProperty("name", heliumRegistry.name());
|
||||
return json;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class HeliumLocalRegistryTest {
|
|||
public void testGetAllPackage() throws IOException {
|
||||
// given
|
||||
File r1Path = new File(tmpDir, "r1");
|
||||
HeliumLocalRegistry r1 = new HeliumLocalRegistry("r1", r1Path.toURI());
|
||||
HeliumLocalRegistry r1 = new HeliumLocalRegistry("r1", r1Path.getAbsolutePath());
|
||||
assertEquals(0, r1.getAll().size());
|
||||
|
||||
// when
|
||||
|
|
|
|||
|
|
@ -50,9 +50,9 @@ public class HeliumTest {
|
|||
File heliumConf = new File(tmpDir, "helium.conf");
|
||||
Helium helium = new Helium(heliumConf.getAbsolutePath());
|
||||
assertFalse(heliumConf.exists());
|
||||
HeliumTestRegistry registry1 = new HeliumTestRegistry("r1", new URI("file:///r1"));
|
||||
HeliumTestRegistry registry1 = new HeliumTestRegistry("r1", "r1");
|
||||
helium.addRegistry(registry1);
|
||||
assertEquals(1, helium.getAllRegistry().size());
|
||||
assertEquals(2, helium.getAllRegistry().size());
|
||||
assertEquals(0, helium.getAllPackageInfo().size());
|
||||
|
||||
// when
|
||||
|
|
@ -63,15 +63,15 @@ public class HeliumTest {
|
|||
|
||||
// then
|
||||
Helium heliumRestored = new Helium(heliumConf.getAbsolutePath());
|
||||
assertEquals(1, heliumRestored.getAllRegistry().size());
|
||||
assertEquals(2, heliumRestored.getAllRegistry().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRestoreRegistryInstances() throws IOException, URISyntaxException {
|
||||
File heliumConf = new File(tmpDir, "helium.conf");
|
||||
Helium helium = new Helium(heliumConf.getAbsolutePath());
|
||||
HeliumTestRegistry registry1 = new HeliumTestRegistry("r1", new URI("file:///r1"));
|
||||
HeliumTestRegistry registry2 = new HeliumTestRegistry("r2", new URI("file:///r2"));
|
||||
HeliumTestRegistry registry1 = new HeliumTestRegistry("r1", "r1");
|
||||
HeliumTestRegistry registry2 = new HeliumTestRegistry("r2", "r2");
|
||||
helium.addRegistry(registry1);
|
||||
helium.addRegistry(registry2);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import java.util.List;
|
|||
public class HeliumTestRegistry extends HeliumRegistry {
|
||||
List<HeliumPackage> infos = new LinkedList<HeliumPackage>();
|
||||
|
||||
public HeliumTestRegistry(String name, URI uri) {
|
||||
public HeliumTestRegistry(String name, String uri) {
|
||||
super(name, uri);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue