You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2020/06/09 16:43:35 UTC

[GitHub] [hadoop-ozone] maobaolong commented on a change in pull request #1033: HDDS-3667. If we gracefully stop datanode it would be better to notify scm and r…

maobaolong commented on a change in pull request #1033:
URL: https://github.com/apache/hadoop-ozone/pull/1033#discussion_r437106724



##########
File path: hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/StateContext.java
##########
@@ -384,10 +384,9 @@ public void addPipelineActionIfAbsent(PipelineAction pipelineAction) {
       return new InitDatanodeState(this.conf, parent.getConnectionManager(),
           this);
     case RUNNING:
-      return new RunningDatanodeState(this.conf, parent.getConnectionManager(),
-          this);
     case SHUTDOWN:
-      return null;
+      return new RunningDatanodeState(this.conf, parent.getConnectionManager(),
+              this);

Review comment:
       this line is not consistent with other lines in this switch block, although checkstyle pass, we should still keep code style consistent to the exist style.

##########
File path: hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/UnRegisterEndpointTask.java
##########
@@ -0,0 +1,262 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 org.apache.hadoop.ozone.container.common.states.endpoint;
+
+import java.io.IOException;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.hdds.conf.ConfigurationSource;
+import org.apache.hadoop.hdds.protocol.DatanodeDetails;
+import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReportsProto;
+import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.NodeReportProto;
+import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineReportsProto;
+import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMUNRegisteredResponseProto;
+import org.apache.hadoop.ozone.container.common.statemachine.EndpointStateMachine;
+import org.apache.hadoop.ozone.container.common.statemachine.EndpointStateMachine.EndPointStates;
+import org.apache.hadoop.ozone.container.common.statemachine.StateContext;
+import org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+
+/**
+ * UnRegister a datanode with SCM.
+ */
+public final class UnRegisterEndpointTask implements
+    Callable<EndpointStateMachine.EndPointStates> {
+  static final Logger LOG =
+          LoggerFactory.getLogger(UnRegisterEndpointTask.class);
+
+  private final EndpointStateMachine rpcEndPoint;
+  private final ConfigurationSource conf;
+  private Future<EndpointStateMachine.EndPointStates> result;
+  private DatanodeDetails datanodeDetails;
+  private final OzoneContainer datanodeContainerManager;
+  private StateContext stateContext;
+
+  /**
+   * Creates a register endpoint task.
+   *
+   * @param rpcEndPoint - endpoint
+   * @param conf - conf
+   * @param ozoneContainer - container
+   */
+  @VisibleForTesting
+  public UnRegisterEndpointTask(EndpointStateMachine rpcEndPoint,
+      ConfigurationSource conf, OzoneContainer ozoneContainer,
+      StateContext context) {
+    this.rpcEndPoint = rpcEndPoint;
+    this.conf = conf;
+    this.datanodeContainerManager = ozoneContainer;
+    this.stateContext = context;
+
+  }
+
+  /**
+   * Get the DatanodeDetails.
+   *
+   * @return DatanodeDetailsProto
+   */
+  public DatanodeDetails getDatanodeDetails() {
+    return datanodeDetails;
+  }
+
+  /**
+   * Set the contiainerNodeID Proto.
+   *
+   * @param datanodeDetails - Container Node ID.
+   */
+  public void setDatanodeDetails(
+      DatanodeDetails datanodeDetails) {
+    this.datanodeDetails = datanodeDetails;
+  }
+
+  /**
+   * Computes a result, or throws an exception if unable to do so.
+   *
+   * @return computed result
+   * @throws Exception if unable to compute a result
+   */
+  @Override
+  public EndpointStateMachine.EndPointStates call() throws Exception {
+
+    if (getDatanodeDetails() == null) {
+      LOG.error("DatanodeDetails cannot be null in RegisterEndpoint task, "
+          + "shutting down the endpoint.");
+      return rpcEndPoint.setState(EndpointStateMachine.EndPointStates.SHUTDOWN);
+    }
+
+    rpcEndPoint.lock();
+    try {
+
+      if (rpcEndPoint.getState()
+          .equals(EndPointStates.SHUTDOWN)) {
+        ContainerReportsProto containerReport =
+            datanodeContainerManager.getController().getContainerReport();
+        NodeReportProto nodeReport = datanodeContainerManager.getNodeReport();
+        PipelineReportsProto pipelineReportsProto =
+            datanodeContainerManager.getPipelineReport();
+        // TODO : Add responses to the command Queue.
+        SCMUNRegisteredResponseProto response = rpcEndPoint.getEndPoint()
+            .unregister(datanodeDetails.getProtoBufMessage(), nodeReport,
+                containerReport, pipelineReportsProto);
+        Preconditions.checkState(UUID.fromString(response.getDatanodeUUID())
+                .equals(datanodeDetails.getUuid()),
+            "Unexpected datanode ID in the response.");
+        Preconditions.checkState(!StringUtils.isBlank(response.getClusterID()),
+            "Invalid cluster ID in the response.");
+        if (response.hasHostname() && response.hasIpAddress()) {

Review comment:
       Not sure if the datanodeDetails updating is necessary for this command is a unregister command which is a last connection to SCM.

##########
File path: hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/UnRegisterEndpointTask.java
##########
@@ -0,0 +1,262 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 org.apache.hadoop.ozone.container.common.states.endpoint;
+
+import java.io.IOException;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.hdds.conf.ConfigurationSource;
+import org.apache.hadoop.hdds.protocol.DatanodeDetails;
+import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReportsProto;
+import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.NodeReportProto;
+import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineReportsProto;
+import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMUNRegisteredResponseProto;
+import org.apache.hadoop.ozone.container.common.statemachine.EndpointStateMachine;
+import org.apache.hadoop.ozone.container.common.statemachine.EndpointStateMachine.EndPointStates;
+import org.apache.hadoop.ozone.container.common.statemachine.StateContext;
+import org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+
+/**
+ * UnRegister a datanode with SCM.
+ */
+public final class UnRegisterEndpointTask implements
+    Callable<EndpointStateMachine.EndPointStates> {
+  static final Logger LOG =
+          LoggerFactory.getLogger(UnRegisterEndpointTask.class);
+
+  private final EndpointStateMachine rpcEndPoint;
+  private final ConfigurationSource conf;
+  private Future<EndpointStateMachine.EndPointStates> result;
+  private DatanodeDetails datanodeDetails;
+  private final OzoneContainer datanodeContainerManager;
+  private StateContext stateContext;
+
+  /**
+   * Creates a register endpoint task.

Review comment:
       `register ` -> `unregister`

##########
File path: hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/UnRegisterEndpointTask.java
##########
@@ -0,0 +1,262 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 org.apache.hadoop.ozone.container.common.states.endpoint;
+
+import java.io.IOException;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.hdds.conf.ConfigurationSource;
+import org.apache.hadoop.hdds.protocol.DatanodeDetails;
+import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReportsProto;
+import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.NodeReportProto;
+import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineReportsProto;
+import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMUNRegisteredResponseProto;
+import org.apache.hadoop.ozone.container.common.statemachine.EndpointStateMachine;
+import org.apache.hadoop.ozone.container.common.statemachine.EndpointStateMachine.EndPointStates;
+import org.apache.hadoop.ozone.container.common.statemachine.StateContext;
+import org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+
+/**
+ * UnRegister a datanode with SCM.
+ */
+public final class UnRegisterEndpointTask implements
+    Callable<EndpointStateMachine.EndPointStates> {
+  static final Logger LOG =
+          LoggerFactory.getLogger(UnRegisterEndpointTask.class);
+
+  private final EndpointStateMachine rpcEndPoint;
+  private final ConfigurationSource conf;
+  private Future<EndpointStateMachine.EndPointStates> result;
+  private DatanodeDetails datanodeDetails;
+  private final OzoneContainer datanodeContainerManager;
+  private StateContext stateContext;
+
+  /**
+   * Creates a register endpoint task.
+   *
+   * @param rpcEndPoint - endpoint
+   * @param conf - conf
+   * @param ozoneContainer - container
+   */
+  @VisibleForTesting
+  public UnRegisterEndpointTask(EndpointStateMachine rpcEndPoint,
+      ConfigurationSource conf, OzoneContainer ozoneContainer,
+      StateContext context) {
+    this.rpcEndPoint = rpcEndPoint;
+    this.conf = conf;
+    this.datanodeContainerManager = ozoneContainer;
+    this.stateContext = context;
+
+  }
+
+  /**
+   * Get the DatanodeDetails.
+   *
+   * @return DatanodeDetailsProto
+   */
+  public DatanodeDetails getDatanodeDetails() {
+    return datanodeDetails;
+  }
+
+  /**
+   * Set the contiainerNodeID Proto.
+   *
+   * @param datanodeDetails - Container Node ID.
+   */
+  public void setDatanodeDetails(
+      DatanodeDetails datanodeDetails) {
+    this.datanodeDetails = datanodeDetails;
+  }
+
+  /**
+   * Computes a result, or throws an exception if unable to do so.
+   *
+   * @return computed result
+   * @throws Exception if unable to compute a result
+   */
+  @Override
+  public EndpointStateMachine.EndPointStates call() throws Exception {
+
+    if (getDatanodeDetails() == null) {
+      LOG.error("DatanodeDetails cannot be null in RegisterEndpoint task, "
+          + "shutting down the endpoint.");
+      return rpcEndPoint.setState(EndpointStateMachine.EndPointStates.SHUTDOWN);
+    }
+
+    rpcEndPoint.lock();
+    try {
+
+      if (rpcEndPoint.getState()
+          .equals(EndPointStates.SHUTDOWN)) {
+        ContainerReportsProto containerReport =
+            datanodeContainerManager.getController().getContainerReport();
+        NodeReportProto nodeReport = datanodeContainerManager.getNodeReport();
+        PipelineReportsProto pipelineReportsProto =
+            datanodeContainerManager.getPipelineReport();
+        // TODO : Add responses to the command Queue.
+        SCMUNRegisteredResponseProto response = rpcEndPoint.getEndPoint()
+            .unregister(datanodeDetails.getProtoBufMessage(), nodeReport,

Review comment:
       Do we still need container report when unregister? If not, we an remove the report logic and container member from this class

##########
File path: hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/UnRegisterEndpointTask.java
##########
@@ -0,0 +1,262 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 org.apache.hadoop.ozone.container.common.states.endpoint;
+
+import java.io.IOException;
+import java.util.UUID;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hadoop.hdds.conf.ConfigurationSource;
+import org.apache.hadoop.hdds.protocol.DatanodeDetails;
+import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ContainerReportsProto;
+import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.NodeReportProto;
+import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineReportsProto;
+import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMUNRegisteredResponseProto;
+import org.apache.hadoop.ozone.container.common.statemachine.EndpointStateMachine;
+import org.apache.hadoop.ozone.container.common.statemachine.EndpointStateMachine.EndPointStates;
+import org.apache.hadoop.ozone.container.common.statemachine.StateContext;
+import org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+
+/**
+ * UnRegister a datanode with SCM.
+ */
+public final class UnRegisterEndpointTask implements
+    Callable<EndpointStateMachine.EndPointStates> {
+  static final Logger LOG =
+          LoggerFactory.getLogger(UnRegisterEndpointTask.class);
+
+  private final EndpointStateMachine rpcEndPoint;
+  private final ConfigurationSource conf;
+  private Future<EndpointStateMachine.EndPointStates> result;
+  private DatanodeDetails datanodeDetails;
+  private final OzoneContainer datanodeContainerManager;
+  private StateContext stateContext;
+
+  /**
+   * Creates a register endpoint task.
+   *
+   * @param rpcEndPoint - endpoint
+   * @param conf - conf
+   * @param ozoneContainer - container
+   */
+  @VisibleForTesting
+  public UnRegisterEndpointTask(EndpointStateMachine rpcEndPoint,
+      ConfigurationSource conf, OzoneContainer ozoneContainer,
+      StateContext context) {
+    this.rpcEndPoint = rpcEndPoint;
+    this.conf = conf;
+    this.datanodeContainerManager = ozoneContainer;
+    this.stateContext = context;
+
+  }
+
+  /**
+   * Get the DatanodeDetails.
+   *
+   * @return DatanodeDetailsProto
+   */
+  public DatanodeDetails getDatanodeDetails() {
+    return datanodeDetails;
+  }
+
+  /**
+   * Set the contiainerNodeID Proto.
+   *
+   * @param datanodeDetails - Container Node ID.
+   */
+  public void setDatanodeDetails(
+      DatanodeDetails datanodeDetails) {
+    this.datanodeDetails = datanodeDetails;
+  }
+
+  /**
+   * Computes a result, or throws an exception if unable to do so.
+   *
+   * @return computed result
+   * @throws Exception if unable to compute a result
+   */
+  @Override
+  public EndpointStateMachine.EndPointStates call() throws Exception {
+
+    if (getDatanodeDetails() == null) {
+      LOG.error("DatanodeDetails cannot be null in RegisterEndpoint task, "
+          + "shutting down the endpoint.");
+      return rpcEndPoint.setState(EndpointStateMachine.EndPointStates.SHUTDOWN);
+    }
+
+    rpcEndPoint.lock();
+    try {
+
+      if (rpcEndPoint.getState()
+          .equals(EndPointStates.SHUTDOWN)) {
+        ContainerReportsProto containerReport =
+            datanodeContainerManager.getController().getContainerReport();
+        NodeReportProto nodeReport = datanodeContainerManager.getNodeReport();
+        PipelineReportsProto pipelineReportsProto =
+            datanodeContainerManager.getPipelineReport();
+        // TODO : Add responses to the command Queue.
+        SCMUNRegisteredResponseProto response = rpcEndPoint.getEndPoint()

Review comment:
       In fact, if there is a new message SCMUnRegisteredResponseProto, it would be better.

##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMDatanodeProtocolServer.java
##########
@@ -244,12 +247,61 @@ public SCMRegisteredResponseProto register(
     }
   }
 
+  @Override
+  public SCMUNRegisteredResponseProto unregister(

Review comment:
       I think you just copy some blocks here, you can make some modification.

##########
File path: hadoop-hdds/interface-server/src/main/proto/ScmServerDatanodeHeartbeatProtocol.proto
##########
@@ -113,6 +116,32 @@ message SCMRegisteredResponseProto {
   optional string networkLocation = 8;
 }
 
+message SCMUNRegisterRequestProto {
+  required DatanodeDetailsProto datanodeDetails = 1;
+  required NodeReportProto nodeReport = 2;

Review comment:
       Are all these memebers fo this message necessary?

##########
File path: hadoop-hdds/interface-server/src/main/proto/ScmServerDatanodeHeartbeatProtocol.proto
##########
@@ -113,6 +116,32 @@ message SCMRegisteredResponseProto {
   optional string networkLocation = 8;
 }
 
+message SCMUNRegisterRequestProto {
+  required DatanodeDetailsProto datanodeDetails = 1;
+  required NodeReportProto nodeReport = 2;
+  required ContainerReportsProto containerReport = 3;
+  required PipelineReportsProto pipelineReports = 4;
+}
+
+/**
+ * Datanode ID returned by the SCM. This is similar to name node
+ * unregisteration of a datanode.
+ */
+message SCMUNRegisteredResponseProto {
+  enum ErrorCode {
+    success = 1;
+    errorNodeNotPermitted = 2;
+  }
+  required ErrorCode errorCode = 1;
+  required string datanodeUUID = 2;

Review comment:
       Nit, clear the unnecessary fields




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: ozone-issues-help@hadoop.apache.org