Skip to content

Commit

Permalink
more renaming changes
Browse files Browse the repository at this point in the history
Signed-off-by: cliu123 <lc12251109@gmail.com>
  • Loading branch information
cliu123 committed Jun 14, 2022
1 parent f37df02 commit ba0a009
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void cleanupAfter() {
* @throws Exception
*/
@Test
public void testPluginEnabledDataNodeWithSSlOnlyMasterNode_ReqOnSSLNode() throws Exception {
public void testPluginEnabledDataNodeWithSSlOnlyClusterManagerNode_ReqOnSSLNode() throws Exception {
final Settings advSecSettings = getAdvSecSettings().build();
final Settings sslOnlySettings = getSSLOnlyModeSettings().build();

Expand All @@ -62,7 +62,7 @@ public void testPluginEnabledDataNodeWithSSlOnlyMasterNode_ReqOnSSLNode() throws
* @throws Exception
*/
@Test
public void testPluginEnabledDataNodeWithSSlOnlyMasterNode_ReqOnAdvSecNode() throws Exception {
public void testPluginEnabledDataNodeWithSSlOnlyClusterManagerNode_ReqOnAdvSecNode() throws Exception {
final Settings advSecSettings = getAdvSecSettings().build();
final Settings sslOnlySettings = getSSLOnlyModeSettings().build();

Expand All @@ -74,12 +74,12 @@ public void testPluginEnabledDataNodeWithSSlOnlyMasterNode_ReqOnAdvSecNode() thr
}

/**
* 1 Master node and 1 Data node is adv sec enabled. 2 Data nodes are SSL only.
* 1 cluster manager node and 1 Data node is adv sec enabled. 2 Data nodes are SSL only.
* Rest request lands on ssl only data node
* @throws Exception
*/
@Test
public void testPluginEnabledMasterNodeWithSSlOnlyDataNode_ReqOnSSLNode() throws Exception {
public void testPluginEnabledClusterManagerNodeWithSSlOnlyDataNode_ReqOnSSLNode() throws Exception {
final Settings advSecSettings = getAdvSecSettings().build();
final Settings sslOnlySettings = getSSLOnlyModeSettings().build();

Expand All @@ -91,12 +91,12 @@ public void testPluginEnabledMasterNodeWithSSlOnlyDataNode_ReqOnSSLNode() throws
}

/**
* 1 Master node and 1 Data node is adv sec enabled. 2 Data nodes are SSL only.
* 1 cluster manager node and 1 Data node is adv sec enabled. 2 Data nodes are SSL only.
* Rest request lands on adv sec data node
* @throws Exception
*/
@Test
public void testPluginEnabledMasterNodeWithSSlOnlyDataNode_ReqOnAdvSecNode() throws Exception {
public void testPluginEnabledClusterManagerNodeWithSSlOnlyDataNode_ReqOnAdvSecNode() throws Exception {
final Settings advSecSettings = getAdvSecSettings().build();
final Settings sslOnlySettings = getSSLOnlyModeSettings().build();

Expand All @@ -108,12 +108,12 @@ public void testPluginEnabledMasterNodeWithSSlOnlyDataNode_ReqOnAdvSecNode() thr
}

/**
* 2 Data nodes are adv sec enabled. 1 Master node and 1 Data node are plugin disabled.
* 2 Data nodes are adv sec enabled. 1 cluster manager node and 1 Data node are plugin disabled.
* Rest request lands on plugin disabled node
* @throws Exception
*/
@Test
public void testPluginEnabledDataNodeWithDisabledMasterNode_ReqOnDisabledNode() throws Exception {
public void testPluginEnabledDataNodeWithDisabledClusterManagerNode_ReqOnDisabledNode() throws Exception {
final Settings advSecSettings = getAdvSecSettingsDualMode().build();
final Settings disabledSettings = getDisabledSettings().build();

Expand All @@ -125,12 +125,12 @@ public void testPluginEnabledDataNodeWithDisabledMasterNode_ReqOnDisabledNode()
}

/**
* 2 Data nodes are adv sec enabled. 1 Master node and 1 Data node are plugin disabled.
* 2 Data nodes are adv sec enabled. 1 cluster manager node and 1 Data node are plugin disabled.
* Rest request lands on adv sec data node
* @throws Exception
*/
@Test
public void testPluginEnabledDataNodeWithDisabledMasterNode_ReqOnAdvSecNode() throws Exception {
public void testPluginEnabledDataNodeWithDisabledClusterManagerNode_ReqOnAdvSecNode() throws Exception {
final Settings advSecSettings = getAdvSecSettingsDualMode().build();
final Settings disabledSettings = getDisabledSettings().build();

Expand All @@ -142,12 +142,12 @@ public void testPluginEnabledDataNodeWithDisabledMasterNode_ReqOnAdvSecNode() th
}

/**
* 1 Master node and 1 Data node are adv sec enabled. 2 Data nodes are plugin disabled.
* 1 cluster manager node and 1 Data node are adv sec enabled. 2 Data nodes are plugin disabled.
* Rest request lands on plugin disabled node
* @throws Exception
*/
@Test
public void testPluginEnabledMasterNodeWithDisabledDataNode_ReqOnDisabledNode() throws Exception {
public void testPluginEnabledClusterManagerNodeWithDisabledDataNode_ReqOnDisabledNode() throws Exception {
final Settings advSecSettings = getAdvSecSettingsDualMode().build();
final Settings disabledSettings = getDisabledSettings().build();

Expand All @@ -159,12 +159,12 @@ public void testPluginEnabledMasterNodeWithDisabledDataNode_ReqOnDisabledNode()
}

/**
* 1 Master node and 2 Data nodes are adv sec enabled. 1 Data node is plugin disabled.
* 1 cluster manager node and 2 Data nodes are adv sec enabled. 1 Data node is plugin disabled.
* Rest request lands on plugin adv sec node
* @throws Exception
*/
@Test
public void testPluginEnabledMasterNodeWithDisabledDataNode_ReqOnAdvSecNode() throws Exception {
public void testPluginEnabledClusterManagerNodeWithDisabledDataNode_ReqOnAdvSecNode() throws Exception {
final Settings advSecSettings = getAdvSecSettingsDualMode().build();
final Settings disabledSettings = getDisabledSettings().build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,19 @@ public List<NodeSettings> getNodeSettings() {
return Collections.unmodifiableList(nodeSettings);
}

public List<NodeSettings> getMasterNodeSettings() {
public List<NodeSettings> getClusterManagerNodeSettings() {
return Collections.unmodifiableList(nodeSettings.stream().filter(a->a.clusterManagerNode).collect(Collectors.toList()));
}

public List<NodeSettings> getNonMasterNodeSettings() {
public List<NodeSettings> getNonClusterManagerNodeSettings() {
return Collections.unmodifiableList(nodeSettings.stream().filter(a->!a.clusterManagerNode).collect(Collectors.toList()));
}

public int getNodes() {
return nodeSettings.size();
}

public int getMasterNodes() {
public int getClusterManagerNodes() {
return (int) nodeSettings.stream().filter(a->a.clusterManagerNode).count();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,29 +132,28 @@ public final synchronized ClusterInfo startCluster(final NodeSettingsSupplier no
assert freePorts.size() == internalNodeSettings.size()*2;
final SortedSet<Integer> tcpClusterManagerPortsOnly = new TreeSet<Integer>();
final SortedSet<Integer> tcpAllPorts = new TreeSet<Integer>();
freePorts.stream().limit(clusterConfiguration.getMasterNodes()).forEach(el->tcpClusterManagerPortsOnly.add(el));
freePorts.stream().limit(clusterConfiguration.getClusterManagerNodes()).forEach(el->tcpClusterManagerPortsOnly.add(el));
freePorts.stream().limit(internalNodeSettings.size()).forEach(el->tcpAllPorts.add(el));

//final Iterator<Integer> tcpPortsMasterOnlyIt = tcpClusterManagerPortsOnly.iterator();
final Iterator<Integer> tcpPortsAllIt = tcpAllPorts.iterator();

final SortedSet<Integer> httpPorts = new TreeSet<Integer>();
freePorts.stream().skip(internalNodeSettings.size()).limit(internalNodeSettings.size()).forEach(el->httpPorts.add(el));
final Iterator<Integer> httpPortsIt = httpPorts.iterator();

System.out.println("tcpMasterPorts: "+tcpClusterManagerPortsOnly+"/tcpAllPorts: "+tcpAllPorts+"/httpPorts: "+httpPorts+" for ("+min+"-"+max+") fork "+forkNumber);
System.out.println("tcpClusterManagerPorts: "+tcpClusterManagerPortsOnly+"/tcpAllPorts: "+tcpAllPorts+"/httpPorts: "+httpPorts+" for ("+min+"-"+max+") fork "+forkNumber);

final CountDownLatch latch = new CountDownLatch(internalNodeSettings.size());

final AtomicReference<Exception> err = new AtomicReference<Exception>();

List<NodeSettings> internalMasterNodeSettings = clusterConfiguration.getMasterNodeSettings();
List<NodeSettings> internalNonMasterNodeSettings = clusterConfiguration.getNonMasterNodeSettings();
List<NodeSettings> internalClusterManagerNodeSettings = clusterConfiguration.getClusterManagerNodeSettings();
List<NodeSettings> internalNonClusterManagerNodeSettings = clusterConfiguration.getNonClusterManagerNodeSettings();

int nodeNumCounter = internalNodeSettings.size();

for (int i = 0; i < internalMasterNodeSettings.size(); i++) {
NodeSettings setting = internalMasterNodeSettings.get(i);
for (int i = 0; i < internalClusterManagerNodeSettings.size(); i++) {
NodeSettings setting = internalClusterManagerNodeSettings.get(i);
int nodeNum = nodeNumCounter--;
PluginAwareNode node = new PluginAwareNode(setting.clusterManagerNode,
getMinimumNonSecurityNodeSettingsBuilder(nodeNum, setting.clusterManagerNode, setting.dataNode, internalNodeSettings.size(), tcpClusterManagerPortsOnly, tcpPortsAllIt.next(), httpPortsIt.next())
Expand All @@ -179,8 +178,8 @@ public void run() {
opensearchNodes.add(node);
}

for (int i = 0; i < internalNonMasterNodeSettings.size(); i++) {
NodeSettings setting = internalNonMasterNodeSettings.get(i);
for (int i = 0; i < internalNonClusterManagerNodeSettings.size(); i++) {
NodeSettings setting = internalNonClusterManagerNodeSettings.get(i);
int nodeNum = nodeNumCounter--;
PluginAwareNode node = new PluginAwareNode(setting.clusterManagerNode,
getMinimumNonSecurityNodeSettingsBuilder(nodeNum, setting.clusterManagerNode, setting.dataNode, internalNodeSettings.size(), tcpClusterManagerPortsOnly, tcpPortsAllIt.next(), httpPortsIt.next())
Expand Down Expand Up @@ -293,11 +292,11 @@ public ClusterInfo waitForCluster(final ClusterHealthStatus status, final TimeVa

final List<NodeInfo> nodes = res.getNodes();

final List<NodeInfo> clusterManagerNodes = nodes.stream().filter(n->n.getNode().getRoles().contains(DiscoveryNodeRole.MASTER_ROLE)).collect(Collectors.toList());
final List<NodeInfo> dataNodes = nodes.stream().filter(n->n.getNode().getRoles().contains(DiscoveryNodeRole.DATA_ROLE) && !n.getNode().getRoles().contains(DiscoveryNodeRole.MASTER_ROLE)).collect(Collectors.toList());
final List<NodeInfo> clusterManagerNodes = nodes.stream().filter(n->n.getNode().getRoles().contains(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)).collect(Collectors.toList());
final List<NodeInfo> dataNodes = nodes.stream().filter(n->n.getNode().getRoles().contains(DiscoveryNodeRole.DATA_ROLE) && !n.getNode().getRoles().contains(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)).collect(Collectors.toList());
// Sorting the nodes so that the node receiving the http requests is always deterministic
dataNodes.sort(Comparator.comparing(nodeInfo -> nodeInfo.getNode().getName()));
final List<NodeInfo> clientNodes = nodes.stream().filter(n->!n.getNode().getRoles().contains(DiscoveryNodeRole.MASTER_ROLE) && !n.getNode().getRoles().contains(DiscoveryNodeRole.DATA_ROLE)).collect(Collectors.toList());
final List<NodeInfo> clientNodes = nodes.stream().filter(n->!n.getNode().getRoles().contains(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE) && !n.getNode().getRoles().contains(DiscoveryNodeRole.DATA_ROLE)).collect(Collectors.toList());


for (NodeInfo nodeInfo: clusterManagerNodes) {
Expand Down Expand Up @@ -352,7 +351,7 @@ public ClusterInfo waitForCluster(final ClusterHealthStatus status, final TimeVa

// @formatter:off
private Settings.Builder getMinimumNonSecurityNodeSettingsBuilder(final int nodenum, final boolean clusterManagerNode,
final boolean dataNode, int nodeCount, SortedSet<Integer> clusterManagerTcpPorts, /*SortedSet<Integer> nonMasterTcpPorts,*/ int tcpPort, int httpPort) {
final boolean dataNode, int nodeCount, SortedSet<Integer> clusterManagerTcpPorts, int tcpPort, int httpPort) {

return Settings.builder()
.put("node.name", "node_"+clustername+ "_num" + nodenum)
Expand Down

0 comments on commit ba0a009

Please sign in to comment.