You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2009/06/02 23:29:35 UTC
svn commit: r781177 [10/11] - in /activemq/sandbox/activemq-flow:
activemq-bio/ activemq-bio/src/main/java/org/
activemq-bio/src/main/java/org/apache/
activemq-bio/src/main/java/org/apache/activemq/
activemq-bio/src/main/java/org/apache/activemq/transp...
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/advisory/ProducerListener.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/advisory/ProducerListener.java?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/advisory/ProducerListener.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/advisory/ProducerListener.java Tue Jun 2 21:29:30 2009
@@ -0,0 +1,27 @@
+/**
+ * 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.activemq.advisory;
+
+/**
+ * Listen to the changes in the number of active consumers available for a given destination.
+ *
+ * @version $Revision: 359679 $
+ */
+public interface ProducerListener {
+
+ void onProducerEvent(ProducerEvent event);
+}
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/advisory/ProducerStartedEvent.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/advisory/ProducerStartedEvent.java?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/advisory/ProducerStartedEvent.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/advisory/ProducerStartedEvent.java Tue Jun 2 21:29:30 2009
@@ -0,0 +1,48 @@
+/**
+ * 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.activemq.advisory;
+
+import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.activemq.command.ProducerInfo;
+
+/**
+ * An event when a new consumer has started.
+ *
+ * @version $Revision: 359679 $
+ */
+public class ProducerStartedEvent extends ProducerEvent {
+
+ private static final long serialVersionUID = 5088138839609391074L;
+
+ private final transient ProducerInfo consumerInfo;
+
+ public ProducerStartedEvent(ProducerEventSource source, ActiveMQDestination destination, ProducerInfo consumerInfo, int count) {
+ super(source, destination, consumerInfo.getProducerId(), count);
+ this.consumerInfo = consumerInfo;
+ }
+
+ public boolean isStarted() {
+ return true;
+ }
+
+ /**
+ * @return details of the subscription
+ */
+ public ProducerInfo getProducerInfo() {
+ return consumerInfo;
+ }
+}
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/advisory/ProducerStoppedEvent.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/advisory/ProducerStoppedEvent.java?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/advisory/ProducerStoppedEvent.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/advisory/ProducerStoppedEvent.java Tue Jun 2 21:29:30 2009
@@ -0,0 +1,39 @@
+/**
+ * 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.activemq.advisory;
+
+import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.activemq.command.ProducerId;
+
+/**
+ * An event generated when a consumer stops.
+ *
+ * @version $Revision: 359679 $
+ */
+public class ProducerStoppedEvent extends ProducerEvent {
+
+ private static final long serialVersionUID = 5378835541037193206L;
+
+ public ProducerStoppedEvent(ProducerEventSource source, ActiveMQDestination destination, ProducerId consumerId, int count) {
+ super(source, destination, consumerId, count);
+ }
+
+ public boolean isStarted() {
+ return false;
+ }
+
+}
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/advisory/package.html
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/advisory/package.html?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/advisory/package.html (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/advisory/package.html Tue Jun 2 21:29:30 2009
@@ -0,0 +1,25 @@
+<!--
+ 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.
+-->
+<html>
+<head>
+</head>
+<body>
+
+Support for JMS Advisory messages as well as some helper listeners to listen to the clients, producers and consumers available.
+
+</body>
+</html>
Propchange: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/advisory/package.html
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/BoundaryStatisticImpl.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/BoundaryStatisticImpl.java?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/BoundaryStatisticImpl.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/BoundaryStatisticImpl.java Tue Jun 2 21:29:30 2009
@@ -0,0 +1,50 @@
+/**
+ * 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.activemq.management;
+
+
+/**
+ * A boundary statistic implementation
+ *
+ * @version $Revision: 1.2 $
+ */
+public class BoundaryStatisticImpl extends StatisticImpl {
+ private long lowerBound;
+ private long upperBound;
+
+ public BoundaryStatisticImpl(String name, String unit, String description, long lowerBound, long upperBound) {
+ super(name, unit, description);
+ this.lowerBound = lowerBound;
+ this.upperBound = upperBound;
+ }
+
+ public long getLowerBound() {
+ return lowerBound;
+ }
+
+ public long getUpperBound() {
+ return upperBound;
+ }
+
+ protected void appendFieldDescription(StringBuffer buffer) {
+ buffer.append(" lowerBound: ");
+ buffer.append(Long.toString(lowerBound));
+ buffer.append(" upperBound: ");
+ buffer.append(Long.toString(upperBound));
+ super.appendFieldDescription(buffer);
+ }
+}
Propchange: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/BoundaryStatisticImpl.java
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/BoundedRangeStatisticImpl.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/BoundedRangeStatisticImpl.java?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/BoundedRangeStatisticImpl.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/BoundedRangeStatisticImpl.java Tue Jun 2 21:29:30 2009
@@ -0,0 +1,50 @@
+/**
+ * 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.activemq.management;
+
+
+/**
+ * A bounded range statistic implementation
+ *
+ * @version $Revision: 1.2 $
+ */
+public class BoundedRangeStatisticImpl extends RangeStatisticImpl {
+ private long lowerBound;
+ private long upperBound;
+
+ public BoundedRangeStatisticImpl(String name, String unit, String description, long lowerBound, long upperBound) {
+ super(name, unit, description);
+ this.lowerBound = lowerBound;
+ this.upperBound = upperBound;
+ }
+
+ public long getLowerBound() {
+ return lowerBound;
+ }
+
+ public long getUpperBound() {
+ return upperBound;
+ }
+
+ protected void appendFieldDescription(StringBuffer buffer) {
+ buffer.append(" lowerBound: ");
+ buffer.append(Long.toString(lowerBound));
+ buffer.append(" upperBound: ");
+ buffer.append(Long.toString(upperBound));
+ super.appendFieldDescription(buffer);
+ }
+}
Propchange: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/BoundedRangeStatisticImpl.java
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/CountStatisticImpl.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/CountStatisticImpl.java?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/CountStatisticImpl.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/CountStatisticImpl.java Tue Jun 2 21:29:30 2009
@@ -0,0 +1,140 @@
+/**
+ * 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.activemq.management;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+import javax.management.j2ee.statistics.CountStatistic;
+
+/**
+ * A count statistic implementation
+ *
+ * @version $Revision: 1.3 $
+ */
+public class CountStatisticImpl extends StatisticImpl implements CountStatistic {
+
+ private final AtomicLong counter = new AtomicLong(0);
+ private CountStatisticImpl parent;
+
+ public CountStatisticImpl(CountStatisticImpl parent, String name, String description) {
+ this(name, description);
+ this.parent = parent;
+ }
+
+ public CountStatisticImpl(String name, String description) {
+ this(name, "count", description);
+ }
+
+ public CountStatisticImpl(String name, String unit, String description) {
+ super(name, unit, description);
+ }
+
+ public void reset() {
+ if (isDoReset()) {
+ super.reset();
+ counter.set(0);
+ }
+ }
+
+ public long getCount() {
+ return counter.get();
+ }
+
+ public void setCount(long count) {
+ if (isEnabled()) {
+ counter.set(count);
+ }
+ }
+
+ public void add(long amount) {
+ if (isEnabled()) {
+ counter.addAndGet(amount);
+ updateSampleTime();
+ if (parent != null) {
+ parent.add(amount);
+ }
+ }
+ }
+
+ public void increment() {
+ if (isEnabled()) {
+ counter.incrementAndGet();
+ updateSampleTime();
+ if (parent != null) {
+ parent.increment();
+ }
+ }
+ }
+
+ public void subtract(long amount) {
+ if (isEnabled()) {
+ counter.addAndGet(-amount);
+ updateSampleTime();
+ if (parent != null) {
+ parent.subtract(amount);
+ }
+ }
+ }
+
+ public void decrement() {
+ if (isEnabled()) {
+ counter.decrementAndGet();
+ updateSampleTime();
+ if (parent != null) {
+ parent.decrement();
+ }
+ }
+ }
+
+ public CountStatisticImpl getParent() {
+ return parent;
+ }
+
+ public void setParent(CountStatisticImpl parent) {
+ this.parent = parent;
+ }
+
+ protected void appendFieldDescription(StringBuffer buffer) {
+ buffer.append(" count: ");
+ buffer.append(Long.toString(counter.get()));
+ super.appendFieldDescription(buffer);
+ }
+
+ /**
+ * @return the average time period that elapses between counter increments
+ * since the last reset.
+ */
+ public double getPeriod() {
+ double count = counter.get();
+ if (count == 0) {
+ return 0;
+ }
+ double time = System.currentTimeMillis() - getStartTime();
+ return time / (count * 1000.0);
+ }
+
+ /**
+ * @return the number of times per second that the counter is incrementing
+ * since the last reset.
+ */
+ public double getFrequency() {
+ double count = counter.get();
+ double time = System.currentTimeMillis() - getStartTime();
+ return count * 1000.0 / time;
+ }
+
+}
Propchange: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/CountStatisticImpl.java
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JCAConnectionPoolStatsImpl.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JCAConnectionPoolStatsImpl.java?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JCAConnectionPoolStatsImpl.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JCAConnectionPoolStatsImpl.java Tue Jun 2 21:29:30 2009
@@ -0,0 +1,67 @@
+/**
+ * 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.activemq.management;
+
+/**
+ * Statistics for a JCA connection pool
+ *
+ * @version $Revision: 1.2 $
+ */
+public class JCAConnectionPoolStatsImpl extends JCAConnectionStatsImpl {
+ private CountStatisticImpl closeCount;
+ private CountStatisticImpl createCount;
+ private BoundedRangeStatisticImpl freePoolSize;
+ private BoundedRangeStatisticImpl poolSize;
+ private RangeStatisticImpl waitingThreadCount;
+
+ public JCAConnectionPoolStatsImpl(String connectionFactory, String managedConnectionFactory, TimeStatisticImpl waitTime, TimeStatisticImpl useTime,
+ CountStatisticImpl closeCount, CountStatisticImpl createCount, BoundedRangeStatisticImpl freePoolSize, BoundedRangeStatisticImpl poolSize,
+ RangeStatisticImpl waitingThreadCount) {
+ super(connectionFactory, managedConnectionFactory, waitTime, useTime);
+ this.closeCount = closeCount;
+ this.createCount = createCount;
+ this.freePoolSize = freePoolSize;
+ this.poolSize = poolSize;
+ this.waitingThreadCount = waitingThreadCount;
+
+ // lets add named stats
+ addStatistic("freePoolSize", freePoolSize);
+ addStatistic("poolSize", poolSize);
+ addStatistic("waitingThreadCount", waitingThreadCount);
+ }
+
+ public CountStatisticImpl getCloseCount() {
+ return closeCount;
+ }
+
+ public CountStatisticImpl getCreateCount() {
+ return createCount;
+ }
+
+ public BoundedRangeStatisticImpl getFreePoolSize() {
+ return freePoolSize;
+ }
+
+ public BoundedRangeStatisticImpl getPoolSize() {
+ return poolSize;
+ }
+
+ public RangeStatisticImpl getWaitingThreadCount() {
+ return waitingThreadCount;
+ }
+
+}
Propchange: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JCAConnectionPoolStatsImpl.java
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JCAConnectionStatsImpl.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JCAConnectionStatsImpl.java?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JCAConnectionStatsImpl.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JCAConnectionStatsImpl.java Tue Jun 2 21:29:30 2009
@@ -0,0 +1,58 @@
+/**
+ * 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.activemq.management;
+
+
+/**
+ * Statistics for a JCA connection
+ *
+ * @version $Revision: 1.2 $
+ */
+public class JCAConnectionStatsImpl extends StatsImpl {
+ private String connectionFactory;
+ private String managedConnectionFactory;
+ private TimeStatisticImpl waitTime;
+ private TimeStatisticImpl useTime;
+
+ public JCAConnectionStatsImpl(String connectionFactory, String managedConnectionFactory, TimeStatisticImpl waitTime, TimeStatisticImpl useTime) {
+ this.connectionFactory = connectionFactory;
+ this.managedConnectionFactory = managedConnectionFactory;
+ this.waitTime = waitTime;
+ this.useTime = useTime;
+
+ // lets add named stats
+ addStatistic("waitTime", waitTime);
+ addStatistic("useTime", useTime);
+ }
+
+ public String getConnectionFactory() {
+ return connectionFactory;
+ }
+
+ public String getManagedConnectionFactory() {
+ return managedConnectionFactory;
+ }
+
+ public TimeStatisticImpl getWaitTime() {
+ return waitTime;
+ }
+
+ public TimeStatisticImpl getUseTime() {
+ return useTime;
+ }
+
+}
Propchange: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JCAConnectionStatsImpl.java
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JCAStatsImpl.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JCAStatsImpl.java?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JCAStatsImpl.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JCAStatsImpl.java Tue Jun 2 21:29:30 2009
@@ -0,0 +1,43 @@
+/**
+ * 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.activemq.management;
+
+
+/**
+ * Statistics for a number of JCA connections and connection pools
+ *
+ * @version $Revision: 1.2 $
+ */
+public class JCAStatsImpl extends StatsImpl {
+ private JCAConnectionStatsImpl[] connectionStats;
+ private JCAConnectionPoolStatsImpl[] connectionPoolStats;
+
+ public JCAStatsImpl(JCAConnectionStatsImpl[] connectionStats, JCAConnectionPoolStatsImpl[] connectionPoolStats) {
+ this.connectionStats = connectionStats;
+ this.connectionPoolStats = connectionPoolStats;
+ }
+
+ public JCAConnectionStatsImpl[] getConnections() {
+ return connectionStats;
+ }
+
+ public JCAConnectionPoolStatsImpl[] getConnectionPools() {
+ return connectionPoolStats;
+ }
+
+
+}
Propchange: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JCAStatsImpl.java
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSConnectionStatsImpl.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSConnectionStatsImpl.java?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSConnectionStatsImpl.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSConnectionStatsImpl.java Tue Jun 2 21:29:30 2009
@@ -0,0 +1,111 @@
+/**
+ * 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.activemq.management;
+
+import java.util.List;
+
+import org.apache.activemq.ActiveMQSession;
+import org.apache.activemq.util.IndentPrinter;
+
+/**
+ * Statistics for a JMS connection
+ *
+ * @version $Revision: 1.2 $
+ */
+public class JMSConnectionStatsImpl extends StatsImpl {
+ private List sessions;
+ private boolean transactional;
+
+ public JMSConnectionStatsImpl(List sessions, boolean transactional) {
+ this.sessions = sessions;
+ this.transactional = transactional;
+ }
+
+ public JMSSessionStatsImpl[] getSessions() {
+ // lets make a snapshot before we process them
+ Object[] sessionArray = sessions.toArray();
+ int size = sessionArray.length;
+ JMSSessionStatsImpl[] answer = new JMSSessionStatsImpl[size];
+ for (int i = 0; i < size; i++) {
+ ActiveMQSession session = (ActiveMQSession)sessionArray[i];
+ answer[i] = session.getSessionStats();
+ }
+ return answer;
+ }
+
+ public void reset() {
+ super.reset();
+ JMSSessionStatsImpl[] stats = getSessions();
+ int size = stats.length;
+ for (int i = 0; i < size; i++) {
+ stats[i].reset();
+ }
+ }
+
+ /**
+ * @param enabled the enabled to set
+ */
+ public void setEnabled(boolean enabled) {
+ super.setEnabled(enabled);
+ JMSSessionStatsImpl[] stats = getSessions();
+ int size = stats.length;
+ for (int i = 0; i < size; i++) {
+ stats[i].setEnabled(enabled);
+ }
+
+ }
+
+ public boolean isTransactional() {
+ return transactional;
+ }
+
+ public String toString() {
+ StringBuffer buffer = new StringBuffer("connection{ ");
+ JMSSessionStatsImpl[] array = getSessions();
+ for (int i = 0; i < array.length; i++) {
+ if (i > 0) {
+ buffer.append(", ");
+ }
+ buffer.append(Integer.toString(i));
+ buffer.append(" = ");
+ buffer.append(array[i]);
+ }
+ buffer.append(" }");
+ return buffer.toString();
+ }
+
+ public void dump(IndentPrinter out) {
+ out.printIndent();
+ out.println("connection {");
+ out.incrementIndent();
+ JMSSessionStatsImpl[] array = getSessions();
+ for (int i = 0; i < array.length; i++) {
+ JMSSessionStatsImpl sessionStat = (JMSSessionStatsImpl)array[i];
+ out.printIndent();
+ out.println("session {");
+ out.incrementIndent();
+ sessionStat.dump(out);
+ out.decrementIndent();
+ out.printIndent();
+ out.println("}");
+ }
+ out.decrementIndent();
+ out.printIndent();
+ out.println("}");
+ out.flush();
+ }
+}
Propchange: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSConnectionStatsImpl.java
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSConsumerStatsImpl.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSConsumerStatsImpl.java?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSConsumerStatsImpl.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSConsumerStatsImpl.java Tue Jun 2 21:29:30 2009
@@ -0,0 +1,71 @@
+/**
+ * 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.activemq.management;
+
+import javax.jms.Destination;
+
+import org.apache.activemq.util.IndentPrinter;
+
+/**
+ * Statistics for a JMS consumer
+ *
+ * @version $Revision: 1.2 $
+ */
+public class JMSConsumerStatsImpl extends JMSEndpointStatsImpl {
+ private String origin;
+
+ public JMSConsumerStatsImpl(JMSSessionStatsImpl sessionStats, Destination destination) {
+ super(sessionStats);
+ if (destination != null) {
+ this.origin = destination.toString();
+ }
+ }
+
+ public JMSConsumerStatsImpl(CountStatisticImpl messageCount, CountStatisticImpl pendingMessageCount, CountStatisticImpl expiredMessageCount, TimeStatisticImpl messageWaitTime,
+ TimeStatisticImpl messageRateTime, String origin) {
+ super(messageCount, pendingMessageCount, expiredMessageCount, messageWaitTime, messageRateTime);
+ this.origin = origin;
+ }
+
+ public String getOrigin() {
+ return origin;
+ }
+
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("consumer ");
+ buffer.append(origin);
+ buffer.append(" { ");
+ buffer.append(super.toString());
+ buffer.append(" }");
+ return buffer.toString();
+ }
+
+ public void dump(IndentPrinter out) {
+ out.printIndent();
+ out.print("consumer ");
+ out.print(origin);
+ out.println(" {");
+ out.incrementIndent();
+
+ super.dump(out);
+
+ out.decrementIndent();
+ out.printIndent();
+ out.println("}");
+ }
+}
Propchange: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSConsumerStatsImpl.java
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSEndpointStatsImpl.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSEndpointStatsImpl.java?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSEndpointStatsImpl.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSEndpointStatsImpl.java Tue Jun 2 21:29:30 2009
@@ -0,0 +1,183 @@
+/**
+ * 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.activemq.management;
+
+import javax.jms.Destination;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+
+import org.apache.activemq.util.IndentPrinter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Statistics for a JMS endpoint, typically a MessageProducer or MessageConsumer
+ * but this class can also be used to represent statistics on a
+ * {@link Destination} as well.
+ *
+ * @version $Revision: 1.3 $
+ */
+public class JMSEndpointStatsImpl extends StatsImpl {
+ private static final Log LOG = LogFactory.getLog(JMSEndpointStatsImpl.class);
+
+ protected CountStatisticImpl messageCount;
+ protected CountStatisticImpl pendingMessageCount;
+ protected CountStatisticImpl expiredMessageCount;
+ protected TimeStatisticImpl messageWaitTime;
+ protected TimeStatisticImpl messageRateTime;
+
+ /**
+ * This constructor is used to create statistics for a
+ * {@link MessageProducer} or {@link MessageConsumer} as it passes in a
+ * {@link Session} parent statistic.
+ *
+ * @param sessionStats
+ */
+ public JMSEndpointStatsImpl(JMSSessionStatsImpl sessionStats) {
+ this();
+ setParent(messageCount, sessionStats.getMessageCount());
+ setParent(pendingMessageCount, sessionStats.getPendingMessageCount());
+ setParent(expiredMessageCount, sessionStats.getExpiredMessageCount());
+ setParent(messageWaitTime, sessionStats.getMessageWaitTime());
+ setParent(messageRateTime, sessionStats.getMessageRateTime());
+ }
+
+ /**
+ * This constructor is typically used to create a statistics object for a
+ * {@link Destination}
+ */
+ public JMSEndpointStatsImpl() {
+ this(new CountStatisticImpl("messageCount", "Number of messages processed"), new CountStatisticImpl("pendingMessageCount", "Number of pending messages"),
+ new CountStatisticImpl("expiredMessageCount", "Number of expired messages"),
+ new TimeStatisticImpl("messageWaitTime", "Time spent by a message before being delivered"), new TimeStatisticImpl("messageRateTime",
+ "Time taken to process a message (thoughtput rate)"));
+ }
+
+ public JMSEndpointStatsImpl(CountStatisticImpl messageCount, CountStatisticImpl pendingMessageCount, CountStatisticImpl expiredMessageCount, TimeStatisticImpl messageWaitTime,
+ TimeStatisticImpl messageRateTime) {
+ this.messageCount = messageCount;
+ this.pendingMessageCount = pendingMessageCount;
+ this.expiredMessageCount = expiredMessageCount;
+ this.messageWaitTime = messageWaitTime;
+ this.messageRateTime = messageRateTime;
+
+ // lets add named stats
+ addStatistic("messageCount", messageCount);
+ addStatistic("pendingMessageCount", pendingMessageCount);
+ addStatistic("expiredMessageCount", expiredMessageCount);
+ addStatistic("messageWaitTime", messageWaitTime);
+ addStatistic("messageRateTime", messageRateTime);
+ }
+
+ public synchronized void reset() {
+ super.reset();
+ messageCount.reset();
+ messageRateTime.reset();
+ pendingMessageCount.reset();
+ expiredMessageCount.reset();
+ messageWaitTime.reset();
+ }
+
+ public CountStatisticImpl getMessageCount() {
+ return messageCount;
+ }
+
+ public CountStatisticImpl getPendingMessageCount() {
+ return pendingMessageCount;
+ }
+
+ public CountStatisticImpl getExpiredMessageCount() {
+ return expiredMessageCount;
+ }
+
+ public TimeStatisticImpl getMessageRateTime() {
+ return messageRateTime;
+ }
+
+ public TimeStatisticImpl getMessageWaitTime() {
+ return messageWaitTime;
+ }
+
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(messageCount);
+ buffer.append(" ");
+ buffer.append(messageRateTime);
+ buffer.append(" ");
+ buffer.append(pendingMessageCount);
+ buffer.append(" ");
+ buffer.append(expiredMessageCount);
+ buffer.append(" ");
+ buffer.append(messageWaitTime);
+ return buffer.toString();
+ }
+
+ public void onMessage() {
+ if (enabled) {
+ long start = messageCount.getLastSampleTime();
+ messageCount.increment();
+ long end = messageCount.getLastSampleTime();
+ messageRateTime.addTime(end - start);
+ }
+ }
+
+ @Override
+ public void setEnabled(boolean enabled) {
+ super.setEnabled(enabled);
+ messageCount.setEnabled(enabled);
+ messageRateTime.setEnabled(enabled);
+ pendingMessageCount.setEnabled(enabled);
+ expiredMessageCount.setEnabled(enabled);
+ messageWaitTime.setEnabled(enabled);
+ }
+
+ public void dump(IndentPrinter out) {
+ out.printIndent();
+ out.println(messageCount);
+ out.printIndent();
+ out.println(messageRateTime);
+ out.printIndent();
+ out.println(pendingMessageCount);
+ out.printIndent();
+ out.println(messageRateTime);
+ out.printIndent();
+ out.println(expiredMessageCount);
+ out.printIndent();
+ out.println(messageWaitTime);
+ }
+
+ // Implementation methods
+ // -------------------------------------------------------------------------
+ protected void setParent(CountStatisticImpl child, CountStatisticImpl parent) {
+ if (child instanceof CountStatisticImpl && parent instanceof CountStatisticImpl) {
+ CountStatisticImpl c = (CountStatisticImpl)child;
+ c.setParent((CountStatisticImpl)parent);
+ } else {
+ LOG.warn("Cannot associate endpoint counters with session level counters as they are not both CountStatisticImpl clases. Endpoint: " + child + " session: " + parent);
+ }
+ }
+
+ protected void setParent(TimeStatisticImpl child, TimeStatisticImpl parent) {
+ if (child instanceof TimeStatisticImpl && parent instanceof TimeStatisticImpl) {
+ TimeStatisticImpl c = (TimeStatisticImpl)child;
+ c.setParent((TimeStatisticImpl)parent);
+ } else {
+ LOG.warn("Cannot associate endpoint counters with session level counters as they are not both TimeStatisticImpl clases. Endpoint: " + child + " session: " + parent);
+ }
+ }
+}
Propchange: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSEndpointStatsImpl.java
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSProducerStatsImpl.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSProducerStatsImpl.java?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSProducerStatsImpl.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSProducerStatsImpl.java Tue Jun 2 21:29:30 2009
@@ -0,0 +1,71 @@
+/**
+ * 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.activemq.management;
+
+import javax.jms.Destination;
+
+import org.apache.activemq.util.IndentPrinter;
+
+/**
+ * Statistics for a JMS producer
+ *
+ * @version $Revision: 1.2 $
+ */
+public class JMSProducerStatsImpl extends JMSEndpointStatsImpl {
+ private String destination;
+
+ public JMSProducerStatsImpl(JMSSessionStatsImpl sessionStats, Destination destination) {
+ super(sessionStats);
+ if (destination != null) {
+ this.destination = destination.toString();
+ }
+ }
+
+ public JMSProducerStatsImpl(CountStatisticImpl messageCount, CountStatisticImpl pendingMessageCount, CountStatisticImpl expiredMessageCount, TimeStatisticImpl messageWaitTime,
+ TimeStatisticImpl messageRateTime, String destination) {
+ super(messageCount, pendingMessageCount, expiredMessageCount, messageWaitTime, messageRateTime);
+ this.destination = destination;
+ }
+
+ public String getDestination() {
+ return destination;
+ }
+
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("producer ");
+ buffer.append(destination);
+ buffer.append(" { ");
+ buffer.append(super.toString());
+ buffer.append(" }");
+ return buffer.toString();
+ }
+
+ public void dump(IndentPrinter out) {
+ out.printIndent();
+ out.print("producer ");
+ out.print(destination);
+ out.println(" {");
+ out.incrementIndent();
+
+ super.dump(out);
+
+ out.decrementIndent();
+ out.printIndent();
+ out.println("}");
+ }
+}
Propchange: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSProducerStatsImpl.java
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSSessionStatsImpl.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSSessionStatsImpl.java?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSSessionStatsImpl.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSSessionStatsImpl.java Tue Jun 2 21:29:30 2009
@@ -0,0 +1,230 @@
+/**
+ * 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.activemq.management;
+
+import java.util.List;
+
+import org.apache.activemq.ActiveMQMessageConsumer;
+import org.apache.activemq.ActiveMQMessageProducer;
+import org.apache.activemq.util.IndentPrinter;
+
+/**
+ * Statistics for a JMS session
+ *
+ * @version $Revision: 1.2 $
+ */
+public class JMSSessionStatsImpl extends StatsImpl {
+ private List producers;
+ private List consumers;
+ private CountStatisticImpl messageCount;
+ private CountStatisticImpl pendingMessageCount;
+ private CountStatisticImpl expiredMessageCount;
+ private TimeStatisticImpl messageWaitTime;
+ private CountStatisticImpl durableSubscriptionCount;
+
+ private TimeStatisticImpl messageRateTime;
+
+ public JMSSessionStatsImpl(List producers, List consumers) {
+ this.producers = producers;
+ this.consumers = consumers;
+ this.messageCount = new CountStatisticImpl("messageCount", "Number of messages exchanged");
+ this.pendingMessageCount = new CountStatisticImpl("pendingMessageCount", "Number of pending messages");
+ this.expiredMessageCount = new CountStatisticImpl("expiredMessageCount", "Number of expired messages");
+ this.messageWaitTime = new TimeStatisticImpl("messageWaitTime",
+ "Time spent by a message before being delivered");
+ this.durableSubscriptionCount = new CountStatisticImpl("durableSubscriptionCount",
+ "The number of durable subscriptions");
+ this.messageWaitTime = new TimeStatisticImpl("messageWaitTime",
+ "Time spent by a message before being delivered");
+ this.messageRateTime = new TimeStatisticImpl("messageRateTime",
+ "Time taken to process a message (thoughtput rate)");
+
+ // lets add named stats
+ addStatistic("messageCount", messageCount);
+ addStatistic("pendingMessageCount", pendingMessageCount);
+ addStatistic("expiredMessageCount", expiredMessageCount);
+ addStatistic("messageWaitTime", messageWaitTime);
+ addStatistic("durableSubscriptionCount", durableSubscriptionCount);
+ addStatistic("messageRateTime", messageRateTime);
+ }
+
+ public JMSProducerStatsImpl[] getProducers() {
+ // lets make a snapshot before we process them
+ Object[] producerArray = producers.toArray();
+ int size = producerArray.length;
+ JMSProducerStatsImpl[] answer = new JMSProducerStatsImpl[size];
+ for (int i = 0; i < size; i++) {
+ ActiveMQMessageProducer producer = (ActiveMQMessageProducer)producerArray[i];
+ answer[i] = producer.getProducerStats();
+ }
+ return answer;
+ }
+
+ public JMSConsumerStatsImpl[] getConsumers() {
+ // lets make a snapshot before we process them
+ Object[] consumerArray = consumers.toArray();
+ int size = consumerArray.length;
+ JMSConsumerStatsImpl[] answer = new JMSConsumerStatsImpl[size];
+ for (int i = 0; i < size; i++) {
+ ActiveMQMessageConsumer consumer = (ActiveMQMessageConsumer)consumerArray[i];
+ answer[i] = consumer.getConsumerStats();
+ }
+ return answer;
+ }
+
+ public void reset() {
+ super.reset();
+ JMSConsumerStatsImpl[] cstats = getConsumers();
+ int size = cstats.length;
+ for (int i = 0; i < size; i++) {
+ cstats[i].reset();
+ }
+ JMSProducerStatsImpl[] pstats = getProducers();
+ size = pstats.length;
+ for (int i = 0; i < size; i++) {
+ pstats[i].reset();
+ }
+ }
+
+ /**
+ * @param enabled the enabled to set
+ */
+ public void setEnabled(boolean enabled) {
+ super.setEnabled(enabled);
+ JMSConsumerStatsImpl[] cstats = getConsumers();
+ int size = cstats.length;
+ for (int i = 0; i < size; i++) {
+ cstats[i].setEnabled(enabled);
+ }
+ JMSProducerStatsImpl[] pstats = getProducers();
+ size = pstats.length;
+ for (int i = 0; i < size; i++) {
+ pstats[i].setEnabled(enabled);
+ }
+
+ }
+
+ public CountStatisticImpl getMessageCount() {
+ return messageCount;
+ }
+
+ public CountStatisticImpl getPendingMessageCount() {
+ return pendingMessageCount;
+ }
+
+ public CountStatisticImpl getExpiredMessageCount() {
+ return expiredMessageCount;
+ }
+
+ public TimeStatisticImpl getMessageWaitTime() {
+ return messageWaitTime;
+ }
+
+ public CountStatisticImpl getDurableSubscriptionCount() {
+ return durableSubscriptionCount;
+ }
+
+ public TimeStatisticImpl getMessageRateTime() {
+ return messageRateTime;
+ }
+
+ public String toString() {
+ StringBuffer buffer = new StringBuffer(" ");
+ buffer.append(messageCount);
+ buffer.append(" ");
+ buffer.append(messageRateTime);
+ buffer.append(" ");
+ buffer.append(pendingMessageCount);
+ buffer.append(" ");
+ buffer.append(expiredMessageCount);
+ buffer.append(" ");
+ buffer.append(messageWaitTime);
+ buffer.append(" ");
+ buffer.append(durableSubscriptionCount);
+
+ buffer.append(" producers{ ");
+ JMSProducerStatsImpl[] producerArray = getProducers();
+ for (int i = 0; i < producerArray.length; i++) {
+ if (i > 0) {
+ buffer.append(", ");
+ }
+ buffer.append(Integer.toString(i));
+ buffer.append(" = ");
+ buffer.append(producerArray[i]);
+ }
+ buffer.append(" } consumers{ ");
+ JMSConsumerStatsImpl[] consumerArray = getConsumers();
+ for (int i = 0; i < consumerArray.length; i++) {
+ if (i > 0) {
+ buffer.append(", ");
+ }
+ buffer.append(Integer.toString(i));
+ buffer.append(" = ");
+ buffer.append(consumerArray[i]);
+ }
+ buffer.append(" }");
+ return buffer.toString();
+ }
+
+ public void dump(IndentPrinter out) {
+ out.printIndent();
+ out.println(messageCount);
+ out.printIndent();
+ out.println(messageRateTime);
+ out.printIndent();
+ out.println(pendingMessageCount);
+ out.printIndent();
+ out.println(expiredMessageCount);
+ out.printIndent();
+ out.println(messageWaitTime);
+ out.printIndent();
+ out.println(durableSubscriptionCount);
+ out.println();
+
+ out.printIndent();
+ out.println("producers {");
+ out.incrementIndent();
+ JMSProducerStatsImpl[] producerArray = getProducers();
+ for (int i = 0; i < producerArray.length; i++) {
+ JMSProducerStatsImpl producer = (JMSProducerStatsImpl)producerArray[i];
+ producer.dump(out);
+ }
+ out.decrementIndent();
+ out.printIndent();
+ out.println("}");
+
+ out.printIndent();
+ out.println("consumers {");
+ out.incrementIndent();
+ JMSConsumerStatsImpl[] consumerArray = getConsumers();
+ for (int i = 0; i < consumerArray.length; i++) {
+ JMSConsumerStatsImpl consumer = (JMSConsumerStatsImpl)consumerArray[i];
+ consumer.dump(out);
+ }
+ out.decrementIndent();
+ out.printIndent();
+ out.println("}");
+ }
+
+ public void onCreateDurableSubscriber() {
+ durableSubscriptionCount.increment();
+ }
+
+ public void onRemoveDurableSubscriber() {
+ durableSubscriptionCount.decrement();
+ }
+}
Propchange: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSSessionStatsImpl.java
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSStatsImpl.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSStatsImpl.java?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSStatsImpl.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSStatsImpl.java Tue Jun 2 21:29:30 2009
@@ -0,0 +1,82 @@
+/**
+ * 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.activemq.management;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.activemq.ActiveMQConnection;
+import org.apache.activemq.util.IndentPrinter;
+
+/**
+ * Statistics for a number of JMS connections
+ *
+ * @version $Revision: 1.2 $
+ */
+public class JMSStatsImpl extends StatsImpl {
+ private List<ActiveMQConnection> connections = new CopyOnWriteArrayList<ActiveMQConnection>();
+
+ public JMSStatsImpl() {
+ }
+
+ public JMSConnectionStatsImpl[] getConnections() {
+ Object[] connectionArray = connections.toArray();
+ int size = connectionArray.length;
+ JMSConnectionStatsImpl[] answer = new JMSConnectionStatsImpl[size];
+ for (int i = 0; i < size; i++) {
+ ActiveMQConnection connection = (ActiveMQConnection)connectionArray[i];
+ answer[i] = connection.getConnectionStats();
+ }
+ return answer;
+ }
+
+ public void addConnection(ActiveMQConnection connection) {
+ connections.add(connection);
+ }
+
+ public void removeConnection(ActiveMQConnection connection) {
+ connections.remove(connection);
+ }
+
+ public void dump(IndentPrinter out) {
+ out.printIndent();
+ out.println("factory {");
+ out.incrementIndent();
+ JMSConnectionStatsImpl[] array = getConnections();
+ for (int i = 0; i < array.length; i++) {
+ JMSConnectionStatsImpl connectionStat = (JMSConnectionStatsImpl)array[i];
+ connectionStat.dump(out);
+ }
+ out.decrementIndent();
+ out.printIndent();
+ out.println("}");
+ out.flush();
+ }
+
+ /**
+ * @param enabled the enabled to set
+ */
+ public void setEnabled(boolean enabled) {
+ super.setEnabled(enabled);
+ JMSConnectionStatsImpl[] stats = getConnections();
+ int size = stats.length;
+ for (int i = 0; i < size; i++) {
+ stats[i].setEnabled(enabled);
+ }
+
+ }
+}
Propchange: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/JMSStatsImpl.java
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/PollCountStatisticImpl.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/PollCountStatisticImpl.java?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/PollCountStatisticImpl.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/PollCountStatisticImpl.java Tue Jun 2 21:29:30 2009
@@ -0,0 +1,116 @@
+/**
+ * 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.activemq.management;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.management.j2ee.statistics.CountStatistic;
+
+/**
+ * A count statistic implementation
+ *
+ * @version $Revision$
+ */
+public class PollCountStatisticImpl extends StatisticImpl implements CountStatistic {
+
+ private PollCountStatisticImpl parent;
+ private List<PollCountStatisticImpl> children;
+
+ public PollCountStatisticImpl(PollCountStatisticImpl parent, String name, String description) {
+ this(name, description);
+ setParent(parent);
+ }
+
+ public PollCountStatisticImpl(String name, String description) {
+ this(name, "count", description);
+ }
+
+ public PollCountStatisticImpl(String name, String unit, String description) {
+ super(name, unit, description);
+ }
+
+ public PollCountStatisticImpl getParent() {
+ return parent;
+ }
+
+ public void setParent(PollCountStatisticImpl parent) {
+ if (this.parent != null) {
+ this.parent.removeChild(this);
+ }
+ this.parent = parent;
+ if (this.parent != null) {
+ this.parent.addChild(this);
+ }
+ }
+
+ private synchronized void removeChild(PollCountStatisticImpl child) {
+ if (children != null) {
+ children.remove(child);
+ }
+ }
+
+ private synchronized void addChild(PollCountStatisticImpl child) {
+ if (children == null) {
+ children = new ArrayList<PollCountStatisticImpl>();
+ }
+ children.add(child);
+ }
+
+ public synchronized long getCount() {
+ if (children == null) {
+ return 0;
+ }
+ long count = 0;
+ for (Iterator<PollCountStatisticImpl> iter = children.iterator(); iter.hasNext();) {
+ PollCountStatisticImpl child = iter.next();
+ count += child.getCount();
+ }
+ return count;
+ }
+
+ protected void appendFieldDescription(StringBuffer buffer) {
+ buffer.append(" count: ");
+ buffer.append(Long.toString(getCount()));
+ super.appendFieldDescription(buffer);
+ }
+
+ /**
+ * @return the average time period that elapses between counter increments
+ * since the last reset.
+ */
+ public double getPeriod() {
+ double count = getCount();
+ if (count == 0) {
+ return 0;
+ }
+ double time = System.currentTimeMillis() - getStartTime();
+ return time / (count * 1000.0);
+ }
+
+ /**
+ * @return the number of times per second that the counter is incrementing
+ * since the last reset.
+ */
+ public double getFrequency() {
+ double count = getCount();
+ double time = System.currentTimeMillis() - getStartTime();
+ return count * 1000.0 / time;
+ }
+
+}
Propchange: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/PollCountStatisticImpl.java
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/RangeStatisticImpl.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/RangeStatisticImpl.java?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/RangeStatisticImpl.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/RangeStatisticImpl.java Tue Jun 2 21:29:30 2009
@@ -0,0 +1,75 @@
+/**
+ * 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.activemq.management;
+
+
+/**
+ * A range statistic implementation
+ *
+ * @version $Revision: 1.2 $
+ */
+public class RangeStatisticImpl extends StatisticImpl {
+ private long highWaterMark;
+ private long lowWaterMark;
+ private long current;
+
+ public RangeStatisticImpl(String name, String unit, String description) {
+ super(name, unit, description);
+ }
+
+ public void reset() {
+ if (isDoReset()) {
+ super.reset();
+ current = 0;
+ lowWaterMark = 0;
+ highWaterMark = 0;
+ }
+ }
+
+ public long getHighWaterMark() {
+ return highWaterMark;
+ }
+
+ public long getLowWaterMark() {
+ return lowWaterMark;
+ }
+
+ public long getCurrent() {
+ return current;
+ }
+
+ public void setCurrent(long current) {
+ this.current = current;
+ if (current > highWaterMark) {
+ highWaterMark = current;
+ }
+ if (current < lowWaterMark || lowWaterMark == 0) {
+ lowWaterMark = current;
+ }
+ updateSampleTime();
+ }
+
+ protected void appendFieldDescription(StringBuffer buffer) {
+ buffer.append(" current: ");
+ buffer.append(Long.toString(current));
+ buffer.append(" lowWaterMark: ");
+ buffer.append(Long.toString(lowWaterMark));
+ buffer.append(" highWaterMark: ");
+ buffer.append(Long.toString(highWaterMark));
+ super.appendFieldDescription(buffer);
+ }
+}
Propchange: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/RangeStatisticImpl.java
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/Resettable.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/Resettable.java?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/Resettable.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/Resettable.java Tue Jun 2 21:29:30 2009
@@ -0,0 +1,30 @@
+/**
+ * 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.activemq.management;
+
+/**
+ * Represents some statistic that is capable of being reset
+ *
+ * @version $Revision: 1.2 $
+ */
+public interface Resettable {
+
+ /**
+ * Reset the statistic
+ */
+ void reset();
+}
Propchange: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/Resettable.java
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/StatisticImpl.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/StatisticImpl.java?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/StatisticImpl.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/StatisticImpl.java Tue Jun 2 21:29:30 2009
@@ -0,0 +1,126 @@
+/**
+ * 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.activemq.management;
+
+import javax.management.j2ee.statistics.Statistic;
+
+/**
+ * Base class for a Statistic implementation
+ *
+ * @version $Revision: 1.2 $
+ */
+public class StatisticImpl implements Statistic, Resettable {
+
+ protected boolean enabled;
+
+ private String name;
+ private String unit;
+ private String description;
+ private long startTime;
+ private long lastSampleTime;
+ private boolean doReset = true;
+
+ public StatisticImpl(String name, String unit, String description) {
+ this.name = name;
+ this.unit = unit;
+ this.description = description;
+ this.startTime = System.currentTimeMillis();
+ this.lastSampleTime = this.startTime;
+ }
+
+ public synchronized void reset() {
+ if(isDoReset()) {
+ this.startTime = System.currentTimeMillis();
+ this.lastSampleTime = this.startTime;
+ }
+ }
+
+ protected synchronized void updateSampleTime() {
+ this.lastSampleTime = System.currentTimeMillis();
+ }
+
+ public synchronized String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(name);
+ buffer.append("{");
+ appendFieldDescription(buffer);
+ buffer.append(" }");
+ return buffer.toString();
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public String getUnit() {
+ return this.unit;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+
+ public synchronized long getStartTime() {
+ return this.startTime;
+ }
+
+ public synchronized long getLastSampleTime() {
+ return this.lastSampleTime;
+ }
+
+ /**
+ * @return the enabled
+ */
+ public boolean isEnabled() {
+ return this.enabled;
+ }
+
+ /**
+ * @param enabled the enabled to set
+ */
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ /**
+ * @return the doReset
+ */
+ public boolean isDoReset() {
+ return this.doReset;
+ }
+
+ /**
+ * @param doReset the doReset to set
+ */
+ public void setDoReset(boolean doReset) {
+ this.doReset = doReset;
+ }
+
+
+ protected synchronized void appendFieldDescription(StringBuffer buffer) {
+ buffer.append(" unit: ");
+ buffer.append(this.unit);
+ buffer.append(" startTime: ");
+ // buffer.append(new Date(startTime));
+ buffer.append(this.startTime);
+ buffer.append(" lastSampleTime: ");
+ // buffer.append(new Date(lastSampleTime));
+ buffer.append(this.lastSampleTime);
+ buffer.append(" description: ");
+ buffer.append(this.description);
+ }
+}
Propchange: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/StatisticImpl.java
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/StatsCapable.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/StatsCapable.java?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/StatsCapable.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/StatsCapable.java Tue Jun 2 21:29:30 2009
@@ -0,0 +1,31 @@
+/**
+ * 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.activemq.management;
+
+
+/**
+ * Represents an object which is capable of providing some stats
+ *
+ * @version $Revision: 1.2 $
+ */
+public interface StatsCapable {
+
+ /**
+ * @return the Stats for this object
+ */
+ StatsImpl getStats();
+}
Propchange: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/StatsCapable.java
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/StatsImpl.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/StatsImpl.java?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/StatsImpl.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/StatsImpl.java Tue Jun 2 21:29:30 2009
@@ -0,0 +1,73 @@
+/**
+ * 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.activemq.management;
+
+import java.util.*;
+import javax.management.j2ee.statistics.Statistic;
+import javax.management.j2ee.statistics.Stats;
+
+/**
+ * Base class for a Stats implementation
+ *
+ * @version $Revision: 1.2 $
+ */
+public class StatsImpl extends StatisticImpl implements Stats, Resettable {
+ private Map<String, StatisticImpl> map;
+
+ public StatsImpl() {
+ this(new HashMap<String, StatisticImpl>());
+ }
+
+ public StatsImpl(Map<String, StatisticImpl> map) {
+ super("stats", "many", "Used only as container, not Statistic");
+ this.map = map;
+ }
+
+ public void reset() {
+ Statistic[] stats = getStatistics();
+ int size = stats.length;
+ for (int i = 0; i < size; i++) {
+ Statistic stat = stats[i];
+ if (stat instanceof Resettable) {
+ Resettable r = (Resettable)stat;
+ r.reset();
+ }
+ }
+ }
+
+ public Statistic getStatistic(String name) {
+ return map.get(name);
+ }
+
+ public String[] getStatisticNames() {
+ Set<String> keys = map.keySet();
+ String[] answer = new String[keys.size()];
+ keys.toArray(answer);
+ return answer;
+ }
+
+ public Statistic[] getStatistics() {
+ Collection<StatisticImpl> values = map.values();
+ Statistic[] answer = new Statistic[values.size()];
+ values.toArray(answer);
+ return answer;
+ }
+
+ protected void addStatistic(String name, StatisticImpl statistic) {
+ map.put(name, statistic);
+ }
+}
Propchange: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/StatsImpl.java
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/TimeStatisticImpl.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/TimeStatisticImpl.java?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/TimeStatisticImpl.java (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/TimeStatisticImpl.java Tue Jun 2 21:29:30 2009
@@ -0,0 +1,174 @@
+/**
+ * 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.activemq.management;
+
+
+/**
+ * A time statistic implementation
+ *
+ * @version $Revision: 1.2 $
+ */
+public class TimeStatisticImpl extends StatisticImpl {
+ private long count;
+ private long maxTime;
+ private long minTime;
+ private long totalTime;
+ private TimeStatisticImpl parent;
+
+ public TimeStatisticImpl(String name, String description) {
+ this(name, "millis", description);
+ }
+
+ public TimeStatisticImpl(TimeStatisticImpl parent, String name, String description) {
+ this(name, description);
+ this.parent = parent;
+ }
+
+ public TimeStatisticImpl(String name, String unit, String description) {
+ super(name, unit, description);
+ }
+
+ public synchronized void reset() {
+ if(isDoReset()) {
+ super.reset();
+ count = 0;
+ maxTime = 0;
+ minTime = 0;
+ totalTime = 0;
+ }
+ }
+
+ public synchronized long getCount() {
+ return count;
+ }
+
+ public synchronized void addTime(long time) {
+ count++;
+ totalTime += time;
+ if (time > maxTime) {
+ maxTime = time;
+ }
+ if (time < minTime || minTime == 0) {
+ minTime = time;
+ }
+ updateSampleTime();
+ if (parent != null) {
+ parent.addTime(time);
+ }
+ }
+
+ /**
+ * @return the maximum time of any step
+ */
+ public long getMaxTime() {
+ return maxTime;
+ }
+
+ /**
+ * @return the minimum time of any step
+ */
+ public synchronized long getMinTime() {
+ return minTime;
+ }
+
+ /**
+ * @return the total time of all the steps added together
+ */
+ public synchronized long getTotalTime() {
+ return totalTime;
+ }
+
+ /**
+ * @return the average time calculated by dividing the
+ * total time by the number of counts
+ */
+ public synchronized double getAverageTime() {
+ if (count == 0) {
+ return 0;
+ }
+ double d = totalTime;
+ return d / count;
+ }
+
+
+ /**
+ * @return the average time calculated by dividing the
+ * total time by the number of counts but excluding the
+ * minimum and maximum times.
+ */
+ public synchronized double getAverageTimeExcludingMinMax() {
+ if (count <= 2) {
+ return 0;
+ }
+ double d = totalTime - minTime - maxTime;
+ return d / (count - 2);
+ }
+
+
+ /**
+ * @return the average number of steps per second
+ */
+ public double getAveragePerSecond() {
+ double d = 1000;
+ double averageTime = getAverageTime();
+ if (averageTime == 0) {
+ return 0;
+ }
+ return d / averageTime;
+ }
+
+ /**
+ * @return the average number of steps per second excluding the min & max values
+ */
+ public double getAveragePerSecondExcludingMinMax() {
+ double d = 1000;
+ double average = getAverageTimeExcludingMinMax();
+ if (average == 0) {
+ return 0;
+ }
+ return d / average;
+ }
+
+ public TimeStatisticImpl getParent() {
+ return parent;
+ }
+
+ public void setParent(TimeStatisticImpl parent) {
+ this.parent = parent;
+ }
+
+ protected synchronized void appendFieldDescription(StringBuffer buffer) {
+ buffer.append(" count: ");
+ buffer.append(Long.toString(count));
+ buffer.append(" maxTime: ");
+ buffer.append(Long.toString(maxTime));
+ buffer.append(" minTime: ");
+ buffer.append(Long.toString(minTime));
+ buffer.append(" totalTime: ");
+ buffer.append(Long.toString(totalTime));
+ buffer.append(" averageTime: ");
+ buffer.append(Double.toString(getAverageTime()));
+ buffer.append(" averageTimeExMinMax: ");
+ buffer.append(Double.toString(getAverageTimeExcludingMinMax()));
+ buffer.append(" averagePerSecond: ");
+ buffer.append(Double.toString(getAveragePerSecond()));
+ buffer.append(" averagePerSecondExMinMax: ");
+ buffer.append(Double.toString(getAveragePerSecondExcludingMinMax()));
+ super.appendFieldDescription(buffer);
+ }
+
+}
Propchange: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/TimeStatisticImpl.java
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/package.html
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/package.html?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/package.html (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/package.html Tue Jun 2 21:29:30 2009
@@ -0,0 +1,27 @@
+<!--
+ 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.
+-->
+<html>
+<head>
+</head>
+<body>
+
+<p>
+ An implementation of the J2EE Management API
+</p>
+
+</body>
+</html>
Propchange: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/management/package.html
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/package.html
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/package.html?rev=781177&view=auto
==============================================================================
--- activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/package.html (added)
+++ activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/package.html Tue Jun 2 21:29:30 2009
@@ -0,0 +1,25 @@
+<!--
+ 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.
+-->
+<html>
+<head>
+</head>
+<body>
+
+The core JMS client API implementation classes.
+
+</body>
+</html>
Propchange: activemq/sandbox/activemq-flow/activemq-client/src/main/java/org/apache/activemq/package.html
------------------------------------------------------------------------------
svn:executable = *