use of com.hazelcast.config.MemberAttributeConfig in project neo4j by neo4j.
the class HazelcastClusterTopology method buildMemberAttributesForCore.
static MemberAttributeConfig buildMemberAttributesForCore(MemberId myself, Config config) {
MemberAttributeConfig memberAttributeConfig = new MemberAttributeConfig();
memberAttributeConfig.setStringAttribute(MEMBER_UUID, myself.getUuid().toString());
AdvertisedSocketAddress discoveryAddress = config.get(CausalClusteringSettings.discovery_advertised_address);
memberAttributeConfig.setStringAttribute(DISCOVERY_SERVER, discoveryAddress.toString());
AdvertisedSocketAddress transactionSource = config.get(CausalClusteringSettings.transaction_advertised_address);
memberAttributeConfig.setStringAttribute(TRANSACTION_SERVER, transactionSource.toString());
AdvertisedSocketAddress raftAddress = config.get(CausalClusteringSettings.raft_advertised_address);
memberAttributeConfig.setStringAttribute(RAFT_SERVER, raftAddress.toString());
ClientConnectorAddresses clientConnectorAddresses = ClientConnectorAddresses.extractFromConfig(config);
memberAttributeConfig.setStringAttribute(CLIENT_CONNECTOR_ADDRESSES, clientConnectorAddresses.toString());
memberAttributeConfig.setBooleanAttribute(REFUSE_TO_BE_LEADER_KEY, config.get(CausalClusteringSettings.refuse_to_be_leader));
return memberAttributeConfig;
}
use of com.hazelcast.config.MemberAttributeConfig in project neo4j by neo4j.
the class HazelcastCoreTopologyService method createHazelcastInstance.
private HazelcastInstance createHazelcastInstance() {
System.setProperty(WAIT_SECONDS_BEFORE_JOIN.getName(), "1");
JoinConfig joinConfig = new JoinConfig();
joinConfig.getMulticastConfig().setEnabled(false);
joinConfig.getAwsConfig().setEnabled(false);
TcpIpConfig tcpIpConfig = joinConfig.getTcpIpConfig();
tcpIpConfig.setEnabled(true);
List<AdvertisedSocketAddress> initialMembers = config.get(CausalClusteringSettings.initial_discovery_members);
for (AdvertisedSocketAddress address : initialMembers) {
tcpIpConfig.addMember(address.toString());
}
Setting<ListenSocketAddress> discovery_listen_address = CausalClusteringSettings.discovery_listen_address;
ListenSocketAddress hazelcastAddress = config.get(discovery_listen_address);
InterfacesConfig interfaces = new InterfacesConfig();
interfaces.addInterface(hazelcastAddress.getHostname());
NetworkConfig networkConfig = new NetworkConfig();
networkConfig.setInterfaces(interfaces);
networkConfig.setPort(hazelcastAddress.getPort());
networkConfig.setJoin(joinConfig);
networkConfig.setPortAutoIncrement(false);
com.hazelcast.config.Config c = new com.hazelcast.config.Config();
c.setProperty(OPERATION_CALL_TIMEOUT_MILLIS.getName(), String.valueOf(10_000));
c.setProperty(MERGE_NEXT_RUN_DELAY_SECONDS.getName(), "10");
c.setProperty(MERGE_FIRST_RUN_DELAY_SECONDS.getName(), "10");
c.setProperty(INITIAL_MIN_CLUSTER_SIZE.getName(), String.valueOf(minimumClusterSizeThatCanTolerateOneFaultForExpectedClusterSize()));
c.setProperty(LOGGING_TYPE.getName(), "none");
c.setNetworkConfig(networkConfig);
MemberAttributeConfig memberAttributeConfig = HazelcastClusterTopology.buildMemberAttributesForCore(myself, config);
c.setMemberAttributeConfig(memberAttributeConfig);
logConnectionInfo(initialMembers);
JobScheduler.JobHandle logJob = scheduler.schedule("HazelcastHealth", HAZELCAST_IS_HEALTHY_TIMEOUT_MS, () -> log.warn("The server has not been able to connect in a timely fashion to the " + "cluster. Please consult the logs for more details. Rebooting the server may " + "solve the problem."));
try {
hazelcastInstance = Hazelcast.newHazelcastInstance(c);
logJob.cancel(true);
} catch (HazelcastException e) {
String errorMessage = String.format("Hazelcast was unable to start with setting: %s = %s", discovery_listen_address.name(), config.get(discovery_listen_address));
userLog.error(errorMessage);
log.error(errorMessage, e);
throw new RuntimeException(e);
}
List<String> groups = config.get(CausalClusteringSettings.server_groups);
refreshGroups(hazelcastInstance, myself.getUuid().toString(), groups);
return hazelcastInstance;
}
use of com.hazelcast.config.MemberAttributeConfig in project hazelcast by hazelcast.
the class ClientMemberAttributeTest method testConfigAttributes.
@Test(timeout = 120000)
public void testConfigAttributes() throws Exception {
Config c = new Config();
JoinConfig join = c.getNetworkConfig().getJoin();
join.getTcpIpConfig().addMember("127.0.0.1").setEnabled(true);
join.getMulticastConfig().setEnabled(false);
MemberAttributeConfig memberAttributeConfig = c.getMemberAttributeConfig();
memberAttributeConfig.setIntAttribute("Test", 123);
HazelcastInstance h1 = hazelcastFactory.newHazelcastInstance(c);
Member m1 = h1.getCluster().getLocalMember();
assertEquals(123, (int) m1.getIntAttribute("Test"));
HazelcastInstance h2 = hazelcastFactory.newHazelcastInstance(c);
Member m2 = h2.getCluster().getLocalMember();
assertEquals(123, (int) m2.getIntAttribute("Test"));
assertEquals(2, h2.getCluster().getMembers().size());
Member member = null;
for (Member m : h2.getCluster().getMembers()) {
if (m == h2.getCluster().getLocalMember()) {
continue;
}
member = m;
}
assertNotNull(member);
assertEquals(m1, member);
assertNotNull(member.getIntAttribute("Test"));
assertEquals(123, (int) member.getIntAttribute("Test"));
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
Collection<Member> members = client.getCluster().getMembers();
for (Member m : members) {
assertEquals(123, (int) m.getIntAttribute("Test"));
}
}
use of com.hazelcast.config.MemberAttributeConfig in project hazelcast by hazelcast.
the class MemberAttributeTest method testConfigAttributes.
@Test(timeout = 120000)
public void testConfigAttributes() throws Exception {
Config config = new Config();
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
MemberAttributeConfig memberAttributeConfig = config.getMemberAttributeConfig();
memberAttributeConfig.setIntAttribute("Test", 123);
HazelcastInstance h1 = factory.newHazelcastInstance(config);
Member m1 = h1.getCluster().getLocalMember();
assertEquals(123, (int) m1.getIntAttribute("Test"));
HazelcastInstance h2 = factory.newHazelcastInstance(config);
Member m2 = h2.getCluster().getLocalMember();
assertEquals(123, (int) m2.getIntAttribute("Test"));
assertEquals(2, h1.getCluster().getMembers().size());
assertEquals(2, h2.getCluster().getMembers().size());
Member member = null;
for (Member m : h2.getCluster().getMembers()) {
if (m == h2.getCluster().getLocalMember())
continue;
member = m;
}
assertNotNull(member);
assertEquals(m1, member);
assertNotNull(member.getIntAttribute("Test"));
assertEquals(123, (int) member.getIntAttribute("Test"));
for (Member m : h1.getCluster().getMembers()) {
if (m == h1.getCluster().getLocalMember())
continue;
member = m;
}
assertNotNull(member);
assertEquals(m2, member);
assertNotNull(member.getIntAttribute("Test"));
assertEquals(123, (int) member.getIntAttribute("Test"));
h1.shutdown();
h2.shutdown();
}
use of com.hazelcast.config.MemberAttributeConfig in project hazelcast by hazelcast.
the class TestFullApplicationContext method testMemberAttributesConfig.
@Test
public void testMemberAttributesConfig() {
MemberAttributeConfig memberAttributeConfig = config.getMemberAttributeConfig();
assertNotNull(memberAttributeConfig);
assertEquals("spring-group", memberAttributeConfig.getStringAttribute("cluster.group.name"));
assertEquals(new Integer(5700), memberAttributeConfig.getIntAttribute("cluster.port.int"));
assertEquals(new Long(5700), memberAttributeConfig.getLongAttribute("cluster.port.long"));
assertEquals(new Short("5700"), memberAttributeConfig.getShortAttribute("cluster.port.short"));
assertEquals(new Byte("111"), memberAttributeConfig.getByteAttribute("attribute.byte"));
assertTrue(memberAttributeConfig.getBooleanAttribute("attribute.boolean"));
assertEquals(0.0d, memberAttributeConfig.getDoubleAttribute("attribute.double"), 0.0001d);
assertEquals(1234.5678, memberAttributeConfig.getFloatAttribute("attribute.float"), 0.0001);
}
Aggregations