if (getMaxSlowDuration() > 0) { updateSlowConsumersList(subscribers); abortAllQualifiedSlowConsumers();
private void abortAllQualifiedSlowConsumers() { HashMap<Subscription, SlowConsumerEntry> toAbort = new HashMap<Subscription, SlowConsumerEntry>(); for (Entry<Subscription, SlowConsumerEntry> entry : slowConsumers.entrySet()) { if (getMaxSlowDuration() > 0 && (entry.getValue().markCount * getCheckPeriod() >= getMaxSlowDuration()) || getMaxSlowCount() > 0 && entry.getValue().slowCount >= getMaxSlowCount()) { LOG.trace("Transferring consumer{} to the abort list: {} slow duration = {}, slow count = {}", new Object[]{ entry.getKey().getConsumerInfo().getConsumerId(), entry.getValue().markCount * getCheckPeriod(), entry.getValue().getSlowCount() }); toAbort.put(entry.getKey(), entry.getValue()); slowConsumers.remove(entry.getKey()); } else { LOG.trace("Not yet time to abort consumer {}: slow duration = {}, slow count = {}", new Object[]{ entry.getKey().getConsumerInfo().getConsumerId(), entry.getValue().markCount * getCheckPeriod(), entry.getValue().slowCount }); } } // Now if any subscriptions made it into the aborts list we can kick them. abortSubscription(toAbort, isAbortConnection()); }
@Override public long getMaxTimeSinceLastAck() { return strategy.getMaxTimeSinceLastAck(); }
private void updateSlowConsumersList(List<Subscription> subscribers) { for (Subscription subscriber : subscribers) { if (isIgnoreNetworkSubscriptions() && subscriber.getConsumerInfo().isNetworkSubscription()) { if (slowConsumers.remove(subscriber) != null) { LOG.info("network sub: {} is no longer slow", subscriber.getConsumerInfo().getConsumerId()); if (isIgnoreIdleConsumers() && subscriber.getDispatchedQueueSize() == 0) { } else if (getMaxSlowCount() > 0) { slowConsumers.get(subscriber).slow();
@Override public void setBrokerService(Broker broker) { super.setBrokerService(broker); // Task starts right away since we may not receive any slow consumer events. if (taskStarted.compareAndSet(false, true)) { scheduler.executePeriodically(this, getCheckPeriod()); } }
@Override public boolean isIgnoreNetworkConsumers() { return this.strategy.isIgnoreNetworkSubscriptions(); }
@Override public void setIgnoreIdleConsumers(boolean ignoreIdleConsumers) { this.strategy.setIgnoreIdleConsumers(ignoreIdleConsumers); }
@Override public boolean isIgnoreIdleConsumers() { return strategy.isIgnoreIdleConsumers(); }
private void updateSlowConsumersList(List<Subscription> subscribers) { for (Subscription subscriber : subscribers) { if (isIgnoreNetworkSubscriptions() && subscriber.getConsumerInfo().isNetworkSubscription()) { if (slowConsumers.remove(subscriber) != null) { LOG.info("network sub: {} is no longer slow", subscriber.getConsumerInfo().getConsumerId()); if (isIgnoreIdleConsumers() && subscriber.getDispatchedQueueSize() == 0) { } else if (getMaxSlowCount() > 0) { slowConsumers.get(subscriber).slow();
@Override public void setBrokerService(Broker broker) { super.setBrokerService(broker); // Task starts right away since we may not receive any slow consumer events. if (taskStarted.compareAndSet(false, true)) { scheduler.executePeriodically(this, getCheckPeriod()); } }
@Override public boolean isIgnoreNetworkConsumers() { return this.strategy.isIgnoreNetworkSubscriptions(); }
@Override public void setIgnoreIdleConsumers(boolean ignoreIdleConsumers) { this.strategy.setIgnoreIdleConsumers(ignoreIdleConsumers); }
@Override public boolean isIgnoreIdleConsumers() { return strategy.isIgnoreIdleConsumers(); }
private void abortAllQualifiedSlowConsumers() { HashMap<Subscription, SlowConsumerEntry> toAbort = new HashMap<Subscription, SlowConsumerEntry>(); for (Entry<Subscription, SlowConsumerEntry> entry : slowConsumers.entrySet()) { if (getMaxSlowDuration() > 0 && (entry.getValue().markCount * getCheckPeriod() >= getMaxSlowDuration()) || getMaxSlowCount() > 0 && entry.getValue().slowCount >= getMaxSlowCount()) { LOG.trace("Transferring consumer{} to the abort list: {} slow duration = {}, slow count = {}", new Object[]{ entry.getKey().getConsumerInfo().getConsumerId(), entry.getValue().markCount * getCheckPeriod(), entry.getValue().getSlowCount() }); toAbort.put(entry.getKey(), entry.getValue()); slowConsumers.remove(entry.getKey()); } else { LOG.trace("Not yet time to abort consumer {}: slow duration = {}, slow count = {}", new Object[]{ entry.getKey().getConsumerInfo().getConsumerId(), entry.getValue().markCount * getCheckPeriod(), entry.getValue().slowCount }); } } // Now if any subscriptions made it into the aborts list we can kick them. abortSubscription(toAbort, isAbortConnection()); }
@Override public void run() { if (maxTimeSinceLastAck < 0) { // nothing to do LOG.info("no limit set, slowConsumer strategy has nothing to do"); return; } if (getMaxSlowDuration() > 0) { // For subscriptions that are already slow we mark them again and check below if // they've exceeded their configured lifetime. for (SlowConsumerEntry entry : slowConsumers.values()) { entry.mark(); } } List<Destination> disposed = new ArrayList<Destination>(); for (Destination destination : destinations.values()) { if (destination.isDisposed()) { disposed.add(destination); continue; } // Not explicitly documented but this returns a stable copy. List<Subscription> subscribers = destination.getConsumers(); updateSlowConsumersList(subscribers); } // Clean up an disposed destinations to save space. for (Destination destination : disposed) { destinations.remove(destination.getName()); } abortAllQualifiedSlowConsumers(); }
private void updateSlowConsumersList(List<Subscription> subscribers) { for (Subscription subscriber : subscribers) { if (isIgnoreNetworkSubscriptions() && subscriber.getConsumerInfo().isNetworkSubscription()) { if (slowConsumers.remove(subscriber) != null) { LOG.info("network sub: {} is no longer slow", subscriber.getConsumerInfo().getConsumerId()); if (isIgnoreIdleConsumers() && subscriber.getDispatchedQueueSize() == 0) { } else if (getMaxSlowCount() > 0) { slowConsumers.get(subscriber).slow();
@Override public void setBrokerService(Broker broker) { super.setBrokerService(broker); // Task starts right away since we may not receive any slow consumer events. if (taskStarted.compareAndSet(false, true)) { scheduler.executePeriodically(this, getCheckPeriod()); } }
@Override public boolean isIgnoreNetworkConsumers() { return this.strategy.isIgnoreNetworkSubscriptions(); }
@Override public long getMaxTimeSinceLastAck() { return strategy.getMaxTimeSinceLastAck(); }
@Override public void setIgnoreIdleConsumers(boolean ignoreIdleConsumers) { this.strategy.setIgnoreIdleConsumers(ignoreIdleConsumers); }