Skip to content

Commit f04e955

Browse files
committed
temp
1 parent db37feb commit f04e955

8 files changed

Lines changed: 77 additions & 8 deletions

File tree

server/src/main/java/org/apache/iotdb/db/engine/StorageEngine.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,8 @@ public DataRegion buildNewStorageGroupProcessor(
555555
systemDir + File.separator + logicalStorageGroupName,
556556
virtualStorageGroupId,
557557
fileFlushPolicy,
558-
storageGroupMNode.getFullPath());
558+
storageGroupMNode.getFullPath(),
559+
false);
559560
processor.setDataTTL(storageGroupMNode.getDataTTL());
560561
processor.setCustomFlushListeners(customFlushListeners);
561562
processor.setCustomCloseFileListeners(customCloseFileListeners);
@@ -1055,6 +1056,10 @@ protected void getSeriesSchemas(InsertPlan insertPlan, DataRegion processor)
10551056
}
10561057
}
10571058

1059+
public String getSystemDir() {
1060+
return systemDir;
1061+
}
1062+
10581063
static class InstanceHolder {
10591064

10601065
private static final StorageEngine INSTANCE = new StorageEngine();

server/src/main/java/org/apache/iotdb/db/engine/StorageEngineV2.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,8 @@ public DataRegion buildNewDataRegion(
481481
systemDir + File.separator + logicalStorageGroupName,
482482
dataRegionId,
483483
fileFlushPolicy,
484-
logicalStorageGroupName);
484+
logicalStorageGroupName,
485+
false);
485486
dataRegion.setDataTTL(ttl);
486487
dataRegion.setCustomFlushListeners(customFlushListeners);
487488
dataRegion.setCustomCloseFileListeners(customCloseFileListeners);
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.iotdb.db.engine.snapshot;
20+
21+
import org.apache.iotdb.db.engine.StorageEngine;
22+
import org.apache.iotdb.db.engine.flush.TsFileFlushPolicy;
23+
import org.apache.iotdb.db.engine.storagegroup.DataRegion;
24+
import org.apache.iotdb.db.exception.DataRegionException;
25+
26+
import org.slf4j.Logger;
27+
import org.slf4j.LoggerFactory;
28+
29+
import java.io.File;
30+
31+
public class SnapshotLoader {
32+
private static final Logger LOGGER = LoggerFactory.getLogger(SnapshotLoader.class);
33+
private String dataDir;
34+
private String storageGroupName;
35+
private String dataRegionId;
36+
37+
public SnapshotLoader(String dataDir, String storageGroupName, String dataRegionId) {
38+
this.dataDir = dataDir;
39+
this.storageGroupName = storageGroupName;
40+
this.dataRegionId = dataRegionId;
41+
}
42+
43+
public DataRegion loadSnapshot() {
44+
try {
45+
return new DataRegion(
46+
StorageEngine.getInstance().getSystemDir() + File.separator + storageGroupName,
47+
dataRegionId,
48+
new TsFileFlushPolicy.DirectFlushPolicy(),
49+
storageGroupName,
50+
true);
51+
} catch (DataRegionException e) {
52+
LOGGER.error("Exception occurs while loading snapshot", e);
53+
}
54+
return null;
55+
}
56+
}

server/src/main/java/org/apache/iotdb/db/engine/storagegroup/DataRegion.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ public class DataRegion {
263263
/** used to collect TsFiles in this virtual storage group */
264264
private TsFileSyncManager tsFileSyncManager = TsFileSyncManager.getInstance();
265265

266+
private boolean recoverFromSnapshot = false;
267+
266268
/**
267269
* constrcut a storage group processor
268270
*
@@ -275,11 +277,13 @@ public DataRegion(
275277
String systemDir,
276278
String dataRegionId,
277279
TsFileFlushPolicy fileFlushPolicy,
278-
String logicalStorageGroupName)
280+
String logicalStorageGroupName,
281+
boolean recoverFromSnapshot)
279282
throws DataRegionException {
280283
this.dataRegionId = dataRegionId;
281284
this.logicalStorageGroupName = logicalStorageGroupName;
282285
this.fileFlushPolicy = fileFlushPolicy;
286+
this.recoverFromSnapshot = recoverFromSnapshot;
283287

284288
storageGroupSysDir = SystemFileFactory.INSTANCE.getFile(systemDir, dataRegionId);
285289
this.tsFileManager =

server/src/test/java/org/apache/iotdb/db/engine/compaction/cross/RewriteCrossSpaceCompactionTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,8 @@ public void testOneDeletionDuringCompaction() throws Exception {
580580
STORAGE_GROUP_DIR.getPath(),
581581
"0",
582582
new TsFileFlushPolicy.DirectFlushPolicy(),
583-
COMPACTION_TEST_SG);
583+
COMPACTION_TEST_SG,
584+
false);
584585
registerTimeseriesInMManger(4, 5, true);
585586
createFiles(2, 2, 3, 300, 0, 0, 50, 50, true, true);
586587
createFiles(2, 4, 5, 300, 700, 700, 50, 50, true, true);
@@ -689,7 +690,8 @@ public void testSeveralDeletionsDuringCompaction() throws Exception {
689690
STORAGE_GROUP_DIR.getPath(),
690691
"0",
691692
new TsFileFlushPolicy.DirectFlushPolicy(),
692-
COMPACTION_TEST_SG);
693+
COMPACTION_TEST_SG,
694+
false);
693695
registerTimeseriesInMManger(4, 5, true);
694696
createFiles(2, 2, 3, 300, 0, 0, 50, 50, true, true);
695697
createFiles(2, 4, 5, 300, 700, 700, 50, 50, true, true);

server/src/test/java/org/apache/iotdb/db/engine/storagegroup/DataRegionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ record = new TSRecord(1, deviceId);
916916
static class DummyDataRegion extends DataRegion {
917917

918918
DummyDataRegion(String systemInfoDir, String storageGroupName) throws DataRegionException {
919-
super(systemInfoDir, "0", new TsFileFlushPolicy.DirectFlushPolicy(), storageGroupName);
919+
super(systemInfoDir, "0", new TsFileFlushPolicy.DirectFlushPolicy(), storageGroupName, false);
920920
}
921921
}
922922
}

server/src/test/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ record = new TSRecord(1, deviceId);
863863
class DummySGP extends DataRegion {
864864

865865
DummySGP(String systemInfoDir, String storageGroupName) throws DataRegionException {
866-
super(systemInfoDir, "0", new TsFileFlushPolicy.DirectFlushPolicy(), storageGroupName);
866+
super(systemInfoDir, "0", new TsFileFlushPolicy.DirectFlushPolicy(), storageGroupName, false);
867867
}
868868
}
869869
}

server/src/test/java/org/apache/iotdb/db/engine/storagegroup/TTLTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ private void createSchemas() throws MetadataException, DataRegionException {
109109
IoTDBDescriptor.getInstance().getConfig().getSystemDir(),
110110
sg1,
111111
new DirectFlushPolicy(),
112-
sg1);
112+
sg1,
113+
false);
113114
IoTDB.schemaProcessor.createTimeseries(
114115
new PartialPath(g1s1),
115116
TSDataType.INT64,

0 commit comments

Comments
 (0)