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
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
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, "")
);
}
return enabled;
}
- List<String> getMembers() {
- return members;
+ List<String> getHosts() {
+ return hosts;
}
- List<String> getInterfaces() {
- return interfaces;
+ List<String> getNetworkInterfaces() {
+ return networkInterfaces;
}
String getName() {
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.",
)
);
} 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);
}
@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)) {
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("");
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);
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");
}
}
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";
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");