diff --git a/cassandra-storage/pom.xml b/cassandra-storage/pom.xml index c821f9aa69b..1e49a41e6af 100644 --- a/cassandra-storage/pom.xml +++ b/cassandra-storage/pom.xml @@ -53,4 +53,20 @@ test + + + + + maven-jar-plugin + + + + true + true + + + + + + diff --git a/common/pom.xml b/common/pom.xml index 24c37411ba3..47e7633c89d 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -168,7 +168,15 @@ - + + + + true + true + + + + diff --git a/examples/pom.xml b/examples/pom.xml index 30ee4e6f586..f4205d8e594 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -104,6 +104,14 @@ + + + + true + true + + + diff --git a/hdfs-storage/pom.xml b/hdfs-storage/pom.xml index 71da35eff72..32a24614d31 100644 --- a/hdfs-storage/pom.xml +++ b/hdfs-storage/pom.xml @@ -71,4 +71,20 @@ test + + + + + maven-jar-plugin + + + + true + true + + + + + + diff --git a/indexing-hadoop/pom.xml b/indexing-hadoop/pom.xml index 3dfb59c2824..d2964f84c26 100644 --- a/indexing-hadoop/pom.xml +++ b/indexing-hadoop/pom.xml @@ -101,6 +101,17 @@ + + maven-jar-plugin + + + + true + true + + + + maven-shade-plugin diff --git a/indexing-service/pom.xml b/indexing-service/pom.xml index 9b718e7e172..c5bb4042857 100644 --- a/indexing-service/pom.xml +++ b/indexing-service/pom.xml @@ -160,4 +160,20 @@ test + + + + + maven-jar-plugin + + + + true + true + + + + + + diff --git a/kafka-eight/pom.xml b/kafka-eight/pom.xml index c92048c47b3..aff29a6ec82 100644 --- a/kafka-eight/pom.xml +++ b/kafka-eight/pom.xml @@ -116,4 +116,20 @@ test + + + + + maven-jar-plugin + + + + true + true + + + + + + diff --git a/kafka-seven/pom.xml b/kafka-seven/pom.xml index cd5ef152864..0367a8e2712 100644 --- a/kafka-seven/pom.xml +++ b/kafka-seven/pom.xml @@ -55,4 +55,19 @@ test + + + + maven-jar-plugin + + + + true + true + + + + + + diff --git a/pom.xml b/pom.xml index e0dff689ffa..ebe0203823d 100644 --- a/pom.xml +++ b/pom.xml @@ -41,6 +41,7 @@ UTF-8 0.25.0 2.1.0-incubating + 0.1.3 @@ -65,7 +66,7 @@ io.druid druid-api - 0.1.3 + ${druid.api.version} diff --git a/processing/pom.xml b/processing/pom.xml index 4c40c9f5a50..14bf1b01d73 100644 --- a/processing/pom.xml +++ b/processing/pom.xml @@ -133,6 +133,14 @@ + + + + true + true + + + diff --git a/s3-extensions/pom.xml b/s3-extensions/pom.xml index ccc97398ad2..1b0f844136e 100644 --- a/s3-extensions/pom.xml +++ b/s3-extensions/pom.xml @@ -66,4 +66,19 @@ test + + + + maven-jar-plugin + + + + true + true + + + + + + diff --git a/server/pom.xml b/server/pom.xml index a85223056cc..8dd5037d3ae 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -220,8 +220,6 @@ caliper test - - @@ -235,6 +233,14 @@ + + + + true + true + + + org.antlr diff --git a/server/src/main/java/io/druid/server/StatusResource.java b/server/src/main/java/io/druid/server/StatusResource.java index a2b30268d4d..f2c01050496 100644 --- a/server/src/main/java/io/druid/server/StatusResource.java +++ b/server/src/main/java/io/druid/server/StatusResource.java @@ -20,10 +20,16 @@ package io.druid.server; import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.inject.Injector; +import io.druid.initialization.DruidModule; +import io.druid.initialization.Initialization; +import io.druid.server.initialization.ExtensionsConfig; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; +import java.util.ArrayList; +import java.util.List; /** */ @@ -33,20 +39,60 @@ public class StatusResource @GET @Produces("application/json") public Status doGet() + { + return getStatus(); + } + + public static Status getStatus() { return new Status( - StatusResource.class.getPackage().getImplementationVersion(), + Initialization.class.getPackage().getImplementationVersion(), + getExtensionVersions(), new Memory(Runtime.getRuntime()) ); } - public static class Status { + /** + * Load the unique extensions and return their implementation-versions + * + * @return map of extensions loaded with their respective implementation versions. + */ + private static List getExtensionVersions() + { + final Injector injector = Initialization.makeStartupInjector(); + final ExtensionsConfig config = injector.getInstance(ExtensionsConfig.class); + final List druidModules = Initialization.getFromExtensions(config, DruidModule.class); + + List moduleVersions = new ArrayList<>(); + for (DruidModule module : druidModules) { + + String artifact = module.getClass().getPackage().getImplementationTitle(); + String version = module.getClass().getPackage().getImplementationVersion(); + + ModuleVersion moduleVersion; + if (artifact != null) { + moduleVersion = new ModuleVersion(module.getClass().getCanonicalName(), artifact, version); + } else { + moduleVersion = new ModuleVersion(module.getClass().getCanonicalName()); + } + + moduleVersions.add(moduleVersion); + } + return moduleVersions; + } + + public static class Status + { final String version; + final List modules; final Memory memory; - public Status(String version, Memory memory) + public Status( + String version, List modules, Memory memory + ) { this.version = version; + this.modules = modules; this.memory = memory; } @@ -56,20 +102,94 @@ public class StatusResource return version; } + @JsonProperty + public List getModules() + { + return modules; + } + @JsonProperty public Memory getMemory() { return memory; } + + @Override + public String toString() + { + final String NL = "\n"; + 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(); + } } - public static class Memory { + public static class ModuleVersion + { + final String name; + final String artifact; + final String version; + + public ModuleVersion(String name) + { + this(name, "", ""); + } + + public ModuleVersion(String name, String artifact, String version) + { + this.name = name; + this.artifact = artifact; + this.version = version; + } + + @JsonProperty + public String getName() + { + return name; + } + + @JsonProperty + public String getArtifact() + { + return artifact; + } + + @JsonProperty + public String getVersion() + { + return version; + } + + @Override + public String toString() + { + if (artifact.isEmpty()) { + return String.format(" - %s ", name); + } else { + return String.format(" - %s (%s-%s)", name, artifact, version); + } + } + } + + public static class Memory + { final long maxMemory; final long totalMemory; final long freeMemory; final long usedMemory; - public Memory(Runtime runtime) { + public Memory(Runtime runtime) + { maxMemory = runtime.maxMemory(); totalMemory = runtime.totalMemory(); freeMemory = runtime.freeMemory(); @@ -99,5 +219,6 @@ public class StatusResource { return usedMemory; } + } } diff --git a/server/src/main/resources/static/index.html b/server/src/main/resources/static/index.html index cec3d620e88..fb8831e29ed 100644 --- a/server/src/main/resources/static/index.html +++ b/server/src/main/resources/static/index.html @@ -32,6 +32,9 @@
+
+

Druid Version: ${pom.version} Druid API Version: ${druid.api.version}

+
diff --git a/services/pom.xml b/services/pom.xml index 0dcad5375c3..77b12502d6f 100644 --- a/services/pom.xml +++ b/services/pom.xml @@ -51,8 +51,20 @@ ${project.parent.version} + + + maven-jar-plugin + + + + true + true + + + + org.apache.maven.plugins maven-shade-plugin diff --git a/services/src/main/java/io/druid/cli/Main.java b/services/src/main/java/io/druid/cli/Main.java index 551acea0706..7e9a633e8ed 100644 --- a/services/src/main/java/io/druid/cli/Main.java +++ b/services/src/main/java/io/druid/cli/Main.java @@ -27,6 +27,8 @@ import io.druid.cli.convert.ConvertProperties; import io.druid.cli.validate.DruidJsonValidator; import io.druid.initialization.Initialization; import io.druid.server.initialization.ExtensionsConfig; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; import java.util.List; @@ -41,7 +43,7 @@ public class Main builder.withDescription("Druid command-line runner.") .withDefaultCommand(Help.class) - .withCommands(Help.class); + .withCommands(Help.class, Version.class); builder.withGroup("server") .withDescription("Run one of the Druid server types.") diff --git a/services/src/main/java/io/druid/cli/Version.java b/services/src/main/java/io/druid/cli/Version.java new file mode 100644 index 00000000000..9212a3cb800 --- /dev/null +++ b/services/src/main/java/io/druid/cli/Version.java @@ -0,0 +1,36 @@ +/* + * Druid - a distributed column store. + * Copyright (C) 2012, 2013 Metamarkets Group Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package io.druid.cli; + +import io.airlift.command.Command; +import io.druid.server.StatusResource; + +@Command( + name = "version", + description = "Returns Druid version information" +) +public class Version implements Runnable +{ + @Override + public void run() + { + System.out.println(StatusResource.getStatus()); + } +}