hanishakoneru commented on a change in pull request #2491:
URL: https://github.com/apache/ozone/pull/2491#discussion_r745165279
##########
File path:
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java
##########
@@ -697,4 +701,78 @@ public static String normalizeKey(String keyName,
}
return omHosts;
}
+
+ /**
+ * Get a list of all OM details (address and ports) from the specified
config.
+ */
+ public static List<OMNodeDetails> getAllOMAddresses(OzoneConfiguration conf,
+ String omServiceId, String currentOMNodeId) {
+
+ List<OMNodeDetails> omNodesList = new ArrayList<>();
+ Collection<String> omNodeIds = OmUtils.getOMNodeIds(conf, omServiceId);
+
+ String rpcAddrStr, hostAddr, httpAddr, httpsAddr;
+ int rpcPort, ratisPort;
+ if (omNodeIds.size() == 0) {
+ //Check if it is non-HA cluster
+ rpcAddrStr = OmUtils.getOmRpcAddress(conf, OZONE_OM_ADDRESS_KEY);
+ if (rpcAddrStr == null || rpcAddrStr.isEmpty()) {
+ return omNodesList;
+ }
+ hostAddr = HddsUtils.getHostName(rpcAddrStr).orElse(null);
+ rpcPort = HddsUtils.getHostPort(rpcAddrStr).orElse(0);
+ ratisPort = conf.getInt(OZONE_OM_RATIS_PORT_KEY,
+ OZONE_OM_RATIS_PORT_DEFAULT);
+ httpAddr = OmUtils.getHttpAddressForOMPeerNode(conf,
+ null, null, hostAddr);
+ httpsAddr = OmUtils.getHttpsAddressForOMPeerNode(conf,
+ null, null, hostAddr);
+
+ omNodesList.add(new OMNodeDetails.Builder()
+ .setOMNodeId(currentOMNodeId)
+ .setHostAddress(hostAddr)
+ .setRpcPort(rpcPort)
+ .setRatisPort(ratisPort)
+ .setHttpAddress(httpAddr)
+ .setHttpsAddress(httpsAddr)
+ .build());
+ return omNodesList;
+ }
+
+ for (String nodeId : omNodeIds) {
+ try {
+ OMNodeDetails omNodeDetails = OMNodeDetails.getOMNodeDetailsFromConf(
+ conf, omServiceId, nodeId);
+ omNodesList.add(omNodeDetails);
+ } catch (IOException e) {
+ String omRpcAddressStr = OMNodeDetails.getOMNodeAddressFromConf(conf,
+ omServiceId, nodeId);
+ LOG.error("OM {} is present in config file but it's address {} could "
+
+ "not be resolved. Hence, OM {} is not added to list of peer
nodes.",
+ nodeId, omRpcAddressStr, nodeId);
+ }
+ }
+
+ return omNodesList;
+ }
+
+ public static String getOMAddressListPrintString(List<OMNodeDetails> omList)
{
Review comment:
Done.
##########
File path:
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OMMetadataProtocolClientSideImpl.java
##########
@@ -0,0 +1,136 @@
+/**
+ * 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.om.protocolPB;
+
+import com.google.protobuf.RpcController;
+import com.google.protobuf.ServiceException;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.util.concurrent.TimeUnit;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hdds.conf.ConfigurationSource;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.utils.LegacyHadoopConfigurationSource;
+import org.apache.hadoop.io.retry.RetryPolicies;
+import org.apache.hadoop.io.retry.RetryPolicy;
+import org.apache.hadoop.io.retry.RetryProxy;
+import org.apache.hadoop.ipc.ProtobufRpcEngine;
+import org.apache.hadoop.ipc.RPC;
+import org.apache.hadoop.net.NetUtils;
+import org.apache.hadoop.ozone.OmUtils;
+import org.apache.hadoop.ozone.om.OMConfigKeys;
+import org.apache.hadoop.ozone.om.helpers.OMNodeDetails;
+import org.apache.hadoop.ozone.om.protocol.OMConfiguration;
+import org.apache.hadoop.ozone.om.protocol.OMMetadataProtocol;
+import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerMetadataProtocolProtos.OMConfigurationRequest;
+import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerMetadataProtocolProtos.OMConfigurationResponse;
+import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerMetadataProtocolProtos.OMNodeInfo;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Protocol implementation for getting OM metadata information.
+ */
+public class OMMetadataProtocolClientSideImpl implements
+ OMMetadataProtocol {
+
+ /**
+ * RpcController is not used and hence is set to null.
+ */
+ private static final RpcController NULL_RPC_CONTROLLER = null;
+
+ private static final Logger LOG =
+ LoggerFactory.getLogger(OMMetadataProtocolClientSideImpl.class);
+
+ private final String omNodeID;
+ private final OMMetadataProtocolPB rpcProxy;
+
+ public OMMetadataProtocolClientSideImpl(ConfigurationSource conf,
+ UserGroupInformation ugi, String omNodeId, InetSocketAddress omAddress)
+ throws IOException {
+
+ RPC.setProtocolEngine(OzoneConfiguration.of(conf),
+ OMMetadataProtocolPB.class, ProtobufRpcEngine.class);
+
+ this.omNodeID = omNodeId;
+
+ int maxRetries = conf.getInt(
+ OMConfigKeys.OZONE_OM_METADATA_PROTOCOL_MAX_RETRIES_KEY,
+ OMConfigKeys.OZONE_OM_METADATA_PROTOCOL_MAX_RETRIES_DEFAULT);
+ long waitBetweenRetries = conf.getLong(
+ OMConfigKeys.OZONE_OM_METADATA_PROTOCOL_WAIT_BETWEEN_RETRIES_KEY,
+ OMConfigKeys.OZONE_OM_METADATA_PROTOCOL_WAIT_BETWEEN_RETRIES_DEFAULT);
+
+ // OM metadata is requested from a specific OM and hence there is no need
+ // of any failover provider.
+ RetryPolicy connectionRetryPolicy = RetryPolicies
+ .retryUpToMaximumCountWithFixedSleep(maxRetries, waitBetweenRetries,
+ TimeUnit.MILLISECONDS);
+ Configuration hadoopConf = LegacyHadoopConfigurationSource
+ .asHadoopConfiguration(conf);
+
+ OMMetadataProtocolPB proxy = RPC.getProtocolProxy(
+ OMMetadataProtocolPB.class,
+ RPC.getProtocolVersion(OMMetadataProtocolPB.class), omAddress, ugi,
+ hadoopConf, NetUtils.getDefaultSocketFactory(hadoopConf),
+ (int) OmUtils.getOMClientRpcTimeOut(conf), connectionRetryPolicy)
+ .getProxy();
+
+ RetryPolicy retryPolicy =
RetryPolicies.retryUpToMaximumCountWithFixedSleep(
+ 10, 1000, TimeUnit.MILLISECONDS);
+
+ this.rpcProxy = (OMMetadataProtocolPB) RetryProxy.create(
+ OMMetadataProtocolPB.class, proxy, retryPolicy);
+ }
+
+ @Override
+ public OMConfiguration getOMConfiguration() throws IOException {
+ try {
+ OMConfigurationResponse getConfigResponse = rpcProxy.getOMConfiguration(
+ NULL_RPC_CONTROLLER, OMConfigurationRequest.newBuilder().build());
+
+ OMConfiguration.Builder omMedatataBuilder = new
OMConfiguration.Builder();
+ if (getConfigResponse.getSuccess()) {
+ if (getConfigResponse.getNodesInMemoryCount() > 0) {
+ for (OMNodeInfo omNodeInfo :
+ getConfigResponse.getNodesInMemoryList()) {
+ omMedatataBuilder.addToNodesInMemory(
+ OMNodeDetails.getFromProtobuf(omNodeInfo));
+ }
+ }
+ if (getConfigResponse.getNodesInNewConfCount() > 0) {
+ for (OMNodeInfo omNodeInfo :
+ getConfigResponse.getNodesInNewConfList()) {
+ omMedatataBuilder.addToNodesInNewConf(
+ OMNodeDetails.getFromProtobuf(omNodeInfo));
+ }
+ }
+ }
+ return omMedatataBuilder.build();
+ } catch (ServiceException e) {
+ LOG.error("Failed to retrieve configuration of OM {}", omNodeID, e);
Review comment:
Done.
##########
File path:
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OMMetadataProtocolServerSideImpl.java
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.protocolPB;
+
+import com.google.protobuf.RpcController;
+import com.google.protobuf.ServiceException;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.hadoop.ozone.om.OzoneManager;
+import org.apache.hadoop.ozone.om.helpers.OMNodeDetails;
+import org.apache.hadoop.ozone.om.protocolPB.OMMetadataProtocolPB;
+import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerMetadataProtocolProtos.OMConfigurationRequest;
+import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerMetadataProtocolProtos.OMConfigurationResponse;
+import
org.apache.hadoop.ozone.protocol.proto.OzoneManagerMetadataProtocolProtos.OMNodeInfo;
+
+/**
+ * This class is the server-side translator that forwards requests received on
+ * {@link OMMetadataProtocolPB} to the OMConfiguration server implementation.
Review comment:
Done.
##########
File path:
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
##########
@@ -1648,7 +1779,7 @@ public long getRatisSnapshotIndex() throws IOException {
* Stop service.
*/
public void stop() {
- LOG.info("Stopping Ozone Manager");
+ LOG.info("{}: Stopping Ozone Manager", getOMNodeId());
Review comment:
Done.
##########
File path:
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
##########
@@ -1531,6 +1650,18 @@ public boolean doesPeerExist(String omNodeId) {
return false;
}
+ public List<OMNodeDetails> getAllOMNodesInMemory() {
Review comment:
Done.
##########
File path:
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
##########
@@ -1531,6 +1650,18 @@ public boolean doesPeerExist(String omNodeId) {
return false;
}
+ public List<OMNodeDetails> getAllOMNodesInMemory() {
+ List<OMNodeDetails> peerNodes = getPeerNodes();
+ // Add current node also to list
+ peerNodes.add(omNodeDetails);
+ return peerNodes;
+ }
+
+ public List<OMNodeDetails> getAllOMNodesInNewConf() {
Review comment:
Done.
##########
File path:
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java
##########
@@ -1423,6 +1466,66 @@ public void restart() throws IOException {
omState = State.RUNNING;
}
+ private void checkConfigBeforeBootstrap() throws IOException {
+ List<OMNodeDetails> omsWihtoutNewConfig = new ArrayList<>();
+ for (Map.Entry<String, OMNodeDetails> entry : peerNodesMap.entrySet()) {
+ String remoteNodeId = entry.getKey();
+ OMNodeDetails remoteNodeDetails = entry.getValue();
+ try (OMMetadataProtocolClientSideImpl omMetadataProtocolClient =
+ new OMMetadataProtocolClientSideImpl(configuration,
+ getRemoteUser(), remoteNodeId,
+ remoteNodeDetails.getRpcAddress())) {
+
+ OMConfiguration remoteOMConfiguration =
+ omMetadataProtocolClient.getOMConfiguration();
+ checkRemoteOMConfig(remoteNodeId, remoteOMConfiguration);
+ } catch (IOException ioe) {
+ LOG.error("Remote OM config check failed on OM {}", remoteNodeId, ioe);
+ omsWihtoutNewConfig.add(remoteNodeDetails);
+ }
+ }
+ if (!omsWihtoutNewConfig.isEmpty()) {
+ String errorMsg =
OmUtils.getOMAddressListPrintString(omsWihtoutNewConfig)
+ + " do not have or have incorrect information of the bootstrapping "
+
+ "OM. Update their ozone-site.xml before proceeding.";
+ exitManager.exitSystem(1, errorMsg, LOG);
+ }
+ }
+
+ /**
+ * Verify that the remote OM configuration is updated for the bootstrapping
+ * OM.
+ */
+ private void checkRemoteOMConfig(String remoteNodeId,
+ OMConfiguration remoteOMConfig) throws IOException {
+ if (remoteOMConfig == null) {
+ throw new IOException("Remote OM " + remoteNodeId + " configuration " +
+ "returned null");
+ }
+
+ if (remoteOMConfig.getCurrentPeerList().contains(this.getOMNodeId())) {
+ throw new IOException("Remote OM " + remoteNodeId + " already contains "
+
+ "bootstrapping OM(" + getOMNodeId() + ") in it's in memory peer " +
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.
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]