zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iv...@apache.org
Subject svn commit: r1232852 - in /zookeeper/bookkeeper/trunk: ./ bookkeeper-server/src/main/java/org/apache/bookkeeper/jmx/
Date Wed, 18 Jan 2012 12:09:48 GMT
Author: ivank
Date: Wed Jan 18 12:09:48 2012
New Revision: 1232852

URL: http://svn.apache.org/viewvc?rev=1232852&view=rev
Log:
BOOKKEEPER-95: extends zookeeper JMX to monitor and manage bookie server (Sijie Guo via ivank)

Added:
    zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/jmx/
    zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/jmx/BKMBeanInfo.java
    zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/jmx/BKMBeanRegistry.java
Modified:
    zookeeper/bookkeeper/trunk/CHANGES.txt

Modified: zookeeper/bookkeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/CHANGES.txt?rev=1232852&r1=1232851&r2=1232852&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/CHANGES.txt (original)
+++ zookeeper/bookkeeper/trunk/CHANGES.txt Wed Jan 18 12:09:48 2012
@@ -22,6 +22,8 @@ Trunk (unreleased changes)
 
 	BOOKKEEPER-150: Entry is lost when recovering a ledger with not enough bookies. (Sijie Guo
via ivank)
 
+        BOOKKEEPER-95: extends zookeeper JMX to monitor and manage bookie server (Sijie Guo
via ivank)
+
       hedwig-server/
       
         BOOKKEEPER-140: Hub server doesn't subscribe remote region correctly when a region
is down. (Sijie Gou via ivank)

Added: zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/jmx/BKMBeanInfo.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/jmx/BKMBeanInfo.java?rev=1232852&view=auto
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/jmx/BKMBeanInfo.java
(added)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/jmx/BKMBeanInfo.java
Wed Jan 18 12:09:48 2012
@@ -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.bookkeeper.jmx;
+
+import org.apache.zookeeper.jmx.ZKMBeanInfo;
+
+/**
+ * BookKeeper MBean info interface.
+ */
+public interface BKMBeanInfo extends ZKMBeanInfo {
+}

Added: zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/jmx/BKMBeanRegistry.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/jmx/BKMBeanRegistry.java?rev=1232852&view=auto
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/jmx/BKMBeanRegistry.java
(added)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/jmx/BKMBeanRegistry.java
Wed Jan 18 12:09:48 2012
@@ -0,0 +1,84 @@
+/**
+ * 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.bookkeeper.jmx;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.apache.log4j.Logger;
+import org.apache.zookeeper.jmx.MBeanRegistry;
+import org.apache.zookeeper.jmx.ZKMBeanInfo;
+
+/**
+ * This class provides a unified interface for registering/unregistering of
+ * bookkeeper MBeans with the platform MBean server. It builds a hierarchy of MBeans
+ * where each MBean represented by a filesystem-like path. Eventually, this hierarchy
+ * will be stored in the zookeeper data tree instance as a virtual data tree.
+ */
+public class BKMBeanRegistry extends MBeanRegistry {
+    static final Logger LOG = Logger.getLogger(BKMBeanRegistry.class);
+    
+    static final String DOMAIN = "org.apache.BookKeeperService";
+
+    static BKMBeanRegistry instance=new BKMBeanRegistry(); 
+
+    public static BKMBeanRegistry getInstance(){
+        return instance;
+    }
+    
+    /**
+     * This takes a path, such as /a/b/c, and converts it to 
+     * name0=a,name1=b,name2=c
+     * 
+     * Copy from zookeeper MBeanRegistry since tokenize is private
+     */
+    protected int tokenize(StringBuilder sb, String path, int index) {
+        String[] tokens = path.split("/");
+        for (String s: tokens) {
+            if (s.length()==0)
+                continue;
+            sb.append("name").append(index++).append("=").append(s).append(",");
+        }
+        return index;
+    }
+
+    /**
+     * Builds an MBean path and creates an ObjectName instance using the path. 
+     * @param path MBean path
+     * @param bean the MBean instance
+     * @return ObjectName to be registered with the platform MBean server
+     */
+    protected ObjectName makeObjectName(String path, ZKMBeanInfo bean)
+        throws MalformedObjectNameException {
+        if(path==null)
+            return null;
+        StringBuilder beanName = new StringBuilder(DOMAIN + ":");
+        int counter=0;
+        counter=tokenize(beanName,path,counter);
+        tokenize(beanName,bean.getName(),counter);
+        beanName.deleteCharAt(beanName.length()-1);
+        try {
+            return new ObjectName(beanName.toString());
+        } catch (MalformedObjectNameException e) {
+            LOG.warn("Invalid name \"" + beanName.toString() + "\" for class "
+                    + bean.getClass().toString());
+            throw e;
+        }
+    }
+}



Mime
View raw message