sokui commented on code in PR #3186: URL: https://github.com/apache/ozone/pull/3186#discussion_r888286762
########## hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/NodeAddressUpdateHandler.java: ########## @@ -0,0 +1,69 @@ +/** + * 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.hdds.scm.node; + +import org.apache.hadoop.hdds.protocol.DatanodeDetails; +import org.apache.hadoop.hdds.scm.ha.SCMService; +import org.apache.hadoop.hdds.scm.ha.SCMServiceManager; +import org.apache.hadoop.hdds.scm.node.states.NodeNotFoundException; +import org.apache.hadoop.hdds.scm.pipeline.PipelineManager; +import org.apache.hadoop.hdds.server.events.EventHandler; +import org.apache.hadoop.hdds.server.events.EventPublisher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Handles datanode ip or hostname change event. + */ +public class NodeAddressUpdateHandler + implements EventHandler<DatanodeDetails> { + private static final Logger LOG = + LoggerFactory.getLogger(NodeAddressUpdateHandler.class); + + private final PipelineManager pipelineManager; + private final NodeDecommissionManager decommissionManager; + private final SCMServiceManager serviceManager; + + public NodeAddressUpdateHandler(PipelineManager pipelineManager, + NodeDecommissionManager + decommissionManager, + SCMServiceManager serviceManager) { + this.pipelineManager = pipelineManager; + this.decommissionManager = decommissionManager; + this.serviceManager = serviceManager; + } + + @Override + public void onMessage(DatanodeDetails datanodeDetails, + EventPublisher publisher) { + try { + LOG.info("Closing stale pipelines for datanode: {}", datanodeDetails); + pipelineManager.closeStalePipelines(datanodeDetails); Review Comment: ``` 2022-06-01 10:01:03 INFO PipelineStateManagerImpl:101 - Created pipeline Pipeline[ Id: 56d494b4-9faf-47ca-ab77-585281316c58, Nodes: 06b25030-0703-4edf-83bb-26fd94666a0d{ip: 10.42.0.40, host: datanode-2.datanode.default.svc.cluster.local, ports: [REPLICATION=9886, RATIS=9858, RATIS_ADMIN=9857, RATIS_SERVER=9856, STANDALONE=9859], networkLocation: /default-rack, certSerialId: null, persistedOpState: IN_SERVICE, persistedOpStateExpiryEpochSec: 0}76504e44-bd67-405b-9d90-95cb8e20dfd9{ip: 10.42.0.36, host: datanode-0.datanode.default.svc.cluster.local, ports: [REPLICATION=9886, RATIS=9858, RATIS_ADMIN=9857, RATIS_SERVER=9856, STANDALONE=9859], networkLocation: /default-rack, certSerialId: null, persistedOpState: IN_SERVICE, persistedOpStateExpiryEpochSec: 0}2f2163ec-bb96-4432-8418-dcfd7b829cbf{ip: 10.42.0.38, host: datanode-1.datanode.default.svc.cluster.local, ports: [REPLICATION=9886, RATIS=9858, RATIS_ADMIN=9857, RATIS_SERVER=9856, STANDALONE=9859], networkLocation: /default-rack, c ertSerialId: null, persistedOpState: IN_SERVICE, persistedOpStateExpiryEpochSec: 0}, ReplicationConfig: RATIS/THREE, State:ALLOCATED, leaderId:, CreationTimestamp2022-06-01T10:01:03.639Z[UTC]]. ``` I think the above log is before the restarting. After restarting, the right order is that: first, datanode update its IP address in SCM; second, SCM closes all pipelines belonging to this datanode's old IP address; third, SCM create new pipeline(s) for this datanode with the new IP -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
