yuqi1129 commented on a change in pull request #2619:
URL: https://github.com/apache/iotdb/pull/2619#discussion_r571349837



##########
File path: 
cluster/src/main/java/org/apache/iotdb/cluster/client/sync/SyncClientAdaptor.java
##########
@@ -349,6 +351,26 @@ public static Integer getPathCount(AsyncDataClient client, 
Node header, List<Str
     return handler.getResult(RaftServer.getReadOperationTimeoutMS());
   }
 
+  public static Set<String> getDevices(AsyncDataClient client, Node header, 
ShowDevicesPlan plan)
+      throws InterruptedException, TException, IOException {
+    GetDevicesHandler handler = new GetDevicesHandler();
+    AtomicReference<Set<String>> response = new AtomicReference<>(null);
+    handler.setResponse(response);
+    handler.setContact(client.getNode());
+    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+    DataOutputStream dataOutputStream = new 
DataOutputStream(byteArrayOutputStream);
+    plan.serialize(dataOutputStream);
+
+    client.getDevices(header, 
ByteBuffer.wrap(byteArrayOutputStream.toByteArray()),
+        handler);
+    synchronized (response) {

Review comment:
       `response` is a local variants and will create a new instance when 
getDevices is called, so 
   synchronized response seems unnecessary

##########
File path: 
cluster/src/main/java/org/apache/iotdb/cluster/metadata/CMManager.java
##########
@@ -1298,6 +1299,49 @@ protected MeasurementMNode getMeasurementMNode(MNode 
deviceMNode, String measure
     return super.showTimeseries(plan, context);
   }
 
+  public Set<PartialPath> getLocalDevices(ShowDevicesPlan plan) throws 
MetadataException {
+    return super.getDevices(plan);
+  }
+
+  @Override
+  public Set<PartialPath> getDevices(ShowDevicesPlan plan) throws 
MetadataException {
+    ConcurrentSkipListSet<PartialPath> resultSet = new 
ConcurrentSkipListSet<>();
+    ExecutorService pool = new ThreadPoolExecutor(THREAD_POOL_SIZE, 
THREAD_POOL_SIZE, 0,
+        TimeUnit.SECONDS, new LinkedBlockingDeque<>());
+    List<PartitionGroup> globalGroups = 
metaGroupMember.getPartitionTable().getGlobalGroups();
+
+    int limit = plan.getLimit() == 0 ? Integer.MAX_VALUE : plan.getLimit();
+    int offset = plan.getOffset();
+    // do not use limit and offset in sub-queries unless offset is 0, 
otherwise the results are
+    // not combinable

Review comment:
       Have we check the limit and offset is reasonable , for example both is 
greater than 0?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to