From 15da428681e063c70717cbf3521bcab1c621a1fb Mon Sep 17 00:00:00 2001 From: Eric Hartmann Date: Fri, 10 Mar 2017 16:24:21 +0100 Subject: [PATCH] SONAR-8818 Rename members & interface properties --- .../cluster/AppStateClusterImpl.java | 6 +-- .../cluster/ClusterProperties.java | 42 +++++++++---------- .../cluster/AppStateClusterImplTest.java | 2 +- .../cluster/ClusterPropertiesTest.java | 20 ++++----- .../org/sonar/process/ProcessProperties.java | 8 ++-- 5 files changed, 39 insertions(+), 39 deletions(-) diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/application/cluster/AppStateClusterImpl.java b/server/sonar-process-monitor/src/main/java/org/sonar/application/cluster/AppStateClusterImpl.java index afd0ebd4381..39a1dc370f9 100644 --- a/server/sonar-process-monitor/src/main/java/org/sonar/application/cluster/AppStateClusterImpl.java +++ b/server/sonar-process-monitor/src/main/java/org/sonar/application/cluster/AppStateClusterImpl.java @@ -75,10 +75,10 @@ public class AppStateClusterImpl implements AppState { NetworkConfig netConfig = hzConfig.getNetworkConfig(); netConfig.setPort(clusterProperties.getPort()); - if (!clusterProperties.getInterfaces().isEmpty()) { + if (!clusterProperties.getNetworkInterfaces().isEmpty()) { netConfig.getInterfaces() .setEnabled(true) - .setInterfaces(clusterProperties.getInterfaces()); + .setInterfaces(clusterProperties.getNetworkInterfaces()); } // Only allowing TCP/IP configuration @@ -86,7 +86,7 @@ public class AppStateClusterImpl implements AppState { joinConfig.getAwsConfig().setEnabled(false); joinConfig.getMulticastConfig().setEnabled(false); joinConfig.getTcpIpConfig().setEnabled(true); - joinConfig.getTcpIpConfig().setMembers(clusterProperties.getMembers()); + joinConfig.getTcpIpConfig().setMembers(clusterProperties.getHosts()); // Tweak HazelCast configuration hzConfig diff --git a/server/sonar-process-monitor/src/main/java/org/sonar/application/cluster/ClusterProperties.java b/server/sonar-process-monitor/src/main/java/org/sonar/application/cluster/ClusterProperties.java index 6c9ea1b8224..661919efbd9 100644 --- a/server/sonar-process-monitor/src/main/java/org/sonar/application/cluster/ClusterProperties.java +++ b/server/sonar-process-monitor/src/main/java/org/sonar/application/cluster/ClusterProperties.java @@ -42,19 +42,19 @@ public final class ClusterProperties { private final int port; private final boolean enabled; - private final List members; - private final List interfaces; + private final List hosts; + private final List networkInterfaces; private final String name; ClusterProperties(AppSettings appSettings) { port = appSettings.getProps().valueAsInt(ProcessProperties.CLUSTER_PORT); enabled = appSettings.getProps().valueAsBoolean(ProcessProperties.CLUSTER_ENABLED); - interfaces = extractInterfaces( - appSettings.getProps().value(ProcessProperties.CLUSTER_INTERFACES, "") + networkInterfaces = extractNetworkInterfaces( + appSettings.getProps().value(ProcessProperties.CLUSTER_NETWORK_INTERFACES, "") ); name = appSettings.getProps().value(ProcessProperties.CLUSTER_NAME); - members = extractMembers( - appSettings.getProps().value(ProcessProperties.CLUSTER_MEMBERS, "") + hosts = extractHosts( + appSettings.getProps().value(ProcessProperties.CLUSTER_HOSTS, "") ); } @@ -66,12 +66,12 @@ public final class ClusterProperties { return enabled; } - List getMembers() { - return members; + List getHosts() { + return hosts; } - List getInterfaces() { - return interfaces; + List getNetworkInterfaces() { + return networkInterfaces; } String getName() { @@ -96,11 +96,11 @@ public final class ClusterProperties { port ); - // Test the interfaces parameter + // Test the networkInterfaces parameter try { List localInterfaces = findAllLocalIPs(); - interfaces.forEach( + networkInterfaces.forEach( inet -> checkArgument( StringUtils.isEmpty(inet) || localInterfaces.contains(inet), "Interface %s is not available on this machine.", @@ -108,29 +108,29 @@ public final class ClusterProperties { ) ); } catch (SocketException e) { - LOGGER.warn("Unable to retrieve network interfaces. Interfaces won't be checked", e); + LOGGER.warn("Unable to retrieve network networkInterfaces. Interfaces won't be checked", e); } } - private static List extractMembers(final String members) { + private static List extractHosts(final String hosts) { List result = new ArrayList<>(); - for (String member : members.split(",")) { - if (StringUtils.isNotEmpty(member)) { - if (!member.contains(":")) { + for (String host : hosts.split(",")) { + if (StringUtils.isNotEmpty(host)) { + if (!host.contains(":")) { result.add( - String.format("%s:%s", member, DEFAULT_PORT) + String.format("%s:%s", host, DEFAULT_PORT) ); } else { - result.add(member); + result.add(host); } } } return result; } - private static List extractInterfaces(final String interfaces) { + private static List extractNetworkInterfaces(final String networkInterfaces) { List result = new ArrayList<>(); - for (String iface : interfaces.split(",")) { + for (String iface : networkInterfaces.split(",")) { if (StringUtils.isNotEmpty(iface)) { result.add(iface); } diff --git a/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/AppStateClusterImplTest.java b/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/AppStateClusterImplTest.java index a1be5f33895..1aaf3bcd6f4 100644 --- a/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/AppStateClusterImplTest.java +++ b/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/AppStateClusterImplTest.java @@ -89,7 +89,7 @@ public class AppStateClusterImplTest { @Test public void simulate_network_cluster() throws InterruptedException { TestAppSettings settings = newClusterSettings(); - settings.set(ProcessProperties.CLUSTER_INTERFACES, InetAddress.getLoopbackAddress().getHostAddress()); + settings.set(ProcessProperties.CLUSTER_NETWORK_INTERFACES, InetAddress.getLoopbackAddress().getHostAddress()); AppStateListener listener = mock(AppStateListener.class); try (AppStateClusterImpl appStateCluster = new AppStateClusterImpl(settings)) { diff --git a/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/ClusterPropertiesTest.java b/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/ClusterPropertiesTest.java index c974219839d..46013fa9811 100644 --- a/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/ClusterPropertiesTest.java +++ b/server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/ClusterPropertiesTest.java @@ -44,13 +44,13 @@ public class ClusterPropertiesTest { ClusterProperties props = new ClusterProperties(appSettings); - assertThat(props.getInterfaces()) + assertThat(props.getNetworkInterfaces()) .isEqualTo(Collections.emptyList()); assertThat(props.getPort()) .isEqualTo(9003); assertThat(props.isEnabled()) .isEqualTo(false); - assertThat(props.getMembers()) + assertThat(props.getHosts()) .isEqualTo(Collections.emptyList()); assertThat(props.getName()) .isEqualTo(""); @@ -78,7 +78,7 @@ public class ClusterPropertiesTest { public void test_interfaces_parameter() { appSettings.getProps().set(ProcessProperties.CLUSTER_ENABLED, "true"); appSettings.getProps().set(ProcessProperties.CLUSTER_NAME, "sonarqube"); - appSettings.getProps().set(ProcessProperties.CLUSTER_INTERFACES, "8.8.8.8"); // This IP belongs to Google + appSettings.getProps().set(ProcessProperties.CLUSTER_NETWORK_INTERFACES, "8.8.8.8"); // This IP belongs to Google ClusterProperties clusterProperties = new ClusterProperties(appSettings); expectedException.expect(IllegalArgumentException.class); @@ -115,22 +115,22 @@ public class ClusterPropertiesTest { appSettings.getProps().set(ProcessProperties.CLUSTER_NAME, "sonarqube"); assertThat( - new ClusterProperties(appSettings).getMembers()).isEqualTo( + new ClusterProperties(appSettings).getHosts()).isEqualTo( Collections.emptyList()); - appSettings.getProps().set(ProcessProperties.CLUSTER_MEMBERS, "192.168.1.1"); + appSettings.getProps().set(ProcessProperties.CLUSTER_HOSTS, "192.168.1.1"); assertThat( - new ClusterProperties(appSettings).getMembers()).isEqualTo( + new ClusterProperties(appSettings).getHosts()).isEqualTo( Arrays.asList("192.168.1.1:9003")); - appSettings.getProps().set(ProcessProperties.CLUSTER_MEMBERS, "192.168.1.2:5501"); + appSettings.getProps().set(ProcessProperties.CLUSTER_HOSTS, "192.168.1.2:5501"); assertThat( - new ClusterProperties(appSettings).getMembers()).containsExactlyInAnyOrder( + new ClusterProperties(appSettings).getHosts()).containsExactlyInAnyOrder( "192.168.1.2:5501"); - appSettings.getProps().set(ProcessProperties.CLUSTER_MEMBERS, "192.168.1.2:5501,192.168.1.1"); + appSettings.getProps().set(ProcessProperties.CLUSTER_HOSTS, "192.168.1.2:5501,192.168.1.1"); assertThat( - new ClusterProperties(appSettings).getMembers()).containsExactlyInAnyOrder( + new ClusterProperties(appSettings).getHosts()).containsExactlyInAnyOrder( "192.168.1.2:5501", "192.168.1.1:9003"); } } diff --git a/server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java b/server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java index 8af47f571ed..e956b0079f5 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java +++ b/server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java @@ -33,9 +33,9 @@ public class ProcessProperties { public static final String CLUSTER_SEARCH_DISABLED = "sonar.cluster.search.disabled"; public static final String CLUSTER_SEARCH_HOSTS = "sonar.cluster.search.hosts"; public static final String CLUSTER_WEB_DISABLED = "sonar.cluster.web.disabled"; - public static final String CLUSTER_MEMBERS = "sonar.cluster.members"; + public static final String CLUSTER_HOSTS = "sonar.cluster.hosts"; public static final String CLUSTER_PORT = "sonar.cluster.port"; - public static final String CLUSTER_INTERFACES = "sonar.cluster.interfaces"; + public static final String CLUSTER_NETWORK_INTERFACES = "sonar.cluster.networkInterfaces"; public static final String CLUSTER_NAME = "sonar.cluster.name"; public static final String HAZELCAST_LOG_LEVEL = "sonar.log.level.app.hazelcast"; public static final String CLUSTER_WEB_LEADER = "sonar.cluster.web.startupLeader"; @@ -139,8 +139,8 @@ public class ProcessProperties { defaults.put(CLUSTER_WEB_DISABLED, "false"); defaults.put(CLUSTER_SEARCH_DISABLED, "false"); defaults.put(CLUSTER_NAME, ""); - defaults.put(CLUSTER_INTERFACES, ""); - defaults.put(CLUSTER_MEMBERS, ""); + defaults.put(CLUSTER_NETWORK_INTERFACES, ""); + defaults.put(CLUSTER_HOSTS, ""); defaults.put(CLUSTER_PORT, "9003"); defaults.put(HAZELCAST_LOG_LEVEL, "WARN"); -- 2.39.5