public static void main(String[] args) throws Throwable { Utils.setTimeDriftThreshold(TIME_DRIFT_THRESHOLD_MICROS); ManagementHost h = new ManagementHost(); h.initializeHostAndServices(args); Runtime.getRuntime().addShutdownHook(new Thread(() -> { h.log(Level.WARNING, "Host stopping ..."); h.stop(); h.log(Level.WARNING, "Host is stopped"); })); }
@AfterClass public static void tearDown() { if (host == null) { return; } host.stop(); sandbox.delete(); }
protected void stopHost(ManagementHost host) { if (host == null) { return; } String hostname = host.getUri().toString(); System.out.println("Stopping host '" + hostname + "'..."); try { ServiceRequestListener secureListener = host.getSecureListener(); host.stop(); secureListener.stop(); waitWhilePortIsListening(secureListener.getPort()); System.out.println("Host '" + hostname + "' stopped."); } catch (Exception e) { throw new RuntimeException("Exception stopping host!", e); } }
@After public void tearDown() throws Throwable { if (host != null && host.getStorageSandbox() != null) { host.stop(); } SANDBOX.delete(); }
static ManagementHost createManagementHost(String[] args) throws Throwable { ManagementHost h = new ManagementHost(); h.initialize(args); h.registerOperationInterceptors(); h.start(); h.setAuthorizationContext(h.getSystemAuthorizationContext()); h.log(Level.INFO, "**** Management host starting ... ****"); h.startFabricServices(); h.startManagementServices(); waitForDefaultRegistryCreated(h); h.log(Level.INFO, "**** Management host started. ****"); h.setAuthorizationContext(null); Runtime.getRuntime().addShutdownHook(new Thread(() -> { h.log(Level.WARNING, "Host stopping ..."); h.stop(); h.log(Level.WARNING, "Host is stopped"); })); return h; }