public Membership add(Address ... mbrs) { for(Address mbr: mbrs) add(mbr); return this; }
/** * Creates a Membership with a given initial members. The Address references are copied out of the list, so that * the list passed in as parameters is not the same reference as the list that the membership class uses * @param initial_members a list of members that belong to this membership */ public Membership(Collection<Address> initial_members) { if(initial_members != null) add(initial_members); }
public Membership(Address ... initial_members) { if(initial_members != null) add(initial_members); }
/** * Clears the membership and adds all members of v This method will clear out all the old members * of this membership by invoking the {@code Clear} method. Then it will add all the all * members provided in the vector v * * @param v * - a vector containing all the members this membership will contain */ public Membership set(Collection<Address> v) { clear(); return add(v); }
/** * Merges membership with the new members and removes suspects. * The Merge method will remove all the suspects and add in the new members. * It will do it in the order * 1. Remove suspects * 2. Add new members * the order is very important to notice. * * @param new_mems - a vector containing a list of members (Address) to be added to this membership * @param suspects - a vector containing a list of members (Address) to be removed from this membership */ public Membership merge(Collection<Address> new_mems, Collection<Address> suspects) { remove(suspects); return add(new_mems); }
/** * Called when a merge happened. The largest subview wins. */ public List<Address> getNewMembership(final Collection<Collection<Address>> subviews) { ArrayList<Collection<Address>> aSubviews=new ArrayList<>(subviews); int sLargest = 0; int iLargest = 0; for (int i = 0; i < aSubviews.size(); i++) { int size = aSubviews.get(i).size(); if (size > sLargest) { sLargest = size; iLargest = i; } } Membership mbrs = new Membership(aSubviews.get(iLargest)); for (int i = 0; i < aSubviews.size(); i++) if (i != iLargest) mbrs.add(aSubviews.get(i)); return mbrs.getMembers(); }
/** * Clears the membership and adds all members of a given membership parameter. Prior to setting * membership this method will clear out all the old members of this membership by invoking the * {@code clear} method. * @param m a membership containing all the members this membership will contain */ public Membership set(Membership m) { clear(); if(m != null) add(m.getMembers()); return this; }
/** * 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(); } }
/** * Takes the existing membership list and removes suspected and left members, then adds new * members to the end of the list * @param current_members The list of current members. Guaranteed to be non-null (but may be empty) * @param joiners The joining members. Guaranteed to be non-null (but may be empty) * @param leavers Members that are leaving. Guaranteed to be non-null (but may be empty) * @param suspects Members which are suspected. 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<Address> current_members, final Collection<Address> joiners, final Collection<Address> leavers, final Collection<Address> suspects) { Membership mbrs=new Membership(current_members).remove(leavers).remove(suspects).add(joiners); return mbrs.getMembers(); }
tmp_members.add(joining); // add members that haven't yet shown up in the membership
public Membership(Address ... initial_members) { if(initial_members != null) add(initial_members); }
/** * Creates a member ship object with the initial members. * The Address references are copied out of the vector, so that the * vector passed in as parameters is not the same reference as the vector * that the membership class is using * * @param initial_members - a list of members that belong to this membership */ public Membership(Collection initial_members) { if(initial_members != null) add(initial_members); }
/** * Creates a Membership with a given initial members. The Address references are copied out of the list, so that * the list passed in as parameters is not the same reference as the list that the membership class uses * @param initial_members a list of members that belong to this membership */ public Membership(Collection<Address> initial_members) { if(initial_members != null) add(initial_members); }
public Membership add(Address ... mbrs) { for(Address mbr: mbrs) add(mbr); return this; }
/** * Clears the membership and adds all members of v This method will clear out all the old members * of this membership by invoking the {@code Clear} method. Then it will add all the all * members provided in the vector v * * @param v * - a vector containing all the members this membership will contain */ public Membership set(Collection<Address> v) { clear(); return add(v); }
/** * merges membership with the new members and removes suspects * The Merge method will remove all the suspects and add in the new members. * It will do it in the order * 1. Remove suspects * 2. Add new members * the order is very important to notice. * * @param new_mems - a vector containing a list of members (Address) to be added to this membership * @param suspects - a vector containing a list of members (Address) to be removed from this membership */ public void merge(Collection new_mems, Collection suspects) { remove(suspects); add(new_mems); }
/** * Clear the membership and adds all members of v * This method will clear out all the old members of this membership by * invoking the <code>Clear</code> method. * Then it will add all the all members provided in the vector v * * @param v - a vector containing all the members this membership will contain */ public void set(Collection v) { clear(); if(v != null) { add(v); } }
/** * Clears the membership and adds all members of a given membership parameter. Prior to setting * membership this method will clear out all the old members of this membership by invoking the * {@code clear} method. * @param m a membership containing all the members this membership will contain */ public Membership set(Membership m) { clear(); if(m != null) add(m.getMembers()); return this; }
/** * Clear the membership and adds all members of v * This method will clear out all the old members of this membership by * invoking the <code>Clear</code> method. * Then it will add all the all members provided in the vector v * * @param m - a membership containing all the members this membership will contain */ public void set(Membership m) { clear(); if(m != null) { add(m.getMembers()); } }
/** * Takes the existing membership list and removes suspected and left members, then adds new * members to the end of the list * @param current_members The list of current members. Guaranteed to be non-null (but may be empty) * @param joiners The joining members. Guaranteed to be non-null (but may be empty) * @param leavers Members that are leaving. Guaranteed to be non-null (but may be empty) * @param suspects Members which are suspected. 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<Address> current_members, final Collection<Address> joiners, final Collection<Address> leavers, final Collection<Address> suspects) { Membership mbrs=new Membership(current_members).remove(leavers).remove(suspects).add(joiners); return mbrs.getMembers(); }