public void abortConsumer(ObjectName consumerToAbort) { Subscription sub = broker.getSubscriber(consumerToAbort); if (sub != null) { LOG.info("aborting consumer via jmx: {}", sub.getConsumerInfo().getConsumerId()); strategy.abortConsumer(sub, false); } else { LOG.warn("cannot resolve subscription matching name: {}", consumerToAbort); } }
@Override public void run() { if (maxSlowDuration > 0) { // mark for (SlowConsumerEntry entry : slowConsumers.values()) { entry.mark(); } } HashMap<Subscription, SlowConsumerEntry> toAbort = new HashMap<Subscription, SlowConsumerEntry>(); for (Entry<Subscription, SlowConsumerEntry> entry : slowConsumers.entrySet()) { Subscription subscription = entry.getKey(); if (isIgnoreNetworkSubscriptions() && subscription.getConsumerInfo().isNetworkSubscription()) { if (slowConsumers.remove(subscription) != null) { LOG.info("network sub: {} is no longer slow", subscription.getConsumerInfo().getConsumerId()); } continue; } if (entry.getKey().isSlowConsumer()) { if (maxSlowDuration > 0 && (entry.getValue().markCount * checkPeriod >= maxSlowDuration) || maxSlowCount > 0 && entry.getValue().slowCount >= maxSlowCount) { toAbort.put(entry.getKey(), entry.getValue()); slowConsumers.remove(entry.getKey()); } } else { LOG.info("sub: " + entry.getKey().getConsumerInfo().getConsumerId() + " is no longer slow"); slowConsumers.remove(entry.getKey()); } } abortSubscription(toAbort, abortConnection); }
public long getCheckPeriod() { return strategy.getCheckPeriod(); }
public void abortConsumer(Subscription sub, boolean abortSubscriberConnection) { if (sub != null) { SlowConsumerEntry entry = slowConsumers.remove(sub); if (entry != null) { Map<Subscription, SlowConsumerEntry> toAbort = new HashMap<Subscription, SlowConsumerEntry>(); toAbort.put(sub, entry); abortSubscription(toAbort, abortSubscriberConnection); } else { LOG.warn("cannot abort subscription as it no longer exists in the map of slow consumers: " + sub); } } }
public static ObjectName createAbortSlowConsumerStrategyName(String brokerObjectName, AbortSlowConsumerStrategy strategy) throws MalformedObjectNameException { String objectNameStr = brokerObjectName; objectNameStr += ",service=SlowConsumerStrategy,instanceName="+ JMXSupport.encodeObjectNamePart(strategy.getName()); ObjectName objectName = new ObjectName(objectNameStr); return objectName; }
public long getMaxSlowDuration() { return strategy.getMaxSlowDuration(); }
public void setMaxSlowCount(long maxSlowCount) { strategy.setMaxSlowCount(maxSlowCount); }
public TabularData getSlowConsumers() throws OpenDataException { OpenTypeSupport.OpenTypeFactory factory = OpenTypeSupport.getFactory(SlowConsumerEntry.class); CompositeType ct = factory.getCompositeType(); TabularType tt = new TabularType("SlowConsumers", "Table of current slow Consumers", ct, new String[] {"subscription" }); TabularDataSupport rc = new TabularDataSupport(tt); int index = 0; Map<Subscription, SlowConsumerEntry> slowConsumers = strategy.getSlowConsumers(); for (Map.Entry<Subscription, SlowConsumerEntry> entry : slowConsumers.entrySet()) { entry.getValue().setSubscription(broker.getSubscriberObjectName(entry.getKey())); rc.put(OpenTypeSupport.convert(entry.getValue())); } return rc; }
public void setMaxSlowDuration(long maxSlowDuration) { strategy.setMaxSlowDuration(maxSlowDuration); }
public long getMaxSlowCount() { return strategy.getMaxSlowCount(); }
public void abortConsumer(Subscription sub, boolean abortSubscriberConnection) { if (sub != null) { SlowConsumerEntry entry = slowConsumers.remove(sub); if (entry != null) { Map<Subscription, SlowConsumerEntry> toAbort = new HashMap<Subscription, SlowConsumerEntry>(); toAbort.put(sub, entry); abortSubscription(toAbort, abortSubscriberConnection); } else { LOG.warn("cannot abort subscription as it no longer exists in the map of slow consumers: " + sub); } } }
public static ObjectName createAbortSlowConsumerStrategyName(String brokerObjectName, AbortSlowConsumerStrategy strategy) throws MalformedObjectNameException { String objectNameStr = brokerObjectName; objectNameStr += ",service=SlowConsumerStrategy,instanceName="+ JMXSupport.encodeObjectNamePart(strategy.getName()); ObjectName objectName = new ObjectName(objectNameStr); return objectName; }
public long getMaxSlowDuration() { return strategy.getMaxSlowDuration(); }
public void setMaxSlowCount(long maxSlowCount) { strategy.setMaxSlowCount(maxSlowCount); }
public TabularData getSlowConsumers() throws OpenDataException { OpenTypeSupport.OpenTypeFactory factory = OpenTypeSupport.getFactory(SlowConsumerEntry.class); CompositeType ct = factory.getCompositeType(); TabularType tt = new TabularType("SlowConsumers", "Table of current slow Consumers", ct, new String[] {"subscription" }); TabularDataSupport rc = new TabularDataSupport(tt); int index = 0; Map<Subscription, SlowConsumerEntry> slowConsumers = strategy.getSlowConsumers(); for (Map.Entry<Subscription, SlowConsumerEntry> entry : slowConsumers.entrySet()) { entry.getValue().setSubscription(broker.getSubscriberObjectName(entry.getKey())); rc.put(OpenTypeSupport.convert(entry.getValue())); } return rc; }
public void setMaxSlowDuration(long maxSlowDuration) { strategy.setMaxSlowDuration(maxSlowDuration); }
public long getMaxSlowCount() { return strategy.getMaxSlowCount(); }
@Override public void run() { if (maxSlowDuration > 0) { // mark for (SlowConsumerEntry entry : slowConsumers.values()) { entry.mark(); } } HashMap<Subscription, SlowConsumerEntry> toAbort = new HashMap<Subscription, SlowConsumerEntry>(); for (Entry<Subscription, SlowConsumerEntry> entry : slowConsumers.entrySet()) { Subscription subscription = entry.getKey(); if (isIgnoreNetworkSubscriptions() && subscription.getConsumerInfo().isNetworkSubscription()) { if (slowConsumers.remove(subscription) != null) { LOG.info("network sub: {} is no longer slow", subscription.getConsumerInfo().getConsumerId()); } continue; } if (entry.getKey().isSlowConsumer()) { if (maxSlowDuration > 0 && (entry.getValue().markCount * checkPeriod >= maxSlowDuration) || maxSlowCount > 0 && entry.getValue().slowCount >= maxSlowCount) { toAbort.put(entry.getKey(), entry.getValue()); slowConsumers.remove(entry.getKey()); } } else { LOG.info("sub: " + entry.getKey().getConsumerInfo().getConsumerId() + " is no longer slow"); slowConsumers.remove(entry.getKey()); } } abortSubscription(toAbort, abortConnection); }
public void abortConnection(ObjectName consumerToAbort) { Subscription sub = broker.getSubscriber(consumerToAbort); if (sub != null) { LOG.info("aborting consumer connection via jmx: {}", sub.getConsumerInfo().getConsumerId().getConnectionId()); strategy.abortConsumer(sub, true); } else { LOG.warn("cannot resolve subscription matching name: {}", consumerToAbort); } }
public void abortConsumer(Subscription sub, boolean abortSubscriberConnection) { if (sub != null) { SlowConsumerEntry entry = slowConsumers.remove(sub); if (entry != null) { Map toAbort = new HashMap<Subscription, SlowConsumerEntry>(); toAbort.put(sub, entry); abortSubscription(toAbort, abortSubscriberConnection); } else { LOG.warn("cannot abort subscription as it no longer exists in the map of slow consumers: " + sub); } } }