-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
tsaitsung-han.tht
committed
Sep 1, 2022
1 parent
584c2de
commit ab9e2ad
Showing
32 changed files
with
1,535 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/io/openmessaging/storage/dledger/snapshot/SnapshotFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright 2017-2022 The DLedger Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.openmessaging.storage.dledger.snapshot; | ||
|
||
public class SnapshotFile { | ||
|
||
public static final String SNAPSHOT_META_FILE = "snapshot_meta"; | ||
public static final String SNAPSHOT_DATA_FILE = "data"; | ||
public static final String SNAPSHOT_DIR_PREFIX = "snapshot_"; | ||
public static final String SNAPSHOT_TEMP_DIR = "tmp"; | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/io/openmessaging/storage/dledger/snapshot/SnapshotManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright 2017-2022 The DLedger Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.openmessaging.storage.dledger.snapshot; | ||
|
||
import io.openmessaging.storage.dledger.entry.DLedgerEntry; | ||
import io.openmessaging.storage.dledger.store.DLedgerStore; | ||
|
||
public interface SnapshotManager { | ||
|
||
void saveSnapshot(DLedgerStore dLedgerStore, DLedgerEntry dLedgerEntry); | ||
|
||
void loadSnapshot(); | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/io/openmessaging/storage/dledger/snapshot/SnapshotMeta.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2017-2022 The DLedger Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.openmessaging.storage.dledger.snapshot; | ||
|
||
public class SnapshotMeta { | ||
|
||
private long lastIncludedIndex; | ||
private long lastIncludedTerm; | ||
|
||
public SnapshotMeta(long lastIncludedIndex, long lastIncludedTerm) { | ||
this.lastIncludedIndex = lastIncludedIndex; | ||
this.lastIncludedTerm = lastIncludedTerm; | ||
} | ||
|
||
public long getLastIncludedIndex() { | ||
return lastIncludedIndex; | ||
} | ||
|
||
public void setLastIncludedIndex(int lastIncludedIndex) { | ||
this.lastIncludedIndex = lastIncludedIndex; | ||
} | ||
|
||
public long getLastIncludedTerm() { | ||
return lastIncludedTerm; | ||
} | ||
|
||
public void setLastIncludedTerm(int lastIncludedTerm) { | ||
this.lastIncludedTerm = lastIncludedTerm; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "SnapshotMeta{" + | ||
"lastIncludedIndex=" + lastIncludedIndex + | ||
", lastIncludedTerm=" + lastIncludedTerm + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/java/io/openmessaging/storage/dledger/snapshot/SnapshotStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2017-2022 The DLedger Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.openmessaging.storage.dledger.snapshot; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public enum SnapshotStatus { | ||
|
||
UNKNOWN(-1), | ||
SUCCESS(0), | ||
FAIL(10001); | ||
|
||
private static Map<Integer, SnapshotStatus> codeMap = new HashMap<>(); | ||
|
||
static { | ||
for (SnapshotStatus status : SnapshotStatus.values()) { | ||
codeMap.put(status.code, status); | ||
} | ||
} | ||
|
||
private int code; | ||
|
||
SnapshotStatus(int code) { | ||
this.code = code; | ||
} | ||
|
||
public static SnapshotStatus valueOf(int code) { | ||
SnapshotStatus tmp = codeMap.get(code); | ||
if (tmp != null) { | ||
return tmp; | ||
} else { | ||
return UNKNOWN; | ||
} | ||
} | ||
|
||
public int getCode() { | ||
return code; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/io/openmessaging/storage/dledger/snapshot/SnapshotStore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright 2017-2022 The DLedger Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.openmessaging.storage.dledger.snapshot; | ||
|
||
public interface SnapshotStore { | ||
|
||
SnapshotWriter openSnapshotWriter(); | ||
|
||
SnapshotReader openSnapshotReader(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.