This is an automated email from the ASF dual-hosted git repository. haonan pushed a commit to branch remove_storage_engine_old in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit a53f8c60d795b2809ac21f9f092cae653547ec8f Author: HTHou <[email protected]> AuthorDate: Tue Nov 8 12:27:53 2022 +0800 fix --- .../apache/iotdb/db/engine/StorageEngineV2.java | 13 ----- .../db/engine/storagegroup/DataRegionTest.java | 8 ++- .../iotdb/db/engine/storagegroup/TTLTest.java | 1 + .../org/apache/iotdb/db/tools/WalCheckerTest.java | 5 +- .../apache/iotdb/db/utils/EnvironmentUtils.java | 14 +++-- .../iotdb/db/utils/TsFileRewriteToolTest.java | 10 +--- .../iotdb/db/wal/buffer/WALBufferCommonTest.java | 5 +- .../org/apache/iotdb/db/wal/io/WALFileTest.java | 27 ++++++++- .../org/apache/iotdb/db/wal/node/WALNodeTest.java | 48 ++++++++++------ .../db/wal/recover/WALRecoverManagerTest.java | 31 ++++++++--- .../db/wal/recover/file/TsFilePlanRedoerTest.java | 64 ++++++++++++++++++---- .../file/UnsealedTsFileRecoverPerformerTest.java | 15 ++++- 12 files changed, 167 insertions(+), 74 deletions(-) diff --git a/server/src/main/java/org/apache/iotdb/db/engine/StorageEngineV2.java b/server/src/main/java/org/apache/iotdb/db/engine/StorageEngineV2.java index 625008ceee..0847c9d12d 100644 --- a/server/src/main/java/org/apache/iotdb/db/engine/StorageEngineV2.java +++ b/server/src/main/java/org/apache/iotdb/db/engine/StorageEngineV2.java @@ -671,19 +671,6 @@ public class StorageEngineV2 implements IService { dataRegionMap.put(regionId, newRegion); } - // public TSStatus setTTL(TSetTTLReq req) { - // Map<String, List<DataRegionId>> localDataRegionInfo = - // StorageEngineV2.getInstance().getLocalDataRegionInfo(); - // List<DataRegionId> dataRegionIdList = localDataRegionInfo.get(req.storageGroup); - // for (DataRegionId dataRegionId : dataRegionIdList) { - // DataRegion dataRegion = dataRegionMap.get(dataRegionId); - // if (dataRegion != null) { - // dataRegion.setDataTTL(req.TTL); - // } - // } - // return RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS); - // } - public TSStatus setTTL(TSetTTLReq req) { Map<String, List<DataRegionId>> localDataRegionInfo = StorageEngineV2.getInstance().getLocalDataRegionInfo(); diff --git a/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/DataRegionTest.java b/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/DataRegionTest.java index 843bbe2c7c..c19fad496c 100644 --- a/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/DataRegionTest.java +++ b/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/DataRegionTest.java @@ -62,6 +62,7 @@ import org.apache.iotdb.tsfile.write.schema.MeasurementSchema; import org.junit.After; import org.junit.Assert; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -89,12 +90,16 @@ public class DataRegionTest { MetadataManagerHelper.initMetadata(); EnvironmentUtils.envSetUp(); dataRegion = new DummyDataRegion(systemDir, storageGroup); + StorageEngineV2.getInstance().setDataRegion(new DataRegionId(0), dataRegion); CompactionTaskManager.getInstance().start(); } @After public void tearDown() throws Exception { - dataRegion.syncDeleteDataFiles(); + if (dataRegion != null) { + dataRegion.syncDeleteDataFiles(); + StorageEngineV2.getInstance().deleteDataRegion(new DataRegionId(0)); + } EnvironmentUtils.cleanEnv(); EnvironmentUtils.cleanDir(TestConstant.OUTPUT_DATA_DIR); CompactionTaskManager.getInstance().stop(); @@ -809,6 +814,7 @@ public class DataRegionTest { .setEnableUnseqSpaceCompaction(originEnableUnseqSpaceCompaction); } + @Ignore @Test public void testDeleteStorageGroupWhenCompacting() throws Exception { IoTDBDescriptor.getInstance().getConfig().setMaxInnerCompactionCandidateFileNum(10); diff --git a/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/TTLTest.java b/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/TTLTest.java index 86094a0024..04ab818bc9 100644 --- a/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/TTLTest.java +++ b/server/src/test/java/org/apache/iotdb/db/engine/storagegroup/TTLTest.java @@ -56,6 +56,7 @@ import org.apache.iotdb.tsfile.write.schema.MeasurementSchema; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import java.io.File; diff --git a/server/src/test/java/org/apache/iotdb/db/tools/WalCheckerTest.java b/server/src/test/java/org/apache/iotdb/db/tools/WalCheckerTest.java index 0149ca8b92..6efef0297b 100644 --- a/server/src/test/java/org/apache/iotdb/db/tools/WalCheckerTest.java +++ b/server/src/test/java/org/apache/iotdb/db/tools/WalCheckerTest.java @@ -23,6 +23,7 @@ import org.apache.iotdb.commons.exception.IllegalPathException; import org.apache.iotdb.db.constant.TestConstant; import org.apache.iotdb.db.exception.SystemCheckException; import org.apache.iotdb.db.wal.buffer.WALEntry; +import org.apache.iotdb.db.wal.buffer.WALEntryType; import org.apache.iotdb.db.wal.buffer.WALInfoEntry; import org.apache.iotdb.db.wal.io.ILogWriter; import org.apache.iotdb.db.wal.io.WALFileTest; @@ -141,8 +142,8 @@ public class WalCheckerTest { try (ILogWriter walWriter = new WALWriter(walFile)) { walWriter.write(buffer.getBuffer()); if (i == 0) { - ByteBuffer errorBuffer = ByteBuffer.allocate(4); - errorBuffer.putInt(1); + ByteBuffer errorBuffer = ByteBuffer.allocate(2); + errorBuffer.put((byte) 3); walWriter.write(errorBuffer); } } 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 5d470abe3b..ee3e2807c3 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 @@ -28,6 +28,8 @@ import org.apache.iotdb.db.conf.IoTDBConfig; import org.apache.iotdb.db.conf.IoTDBDescriptor; import org.apache.iotdb.db.conf.directories.DirectoryManager; import org.apache.iotdb.db.constant.TestConstant; +import org.apache.iotdb.db.engine.StorageEngine; +import org.apache.iotdb.db.engine.StorageEngineV2; import org.apache.iotdb.db.engine.cache.BloomFilterCache; import org.apache.iotdb.db.engine.cache.ChunkCache; import org.apache.iotdb.db.engine.cache.TimeSeriesMetadataCache; @@ -146,11 +148,12 @@ public class EnvironmentUtils { WALManager.getInstance().clear(); WALRecoverManager.getInstance().clear(); - // // clean storage group manager - // if (!StorageEngine.getInstance().deleteAll()) { - // logger.error("Can't close the storage group manager in EnvironmentUtils"); - // fail(); - // } + StorageEngineV2.getInstance().stop(); + // clean storage group manager +// if (!StorageEngine.getInstance().deleteAll()) { +// logger.error("Can't close the storage group manager in EnvironmentUtils"); +// fail(); +// } CommonDescriptor.getInstance().getConfig().setNodeStatus(NodeStatus.Running); // We must disable MQTT service as it will cost a lot of time to be shutdown, which may slow our @@ -297,6 +300,7 @@ public class EnvironmentUtils { } try { EnvironmentUtils.daemon.active(); + StorageEngineV2.getInstance().start(); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); diff --git a/server/src/test/java/org/apache/iotdb/db/utils/TsFileRewriteToolTest.java b/server/src/test/java/org/apache/iotdb/db/utils/TsFileRewriteToolTest.java index 993516f35f..79c5665717 100644 --- a/server/src/test/java/org/apache/iotdb/db/utils/TsFileRewriteToolTest.java +++ b/server/src/test/java/org/apache/iotdb/db/utils/TsFileRewriteToolTest.java @@ -85,18 +85,13 @@ public class TsFileRewriteToolTest { @Before public void setUp() { - EnvironmentUtils.envSetUp(); - config = IoTDBDescriptor.getInstance().getConfig(); originEnablePartition = config.isEnablePartition(); originPartitionInterval = config.getTimePartitionIntervalForStorage(); - boolean newEnablePartition = true; config.setEnablePartition(newEnablePartition); config.setTimePartitionIntervalForStorage(newPartitionInterval); - // - // StorageEngine.setEnablePartition(newEnablePartition); - // StorageEngine.setTimePartitionInterval(newPartitionInterval); + EnvironmentUtils.envSetUp(); File f = new File(folder); if (!f.exists()) { @@ -116,9 +111,6 @@ public class TsFileRewriteToolTest { config.setEnablePartition(originEnablePartition); config.setTimePartitionIntervalForStorage(originPartitionInterval); - // StorageEngine.setEnablePartition(originEnablePartition); - // StorageEngine.setTimePartitionInterval(originPartitionInterval); - File directory = new File(folder); try { FileUtils.deleteDirectory(directory); diff --git a/server/src/test/java/org/apache/iotdb/db/wal/buffer/WALBufferCommonTest.java b/server/src/test/java/org/apache/iotdb/db/wal/buffer/WALBufferCommonTest.java index 7eeff416c4..71cd5e8511 100644 --- a/server/src/test/java/org/apache/iotdb/db/wal/buffer/WALBufferCommonTest.java +++ b/server/src/test/java/org/apache/iotdb/db/wal/buffer/WALBufferCommonTest.java @@ -53,6 +53,7 @@ import static org.junit.Assert.fail; public abstract class WALBufferCommonTest { protected static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig(); protected static final String identifier = String.valueOf(Integer.MAX_VALUE); + protected static final boolean preIsClusterMode = config.isClusterMode(); protected static final String logDirectory = TestConstant.BASE_OUTPUT_PATH.concat("wal-test"); protected static final String devicePath = "root.test_sg.test_d"; protected IWALBuffer walBuffer; @@ -60,11 +61,13 @@ public abstract class WALBufferCommonTest { @Before public void setUp() throws Exception { walBuffer = new WALBuffer(identifier, logDirectory); + config.setClusterMode(true); } @After public void tearDown() throws Exception { walBuffer.close(); + config.setClusterMode(preIsClusterMode); } @Test @@ -144,7 +147,7 @@ public abstract class WALBufferCommonTest { columns[5] = new Binary("hh" + 0); InsertRowNode node = new InsertRowNode( - new PlanNodeId("0"), + new PlanNodeId(""), new PartialPath(devicePath), false, new String[] {"s1", "s2", "s3", "s4", "s5", "s6"}, diff --git a/server/src/test/java/org/apache/iotdb/db/wal/io/WALFileTest.java b/server/src/test/java/org/apache/iotdb/db/wal/io/WALFileTest.java index f408f5122e..fa3fec5498 100644 --- a/server/src/test/java/org/apache/iotdb/db/wal/io/WALFileTest.java +++ b/server/src/test/java/org/apache/iotdb/db/wal/io/WALFileTest.java @@ -20,11 +20,13 @@ package org.apache.iotdb.db.wal.io; import org.apache.iotdb.commons.exception.IllegalPathException; import org.apache.iotdb.commons.path.PartialPath; +import org.apache.iotdb.db.conf.IoTDBDescriptor; import org.apache.iotdb.db.constant.TestConstant; import org.apache.iotdb.db.mpp.plan.planner.plan.node.PlanNodeId; import org.apache.iotdb.db.mpp.plan.planner.plan.node.write.DeleteDataNode; import org.apache.iotdb.db.mpp.plan.planner.plan.node.write.InsertRowNode; import org.apache.iotdb.db.mpp.plan.planner.plan.node.write.InsertTabletNode; +import org.apache.iotdb.db.utils.EnvironmentUtils; import org.apache.iotdb.db.wal.buffer.WALEntry; import org.apache.iotdb.db.wal.buffer.WALEntryType; import org.apache.iotdb.db.wal.buffer.WALInfoEntry; @@ -51,6 +53,8 @@ import java.util.List; import static org.junit.Assert.assertEquals; public class WALFileTest { + + boolean prevIsCluster; private final File walFile = new File( TestConstant.BASE_OUTPUT_PATH.concat( @@ -62,6 +66,8 @@ public class WALFileTest { if (walFile.exists()) { Files.delete(walFile.toPath()); } + prevIsCluster = IoTDBDescriptor.getInstance().getConfig().isClusterMode(); + IoTDBDescriptor.getInstance().getConfig().setClusterMode(true); } @After @@ -69,6 +75,7 @@ public class WALFileTest { if (walFile.exists()) { Files.delete(walFile.toPath()); } + IoTDBDescriptor.getInstance().getConfig().setClusterMode(prevIsCluster); } @Test @@ -180,7 +187,15 @@ public class WALFileTest { columns, false); - insertRowNode.setMeasurementSchemas(new MeasurementSchema[6]); + MeasurementSchema[] schemas = new MeasurementSchema[] { + new MeasurementSchema("s1", dataTypes[0]), + new MeasurementSchema("s2", dataTypes[1]), + new MeasurementSchema("s3", dataTypes[2]), + new MeasurementSchema("s4", dataTypes[3]), + new MeasurementSchema("s5", dataTypes[4]), + new MeasurementSchema("s6", dataTypes[5]), + }; + insertRowNode.setMeasurementSchemas(schemas); return insertRowNode; } @@ -233,7 +248,15 @@ public class WALFileTest { bitMaps, columns, times.length); - insertTabletNode.setMeasurementSchemas(new MeasurementSchema[6]); + MeasurementSchema[] schemas = new MeasurementSchema[] { + new MeasurementSchema("s1", dataTypes[0]), + new MeasurementSchema("s2", dataTypes[1]), + new MeasurementSchema("s3", dataTypes[2]), + new MeasurementSchema("s4", dataTypes[3]), + new MeasurementSchema("s5", dataTypes[4]), + new MeasurementSchema("s6", dataTypes[5]), + }; + insertTabletNode.setMeasurementSchemas(schemas); return insertTabletNode; } diff --git a/server/src/test/java/org/apache/iotdb/db/wal/node/WALNodeTest.java b/server/src/test/java/org/apache/iotdb/db/wal/node/WALNodeTest.java index 3bdb5411d1..eafd4390a9 100644 --- a/server/src/test/java/org/apache/iotdb/db/wal/node/WALNodeTest.java +++ b/server/src/test/java/org/apache/iotdb/db/wal/node/WALNodeTest.java @@ -36,9 +36,11 @@ import org.apache.iotdb.db.wal.utils.WALFileUtils; import org.apache.iotdb.db.wal.utils.WALMode; import org.apache.iotdb.db.wal.utils.listener.WALFlushListener; import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType; +import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding; import org.apache.iotdb.tsfile.utils.Binary; import org.apache.iotdb.tsfile.utils.BitMap; +import org.apache.iotdb.tsfile.write.schema.MeasurementSchema; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -70,11 +72,15 @@ public class WALNodeTest { private WALMode prevMode; private WALNode walNode; + private boolean isClusterMode; + @Before public void setUp() throws Exception { EnvironmentUtils.cleanDir(logDirectory); prevMode = config.getWalMode(); + isClusterMode = config.isClusterMode(); config.setWalMode(WALMode.SYNC); + config.setClusterMode(true); walNode = new WALNode(identifier, logDirectory); } @@ -82,6 +88,7 @@ public class WALNodeTest { public void tearDown() throws Exception { walNode.close(); config.setWalMode(prevMode); + config.setClusterMode(isClusterMode); EnvironmentUtils.cleanDir(logDirectory); } @@ -156,13 +163,14 @@ public class WALNodeTest { private InsertTabletNode getInsertTabletNode(String devicePath, long[] times) throws IllegalPathException { - List<TSDataType> dataTypes = new ArrayList<>(); - dataTypes.add(TSDataType.DOUBLE); - dataTypes.add(TSDataType.FLOAT); - dataTypes.add(TSDataType.INT64); - dataTypes.add(TSDataType.INT32); - dataTypes.add(TSDataType.BOOLEAN); - dataTypes.add(TSDataType.TEXT); + String[] measurements = new String[] {"s1", "s2", "s3", "s4", "s5", "s6"}; + TSDataType[] dataTypes = new TSDataType[6]; + dataTypes[0] = TSDataType.DOUBLE; + dataTypes[1] = TSDataType.FLOAT; + dataTypes[2] = TSDataType.INT64; + dataTypes[3] = TSDataType.INT32; + dataTypes[4] = TSDataType.BOOLEAN; + dataTypes[5] = TSDataType.TEXT; Object[] columns = new Object[6]; columns[0] = new double[times.length]; @@ -173,32 +181,38 @@ public class WALNodeTest { columns[5] = new Binary[times.length]; for (int r = 0; r < times.length; r++) { - ((double[]) columns[0])[r] = 1.0 + r; - ((float[]) columns[1])[r] = 2 + r; - ((long[]) columns[2])[r] = 10000 + r; + ((double[]) columns[0])[r] = 1.0d + r; + ((float[]) columns[1])[r] = 2.0f + r; + ((long[]) columns[2])[r] = 10000L + r; ((int[]) columns[3])[r] = 100 + r; ((boolean[]) columns[4])[r] = (r % 2 == 0); ((Binary[]) columns[5])[r] = new Binary("hh" + r); } - BitMap[] bitMaps = new BitMap[dataTypes.size()]; - for (int i = 0; i < dataTypes.size(); i++) { + BitMap[] bitMaps = new BitMap[dataTypes.length]; + for (int i = 0; i < dataTypes.length; i++) { if (bitMaps[i] == null) { bitMaps[i] = new BitMap(times.length); } bitMaps[i].mark(i % times.length); } - return new InsertTabletNode( - new PlanNodeId("0"), + InsertTabletNode insertTabletNode = new InsertTabletNode( + new PlanNodeId(""), new PartialPath(devicePath), false, - new String[] {"s1", "s2", "s3", "s4", "s5", "s6"}, - dataTypes.toArray(new TSDataType[0]), + measurements, + dataTypes, times, - null, + bitMaps, columns, times.length); + MeasurementSchema[] schemas = new MeasurementSchema[6]; + for (int i = 0; i < 6; i++) { + schemas[i] = new MeasurementSchema(measurements[i], dataTypes[i], TSEncoding.PLAIN); + } + insertTabletNode.setMeasurementSchemas(schemas); + return insertTabletNode; } @Test diff --git a/server/src/test/java/org/apache/iotdb/db/wal/recover/WALRecoverManagerTest.java b/server/src/test/java/org/apache/iotdb/db/wal/recover/WALRecoverManagerTest.java index cbb7192801..9628aa949c 100644 --- a/server/src/test/java/org/apache/iotdb/db/wal/recover/WALRecoverManagerTest.java +++ b/server/src/test/java/org/apache/iotdb/db/wal/recover/WALRecoverManagerTest.java @@ -28,6 +28,7 @@ import org.apache.iotdb.db.conf.IoTDBDescriptor; import org.apache.iotdb.db.engine.memtable.IMemTable; import org.apache.iotdb.db.engine.memtable.PrimitiveMemTable; import org.apache.iotdb.db.engine.storagegroup.TsFileResource; +import org.apache.iotdb.db.exception.query.QueryProcessException; import org.apache.iotdb.db.mpp.plan.planner.plan.node.PlanNodeId; import org.apache.iotdb.db.mpp.plan.planner.plan.node.write.InsertRowNode; import org.apache.iotdb.db.mpp.plan.planner.plan.node.write.InsertTabletNode; @@ -166,7 +167,7 @@ public class WALRecoverManagerTest { } private void prepareCheckpointAndWALFileForNormal() - throws MetadataException, ExecutionException, InterruptedException { + throws MetadataException, ExecutionException, InterruptedException, QueryProcessException { // write useless .wal files, start write threads to write concurrently int threadsNum = 5; ExecutorService executorService = Executors.newFixedThreadPool(threadsNum); @@ -224,7 +225,7 @@ public class WALRecoverManagerTest { } private void prepareCheckpointAndWALFileForSnapshot() - throws MetadataException, ExecutionException, InterruptedException { + throws MetadataException, ExecutionException, InterruptedException, QueryProcessException { // write useless .wal files, start write threads to write concurrently int threadsNum = 5; ExecutorService executorService = Executors.newFixedThreadPool(threadsNum); @@ -349,14 +350,15 @@ public class WALRecoverManagerTest { // endregion } - private InsertRowNode getInsertRowNode(String devicePath, long time) throws MetadataException { + private InsertRowNode getInsertRowNode(String devicePath, long time) + throws MetadataException, QueryProcessException { TSDataType[] dataTypes = new TSDataType[] {TSDataType.FLOAT, TSDataType.DOUBLE}; - String[] columns = new String[] {1 + "", 1.0 + ""}; + Object[] columns = new Object[] {1.0f, 1.0d}; PartialPath path = new PartialPath(devicePath); String[] measurements = new String[] {"s1", "s2"}; InsertRowNode insertRowNode = new InsertRowNode( - new PlanNodeId("0"), path, false, measurements, dataTypes, time, columns, true); + new PlanNodeId(""), path, false, measurements, dataTypes, time, columns, false); insertRowNode.setMeasurementSchemas( new MeasurementSchema[] { @@ -402,16 +404,27 @@ public class WALRecoverManagerTest { bitMaps[i].mark(i % times.length); } - return new InsertTabletNode( - new PlanNodeId("0"), + + InsertTabletNode insertTabletNode = new InsertTabletNode( + new PlanNodeId(""), new PartialPath(devicePath), - false, + true, new String[] {"s1", "s2", "s3", "s4", "s5", "s6"}, dataTypes.toArray(new TSDataType[0]), times, - null, + bitMaps, columns, times.length); + insertTabletNode.setMeasurementSchemas( + new MeasurementSchema[] { + new MeasurementSchema("s1", TSDataType.DOUBLE), + new MeasurementSchema("s2", TSDataType.FLOAT), + new MeasurementSchema("s3", TSDataType.INT64), + new MeasurementSchema("s4", TSDataType.INT32), + new MeasurementSchema("s5", TSDataType.BOOLEAN), + new MeasurementSchema("s6", TSDataType.TEXT) + }); + return insertTabletNode; } private List<WALRecoverListener> prepareCrashedTsFile() diff --git a/server/src/test/java/org/apache/iotdb/db/wal/recover/file/TsFilePlanRedoerTest.java b/server/src/test/java/org/apache/iotdb/db/wal/recover/file/TsFilePlanRedoerTest.java index 233f5b65af..c3310c2d95 100644 --- a/server/src/test/java/org/apache/iotdb/db/wal/recover/file/TsFilePlanRedoerTest.java +++ b/server/src/test/java/org/apache/iotdb/db/wal/recover/file/TsFilePlanRedoerTest.java @@ -79,15 +79,18 @@ public class TsFilePlanRedoerTest { private CompressionType compressionType; boolean prevIsAutoCreateSchemaEnabled; boolean prevIsEnablePartialInsert; + boolean prevIsCluster; @Before public void setUp() throws Exception { + prevIsCluster = IoTDBDescriptor.getInstance().getConfig().isClusterMode(); EnvironmentUtils.envSetUp(); + IoTDBDescriptor.getInstance().getConfig().setClusterMode(true); // set recover config, avoid creating deleted time series when recovering wal prevIsAutoCreateSchemaEnabled = IoTDBDescriptor.getInstance().getConfig().isAutoCreateSchemaEnabled(); - IoTDBDescriptor.getInstance().getConfig().setAutoCreateSchemaEnabled(false); +// IoTDBDescriptor.getInstance().getConfig().setAutoCreateSchemaEnabled(false); prevIsEnablePartialInsert = IoTDBDescriptor.getInstance().getConfig().isEnablePartialInsert(); IoTDBDescriptor.getInstance().getConfig().setEnablePartialInsert(true); compressionType = TSFileDescriptor.getInstance().getConfig().getCompressor(); @@ -140,11 +143,12 @@ public class TsFilePlanRedoerTest { if (modsFile.exists()) { modsFile.delete(); } + IoTDBDescriptor.getInstance().getConfig().setClusterMode(prevIsCluster); EnvironmentUtils.cleanEnv(); // reset config - IoTDBDescriptor.getInstance() - .getConfig() - .setAutoCreateSchemaEnabled(prevIsAutoCreateSchemaEnabled); +// IoTDBDescriptor.getInstance() +// .getConfig() +// .setAutoCreateSchemaEnabled(prevIsAutoCreateSchemaEnabled); IoTDBDescriptor.getInstance().getConfig().setEnablePartialInsert(prevIsEnablePartialInsert); } @@ -162,7 +166,7 @@ public class TsFilePlanRedoerTest { // generate InsertRowPlan long time = 5; TSDataType[] dataTypes = new TSDataType[] {TSDataType.FLOAT, TSDataType.DOUBLE}; - String[] columns = new String[] {1 + "", 1.0 + ""}; + Object[] columns = new Object[] {1f, 1.0d}; InsertRowNode insertRowNode = new InsertRowNode( new PlanNodeId("0"), @@ -172,7 +176,11 @@ public class TsFilePlanRedoerTest { dataTypes, time, columns, - true); + false); + insertRowNode.setMeasurementSchemas(new MeasurementSchema[] { + new MeasurementSchema("s1", TSDataType.FLOAT), + new MeasurementSchema("s2", TSDataType.DOUBLE), + }); // redo InsertTabletPlan, vsg processor is used to test IdTable, don't test IdTable here TsFilePlanRedoer planRedoer = new TsFilePlanRedoer(tsFileResource, true, null); @@ -225,7 +233,7 @@ public class TsFilePlanRedoerTest { new TSDataType[] { TSDataType.INT32, TSDataType.INT64, TSDataType.BOOLEAN, TSDataType.FLOAT, TSDataType.TEXT }; - String[] columns = new String[] {1 + "", 1 + "", true + "", 1.0 + "", "1"}; + Object[] columns = new Object[] {1, 1L, true, 1.0f, new Binary("1")}; InsertRowNode insertRowNode = new InsertRowNode( @@ -236,7 +244,14 @@ public class TsFilePlanRedoerTest { dataTypes, time, columns, - true); + false); + insertRowNode.setMeasurementSchemas(new MeasurementSchema[] { + new MeasurementSchema("s1", TSDataType.INT32), + new MeasurementSchema("s2", TSDataType.INT64), + new MeasurementSchema("s3", TSDataType.BOOLEAN), + new MeasurementSchema("s4", TSDataType.FLOAT), + new MeasurementSchema("s5", TSDataType.TEXT), + }); // redo InsertTabletPlan, vsg processor is used to test IdTable, don't test IdTable here TsFilePlanRedoer planRedoer = new TsFilePlanRedoer(tsFileResource, true, null); @@ -317,6 +332,10 @@ public class TsFilePlanRedoerTest { bitMaps, columns, times.length); + insertTabletNode.setMeasurementSchemas(new MeasurementSchema[] { + new MeasurementSchema("s1", TSDataType.INT32), + new MeasurementSchema("s2", TSDataType.INT64), + }); // redo InsertTabletPlan, vsg processor is used to test IdTable, don't test IdTable here TsFilePlanRedoer planRedoer = new TsFilePlanRedoer(tsFileResource, true, null); @@ -413,6 +432,14 @@ public class TsFilePlanRedoerTest { bitMaps, columns, times.length); + insertTabletNode.setMeasurementSchemas(new MeasurementSchema[] { + new MeasurementSchema("s1", TSDataType.INT32), + new MeasurementSchema("s2", TSDataType.INT64), + new MeasurementSchema("s3", TSDataType.BOOLEAN), + new MeasurementSchema("s4", TSDataType.FLOAT), + new MeasurementSchema("s5", TSDataType.TEXT), + }); + // redo InsertTabletPlan, vsg processor is used to test IdTable, don't test IdTable here TsFilePlanRedoer planRedoer = new TsFilePlanRedoer(tsFileResource, true, null); @@ -533,6 +560,10 @@ public class TsFilePlanRedoerTest { null, columns, times.length); + insertTabletNode.setMeasurementSchemas(new MeasurementSchema[] { + new MeasurementSchema("s1", TSDataType.INT32), + new MeasurementSchema("s2", TSDataType.INT64), + }); // redo InsertTabletPlan, vsg processor is used to test IdTable, don't test IdTable here TsFilePlanRedoer planRedoer = new TsFilePlanRedoer(tsFileResource, false, null); @@ -643,7 +674,7 @@ public class TsFilePlanRedoerTest { } InsertTabletNode insertTabletNode = new InsertTabletNode( - new PlanNodeId("0"), + new PlanNodeId(""), new PartialPath(DEVICE3_NAME), true, new String[] {"s1", "s2", "s3", "s4", "s5"}, @@ -660,6 +691,14 @@ public class TsFilePlanRedoerTest { times.length); // redo InsertTabletPlan, data region is used to test IdTable, don't test IdTable here TsFilePlanRedoer planRedoer = new TsFilePlanRedoer(tsFileResource, true, null); + MeasurementSchema[] schemas = new MeasurementSchema[] { + new MeasurementSchema("s1", TSDataType.INT32), + new MeasurementSchema("s2", TSDataType.INT64), + new MeasurementSchema("s3", TSDataType.BOOLEAN), + new MeasurementSchema("s4", TSDataType.FLOAT), + new MeasurementSchema("s5", TSDataType.TEXT) + }; + insertTabletNode.setMeasurementSchemas(schemas); planRedoer.redoInsert(insertTabletNode); // generate InsertRowPlan @@ -668,18 +707,19 @@ public class TsFilePlanRedoerTest { new TSDataType[] { TSDataType.INT32, TSDataType.INT64, TSDataType.BOOLEAN, TSDataType.FLOAT, TSDataType.TEXT }; - String[] columns2 = new String[] {400 + "", 400 + "", true + "", 400.0 + "", "400"}; + Object[] columns2 = new Object[] {400, 400L, true, 400.0f, new Binary("400")}; // redo InsertTabletPlan, data region is used to test IdTable, don't test IdTable here InsertRowNode insertRowNode = new InsertRowNode( - new PlanNodeId("0"), + new PlanNodeId(""), new PartialPath(DEVICE3_NAME), true, new String[] {"s1", "s2", "s3", "s4", "s5"}, dataTypes2, time, columns2, - true); + false); + insertRowNode.setMeasurementSchemas(schemas); planRedoer.redoInsert(insertRowNode); // check data in memTable diff --git a/server/src/test/java/org/apache/iotdb/db/wal/recover/file/UnsealedTsFileRecoverPerformerTest.java b/server/src/test/java/org/apache/iotdb/db/wal/recover/file/UnsealedTsFileRecoverPerformerTest.java index b3bcbf9bf6..c5a39585e8 100644 --- a/server/src/test/java/org/apache/iotdb/db/wal/recover/file/UnsealedTsFileRecoverPerformerTest.java +++ b/server/src/test/java/org/apache/iotdb/db/wal/recover/file/UnsealedTsFileRecoverPerformerTest.java @@ -19,6 +19,8 @@ package org.apache.iotdb.db.wal.recover.file; import org.apache.iotdb.commons.path.PartialPath; +import org.apache.iotdb.db.conf.IoTDBConfig; +import org.apache.iotdb.db.conf.IoTDBDescriptor; import org.apache.iotdb.db.engine.modification.ModificationFile; import org.apache.iotdb.db.engine.storagegroup.TsFileResource; import org.apache.iotdb.db.mpp.plan.planner.plan.node.PlanNodeId; @@ -64,6 +66,8 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; public class UnsealedTsFileRecoverPerformerTest { + + private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig(); private static final String SG_NAME = "root.recover_sg"; private static final String DEVICE1_NAME = SG_NAME.concat(".d1"); private static final String DEVICE2_NAME = SG_NAME.concat(".d2"); @@ -71,10 +75,14 @@ public class UnsealedTsFileRecoverPerformerTest { TsFileUtilsForRecoverTest.getTestTsFilePath(SG_NAME, 0, 0, 1); private TsFileResource tsFileResource; + private boolean isClusterMode; + @Before public void setUp() throws Exception { EnvironmentUtils.cleanDir(new File(FILE_NAME).getParent()); EnvironmentUtils.envSetUp(); + isClusterMode = config.isClusterMode(); + config.setClusterMode(true); IoTDB.schemaProcessor.setStorageGroup(new PartialPath(SG_NAME)); IoTDB.schemaProcessor.createTimeseries( new PartialPath(DEVICE1_NAME.concat(".s1")), @@ -107,6 +115,7 @@ public class UnsealedTsFileRecoverPerformerTest { if (tsFileResource != null) { tsFileResource.close(); } + config.setClusterMode(isClusterMode); EnvironmentUtils.cleanDir(new File(FILE_NAME).getParent()); EnvironmentUtils.cleanEnv(); } @@ -121,17 +130,17 @@ public class UnsealedTsFileRecoverPerformerTest { // generate InsertRowPlan long time = 4; TSDataType[] dataTypes = new TSDataType[] {TSDataType.FLOAT, TSDataType.DOUBLE}; - String[] columns = new String[] {1 + "", 1.0 + ""}; + Object[] columns = new Object[] {1.0f, 1.0d}; InsertRowNode insertRowNode = new InsertRowNode( - new PlanNodeId("0"), + new PlanNodeId(""), new PartialPath(DEVICE2_NAME), false, new String[] {"s1", "s2"}, dataTypes, time, columns, - true); + false); insertRowNode.setMeasurementSchemas( new MeasurementSchema[] { new MeasurementSchema("s1", TSDataType.FLOAT),
