Skip to content

Commit 3b94e8c

Browse files
committed
modify snapshot logic
Signed-off-by: Weihao Li <18110526956@163.com>
1 parent db6c1f3 commit 3b94e8c

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/externalservice/ExternalServiceInfo.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ private ServiceInfo deserializeServiceInfoConsiderCRC(InputStream inputStream)
250250

251251
@Override
252252
public boolean processTakeSnapshot(File snapshotDir) throws IOException {
253+
// do nothing if there is no any user-defined ServiceInfo
254+
if (datanodeToServiceInfos.isEmpty()) {
255+
return true;
256+
}
257+
253258
File snapshotFile = new File(snapshotDir, SNAPSHOT_FILENAME);
254259
if (snapshotFile.exists() && snapshotFile.isFile()) {
255260
LOGGER.error(
@@ -272,9 +277,15 @@ public boolean processTakeSnapshot(File snapshotDir) throws IOException {
272277
@Override
273278
public void processLoadSnapshot(File snapshotDir) throws IOException {
274279
File snapshotFile = new File(snapshotDir, SNAPSHOT_FILENAME);
275-
if (!snapshotFile.exists() || !snapshotFile.isFile()) {
280+
281+
if (!snapshotFile.exists()) {
282+
// do nothing if the snapshot file is not existed
283+
return;
284+
}
285+
286+
if (!snapshotFile.isFile()) {
276287
LOGGER.error(
277-
"Failed to load snapshot,snapshot file [{}] is not exist.",
288+
"Failed to load snapshot,snapshot file [{}] is not a normal file.",
278289
snapshotFile.getAbsolutePath());
279290
return;
280291
}

iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/persistence/ExternalServiceInfoTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ public static void cleanup() throws IOException {
6262

6363
@Test
6464
public void testSnapshot() throws TException, IOException, IllegalPathException {
65+
// test empty
66+
serviceInfoBefore.processTakeSnapshot(snapshotDir);
67+
serviceInfo.processLoadSnapshot(snapshotDir);
68+
6569
CreateExternalServicePlan createExternalServicePlan =
6670
new CreateExternalServicePlan(
6771
1, new ServiceInfo("TEST1", "testClassName", ServiceInfo.ServiceType.USER_DEFINED));

0 commit comments

Comments
 (0)