/** Stops resending messages for the specified source sequence. */ public void stop(SourceSequence seq) { synchronized (this) { List<ResendCandidate> sequenceCandidates = getSequenceCandidates(seq); if (null != sequenceCandidates) { for (int i = sequenceCandidates.size() - 1; i >= 0; i--) { ResendCandidate candidate = sequenceCandidates.get(i); candidate.cancel(); } LOG.log(Level.FINE, "Cancelled resends for sequence {0}.", seq.getIdentifier().getValue()); } } }
public void resume(SourceSequence seq) { synchronized (this) { String key = seq.getIdentifier().getValue(); List<ResendCandidate> sequenceCandidates = suspendedCandidates.remove(key); if (null != sequenceCandidates) { for (int i = 0; i < sequenceCandidates.size(); i++) { ResendCandidate candidate = sequenceCandidates.get(i); candidate.resume(); } candidates.put(key, sequenceCandidates); LOG.log(Level.FINE, "Resumed resends for sequence {0}.", key); } } }
private void purgeCandidates(SourceSequence seq, boolean any) { Collection<Long> purged = new ArrayList<Long>(); Collection<ResendCandidate> resends = new ArrayList<ResendCandidate>(); Identifier sid = seq.getIdentifier(); synchronized (this) { LOG.fine("Start purging resend candidates."); List<ResendCandidate> sequenceCandidates = getSequenceCandidates(seq); if (null != sequenceCandidates) { for (int i = sequenceCandidates.size() - 1; i >= 0; i--) { ResendCandidate candidate = sequenceCandidates.get(i); long m = candidate.getNumber(); if (any || seq.isAcknowledged(m)) { sequenceCandidates.remove(i); candidate.resolved(); unacknowledgedCount--; purged.add(m); resends.add(candidate); } } if (sequenceCandidates.isEmpty()) { candidates.remove(sid.getValue()); } } LOG.fine("Completed purging resend candidates."); } if (purged.size() > 0) { RMStore store = manager.getStore(); if (null != store) { store.removeMessages(sid, purged, true); } RMEndpoint rmEndpoint = seq.getSource().getReliableEndpoint(); for (ResendCandidate resend : resends) { rmEndpoint.handleAcknowledgment(sid.getValue(), resend.getNumber(), resend.getMessage()); } } }
/** * @param seq the sequence under consideration * @return the list of resend candidates for that sequence * @pre called with mutex held */ protected List<ResendCandidate> getSequenceCandidates(SourceSequence seq) { return getSequenceCandidates(seq.getIdentifier().getValue()); }