public SearchNodeHealthProvider(Props props, ClusterAppState clusterAppState, NetworkUtils networkUtils) { this(props, clusterAppState, networkUtils, new Clock()); }
@Override public void stop() { healthStateRefresher.stop(); stopExecutorService(executorService); }
public ClusterAppStateImpl(AppSettings settings, HazelcastMember hzMember, EsConnector esConnector) { this.hzMember = hzMember; // Get or create the replicated map operationalProcesses = (ReplicatedMap) hzMember.getReplicatedMap(OPERATIONAL_PROCESSES); operationalProcessListenerUUID = operationalProcesses.addEntryListener(new OperationalProcessListener()); nodeDisconnectedListenerUUID = hzMember.getCluster().addMembershipListener(new NodeDisconnectedListener()); if (ClusterSettings.isLocalElasticsearchEnabled(settings)) { this.healthStateSharing = new HealthStateSharingImpl(hzMember, new SearchNodeHealthProvider(settings.getProps(), this, NetworkUtilsImpl.INSTANCE)); this.healthStateSharing.start(); } this.esConnector = esConnector; }
@Test public void get_returns_started_from_System2_now_at_constructor_time() { Properties properties = new Properties(); long now = setRequiredPropertiesAndMocks(properties); SearchNodeHealthProvider underTest = new SearchNodeHealthProvider(new Props(properties), clusterAppState, networkUtils, clock); NodeHealth nodeHealth = underTest.get(); assertThat(nodeHealth.getDetails().getStartedAt()).isEqualTo(now); // change now when(clock.now()).thenReturn(now); NodeHealth newNodeHealth = underTest.get(); assertThat(newNodeHealth.getDetails().getStartedAt()).isEqualTo(now); }
SearchNodeHealthProvider(Props props, ClusterAppState clusterAppState, NetworkUtils networkUtils, Clock clock) { this.clusterAppState = clusterAppState; this.nodeDetails = NodeDetails.newNodeDetailsBuilder() .setType(NodeDetails.Type.SEARCH) .setName(props.nonNullValue(CLUSTER_NODE_NAME.getKey())) .setHost(getHost(props, networkUtils)) .setPort(Integer.valueOf(props.nonNullValue(CLUSTER_NODE_HZ_PORT.getKey()))) .setStartedAt(clock.now()) .build(); }
@Test public void get_returns_host_from_NetworkUtils_getHostname_if_property_is_not_set_at_constructor_time() { getReturnsHostFromNetworkUtils(null); }
@Test public void invokeAny2() throws InterruptedException, ExecutionException, TimeoutException { underTest.invokeAny(callables, timeout, SECONDS); verify(executorService).invokeAny(callables, timeout, SECONDS); }
@Test public void submit2() { underTest.submit(runnable); verify(executorService).submit(runnable); }
@Test public void shutdown() { underTest.shutdown(); verify(executorService).shutdown(); }
@Test public void schedule1() { underTest.schedule(callable, delay, SECONDS); verify(executorService).schedule(callable, delay, SECONDS); }
@Test public void isShutdown() { underTest.isShutdown(); verify(executorService).isShutdown(); }
@Test public void scheduleWithFixeddelay() { underTest.scheduleWithFixedDelay(runnable, initialDelay, delay, TimeUnit.SECONDS); verify(executorService).scheduleWithFixedDelay(runnable, initialDelay, delay, TimeUnit.SECONDS); }
@Test public void awaitTermination() throws InterruptedException { underTest.awaitTermination(timeout, TimeUnit.SECONDS); verify(executorService).awaitTermination(timeout, TimeUnit.SECONDS); }
@Test public void scheduleAtFixedRate() { underTest.scheduleAtFixedRate(runnable, initialDelay, period, SECONDS); verify(executorService).scheduleAtFixedRate(runnable, initialDelay, period, SECONDS); }
@Test public void shutdownNow() { underTest.shutdownNow(); verify(executorService).shutdownNow(); }
@Test public void invokeAll() throws InterruptedException { underTest.invokeAll(callables); verify(executorService).invokeAll(callables); }
@Test public void isTerminated() { underTest.isTerminated(); verify(executorService).isTerminated(); }
@Test public void get_returns_host_from_NetworkUtils_getHostname_if_property_is_empty_at_constructor_time() { getReturnsHostFromNetworkUtils(random.nextBoolean() ? "" : " "); }
@Test public void invokeAny() throws InterruptedException, ExecutionException { underTest.invokeAny(callables); verify(executorService).invokeAny(callables); }
@Test public void submit1() { underTest.submit(runnable, result); verify(executorService).submit(runnable, result); }