summaryrefslogtreecommitdiffstats
path: root/infra/minimal-distribution/src/main/java
diff options
context:
space:
mode:
authorMaros Marsalek <mmarsale@cisco.com>2016-08-12 13:51:56 +0200
committerMaros Marsalek <mmarsale@cisco.com>2016-08-19 12:49:56 +0200
commitdcd507eff53e7c0abd659da416aac91a7d29e3d3 (patch)
tree8e021d05538cb862527ed98c3e9d1f3e19fc4d8f /infra/minimal-distribution/src/main/java
parentd022ca8d078e1731435bf3e69a9a1ff85e7e0c63 (diff)
HONEYCOMB-137: Put minimal distribution into RPM
Change-Id: I163be0361f75a29aac569b019892433b12bfb0a6 Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'infra/minimal-distribution/src/main/java')
-rw-r--r--infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java75
1 files changed, 43 insertions, 32 deletions
diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java
index ff85cd2a7..6c63c213d 100644
--- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java
+++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java
@@ -17,10 +17,13 @@
package io.fd.honeycomb.infra.distro;
import com.google.common.collect.ImmutableList;
+import com.google.inject.ConfigurationException;
+import com.google.inject.CreationException;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.Module;
+import com.google.inject.ProvisionException;
import com.google.inject.name.Names;
import groovy.util.logging.Slf4j;
import io.fd.honeycomb.data.init.DataTreeInitializer;
@@ -68,49 +71,57 @@ public final class Main {
}
public static Injector init(final List<? extends Module> modules) {
- LOG.info("Starting honeycomb");
+ try {
+ LOG.info("Starting honeycomb");
- Injector injector = Guice.createInjector(modules);
- LOG.info("Honeycomb configuration: " + injector.getInstance(HoneycombConfiguration.class));
+ Injector injector = Guice.createInjector(modules);
+ LOG.info("Honeycomb configuration: " + injector.getInstance(HoneycombConfiguration.class));
- // Log all bindings
- injector.getAllBindings().entrySet().stream()
- .forEach(e -> LOG.trace("Component available under: {} is {}", e.getKey(), e.getValue()));
+ // Log all bindings
+ injector.getAllBindings().entrySet().stream()
+ .forEach(e -> LOG.trace("Component available under: {} is {}", e.getKey(), e.getValue()));
- final HoneycombConfiguration cfgAttributes = injector.getInstance(HoneycombConfiguration.class);
+ final HoneycombConfiguration cfgAttributes = injector.getInstance(HoneycombConfiguration.class);
- // Now get instances for all dependency roots
+ // Now get instances for all dependency roots
- LOG.info("Starting RESTCONF");
- injector.getInstance(RestConnector.class);
+ LOG.info("Starting RESTCONF");
+ injector.getInstance(RestConnector.class);
- LOG.info("Starting NETCONF");
- injector.getInstance(
- Key.get(NetconfOperationServiceFactory.class, Names.named("netconf-mapper-honeycomb")));
- injector.getInstance(
- Key.get(NetconfOperationServiceFactory.class, Names.named("netconf-mapper-notification")));
- injector.getInstance(
- Key.get(NetconfOperationServiceFactory.class, Names.named("netconf-mapper-monitoring")));
+ LOG.info("Starting NETCONF");
+ injector.getInstance(
+ Key.get(NetconfOperationServiceFactory.class, Names.named("netconf-mapper-honeycomb")));
+ injector.getInstance(
+ Key.get(NetconfOperationServiceFactory.class, Names.named("netconf-mapper-notification")));
+ injector.getInstance(
+ Key.get(NetconfOperationServiceFactory.class, Names.named("netconf-mapper-monitoring")));
- if (cfgAttributes.isNetconfTcpServerEnabled()) {
- injector.getInstance(NetconfTcpServerProvider.NetconfTcpServer.class);
- }
+ if (cfgAttributes.isNetconfTcpServerEnabled()) {
+ injector.getInstance(NetconfTcpServerProvider.NetconfTcpServer.class);
+ }
- injector.getInstance(NetconfSshServerProvider.NetconfSshServer.class);
- injector.getInstance(HoneycombNotification2NetconfProvider.HoneycombNotification2Netconf.class);
+ injector.getInstance(NetconfSshServerProvider.NetconfSshServer.class);
+ injector.getInstance(HoneycombNotification2NetconfProvider.HoneycombNotification2Netconf.class);
- LOG.info("Honeycomb started successfully!");
+ LOG.info("Honeycomb started successfully!");
- try {
- LOG.info("Initializing configuration");
- injector.getInstance(Key.get(InitializerRegistry.class, Names.named("honeycomb-initializer"))).initialize();
- LOG.info("Configuration initialized successfully");
- } catch (DataTreeInitializer.InitializeException e) {
- LOG.error("Unable to initialize configuration", e);
- }
+ try {
+ LOG.info("Initializing configuration");
+ injector.getInstance(Key.get(InitializerRegistry.class, Names.named("honeycomb-initializer"))).initialize();
+ LOG.info("Configuration initialized successfully");
+ } catch (DataTreeInitializer.InitializeException e) {
+ LOG.error("Unable to initialize configuration", e);
+ }
- LOG.info("Honeycomb started successfully!");
+ LOG.info("Honeycomb started successfully!");
- return injector;
+ return injector;
+ } catch (CreationException | ProvisionException | ConfigurationException e) {
+ LOG.error("Failed to initialize Honeycomb components", e);
+ throw e;
+ } catch (RuntimeException e) {
+ LOG.error("Unexpected initialization failure", e);
+ throw e;
+ }
}
}