paul-rogers commented on code in PR #12874: URL: https://github.com/apache/druid/pull/12874#discussion_r943805075
########## core/src/main/java/org/apache/druid/storage/StorageConnector.java: ########## @@ -0,0 +1,103 @@ +/* + * 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.druid.storage; + +import org.apache.druid.guice.annotations.UnstableApi; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +/** + * Low level interface for interacting with different storage providers like S3, GCS, Azure and local file system. + * <p> + * For adding a new implementation of this interface in your extension extend {@link StorageConnectorProvider}. + * <p> + * For using the interface in your extension as a consumer, use JsonConfigProvider like: + * <ol> + * <li>{@code JsonConfigProvider.bind(binder, "druid,extension.custom.type", StorageConnectorProvider.class, Custom.class);}</li> + * <li>// bind the storage config provider {@code binder.bind(Key.get(StorageConnector.class, Custom.class)).toProvider(Key.get(StorageConnectorProvider.class, Custom.class)).in(LazySingleton.class);} </li> + * <li>// Use Named annotations to access the storageConnector instance in your custom extension.{@code @Custom StorageConnector storageConnector} </li> + * </ol> + * The final state of this inteface would have + * <ol> + * <li>Future Non blocking API's</li> + * <li>Offset based fetch</li> + * </ol> + */ + +@UnstableApi +public interface StorageConnector +{ + + /** + * Check if the path exists in the underlying storage layer. Most implementations prepend the input path + * with a basePath. + * + * @param path + * @return true if path exists else false. + * @throws IOException + */ + @SuppressWarnings("all") Review Comment: I believe that IntelliJ inspections will complain if an implementation includes a `throws` unnecessarily, but I'm not sure about the interface: it can't know that third-part code, outside the code it inspects, might implement the `throws`. ########## core/src/test/java/org/apache/druid/storage/local/LocalFileStorageConnectorTest.java: ########## @@ -0,0 +1,105 @@ +/* + * 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.druid.storage.local; + +import org.apache.druid.storage.StorageConnector; +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.UUID; + +public class LocalFileStorageConnectorTest +{ + @Rule + TemporaryFolder temporaryFolder = new TemporaryFolder(); + private File tempDir = temporaryFolder.newFolder(); + private StorageConnector storageConnector = new LocalFileStorageConnectorProvider(tempDir).get(); + + public LocalFileStorageConnectorTest() throws IOException {} Review Comment: This is not needed, and will fail both checkstyle and IntelliJ inspections, sadly. -- 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]
