use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.
the class PartitionStateGeneratorImpl method createNodeGroups.
private Queue<NodeGroup> createNodeGroups(Collection<MemberGroup> memberGroups) {
Queue<NodeGroup> nodeGroups = new LinkedList<NodeGroup>();
if (memberGroups == null || memberGroups.isEmpty()) {
return nodeGroups;
}
for (MemberGroup memberGroup : memberGroups) {
NodeGroup nodeGroup;
if (memberGroup.size() == 0) {
continue;
}
if (memberGroup instanceof SingleMemberGroup || memberGroup.size() == 1) {
nodeGroup = new SingleNodeGroup();
MemberImpl next = (MemberImpl) memberGroup.iterator().next();
nodeGroup.addNode(next.getAddress());
} else {
nodeGroup = new DefaultNodeGroup();
Iterator<Member> iter = memberGroup.iterator();
while (iter.hasNext()) {
MemberImpl next = (MemberImpl) iter.next();
nodeGroup.addNode(next.getAddress());
}
}
nodeGroups.add(nodeGroup);
}
return nodeGroups;
}
use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.
the class HostAwareMemberGroupFactory method createInternalMemberGroups.
@Override
protected Set<MemberGroup> createInternalMemberGroups(Collection<? extends Member> allMembers) {
Map<String, MemberGroup> groups = new HashMap<String, MemberGroup>();
for (Member member : allMembers) {
Address address = ((MemberImpl) member).getAddress();
MemberGroup group = groups.get(address.getHost());
if (group == null) {
group = new DefaultMemberGroup();
groups.put(address.getHost(), group);
}
group.addMember(member);
}
return new HashSet<MemberGroup>(groups.values());
}
use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.
the class TopicService method dispatchEvent.
@Override
public void dispatchEvent(Object event, Object listener) {
TopicEvent topicEvent = (TopicEvent) event;
ClusterService clusterService = nodeEngine.getClusterService();
MemberImpl member = clusterService.getMember(topicEvent.publisherAddress);
if (member == null) {
member = new MemberImpl(topicEvent.publisherAddress, nodeEngine.getVersion(), false);
}
Message message = new DataAwareMessage(topicEvent.name, topicEvent.data, topicEvent.publishTime, member, nodeEngine.getSerializationService());
incrementReceivedMessages(topicEvent.name);
MessageListener messageListener = (MessageListener) listener;
messageListener.onMessage(message);
}
use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.
the class TransactionManagerServiceImpl method pickBackupLogAddresses.
Address[] pickBackupLogAddresses(int durability) {
if (durability == 0) {
return EMPTY_ADDRESSES;
}
// This should be cleaned up because this is quite a complex approach since it depends on
// the number of members in the cluster and creates litter.
ClusterService clusterService = nodeEngine.getClusterService();
List<MemberImpl> members = new ArrayList<MemberImpl>(clusterService.getMemberImpls());
members.remove(nodeEngine.getLocalMember());
int c = Math.min(members.size(), durability);
shuffle(members);
Address[] addresses = new Address[c];
for (int i = 0; i < c; i++) {
addresses[i] = members.get(i).getAddress();
}
return addresses;
}
use of com.hazelcast.instance.MemberImpl in project hazelcast by hazelcast.
the class CacheSerializationTest method testCachePartitionEventData.
@Test
public void testCachePartitionEventData() throws UnknownHostException {
Address address = new Address("127.0.0.1", 5701);
Member member = new MemberImpl(address, MemberVersion.UNKNOWN, true, false);
CachePartitionEventData cachePartitionEventData = new CachePartitionEventData("test", 1, member);
CachePartitionEventData deserialized = service.toObject(cachePartitionEventData);
assertEquals(cachePartitionEventData, deserialized);
}
Aggregations