You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by hx...@apache.org on 2021/05/03 04:17:44 UTC

[iotdb] branch test_container updated: finish adding api

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

hxd pushed a commit to branch test_container
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/test_container by this push:
     new 25c2f9f  finish adding api
25c2f9f is described below

commit 25c2f9fd6ba83cef6dd32c967a21abab4693b4f4
Author: xiangdong huang <sa...@gmail.com>
AuthorDate: Mon May 3 12:17:11 2021 +0800

    finish adding api
---
 .../cluster/server/ClusterInfoClientServer.java    | 27 ++++++++++++++--------
 .../utils/nodetool/ClusterMonitorMBean.java        |  2 +-
 thrift-cluster/src/main/thrift/cluster.thrift      | 11 ++++++---
 3 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/server/ClusterInfoClientServer.java b/cluster/src/main/java/org/apache/iotdb/cluster/server/ClusterInfoClientServer.java
index cff7fe9..a75fad2 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/server/ClusterInfoClientServer.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/server/ClusterInfoClientServer.java
@@ -18,7 +18,13 @@
  */
 package org.apache.iotdb.cluster.server;
 
+import java.util.ArrayList;
+import java.util.stream.Collectors;
+import org.apache.commons.collections4.keyvalue.MultiKey;
+import org.apache.commons.collections4.map.MultiKeyMap;
+import org.apache.iotdb.cluster.partition.PartitionGroup;
 import org.apache.iotdb.cluster.rpc.thrift.ClusterInfoService;
+import org.apache.iotdb.cluster.rpc.thrift.DataPartitionEntry;
 import org.apache.iotdb.cluster.rpc.thrift.Node;
 import org.apache.iotdb.cluster.utils.nodetool.ClusterMonitor;
 import org.apache.thrift.TException;
@@ -34,29 +40,30 @@ public class ClusterInfoClientServer implements ClusterInfoService.Iface {
   }
 
   @Override
-  public Map<Long, List<Node>> getDataPartition(String path, long startTime, long endTime)
+  public List<DataPartitionEntry> getDataPartition(String path, long startTime, long endTime)
       throws TException {
-    //    Map<Long, PartitionGroup> result =
-    //        ClusterMonitor.INSTANCE.getDataPartition(path, startTime, endTime);
-
-    return null;
+        MultiKeyMap<Long, PartitionGroup> partitions =
+            ClusterMonitor.INSTANCE.getDataPartition(path, startTime, endTime);
+        List<DataPartitionEntry> result = new ArrayList<>(partitions.size());
+        partitions.forEach((multikey, nodes) -> {
+          result.add(new DataPartitionEntry(multikey.getKey(1), multikey.getKey(2), nodes));
+        });
+    return result;
   }
 
   @Override
   public List<Node> getMetaPartition(String path) throws TException {
-    return null;
+    return ClusterMonitor.INSTANCE.getMetaPartition(path);
   }
 
   @Override
   public Map<Node, Boolean> getAllNodeStatus() throws TException {
-    return null;
+    return ClusterMonitor.INSTANCE.getAllNodeStatus();
   }
 
   @Override
   public String getInstrumentingInfo() throws TException {
-    return null;
+    return ClusterMonitor.INSTANCE.getInstrumentingInfo();
   }
 
-  @Override
-  public void resetInstrumenting() throws TException {}
 }
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/utils/nodetool/ClusterMonitorMBean.java b/cluster/src/main/java/org/apache/iotdb/cluster/utils/nodetool/ClusterMonitorMBean.java
index 410f462..1ba18d1 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/utils/nodetool/ClusterMonitorMBean.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/utils/nodetool/ClusterMonitorMBean.java
@@ -39,7 +39,7 @@ public interface ClusterMonitorMBean {
    * Get data partition information of input path and time range.
    *
    * @param path input path
-   * @return data partition information
+   * @return data partition information: ((start time, end time), PartitionGroup)
    */
   MultiKeyMap<Long, PartitionGroup> getDataPartition(String path, long startTime, long endTime);
 
diff --git a/thrift-cluster/src/main/thrift/cluster.thrift b/thrift-cluster/src/main/thrift/cluster.thrift
index e3985c6..2bcf9bf 100644
--- a/thrift-cluster/src/main/thrift/cluster.thrift
+++ b/thrift-cluster/src/main/thrift/cluster.thrift
@@ -511,6 +511,13 @@ service TSMetaService extends RaftService {
   void handshake(1:Node sender);
 }
 
+
+struct DataPartitionEntry{
+  1: required long startTime,
+  2: required long endTime,
+  3: required list<Node> nodes
+}
+
 /**
 * for cluster maintainer.
 * The interface will replace the JMX based NodeTool APIs.
@@ -527,7 +534,7 @@ service ClusterInfoService {
      * @param path input path
      * @return data partition information
      */
-    map<long, list<Node>> getDataPartition(1:string path, 2:long startTime, 3:long endTime);
+    list<DataPartitionEntry> getDataPartition(1:string path, 2:long startTime, 3:long endTime);
 
     /**
      * Get metadata partition information of input path
@@ -550,6 +557,4 @@ service ClusterInfoService {
      */
     string getInstrumentingInfo();
 
-    /** Reset all instrumenting statistics in Timer. */
-    void resetInstrumenting();
 }
\ No newline at end of file