use of com.hazelcast.core.Member in project hazelcast by hazelcast.
the class SimpleMapTest method load.
private void load(ExecutorService es) throws InterruptedException {
if (!load) {
return;
}
final IMap<String, Object> map = instance.getMap(NAMESPACE);
final Member thisMember = instance.getCluster().getLocalMember();
List<String> lsOwnedEntries = new LinkedList<String>();
for (int i = 0; i < entryCount; i++) {
final String key = String.valueOf(i);
Partition partition = instance.getPartitionService().getPartition(key);
if (thisMember.equals(partition.getOwner())) {
lsOwnedEntries.add(key);
}
}
final CountDownLatch latch = new CountDownLatch(lsOwnedEntries.size());
for (final String ownedKey : lsOwnedEntries) {
es.execute(new Runnable() {
public void run() {
map.put(ownedKey, createValue());
latch.countDown();
}
});
}
latch.await();
}
use of com.hazelcast.core.Member in project hazelcast by hazelcast.
the class MemberGroupFactoryTest method createMembersWithHostAwareMetadata.
private Collection<Member> createMembersWithHostAwareMetadata() throws UnknownHostException {
Collection<Member> members = new HashSet<Member>();
InetAddress fakeAddress = InetAddress.getLocalHost();
MemberImpl member1 = new MemberImpl(new Address("192.192.0.1", fakeAddress, 5701), VERSION, true);
member1.setStringAttribute(PartitionGroupMetaData.PARTITION_GROUP_HOST, "host-1");
MemberImpl member2 = new MemberImpl(new Address("192.192.0.2", fakeAddress, 5701), VERSION, true);
member2.setStringAttribute(PartitionGroupMetaData.PARTITION_GROUP_HOST, "host-2");
MemberImpl member3 = new MemberImpl(new Address("192.192.0.3", fakeAddress, 5701), VERSION, true);
member3.setStringAttribute(PartitionGroupMetaData.PARTITION_GROUP_HOST, "host-3");
members.add(member1);
members.add(member2);
members.add(member3);
return members;
}
use of com.hazelcast.core.Member in project hazelcast by hazelcast.
the class MemberGroupFactoryTest method createMembers.
private Collection<Member> createMembers() throws UnknownHostException {
Collection<Member> members = new HashSet<Member>();
InetAddress fakeAddress = InetAddress.getLocalHost();
members.add(new MemberImpl(new Address("192.192.0.1", fakeAddress, 5701), VERSION, false));
members.add(new MemberImpl(new Address("192.192.0.1", fakeAddress, 5702), VERSION, false));
members.add(new MemberImpl(new Address("192.168.3.101", fakeAddress, 5701), VERSION, false));
members.add(new MemberImpl(new Address("192.168.3.101", fakeAddress, 5702), VERSION, false));
members.add(new MemberImpl(new Address("172.16.5.11", fakeAddress, 5701), VERSION, false));
members.add(new MemberImpl(new Address("172.16.5.11", fakeAddress, 5702), VERSION, false));
members.add(new MemberImpl(new Address("172.123.0.13", fakeAddress, 5701), VERSION, false));
members.add(new MemberImpl(new Address("172.123.0.13", fakeAddress, 5702), VERSION, false));
members.add(new MemberImpl(new Address("www.hazelcast.com.tr", fakeAddress, 5701), VERSION, false));
members.add(new MemberImpl(new Address("www.hazelcast.com.tr", fakeAddress, 5702), VERSION, false));
members.add(new MemberImpl(new Address("jobs.hazelcast.com", fakeAddress, 5701), VERSION, false));
members.add(new MemberImpl(new Address("jobs.hazelcast.com", fakeAddress, 5702), VERSION, false));
members.add(new MemberImpl(new Address("www.hazelcast.org", fakeAddress, 5701), VERSION, false));
members.add(new MemberImpl(new Address("www.hazelcast.org", fakeAddress, 5702), VERSION, false));
members.add(new MemberImpl(new Address("download.hazelcast.org", fakeAddress, 5701), VERSION, false));
members.add(new MemberImpl(new Address("download.hazelcast.org", fakeAddress, 5702), VERSION, false));
return members;
}
use of com.hazelcast.core.Member in project hazelcast by hazelcast.
the class SafeClusterTest method isMemberSafe_localMember.
@Test
public void isMemberSafe_localMember() throws Exception {
final HazelcastInstance node = createHazelcastInstance();
final Member localMember = node.getCluster().getLocalMember();
final boolean safe = node.getPartitionService().isMemberSafe(localMember);
assertTrue(safe);
}
use of com.hazelcast.core.Member in project hazelcast by hazelcast.
the class DiscoverySpiTest method testSPIAwareMemberGroupFactoryCreateMemberGroups.
@Test
public void testSPIAwareMemberGroupFactoryCreateMemberGroups() throws Exception {
String xmlFileName = "test-hazelcast-discovery-spi-metadata.xml";
Config config = getDiscoverySPIConfig(xmlFileName);
// we create this instance in order to fully create Node
HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(config);
Node node = TestUtil.getNode(hazelcastInstance);
assertNotNull(node);
MemberGroupFactory groupFactory = new SPIAwareMemberGroupFactory(node.getDiscoveryService());
Collection<Member> members = createMembers();
Collection<MemberGroup> memberGroups = groupFactory.createMemberGroups(members);
assertEquals("Member Groups: " + String.valueOf(memberGroups), 2, memberGroups.size());
for (MemberGroup memberGroup : memberGroups) {
assertEquals("Member Group: " + String.valueOf(memberGroup), 2, memberGroup.size());
}
hazelcastInstance.shutdown();
}
Aggregations