You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kf...@apache.org on 2017/04/10 08:16:13 UTC

svn commit: r1790791 - in /tomcat/trunk/java/org/apache/catalina/tribes/membership: McastService.java McastServiceMBean.java

Author: kfujino
Date: Mon Apr 10 08:16:13 2017
New Revision: 1790791

URL: http://svn.apache.org/viewvc?rev=1790791&view=rev
Log:
Add MBean for Membership component.

Added:
    tomcat/trunk/java/org/apache/catalina/tribes/membership/McastServiceMBean.java   (with props)
Modified:
    tomcat/trunk/java/org/apache/catalina/tribes/membership/McastService.java

Modified: tomcat/trunk/java/org/apache/catalina/tribes/membership/McastService.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/membership/McastService.java?rev=1790791&r1=1790790&r2=1790791&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/membership/McastService.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/membership/McastService.java Mon Apr 10 08:16:13 2017
@@ -21,6 +21,8 @@ import java.io.IOException;
 import java.net.DatagramPacket;
 import java.util.Properties;
 
+import javax.management.ObjectName;
+
 import org.apache.catalina.tribes.Channel;
 import org.apache.catalina.tribes.ChannelException;
 import org.apache.catalina.tribes.ChannelMessage;
@@ -30,6 +32,7 @@ import org.apache.catalina.tribes.Member
 import org.apache.catalina.tribes.MessageListener;
 import org.apache.catalina.tribes.io.ChannelData;
 import org.apache.catalina.tribes.io.XByteBuffer;
+import org.apache.catalina.tribes.jmx.JmxRegistry;
 import org.apache.catalina.tribes.util.Arrays;
 import org.apache.catalina.tribes.util.StringManager;
 import org.apache.catalina.tribes.util.UUIDGenerator;
@@ -42,7 +45,8 @@ import org.apache.juli.logging.LogFactor
  * This class is responsible for maintaining a list of active cluster nodes in the cluster.
  * If a node fails to send out a heartbeat, the node will be dismissed.
  */
-public class McastService implements MembershipService,MembershipListener,MessageListener {
+public class McastService
+        implements MembershipService,MembershipListener,MessageListener, McastServiceMBean {
 
     private static final Log log = LogFactory.getLog(McastService.class);
 
@@ -81,6 +85,11 @@ public class McastService implements Mem
     private Channel channel;
 
     /**
+     * the ObjectName of this McastService. 
+     */
+    private ObjectName oname = null;
+
+    /**
      * Create a membership service.
      */
     public McastService() {
@@ -363,7 +372,11 @@ public class McastService implements Mem
         impl.setChannel(channel);
 
         impl.start(level);
-
+        // register jmx
+        JmxRegistry jmxRegistry = JmxRegistry.getRegistry(channel);
+        if (jmxRegistry != null) {
+            this.oname = jmxRegistry.registerJmx(",component=Membership", this);
+        }
 
     }
 
@@ -375,6 +388,10 @@ public class McastService implements Mem
     public void stop(int svc) {
         try  {
             if ( impl != null && impl.stop(svc) ) {
+                if (oname != null) {
+                    JmxRegistry.getRegistry(channel).unregisterJmx(oname);
+                    oname = null;
+                }
                 impl.setChannel(null);
                 impl = null;
                 channel = null;

Added: tomcat/trunk/java/org/apache/catalina/tribes/membership/McastServiceMBean.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/membership/McastServiceMBean.java?rev=1790791&view=auto
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/membership/McastServiceMBean.java (added)
+++ tomcat/trunk/java/org/apache/catalina/tribes/membership/McastServiceMBean.java Mon Apr 10 08:16:13 2017
@@ -0,0 +1,60 @@
+/*
+ * 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.catalina.tribes.membership;
+
+import java.util.Properties;
+
+import org.apache.catalina.tribes.Member;
+
+public interface McastServiceMBean {
+
+    // Attributes
+    public String getAddress();
+
+    public int getPort();
+
+    public long getFrequency();
+
+    public long getDropTime();
+
+    public String getBind();
+
+    public int getTtl();
+
+    public byte[] getDomain();
+
+    public int getSoTimeout();
+
+    public boolean getRecoveryEnabled();
+
+    public int getRecoveryCounter();
+
+    public long getRecoverySleepTime();
+
+    public boolean getLocalLoopbackDisabled();
+
+    public String getLocalMemberName();
+
+    // Operation
+    public Properties getProperties();
+
+    public boolean hasMembers();
+
+    public String[] getMembersByName();
+
+    public Member findMemberByName(String name);
+}

Propchange: tomcat/trunk/java/org/apache/catalina/tribes/membership/McastServiceMBean.java
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org