use of io.atomix.cluster.Member in project atomix by atomix.
the class AtomixTest method testClientProperties.
/**
* Tests a client properties.
*/
@Test
public void testClientProperties() throws Exception {
List<CompletableFuture<Atomix>> futures = new ArrayList<>();
futures.add(startAtomix(1, Arrays.asList(1, 2, 3), ConsensusProfile.builder().withMembers("1", "2", "3").withDataPath(new File(new File(DATA_DIR, "client-properties"), "1")).build()));
futures.add(startAtomix(2, Arrays.asList(1, 2, 3), ConsensusProfile.builder().withMembers("1", "2", "3").withDataPath(new File(new File(DATA_DIR, "client-properties"), "2")).build()));
futures.add(startAtomix(3, Arrays.asList(1, 2, 3), ConsensusProfile.builder().withMembers("1", "2", "3").withDataPath(new File(new File(DATA_DIR, "client-properties"), "3")).build()));
Futures.allOf(futures).get(30, TimeUnit.SECONDS);
TestClusterMembershipEventListener dataListener = new TestClusterMembershipEventListener();
instances.get(0).getMembershipService().addListener(dataListener);
Properties properties = new Properties();
properties.setProperty("a-key", "a-value");
Atomix client1 = startAtomix(4, Arrays.asList(1, 2, 3), properties, Profile.client()).get(30, TimeUnit.SECONDS);
assertEquals(1, client1.getPartitionService().getPartitionGroups().size());
// client1 added to data node
ClusterMembershipEvent event1 = dataListener.event();
assertEquals(ClusterMembershipEvent.Type.MEMBER_ADDED, event1.type());
Member member = event1.subject();
assertNotNull(member.properties());
assertEquals(1, member.properties().size());
assertEquals("a-value", member.properties().get("a-key"));
}
Aggregations