本文整理汇总了Java中org.apache.catalina.tribes.membership.MemberImpl类的典型用法代码示例。如果您正苦于以下问题:Java MemberImpl类的具体用法?Java MemberImpl怎么用?Java MemberImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MemberImpl类属于org.apache.catalina.tribes.membership包,在下文中一共展示了MemberImpl类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: memberAdded
import org.apache.catalina.tribes.membership.MemberImpl; //导入依赖的package包/类
@Override
public void memberAdded(Member member) {
if ( membership == null ) setupMembership();
boolean notify = false;
synchronized (membership) {
if (removeSuspects.containsKey(member)) {
//previously marked suspect, system below picked up the member again
removeSuspects.remove(member);
} else if (membership.getMember(member) == null){
//if we add it here, then add it upwards too
//check to see if it is alive
if (memberAlive(member)) {
membership.memberAlive( (MemberImpl) member);
notify = true;
} else {
addSuspects.put(member, Long.valueOf(System.currentTimeMillis()));
}
}
}
if ( notify ) super.memberAdded(member);
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:22,代码来源:TcpFailureDetector.java
示例2: performForcedCheck
import org.apache.catalina.tribes.membership.MemberImpl; //导入依赖的package包/类
protected void performForcedCheck() {
//update all alive times
Member[] members = super.getMembers();
for (int i = 0; members != null && i < members.length; i++) {
if (memberAlive(members[i])) {
if (membership.memberAlive((MemberImpl)members[i])) super.memberAdded(members[i]);
addSuspects.remove(members[i]);
} else {
if (membership.getMember(members[i])!=null) {
membership.removeMember((MemberImpl)members[i]);
removeSuspects.remove(members[i]);
if (members[i] instanceof StaticMember) {
addSuspects.put(members[i], Long.valueOf(System.currentTimeMillis()));
}
super.memberDisappeared(members[i]);
}
} //end if
} //for
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:21,代码来源:TcpFailureDetector.java
示例3: sendElectionMsgToNextInline
import org.apache.catalina.tribes.membership.MemberImpl; //导入依赖的package包/类
protected void sendElectionMsgToNextInline(MemberImpl local, CoordinationMessage msg) throws ChannelException {
int next = Arrays.nextIndex(local,msg.getMembers());
int current = next;
msg.leader = msg.getMembers()[0];
boolean sent = false;
while ( !sent && current >= 0 ) {
try {
sendElectionMsg(local, msg.getMembers()[current], msg);
sent = true;
}catch ( ChannelException x ) {
log.warn("Unable to send election message to:"+msg.getMembers()[current]);
current = Arrays.nextIndex(msg.getMembers()[current],msg.getMembers());
if ( current == next ) throw x;
}
}
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:17,代码来源:NonBlockingCoordinator.java
示例4: handleMyToken
import org.apache.catalina.tribes.membership.MemberImpl; //导入依赖的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
示例5: handleViewConf
import org.apache.catalina.tribes.membership.MemberImpl; //导入依赖的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
示例6: memberDisappeared
import org.apache.catalina.tribes.membership.MemberImpl; //导入依赖的package包/类
@Override
public void memberDisappeared(Member member) {
try {
membership.removeMember((MemberImpl)member);
super.memberDisappeared(member);
try {
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_MBR_DEL,this,"Member remove("+member.getName()+")"));
if ( started && (isCoordinator() || isHighest()) )
startElection(true); //to do, if a member disappears, only the coordinator can start
}catch ( ChannelException x ) {
log.error("Unable to start election when member was removed.",x);
}
}finally {
}
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:17,代码来源:NonBlockingCoordinator.java
示例7: heartbeat
import org.apache.catalina.tribes.membership.MemberImpl; //导入依赖的package包/类
@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();
}
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:18,代码来源:NonBlockingCoordinator.java
示例8: getDataPackage
import org.apache.catalina.tribes.membership.MemberImpl; //导入依赖的package包/类
public byte[] getDataPackage(byte[] data, int offset) {
byte[] addr = ((MemberImpl)address).getData(false);
XByteBuffer.toBytes(options,data,offset);
offset += 4; //options
XByteBuffer.toBytes(timestamp,data,offset);
offset += 8; //timestamp
XByteBuffer.toBytes(uniqueId.length,data,offset);
offset += 4; //uniqueId.length
System.arraycopy(uniqueId,0,data,offset,uniqueId.length);
offset += uniqueId.length; //uniqueId data
XByteBuffer.toBytes(addr.length,data,offset);
offset += 4; //addr.length
System.arraycopy(addr,0,data,offset,addr.length);
offset += addr.length; //addr data
XByteBuffer.toBytes(message.getLength(),data,offset);
offset += 4; //message.length
System.arraycopy(message.getBytesDirect(),0,data,offset,message.getLength());
offset += message.getLength(); //message data
return data;
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:21,代码来源:ChannelData.java
示例9: getDataFromPackage
import org.apache.catalina.tribes.membership.MemberImpl; //导入依赖的package包/类
public static ChannelData getDataFromPackage(byte[] b) {
ChannelData data = new ChannelData(false);
int offset = 0;
data.setOptions(XByteBuffer.toInt(b,offset));
offset += 4; //options
data.setTimestamp(XByteBuffer.toLong(b,offset));
offset += 8; //timestamp
data.uniqueId = new byte[XByteBuffer.toInt(b,offset)];
offset += 4; //uniqueId length
System.arraycopy(b,offset,data.uniqueId,0,data.uniqueId.length);
offset += data.uniqueId.length; //uniqueId data
byte[] addr = new byte[XByteBuffer.toInt(b,offset)];
offset += 4; //addr length
System.arraycopy(b,offset,addr,0,addr.length);
data.setAddress(MemberImpl.getMember(addr));
offset += addr.length; //addr data
int xsize = XByteBuffer.toInt(b,offset);
//data.message = new XByteBuffer(new byte[xsize],false);
data.message = BufferPool.getBufferPool().getBuffer(xsize,false);
offset += 4; //message length
System.arraycopy(b,offset,data.message.getBytesDirect(),0,xsize);
data.message.append(b,offset,xsize);
offset += xsize; //message data
return data;
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:26,代码来源:ChannelData.java
示例10: memberAdded
import org.apache.catalina.tribes.membership.MemberImpl; //导入依赖的package包/类
@Override
public void memberAdded(Member member) {
if (membership == null)
setupMembership();
boolean notify = false;
synchronized (membership) {
if (removeSuspects.containsKey(member)) {
// previously marked suspect, system below picked up the member
// again
removeSuspects.remove(member);
} else if (membership.getMember(member) == null) {
// if we add it here, then add it upwards too
// check to see if it is alive
if (memberAlive(member)) {
membership.memberAlive((MemberImpl) member);
notify = true;
} else {
addSuspects.put(member, Long.valueOf(System.currentTimeMillis()));
}
}
}
if (notify)
super.memberAdded(member);
}
开发者ID:how2j,项目名称:lazycat,代码行数:25,代码来源:TcpFailureDetector.java
示例11: performForcedCheck
import org.apache.catalina.tribes.membership.MemberImpl; //导入依赖的package包/类
protected void performForcedCheck() {
// update all alive times
Member[] members = super.getMembers();
for (int i = 0; members != null && i < members.length; i++) {
if (memberAlive(members[i])) {
if (membership.memberAlive((MemberImpl) members[i]))
super.memberAdded(members[i]);
addSuspects.remove(members[i]);
} else {
if (membership.getMember(members[i]) != null) {
membership.removeMember((MemberImpl) members[i]);
removeSuspects.remove(members[i]);
if (members[i] instanceof StaticMember) {
addSuspects.put(members[i], Long.valueOf(System.currentTimeMillis()));
}
super.memberDisappeared(members[i]);
}
} // end if
} // for
}
开发者ID:how2j,项目名称:lazycat,代码行数:22,代码来源:TcpFailureDetector.java
示例12: getDataFromPackage
import org.apache.catalina.tribes.membership.MemberImpl; //导入依赖的package包/类
public static ChannelData getDataFromPackage(byte[] b) {
ChannelData data = new ChannelData(false);
int offset = 0;
data.setOptions(XByteBuffer.toInt(b, offset));
offset += 4; // options
data.setTimestamp(XByteBuffer.toLong(b, offset));
offset += 8; // timestamp
data.uniqueId = new byte[XByteBuffer.toInt(b, offset)];
offset += 4; // uniqueId length
System.arraycopy(b, offset, data.uniqueId, 0, data.uniqueId.length);
offset += data.uniqueId.length; // uniqueId data
byte[] addr = new byte[XByteBuffer.toInt(b, offset)];
offset += 4; // addr length
System.arraycopy(b, offset, addr, 0, addr.length);
data.setAddress(MemberImpl.getMember(addr));
offset += addr.length; // addr data
int xsize = XByteBuffer.toInt(b, offset);
// data.message = new XByteBuffer(new byte[xsize],false);
data.message = BufferPool.getBufferPool().getBuffer(xsize, false);
offset += 4; // message length
System.arraycopy(b, offset, data.message.getBytesDirect(), 0, xsize);
data.message.append(b, offset, xsize);
offset += xsize; // message data
return data;
}
开发者ID:how2j,项目名称:lazycat,代码行数:26,代码来源:ChannelData.java
示例13: sendElectionMsgToNextInline
import org.apache.catalina.tribes.membership.MemberImpl; //导入依赖的package包/类
protected void sendElectionMsgToNextInline(MemberImpl local, CoordinationMessage msg) throws ChannelException {
int next = Arrays.nextIndex(local, msg.getMembers());
int current = next;
msg.leader = msg.getMembers()[0];
boolean sent = false;
while (!sent && current >= 0) {
try {
sendElectionMsg(local, msg.getMembers()[current], msg);
sent = true;
} catch (ChannelException x) {
log.warn("Unable to send election message to:" + msg.getMembers()[current]);
current = Arrays.nextIndex(msg.getMembers()[current], msg.getMembers());
if (current == next)
throw x;
}
}
}
开发者ID:how2j,项目名称:lazycat,代码行数:18,代码来源:NonBlockingCoordinator.java
示例14: mergeOnArrive
import org.apache.catalina.tribes.membership.MemberImpl; //导入依赖的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
示例15: handleMyToken
import org.apache.catalina.tribes.membership.MemberImpl; //导入依赖的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
示例16: handleViewConf
import org.apache.catalina.tribes.membership.MemberImpl; //导入依赖的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
示例17: memberAdded
import org.apache.catalina.tribes.membership.MemberImpl; //导入依赖的package包/类
public void memberAdded(Member member, boolean elect) {
try {
if (membership == null)
setupMembership();
if (membership.memberAlive((MemberImpl) member))
super.memberAdded(member);
try {
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_MBR_ADD, this,
"Member add(" + member.getName() + ")"));
if (started && elect)
startElection(false);
} catch (ChannelException x) {
log.error("Unable to start election when member was added.", x);
}
} finally {
}
}
开发者ID:how2j,项目名称:lazycat,代码行数:19,代码来源:NonBlockingCoordinator.java
示例18: memberDisappeared
import org.apache.catalina.tribes.membership.MemberImpl; //导入依赖的package包/类
@Override
public void memberDisappeared(Member member) {
try {
membership.removeMember((MemberImpl) member);
super.memberDisappeared(member);
try {
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_MBR_DEL, this,
"Member remove(" + member.getName() + ")"));
if (started && (isCoordinator() || isHighest()))
startElection(true); // to do, if a member disappears, only
// the coordinator can start
} catch (ChannelException x) {
log.error("Unable to start election when member was removed.", x);
}
} finally {
}
}
开发者ID:how2j,项目名称:lazycat,代码行数:19,代码来源:NonBlockingCoordinator.java
示例19: heartbeat
import org.apache.catalina.tribes.membership.MemberImpl; //导入依赖的package包/类
@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();
}
}
开发者ID:how2j,项目名称:lazycat,代码行数:19,代码来源:NonBlockingCoordinator.java
示例20: memberAdded
import org.apache.catalina.tribes.membership.MemberImpl; //导入依赖的package包/类
@Override
public void memberAdded(Member member) {
if (membership == null)
setupMembership();
boolean notify = false;
synchronized (membership) {
notify = Arrays.equals(domain, member.getDomain());
if (notify)
notify = membership.memberAlive((MemberImpl) member);
}
if (notify) {
super.memberAdded(member);
} else {
if (log.isInfoEnabled())
log.info("Member was refused to join cluster[" + member + "]");
}
}
开发者ID:how2j,项目名称:lazycat,代码行数:18,代码来源:DomainFilterInterceptor.java
注:本文中的org.apache.catalina.tribes.membership.MemberImpl类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论