kishoreg commented on a change in pull request #4939: Removing pinot-common dependency from pinot-hadoop-filesystem and pin… URL: https://github.com/apache/incubator-pinot/pull/4939#discussion_r359143516
########## File path: pinot-common/src/main/java/org/apache/pinot/filesystem/PinotFSDelegator.java ########## @@ -0,0 +1,147 @@ +/** + * 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.pinot.filesystem; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import org.apache.commons.configuration.Configuration; +import org.apache.pinot.common.utils.retry.RetryPolicies; +import org.apache.pinot.common.utils.retry.RetryPolicy; +import org.apache.pinot.spi.filesystem.PinotFS; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.apache.pinot.common.utils.CommonConstants.SegmentOperations.RETRY; +import static org.apache.pinot.common.utils.CommonConstants.SegmentOperations.RETRY_DEFAULT; +import static org.apache.pinot.common.utils.CommonConstants.SegmentOperations.RETRY_WAITIME_MS; +import static org.apache.pinot.common.utils.CommonConstants.SegmentOperations.RETRY_WAITIME_MS_DEFAULT; + + +public class PinotFSDelegator extends PinotFS { + private static final Logger LOGGER = LoggerFactory.getLogger(PinotFSDelegator.class); + + private PinotFS _pinotFS; + + private int _retryCount = RETRY_DEFAULT; + private int _retryWaitMs = RETRY_WAITIME_MS_DEFAULT; + + PinotFSDelegator(PinotFS pinotFS) { + + _pinotFS = pinotFS; + } + + @Override + public void init(Configuration config) { + _retryCount = config.getInt(RETRY, _retryCount); + _retryWaitMs = config.getInt(RETRY_WAITIME_MS, _retryWaitMs); + _pinotFS.init(config); + } + + @Override + public boolean mkdir(URI uri) + throws IOException { + return _pinotFS.mkdir(uri); + } + + @Override + public boolean delete(URI segmentUri, boolean forceDelete) + throws IOException { + return _pinotFS.delete(segmentUri, forceDelete); + } + + @Override + public boolean doMove(URI srcUri, URI dstUri) + throws IOException { + return _pinotFS.doMove(srcUri, dstUri); + } + + @Override + public boolean copy(URI srcUri, URI dstUri) + throws IOException { + return _pinotFS.copy(srcUri, dstUri); + } + + @Override + public boolean exists(URI fileUri) + throws IOException { + return _pinotFS.exists(fileUri); + } + + @Override + public long length(URI fileUri) + throws IOException { + return _pinotFS.length(fileUri); + } + + @Override + public String[] listFiles(URI fileUri, boolean recursive) + throws IOException { + return _pinotFS.listFiles(fileUri, recursive); + } + + @Override + public void copyToLocalFile(URI srcUri, File dstFile) + throws Exception { + RetryPolicy fixedDelayRetryPolicy = RetryPolicies.fixedDelayRetryPolicy(_retryCount, _retryWaitMs); Review comment: I can do that. With that I can move PinotFsFactory and other classes related to PinotFS to pinot-spi. we need to create a utils module at some point. ---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
