Java Code Examples for org.apache.catalina.tribes.util.Arrays#diff()

The following examples show how to use org.apache.catalina.tribes.util.Arrays#diff() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NonBlockingCoordinator.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public void heartbeat() {
    try {
        Member local = getLocalMember(false);
        if ( view != null && (Arrays.diff(view,membership,local).length != 0 ||  Arrays.diff(membership,view,local).length != 0) ) {
            if ( isHighest() ) {
                fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_START_ELECT, this,
                        sm.getString("nonBlockingCoordinator.heartbeat.inconsistency")));
                startElection(true);
            }
        }
    } catch ( Exception x  ){
        log.error(sm.getString("nonBlockingCoordinator.heartbeat.failed"),x);
    } finally {
        super.heartbeat();
    }
}
 
Example 2
Source File: NonBlockingCoordinator.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Override
public void heartbeat() {
    try {
        MemberImpl local = (MemberImpl)getLocalMember(false);
        if ( view != null && (Arrays.diff(view,membership,local).length != 0 ||  Arrays.diff(membership,view,local).length != 0) ) {
            if ( isHighest() ) {
                fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_START_ELECT, this,
                                                           "Heartbeat found inconsistency, restart election"));
                startElection(true);
            }            
        }
    } catch ( Exception x  ){
        log.error("Unable to perform heartbeat.",x);
    } finally {
        super.heartbeat();
    }
}
 
Example 3
Source File: NonBlockingCoordinator.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public void heartbeat() {
    try {
        MemberImpl local = (MemberImpl)getLocalMember(false);
        if ( view != null && (Arrays.diff(view,membership,local).length != 0 ||  Arrays.diff(membership,view,local).length != 0) ) {
            if ( isHighest() ) {
                fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_START_ELECT, this,
                                                           "Heartbeat found inconsistency, restart election"));
                startElection(true);
            }            
        }
    } catch ( Exception x  ){
        log.error("Unable to perform heartbeat.",x);
    } finally {
        super.heartbeat();
    }
}
 
Example 4
Source File: NonBlockingCoordinator.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
protected Membership mergeOnArrive(CoordinationMessage msg) {
    fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_PRE_MERGE,this,"Pre merge"));
    Member local = getLocalMember(false);
    Membership merged = new Membership(local,AbsoluteOrder.comp,true);
    Arrays.fill(merged,msg.getMembers());
    Arrays.fill(merged,getMembers());
    Member[] diff = Arrays.diff(merged,membership,local);
    for ( int i=0; i<diff.length; i++ ) {
        if (!alive(diff[i])) merged.removeMember(diff[i]);
        else memberAdded(diff[i],false);
    }
    fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_POST_MERGE,this,"Post merge"));
    return merged;
}
 
Example 5
Source File: NonBlockingCoordinator.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
protected Membership mergeOnArrive(CoordinationMessage msg, Member sender) {
    fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_PRE_MERGE,this,"Pre merge"));
    MemberImpl local = (MemberImpl)getLocalMember(false);
    Membership merged = new Membership(local,AbsoluteOrder.comp,true);
    Arrays.fill(merged,msg.getMembers());
    Arrays.fill(merged,getMembers());
    Member[] diff = Arrays.diff(merged,membership,local);
    for ( int i=0; i<diff.length; i++ ) {
        if (!alive(diff[i])) merged.removeMember((MemberImpl)diff[i]);
        else memberAdded(diff[i],false);
    }
    fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_POST_MERGE,this,"Post merge"));
    return merged;
}
 
Example 6
Source File: NonBlockingCoordinator.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
protected Membership mergeOnArrive(CoordinationMessage msg, Member sender) {
    fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_PRE_MERGE,this,"Pre merge"));
    MemberImpl local = (MemberImpl)getLocalMember(false);
    Membership merged = new Membership(local,AbsoluteOrder.comp,true);
    Arrays.fill(merged,msg.getMembers());
    Arrays.fill(merged,getMembers());
    Member[] diff = Arrays.diff(merged,membership,local);
    for ( int i=0; i<diff.length; i++ ) {
        if (!alive(diff[i])) merged.removeMember((MemberImpl)diff[i]);
        else memberAdded(diff[i],false);
    }
    fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_POST_MERGE,this,"Post merge"));
    return merged;
}