m.putHeader(this.id, new FlushHeader(FlushHeader.FLUSH_COMPLETED, viewID)).setBuffer(marshal(null, digest)); down_prot.down(m);
msg = new Message().setFlag(Message.Flag.OOB); reconcileOks.clear(); msg.putHeader(this.id, new FlushHeader(FlushHeader.FLUSH_RECONCILE, currentViewId())) .setBuffer(marshal(flushMembers, d));
/** * Starts the flush protocol * @param members List of participants in the flush protocol. Guaranteed to be non-null */ private void onSuspend(final List<Address> members) { Message msg = null; Collection<Address> participantsInFlush = null; synchronized (sharedLock) { flushCoordinator = localAddress; // start FLUSH only on group members that we need to flush participantsInFlush = members; participantsInFlush.retainAll(currentView.getMembers()); flushMembers.clear(); flushMembers.addAll(participantsInFlush); flushMembers.removeAll(suspected); msg = new Message(null).src(localAddress).setBuffer(marshal(participantsInFlush, null)) .putHeader(this.id, new FlushHeader(FlushHeader.START_FLUSH, currentViewId())); } if (participantsInFlush.isEmpty()) { flush_promise.setResult(SUCCESS_START_FLUSH); } else { down_prot.down(msg); if (log.isDebugEnabled()) log.debug(localAddress + ": flush coordinator " + " is starting FLUSH with participants " + participantsInFlush); } }
@SuppressWarnings("unchecked") private void onResume(Event evt) { List<Address> members =evt.getArg(); long viewID = currentViewId(); boolean isParticipant = false; synchronized(sharedLock) { isParticipant = flushMembers.contains(localAddress) || (members != null && members.contains(localAddress)); } if (members == null || members.isEmpty()) { Message msg = new Message(null).src(localAddress); // Cannot be OOB since START_FLUSH is not OOB // we have to FIFO order two subsequent flushes if (log.isDebugEnabled()) log.debug(localAddress + ": received RESUME, sending STOP_FLUSH to all"); msg.putHeader(this.id, new FlushHeader(FlushHeader.STOP_FLUSH, viewID)); down_prot.down(msg); } else { for (Address address : members) { Message msg = new Message(address).src(localAddress); // Cannot be OOB since START_FLUSH is not OOB // we have to FIFO order two subsequent flushes if (log.isDebugEnabled()) log.debug(localAddress + ": received RESUME, sending STOP_FLUSH to " + address); msg.putHeader(this.id, new FlushHeader(FlushHeader.STOP_FLUSH, viewID)); down_prot.down(msg); } } if(isParticipant) waitForUnblock(); }
/** * Starts the flush protocol * @param members List of participants in the flush protocol. Guaranteed to be non-null */ private void onSuspend(final List<Address> members) { Message msg = null; Collection<Address> participantsInFlush = null; synchronized (sharedLock) { flushCoordinator = localAddress; // start FLUSH only on group members that we need to flush participantsInFlush = members; participantsInFlush.retainAll(currentView.getMembers()); flushMembers.clear(); flushMembers.addAll(participantsInFlush); flushMembers.removeAll(suspected); msg = new Message(null).src(localAddress).setBuffer(marshal(participantsInFlush, null)) .putHeader(this.id, new FlushHeader(FlushHeader.START_FLUSH, currentViewId())); } if (participantsInFlush.isEmpty()) { flush_promise.setResult(SUCCESS_START_FLUSH); } else { down_prot.down(msg); if (log.isDebugEnabled()) log.debug(localAddress + ": flush coordinator " + " is starting FLUSH with participants " + participantsInFlush); } }
FlushHeader fh = new FlushHeader(FlushHeader.FLUSH_COMPLETED,viewID); fh.addDigest(digest); m.putHeader(getName(), fh);
private void onStartFlush(Address flushStarter, FlushHeader fh) { if (stats) { startFlushTime = System.currentTimeMillis(); numberOfFlushes += 1; } boolean amIParticipant = false; synchronized (sharedLock) { flushCoordinator = flushStarter; flushMembers.clear(); if (fh.flushParticipants != null) { flushMembers.addAll(fh.flushParticipants); } flushMembers.removeAll(suspected); amIParticipant = flushMembers.contains(localAddress); } if (amIParticipant) { Message msg = new Message(null); msg.putHeader(getName(), new FlushHeader(FlushHeader.FLUSH_OK,fh.viewID)); down_prot.down(new Event(Event.MSG, msg)); if (log.isDebugEnabled()) log.debug("Received START_FLUSH at " + localAddress + " responded with FLUSH_OK"); } }
private void onSuspend(View view) { Message msg = null; Collection<Address> participantsInFlush = null; synchronized (sharedLock) { // start FLUSH only on group members that we need to flush if (view != null) { participantsInFlush = new ArrayList<Address>(view.getMembers()); participantsInFlush.retainAll(currentView.getMembers()); } else { participantsInFlush = new ArrayList<Address>(currentView.getMembers()); } msg = new Message(null, localAddress, null); msg.putHeader(getName(), new FlushHeader(FlushHeader.START_FLUSH, currentViewId(), participantsInFlush)); } if (participantsInFlush.isEmpty()) { flush_promise.setResult(Boolean.TRUE); } else { down_prot.down(new Event(Event.MSG, msg)); if (log.isDebugEnabled()) log.debug("Flush coordinator " + localAddress + " is starting FLUSH with participants " + participantsInFlush); } }
private void handleStartFlush(Message msg, FlushHeader fh) { Address flushRequester = msg.getSrc(); boolean proceed = flushInProgress.compareAndSet(false, true); if (proceed) { synchronized (sharedLock) { flushCoordinator = flushRequester; } onStartFlush(flushRequester, msg, fh); } else { Tuple<Collection<? extends Address>,Digest> tuple=readParticipantsAndDigest(msg.getRawBuffer(), msg.getOffset(),msg.getLength()); Collection<? extends Address> flushParticipants=tuple.getVal1(); Message response = new Message(flushRequester) .putHeader(this.id,new FlushHeader(FlushHeader.FLUSH_NOT_COMPLETED,fh.viewID)) .setBuffer(marshal(flushParticipants,null)); down_prot.down(response); if (log.isDebugEnabled()) log.debug(localAddress + ": received START_FLUSH, responded with FLUSH_NOT_COMPLETED to " + flushRequester); } }
private void handleFlushReconcile(Message msg) { Address requester = msg.getSrc(); Tuple<Collection<? extends Address>,Digest> tuple=readParticipantsAndDigest(msg.getRawBuffer(), msg.getOffset(),msg.getLength()); Digest reconcileDigest = tuple.getVal2(); if (log.isDebugEnabled()) log.debug(localAddress + ": received FLUSH_RECONCILE, passing digest to NAKACK " + reconcileDigest); // Let NAKACK reconcile missing messages down_prot.down(new Event(Event.REBROADCAST, reconcileDigest)); if (log.isDebugEnabled()) log.debug(localAddress + ": returned from FLUSH_RECONCILE, " + " sending RECONCILE_OK to " + requester); Message reconcileOk = new Message(requester).setFlag(Message.Flag.OOB, Message.Flag.INTERNAL) .putHeader(this.id,new FlushHeader(FlushHeader.FLUSH_RECONCILE_OK)); down_prot.down(reconcileOk); }
private void sendServiceMessage(byte type, String service, Address host,boolean bypassFlush, byte[] payload) throws Exception { if(host == null) host=getLocalAddress(); if(host == null) { if(log.isWarnEnabled()) { log.warn("local_addr is null, cannot send ServiceInfo." + ServiceInfo.typeToString(type) + " message"); } return; } ServiceInfo si=new ServiceInfo(type, service, host, payload); MuxHeader hdr=new MuxHeader(si); Message service_msg=new Message(); service_msg.putHeader(NAME, hdr); if(bypassFlush && flush_present) service_msg.putHeader(FLUSH.NAME, new FLUSH.FlushHeader(FLUSH.FlushHeader.FLUSH_BYPASS)); channel.send(service_msg); }
private void handleFlushReconcile(Message msg, FlushHeader fh) { Address requester = msg.getSrc(); Digest reconcileDigest = fh.digest; if (log.isDebugEnabled()) log.debug("Received FLUSH_RECONCILE at " + localAddress + " passing digest to NAKACK " + reconcileDigest); // Let NAKACK reconcile missing messages down_prot.down(new Event(Event.REBROADCAST, reconcileDigest)); if (log.isDebugEnabled()) log.debug("Returned from FLUSH_RECONCILE at " + localAddress + " Sending RECONCILE_OK to " + requester + ", thread " + Thread.currentThread()); Message reconcileOk = new Message(requester); reconcileOk.setFlag(Message.OOB); reconcileOk.putHeader(getName(), new FlushHeader(FlushHeader.FLUSH_RECONCILE_OK)); down_prot.down(new Event(Event.MSG, reconcileOk)); }
private void onResume() { long viewID = currentViewId(); Message msg = new Message(null, localAddress, null); msg.putHeader(getName(), new FlushHeader(FlushHeader.STOP_FLUSH, viewID)); down_prot.down(new Event(Event.MSG, msg)); if (log.isDebugEnabled()) log.debug("Received RESUME at " + localAddress + ", sent STOP_FLUSH to all"); }
private void rejectFlush(Collection<? extends Address> participants, long viewId) { if(participants == null) return; for (Address flushMember : participants) { if(flushMember == null) continue; Message reject = new Message(flushMember).src(localAddress).setFlag(Message.Flag.OOB, Message.Flag.INTERNAL) .putHeader(this.id, new FlushHeader(FlushHeader.ABORT_FLUSH, viewId)) .setBuffer(marshal(participants, null)); down_prot.down(reject); } }
private void rejectFlush(long viewId, Address flushRequester) { Message reject = new Message(flushRequester, localAddress, null); reject.putHeader(getName(), new FlushHeader(FlushHeader.ABORT_FLUSH,viewId)); down_prot.down(new Event(Event.MSG, reject)); }
.putHeader(this.id, new FlushHeader(FlushHeader.FLUSH_COMPLETED, fh.viewID)) .setBuffer(marshal(tuple.getVal1(),digest)); down_prot.down(start_msg);
@SuppressWarnings("unchecked") private void onResume(Event evt) { List<Address> members =evt.getArg(); long viewID = currentViewId(); boolean isParticipant = false; synchronized(sharedLock) { isParticipant = flushMembers.contains(localAddress) || (members != null && members.contains(localAddress)); } if (members == null || members.isEmpty()) { Message msg = new Message(null).src(localAddress); // Cannot be OOB since START_FLUSH is not OOB // we have to FIFO order two subsequent flushes if (log.isDebugEnabled()) log.debug(localAddress + ": received RESUME, sending STOP_FLUSH to all"); msg.putHeader(this.id, new FlushHeader(FlushHeader.STOP_FLUSH, viewID)); down_prot.down(msg); } else { for (Address address : members) { Message msg = new Message(address).src(localAddress); // Cannot be OOB since START_FLUSH is not OOB // we have to FIFO order two subsequent flushes if (log.isDebugEnabled()) log.debug(localAddress + ": received RESUME, sending STOP_FLUSH to " + address); msg.putHeader(this.id, new FlushHeader(FlushHeader.STOP_FLUSH, viewID)); down_prot.down(msg); } } if(isParticipant) waitForUnblock(); }
private void handleStartFlush(Message msg, FlushHeader fh) { Address flushRequester = msg.getSrc(); boolean proceed = flushInProgress.compareAndSet(false, true); if (proceed) { synchronized (sharedLock) { flushCoordinator = flushRequester; } onStartFlush(flushRequester, msg, fh); } else { Tuple<Collection<? extends Address>,Digest> tuple=readParticipantsAndDigest(msg.getRawBuffer(), msg.getOffset(),msg.getLength()); Collection<? extends Address> flushParticipants=tuple.getVal1(); Message response = new Message(flushRequester) .putHeader(this.id,new FlushHeader(FlushHeader.FLUSH_NOT_COMPLETED,fh.viewID)) .setBuffer(marshal(flushParticipants,null)); down_prot.down(response); if (log.isDebugEnabled()) log.debug(localAddress + ": received START_FLUSH, responded with FLUSH_NOT_COMPLETED to " + flushRequester); } }
private void handleFlushReconcile(Message msg) { Address requester = msg.getSrc(); Tuple<Collection<? extends Address>,Digest> tuple=readParticipantsAndDigest(msg.getRawBuffer(), msg.getOffset(),msg.getLength()); Digest reconcileDigest = tuple.getVal2(); if (log.isDebugEnabled()) log.debug(localAddress + ": received FLUSH_RECONCILE, passing digest to NAKACK " + reconcileDigest); // Let NAKACK reconcile missing messages down_prot.down(new Event(Event.REBROADCAST, reconcileDigest)); if (log.isDebugEnabled()) log.debug(localAddress + ": returned from FLUSH_RECONCILE, " + " sending RECONCILE_OK to " + requester); Message reconcileOk = new Message(requester).setFlag(Message.Flag.OOB, Message.Flag.INTERNAL) .putHeader(this.id,new FlushHeader(FlushHeader.FLUSH_RECONCILE_OK)); down_prot.down(reconcileOk); }
private void rejectFlush(Collection<? extends Address> participants, long viewId) { if(participants == null) return; for (Address flushMember : participants) { if(flushMember == null) continue; Message reject = new Message(flushMember).src(localAddress).setFlag(Message.Flag.OOB, Message.Flag.INTERNAL) .putHeader(this.id, new FlushHeader(FlushHeader.ABORT_FLUSH, viewId)) .setBuffer(marshal(participants, null)); down_prot.down(reject); } }