You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by wa...@apache.org on 2022/05/26 01:05:50 UTC
[iotdb] branch master updated: [IOTDB-3221] Fix NPE exception when getOrCreatePartition (#5988)
This is an automated email from the ASF dual-hosted git repository.
wangchao316 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 882dbcfc2e [IOTDB-3221] Fix NPE exception when getOrCreatePartition (#5988)
882dbcfc2e is described below
commit 882dbcfc2e2fb9dd030a10e662898c611f60e642
Author: YongzaoDan <33...@users.noreply.github.com>
AuthorDate: Thu May 26 09:05:45 2022 +0800
[IOTDB-3221] Fix NPE exception when getOrCreatePartition (#5988)
[IOTDB-3221] Fix NPE exception when getOrCreatePartition
---
.../iotdb/confignode/manager/ConfigManager.java | 24 ++++++++++++-------
.../thrift/ConfigNodeRPCServiceProcessorTest.java | 28 +++++++++++++++++-----
2 files changed, 38 insertions(+), 14 deletions(-)
diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java b/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
index 34477bbd6c..fcdd767d39 100644
--- a/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
+++ b/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
@@ -362,10 +362,14 @@ public class ConfigManager implements Manager {
partitionManager.getOrCreateSchemaPartition(getOrCreateSchemaPartitionReq);
// TODO: Delete or hide this LOGGER before officially release.
- LOGGER.info(
- "GetOrCreateSchemaPartition interface receive devicePaths: {}, return SchemaPartition: {}",
- devicePaths,
- resp.getSchemaPartition().getSchemaPartitionMap());
+ if (resp.getStatus().getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+ LOGGER.info(
+ "GetOrCreateSchemaPartition success. receive devicePaths: {}, return SchemaPartition: {}",
+ devicePaths,
+ resp.getSchemaPartition().getSchemaPartitionMap());
+ } else {
+ LOGGER.info("GetOrCreateSchemaPartition failed: {}", resp.getStatus());
+ }
return resp;
} else {
@@ -433,10 +437,14 @@ public class ConfigManager implements Manager {
partitionManager.getOrCreateDataPartition(getOrCreateDataPartitionReq);
// TODO: Delete or hide this LOGGER before officially release.
- LOGGER.info(
- "GetOrCreateDataPartition receive PartitionSlotsMap: {}, return DataPartition: {}",
- getOrCreateDataPartitionReq.getPartitionSlotsMap(),
- resp.getDataPartition().getDataPartitionMap());
+ if (resp.getStatus().getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+ LOGGER.info(
+ "GetOrCreateDataPartition success. receive PartitionSlotsMap: {}, return DataPartition: {}",
+ getOrCreateDataPartitionReq.getPartitionSlotsMap(),
+ resp.getDataPartition().getDataPartitionMap());
+ } else {
+ LOGGER.info("GetOrCreateDataPartition failed: {}", resp.getStatus());
+ }
return resp;
} else {
diff --git a/confignode/src/test/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessorTest.java b/confignode/src/test/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessorTest.java
index 929145250b..87ad5c0374 100644
--- a/confignode/src/test/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessorTest.java
+++ b/confignode/src/test/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessorTest.java
@@ -325,15 +325,24 @@ public class ConfigNodeRPCServiceProcessorTest {
Map<String, Map<TSeriesPartitionSlot, TRegionReplicaSet>> schemaPartitionMap;
- // register DataNodes
- registerDataNodes();
-
// Set StorageGroups
status = processor.setStorageGroup(new TSetStorageGroupReq(new TStorageGroupSchema(sg0)));
Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
status = processor.setStorageGroup(new TSetStorageGroupReq(new TStorageGroupSchema(sg1)));
Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
+ // Test getOrCreateSchemaPartition, the result should be NOT_ENOUGH_DATANODE
+ buffer = generatePatternTreeBuffer(new String[] {d00, d01, allSg1});
+ schemaPartitionReq = new TSchemaPartitionReq(buffer);
+ schemaPartitionResp = processor.getOrCreateSchemaPartition(schemaPartitionReq);
+ Assert.assertEquals(
+ TSStatusCode.NOT_ENOUGH_DATA_NODE.getStatusCode(),
+ schemaPartitionResp.getStatus().getCode());
+ Assert.assertNull(schemaPartitionResp.getSchemaRegionMap());
+
+ // register DataNodes
+ registerDataNodes();
+
// Test getSchemaPartition, the result should be empty
buffer = generatePatternTreeBuffer(new String[] {d00, d01, allSg1});
schemaPartitionReq = new TSchemaPartitionReq(buffer);
@@ -509,9 +518,6 @@ public class ConfigNodeRPCServiceProcessorTest {
TDataPartitionReq dataPartitionReq;
TDataPartitionResp dataPartitionResp;
- // register DataNodes
- registerDataNodes();
-
// Prepare partitionSlotsMap
Map<String, Map<TSeriesPartitionSlot, List<TTimePartitionSlot>>> partitionSlotsMap0 =
constructPartitionSlotsMap(storageGroupNum, seriesPartitionSlotNum, timePartitionSlotNum);
@@ -526,6 +532,16 @@ public class ConfigNodeRPCServiceProcessorTest {
Assert.assertEquals(TSStatusCode.SUCCESS_STATUS.getStatusCode(), status.getCode());
}
+ // Test getOrCreateDataPartition, the result should be NOT_ENOUGH_DATANODE
+ dataPartitionReq = new TDataPartitionReq(partitionSlotsMap0);
+ dataPartitionResp = processor.getOrCreateDataPartition(dataPartitionReq);
+ Assert.assertEquals(
+ TSStatusCode.NOT_ENOUGH_DATA_NODE.getStatusCode(), dataPartitionResp.getStatus().getCode());
+ Assert.assertNull(dataPartitionResp.getDataPartitionMap());
+
+ // register DataNodes
+ registerDataNodes();
+
// Test getDataPartition, the result should be empty
dataPartitionReq = new TDataPartitionReq(partitionSlotsMap0);
dataPartitionResp = processor.getDataPartition(dataPartitionReq);