Copilot commented on code in PR #156: URL: https://github.com/apache/hbase-operator-tools/pull/156#discussion_r2465918604
########## hbase-hbck2/src/main/java/org/apache/hbase/ReplicationStorageFactoryHelper.java: ########## @@ -0,0 +1,86 @@ +/* + * 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.hbase; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.hbase.client.Connection; +import org.apache.hadoop.hbase.replication.ReplicationPeerStorage; +import org.apache.hadoop.hbase.replication.ReplicationQueueStorage; +import org.apache.hadoop.hbase.replication.ReplicationStorageFactory; +import org.apache.hadoop.hbase.zookeeper.ZKWatcher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Helper class for supporting different versions of HBase for creating + * {@link ReplicationQueueStorage} and {@link ReplicationPeerStorage}. + */ +public class ReplicationStorageFactoryHelper { + + private static final Logger LOG = LoggerFactory.getLogger(ReplicationStorageFactoryHelper.class); + + public static ReplicationPeerStorage getReplicationPeerStorage(Configuration conf, ZKWatcher zkw, + FileSystem fs) { + // Case HBase >= 2.6.0: Invoke the method that requires three parameters + try { + Method method = ReplicationStorageFactory.class.getMethod("getReplicationPeerStorage", + FileSystem.class, ZKWatcher.class, Configuration.class); + return (ReplicationPeerStorage) method.invoke(null, fs, zkw, conf); + } catch (NoSuchMethodException e) { + LOG.debug("No getReplicationQueueStorage method with FileSystem as a parameter, " Review Comment: The error message incorrectly references 'getReplicationQueueStorage' when it should reference 'getReplicationPeerStorage' since this is in the peer storage method. ```suggestion LOG.debug("No getReplicationPeerStorage method with FileSystem as a parameter, " ``` -- 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]
