aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/AppStateFactory.java5
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterAppStateImpl.java9
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/cluster/ClusterAppStateImplTest.java2
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMember.java6
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMemberBuilder.java11
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberBuilderTest.java13
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberImplTest.java2
7 files changed, 16 insertions, 32 deletions
diff --git a/server/sonar-main/src/main/java/org/sonar/application/AppStateFactory.java b/server/sonar-main/src/main/java/org/sonar/application/AppStateFactory.java
index bc92244f749..7c43140a3e2 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/AppStateFactory.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/AppStateFactory.java
@@ -30,18 +30,16 @@ import org.sonar.application.es.EsConnector;
import org.sonar.application.es.EsConnectorImpl;
import org.sonar.process.ProcessId;
import org.sonar.process.Props;
-import org.sonar.process.cluster.NodeType;
import org.sonar.process.cluster.hz.HazelcastMember;
import org.sonar.process.cluster.hz.HazelcastMemberBuilder;
import static java.util.Arrays.asList;
import static org.sonar.process.ProcessProperties.Property.CLUSTER_HOSTS;
+import static org.sonar.process.ProcessProperties.Property.CLUSTER_NAME;
import static org.sonar.process.ProcessProperties.Property.CLUSTER_NODE_HOST;
import static org.sonar.process.ProcessProperties.Property.CLUSTER_NODE_NAME;
import static org.sonar.process.ProcessProperties.Property.CLUSTER_NODE_PORT;
-import static org.sonar.process.ProcessProperties.Property.CLUSTER_NODE_TYPE;
import static org.sonar.process.ProcessProperties.Property.CLUSTER_SEARCH_HOSTS;
-import static org.sonar.process.ProcessProperties.Property.CLUSTER_NAME;
public class AppStateFactory {
@@ -64,7 +62,6 @@ public class AppStateFactory {
HazelcastMemberBuilder builder = new HazelcastMemberBuilder()
.setNetworkInterface(props.nonNullValue(CLUSTER_NODE_HOST.getKey()))
.setMembers(asList(props.nonNullValue(CLUSTER_HOSTS.getKey()).split(",")))
- .setNodeType(NodeType.parse(props.nonNullValue(CLUSTER_NODE_TYPE.getKey())))
.setNodeName(props.nonNullValue(CLUSTER_NODE_NAME.getKey()))
.setPort(Integer.parseInt(props.nonNullValue(CLUSTER_NODE_PORT.getKey())))
.setProcessId(ProcessId.APP);
diff --git a/server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterAppStateImpl.java b/server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterAppStateImpl.java
index 0659b0444e3..a1bdc68db33 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterAppStateImpl.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterAppStateImpl.java
@@ -48,11 +48,9 @@ import org.sonar.application.es.EsConnector;
import org.sonar.process.MessageException;
import org.sonar.process.NetworkUtilsImpl;
import org.sonar.process.ProcessId;
-import org.sonar.process.cluster.NodeType;
import org.sonar.process.cluster.hz.HazelcastMember;
import static java.lang.String.format;
-import static org.sonar.process.cluster.hz.HazelcastMember.Attribute.NODE_TYPE;
import static org.sonar.process.cluster.hz.HazelcastObjects.CLUSTER_NAME;
import static org.sonar.process.cluster.hz.HazelcastObjects.LEADER;
import static org.sonar.process.cluster.hz.HazelcastObjects.OPERATIONAL_PROCESSES;
@@ -282,8 +280,7 @@ public class ClusterAppStateImpl implements ClusterAppState {
@Override
public void memberRemoved(MembershipEvent membershipEvent) {
removeOperationalProcess(membershipEvent.getMember().getUuid());
- if (membershipEvent.getMembers().stream()
- .noneMatch(this::isAppNode)) {
+ if (membershipEvent.getMembers().isEmpty()) {
purgeSharedMemoryForAppNodes();
}
}
@@ -293,10 +290,6 @@ public class ClusterAppStateImpl implements ClusterAppState {
// Nothing to do
}
- private boolean isAppNode(Member member) {
- return NodeType.APPLICATION.getValue().equals(member.getStringAttribute(NODE_TYPE.getKey()));
- }
-
private void removeOperationalProcess(String uuid) {
for (ClusterProcess clusterProcess : operationalProcesses.keySet()) {
if (clusterProcess.getNodeUuid().equals(uuid)) {
diff --git a/server/sonar-main/src/test/java/org/sonar/application/cluster/ClusterAppStateImplTest.java b/server/sonar-main/src/test/java/org/sonar/application/cluster/ClusterAppStateImplTest.java
index bab40cc3e18..37b2563a794 100644
--- a/server/sonar-main/src/test/java/org/sonar/application/cluster/ClusterAppStateImplTest.java
+++ b/server/sonar-main/src/test/java/org/sonar/application/cluster/ClusterAppStateImplTest.java
@@ -32,7 +32,6 @@ import org.sonar.application.es.EsConnector;
import org.sonar.process.MessageException;
import org.sonar.process.NetworkUtilsImpl;
import org.sonar.process.ProcessId;
-import org.sonar.process.cluster.NodeType;
import org.sonar.process.cluster.hz.HazelcastMember;
import org.sonar.process.cluster.hz.HazelcastMemberBuilder;
@@ -140,7 +139,6 @@ public class ClusterAppStateImplTest {
InetAddress loopback = InetAddress.getLoopbackAddress();
return new HazelcastMemberBuilder()
- .setNodeType(NodeType.APPLICATION)
.setProcessId(ProcessId.COMPUTE_ENGINE)
.setNodeName("bar")
.setPort(NetworkUtilsImpl.INSTANCE.getNextAvailablePort(loopback))
diff --git a/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMember.java b/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMember.java
index ab9cb252a2d..012c1e1d1d4 100644
--- a/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMember.java
+++ b/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMember.java
@@ -27,7 +27,6 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.locks.Lock;
import org.sonar.process.ProcessId;
-import org.sonar.process.cluster.NodeType;
public interface HazelcastMember extends AutoCloseable {
@@ -37,11 +36,6 @@ public interface HazelcastMember extends AutoCloseable {
*/
NODE_NAME("NODE_NAME"),
/**
- * The role of the sonar-application inside the SonarQube cluster
- * {@link NodeType}
- */
- NODE_TYPE("NODE_TYPE"),
- /**
* Key of process as defined by {@link ProcessId#getKey()}
*/
PROCESS_KEY("PROCESS_KEY");
diff --git a/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMemberBuilder.java b/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMemberBuilder.java
index edcbd659b39..338cc6ad1f1 100644
--- a/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMemberBuilder.java
+++ b/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMemberBuilder.java
@@ -30,7 +30,6 @@ import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import org.sonar.process.ProcessId;
-import org.sonar.process.cluster.NodeType;
import org.sonar.process.cluster.hz.HazelcastMember.Attribute;
import static java.lang.String.format;
@@ -42,7 +41,6 @@ public class HazelcastMemberBuilder {
private String nodeName;
private int port;
- private NodeType nodeType;
private ProcessId processId;
private String networkInterface;
private List<String> members = new ArrayList<>();
@@ -52,12 +50,10 @@ public class HazelcastMemberBuilder {
return this;
}
- public HazelcastMemberBuilder setNodeType(NodeType t) {
- this.nodeType = t;
- return this;
- }
-
public HazelcastMemberBuilder setProcessId(ProcessId p) {
+ if (p == ProcessId.ELASTICSEARCH) {
+ throw new IllegalArgumentException("Hazelcast must not be enabled on Elasticsearch node");
+ }
this.processId = p;
return this;
}
@@ -128,7 +124,6 @@ public class HazelcastMemberBuilder {
MemberAttributeConfig attributes = config.getMemberAttributeConfig();
attributes.setStringAttribute(Attribute.NODE_NAME.getKey(), requireNonNull(nodeName, "Node name is missing"));
- attributes.setStringAttribute(Attribute.NODE_TYPE.getKey(), requireNonNull(nodeType, "Node type is missing").getValue());
attributes.setStringAttribute(Attribute.PROCESS_KEY.getKey(), requireNonNull(processId, "Process key is missing").getKey());
return new HazelcastMemberImpl(Hazelcast.newHazelcastInstance(config));
diff --git a/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberBuilderTest.java b/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberBuilderTest.java
index b06d7dc3570..a829d1008ca 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberBuilderTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberBuilderTest.java
@@ -23,11 +23,11 @@ import java.net.InetAddress;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.DisableOnDebug;
+import org.junit.rules.ExpectedException;
import org.junit.rules.TestRule;
import org.junit.rules.Timeout;
import org.sonar.process.NetworkUtilsImpl;
import org.sonar.process.ProcessId;
-import org.sonar.process.cluster.NodeType;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
@@ -36,6 +36,8 @@ import static org.sonar.process.ProcessProperties.Property.CLUSTER_NODE_PORT;
public class HazelcastMemberBuilderTest {
@Rule
+ public ExpectedException expectedException = ExpectedException.none();
+ @Rule
public TestRule safeguardTimeout = new DisableOnDebug(Timeout.seconds(60));
// use loopback for support of offline builds
@@ -45,7 +47,6 @@ public class HazelcastMemberBuilderTest {
@Test
public void build_member() {
HazelcastMember member = underTest
- .setNodeType(NodeType.APPLICATION)
.setProcessId(ProcessId.COMPUTE_ENGINE)
.setNodeName("bar")
.setPort(NetworkUtilsImpl.INSTANCE.getNextAvailablePort(loopback))
@@ -76,4 +77,12 @@ public class HazelcastMemberBuilderTest {
"bar:9100",
"1.2.3.4:" + CLUSTER_NODE_PORT.getDefaultValue());
}
+
+ @Test
+ public void fail_if_elasticsearch_process() {
+ expectedException.expect(IllegalArgumentException.class);
+ expectedException.expectMessage("Hazelcast must not be enabled on Elasticsearch node");
+
+ underTest.setProcessId(ProcessId.ELASTICSEARCH);
+ }
}
diff --git a/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberImplTest.java b/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberImplTest.java
index ee784627048..ebe458f0952 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberImplTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberImplTest.java
@@ -37,7 +37,6 @@ import org.junit.rules.TestRule;
import org.junit.rules.Timeout;
import org.sonar.process.NetworkUtilsImpl;
import org.sonar.process.ProcessId;
-import org.sonar.process.cluster.NodeType;
import static org.assertj.core.api.Assertions.assertThat;
@@ -112,7 +111,6 @@ public class HazelcastMemberImplTest {
private static HazelcastMember newHzMember(int port, int... otherPorts) {
return new HazelcastMemberBuilder()
- .setNodeType(NodeType.APPLICATION)
.setProcessId(ProcessId.COMPUTE_ENGINE)
.setNodeName("name" + port)
.setPort(port)