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

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


The following commit(s) were added to refs/heads/master by this push:
     new 084d4a4452 [IOTDB-3541][IOTDB-3542] Support handling exception and 
make it stable in cluster IT (#6341)
084d4a4452 is described below

commit 084d4a445277cbb99febc701164299e094818fe3
Author: BaiJian <[email protected]>
AuthorDate: Mon Jun 20 16:43:16 2022 +0800

    [IOTDB-3541][IOTDB-3542] Support handling exception and make it stable in 
cluster IT (#6341)
---
 .../java/org/apache/iotdb/it/env/AbstractEnv.java  |  67 +++-----
 .../itbase/runtime/ParallelRequestDelegate.java    |   8 +-
 .../iotdb/itbase/runtime/RequestDelegate.java      |  45 +++++-
 .../itbase/runtime/SerialRequestDelegate.java      |   4 +-
 integration/checkstyle.xml                         | 173 ++++++++++++++++++++-
 .../src/assembly/resources/sbin/stop-datanode.bat  |  19 ++-
 6 files changed, 264 insertions(+), 52 deletions(-)

diff --git 
a/integration-test/src/main/java/org/apache/iotdb/it/env/AbstractEnv.java 
b/integration-test/src/main/java/org/apache/iotdb/it/env/AbstractEnv.java
index bc734db5fd..124c3fcce9 100644
--- a/integration-test/src/main/java/org/apache/iotdb/it/env/AbstractEnv.java
+++ b/integration-test/src/main/java/org/apache/iotdb/it/env/AbstractEnv.java
@@ -40,7 +40,6 @@ import java.util.Date;
 import java.util.List;
 import java.util.Random;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
 import static org.apache.iotdb.jdbc.Config.VERSION;
@@ -48,7 +47,8 @@ import static org.junit.Assert.fail;
 
 public abstract class AbstractEnv implements BaseEnv {
   private static final Logger logger = 
LoggerFactory.getLogger(AbstractEnv.class);
-  private final int NODE_START_TIMEOUT = 10;
+  private final int NODE_START_TIMEOUT = 100;
+  private final int PROBE_TIMEOUT = 2;
   protected List<ConfigNodeWrapper> configNodeWrapperList;
   protected List<DataNodeWrapper> dataNodeWrapperList;
   private final Random rand = new Random();
@@ -159,53 +159,34 @@ public abstract class AbstractEnv implements BaseEnv {
     return "IT";
   }
 
-  public void testWorking() throws InterruptedException {
+  public void testWorking() {
     List<String> endpoints =
         dataNodeWrapperList.stream()
-            .map(AbstractNodeWrapper::getIpAndPortString)
+            .map(DataNodeWrapper::getIpAndPortString)
             .collect(Collectors.toList());
-    boolean[] success = new boolean[dataNodeWrapperList.size()];
-    Exception[] exceptions = new Exception[dataNodeWrapperList.size()];
-    final int probeTimeout = 5;
-    AtomicInteger successCount = new AtomicInteger(0);
-    for (int counter = 0; counter < 30; counter++) {
-      RequestDelegate<Void> testDelegate = new 
ParallelRequestDelegate<>(endpoints, probeTimeout);
-      for (int i = 0; i < dataNodeWrapperList.size(); i++) {
-        final int idx = i;
-        final String dataNodeEndpoint = 
dataNodeWrapperList.get(i).getIpAndPortString();
-        testDelegate.addRequest(
-            () -> {
-              if (!success[idx]) {
-                try (Connection ignored = getConnection(dataNodeEndpoint, 
probeTimeout)) {
-                  success[idx] = true;
-                  successCount.incrementAndGet();
-                } catch (Exception e) {
-                  exceptions[idx] = e;
-                  logger.debug("Open connection of {} failed", 
dataNodeEndpoint, e);
-                }
+    RequestDelegate<Void> testDelegate =
+        new ParallelRequestDelegate<>(endpoints, NODE_START_TIMEOUT);
+    for (DataNodeWrapper dataNode : dataNodeWrapperList) {
+      final String dataNodeEndpoint = dataNode.getIpAndPortString();
+      testDelegate.addRequest(
+          () -> {
+            Exception lastException = null;
+            for (int i = 0; i < 30; i++) {
+              try (Connection ignored = getConnection(dataNodeEndpoint, 
PROBE_TIMEOUT)) {
+                return null;
+              } catch (Exception e) {
+                lastException = e;
+                TimeUnit.SECONDS.sleep(1L);
               }
-              return null;
-            });
-      }
-      try {
-        testDelegate.requestAll();
-      } catch (SQLException e) {
-        // It will never be thrown as it has already caught in the request.
-      }
-      if (successCount.get() == dataNodeWrapperList.size()) {
-        logger.info("The whole cluster is ready.");
-        return;
-      }
-      TimeUnit.SECONDS.sleep(1);
+            }
+            throw lastException;
+          });
     }
-    // The cluster is not ready after 30 times to try
-    for (int i = 0; i < dataNodeWrapperList.size(); i++) {
-      if (!success[i] && exceptions[i] != null) {
-        logger.error(
-            "Connect to {} failed", 
dataNodeWrapperList.get(i).getIpAndPortString(), exceptions[i]);
-      }
+    try {
+      testDelegate.requestAll();
+    } catch (Exception e) {
+      fail("After 30 times retry, the cluster can't work!");
     }
-    fail("After 30 times retry, the cluster can't work!");
   }
 
   @Override
diff --git 
a/integration-test/src/main/java/org/apache/iotdb/itbase/runtime/ParallelRequestDelegate.java
 
b/integration-test/src/main/java/org/apache/iotdb/itbase/runtime/ParallelRequestDelegate.java
index fbec912adb..92b5b478bc 100644
--- 
a/integration-test/src/main/java/org/apache/iotdb/itbase/runtime/ParallelRequestDelegate.java
+++ 
b/integration-test/src/main/java/org/apache/iotdb/itbase/runtime/ParallelRequestDelegate.java
@@ -22,8 +22,10 @@ import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 
 /**
  * ParallelRequestDelegate will handle requests in parallel. It's more 
efficient when requests
@@ -44,10 +46,13 @@ public class ParallelRequestDelegate<T> extends 
RequestDelegate<T> {
       resultFutures.add(f);
     }
     List<T> results = new ArrayList<>(getRequests().size());
+    Exception[] exceptions = new Exception[getEndpoints().size()];
     for (int i = 0; i < getEndpoints().size(); i++) {
       try {
         results.add(resultFutures.get(i).get(taskTimeoutSeconds, 
TimeUnit.SECONDS));
-      } catch (Exception e) {
+      } catch (ExecutionException e) {
+        exceptions[i] = e;
+      } catch (InterruptedException | TimeoutException e) {
         for (int j = i; j < getEndpoints().size(); j++) {
           resultFutures.get(j).cancel(true);
         }
@@ -55,6 +60,7 @@ public class ParallelRequestDelegate<T> extends 
RequestDelegate<T> {
             String.format("Waiting for query results of %s failed", 
getEndpoints().get(i)), e);
       }
     }
+    handleExceptions(exceptions);
     return results;
   }
 }
diff --git 
a/integration-test/src/main/java/org/apache/iotdb/itbase/runtime/RequestDelegate.java
 
b/integration-test/src/main/java/org/apache/iotdb/itbase/runtime/RequestDelegate.java
index af71fe1577..d191926fa1 100644
--- 
a/integration-test/src/main/java/org/apache/iotdb/itbase/runtime/RequestDelegate.java
+++ 
b/integration-test/src/main/java/org/apache/iotdb/itbase/runtime/RequestDelegate.java
@@ -18,15 +18,20 @@
  */
 package org.apache.iotdb.itbase.runtime;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
 import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
 
 /** This class is used to handle multi requests and gather their returned 
values. */
 public abstract class RequestDelegate<T> {
 
+  private static final Logger logger = 
LoggerFactory.getLogger(RequestDelegate.class);
   private final List<String> endpoints;
   private final List<Callable<T>> requests = new ArrayList<>();
 
@@ -49,7 +54,9 @@ public abstract class RequestDelegate<T> {
   }
 
   /**
-   * Do the requests which have been added, and return a list of their return 
values.
+   * Do the requests which have been added, and return a list of their return 
values. If some
+   * exception throws from the request, the exception thrown by each request 
will be compared and be
+   * thrown if they are even, or an InconsistentDataException.
    *
    * @return the return values of all the request added in order.
    * @throws SQLException if any error happens during requesting.
@@ -76,6 +83,42 @@ public abstract class RequestDelegate<T> {
     return data;
   }
 
+  protected void handleExceptions(Exception[] exceptions) throws SQLException {
+    if (exceptions.length == 0) {
+      return;
+    }
+    String[] exceptionMsg = new String[exceptions.length];
+    Throwable[] businessExceptions = new Throwable[exceptions.length];
+    boolean exceptionInconsistent = false;
+    for (int i = 0; i < exceptions.length; i++) {
+      if (exceptions[i] != null) {
+        businessExceptions[i] =
+            exceptions[i] instanceof ExecutionException ? 
exceptions[i].getCause() : exceptions[i];
+        exceptionMsg[i] = businessExceptions[i].getMessage();
+      }
+    }
+    for (int i = 1; i < exceptionMsg.length; i++) {
+      if (!Objects.equals(exceptionMsg[i], exceptionMsg[0])) {
+        exceptionInconsistent = true;
+        break;
+      }
+    }
+    for (int i = 0; i < businessExceptions.length; i++) {
+      if (businessExceptions[i] != null) {
+        // As each exception has its own stacktrace, in order to display them 
clearly, we can only
+        // print them through logger.
+        logger.error(
+            "Exception happens during request to {}", getEndpoints().get(i), 
businessExceptions[i]);
+      }
+    }
+    if (!exceptionInconsistent && exceptionMsg[0] != null) {
+      throw new SQLException(exceptionMsg[0]);
+    }
+    if (exceptionInconsistent) {
+      throw new InconsistentDataException(exceptionMsg, getEndpoints());
+    }
+  }
+
   protected List<String> getEndpoints() {
     return endpoints;
   }
diff --git 
a/integration-test/src/main/java/org/apache/iotdb/itbase/runtime/SerialRequestDelegate.java
 
b/integration-test/src/main/java/org/apache/iotdb/itbase/runtime/SerialRequestDelegate.java
index 10e53b62e6..096983af23 100644
--- 
a/integration-test/src/main/java/org/apache/iotdb/itbase/runtime/SerialRequestDelegate.java
+++ 
b/integration-test/src/main/java/org/apache/iotdb/itbase/runtime/SerialRequestDelegate.java
@@ -35,13 +35,15 @@ public class SerialRequestDelegate<T> extends 
RequestDelegate<T> {
   @Override
   public List<T> requestAll() throws SQLException {
     List<T> results = new ArrayList<>(getEndpoints().size());
+    Exception[] exceptions = new Exception[getEndpoints().size()];
     for (int i = 0; i < getEndpoints().size(); i++) {
       try {
         results.add(getRequests().get(i).call());
       } catch (Exception e) {
-        throw new SQLException(String.format("Request %s error.", 
getEndpoints().get(i)), e);
+        exceptions[i] = e;
       }
     }
+    handleExceptions(exceptions);
     return results;
   }
 }
diff --git a/integration/checkstyle.xml b/integration/checkstyle.xml
index 578af5a865..3019192677 100644
--- a/integration/checkstyle.xml
+++ b/integration/checkstyle.xml
@@ -25,7 +25,178 @@
     <property name="severity" value="error"/>
     <property name="fileExtensions" value="java"/>
     <module name="BeforeExecutionExclusionFileFilter">
-        <property name="fileNamePattern" 
value="(^.*([\\/]src[\\/]main|[\\/]src[\\/]test[\\/]java[\\/]org[\\/]apache[\\/]iotdb[\\/]session)[\\/].*$)|
                 |^.*IoTDBSchemaTemplateIT\.java$|                 
|^.*IoTDBSeriesReaderIT\.java$|                 |^.*IoTDBCompactionIT\.java$|   
              |^.*IoTDBAggregationByLevelIT\.java$|                 
|^.*IoTDBUDFNestAggregationIT\.java$|                 
|^.*IoTDBAggregationDeleteIT\.java$|                 |^.*IoTDBUserDefinedA [...]
+        <!--Generate these files by: find . -name \*.java -print | xargs -n 1 
basename | awk -F '.' '{print "|^.*"$1"\\.java$|"}' | grep IT -->
+        <property name="fileNamePattern"
+                  
value="(^.*([\\/]src[\\/]main|[\\/]src[\\/]test[\\/]java[\\/]org[\\/]apache[\\/]iotdb[\\/]session|)[\\/].*$)|
+                |^.*AlignedWriteUtil\.java$|
+                |^.*StandaloneEnv\.java$|
+                |^.*StandaloneEnvConfig\.java$|
+                |^.*SyncTestUtil\.java$|
+                |^.*TransportClientMock\.java$|
+                |^.*TransportHandlerMock\.java$|
+                |^.*IoTDBSchemaTemplateIT\.java$|
+                |^.*IoTDBSeriesReaderIT\.java$|
+                |^.*IoTDBCompactionIT\.java$|
+                |^.*IoTDBSnapshotIT\.java$|
+                |^.*IoTDBAggregationByLevelIT\.java$|
+                |^.*IoTDBUDFNestAggregationIT\.java$|
+                |^.*IoTDBAggregationDeleteIT\.java$|
+                |^.*IoTDBUserDefinedAggregationFunctionIT\.java$|
+                |^.*IoTDBAggregationIT\.java$|
+                |^.*IoTDBAggregationSmallDataIT\.java$|
+                |^.*IoTDBAggregationLargeDataIT\.java$|
+                |^.*IoTDBPartialInsertionIT\.java$|
+                |^.*IoTDBInsertWithoutTimeIT\.java$|
+                |^.*IoTDBMultiSeriesIT\.java$|
+                |^.*IoTDBDisableAlignIT\.java$|
+                |^.*IoTDBManageTsFileResourceIT\.java$|
+                |^.*IoTDBInsertMultiRowIT\.java$|
+                |^.*IoTDBQueryWithComplexValueFilterIT\.java$|
+                |^.*IoTDBUDTFHybridQueryIT\.java$|
+                |^.*IoTDBQueryMemoryControlIT\.java$|
+                |^.*IoTDBClearCacheIT\.java$|
+                |^.*IoTDBTracingIT\.java$|
+                |^.*IoTDBLoadExternalTsFileWithTimePartitionIT\.java$|
+                |^.*IoTDBKillQueryIT\.java$|
+                |^.*IoTDBCompactionWithIDTableIT\.java$|
+                |^.*IoTDBMultiStatementsIT\.java$|
+                |^.*IoTDBArithmeticIT\.java$|
+                |^.*IoTDBQueryWithIDTableIT\.java$|
+                |^.*IoTDBDaemonIT\.java$|
+                |^.*IoTDBTriggerForwardIT\.java$|
+                |^.*IoTDBEncodingIT\.java$|
+                |^.*IoTDBNestedQueryIT\.java$|
+                |^.*IoTDBSelectSchemaIT\.java$|
+                |^.*IoTDBSortedShowTimeseriesIT\.java$|
+                |^.*IoTDBLoadExternalTsfileWithVirtualSGIT\.java$|
+                |^.*IoTDBFillIT\.java$|
+                |^.*IoTDBSelectCompareExpressionIT\.java$|
+                |^.*IoTDBFilePathUtilsIT\.java$|
+                |^.*IoTDBTtlIT\.java$|
+                |^.*IoTDBUnseqOverlappedPageIT\.java$|
+                |^.*IoTDBVersionIT\.java$|
+                |^.*IoTDBCreateTimeseriesIT\.java$|
+                |^.*IoTDBCompressTypeIT\.java$|
+                |^.*IoTDBTagAlterIT\.java$|
+                |^.*IoTDBQueryDemoIT\.java$|
+                |^.*IoTDBSyntaxConventionIdentifierIT\.java$|
+                |^.*IoTDBNumberPathIT\.java$|
+                |^.*IoTDBSettleIT\.java$|
+                |^.*IoTDBOverlappedPageIT\.java$|
+                |^.*IoTDBDatetimeFormatIT\.java$|
+                |^.*IoTDBInIT\.java$|
+                |^.*IoTDBMetadataFetchIT\.java$|
+                |^.*IoTDBFloatPrecisionIT\.java$|
+                |^.*IoTDBRecoverIT\.java$|
+                |^.*IoTDBFuzzyQueryIT\.java$|
+                |^.*IoTDBAliasIT\.java$|
+                |^.*IoTDBUDFWindowQueryIT\.java$|
+                |^.*IoTDBAuthorizationIT\.java$|
+                |^.*IoTDBTriggerManagementIT\.java$|
+                |^.*IoTDBRecoverUnclosedIT\.java$|
+                |^.*IoTDBCreateAlignedTimeseriesIT\.java$|
+                |^.*IoTDBSameMeasurementsDifferentTypesIT\.java$|
+                |^.*IoTDBRpcCompressionIT\.java$|
+                |^.*IoTDBAlignByDeviceIT\.java$|
+                |^.*IoTDBLoadExternalAlignedTsFileIT\.java$|
+                |^.*IoTDBGroupByQueryWithValueFilterWithDeletion2IT\.java$|
+                |^.*IoTDBGroupBySlidingWindowQueryWithoutValueFilterIT\.java$|
+                |^.*IoTDBRawQueryWithValueFilterIT\.java$|
+                |^.*IoTDBAggregationWithValueFilterIT\.java$|
+                |^.*IoTDBGroupByFillQueryBigDataIT\.java$|
+                |^.*IoTDBGroupByQueryWithValueFilterWithDeletionIT\.java$|
+                |^.*IoTDBAggregationWithValueFilterWithDeletion2IT\.java$|
+                |^.*IoTDBAggregationWithValueFilter2IT\.java$|
+                |^.*IoTDBRawQueryWithValueFilterWithDeletion2IT\.java$|
+                |^.*IoTDBGroupByFillQueryIT\.java$|
+                |^.*IoTDBDeleteTimeseriesIT\.java$|
+                |^.*IoTDBDeletionIT\.java$|
+                |^.*IoTDBGroupByQueryWithValueFilter2IT\.java$|
+                |^.*IoTDBEmptyDataIT\.java$|
+                |^.*IoTDBAggregationWithValueFilterWithDeletionIT\.java$|
+                |^.*IoTDBRawQueryWithValueFilterWithDeletionIT\.java$|
+                |^.*IoTDBAggregationGroupByLevelIT\.java$|
+                |^.*IoTDBRawQueryWithValueFilter2IT\.java$|
+                |^.*IoTDBGroupBySlidingWindowQueryWithValueFilterIT\.java$|
+                |^.*IoTDBGroupByQueryWithValueFilterIT\.java$|
+                |^.*IoTDBMultiDeviceIT\.java$|
+                |^.*IoTDBQueryVersionAdaptionIT\.java$|
+                |^.*IoTDBDDLVersionAdaptionIT\.java$|
+                |^.*IoTDBDeletionVersionAdaptionIT\.java$|
+                |^.*IoTDBCreateStorageGroupIT\.java$|
+                |^.*IoTDBCompleteIT\.java$|
+                |^.*IOTDBGroupByInnerIntervalIT\.java$|
+                |^.*IoTDBGroupByFillWithRangeIT\.java$|
+                |^.*IoTDBGroupByUnseqIT\.java$|
+                |^.*IOTDBGroupByIT\.java$|
+                |^.*IoTDBGroupByFillIT\.java$|
+                |^.*IoTDBGroupByMonthFillIT\.java$|
+                |^.*IoTDBGroupByFillMixPathsIT\.java$|
+                |^.*IoTDBGroupByMonthIT\.java$|
+                |^.*IoTDBResultSetIT\.java$|
+                |^.*IoTDBSimpleQueryIT\.java$|
+                |^.*IoTDBDeleteStorageGroupIT\.java$|
+                |^.*IOTDBInsertIT\.java$|
+                |^.*IoTDBTagIT\.java$|
+                |^.*IoTDBDeleteTimeseriesIT\.java$|
+                |^.*IoTDBDeletionIT\.java$|
+                |^.*IoTDBExecuteBatchIT\.java$|
+                |^.*IoTDBMaxTimeQueryIT\.java$|
+                |^.*IoTDBSensorUpdateIT\.java$|
+                |^.*IoTDBWithoutNullAllFilterIT\.java$|
+                |^.*IoTDBWithoutNullAnyFilterIT\.java$|
+                |^.*IoTDBRemovePartitionIT\.java$|
+                |^.*IoTDBUDTFAlignByTimeQueryIT\.java$|
+                |^.*IoTDBAutoCreateSchemaIT\.java$|
+                |^.*IoTDBQueryTimeoutIT\.java$|
+                |^.*IoTDBLoadExternalTsfileIT\.java$|
+                |^.*IoTDBSessionTimeoutIT\.java$|
+                |^.*IoTDBAsIT\.java$|
+                |^.*IoTDBPathNumOverLimitIT\.java$|
+                |^.*IoTDBFlushQueryMergeIT\.java$|
+                |^.*IoTDBSelectIntoIT\.java$|
+                |^.*IoTDBMultiOverlappedChunkInUnseqIT\.java$|
+                |^.*IoTDBInsertWithQueryIT\.java$|
+                |^.*IoTDBTimeZoneIT\.java$|
+                |^.*IoTDBTriggerExecutionIT\.java$|
+                |^.*IoTDBWithoutAllNullIT\.java$|
+                |^.*IoTDBLimitSlimitIT\.java$|
+                |^.*IoTDBLargeDataIT\.java$|
+                |^.*IoTDBResultMetadataIT\.java$|
+                |^.*IoTDBWithoutAnyNullIT\.java$|
+                |^.*IoTDBQuotedPathIT\.java$|
+                |^.*IoTDBSyncReceiverLoaderIT\.java$|
+                |^.*IoTDBSyncSenderIT\.java$|
+                |^.*IoTDBSyncReceiverIT\.java$|
+                |^.*IoTDBSyncReceiverCollectorIT\.java$|
+                |^.*IoTDBUDTFBuiltinFunctionIT\.java$|
+                |^.*IoTDBInsertNaNIT\.java$|
+                |^.*IoTDBLastIT\.java$|
+                |^.*IoTDBNewTsFileCompactionIT\.java$|
+                |^.*IoTDBSyntaxConventionStringLiteralIT\.java$|
+                |^.*IoTDBSequenceDataQueryIT\.java$|
+                |^.*IoTDBTimePartitionIT\.java$|
+                |^.*IoTDBCloseIT\.java$|
+                |^.*IoTDBQueryWithRecreatedTimeseriesIT\.java$|
+                |^.*IoTDBEngineTimeGeneratorIT\.java$|
+                |^.*IoTDBInsertNullIT\.java$|
+                |^.*IoTDBCheckConfigIT\.java$|
+                |^.*IoTDBMultiOverlappedPageIT\.java$|
+                |^.*IoTDBAlignedTimeSeriesCompactionIT\.java$|
+                |^.*IoTDBRestartIT\.java$|
+                |^.*IoTDBUDTFNonAlignQueryIT\.java$|
+                |^.*IoTDBSetSystemReadOnlyWritableIT\.java$|
+                |^.*IoTDBContinuousQueryIT\.java$|
+                |^.*IoTDBSizeTieredCompactionIT\.java$|
+                |^.*IoTDBSessionVectorAggregationIT\.java$|
+                |^.*IoTDBSessionDisableMemControlIT\.java$|
+                |^.*IoTDBSessionSimpleIT\.java$|
+                |^.*IoTDBSessionComplexIT\.java$|
+                |^.*IoTDBSessionVectorABDeviceIT\.java$|
+                |^.*IoTDBSessionVectorAggregationWithUnSeqIT\.java$|
+                |^.*IoTDBSessionVectorInsertIT\.java$|
+                |^.*IoTDBSessionIteratorIT\.java$|
+                |^.*IoTDBSessionSyntaxConventionIT\.java$"/>
     </module>
     <!--    <module name="RegexpOnFilename">-->
     <!--        <property name="fileNamePattern" value="^.*IT\.java$"/>-->
diff --git a/server/src/assembly/resources/sbin/stop-datanode.bat 
b/server/src/assembly/resources/sbin/stop-datanode.bat
index e33c1bd81f..b7de06477f 100644
--- a/server/src/assembly/resources/sbin/stop-datanode.bat
+++ b/server/src/assembly/resources/sbin/stop-datanode.bat
@@ -19,11 +19,20 @@
 
 @echo off
 
-pushd..
-set exec_dir=%cd%
-popd
-set exec_dir=%exec_dir:\=\\%
-wmic process where (commandline like "%%iotdb.DataNode%%" and not 
name="wmic.exe" and  commandline  like "%%%exec_dir%%%") delete
+set current_dir=%~dp0
+set superior_dir=%current_dir%\..\
 
+for /f  "eol=; tokens=2,2 delims==" %%i in ('findstr /i "^rpc_port"
+%superior_dir%\conf\iotdb-engine.properties') do (
+  set rpc_port=%%i
+)
 
+for /f  "eol=; tokens=2,2 delims==" %%i in ('findstr /i "rpc_address"
+%superior_dir%\conf\iotdb-engine.properties') do (
+  set rpc_address=%%i
+)
 
+for /f "tokens=5" %%a in ('netstat /ano ^| findstr %rpc_address%:%rpc_port%') 
do (
+  taskkill /f /pid %%a
+)
+rem ps ax | grep -i 'iotdb.DataNode' | grep -v grep | awk '{print $1}' | xargs 
kill -SIGTERM

Reply via email to