Java Code Examples for org.apache.catalina.tribes.Member#getMemberAliveTime()

The following examples show how to use org.apache.catalina.tribes.Member#getMemberAliveTime() . 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: Membership.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Notify the membership that this member has announced itself.
 *
 * @param member - the member that just pinged us
 * @return - true if this member is new to the cluster, false otherwise.<br>
 * - false if this member is the local member or updated.
 */
public boolean memberAlive(Member member) {
    // Ignore ourselves
    if (member.equals(local)) {
        return false;
    }

    boolean result = false;
    synchronized (membersLock) {
        MbrEntry entry = map.get(member);
        if (entry == null) {
            entry = addMember(member);
            result = true;
        } else {
            // Update the member alive time
            Member updateMember = entry.getMember();
            if (updateMember.getMemberAliveTime() != member.getMemberAliveTime()) {
                // Update fields that can change
                updateMember.setMemberAliveTime(member.getMemberAliveTime());
                updateMember.setPayload(member.getPayload());
                updateMember.setCommand(member.getCommand());
                // Re-order. Can't sort in place since a call to
                // getMembers() may then receive an intermediate result.
                Member[] newMembers = members.clone();
                Arrays.sort(newMembers, memberComparator);
                members = newMembers;
            }
        }
        entry.accessed();
    }
    return result;
}
 
Example 2
Source File: Membership.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
public int compare(Member m1, Member m2) {
    // Longer alive time, means sort first
    long result = m2.getMemberAliveTime() - m1.getMemberAliveTime();
    if (result < 0) {
        return -1;
    } else if (result == 0) {
        return 0;
    } else {
        return 1;
    }
}
 
Example 3
Source File: Membership.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(Member m1, Member m2) {
    //longer alive time, means sort first
    long result = m2.getMemberAliveTime() - m1.getMemberAliveTime();
    if (result < 0)
        return -1;
    else if (result == 0)
        return 0;
    else
        return 1;
}
 
Example 4
Source File: Membership.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(Member m1, Member m2) {
    //longer alive time, means sort first
    long result = m2.getMemberAliveTime() - m1.getMemberAliveTime();
    if (result < 0)
        return -1;
    else if (result == 0)
        return 0;
    else
        return 1;
}