Code style improvement
This commit is contained in:
parent
d5552a980f
commit
183ca37dfa
15
pom.xml
15
pom.xml
|
@ -483,7 +483,8 @@
|
|||
<haltOnFailure>${tests.failfast}</haltOnFailure>
|
||||
<uniqueSuiteNames>false</uniqueSuiteNames>
|
||||
<systemProperties>
|
||||
<java.io.tmpdir>.</java.io.tmpdir> <!-- we use '.' since this is different per JVM-->
|
||||
<java.io.tmpdir>.</java.io.tmpdir>
|
||||
<!-- we use '.' since this is different per JVM-->
|
||||
<!-- RandomizedTesting library system properties -->
|
||||
<tests.bwc>${tests.bwc}</tests.bwc>
|
||||
<tests.bwc.path>${tests.bwc.path}</tests.bwc.path>
|
||||
|
@ -573,7 +574,9 @@
|
|||
</fileset>
|
||||
<map from="${basedir}${file.separator}" to="* "/>
|
||||
</pathconvert>
|
||||
<fail if="validate.patternsFound">The following files contain tabs or nocommits:${line.separator}${validate.patternsFound}</fail>
|
||||
<fail if="validate.patternsFound">The following files contain tabs or
|
||||
nocommits:${line.separator}${validate.patternsFound}
|
||||
</fail>
|
||||
</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
@ -581,7 +584,8 @@
|
|||
<id>tests</id>
|
||||
<phase>test</phase>
|
||||
<configuration>
|
||||
<skip>${skipTests}</skip> <!-- don't run if we skip the tests -->
|
||||
<skip>${skipTests}</skip>
|
||||
<!-- don't run if we skip the tests -->
|
||||
<failOnError>false</failOnError>
|
||||
<target>
|
||||
<property name="runtime_classpath" refid="maven.runtime.classpath"/>
|
||||
|
@ -1222,7 +1226,7 @@
|
|||
<excludes>
|
||||
<!-- start exclude for test GC simulation using Thread.suspend -->
|
||||
<exclude>org/elasticsearch/test/disruption/LongGCDisruption.class</exclude>
|
||||
<!-- end exclude for Channels -->
|
||||
<!-- end exclude for GC simulation -->
|
||||
</excludes>
|
||||
<signaturesFiles>
|
||||
<signaturesFile>test-signatures.txt</signaturesFile>
|
||||
|
@ -1385,7 +1389,8 @@
|
|||
<exclude>src/main/java/org/apache/lucene/queryparser/XSimpleQueryParser.java</exclude>
|
||||
<exclude>src/main/java/org/apache/lucene/**/X*.java</exclude>
|
||||
<!-- t-digest -->
|
||||
<exclude>src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/tdigest/TDigestState.java</exclude>
|
||||
<exclude>src/main/java/org/elasticsearch/search/aggregations/metrics/percentiles/tdigest/TDigestState.java
|
||||
</exclude>
|
||||
<exclude>src/test/java/org/elasticsearch/search/aggregations/metrics/GroupTree.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
|
|
|
@ -118,7 +118,7 @@ public class ClusterBlocks {
|
|||
}
|
||||
|
||||
public boolean hasGlobalBlock(ClusterBlockLevel level) {
|
||||
return !global(level).isEmpty();
|
||||
return global(level).size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -89,11 +89,12 @@ public class DiscoverySettings extends AbstractComponent {
|
|||
}
|
||||
|
||||
private ClusterBlock parseNoMasterBlock(String value) {
|
||||
if ("all".equals(value)) {
|
||||
switch (value) {
|
||||
case "all":
|
||||
return NO_MASTER_BLOCK_ALL;
|
||||
} else if ("write".equals(value)) {
|
||||
case "write":
|
||||
return NO_MASTER_BLOCK_WRITES;
|
||||
} else {
|
||||
default:
|
||||
throw new ElasticsearchIllegalArgumentException("invalid master block [" + value + "]");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -939,13 +939,14 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
|
||||
if (pingMasters.isEmpty()) {
|
||||
// if we don't have enough master nodes, we bail, because there are not enough master to elect from
|
||||
if (!electMaster.hasEnoughMasterNodes(possibleMasterNodes)) {
|
||||
if (electMaster.hasEnoughMasterNodes(possibleMasterNodes)) {
|
||||
return electMaster.electMaster(possibleMasterNodes);
|
||||
} else {
|
||||
logger.trace("not enough master nodes [{}]", possibleMasterNodes);
|
||||
return null;
|
||||
}
|
||||
// lets tie break between discovered nodes
|
||||
return electMaster.electMaster(possibleMasterNodes);
|
||||
} else {
|
||||
// lets tie break between discovered nodes
|
||||
return electMaster.electMaster(pingMasters);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -396,6 +396,7 @@ public class MasterFaultDetection extends AbstractComponent {
|
|||
throw new NotMasterException();
|
||||
}
|
||||
|
||||
// ping from nodes of version < 1.4.0 will have the clustername set to null
|
||||
if (request.clusterName != null && !request.clusterName.equals(clusterName)) {
|
||||
logger.trace("master fault detection ping request is targeted for a different [{}] cluster then us [{}]", request.clusterName, clusterName);
|
||||
throw new NotMasterException("master fault detection ping request is targeted for a different [" + request.clusterName + "] cluster then us [" + clusterName + "]");
|
||||
|
|
|
@ -321,6 +321,8 @@ public class NodesFaultDetection extends AbstractComponent {
|
|||
if (!latestNodes.localNodeId().equals(request.nodeId)) {
|
||||
throw new ElasticsearchIllegalStateException("Got pinged as node [" + request.nodeId + "], but I am node [" + latestNodes.localNodeId() + "]");
|
||||
}
|
||||
|
||||
// PingRequest will have clusterName set to null if it came from a node of version <1.4.0
|
||||
if (request.clusterName != null && !request.clusterName.equals(clusterName)) {
|
||||
// Don't introduce new exception for bwc reasons
|
||||
throw new ElasticsearchIllegalStateException("Got pinged with cluster name [" + request.clusterName + "], but I'm part of cluster [" + clusterName + "]");
|
||||
|
|
|
@ -71,7 +71,7 @@ public class UnicastZenPing extends AbstractLifecycleComponent<ZenPing> implemen
|
|||
|
||||
private final int concurrentConnects;
|
||||
|
||||
private final DiscoveryNode[] nodes;
|
||||
private final DiscoveryNode[] configuredTargetNodes;
|
||||
|
||||
private volatile DiscoveryNodesProvider nodesProvider;
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class UnicastZenPing extends AbstractLifecycleComponent<ZenPing> implemen
|
|||
|
||||
private final Map<Integer, ConcurrentMap<DiscoveryNode, PingResponse>> receivedResponses = newConcurrentMap();
|
||||
|
||||
// a list of temporal responses a node will return for a request (holds requests from other nodes)
|
||||
// a list of temporal responses a node will return for a request (holds requests from other configuredTargetNodes)
|
||||
private final Queue<PingResponse> temporalResponses = ConcurrentCollections.newQueue();
|
||||
|
||||
private final CopyOnWriteArrayList<UnicastHostsProvider> hostsProviders = new CopyOnWriteArrayList<>();
|
||||
|
@ -107,20 +107,20 @@ public class UnicastZenPing extends AbstractLifecycleComponent<ZenPing> implemen
|
|||
List<String> hosts = Lists.newArrayList(hostArr);
|
||||
logger.debug("using initial hosts {}, with concurrent_connects [{}]", hosts, concurrentConnects);
|
||||
|
||||
List<DiscoveryNode> nodes = Lists.newArrayList();
|
||||
List<DiscoveryNode> configuredTargetNodes = Lists.newArrayList();
|
||||
int idCounter = 0;
|
||||
for (String host : hosts) {
|
||||
try {
|
||||
TransportAddress[] addresses = transportService.addressesFromString(host);
|
||||
// we only limit to 1 addresses, makes no sense to ping 100 ports
|
||||
for (int i = 0; (i < addresses.length && i < LIMIT_PORTS_COUNT); i++) {
|
||||
nodes.add(new DiscoveryNode("#zen_unicast_" + (++idCounter) + "#", addresses[i], version.minimumCompatibilityVersion()));
|
||||
configuredTargetNodes.add(new DiscoveryNode("#zen_unicast_" + (++idCounter) + "#", addresses[i], version.minimumCompatibilityVersion()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ElasticsearchIllegalArgumentException("Failed to resolve address for [" + host + "]", e);
|
||||
}
|
||||
}
|
||||
this.nodes = nodes.toArray(new DiscoveryNode[nodes.size()]);
|
||||
this.configuredTargetNodes = configuredTargetNodes.toArray(new DiscoveryNode[configuredTargetNodes.size()]);
|
||||
|
||||
transportService.registerHandler(ACTION_NAME, new UnicastPingRequestHandler());
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ public class UnicastZenPing extends AbstractLifecycleComponent<ZenPing> implemen
|
|||
List<DiscoveryNode> sortedNodesToPing = electMasterService.sortByMasterLikelihood(nodesToPingSet);
|
||||
|
||||
// new add the the unicast targets first
|
||||
ArrayList<DiscoveryNode> nodesToPing = Lists.newArrayList(nodes);
|
||||
ArrayList<DiscoveryNode> nodesToPing = Lists.newArrayList(configuredTargetNodes);
|
||||
nodesToPing.addAll(sortedNodesToPing);
|
||||
|
||||
final CountDownLatch latch = new CountDownLatch(nodesToPing.size());
|
||||
|
|
Loading…
Reference in New Issue