mirror of
https://github.com/Graylog2/graylog2-server.git
synced 2026-03-13 09:32:21 +08:00
Datanode: setting initial master nodes simplification (#16712)
* automatic initial manager nodes * fixing binding * removing unneccessary URI usage
This commit is contained in:
@@ -36,5 +36,5 @@ public interface OpensearchProcess extends ManagableProcess<OpensearchConfigurat
|
||||
List<String> stdErrLogs();
|
||||
|
||||
URI getOpensearchBaseUrl();
|
||||
URI getOpensearchClusterUrl();
|
||||
String getOpensearchClusterUrl();
|
||||
}
|
||||
|
||||
@@ -123,17 +123,9 @@ class OpensearchProcessImpl implements OpensearchProcess, ProcessListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getOpensearchClusterUrl() {
|
||||
final String baseUrl = opensearchConfiguration.map(OpensearchConfiguration::getClusterBaseUrl)
|
||||
.map(httpHost -> new URIBuilder()
|
||||
.setHost(httpHost.getHostName())
|
||||
.setPort(httpHost.getPort())
|
||||
.setScheme(httpHost.getSchemeName()).toString())
|
||||
.orElseGet( () -> {
|
||||
final var hostname = DatanodeConfigurationProvider.getNodesFromConfig(configuration.getDatanodeNodeName());
|
||||
return URI.create("http://" + hostname + ":" + configuration.getOpensearchTransportPort()).toString();
|
||||
});
|
||||
return URI.create(baseUrl);
|
||||
public String getOpensearchClusterUrl() {
|
||||
final var hostname = DatanodeConfigurationProvider.getNodesFromConfig(configuration.getDatanodeNodeName());
|
||||
return URI.create(hostname + ":" + configuration.getOpensearchTransportPort()).toString();
|
||||
}
|
||||
|
||||
public void onEvent(ProcessEvent event) {
|
||||
@@ -167,15 +159,7 @@ class OpensearchProcessImpl implements OpensearchProcess, ProcessListener {
|
||||
|
||||
private void writeSeedHostsList() {
|
||||
try {
|
||||
final Set<String> current = nodeService.allActive(Node.Type.DATANODE).values().stream().map(node -> {
|
||||
try {
|
||||
return new URI(node.getClusterAddress()).getAuthority();
|
||||
} catch (URISyntaxException ex) {
|
||||
LOG.warn("Could not get host:port from {}", node);
|
||||
return null;
|
||||
}
|
||||
}).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
|
||||
final Set<String> current = nodeService.allActive(Node.Type.DATANODE).values().stream().map(Node::getClusterAddress).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
Files.write(hostsfile, current, Charset.defaultCharset(), StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE);
|
||||
} catch (IOException iox) {
|
||||
LOG.error("Could not write to file: {} - {}", hostsfile, iox.getMessage());
|
||||
|
||||
@@ -36,7 +36,7 @@ public class NodePingPeriodical extends Periodical {
|
||||
private final NodeService nodeService;
|
||||
private final NodeId nodeId;
|
||||
private final Supplier<URI> opensearchBaseUri;
|
||||
private final Supplier<URI> opensearchClusterUri;
|
||||
private final Supplier<String> opensearchClusterUri;
|
||||
private final Supplier<Boolean> isLeader;
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ public class NodePingPeriodical extends Periodical {
|
||||
NodeService nodeService,
|
||||
NodeId nodeId,
|
||||
Supplier<URI> opensearchBaseUri,
|
||||
Supplier<URI> opensearchClusterUri,
|
||||
Supplier<String> opensearchClusterUri,
|
||||
Supplier<Boolean> isLeader
|
||||
) {
|
||||
this.nodeService = nodeService;
|
||||
|
||||
Reference in New Issue
Block a user