Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smaller aesthetic fixes to InternalTestCluster #31831

Merged
merged 3 commits into from
Jul 6, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,6 @@ public InternalTestCluster(long clusterSeed, Path baseDir,
this.nodePrefix = nodePrefix;

assert nodePrefix != null;
ArrayList<Class<? extends Plugin>> tmpMockPlugins = new ArrayList<>(mockPlugins);


this.mockPlugins = mockPlugins;

Expand Down Expand Up @@ -458,14 +456,9 @@ private synchronized NodeAndClient getRandomNodeAndClient() {

private synchronized NodeAndClient getRandomNodeAndClient(Predicate<NodeAndClient> predicate) {
ensureOpen();
Collection<NodeAndClient> values = nodes.values().stream().filter(predicate).collect(Collectors.toCollection(ArrayList::new));
if (!values.isEmpty()) {
int whichOne = random.nextInt(values.size());
for (NodeAndClient nodeAndClient : values) {
if (whichOne-- == 0) {
return nodeAndClient;
}
}
List<NodeAndClient> values = nodes.values().stream().filter(predicate).collect(Collectors.toList());
if (values.isEmpty() == false) {
return randomFrom(random, values);
}
return null;
}
Expand All @@ -476,18 +469,14 @@ private synchronized NodeAndClient getRandomNodeAndClient(Predicate<NodeAndClien
* stop any of the running nodes.
*/
public synchronized void ensureAtLeastNumDataNodes(int n) {
boolean added = false;
int size = numDataNodes();
for (int i = size; i < n; i++) {
if (size < n) {
logger.info("increasing cluster size from {} to {}", size, n);
added = true;
if (numSharedDedicatedMasterNodes > 0) {
startDataOnlyNode(Settings.EMPTY);
startDataOnlyNodes(n - size);
} else {
startNode(Settings.EMPTY);
startNodes(n - size);
}
}
if (added) {
validateClusterFormed();
}
}
Expand Down Expand Up @@ -1649,10 +1638,7 @@ public synchronized String startNode(Settings.Builder settings) {
* Starts a node with the given settings and returns it's name.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*its (it's wrong in some other places too)

*/
public synchronized String startNode(Settings settings) {
final int defaultMinMasterNodes = getMinMasterNodes(getMasterNodesCount() + (Node.NODE_MASTER_SETTING.get(settings) ? 1 : 0));
NodeAndClient buildNode = buildNode(settings, defaultMinMasterNodes);
startAndPublishNodesAndClients(Collections.singletonList(buildNode));
return buildNode.name;
return startNodes(settings).get(0);
}

/**
Expand Down