当前位置: 首页>>代码示例>>Java>>正文


Java AbsoluteOrder类代码示例

本文整理汇总了Java中org.apache.catalina.tribes.group.AbsoluteOrder的典型用法代码示例。如果您正苦于以下问题:Java AbsoluteOrder类的具体用法?Java AbsoluteOrder怎么用?Java AbsoluteOrder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AbsoluteOrder类属于org.apache.catalina.tribes.group包,在下文中一共展示了AbsoluteOrder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleMyToken

import org.apache.catalina.tribes.group.AbsoluteOrder; //导入依赖的package包/类
protected void handleMyToken(MemberImpl local, CoordinationMessage msg, Member sender,Membership merged) throws ChannelException {
    if ( local.equals(msg.getLeader()) ) {
        //no leadership change
        if ( Arrays.sameMembers(msg.getMembers(),merged.getMembers()) ) {
            msg.type = COORD_CONF;
            super.sendMessage(Arrays.remove(msg.getMembers(),local),createData(msg,local),null);
            handleViewConf(msg,local,merged);
        } else {
            //membership change
            suggestedView = new Membership(local,AbsoluteOrder.comp,true);
            suggestedviewId = msg.getId();
            Arrays.fill(suggestedView,merged.getMembers());
            msg.view = merged.getMembers();
            sendElectionMsgToNextInline(local,msg);
        }
    } else {
        //leadership change
        suggestedView = null;
        suggestedviewId = null;
        msg.view = merged.getMembers();
        sendElectionMsgToNextInline(local,msg);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:24,代码来源:NonBlockingCoordinator.java

示例2: handleViewConf

import org.apache.catalina.tribes.group.AbsoluteOrder; //导入依赖的package包/类
protected void handleViewConf(CoordinationMessage msg, Member sender,Membership merged) throws ChannelException {
    if ( viewId != null && msg.getId().equals(viewId) ) return;//we already have this view
    view = new Membership((MemberImpl)getLocalMember(false),AbsoluteOrder.comp,true);
    Arrays.fill(view,msg.getMembers());
    viewId = msg.getId();
    
    if ( viewId.equals(suggestedviewId) ) {
        suggestedView = null;
        suggestedviewId = null;
    }
    
    if (suggestedView != null && AbsoluteOrder.comp.compare(suggestedView.getMembers()[0],merged.getMembers()[0])<0 ) {
        suggestedView = null;
        suggestedviewId = null;
    }
    
    viewChange(viewId,view.getMembers());
    fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_CONF_RX,this,"Accepted View"));
    
    if ( suggestedviewId == null && hasHigherPriority(merged.getMembers(),membership.getMembers()) ) {
        startElection(false);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:24,代码来源:NonBlockingCoordinator.java

示例3: mergeOnArrive

import org.apache.catalina.tribes.group.AbsoluteOrder; //导入依赖的package包/类
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;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:17,代码来源:NonBlockingCoordinator.java

示例4: handleMyToken

import org.apache.catalina.tribes.group.AbsoluteOrder; //导入依赖的package包/类
protected void handleMyToken(MemberImpl local, CoordinationMessage msg, Member sender, Membership merged)
		throws ChannelException {
	if (local.equals(msg.getLeader())) {
		// no leadership change
		if (Arrays.sameMembers(msg.getMembers(), merged.getMembers())) {
			msg.type = COORD_CONF;
			super.sendMessage(Arrays.remove(msg.getMembers(), local), createData(msg, local), null);
			handleViewConf(msg, local, merged);
		} else {
			// membership change
			suggestedView = new Membership(local, AbsoluteOrder.comp, true);
			suggestedviewId = msg.getId();
			Arrays.fill(suggestedView, merged.getMembers());
			msg.view = merged.getMembers();
			sendElectionMsgToNextInline(local, msg);
		}
	} else {
		// leadership change
		suggestedView = null;
		suggestedviewId = null;
		msg.view = merged.getMembers();
		sendElectionMsgToNextInline(local, msg);
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:25,代码来源:NonBlockingCoordinator.java

示例5: handleViewConf

import org.apache.catalina.tribes.group.AbsoluteOrder; //导入依赖的package包/类
protected void handleViewConf(CoordinationMessage msg, Member sender, Membership merged) throws ChannelException {
	if (viewId != null && msg.getId().equals(viewId))
		return;// we already have this view
	view = new Membership((MemberImpl) getLocalMember(false), AbsoluteOrder.comp, true);
	Arrays.fill(view, msg.getMembers());
	viewId = msg.getId();

	if (viewId.equals(suggestedviewId)) {
		suggestedView = null;
		suggestedviewId = null;
	}

	if (suggestedView != null
			&& AbsoluteOrder.comp.compare(suggestedView.getMembers()[0], merged.getMembers()[0]) < 0) {
		suggestedView = null;
		suggestedviewId = null;
	}

	viewChange(viewId, view.getMembers());
	fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_CONF_RX, this, "Accepted View"));

	if (suggestedviewId == null && hasHigherPriority(merged.getMembers(), membership.getMembers())) {
		startElection(false);
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:26,代码来源:NonBlockingCoordinator.java

示例6: getMembers

import org.apache.catalina.tribes.group.AbsoluteOrder; //导入依赖的package包/类
/**
 * Get all current cluster members
 * 
 * @return all members or empty array
 */
@Override
public Member[] getMembers() {
	if (members.size() == 0)
		return super.getMembers();
	else {
		synchronized (members) {
			Member[] others = super.getMembers();
			Member[] result = new Member[members.size() + others.length];
			for (int i = 0; i < others.length; i++)
				result[i] = others[i];
			for (int i = 0; i < members.size(); i++)
				result[i + others.length] = members.get(i);
			AbsoluteOrder.absoluteOrder(result);
			return result;
		} // sync
	} // end if
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:23,代码来源:StaticMembershipInterceptor.java

示例7: createElectionMsg

import org.apache.catalina.tribes.group.AbsoluteOrder; //导入依赖的package包/类
private CoordinationMessage createElectionMsg(MemberImpl local, MemberImpl[] others, MemberImpl leader) {
    Membership m = new Membership(local,AbsoluteOrder.comp,true);
    Arrays.fill(m,others);
    MemberImpl[] mbrs = m.getMembers();
    m.reset(); 
    CoordinationMessage msg = new CoordinationMessage(leader, local, mbrs,new UniqueId(UUIDGenerator.randomUUID(true)), COORD_REQUEST);
    return msg;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:9,代码来源:NonBlockingCoordinator.java

示例8: mergeOnArrive

import org.apache.catalina.tribes.group.AbsoluteOrder; //导入依赖的package包/类
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;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:15,代码来源:NonBlockingCoordinator.java

示例9: hasHigherPriority

import org.apache.catalina.tribes.group.AbsoluteOrder; //导入依赖的package包/类
protected boolean hasHigherPriority(Member[] complete, Member[] local) {
    if ( local == null || local.length == 0 ) return false;
    if ( complete == null || complete.length == 0 ) return true;
    AbsoluteOrder.absoluteOrder(complete);
    AbsoluteOrder.absoluteOrder(local);
    return (AbsoluteOrder.comp.compare(complete[0],local[0]) > 0);
    
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:9,代码来源:NonBlockingCoordinator.java

示例10: getMembers

import org.apache.catalina.tribes.group.AbsoluteOrder; //导入依赖的package包/类
/**
 * Get all current cluster members
 * @return all members or empty array
 */
@Override
public Member[] getMembers() {
    if ( members.size() == 0 ) return super.getMembers();
    else {
        synchronized (members) {
            Member[] others = super.getMembers();
            Member[] result = new Member[members.size() + others.length];
            for (int i = 0; i < others.length; i++) result[i] = others[i];
            for (int i = 0; i < members.size(); i++) result[i + others.length] = members.get(i);
            AbsoluteOrder.absoluteOrder(result);
            return result;
        }//sync
    }//end if
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:19,代码来源:StaticMembershipInterceptor.java

示例11: installViewWhenStable

import org.apache.catalina.tribes.group.AbsoluteOrder; //导入依赖的package包/类
private void installViewWhenStable() {
    int stableCount = 0;

    while (stableCount < 10) {
        if (membershipChanged.compareAndSet(true, false)) {
            stableCount = 0;
        } else {
            stableCount++;
        }
        try {
            TimeUnit.MILLISECONDS.sleep(250);
        } catch (final InterruptedException e) {
            Thread.currentThread().interrupt();
        }
    }

    final Member[] members = getMembers();
    final Member[] view = new Member[members.length+1];
    System.arraycopy(members, 0, view, 0, members.length);
    view[members.length] = getLocalMember(false);
    Arrays.sort(view, AbsoluteOrder.comp);
    if (Arrays.equals(view, this.view)) {
        return;
    }
    this.view = view;
    viewChange(view);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:28,代码来源:SimpleCoordinator.java

示例12: merge

import org.apache.catalina.tribes.group.AbsoluteOrder; //导入依赖的package包/类
public static Member[] merge(Member[] m1, Member[] m2) {
    AbsoluteOrder.absoluteOrder(m1);
    AbsoluteOrder.absoluteOrder(m2);
    ArrayList<Member> list =
        new ArrayList<Member>(java.util.Arrays.asList(m1));
    for (int i=0; i<m2.length; i++) if ( !list.contains(m2[i]) ) list.add(m2[i]);
    Member[] result = new Member[list.size()];
    list.toArray(result);
    AbsoluteOrder.absoluteOrder(result);
    return result;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:12,代码来源:Arrays.java

示例13: createElectionMsg

import org.apache.catalina.tribes.group.AbsoluteOrder; //导入依赖的package包/类
private CoordinationMessage createElectionMsg(MemberImpl local, MemberImpl[] others, MemberImpl leader) {
	Membership m = new Membership(local, AbsoluteOrder.comp, true);
	Arrays.fill(m, others);
	MemberImpl[] mbrs = m.getMembers();
	m.reset();
	CoordinationMessage msg = new CoordinationMessage(leader, local, mbrs,
			new UniqueId(UUIDGenerator.randomUUID(true)), COORD_REQUEST);
	return msg;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:10,代码来源:NonBlockingCoordinator.java

示例14: hasHigherPriority

import org.apache.catalina.tribes.group.AbsoluteOrder; //导入依赖的package包/类
protected boolean hasHigherPriority(Member[] complete, Member[] local) {
	if (local == null || local.length == 0)
		return false;
	if (complete == null || complete.length == 0)
		return true;
	AbsoluteOrder.absoluteOrder(complete);
	AbsoluteOrder.absoluteOrder(local);
	return (AbsoluteOrder.comp.compare(complete[0], local[0]) > 0);

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:11,代码来源:NonBlockingCoordinator.java

示例15: isHighest

import org.apache.catalina.tribes.group.AbsoluteOrder; //导入依赖的package包/类
public boolean isHighest() {
	Member local = getLocalMember(false);
	if (membership.getMembers().length == 0)
		return true;
	else
		return AbsoluteOrder.comp.compare(local, membership.getMembers()[0]) <= 0;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:8,代码来源:NonBlockingCoordinator.java


注:本文中的org.apache.catalina.tribes.group.AbsoluteOrder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。