Skip to content

Commit

Permalink
resolve node_name from configuration getter instead of named parame…
Browse files Browse the repository at this point in the history
…ter (#20524)
  • Loading branch information
moesterheld committed Sep 24, 2024
1 parent d25e952 commit c83e5a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.google.common.eventbus.EventBus;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import org.apache.commons.collections4.queue.CircularFifoQueue;
import org.apache.commons.exec.ExecuteException;
import org.apache.http.client.utils.URIBuilder;
Expand Down Expand Up @@ -119,7 +118,7 @@ public class OpensearchProcessImpl implements OpensearchProcess, ProcessListener
@Inject
OpensearchProcessImpl(DatanodeConfiguration datanodeConfiguration, final CustomCAX509TrustManager trustManager,
final Configuration configuration, final NodeService<DataNodeDto> nodeService,
ObjectMapper objectMapper, OpensearchStateMachine processState, @Named("node_name") String nodeName, NodeId nodeId, EventBus eventBus) {
ObjectMapper objectMapper, OpensearchStateMachine processState, NodeId nodeId, EventBus eventBus) {
this.datanodeConfiguration = datanodeConfiguration;
this.processState = processState;
this.stdout = new CircularFifoQueue<>(datanodeConfiguration.processLogsBufferSize());
Expand All @@ -128,7 +127,7 @@ public class OpensearchProcessImpl implements OpensearchProcess, ProcessListener
this.nodeService = nodeService;
this.configuration = configuration;
this.objectMapper = objectMapper;
this.nodeName = nodeName;
this.nodeName = configuration.getDatanodeNodeName();
this.nodeId = nodeId;
this.eventBus = eventBus;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.google.common.eventbus.EventBus;
import org.graylog.datanode.Configuration;
import org.graylog.datanode.configuration.DatanodeConfiguration;
import org.graylog.datanode.opensearch.statemachine.OpensearchEvent;
import org.graylog.datanode.opensearch.statemachine.OpensearchStateMachine;
import org.graylog.shaded.opensearch2.org.opensearch.action.admin.cluster.health.ClusterHealthResponse;
import org.graylog.shaded.opensearch2.org.opensearch.action.admin.cluster.settings.ClusterGetSettingsResponse;
Expand Down Expand Up @@ -83,8 +84,9 @@ public class OpensearchProcessImplTest {
@Before
public void setup() throws IOException {
when(datanodeConfiguration.processLogsBufferSize()).thenReturn(100);
when(configuration.getDatanodeNodeName()).thenReturn(nodeName);
this.opensearchProcess = spy(new OpensearchProcessImpl(datanodeConfiguration, trustmManager, configuration,
nodeService, objectMapper, processState, nodeName, nodeId, eventBus));
nodeService, objectMapper, processState, nodeId, eventBus));
when(opensearchProcess.restClient()).thenReturn(Optional.of(restClient));
when(restClient.cluster()).thenReturn(clusterClient);
}
Expand Down Expand Up @@ -128,7 +130,7 @@ public void testShutdownWhenRemovedSuccessfully() throws IOException {
final ScheduledExecutorService executor = mock(ScheduledExecutorService.class);
opensearchProcess.executorService = executor;
opensearchProcess.checkRemovalStatus();
verify(opensearchProcess).stop();
verify(processState).fire(OpensearchEvent.PROCESS_STOPPED);
verify(executor).shutdown();
}

Expand Down

0 comments on commit c83e5a0

Please sign in to comment.