You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by yu...@apache.org on 2020/11/01 06:19:25 UTC
[iotdb] branch kyy updated: extract check failed reasons
This is an automated email from the ASF dual-hosted git repository.
yuyuankang pushed a commit to branch kyy
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/kyy by this push:
new a03fa08 extract check failed reasons
a03fa08 is described below
commit a03fa08477ca52b8974be3e8a3429abc964041bf
Author: Ring-k <yu...@hotmail.com>
AuthorDate: Sun Nov 1 14:18:50 2020 +0800
extract check failed reasons
---
.../apache/iotdb/db/qp/executor/PlanExecutor.java | 61 +++++++---------------
.../java/org/apache/iotdb/db/utils/IOUtils.java | 8 +++
2 files changed, 26 insertions(+), 43 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
index 999cff5..48fa596 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java
@@ -130,6 +130,7 @@ import org.apache.iotdb.db.query.executor.QueryRouter;
import org.apache.iotdb.db.service.IoTDB;
import org.apache.iotdb.db.utils.AuthUtils;
import org.apache.iotdb.db.utils.FileLoaderUtils;
+import org.apache.iotdb.db.utils.IOUtils;
import org.apache.iotdb.db.utils.UpgradeUtils;
import org.apache.iotdb.rpc.RpcUtils;
import org.apache.iotdb.service.rpc.thrift.TSStatus;
@@ -936,28 +937,8 @@ public class PlanExecutor implements IPlanExecutor {
}
StorageEngine.getInstance().insert(insertRowPlan);
- if (insertRowPlan.getFailedMeasurements() != null) {
- // check if all path not exist exceptions
- List<String> failedPaths = insertRowPlan.getFailedMeasurements();
- List<Exception> exceptions = insertRowPlan.getFailedExceptions();
- boolean isPathNotExistException = true;
- for (Exception e : exceptions) {
- Throwable curException = e;
- while (curException.getCause() != null) {
- curException = curException.getCause();
- }
- if (!(curException instanceof PathNotExistException)) {
- isPathNotExistException = false;
- break;
- }
- }
- if (isPathNotExistException) {
- throw new PathNotExistException(failedPaths);
- } else {
- throw new StorageEngineException(
- INSERT_MEASUREMENTS_FAILED_MESSAGE + insertRowPlan.getFailedMeasurements());
- }
- }
+ checkFailedReasons(insertRowPlan.getFailedMeasurements(),
+ insertRowPlan.getFailedExceptions());
} catch (StorageEngineException | MetadataException e) {
throw new QueryProcessException(e);
}
@@ -974,30 +955,24 @@ public class PlanExecutor implements IPlanExecutor {
logger.info("device id does not exist");
}
StorageEngine.getInstance().insertTablet(insertTabletPlan);
- if (insertTabletPlan.getFailedMeasurements() != null) {
- // check if all path not exist exceptions
- List<String> failedPaths = insertTabletPlan.getFailedMeasurements();
- List<Exception> exceptions = insertTabletPlan.getFailedExceptions();
- boolean isPathNotExistException = true;
- for (Exception e : exceptions) {
- Throwable curException = e;
- while (curException.getCause() != null) {
- curException = curException.getCause();
- }
- if (!(curException instanceof PathNotExistException)) {
- isPathNotExistException = false;
- break;
- }
- }
- if (isPathNotExistException) {
- throw new PathNotExistException(failedPaths);
- } else {
+ checkFailedReasons(insertTabletPlan.getFailedMeasurements(),
+ insertTabletPlan.getFailedExceptions());
+ } catch (StorageEngineException | MetadataException e) {
+ throw new QueryProcessException(e);
+ }
+ }
+
+ private void checkFailedReasons(List<String> failedMeasurements, List<Exception> failedExceptions)
+ throws PathNotExistException, StorageEngineException {
+ if (failedMeasurements != null) {
+ // check if all path not exist exceptions
+ for (Exception e : failedExceptions) {
+ if (!(IOUtils.getRootCause(e) instanceof PathNotExistException)) {
throw new StorageEngineException(
- INSERT_MEASUREMENTS_FAILED_MESSAGE + insertTabletPlan.getFailedMeasurements());
+ INSERT_MEASUREMENTS_FAILED_MESSAGE + failedMeasurements);
}
}
- } catch (StorageEngineException | MetadataException e) {
- throw new QueryProcessException(e);
+ throw new PathNotExistException(failedMeasurements);
}
}
diff --git a/server/src/main/java/org/apache/iotdb/db/utils/IOUtils.java b/server/src/main/java/org/apache/iotdb/db/utils/IOUtils.java
index c04dfb6..79a8c18 100644
--- a/server/src/main/java/org/apache/iotdb/db/utils/IOUtils.java
+++ b/server/src/main/java/org/apache/iotdb/db/utils/IOUtils.java
@@ -177,4 +177,12 @@ public class IOUtils {
}
}
}
+
+ public static Throwable getRootCause(Throwable e) {
+ Throwable curr = e;
+ while (curr.getCause() != null) {
+ curr = curr.getCause();
+ }
+ return curr;
+ }
}