You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by el...@apache.org on 2021/02/09 09:43:24 UTC
[ozone] branch master updated: HDDS-4734. Validate update state in
PipelineStateMap.updatePipelineState (#1835)
This is an automated email from the ASF dual-hosted git repository.
elek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 09bb69f HDDS-4734. Validate update state in PipelineStateMap.updatePipelineState (#1835)
09bb69f is described below
commit 09bb69f742a88c3e3f1661ef7c46a0ea79162450
Author: Symious <yi...@foxmail.com>
AuthorDate: Tue Feb 9 17:43:09 2021 +0800
HDDS-4734. Validate update state in PipelineStateMap.updatePipelineState (#1835)
---
.../apache/hadoop/hdds/scm/container/states/ContainerAttribute.java | 5 ++++-
.../apache/hadoop/hdds/scm/container/states/ContainerStateMap.java | 6 ++++++
.../java/org/apache/hadoop/hdds/scm/pipeline/PipelineStateMap.java | 6 ++++++
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/states/ContainerAttribute.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/states/ContainerAttribute.java
index af44a8a..49467e5 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/states/ContainerAttribute.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/states/ContainerAttribute.java
@@ -230,7 +230,10 @@ public class ContainerAttribute<T> {
throws SCMException {
Preconditions.checkNotNull(currentKey);
Preconditions.checkNotNull(newKey);
-
+ // Return if container attribute not changed
+ if (currentKey == newKey) {
+ return;
+ }
boolean removed = false;
try {
removed = remove(currentKey, value);
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/states/ContainerStateMap.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/states/ContainerStateMap.java
index fc20a51..7cb2a6b 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/states/ContainerStateMap.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/states/ContainerStateMap.java
@@ -293,6 +293,12 @@ public class ContainerStateMap {
lock.writeLock().lock();
try {
checkIfContainerExist(containerID);
+ // Return if updating state not changed
+ if (currentState == newState) {
+ LOG.debug("CurrentState and NewState are the same, return from " +
+ "updateState directly.");
+ return;
+ }
final ContainerInfo currentInfo = containerMap.get(containerID);
try {
currentInfo.setState(newState);
diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineStateMap.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineStateMap.java
index 5e20eb1..0af6101 100644
--- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineStateMap.java
+++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineStateMap.java
@@ -389,6 +389,12 @@ class PipelineStateMap {
Preconditions.checkNotNull(state, "Pipeline LifeCycleState cannot be null");
final Pipeline pipeline = getPipeline(pipelineID);
+ // Return the old pipeline if updating same state
+ if (pipeline.getPipelineState() == state) {
+ LOG.debug("CurrentState and NewState are the same, return from " +
+ "updatePipelineState directly.");
+ return pipeline;
+ }
Pipeline updatedPipeline = pipelineMap.compute(pipelineID,
(id, p) -> Pipeline.newBuilder(pipeline).setState(state).build());
PipelineQuery query = new PipelineQuery(pipeline);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ozone.apache.org
For additional commands, e-mail: commits-help@ozone.apache.org