• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Membership类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: handleMyToken

import org.apache.catalina.tribes.membership.Membership; //导入依赖的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.membership.Membership; //导入依赖的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.membership.Membership; //导入依赖的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.membership.Membership; //导入依赖的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.membership.Membership; //导入依赖的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: createElectionMsg

import org.apache.catalina.tribes.membership.Membership; //导入依赖的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


示例7: mergeOnArrive

import org.apache.catalina.tribes.membership.Membership; //导入依赖的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


示例8: processCoordMessage

import org.apache.catalina.tribes.membership.Membership; //导入依赖的package包/类
protected void processCoordMessage(CoordinationMessage msg, Member sender) throws ChannelException {
    if ( !coordMsgReceived.get() ) {
        coordMsgReceived.set(true);
        synchronized (electionMutex) { electionMutex.notifyAll();}
    } 
    msg.timestamp = System.currentTimeMillis();
    Membership merged = mergeOnArrive(msg, sender);
    if (isViewConf(msg)) handleViewConf(msg, sender, merged);
    else handleToken(msg, sender, merged);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:11,代码来源:NonBlockingCoordinator.java


示例9: handleToken

import org.apache.catalina.tribes.membership.Membership; //导入依赖的package包/类
protected void handleToken(CoordinationMessage msg, Member sender,Membership merged) throws ChannelException {
    MemberImpl local = (MemberImpl)getLocalMember(false);
    if ( local.equals(msg.getSource()) ) {
        //my message msg.src=local
        handleMyToken(local, msg, sender,merged);
    } else {
        handleOtherToken(local, msg, sender,merged);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:10,代码来源:NonBlockingCoordinator.java


示例10: handleOtherToken

import org.apache.catalina.tribes.membership.Membership; //导入依赖的package包/类
protected void handleOtherToken(MemberImpl local, CoordinationMessage msg, Member sender,Membership merged) throws ChannelException {
    if ( local.equals(msg.getLeader()) ) {
        //I am the new leader
        //startElection(false);
    } else {
        msg.view = merged.getMembers();
        sendElectionMsgToNextInline(local,msg);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:10,代码来源:NonBlockingCoordinator.java


示例11: diff

import org.apache.catalina.tribes.membership.Membership; //导入依赖的package包/类
public static Member[] diff(Membership complete, Membership local, MemberImpl ignore) {
    ArrayList<Member> result = new ArrayList<Member>();
    MemberImpl[] comp = complete.getMembers();
    for ( int i=0; i<comp.length; i++ ) {
        if ( ignore!=null && ignore.equals(comp[i]) ) continue;
        if ( local.getMember(comp[i]) == null ) result.add(comp[i]);
    }
    return result.toArray(new MemberImpl[result.size()]);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:10,代码来源:Arrays.java


示例12: createElectionMsg

import org.apache.catalina.tribes.membership.Membership; //导入依赖的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


示例13: processCoordMessage

import org.apache.catalina.tribes.membership.Membership; //导入依赖的package包/类
protected void processCoordMessage(CoordinationMessage msg, Member sender) throws ChannelException {
	if (!coordMsgReceived.get()) {
		coordMsgReceived.set(true);
		synchronized (electionMutex) {
			electionMutex.notifyAll();
		}
	}
	msg.timestamp = System.currentTimeMillis();
	Membership merged = mergeOnArrive(msg, sender);
	if (isViewConf(msg))
		handleViewConf(msg, sender, merged);
	else
		handleToken(msg, sender, merged);
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:15,代码来源:NonBlockingCoordinator.java


示例14: handleToken

import org.apache.catalina.tribes.membership.Membership; //导入依赖的package包/类
protected void handleToken(CoordinationMessage msg, Member sender, Membership merged) throws ChannelException {
	MemberImpl local = (MemberImpl) getLocalMember(false);
	if (local.equals(msg.getSource())) {
		// my message msg.src=local
		handleMyToken(local, msg, sender, merged);
	} else {
		handleOtherToken(local, msg, sender, merged);
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:10,代码来源:NonBlockingCoordinator.java


示例15: handleOtherToken

import org.apache.catalina.tribes.membership.Membership; //导入依赖的package包/类
protected void handleOtherToken(MemberImpl local, CoordinationMessage msg, Member sender, Membership merged)
		throws ChannelException {
	if (local.equals(msg.getLeader())) {
		// I am the new leader
		// startElection(false);
	} else {
		msg.view = merged.getMembers();
		sendElectionMsgToNextInline(local, msg);
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:11,代码来源:NonBlockingCoordinator.java


示例16: diff

import org.apache.catalina.tribes.membership.Membership; //导入依赖的package包/类
public static Member[] diff(Membership complete, Membership local, MemberImpl ignore) {
	ArrayList<Member> result = new ArrayList<Member>();
	MemberImpl[] comp = complete.getMembers();
	for (int i = 0; i < comp.length; i++) {
		if (ignore != null && ignore.equals(comp[i]))
			continue;
		if (local.getMember(comp[i]) == null)
			result.add(comp[i]);
	}
	return result.toArray(new MemberImpl[result.size()]);
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:12,代码来源:Arrays.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TextChangeListener类代码示例发布时间:2022-05-23
下一篇:
Java TIFFTranscoder类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap