use of com.hazelcast.config.AdvancedNetworkConfig in project hazelcast by hazelcast.
the class RestInstanceMultiendpointTest method createConfig.
@Override
protected Config createConfig() {
Config c = new Config();
AdvancedNetworkConfig anc = c.getAdvancedNetworkConfig();
anc.setEnabled(true);
return c;
}
use of com.hazelcast.config.AdvancedNetworkConfig in project hazelcast by hazelcast.
the class TestAwareInstanceFactory method newHazelcastInstance.
/**
* Creates new member instance with TCP join configured. Uses
* {@link com.hazelcast.test.AbstractHazelcastClassRunner#getTestMethodName()}
* as the cluster name if it's not changed already.
*/
public HazelcastInstance newHazelcastInstance(Config config, NodeContext nodeCtx) {
if (config == null) {
config = new Config();
}
if (DEFAULT_CLUSTER_NAME.equals(config.getClusterName())) {
config.setClusterName(getTestMethodName());
}
List<HazelcastInstance> members = getOrInitInstances(perMethodMembers);
// Prepare Unified Networking (legacy)
NetworkConfig unifiedNetworkingConfig = config.getNetworkConfig();
unifiedNetworkingConfig.setPort(PORT.getAndIncrement());
JoinConfig unifiedJoinConfig = unifiedNetworkingConfig.getJoin();
unifiedJoinConfig.getMulticastConfig().setEnabled(false);
TcpIpConfig unifiedTcpIpConfig = unifiedJoinConfig.getTcpIpConfig().setEnabled(true);
for (HazelcastInstance member : members) {
unifiedTcpIpConfig.addMember("127.0.0.1:" + getPort(member, MEMBER));
}
// Prepare Advanced Networking - Will be disabled by default but properly configured if needed
AdvancedNetworkConfig advancedNetworkConfig = config.getAdvancedNetworkConfig();
ServerSocketEndpointConfig memberEndpointConfig = (ServerSocketEndpointConfig) advancedNetworkConfig.getEndpointConfigs().get(MEMBER);
memberEndpointConfig.setPort(PORT.getAndIncrement());
JoinConfig advancedJoinConfig = advancedNetworkConfig.getJoin();
advancedJoinConfig.getMulticastConfig().setEnabled(false);
TcpIpConfig advancedTcpIpConfig = advancedJoinConfig.getTcpIpConfig().setEnabled(true);
for (HazelcastInstance member : members) {
advancedTcpIpConfig.addMember("127.0.0.1:" + getPort(member, MEMBER));
}
HazelcastInstance hz = HazelcastInstanceFactory.newHazelcastInstance(config, config.getInstanceName(), nodeCtx);
members.add(hz);
int nextPort = getPort(hz, MEMBER) + 1;
int current;
while (nextPort > (current = PORT.get())) {
PORT.compareAndSet(current, nextPort);
}
return hz;
}
Aggregations