You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ji...@apache.org on 2020/02/05 09:39:19 UTC
[incubator-iotdb] branch cluster_node_deletion updated: fix tests
This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a commit to branch cluster_node_deletion
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/cluster_node_deletion by this push:
new 91e3dc1 fix tests
91e3dc1 is described below
commit 91e3dc1ee664dd8084befa7075cdb63e9396031d
Author: jt2594838 <jt...@163.com>
AuthorDate: Wed Feb 5 17:39:03 2020 +0800
fix tests
---
.../java/org/apache/iotdb/cluster/partition/PartitionTable.java | 5 +++--
.../org/apache/iotdb/cluster/server/member/DataGroupMember.java | 9 ++++++---
.../org/apache/iotdb/cluster/common/TestRemoteFileSnapshot.java | 2 +-
.../src/test/java/org/apache/iotdb/cluster/common/TestUtils.java | 2 +-
.../log/log/manage/FilePartitionedSnapshotLogManagerTest.java | 4 ++--
.../log/manage/FilePartitionedSnapshotLogManagerTest.java | 4 ++--
.../apache/iotdb/cluster/query/ClusterPhysicalGeneratorTest.java | 6 ++----
7 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/partition/PartitionTable.java b/cluster/src/main/java/org/apache/iotdb/cluster/partition/PartitionTable.java
index 5810f34..eefe9de 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/partition/PartitionTable.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/partition/PartitionTable.java
@@ -30,6 +30,7 @@ import org.apache.iotdb.cluster.log.Log;
import org.apache.iotdb.cluster.log.logtypes.PhysicalPlanLog;
import org.apache.iotdb.cluster.rpc.thrift.Node;
import org.apache.iotdb.cluster.utils.PartitionUtils;
+import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.engine.StorageEngine;
import org.apache.iotdb.db.exception.metadata.MetadataException;
import org.apache.iotdb.db.exception.metadata.StorageGroupNotSetException;
@@ -49,7 +50,6 @@ import org.slf4j.LoggerFactory;
public interface PartitionTable {
// static final is not necessary, it is redundant for an interface
Logger logger = LoggerFactory.getLogger(SlotPartitionTable.class);
- long PARTITION_INTERVAL = StorageEngine.getTimePartitionInterval();
/**
* Given the storageGroupName and the timestamp, return the list of nodes on which the storage
@@ -181,8 +181,9 @@ public interface PartitionTable {
long startTime, long endTime) throws StorageGroupNotSetException {
MultiKeyMap<Long, PartitionGroup> timeRangeMapRaftGroup = new MultiKeyMap<>();
String storageGroup = MManager.getInstance().getStorageGroupNameByPath(path);
+ long partitionInterval = IoTDBDescriptor.getInstance().getConfig().getPartitionInterval();
while (startTime <= endTime) {
- long nextTime = (startTime / PARTITION_INTERVAL + 1) * PARTITION_INTERVAL; //FIXME considering the time unit
+ long nextTime = (startTime / partitionInterval + 1) * partitionInterval; //FIXME considering the time unit
timeRangeMapRaftGroup.put(startTime, Math.min(nextTime - 1, endTime),
this.route(storageGroup, startTime));
startTime = nextTime;
diff --git a/cluster/src/main/java/org/apache/iotdb/cluster/server/member/DataGroupMember.java b/cluster/src/main/java/org/apache/iotdb/cluster/server/member/DataGroupMember.java
index 3e901a5..305158a 100644
--- a/cluster/src/main/java/org/apache/iotdb/cluster/server/member/DataGroupMember.java
+++ b/cluster/src/main/java/org/apache/iotdb/cluster/server/member/DataGroupMember.java
@@ -297,7 +297,8 @@ public class DataGroupMember extends RaftMember implements TSDataService.AsyncIf
// TODO-Cluster#352: The problem of duplicated data in remote files is partially resolved by
// tracking the merge history using the version numbers of the merged files. But a better
// solution still remains to be found.
- String[] pathSegments = resource.getFile().getAbsolutePath().split(File.separator);
+ String separatorString = File.separator.equals("\\") ? "\\\\" : "/";
+ String[] pathSegments = resource.getFile().getAbsolutePath().split(separatorString);
int segSize = pathSegments.length;
// {storageGroupName}/{fileName}
String storageGroupName = pathSegments[segSize - 2];
@@ -341,7 +342,8 @@ public class DataGroupMember extends RaftMember implements TSDataService.AsyncIf
private void loadRemoteResource(RemoteTsFileResource resource) {
// remote/{nodeIdentifier}/{storageGroupName}/{fileName}
- String[] pathSegments = resource.getFile().getAbsolutePath().split(File.separator);
+ String separatorString = File.separator.equals("\\") ? "\\\\" : "/";
+ String[] pathSegments = resource.getFile().getAbsolutePath().split(separatorString);
int segSize = pathSegments.length;
String storageGroupName = pathSegments[segSize - 2];
File remoteModFile =
@@ -365,7 +367,8 @@ public class DataGroupMember extends RaftMember implements TSDataService.AsyncIf
private File pullRemoteFile(RemoteTsFileResource resource, Node node) {
logger.debug("{}: pulling remote file {} from {}", name, resource, node);
- String[] pathSegments = resource.getFile().getAbsolutePath().split(File.separator);
+ String separatorString = File.separator.equals("\\") ? "\\\\" : "/";
+ String[] pathSegments = resource.getFile().getAbsolutePath().split(separatorString);
int segSize = pathSegments.length;
// remote/{nodeIdentifier}/{storageGroupName}/{fileName}
String tempFileName =
diff --git a/cluster/src/test/java/org/apache/iotdb/cluster/common/TestRemoteFileSnapshot.java b/cluster/src/test/java/org/apache/iotdb/cluster/common/TestRemoteFileSnapshot.java
index 6244649..016b706 100644
--- a/cluster/src/test/java/org/apache/iotdb/cluster/common/TestRemoteFileSnapshot.java
+++ b/cluster/src/test/java/org/apache/iotdb/cluster/common/TestRemoteFileSnapshot.java
@@ -58,7 +58,7 @@ public class TestRemoteFileSnapshot extends FileSnapshot implements RemoteSnapsh
int startTime = 12345;
for (RemoteTsFileResource tsFileResource : remoteDataFiles) {
// fake a file for each resource
- String[] splits = tsFileResource.getFile().getPath().split(File.separator);
+ String[] splits = tsFileResource.getFile().getPath().split("\\\\");
String storageGroup = splits[splits.length - 2];
InsertPlan insertPlan = new InsertPlan();
insertPlan.setDeviceId(storageGroup);
diff --git a/cluster/src/test/java/org/apache/iotdb/cluster/common/TestUtils.java b/cluster/src/test/java/org/apache/iotdb/cluster/common/TestUtils.java
index 8742303..11a2be0 100644
--- a/cluster/src/test/java/org/apache/iotdb/cluster/common/TestUtils.java
+++ b/cluster/src/test/java/org/apache/iotdb/cluster/common/TestUtils.java
@@ -67,7 +67,7 @@ public class TestUtils {
for (int i = 0; i < nodeNum; i++) {
nodes.add(getNode(i));
}
- return new SlotPartitionTable(nodes, getNode(0));
+ return new SlotPartitionTable(nodes, getNode(0), 100);
}
public static String getTestSg(int i) {
diff --git a/cluster/src/test/java/org/apache/iotdb/cluster/log/log/manage/FilePartitionedSnapshotLogManagerTest.java b/cluster/src/test/java/org/apache/iotdb/cluster/log/log/manage/FilePartitionedSnapshotLogManagerTest.java
index 77cc96b..dcd1220 100644
--- a/cluster/src/test/java/org/apache/iotdb/cluster/log/log/manage/FilePartitionedSnapshotLogManagerTest.java
+++ b/cluster/src/test/java/org/apache/iotdb/cluster/log/log/manage/FilePartitionedSnapshotLogManagerTest.java
@@ -60,7 +60,7 @@ public class FilePartitionedSnapshotLogManagerTest extends IoTDBTest {
manager.commitLog(10);
// create files for sgs
- for (int i = 0; i < 3; i++) {
+ for (int i = 1; i < 4; i++) {
String sg = TestUtils.getTestSg(i);
for (int j = 0; j < 4; j++) {
// closed files
@@ -73,7 +73,7 @@ public class FilePartitionedSnapshotLogManagerTest extends IoTDBTest {
manager.takeSnapshot();
PartitionedSnapshot snapshot = (PartitionedSnapshot) manager.getSnapshot();
- for (int i = 0; i < 3; i++) {
+ for (int i = 1; i < 4; i++) {
FileSnapshot fileSnapshot =
(FileSnapshot) snapshot.getSnapshot(PartitionUtils.calculateStorageGroupSlot(
TestUtils.getTestSg(i), 0, 100));
diff --git a/cluster/src/test/java/org/apache/iotdb/cluster/log/manage/FilePartitionedSnapshotLogManagerTest.java b/cluster/src/test/java/org/apache/iotdb/cluster/log/manage/FilePartitionedSnapshotLogManagerTest.java
index 344f0bb..ab1cc25 100644
--- a/cluster/src/test/java/org/apache/iotdb/cluster/log/manage/FilePartitionedSnapshotLogManagerTest.java
+++ b/cluster/src/test/java/org/apache/iotdb/cluster/log/manage/FilePartitionedSnapshotLogManagerTest.java
@@ -59,7 +59,7 @@ public class FilePartitionedSnapshotLogManagerTest extends IoTDBTest {
manager.commitLog(10);
// create files for sgs
- for (int i = 0; i < 3; i++) {
+ for (int i = 1; i < 4; i++) {
String sg = TestUtils.getTestSg(i);
for (int j = 0; j < 4; j++) {
// closed files
@@ -72,7 +72,7 @@ public class FilePartitionedSnapshotLogManagerTest extends IoTDBTest {
manager.takeSnapshot();
PartitionedSnapshot snapshot = (PartitionedSnapshot) manager.getSnapshot();
- for (int i = 0; i < 3; i++) {
+ for (int i = 1; i < 4; i++) {
FileSnapshot fileSnapshot =
(FileSnapshot) snapshot.getSnapshot(PartitionUtils.calculateStorageGroupSlot(
TestUtils.getTestSg(i), 0, 100));
diff --git a/cluster/src/test/java/org/apache/iotdb/cluster/query/ClusterPhysicalGeneratorTest.java b/cluster/src/test/java/org/apache/iotdb/cluster/query/ClusterPhysicalGeneratorTest.java
index 74fe770..fdb14e3 100644
--- a/cluster/src/test/java/org/apache/iotdb/cluster/query/ClusterPhysicalGeneratorTest.java
+++ b/cluster/src/test/java/org/apache/iotdb/cluster/query/ClusterPhysicalGeneratorTest.java
@@ -47,10 +47,9 @@ public class ClusterPhysicalGeneratorTest extends BaseQueryTest{
@Test
public void test() throws QueryProcessException {
QueryOperator operator = new QueryOperator(SQLConstant.TOK_QUERY);
- operator.setGroupByDevice(true);
SelectOperator selectOperator = new SelectOperator(SQLConstant.TOK_SELECT);
- selectOperator.setSuffixPathList(Collections.singletonList(new Path("*")));
+ selectOperator.setSuffixPathList(pathList);
FromOperator fromOperator = new FromOperator(SQLConstant.TOK_FROM);
fromOperator.addPrefixTablePath(new Path(TestUtils.getTestSg(0)));
@@ -58,8 +57,7 @@ public class ClusterPhysicalGeneratorTest extends BaseQueryTest{
operator.setFromOperator(fromOperator);
QueryPlan plan = (QueryPlan) physicalGenerator.transformToPhysicalPlan(operator);
- // TODO: Enable this when IOTDB-412 is fixed
- //assertEquals(pathList, plan.getDeduplicatedPaths());
+ assertEquals(pathList, plan.getDeduplicatedPaths());
assertEquals(dataTypes, plan.getDeduplicatedDataTypes());
}
}
\ No newline at end of file