org.apache.catalina.tribes.membership.Membership Java Examples
The following examples show how to use
org.apache.catalina.tribes.membership.Membership.
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 tomcatsrc with Apache License 2.0 | 6 votes |
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); } }
Example #2
Source File: NonBlockingCoordinator.java From Tomcat8-Source-Read with MIT License | 6 votes |
protected void handleMyToken(Member local, CoordinationMessage msg, 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, 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); } }
Example #3
Source File: NonBlockingCoordinator.java From tomcatsrc with Apache License 2.0 | 6 votes |
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); } }
Example #4
Source File: NonBlockingCoordinator.java From Tomcat8-Source-Read with MIT License | 6 votes |
protected void handleViewConf(CoordinationMessage msg, Membership merged) throws ChannelException { if ( viewId != null && msg.getId().equals(viewId) ) return;//we already have this view view = new Membership(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; } fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_CONF_RX,this,"Accepted View")); if ( suggestedviewId == null && hasHigherPriority(merged.getMembers(),membership.getMembers()) ) { startElection(false); } }
Example #5
Source File: NonBlockingCoordinator.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
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); } }
Example #6
Source File: NonBlockingCoordinator.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
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); } }
Example #7
Source File: Arrays.java From tomcatsrc with Apache License 2.0 | 5 votes |
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()]); }
Example #8
Source File: NonBlockingCoordinator.java From Tomcat8-Source-Read with MIT License | 5 votes |
private CoordinationMessage createElectionMsg(Member local, Member[] others, Member leader) { Membership m = new Membership(local,AbsoluteOrder.comp,true); Arrays.fill(m,others); Member[] mbrs = m.getMembers(); m.reset(); CoordinationMessage msg = new CoordinationMessage(leader, local, mbrs,new UniqueId(UUIDGenerator.randomUUID(true)), COORD_REQUEST); return msg; }
Example #9
Source File: NonBlockingCoordinator.java From tomcatsrc with Apache License 2.0 | 5 votes |
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); } }
Example #10
Source File: NonBlockingCoordinator.java From tomcatsrc with Apache License 2.0 | 5 votes |
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); } }
Example #11
Source File: NonBlockingCoordinator.java From tomcatsrc with Apache License 2.0 | 5 votes |
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); }
Example #12
Source File: NonBlockingCoordinator.java From tomcatsrc with Apache License 2.0 | 5 votes |
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 #13
Source File: NonBlockingCoordinator.java From tomcatsrc with Apache License 2.0 | 5 votes |
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; }
Example #14
Source File: Arrays.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
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()]); }
Example #15
Source File: NonBlockingCoordinator.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
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); } }
Example #16
Source File: NonBlockingCoordinator.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
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); } }
Example #17
Source File: NonBlockingCoordinator.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
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); }
Example #18
Source File: NonBlockingCoordinator.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
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 #19
Source File: NonBlockingCoordinator.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
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; }
Example #20
Source File: Arrays.java From Tomcat8-Source-Read with MIT License | 5 votes |
public static Member[] diff(Membership complete, Membership local, Member ignore) { ArrayList<Member> result = new ArrayList<>(); Member[] 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 Member[result.size()]); }
Example #21
Source File: NonBlockingCoordinator.java From Tomcat8-Source-Read with MIT License | 5 votes |
protected void handleOtherToken(Member local, CoordinationMessage msg, Membership merged) throws ChannelException { if ( local.equals(msg.getLeader()) ) { //I am the new leader //startElection(false); } else { msg.view = merged.getMembers(); sendElectionMsgToNextInline(local,msg); } }
Example #22
Source File: NonBlockingCoordinator.java From Tomcat8-Source-Read with MIT License | 5 votes |
protected void handleToken(CoordinationMessage msg, Membership merged) throws ChannelException { Member local = getLocalMember(false); if ( local.equals(msg.getSource()) ) { //my message msg.src=local handleMyToken(local, msg, merged); } else { handleOtherToken(local, msg, merged); } }
Example #23
Source File: NonBlockingCoordinator.java From Tomcat8-Source-Read with MIT License | 5 votes |
protected void processCoordMessage(CoordinationMessage msg) throws ChannelException { if ( !coordMsgReceived.get() ) { coordMsgReceived.set(true); synchronized (electionMutex) { electionMutex.notifyAll();} } Membership merged = mergeOnArrive(msg); if (isViewConf(msg)) handleViewConf(msg, merged); else handleToken(msg, merged); }
Example #24
Source File: NonBlockingCoordinator.java From Tomcat8-Source-Read with MIT License | 5 votes |
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 #25
Source File: Arrays.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
public static void fill(Membership mbrship, Member[] m) { for (int i=0; i<m.length; i++ ) mbrship.addMember((MemberImpl)m[i]); }
Example #26
Source File: Arrays.java From Tomcat8-Source-Read with MIT License | 4 votes |
public static void fill(Membership mbrship, Member[] m) { for (int i=0; i<m.length; i++ ) mbrship.addMember(m[i]); }
Example #27
Source File: Arrays.java From tomcatsrc with Apache License 2.0 | 4 votes |
public static void fill(Membership mbrship, Member[] m) { for (int i=0; i<m.length; i++ ) mbrship.addMember((MemberImpl)m[i]); }