[ 
https://issues.apache.org/jira/browse/HIVE-24032?focusedWorklogId=470534&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-470534
 ]

ASF GitHub Bot logged work on HIVE-24032:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 14/Aug/20 02:20
            Start Date: 14/Aug/20 02:20
    Worklog Time Spent: 10m 
      Work Description: aasha commented on a change in pull request #1396:
URL: https://github.com/apache/hive/pull/1396#discussion_r470373805



##########
File path: 
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/EncryptionFileUtils.java
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.hive.metastore.utils;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hdfs.client.HdfsAdmin;
+import org.apache.hadoop.hdfs.protocol.EncryptionZone;
+
+import java.io.IOException;
+import java.net.URI;
+
+public class EncryptionFileUtils {
+
+  public static boolean isPathEncrypted(Path path, Configuration conf) throws 
IOException {
+    Path fullPath;
+    if (path.isAbsolute()) {
+      fullPath = path;
+    } else {
+      fullPath = path.getFileSystem(conf).makeQualified(path);
+    }
+    if(!"hdfs".equalsIgnoreCase(path.toUri().getScheme())) {
+      return false;
+    }
+    return (EncryptionFileUtils.getEncryptionZoneForPath(fullPath, conf) != 
null);
+  }
+
+  public static EncryptionZone getEncryptionZoneForPath(Path path, 
Configuration conf) throws IOException {
+    URI uri = path.getFileSystem(conf).getUri();
+    if ("hdfs".equals(uri.getScheme())) {
+      HdfsAdmin hdfsAdmin = new HdfsAdmin(uri, conf);
+      if (path.getFileSystem(conf).exists(path)) {
+        return hdfsAdmin.getEncryptionZoneForPath(path);
+      } else if (!path.getParent().equals(path)) {
+        return getEncryptionZoneForPath(path.getParent(), conf);
+      } else {
+        return null;
+      }
+    }
+    return null;
+  }
+
+  public static void createEncryptionZone(Path path, String keyName, 
Configuration conf) throws IOException {

Review comment:
       Better to keep it as part of same utility class. Tests can also use this 
from utility. Its not a test code, its a utility method




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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 470534)
    Time Spent: 40m  (was: 0.5h)

> Remove hadoop shims dependency and use FileSystem Api directly from 
> standalone metastore
> ----------------------------------------------------------------------------------------
>
>                 Key: HIVE-24032
>                 URL: https://issues.apache.org/jira/browse/HIVE-24032
>             Project: Hive
>          Issue Type: Task
>            Reporter: Aasha Medhi
>            Assignee: Aasha Medhi
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: HIVE-24032.01.patch
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to