use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MemberMap method cloneAdding.
/**
* Creates clone of source {@code MemberMap} additionally including new members.
*
* @param source source map
* @param newMembers new members to add
* @return clone map
*/
static MemberMap cloneAdding(MemberMap source, MemberImpl... newMembers) {
Map<Address, MemberImpl> addressMap = new LinkedHashMap<>(source.addressToMemberMap);
Map<UUID, MemberImpl> uuidMap = new LinkedHashMap<>(source.uuidToMemberMap);
for (MemberImpl member : newMembers) {
putMember(addressMap, uuidMap, member);
}
return new MemberMap(source.version + newMembers.length, addressMap, uuidMap);
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MemberMap method tailMemberSet.
Set<MemberImpl> tailMemberSet(MemberImpl member, boolean inclusive) {
ensureMemberExist(member);
Set<MemberImpl> result = new LinkedHashSet<>();
boolean found = false;
for (MemberImpl m : members) {
if (!found && m.equals(member)) {
found = true;
if (inclusive) {
result.add(m);
}
continue;
}
if (found) {
result.add(m);
}
}
assert found : member + " should have been found!";
return result;
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MemberMap method getMember.
MemberImpl getMember(Address address, UUID uuid) {
MemberImpl member1 = addressToMemberMap.get(address);
MemberImpl member2 = uuidToMemberMap.get(uuid);
if (member1 != null && member1.equals(member2)) {
return member1;
}
return null;
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MemberMap method cloneExcluding.
/**
* Creates clone of source {@code MemberMap}, excluding given members.
* If source is empty, same map instance will be returned. If excluded members are empty or not present in
* source, a new map will be created containing the same members with source.
*
* @param source source map
* @param excludeMembers members to exclude
* @return clone map
*/
static MemberMap cloneExcluding(MemberMap source, MemberImpl... excludeMembers) {
if (source.size() == 0) {
return source;
}
Map<Address, MemberImpl> addressMap = new LinkedHashMap<>(source.addressToMemberMap);
Map<UUID, MemberImpl> uuidMap = new LinkedHashMap<>(source.uuidToMemberMap);
for (MemberImpl member : excludeMembers) {
MemberImpl removed = addressMap.remove(member.getAddress());
if (removed != null) {
uuidMap.remove(removed.getUuid());
}
removed = uuidMap.remove(member.getUuid());
if (removed != null) {
addressMap.remove(removed.getAddress());
}
}
return new MemberMap(source.version + excludeMembers.length, addressMap, uuidMap);
}
use of com.hazelcast.cluster.impl.MemberImpl in project hazelcast by hazelcast.
the class MembersView method toMemberMap.
MemberMap toMemberMap() {
MemberImpl[] m = new MemberImpl[size()];
int ix = 0;
for (MemberInfo memberInfo : members) {
m[ix++] = memberInfo.toMember();
}
return MemberMap.createNew(version, m);
}
Aggregations