@Test public void checkShutdown() throws Exception { List<Main> mm = new ArrayList<>(); for (int i = 0; i < 3; i++) { mm.add(createMain("node" + (i + 1), false)); } Main main = mm.get(0); PrivateKey myKey = TestKeys.privateKey(3); Client client = null; try { client = new Client(myKey, main.myInfo, null); } catch (Exception e) { System.out.println("prepareClient exception: " + e.toString()); } Contract testContract = new Contract(myKey); for (int i = 0; i < 10; i++) { Contract nc = new Contract(myKey); testContract.addNewItems(nc); } testContract.seal(); assertTrue(testContract.isOk()); Parcel parcel = createParcelWithFreshU(client, testContract, Do.listOf(myKey)); client.registerParcelWithState(parcel.pack(), 5000); System.out.println(">> before shutdown state: " + client.getState(parcel.getPayloadContract().getId())); System.out.println(">> before shutdown state: " + client.getState(parcel.getPayloadContract().getNew().get(0).getId())); main.shutdown(); Thread.sleep(8000); mm.remove(main); main = createMain("node1", false); mm.add(main); try { client = new Client(myKey, main.myInfo, null); } catch (Exception e) { System.out.println("prepareClient exception: " + e.toString()); } Thread.currentThread().sleep(8000); ItemResult itemResult = client.getState(parcel.getPayloadContract().getId()); ItemResult itemResult2 = client.getState(parcel.getPayloadContract().getNew().get(0).getId()); System.out.println(">> after shutdown state: " + itemResult + " and new " + itemResult2); while (itemResult.state.isPending()) { Thread.currentThread().sleep(500); itemResult = client.getState(parcel.getPayloadContract().getId()); System.out.println(">> wait result: " + itemResult); } itemResult2 = client.getState(parcel.getPayloadContract().getNew().get(0).getId()); assertEquals(ItemState.APPROVED, itemResult.state); assertEquals(ItemState.APPROVED, itemResult2.state); mm.forEach(x -> x.shutdown()); }
public void shutdown() { try { if (hookThread != null) Runtime.getRuntime().removeShutdownHook(hookThread); ledger.close(); log("shutting down"); network.shutdown(); clientHTTPServer.shutdown(); } catch (Exception e) { } synchronized (parser) { parser.notifyAll(); } try { logger.close(); } catch (Exception e) { e.printStackTrace(); } }
Main { public void shutdown() { try { if (hookThread != null) Runtime.getRuntime().removeShutdownHook(hookThread); ledger.close(); log("shutting down"); network.shutdown(); clientHTTPServer.shutdown(); } catch (Exception e) { } synchronized (parser) { parser.notifyAll(); } try { logger.close(); } catch (Exception e) { e.printStackTrace(); } } }
Main { public void shutdown() { try { if (hookThread != null) Runtime.getRuntime().removeShutdownHook(hookThread); ledger.close(); log("shutting down"); network.shutdown(); clientHTTPServer.shutdown(); } catch (Exception e) { } synchronized (parser) { parser.notifyAll(); } try { logger.close(); } catch (Exception e) { e.printStackTrace(); } } Main(String[] args); }
Main { public void shutdown() { try { if (hookThread != null) Runtime.getRuntime().removeShutdownHook(hookThread); ledger.close(); log("shutting down"); network.shutdown(); clientHTTPServer.shutdown(); } catch (Exception e) { } synchronized (parser) { parser.notifyAll(); } try { logger.close(); } catch (Exception e) { e.printStackTrace(); } } Main(String[] args); static void main(String[] args); void waitReady(); void shutdown(); void setVerboseLevel(int level); void setUDPVerboseLevel(int level); void restartUDPAdapter(); PublicKey getNodePublicKey(); }
Main { public void shutdown() { try { if (hookThread != null) Runtime.getRuntime().removeShutdownHook(hookThread); ledger.close(); log("shutting down"); network.shutdown(); clientHTTPServer.shutdown(); } catch (Exception e) { } synchronized (parser) { parser.notifyAll(); } try { logger.close(); } catch (Exception e) { e.printStackTrace(); } } Main(String[] args); static void main(String[] args); void waitReady(); void shutdown(); void setVerboseLevel(int level); void setUDPVerboseLevel(int level); void restartUDPAdapter(); PublicKey getNodePublicKey(); static final String NODE_VERSION; final Reporter reporter; final BufferedLogger logger; public NetConfig netConfig; public NetworkV2 network; final Config config; public NodeInfo myInfo; public Node node; public ItemCache cache; public ParcelCache parcelCache; public PaidOperationCache paidOperationCache; }