private <T> T call(ActionClient<T> actionClient) { try (DefaultProcessCommands commands = DefaultProcessCommands.secondary(ipcSharedDir, COMPUTE_ENGINE.getIpcIndex())) { if (commands.isUp()) { return actionClient.call(commands.getHttpUrl() + "/" + actionClient.getPath()); } return actionClient.getDefault(); } catch (Exception e) { throw new IllegalStateException("Failed to call HTTP server of process " + COMPUTE_ENGINE, e); } }
@Test public void start_publishes_URL_in_IPC() { try (DefaultProcessCommands commands = DefaultProcessCommands.secondary(this.sharedDir, 1)) { assertThat(commands.getHttpUrl()).startsWith("http://127.0.0.1:"); } }
@Test public void secondary_does_not_clear_the_memory_space_of_the_specified_process_number() throws IOException { File dir = temp.newFolder(); try (DefaultProcessCommands commands = DefaultProcessCommands.main(dir, PROCESS_NUMBER)) { commands.setUp(); commands.setHttpUrl("bla"); commands.setOperational(); } try (DefaultProcessCommands commands = DefaultProcessCommands.secondary(dir, PROCESS_NUMBER)) { assertThat(commands.isUp()).isTrue(); assertThat(commands.getHttpUrl()).isEqualTo("bla"); assertThat(commands.isOperational()).isTrue(); } }
@Test public void main_clears_the_memory_space_of_the_specified_process_number() throws IOException { File dir = temp.newFolder(); try (DefaultProcessCommands commands = DefaultProcessCommands.main(dir, PROCESS_NUMBER)) { commands.setUp(); commands.setHttpUrl("bla"); commands.setOperational(); } try (DefaultProcessCommands commands = DefaultProcessCommands.main(dir, PROCESS_NUMBER)) { assertThat(commands.isUp()).isFalse(); assertThat(commands.getHttpUrl()).isEmpty(); assertThat(commands.isOperational()).isFalse(); } }
private <T> T call(ActionClient<T> actionClient) { try (DefaultProcessCommands commands = DefaultProcessCommands.secondary(ipcSharedDir, COMPUTE_ENGINE.getIpcIndex())) { if (commands.isUp()) { return actionClient.call(commands.getHttpUrl() + "/" + actionClient.getPath()); } return actionClient.getDefault(); } catch (Exception e) { throw new IllegalStateException("Failed to call HTTP server of process " + COMPUTE_ENGINE, e); } }