You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2020/03/05 19:09:57 UTC

[GitHub] [incubator-pinot] snleee commented on a change in pull request #5116: Add Azure Data Lake Gen2 connector for PinotFS

snleee commented on a change in pull request #5116: Add Azure Data Lake Gen2 connector for PinotFS
URL: https://github.com/apache/incubator-pinot/pull/5116#discussion_r388502577
 
 

 ##########
 File path: pinot-plugins/pinot-file-system/pinot-adls/src/main/java/org/apache/pinot/plugin/filesystem/AzureGen2PinotFS.java
 ##########
 @@ -0,0 +1,447 @@
+/**
+ * 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.plugin.filesystem;
+
+import com.azure.core.http.rest.PagedIterable;
+import com.azure.core.util.Context;
+import com.azure.storage.blob.BlobClient;
+import com.azure.storage.blob.BlobServiceClient;
+import com.azure.storage.blob.BlobServiceClientBuilder;
+import com.azure.storage.common.StorageSharedKeyCredential;
+import com.azure.storage.common.Utility;
+import com.azure.storage.file.datalake.DataLakeFileClient;
+import com.azure.storage.file.datalake.DataLakeFileSystemClient;
+import com.azure.storage.file.datalake.DataLakeServiceClient;
+import com.azure.storage.file.datalake.DataLakeServiceClientBuilder;
+import com.azure.storage.file.datalake.models.DataLakeRequestConditions;
+import com.azure.storage.file.datalake.models.DataLakeStorageException;
+import com.azure.storage.file.datalake.models.ListPathsOptions;
+import com.azure.storage.file.datalake.models.PathHttpHeaders;
+import com.azure.storage.file.datalake.models.PathItem;
+import com.azure.storage.file.datalake.models.PathProperties;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URLDecoder;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.sql.Timestamp;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
+import java.util.Arrays;
+import java.util.Map;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.io.FileUtils;
+import org.apache.pinot.spi.filesystem.PinotFS;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Azure Data Lake Storage Gen2 implementation for the PinotFS interface.
+ */
+public class AzureGen2PinotFS extends PinotFS {
+  private static final Logger LOGGER = LoggerFactory.getLogger(AzureGen2PinotFS.class);
+
+  private static final String ACCOUNT_NAME = "accountName";
+  private static final String ACCESS_KEY = "accessKey";
+  private static final String FILE_SYSTEM_NAME = "fileSystemName";
+
+  private static final String HTTPS_URL_PREFIX = "https://";
+  private static final String DIRECTORY_DELIMITER = "/";
+
+  private static final String AZURE_STORAGE_DNS_SUFFIX = ".dfs.core.windows.net";
+  private static final String AZURE_BLOB_DNS_SUFFIX = ".blob.core.windows.net";
+  private static final String PATH_ALREADY_EXISTS_ERROR_CODE = "PathAlreadyExists";
+  private static final String IS_DIRECTORY_KEY = "hdi_isfolder";
+
+  private static final int NOT_FOUND_STATUS_CODE = 404;
+  private static final int ALREADY_EXISTS_STATUS_CODE = 409;
+
+  // Azure Data Lake Gen2's block size is 4MB
+  private static final int BUFFER_SIZE = 4 * 1024 * 1024;
+
+  private DataLakeFileSystemClient _fileSystemClient;
+  private BlobServiceClient _blobServiceClient;
+
+  @Override
+  public void init(Configuration config) {
+    // Azure storage account name
+    String accountName = config.getString(ACCOUNT_NAME);
+    String accessKey = config.getString(ACCESS_KEY);
 
 Review comment:
   Existing AzurePinotFS also gets the config as a string. I guess that our internal restli framework handles encryption of the `ACCESS_KEY`. I will add `TODO` comment

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org