activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject git commit: Fix for https://issues.apache.org/jira/browse/AMQ-4918
Date Wed, 04 Dec 2013 20:14:25 GMT
Updated Branches:
  refs/heads/trunk 489f92968 -> 9b8890245


Fix for https://issues.apache.org/jira/browse/AMQ-4918


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/9b889024
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/9b889024
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/9b889024

Branch: refs/heads/trunk
Commit: 9b889024596dc47dea4917551a2d5813796a6b19
Parents: 489f929
Author: rajdavies <rajdavies@gmail.com>
Authored: Wed Dec 4 20:14:07 2013 +0000
Committer: rajdavies <rajdavies@gmail.com>
Committed: Wed Dec 4 20:14:07 2013 +0000

----------------------------------------------------------------------
 .../activemq/broker/jmx/NetworkBridgeView.java    | 18 ++++++++++++++++++
 .../broker/jmx/NetworkBridgeViewMBean.java        |  2 ++
 .../broker/jmx/NetworkDestinationView.java        | 12 +++++++++---
 .../broker/jmx/NetworkDestinationViewMBean.java   |  2 +-
 .../activemq/network/MBeanBridgeDestination.java  | 14 +++++++++-----
 .../activemq/network/MBeanNetworkListener.java    |  7 +++----
 6 files changed, 42 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/9b889024/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkBridgeView.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkBridgeView.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkBridgeView.java
index 2201b30..795de3a 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkBridgeView.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkBridgeView.java
@@ -16,12 +16,16 @@
  */
 package org.apache.activemq.broker.jmx;
 
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
 import org.apache.activemq.network.NetworkBridge;
 
 public class NetworkBridgeView implements NetworkBridgeViewMBean {
 
     private final NetworkBridge bridge;
     private boolean createByDuplex = false;
+    private List<NetworkDestinationView> networkDestinationViewList = new CopyOnWriteArrayList<NetworkDestinationView>();
 
     public NetworkBridgeView(NetworkBridge bridge) {
         this.bridge = bridge;
@@ -66,4 +70,18 @@ public class NetworkBridgeView implements NetworkBridgeViewMBean {
     public void setCreateByDuplex(boolean createByDuplex) {
         this.createByDuplex = createByDuplex;
     }
+
+    public void resetStats(){
+        for (NetworkDestinationView networkDestinationView:networkDestinationViewList){
+            networkDestinationView.resetStats();
+        }
+    }
+
+    public void addNetworkDestinationView(NetworkDestinationView networkDestinationView){
+        networkDestinationViewList.add(networkDestinationView);
+    }
+
+    public void removeNetworkDestinationView(NetworkDestinationView networkDestinationView){
+        networkDestinationViewList.remove(networkDestinationView);
+    }
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/9b889024/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkBridgeViewMBean.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkBridgeViewMBean.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkBridgeViewMBean.java
index ec7598c..b8733d1 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkBridgeViewMBean.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkBridgeViewMBean.java
@@ -34,4 +34,6 @@ public interface NetworkBridgeViewMBean extends Service {
 
     boolean isCreatedByDuplex();
 
+    void resetStats();
+
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/9b889024/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkDestinationView.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkDestinationView.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkDestinationView.java
index 4edfd37..26177d5 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkDestinationView.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkDestinationView.java
@@ -25,10 +25,12 @@ public class NetworkDestinationView implements NetworkDestinationViewMBean
{
     private TimeStatisticImpl timeStatistic = new TimeStatisticImpl("networkEnqueue","network
messages enqueued");
 
     private final String name;
+    private final NetworkBridgeView networkBridgeView;
     private long lastTime = -1;
 
-    public NetworkDestinationView(String name){
-       this.name = name;
+    public NetworkDestinationView(NetworkBridgeView networkBridgeView, String name){
+       this.networkBridgeView = networkBridgeView;
+       this.name=name;
     }
     /**
      * Returns the name of this destination
@@ -42,7 +44,7 @@ public class NetworkDestinationView implements NetworkDestinationViewMBean
{
      * Resets the managment counters.
      */
     @Override
-    public void resetStatistics() {
+    public void resetStats() {
         timeStatistic.reset();
         lastTime = -1;
     }
@@ -70,4 +72,8 @@ public class NetworkDestinationView implements NetworkDestinationViewMBean
{
         timeStatistic.addTime(time);
         lastTime=currentTime;
     }
+
+    public void close(){
+        networkBridgeView.removeNetworkDestinationView(this);
+    }
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/9b889024/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkDestinationViewMBean.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkDestinationViewMBean.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkDestinationViewMBean.java
index 7164cdd..96c57c0 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkDestinationViewMBean.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/jmx/NetworkDestinationViewMBean.java
@@ -28,7 +28,7 @@ public interface NetworkDestinationViewMBean {
      * Resets the managment counters.
      */
     @MBeanInfo("Resets statistics.")
-    void resetStatistics();
+    void resetStats();
 
     /**
      * Returns the number of messages that have been sent to the destination.

http://git-wip-us.apache.org/repos/asf/activemq/blob/9b889024/activemq-broker/src/main/java/org/apache/activemq/network/MBeanBridgeDestination.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/network/MBeanBridgeDestination.java
b/activemq-broker/src/main/java/org/apache/activemq/network/MBeanBridgeDestination.java
index 666f11e..c718063 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/network/MBeanBridgeDestination.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/network/MBeanBridgeDestination.java
@@ -23,6 +23,7 @@ import javax.management.ObjectName;
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.broker.jmx.AnnotatedMBean;
 import org.apache.activemq.broker.jmx.BrokerMBeanSupport;
+import org.apache.activemq.broker.jmx.NetworkBridgeView;
 import org.apache.activemq.broker.jmx.NetworkDestinationView;
 import org.apache.activemq.command.ActiveMQDestination;
 import org.apache.activemq.command.Message;
@@ -33,13 +34,15 @@ public class MBeanBridgeDestination {
     private static final Logger LOG = LoggerFactory.getLogger(MBeanBridgeDestination.class);
     private final BrokerService brokerService;
     private final NetworkBridge bridge;
+    private final NetworkBridgeView networkBridgeView;
     private Map<ActiveMQDestination, ObjectName> destinationObjectNameMap = new ConcurrentHashMap<ActiveMQDestination,
ObjectName>();
     private Map<ActiveMQDestination, NetworkDestinationView> outboundDestinationViewMap
= new ConcurrentHashMap<ActiveMQDestination, NetworkDestinationView>();
     private Map<ActiveMQDestination, NetworkDestinationView> inboundDestinationViewMap
= new ConcurrentHashMap<ActiveMQDestination, NetworkDestinationView>();
 
-    public MBeanBridgeDestination(BrokerService brokerService, NetworkBridge bridge) {
+    public MBeanBridgeDestination(BrokerService brokerService, NetworkBridge bridge, NetworkBridgeView
networkBridgeView) {
         this.brokerService = brokerService;
         this.bridge = bridge;
+        this.networkBridgeView = networkBridgeView;
     }
 
 
@@ -48,11 +51,11 @@ public class MBeanBridgeDestination {
         NetworkDestinationView networkDestinationView = outboundDestinationViewMap.get(destination);
         if (networkDestinationView == null) {
             synchronized (destinationObjectNameMap) {
-                if (!destinationObjectNameMap.containsKey(destination)) {
+                if ((networkDestinationView = outboundDestinationViewMap.get(destination))
== null) {
                     ObjectName bridgeObjectName = bridge.getMbeanObjectName();
                     try {
                         ObjectName objectName = BrokerMBeanSupport.createNetworkOutBoundDestinationObjectName(bridgeObjectName,
destination);
-                        networkDestinationView = new NetworkDestinationView(destination.getPhysicalName());
+                        networkDestinationView = new NetworkDestinationView(networkBridgeView,destination.getPhysicalName());
                         AnnotatedMBean.registerMBean(brokerService.getManagementContext(),
networkDestinationView, objectName);
                         destinationObjectNameMap.put(destination, objectName);
                         outboundDestinationViewMap.put(destination, networkDestinationView);
@@ -72,11 +75,12 @@ public class MBeanBridgeDestination {
         NetworkDestinationView networkDestinationView = inboundDestinationViewMap.get(destination);
         if (networkDestinationView == null) {
             synchronized (destinationObjectNameMap) {
-                if (!destinationObjectNameMap.containsKey(destination)) {
+                if ((networkDestinationView = inboundDestinationViewMap.get(destination))
== null) {
                     ObjectName bridgeObjectName = bridge.getMbeanObjectName();
                     try {
                         ObjectName objectName = BrokerMBeanSupport.createNetworkInBoundDestinationObjectName(bridgeObjectName,
destination);
-                        networkDestinationView= new NetworkDestinationView(destination.getPhysicalName());
+                        networkDestinationView= new NetworkDestinationView(networkBridgeView,destination.getPhysicalName());
+                        networkBridgeView.addNetworkDestinationView(networkDestinationView);
                         AnnotatedMBean.registerMBean(brokerService.getManagementContext(),
networkDestinationView, objectName);
                         destinationObjectNameMap.put(destination, objectName);
                         inboundDestinationViewMap.put(destination, networkDestinationView);

http://git-wip-us.apache.org/repos/asf/activemq/blob/9b889024/activemq-broker/src/main/java/org/apache/activemq/network/MBeanNetworkListener.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/network/MBeanNetworkListener.java
b/activemq-broker/src/main/java/org/apache/activemq/network/MBeanNetworkListener.java
index 0481f3d..c877ecd 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/network/MBeanNetworkListener.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/network/MBeanNetworkListener.java
@@ -25,7 +25,6 @@ import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.broker.jmx.AnnotatedMBean;
 import org.apache.activemq.broker.jmx.BrokerMBeanSupport;
 import org.apache.activemq.broker.jmx.NetworkBridgeView;
-import org.apache.activemq.broker.jmx.NetworkBridgeViewMBean;
 import org.apache.activemq.command.Message;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -52,13 +51,13 @@ public class MBeanNetworkListener implements NetworkBridgeListener {
         if (!brokerService.isUseJmx()) {
             return;
         }
-        NetworkBridgeViewMBean view = new NetworkBridgeView(bridge);
-        ((NetworkBridgeView)view).setCreateByDuplex(createdByDuplex);
+        NetworkBridgeView view = new NetworkBridgeView(bridge);
+        view.setCreateByDuplex(createdByDuplex);
         try {
             ObjectName objectName = createNetworkBridgeObjectName(bridge);
             AnnotatedMBean.registerMBean(brokerService.getManagementContext(), view, objectName);
             bridge.setMbeanObjectName(objectName);
-            MBeanBridgeDestination mBeanBridgeDestination = new MBeanBridgeDestination(brokerService,bridge);
+            MBeanBridgeDestination mBeanBridgeDestination = new MBeanBridgeDestination(brokerService,bridge,view);
             destinationObjectNameMap.put(bridge,mBeanBridgeDestination);
             LOG.debug("registered: {} as: {}", bridge, objectName);
         } catch (Throwable e) {


Mime
View raw message