Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Iotdb
提交
a3c1b68d
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 搜索 >>
未验证
提交
a3c1b68d
编写于
7月 04, 2023
作者:
P
Potato
提交者:
GitHub
7月 04, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix semantic incompatibility when AtomicReference replaces volatile (#10418)
Signed-off-by:
N
OneSizeFitQuorum
<
tanxinyu@apache.org
>
上级
dcb1f73f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
17 addition
and
20 deletion
+17
-20
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
...va/org/apache/iotdb/confignode/manager/ConfigManager.java
+4
-5
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/Procedure.java
...java/org/apache/iotdb/confignode/procedure/Procedure.java
+3
-3
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/ProcedureExecutor.java
.../apache/iotdb/confignode/procedure/ProcedureExecutor.java
+5
-5
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RequestMessage.java
...java/org/apache/iotdb/consensus/ratis/RequestMessage.java
+3
-4
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/ResponseMessage.java
...ava/org/apache/iotdb/consensus/ratis/ResponseMessage.java
+2
-3
未找到文件。
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
浏览文件 @
a3c1b68d
...
...
@@ -208,7 +208,7 @@ public class ConfigManager implements IManager {
private
static
final
CommonConfig
COMMON_CONF
=
CommonDescriptor
.
getInstance
().
getConfig
();
/** Manage PartitionTable read/write requests through the ConsensusLayer. */
private
AtomicReference
<
ConsensusManager
>
consensusManager
;
private
final
AtomicReference
<
ConsensusManager
>
consensusManager
=
new
AtomicReference
<>()
;
/** Manage cluster node. */
private
final
NodeManager
nodeManager
;
...
...
@@ -305,12 +305,11 @@ public class ConfigManager implements IManager {
}
public
void
initConsensusManager
()
throws
IOException
{
ConsensusManager
consensusManager
=
new
ConsensusManager
(
this
,
this
.
stateMachine
);
this
.
consensusManager
=
new
AtomicReference
<>(
consensusManager
);
this
.
consensusManager
.
set
(
new
ConsensusManager
(
this
,
this
.
stateMachine
));
}
public
void
close
()
throws
IOException
{
if
(
consensusManager
!=
null
)
{
if
(
consensusManager
.
get
()
!=
null
)
{
consensusManager
.
get
().
close
();
}
if
(
partitionManager
!=
null
)
{
...
...
@@ -1122,7 +1121,7 @@ public class ConfigManager implements IManager {
public
TSStatus
createPeerForConsensusGroup
(
List
<
TConfigNodeLocation
>
configNodeLocations
)
{
for
(
int
i
=
0
;
i
<
30
;
i
++)
{
try
{
if
(
consensusManager
==
null
)
{
if
(
consensusManager
.
get
()
==
null
)
{
Thread
.
sleep
(
1000
);
}
else
{
// When add non Seed-ConfigNode to the ConfigNodeGroup, the parameter should be emptyList
...
...
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/Procedure.java
浏览文件 @
a3c1b68d
...
...
@@ -64,7 +64,7 @@ public abstract class Procedure<Env> implements Comparable<Procedure<Env>> {
private
volatile
long
timeout
=
NO_TIMEOUT
;
private
volatile
long
lastUpdate
;
private
AtomicReference
<
byte
[]>
result
=
null
;
private
final
AtomicReference
<
byte
[]>
result
=
new
AtomicReference
<>()
;
private
volatile
boolean
locked
=
false
;
private
boolean
lockedWhenLoading
=
false
;
...
...
@@ -173,7 +173,7 @@ public abstract class Procedure<Env> implements Comparable<Procedure<Env>> {
}
// result
if
(
result
!=
null
)
{
if
(
result
.
get
()
!=
null
)
{
stream
.
writeInt
(
result
.
get
().
length
);
stream
.
write
(
result
.
get
());
}
else
{
...
...
@@ -652,7 +652,7 @@ public abstract class Procedure<Env> implements Comparable<Procedure<Env>> {
* @param result the serialized result that will be passed to the client
*/
protected
void
setResult
(
byte
[]
result
)
{
this
.
result
=
new
AtomicReference
<>
(
result
);
this
.
result
.
set
(
result
);
}
/**
...
...
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/ProcedureExecutor.java
浏览文件 @
a3c1b68d
...
...
@@ -710,7 +710,7 @@ public class ProcedureExecutor<Env> {
private
class
WorkerThread
extends
StoppableThread
{
private
final
AtomicLong
startTime
=
new
AtomicLong
(
Long
.
MAX_VALUE
);
private
AtomicReference
<
Procedure
<
Env
>>
activeProcedure
;
private
final
AtomicReference
<
Procedure
<
Env
>>
activeProcedure
=
new
AtomicReference
<>()
;
protected
long
keepAliveTime
=
-
1
;
public
WorkerThread
(
ThreadGroup
threadGroup
)
{
...
...
@@ -736,19 +736,19 @@ public class ProcedureExecutor<Env> {
if
(
procedure
==
null
)
{
continue
;
}
this
.
activeProcedure
=
new
AtomicReference
<>
(
procedure
);
this
.
activeProcedure
.
set
(
procedure
);
int
activeCount
=
activeExecutorCount
.
incrementAndGet
();
startTime
.
set
(
System
.
currentTimeMillis
());
executeProcedure
(
procedure
);
activeCount
=
activeExecutorCount
.
decrementAndGet
();
LOG
.
trace
(
"Halt pid={}, activeCount={}"
,
procedure
.
getProcId
(),
activeCount
);
this
.
activeProcedure
=
null
;
this
.
activeProcedure
.
set
(
null
)
;
lastUpdated
=
System
.
currentTimeMillis
();
startTime
.
set
(
lastUpdated
);
}
}
catch
(
Throwable
throwable
)
{
if
(
this
.
activeProcedure
!=
null
)
{
if
(
this
.
activeProcedure
.
get
()
!=
null
)
{
LOG
.
warn
(
"Worker terminated {}"
,
this
.
activeProcedure
.
get
(),
throwable
);
}
}
finally
{
...
...
@@ -804,7 +804,7 @@ public class ProcedureExecutor<Env> {
// check if any of the worker is stuck
int
stuckCount
=
0
;
for
(
WorkerThread
worker
:
workerThreads
)
{
if
(
worker
.
activeProcedure
==
null
if
(
worker
.
activeProcedure
.
get
()
==
null
||
worker
.
getCurrentRunTime
()
<
DEFAULT_WORKER_STUCK_THRESHOLD
)
{
continue
;
}
...
...
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RequestMessage.java
浏览文件 @
a3c1b68d
...
...
@@ -30,7 +30,7 @@ import java.util.concurrent.atomic.AtomicReference;
class
RequestMessage
implements
Message
{
private
final
IConsensusRequest
actualRequest
;
private
AtomicReference
<
ByteString
>
serializedContent
=
new
AtomicReference
<>();
private
final
AtomicReference
<
ByteString
>
serializedContent
=
new
AtomicReference
<>();
RequestMessage
(
IConsensusRequest
request
)
{
this
.
actualRequest
=
request
;
...
...
@@ -45,9 +45,8 @@ class RequestMessage implements Message {
if
(
serializedContent
.
get
()
==
null
)
{
synchronized
(
this
)
{
if
(
serializedContent
.
get
()
==
null
)
{
serializedContent
=
new
AtomicReference
<>(
UnsafeByteOperations
.
unsafeWrap
(
actualRequest
.
serializeToByteBuffer
()));
serializedContent
.
set
(
UnsafeByteOperations
.
unsafeWrap
(
actualRequest
.
serializeToByteBuffer
()));
}
}
}
...
...
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/ResponseMessage.java
浏览文件 @
a3c1b68d
...
...
@@ -38,7 +38,7 @@ class ResponseMessage implements Message {
*/
private
final
Object
contentHolder
;
private
AtomicReference
<
ByteString
>
serializedData
=
new
AtomicReference
<>();
private
final
AtomicReference
<
ByteString
>
serializedData
=
new
AtomicReference
<>();
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ResponseMessage
.
class
);
ResponseMessage
(
Object
content
)
{
...
...
@@ -57,8 +57,7 @@ class ResponseMessage implements Message {
assert
contentHolder
instanceof
TSStatus
;
TSStatus
status
=
(
TSStatus
)
contentHolder
;
try
{
serializedData
=
new
AtomicReference
<>(
ByteString
.
copyFrom
(
Utils
.
serializeTSStatus
(
status
)));
serializedData
.
set
(
ByteString
.
copyFrom
(
Utils
.
serializeTSStatus
(
status
)));
}
catch
(
TException
e
)
{
logger
.
warn
(
"serialize TSStatus failed {}"
,
status
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录