/** Returns the second-in-line */ protected Address determineNextCoordinator() { synchronized(members) { return members.size() > 1? members.elementAt(1) : null; } }
/** Checks whether the potential_new_coord would be the new coordinator (2nd in line) */ protected boolean wouldBeNewCoordinator(Address potential_new_coord) { if(potential_new_coord == null) return false; synchronized(members) { if(members.size() < 2) return false; Address new_coord=members.elementAt(1); // member at 2nd place return Objects.equals(new_coord, potential_new_coord); } }
protected Address determineCoordinator() { synchronized(members) { return members.size() > 0? members.elementAt(0) : null; } }
/** Returns the address of the merge leader */ protected Address determineMergeLeader(Map<Address,View> views) { // we need the merge *coordinators* not merge participants because not everyone can lead a merge ! Collection<Address> coords=Util.determineActualMergeCoords(views); if(coords.isEmpty()) coords=Util.determineMergeCoords(views); // https://issues.jboss.org/browse/JGRP-2092 if(coords.isEmpty()) { log.error("%s: unable to determine merge leader from %s; not starting a merge", gms.local_addr, views); return null; } return new Membership(coords).sort().elementAt(0); // establish a deterministic order, so that coords can elect leader }
/** * Default implementation for a merge. Picks the new coordinator among the coordinators of the old subviews * by getting all coords, sorting them and picking the first. Then the coord is added to the new list, and * all subviews are subsequently added.<p/> * Tries to minimize coordinatorship moving around between different members * @param subviews A list of membership lists, e.g. [{A,B,C}, {M,N,O,P}, {X,Y,Z}]. This is a merge between * 3 subviews. Guaranteed to be non-null (but may be empty) * @return The new membership. Needs to be non-null and cannot contain duplicates */ public List<Address> getNewMembership(final Collection<Collection<Address>> subviews) { // add the coord of each subview Membership coords=new Membership(); subviews.stream().filter(subview -> !subview.isEmpty()).forEach(subview -> coords.add(subview.iterator().next())); // pick the first coord of the sorted list as the new coord coords.sort(); Membership new_mbrs=new Membership().add(coords.elementAt(0)); // add all other members in the order in which they occurred in their subviews - dupes are not added subviews.forEach(new_mbrs::add); return new_mbrs.getMembers(); } }
/** Checks whether the potential_new_coord would be the new coordinator (2nd in line) */ protected boolean wouldBeNewCoordinator(Address potential_new_coord) { Address new_coord; if(potential_new_coord == null) return false; synchronized(members) { if(members.size() < 2) return false; new_coord=(Address)members.elementAt(1); // member at 2nd place return new_coord != null && new_coord.equals(potential_new_coord); } }
protected Address determineCoordinator() { synchronized(members) { return members != null && members.size() > 0? (Address)members.elementAt(0) : null; } }
protected Address determineCoordinator() { synchronized(members) { return members.size() > 0? members.elementAt(0) : null; } }
/** Returns the second-in-line */ protected Address determineNextCoordinator() { synchronized(members) { return members.size() > 1? members.elementAt(1) : null; } }
/** Checks whether the potential_new_coord would be the new coordinator (2nd in line) */ protected boolean wouldBeNewCoordinator(Address potential_new_coord) { if(potential_new_coord == null) return false; synchronized(members) { if(members.size() < 2) return false; Address new_coord=members.elementAt(1); // member at 2nd place return Objects.equals(new_coord, potential_new_coord); } }
merge_leader=(Address)tmp.elementAt(0);
/** * Default implementation for a merge. Picks the new coordinator among the coordinators of the old subviews * by getting all coords, sorting them and picking the first. Then the coord is added to the new list, and * all subviews are subsequently added.<p/> * Tries to minimize coordinatorship moving around between different members * @param subviews A list of membership lists, e.g. [{A,B,C}, {M,N,O,P}, {X,Y,Z}]. This is a merge between * 3 subviews. Guaranteed to be non-null (but may be empty) * @return The new membership. Needs to be non-null and cannot contain duplicates */ public List<Address> getNewMembership(final Collection<Collection<Address>> subviews) { // add the coord of each subview Membership coords=new Membership(); subviews.stream().filter(subview -> !subview.isEmpty()).forEach(subview -> coords.add(subview.iterator().next())); // pick the first coord of the sorted list as the new coord coords.sort(); Membership new_mbrs=new Membership().add(coords.elementAt(0)); // add all other members in the order in which they occurred in their subviews - dupes are not added subviews.forEach(new_mbrs::add); return new_mbrs.getMembers(); } }
/** Returns the address of the merge leader */ protected Address determineMergeLeader(Map<Address,View> views) { // we need the merge *coordinators* not merge participants because not everyone can lead a merge ! Collection<Address> coords=Util.determineActualMergeCoords(views); if(coords.isEmpty()) coords=Util.determineMergeCoords(views); // https://issues.jboss.org/browse/JGRP-2092 if(coords.isEmpty()) { log.error("%s: unable to determine merge leader from %s; not starting a merge", gms.local_addr, views); return null; } return new Membership(coords).sort().elementAt(0); // establish a deterministic order, so that coords can elect leader }
/** Returns potential coordinator based on lexicographic ordering of member addresses. Another approach would be to keep track of the primary partition and return the first member if we are the primary partition. */ protected boolean iWouldBeCoordinator(Vector new_mbrs) { Membership tmp_mbrs=gms.members.copy(); tmp_mbrs.merge(new_mbrs, null); tmp_mbrs.sort(); return !(tmp_mbrs.size() <= 0 || gms.local_addr == null) && gms.local_addr.equals(tmp_mbrs.elementAt(0)); }
new_coord=num_mbrs > 0? (Address)new_mbrs.elementAt(0) : null; if(new_coord == null) { if(log.isErrorEnabled()) log.error("new_coord == null");