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

2020-07-24 Thread GitBox


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



##
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/NodeStateManager.java
##
@@ -708,6 +707,21 @@ private void updateNodeState(DatanodeInfo node, 
Predicate condition,
 }
   }
 
+  /**
+   *
+   * @param datanodeDetails
+   */
+  public void stopNode(DatanodeDetails datanodeDetails)
+  throws NodeNotFoundException {
+UUID uuid = datanodeDetails.getUuid();
+NodeState state = nodeStateMap.getNodeState(uuid);
+DatanodeInfo node = nodeStateMap.getNodeInfo(uuid);
+nodeStateMap.updateNodeState(datanodeDetails.getUuid(), state,
+NodeState.DEAD);
+node.updateLastHeartbeatTime(0L);

Review comment:
   Yeah, this problem really exists.
   i will create a new jira to solve this prolem.





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:
us...@infra.apache.org



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



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

2020-07-22 Thread GitBox


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



##
File path: 
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/HddsDatanodeService.java
##
@@ -164,9 +171,29 @@ public Void call() throws Exception {
   HddsDatanodeService.class, args, LOG);
 }
 start(createOzoneConfiguration());
+stopDataNodeShutdownHook = () ->
+stopDataNode();
+ShutdownHookManager.get().addShutdownHook(stopDataNodeShutdownHook,
+SHUTDOWN_HOOK_PRIORITY);
 join();
 return null;
   }
+  
+  private void stopDataNode() {
+Collection endpointStateMachines =
+datanodeStateMachine.getConnectionManager().getValues();
+for (EndpointStateMachine endpointStateMachine : endpointStateMachines) {
+  try {
+// Make sure the heartbeat is not sent

Review comment:
   done
   





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:
us...@infra.apache.org



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



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

2020-07-22 Thread GitBox


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



##
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/NodeStateManager.java
##
@@ -708,6 +707,21 @@ private void updateNodeState(DatanodeInfo node, 
Predicate condition,
 }
   }
 
+  /**
+   *
+   * @param datanodeDetails
+   */
+  public void stopNode(DatanodeDetails datanodeDetails)
+  throws NodeNotFoundException {
+UUID uuid = datanodeDetails.getUuid();
+NodeState state = nodeStateMap.getNodeState(uuid);
+DatanodeInfo node = nodeStateMap.getNodeInfo(uuid);
+nodeStateMap.updateNodeState(datanodeDetails.getUuid(), state,
+NodeState.DEAD);
+node.updateLastHeartbeatTime(0L);

Review comment:
   According to LastHeartbeatTime, NodeStateManager#checkNodesHealth 
detemine the status of node periodically.
   If LastHeartbeatTime is not set to 0, NodeStateManager#checkNodesHealth 
could update the healty of node after we set the status of the node to dead.
   





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:
us...@infra.apache.org



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



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

2020-06-10 Thread GitBox


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



##
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
+ * 
+ * http://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 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 {
+  static final Logger LOG =
+  LoggerFactory.getLogger(UnRegisterEndpointTask.class);
+
+  private final EndpointStateMachine rpcEndPoint;
+  private final ConfigurationSource conf;
+  private Future 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, 

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

2020-06-09 Thread GitBox


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



##
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:
   done

##
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
+ * 
+ * http://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 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 {
+  static final Logger LOG =
+  LoggerFactory.getLogger(UnRegisterEndpointTask.class);
+
+  private final EndpointStateMachine rpcEndPoint;
+  private final ConfigurationSource conf;
+  private Future result;
+  private DatanodeDetails datanodeDetails;
+  private final OzoneContainer datanodeContainerManager;
+  private StateContext stateContext;
+
+  /**
+   * Creates a register endpoint task.

Review comment:
   done

##
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
+ * 
+ * http://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 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