]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8818 Rename members & interface properties
authorEric Hartmann <hartmann.eric@gmail.com>
Fri, 10 Mar 2017 15:24:21 +0000 (16:24 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 13 Mar 2017 12:54:03 +0000 (13:54 +0100)
server/sonar-process-monitor/src/main/java/org/sonar/application/cluster/AppStateClusterImpl.java
server/sonar-process-monitor/src/main/java/org/sonar/application/cluster/ClusterProperties.java
server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/AppStateClusterImplTest.java
server/sonar-process-monitor/src/test/java/org/sonar/application/cluster/ClusterPropertiesTest.java
server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java

index afd0ebd4381e8269f4ca5b07aaecd4212da061bf..39a1dc370f92f3022c7848536ca79db08cd2d9cc 100644 (file)
@@ -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
index 6c9ea1b82243c2625a88a3444a6e64ad88b40766..661919efbd906850613c51f0d8bf468008716c2c 100644 (file)
@@ -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);
       }
index a1be5f33895ad88a260df8600332748c19c815c7..1aaf3bcd6f4ffded6f10b0639fa3c6451cd20858 100644 (file)
@@ -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)) {
index c974219839dcc4c429875ec92b8a2388326f2970..46013fa981152b5087e2ac473c29ccdd2a0b5fae 100644 (file)
@@ -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");
   }
 }
index 8af47f571ed3b7453b80349b8eecc730f4b5ef35..e956b0079f50b0611ec27edcd8bc9828a596ba01 100644 (file)
@@ -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");