public void installView(View new_view) { Address coord; int rc; ViewId vid=new_view.getVid(); Vector mbrs=new_view.getMembers();  if(log.isDebugEnabled()) log.debug("[local_addr=" + local_addr + "] view is " + new_view); if(stats) { num_views++; prev_views.add(new_view); }   if(view_id != null) { rc=vid.compareTo(view_id); if(rc <= 0) { if(log.isTraceEnabled() && rc < 0) log.trace("[" + local_addr + "] received view < current view;" + " discarding it (current vid: " + view_id + ", new vid: " + vid + ')'); return; } }  ltime=Math.max(vid.getId(), ltime);   if(checkSelfInclusion(mbrs) == false) {     if(shun && local_addr != null && prev_members.contains(local_addr)) { if(warn) log.warn("I (" + local_addr + ") am not a member of view " + new_view + ", shunning myself and leaving the group (prev_members are " + prev_members + ", current view is " + view + ")"); if(impl != null) impl.handleExit(); passUp(new Event(Event.EXIT)); } else { if(warn) log.warn("I (" + local_addr + ") am not a member of view " + new_view + "; discarding view"); } return; }  synchronized(members) {  if(new_view instanceof MergeView) view=new View(new_view.getVid(), new_view.getMembers()); else view=new_view; view_id=vid.copy();   if(mbrs != null && mbrs.size() > 0) { members.set(mbrs); tmp_members.set(members); joining.removeAll(mbrs);  leaving.retainAll(mbrs);  tmp_members.add(joining); tmp_members.remove(leaving);   for(Iterator it=mbrs.iterator(); it.hasNext();) { Address addr=(Address)it.next(); if(!prev_members.contains(addr)) prev_members.add(addr); } }   Event view_event=new Event(Event.VIEW_CHANGE, new_view.clone()); passDown(view_event); passUp(view_event);  coord=determineCoordinator();   if(coord != null && coord.equals(local_addr) && !haveCoordinatorRole()) { becomeCoordinator(); } else { if(haveCoordinatorRole() && !local_addr.equals(coord)) becomeParticipant(); } }
public void installView(View new_view, Digest digest) { if(digest != null) mergeDigest(digest); installView(new_view);
    public void installView(View new_view) {        Address coord;        int rc;        ViewId vid=new_view.getVid();        Vector mbrs=new_view.getMembers();        if(log.isDebugEnabled()) log.debug("[local_addr=" + local_addr + "] view is " + new_view);        if(stats) {            num_views++;            prev_views.add(new_view);        }        // Discards view with id lower than our own. Will be installed without check if first view        if(view_id != null) {            rc=vid.compareTo(view_id);            if(rc <= 0) {                if(log.isTraceEnabled() && rc < 0) // only scream if view is smaller, silently discard same views                    log.trace("[" + local_addr + "] received view < current view;" +                            " discarding it (current vid: " + view_id + ", new vid: " + vid + ')');                return;            }        }        ltime=Math.max(vid.getId(), ltime);  // compute Lamport logical time        /* Check for self-inclusion: if I'm not part of the new membership, I just discard it.        This ensures that messages sent in view V1 are only received by members of V1 */        if(checkSelfInclusion(mbrs) == false) {            // only shun if this member was previously part of the group. avoids problem where multiple            // members (e.g. X,Y,Z) join {A,B} concurrently, X is joined first, and Y and Z get view            // {A,B,X}, which would cause Y and Z to be shunned as they are not part of the membership            // bela Nov 20 2003            if(shun && local_addr != null && prev_members.contains(local_addr)) {                if(warn)                    log.warn("I (" + local_addr + ") am not a member of view " + new_view +                            ", shunning myself and leaving the group (prev_members are " + prev_members +                            ", current view is " + view + ")");                if(impl != null)                    impl.handleExit();                passUp(new Event(Event.EXIT));            }            else {                if(warn) log.warn("I (" + local_addr + ") am not a member of view " + new_view + "; discarding view");            }            return;        }        synchronized(members) {   // serialize access to views            // assign new_view to view_id            if(new_view instanceof MergeView)                view=new View(new_view.getVid(), new_view.getMembers());            else                view=new_view;            view_id=vid.copy();            // Set the membership. Take into account joining members            if(mbrs != null && mbrs.size() > 0) {                members.set(mbrs);                tmp_members.set(members);                joining.removeAll(mbrs);  // remove all members in mbrs from joining                // remove all elements from 'leaving' that are not in 'mbrs'                leaving.retainAll(mbrs);                tmp_members.add(joining);    // add members that haven't yet shown up in the membership                tmp_members.remove(leaving); // remove members that haven't yet been removed from the membership                // add to prev_members                for(Iterator it=mbrs.iterator(); it.hasNext();) {                    Address addr=(Address)it.next();                    if(!prev_members.contains(addr))                        prev_members.add(addr);                }            }            // Send VIEW_CHANGE event up and down the stack:            Event view_event=new Event(Event.VIEW_CHANGE, new_view.clone());            passDown(view_event); // needed e.g. by failure detector or UDP            passUp(view_event);            coord=determineCoordinator();            // if(coord != null && coord.equals(local_addr) && !(coord.equals(vid.getCoordAddress()))) {            // changed on suggestion by yaronr and Nicolas Piedeloupe            if(coord != null && coord.equals(local_addr) && !haveCoordinatorRole()) {                becomeCoordinator();            }            else {                if(haveCoordinatorRole() && !local_addr.equals(coord))                    becomeParticipant();            }        }    }