You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by li...@apache.org on 2019/06/03 04:27:58 UTC

[incubator-iotdb] branch add_singletion_jmx created (now 5c6f5f9)

This is an automated email from the ASF dual-hosted git repository.

liurui pushed a change to branch add_singletion_jmx
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git.


      at 5c6f5f9  add MManager JMX Bean

This branch includes the following new commits:

     new 5c6f5f9  add MManager JMX Bean

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-iotdb] 01/01: add MManager JMX Bean

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liurui pushed a commit to branch add_singletion_jmx
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit 5c6f5f99bbe1a21ec56219d880ace82cd662c79c
Author: liuruiyiyang <24...@qq.com>
AuthorDate: Mon Jun 3 12:27:34 2019 +0800

    add MManager JMX Bean
---
 .../org/apache/iotdb/db/mbeans/MManagerMBean.java  | 37 ++++++++++++++++++
 .../java/org/apache/iotdb/db/metadata/MGraph.java  |  8 ++++
 .../org/apache/iotdb/db/metadata/MManager.java     | 44 +++++++++++++++++++++-
 3 files changed, 88 insertions(+), 1 deletion(-)

diff --git a/iotdb/src/main/java/org/apache/iotdb/db/mbeans/MManagerMBean.java b/iotdb/src/main/java/org/apache/iotdb/db/mbeans/MManagerMBean.java
new file mode 100644
index 0000000..80f528a
--- /dev/null
+++ b/iotdb/src/main/java/org/apache/iotdb/db/mbeans/MManagerMBean.java
@@ -0,0 +1,37 @@
+/**
+ * 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.iotdb.db.mbeans;
+
+public interface MManagerMBean {
+
+  String getDatafilePath();
+
+  String getLogFilePath();
+
+  int getMGraphPTreeMapSize();
+
+  boolean getIsWriteToLog();
+
+  String getMetadataDirPath();
+
+  int getCheckAndGetDataTypeCacheSize();
+
+  int getMNodeCacheSize();
+
+}
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/metadata/MGraph.java b/iotdb/src/main/java/org/apache/iotdb/db/metadata/MGraph.java
index 70e9b17..5613b37 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/metadata/MGraph.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/metadata/MGraph.java
@@ -378,4 +378,12 @@ public class MGraph implements Serializable {
   public static String combineMetadataInStrings(String[] metadatas) {
     return MTree.combineMetadataInStrings(metadatas);
   }
+
+  /**
+   * get the map size of variable ptreeMap
+   * @return ptreeMap.size()
+   */
+  public int getPTreeMapSize(){
+    return ptreeMap.size();
+  }
 }
diff --git a/iotdb/src/main/java/org/apache/iotdb/db/metadata/MManager.java b/iotdb/src/main/java/org/apache/iotdb/db/metadata/MManager.java
index c45a3f0..9c653cf 100644
--- a/iotdb/src/main/java/org/apache/iotdb/db/metadata/MManager.java
+++ b/iotdb/src/main/java/org/apache/iotdb/db/metadata/MManager.java
@@ -35,9 +35,12 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
+import org.apache.iotdb.db.conf.IoTDBConstant;
 import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.exception.MetadataArgsErrorException;
 import org.apache.iotdb.db.exception.PathErrorException;
+import org.apache.iotdb.db.mbeans.MManagerMBean;
+import org.apache.iotdb.db.service.JMXService;
 import org.apache.iotdb.db.utils.RandomDeleteCache;
 import org.apache.iotdb.tsfile.common.conf.TSFileConfig;
 import org.apache.iotdb.tsfile.exception.cache.CacheException;
@@ -56,11 +59,13 @@ import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
  *
  * @author Jinrui Zhang
  */
-public class MManager {
+public class MManager implements MManagerMBean {
 
   private static final Logger LOGGER = LoggerFactory.getLogger(MManager.class);
   private static final String ROOT_NAME = MetadataConstant.ROOT;
   public static final String TIME_SERIES_TREE_HEADER = "===  Timeseries Tree  ===\n\n";
+  private final String mbeanName = String.format("%s:%s=%s", IoTDBConstant.IOTDB_PACKAGE,
+      IoTDBConstant.JMX_TYPE, "MManager");
 
   // the lock for read/write
   private ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
@@ -148,6 +153,8 @@ public class MManager {
     } finally {
       lock.writeLock().unlock();
     }
+
+    JMXService.registerMBean(getInstance(), mbeanName);
   }
 
   private void initFromDataFile(File dataFile) throws IOException, ClassNotFoundException {
@@ -1025,6 +1032,41 @@ public class MManager {
     }
   }
 
+  @Override
+  public String getDatafilePath() {
+    return datafilePath;
+  }
+
+  @Override
+  public String getLogFilePath() {
+    return logFilePath;
+  }
+
+  @Override
+  public int getMGraphPTreeMapSize() {
+    return mgraph.getPTreeMapSize();
+  }
+
+  @Override
+  public boolean getIsWriteToLog() {
+    return writeToLog;
+  }
+
+  @Override
+  public String getMetadataDirPath() {
+    return metadataDirPath;
+  }
+
+  @Override
+  public int getCheckAndGetDataTypeCacheSize() {
+    return checkAndGetDataTypeCache.size();
+  }
+
+  @Override
+  public int getMNodeCacheSize() {
+    return mNodeCache.size();
+  }
+
   private static class MManagerHolder {
     private MManagerHolder(){
       //allowed to do nothing