mirror of https://github.com/apache/druid.git
Do not load extensions on each call
This commit is contained in:
parent
aef7726c33
commit
65facc935d
|
@ -101,6 +101,16 @@ public class Initialization
|
||||||
"io.druid",
|
"io.druid",
|
||||||
"com.metamx.druid"
|
"com.metamx.druid"
|
||||||
);
|
);
|
||||||
|
private static List loadedDruidModules = Lists.newArrayList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return List of {@link DruidModule}, once loaded.
|
||||||
|
*/
|
||||||
|
public static List getLoadedDruidModules()
|
||||||
|
{
|
||||||
|
return loadedDruidModules;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public synchronized static <T> List<T> getFromExtensions(ExtensionsConfig config, Class<T> clazz)
|
public synchronized static <T> List<T> getFromExtensions(ExtensionsConfig config, Class<T> clazz)
|
||||||
{
|
{
|
||||||
|
@ -131,6 +141,10 @@ public class Initialization
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (clazz.equals(DruidModule.class)){
|
||||||
|
loadedDruidModules.addAll(retVal);
|
||||||
|
}
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,12 +19,16 @@
|
||||||
|
|
||||||
package io.druid.server;
|
package io.druid.server;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import io.druid.initialization.DruidModule;
|
||||||
import io.druid.initialization.Initialization;
|
import io.druid.initialization.Initialization;
|
||||||
|
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
|
@ -42,20 +46,42 @@ public class StatusResource
|
||||||
{
|
{
|
||||||
return new Status(
|
return new Status(
|
||||||
Initialization.class.getPackage().getImplementationVersion(),
|
Initialization.class.getPackage().getImplementationVersion(),
|
||||||
|
getExtensionVersions(),
|
||||||
new Memory(Runtime.getRuntime())
|
new Memory(Runtime.getRuntime())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the unique extensions and return their implementation-versions
|
||||||
|
*
|
||||||
|
* @return map of extensions loaded with their respective implementation versions.
|
||||||
|
*/
|
||||||
|
private static List<ModuleVersion> getExtensionVersions()
|
||||||
|
{
|
||||||
|
final List<DruidModule> druidModules = Initialization.getLoadedDruidModules();
|
||||||
|
|
||||||
|
List<ModuleVersion> moduleVersions = new ArrayList<>();
|
||||||
|
for (DruidModule module : druidModules) {
|
||||||
|
String artifact = module.getClass().getPackage().getImplementationTitle();
|
||||||
|
String version = module.getClass().getPackage().getImplementationVersion();
|
||||||
|
|
||||||
|
moduleVersions.add(new ModuleVersion(module.getClass().getCanonicalName(), artifact, version));
|
||||||
|
}
|
||||||
|
return moduleVersions;
|
||||||
|
}
|
||||||
|
|
||||||
public static class Status
|
public static class Status
|
||||||
{
|
{
|
||||||
final String version;
|
final String version;
|
||||||
|
final List<ModuleVersion> modules;
|
||||||
final Memory memory;
|
final Memory memory;
|
||||||
|
|
||||||
public Status(
|
public Status(
|
||||||
String version, Memory memory
|
String version, List<ModuleVersion> modules, Memory memory
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.version = version;
|
this.version = version;
|
||||||
|
this.modules = modules;
|
||||||
this.memory = memory;
|
this.memory = memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +91,12 @@ public class StatusResource
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonProperty
|
||||||
|
public List<ModuleVersion> getModules()
|
||||||
|
{
|
||||||
|
return modules;
|
||||||
|
}
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
public Memory getMemory()
|
public Memory getMemory()
|
||||||
{
|
{
|
||||||
|
@ -75,21 +107,29 @@ public class StatusResource
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
final String NL = System.getProperty("line.separator");
|
final String NL = System.getProperty("line.separator");
|
||||||
return String.format("Druid version - %s", version) + NL;
|
StringBuilder output = new StringBuilder();
|
||||||
|
output.append(String.format("Druid version - %s", version)).append(NL).append(NL);
|
||||||
|
|
||||||
|
if (modules.size() > 0) {
|
||||||
|
output.append("Registered Druid Modules").append(NL);
|
||||||
|
} else {
|
||||||
|
output.append("No Druid Modules loaded !");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ModuleVersion moduleVersion : modules) {
|
||||||
|
output.append(moduleVersion).append(NL);
|
||||||
|
}
|
||||||
|
return output.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public static class ModuleVersion
|
public static class ModuleVersion
|
||||||
{
|
{
|
||||||
final String name;
|
final String name;
|
||||||
final String artifact;
|
final String artifact;
|
||||||
final String version;
|
final String version;
|
||||||
|
|
||||||
public ModuleVersion(String name)
|
|
||||||
{
|
|
||||||
this(name, "", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModuleVersion(String name, String artifact, String version)
|
public ModuleVersion(String name, String artifact, String version)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
Loading…
Reference in New Issue