This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch rel/0.13
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/rel/0.13 by this push:
new 6a88961255 [To rel/0.13][IOTDB-4004] Fix mvn release:prepare failed
cause by singleton HashVirtualPartitioner (#6845)
6a88961255 is described below
commit 6a88961255b1bc625def6c8a19ecb158796b7d13
Author: Chen YZ <[email protected]>
AuthorDate: Sun Jul 31 16:11:55 2022 +0800
[To rel/0.13][IOTDB-4004] Fix mvn release:prepare failed cause by singleton
HashVirtualPartitioner (#6845)
---
.../db/engine/storagegroup/virtualSg/HashVirtualPartitioner.java | 8 +++++++-
.../src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java | 4 ++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git
a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/virtualSg/HashVirtualPartitioner.java
b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/virtualSg/HashVirtualPartitioner.java
index 14537e8ef7..1166f497c2 100644
---
a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/virtualSg/HashVirtualPartitioner.java
+++
b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/virtualSg/HashVirtualPartitioner.java
@@ -20,11 +20,12 @@ package org.apache.iotdb.db.engine.storagegroup.virtualSg;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.metadata.path.PartialPath;
+import org.apache.iotdb.db.utils.TestOnly;
public class HashVirtualPartitioner implements VirtualPartitioner {
/** total number of virtual storage groups */
- public static int STORAGE_GROUP_NUM =
+ private static int STORAGE_GROUP_NUM =
IoTDBDescriptor.getInstance().getConfig().getVirtualStorageGroupNum();
private HashVirtualPartitioner() {}
@@ -47,6 +48,11 @@ public class HashVirtualPartitioner implements
VirtualPartitioner {
return Math.abs(deviceId.hashCode() % STORAGE_GROUP_NUM);
}
+ @TestOnly
+ public void reset() {
+ STORAGE_GROUP_NUM =
IoTDBDescriptor.getInstance().getConfig().getVirtualStorageGroupNum();
+ }
+
private static class HashVirtualPartitionerHolder {
private static final HashVirtualPartitioner INSTANCE = new
HashVirtualPartitioner();
diff --git
a/server/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java
b/server/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java
index f41ca37f9b..a7bd78165b 100644
--- a/server/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java
+++ b/server/src/test/java/org/apache/iotdb/db/utils/EnvironmentUtils.java
@@ -31,6 +31,7 @@ import org.apache.iotdb.db.engine.cache.ChunkCache;
import org.apache.iotdb.db.engine.cache.TimeSeriesMetadataCache;
import org.apache.iotdb.db.engine.compaction.CompactionTaskManager;
import org.apache.iotdb.db.engine.cq.ContinuousQueryService;
+import
org.apache.iotdb.db.engine.storagegroup.virtualSg.HashVirtualPartitioner;
import org.apache.iotdb.db.engine.trigger.service.TriggerRegistrationService;
import org.apache.iotdb.db.exception.ContinuousQueryException;
import org.apache.iotdb.db.exception.StorageEngineException;
@@ -283,6 +284,9 @@ public class EnvironmentUtils {
// reset id method
DeviceIDFactory.getInstance().reset();
+ // reset HashVirtualPartitioner
+ HashVirtualPartitioner.getInstance().reset();
+
TEST_QUERY_JOB_ID = QueryResourceManager.getInstance().assignQueryId(true);
TEST_QUERY_CONTEXT = new QueryContext(TEST_QUERY_JOB_ID);
}