diff options
author | Eric Hartmann <hartmann.eric@gmail.com> | 2017-03-10 16:24:21 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-03-13 13:54:03 +0100 |
commit | 15da428681e063c70717cbf3521bcab1c621a1fb (patch) | |
tree | c546f1881047e9e39815073c18ce1df2e7484e03 /server/sonar-process-monitor | |
parent | 8743da42906ff7030b33c4a13f867f58aa8f99be (diff) | |
download | sonarqube-15da428681e063c70717cbf3521bcab1c621a1fb.tar.gz sonarqube-15da428681e063c70717cbf3521bcab1c621a1fb.zip |
SONAR-8818 Rename members & interface properties
Diffstat (limited to 'server/sonar-process-monitor')
4 files changed, 35 insertions, 35 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<String> members; - private final List<String> interfaces; + private final List<String> hosts; + private final List<String> 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<String> getMembers() { - return members; + List<String> getHosts() { + return hosts; } - List<String> getInterfaces() { - return interfaces; + List<String> getNetworkInterfaces() { + return networkInterfaces; } String getName() { @@ -96,11 +96,11 @@ public final class ClusterProperties { port ); - // Test the interfaces parameter + // Test the networkInterfaces parameter try { List<String> 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<String> extractMembers(final String members) { + private static List<String> extractHosts(final String hosts) { List<String> 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<String> extractInterfaces(final String interfaces) { + private static List<String> extractNetworkInterfaces(final String networkInterfaces) { List<String> 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"); } } |