CAMEL-8526: Add more EIP as specialized mbeans
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/edb9fd30 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/edb9fd30 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/edb9fd30 Branch: refs/heads/master Commit: edb9fd303831f9477dab5576cd463f56d633165c Parents: 3f3d974 Author: Claus Ibsen <davscl...@apache.org> Authored: Tue Jul 21 17:16:41 2015 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Tue Jul 21 17:16:41 2015 +0200 ---------------------------------------------------------------------- .../mbean/ManagedSamplingThrottlerMBean.java | 32 +++++++++++ .../DefaultManagementObjectStrategy.java | 4 ++ .../mbean/ManagedSamplingThrottler.java | 57 ++++++++++++++++++++ .../camel/processor/SamplingThrottler.java | 12 +++++ 4 files changed, 105 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/edb9fd30/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedSamplingThrottlerMBean.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedSamplingThrottlerMBean.java b/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedSamplingThrottlerMBean.java new file mode 100644 index 0000000..9b4b718 --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedSamplingThrottlerMBean.java @@ -0,0 +1,32 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.api.management.mbean; + +import org.apache.camel.api.management.ManagedAttribute; + +public interface ManagedSamplingThrottlerMBean extends ManagedProcessorMBean { + + @ManagedAttribute(description = "The sample period during which only a single Exchange will pass through") + Long getSamplePeriod(); + + @ManagedAttribute(description = "The sample message count which only a single Exchange will pass through after this many received") + Long getMessageFrequency(); + + @ManagedAttribute(description = "The time units for the sample period") + String getTimeUnit(); + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/edb9fd30/camel-core/src/main/java/org/apache/camel/management/DefaultManagementObjectStrategy.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/management/DefaultManagementObjectStrategy.java b/camel-core/src/main/java/org/apache/camel/management/DefaultManagementObjectStrategy.java index 661f914..bc1686d 100644 --- a/camel-core/src/main/java/org/apache/camel/management/DefaultManagementObjectStrategy.java +++ b/camel-core/src/main/java/org/apache/camel/management/DefaultManagementObjectStrategy.java @@ -55,6 +55,7 @@ import org.apache.camel.management.mbean.ManagedRecipientList; import org.apache.camel.management.mbean.ManagedResequencer; import org.apache.camel.management.mbean.ManagedRoute; import org.apache.camel.management.mbean.ManagedRoutingSlip; +import org.apache.camel.management.mbean.ManagedSamplingThrottler; import org.apache.camel.management.mbean.ManagedScheduledPollConsumer; import org.apache.camel.management.mbean.ManagedSendDynamicProcessor; import org.apache.camel.management.mbean.ManagedSendProcessor; @@ -80,6 +81,7 @@ import org.apache.camel.processor.PollEnricher; import org.apache.camel.processor.RecipientList; import org.apache.camel.processor.Resequencer; import org.apache.camel.processor.RoutingSlip; +import org.apache.camel.processor.SamplingThrottler; import org.apache.camel.processor.SendDynamicProcessor; import org.apache.camel.processor.SendProcessor; import org.apache.camel.processor.StreamResequencer; @@ -229,6 +231,8 @@ public class DefaultManagementObjectStrategy implements ManagementObjectStrategy answer = new ManagedRecipientList(context, (RecipientList) target, definition); } else if (target instanceof MulticastProcessor) { answer = new ManagedMulticast(context, (MulticastProcessor) target, definition); + } else if (target instanceof SamplingThrottler) { + answer = new ManagedSamplingThrottler(context, (SamplingThrottler) target, definition); } else if (target instanceof Resequencer) { answer = new ManagedResequencer(context, (Resequencer) target, definition); } else if (target instanceof StreamResequencer) { http://git-wip-us.apache.org/repos/asf/camel/blob/edb9fd30/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedSamplingThrottler.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedSamplingThrottler.java b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedSamplingThrottler.java new file mode 100644 index 0000000..5e5cac8 --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedSamplingThrottler.java @@ -0,0 +1,57 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.management.mbean; + +import java.util.Locale; + +import org.apache.camel.CamelContext; +import org.apache.camel.api.management.ManagedResource; +import org.apache.camel.api.management.mbean.ManagedSamplingThrottlerMBean; +import org.apache.camel.model.ProcessorDefinition; +import org.apache.camel.processor.SamplingThrottler; + +/** + * @version + */ +@ManagedResource(description = "Managed SamplingThrottler") +public class ManagedSamplingThrottler extends ManagedProcessor implements ManagedSamplingThrottlerMBean { + private final SamplingThrottler processor; + + public ManagedSamplingThrottler(CamelContext context, SamplingThrottler processor, ProcessorDefinition<?> definition) { + super(context, processor, definition); + this.processor = processor; + } + + @Override + public Long getSamplePeriod() { + return processor.getSamplePeriod(); + } + + @Override + public Long getMessageFrequency() { + return processor.getMessageFrequency(); + } + + @Override + public String getTimeUnit() { + if (processor.getUnits() != null) { + return processor.getUnits().toString().toLowerCase(Locale.ENGLISH); + } else { + return null; + } + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/edb9fd30/camel-core/src/main/java/org/apache/camel/processor/SamplingThrottler.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/processor/SamplingThrottler.java b/camel-core/src/main/java/org/apache/camel/processor/SamplingThrottler.java index 661646c..9d6bbfe 100644 --- a/camel-core/src/main/java/org/apache/camel/processor/SamplingThrottler.java +++ b/camel-core/src/main/java/org/apache/camel/processor/SamplingThrottler.java @@ -102,6 +102,18 @@ public class SamplingThrottler extends DelegateAsyncProcessor implements Traceab } } + public long getMessageFrequency() { + return messageFrequency; + } + + public long getSamplePeriod() { + return samplePeriod; + } + + public TimeUnit getUnits() { + return units; + } + @Override public boolean process(Exchange exchange, AsyncCallback callback) { boolean doSend = false;