hanishakoneru commented on a change in pull request #2491: URL: https://github.com/apache/ozone/pull/2491#discussion_r694350553
########## File path: hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OMMetadataProtocolClientSideImpl.java ########## @@ -0,0 +1,128 @@ +/** + * 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.helpers.OMNodeDetails; +import org.apache.hadoop.ozone.om.protocol.OMMetadata; +import org.apache.hadoop.ozone.om.protocol.OMMetadataProtocol; +import org.apache.hadoop.ozone.protocol.proto.OzoneManagerMetadataProtocolProtos.OMMetadataInfoRequest; +import org.apache.hadoop.ozone.protocol.proto.OzoneManagerMetadataProtocolProtos.OMMetadataInfoResponse; +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), + OMInterServiceProtocolPB.class, ProtobufRpcEngine.class); + + this.omNodeID = omNodeId; + + // OM metadata is requested from a specific OM and hence there is no need + // of any failover provider. + RetryPolicy connectionRetryPolicy = RetryPolicies + .failoverOnNetworkException(0); Review comment: Done. ########## File path: hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/OMMetadataProtocolClientSideImpl.java ########## @@ -0,0 +1,128 @@ +/** + * 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.helpers.OMNodeDetails; +import org.apache.hadoop.ozone.om.protocol.OMMetadata; +import org.apache.hadoop.ozone.om.protocol.OMMetadataProtocol; +import org.apache.hadoop.ozone.protocol.proto.OzoneManagerMetadataProtocolProtos.OMMetadataInfoRequest; +import org.apache.hadoop.ozone.protocol.proto.OzoneManagerMetadataProtocolProtos.OMMetadataInfoResponse; +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), + OMInterServiceProtocolPB.class, ProtobufRpcEngine.class); Review comment: Done. ########## File path: hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocol/OMMetadata.java ########## @@ -0,0 +1,77 @@ +/** + * 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.protocol; + +import java.util.ArrayList; +import java.util.List; +import org.apache.hadoop.ozone.om.helpers.OMNodeDetails; + +/** + * Class storing the OM metadata such as the node details in memory and node + * details when config is reloaded from disk. + * Note that this class is used as a structure to transfer the OM node + * information through the {@link OMMetadataProtocol} and not for storing the + * metadata information in OzoneManager itself. + */ +public final class OMMetadata { + + // OM nodes present in OM's memory + private List<OMNodeDetails> omNodesInMemory = new ArrayList<>(); + // OM nodes reloaded from new config on disk + private List<OMNodeDetails> omNodesInNewConf = new ArrayList<>(); + + private OMMetadata(List<OMNodeDetails> inMemoryNodeList, + List<OMNodeDetails> onDiskNodeList) { + if (inMemoryNodeList != null) { Review comment: Done. ########## File path: hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java ########## @@ -697,4 +701,51 @@ 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 rpcAddrKey, rpcAddrStr, hostAddr, httpAddr, httpsAddr; + int rpcPort, ratisPort; + if (omNodeIds.size() == 0) { + //Check if it is non-HA cluster + rpcAddrKey = ConfUtils.addKeySuffixes(OZONE_OM_ADDRESS_KEY); 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]
