Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Iotdb
提交
6e2fe072
I
Iotdb
项目概览
apache
/
Iotdb
10 个月 前同步成功
通知
25
Star
3344
Fork
916
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
Iotdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
6e2fe072
编写于
11月 28, 2022
作者:
W
William Song
提交者:
GitHub
11月 28, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[To rel/1.0] fix snapshot init warning (#8226)
上级
f95389f3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
5 deletion
+16
-5
consensus/src/main/java/org/apache/iotdb/consensus/ratis/ApplicationStateMachineProxy.java
...e/iotdb/consensus/ratis/ApplicationStateMachineProxy.java
+2
-2
consensus/src/main/java/org/apache/iotdb/consensus/ratis/SnapshotStorage.java
...ava/org/apache/iotdb/consensus/ratis/SnapshotStorage.java
+14
-3
未找到文件。
consensus/src/main/java/org/apache/iotdb/consensus/ratis/ApplicationStateMachineProxy.java
浏览文件 @
6e2fe072
...
@@ -61,13 +61,13 @@ public class ApplicationStateMachineProxy extends BaseStateMachine {
...
@@ -61,13 +61,13 @@ public class ApplicationStateMachineProxy extends BaseStateMachine {
public
ApplicationStateMachineProxy
(
IStateMachine
stateMachine
,
RaftGroupId
id
)
{
public
ApplicationStateMachineProxy
(
IStateMachine
stateMachine
,
RaftGroupId
id
)
{
applicationStateMachine
=
stateMachine
;
applicationStateMachine
=
stateMachine
;
groupId
=
id
;
retryPolicy
=
retryPolicy
=
applicationStateMachine
instanceof
IStateMachine
.
RetryPolicy
applicationStateMachine
instanceof
IStateMachine
.
RetryPolicy
?
(
IStateMachine
.
RetryPolicy
)
applicationStateMachine
?
(
IStateMachine
.
RetryPolicy
)
applicationStateMachine
:
new
IStateMachine
.
RetryPolicy
()
{};
:
new
IStateMachine
.
RetryPolicy
()
{};
snapshotStorage
=
new
SnapshotStorage
(
applicationStateMachine
);
snapshotStorage
=
new
SnapshotStorage
(
applicationStateMachine
,
groupId
);
applicationStateMachine
.
start
();
applicationStateMachine
.
start
();
groupId
=
id
;
}
}
@Override
@Override
...
...
consensus/src/main/java/org/apache/iotdb/consensus/ratis/SnapshotStorage.java
浏览文件 @
6e2fe072
...
@@ -20,6 +20,7 @@ package org.apache.iotdb.consensus.ratis;
...
@@ -20,6 +20,7 @@ package org.apache.iotdb.consensus.ratis;
import
org.apache.iotdb.consensus.IStateMachine
;
import
org.apache.iotdb.consensus.IStateMachine
;
import
org.apache.ratis.protocol.RaftGroupId
;
import
org.apache.ratis.server.protocol.TermIndex
;
import
org.apache.ratis.server.protocol.TermIndex
;
import
org.apache.ratis.server.storage.FileInfo
;
import
org.apache.ratis.server.storage.FileInfo
;
import
org.apache.ratis.server.storage.RaftStorage
;
import
org.apache.ratis.server.storage.RaftStorage
;
...
@@ -39,7 +40,6 @@ import java.nio.file.Path;
...
@@ -39,7 +40,6 @@ import java.nio.file.Path;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.concurrent.locks.ReentrantReadWriteLock
;
import
java.util.concurrent.locks.ReentrantReadWriteLock
;
public
class
SnapshotStorage
implements
StateMachineStorage
{
public
class
SnapshotStorage
implements
StateMachineStorage
{
...
@@ -48,17 +48,28 @@ public class SnapshotStorage implements StateMachineStorage {
...
@@ -48,17 +48,28 @@ public class SnapshotStorage implements StateMachineStorage {
private
final
String
TMP_PREFIX
=
".tmp."
;
private
final
String
TMP_PREFIX
=
".tmp."
;
private
File
stateMachineDir
;
private
File
stateMachineDir
;
private
final
RaftGroupId
groupId
;
private
File
snapshotStorageRoot
;
private
final
ReentrantReadWriteLock
snapshotCacheGuard
=
new
ReentrantReadWriteLock
();
private
final
ReentrantReadWriteLock
snapshotCacheGuard
=
new
ReentrantReadWriteLock
();
private
SnapshotInfo
currentSnapshot
=
null
;
private
SnapshotInfo
currentSnapshot
=
null
;
public
SnapshotStorage
(
IStateMachine
applicationStateMachine
)
{
public
SnapshotStorage
(
IStateMachine
applicationStateMachine
,
RaftGroupId
groupId
)
{
this
.
applicationStateMachine
=
applicationStateMachine
;
this
.
applicationStateMachine
=
applicationStateMachine
;
this
.
groupId
=
groupId
;
}
}
@Override
@Override
public
void
init
(
RaftStorage
raftStorage
)
throws
IOException
{
public
void
init
(
RaftStorage
raftStorage
)
throws
IOException
{
this
.
stateMachineDir
=
raftStorage
.
getStorageDir
().
getStateMachineDir
();
this
.
stateMachineDir
=
raftStorage
.
getStorageDir
().
getStateMachineDir
();
if
(
getSnapshotDir
()
!=
null
)
{
snapshotStorageRoot
=
new
File
(
getSnapshotDir
(),
groupId
.
toString
());
}
else
{
snapshotStorageRoot
=
stateMachineDir
;
}
if
(!
snapshotStorageRoot
.
exists
())
{
FileUtils
.
createDirectories
(
snapshotStorageRoot
);
}
updateSnapshotCache
();
updateSnapshotCache
();
}
}
...
@@ -168,7 +179,7 @@ public class SnapshotStorage implements StateMachineStorage {
...
@@ -168,7 +179,7 @@ public class SnapshotStorage implements StateMachineStorage {
}
}
public
File
getStateMachineDir
()
{
public
File
getStateMachineDir
()
{
return
Optional
.
ofNullable
(
getSnapshotDir
()).
orElse
(
stateMachineDir
)
;
return
snapshotStorageRoot
;
}
}
public
File
getSnapshotDir
(
String
snapshotMetadata
)
{
public
File
getSnapshotDir
(
String
snapshotMetadata
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录