[ https://issues.apache.org/jira/browse/TRAFODION-3026?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16456678#comment-16456678 ]
ASF GitHub Bot commented on TRAFODION-3026: ------------------------------------------- Github user selvaganesang commented on a diff in the pull request: https://github.com/apache/trafodion/pull/1532#discussion_r184734061 --- Diff: core/sql/src/main/java/org/trafodion/sql/HBaseClient.java --- @@ -552,10 +578,84 @@ public boolean createk(String tblName, Object[] tableOptions, admin.createTable(desc); } } - admin.close(); + + if(setDescRet!= null) + if(setDescRet.storagePolicyChanged()) + { + //change the HDFS storage policy + //get the HBase table path + String hbaseRoot = config.get("hbase.rootdir"); + FileSystem fs = FileSystem.get(config); + //Construct the HDFS dir + //find out if namespace is there + String[] parts = tblName.split(":"); + String namespacestr=""; + + //guess the path pattern + //different HBase version may have different path pattern + //There is no interface to get this information using HBase User API + //Since it is HBase internal behavior + //At present, before HBase 2.0 release and before HBASE-19858 released in HBase 1.5.0 + //Trafodion here need a trick to guess + String fullPath = hbaseRoot + "/data/" ; + String fullPath2 = hbaseRoot + "/data/default/"; + + //check if fullPath2 exist + if(fs.exists(new Path(fullPath2))) + fullPath = fullPath2; + + if(parts.length >1) //have namespace + fullPath = fullPath + parts[0] + "/" + parts[1]; + else + fullPath = fullPath + tblName; + + if (logger.isDebugEnabled()) logger.debug("createk table fullPath is " + fullPath); + + String invokeret = invokeSetStoragePolicy(fs, fullPath, setDescRet.storagePolicy_ ) ; + + if( invokeret != null) + { + //error handling + admin.close(); + throw new IOException(invokeret); + } + } + + admin.close(); return true; } + private static String invokeSetStoragePolicy(final FileSystem fs, final String pathstr, + final String storagePolicy) { + String ret = null; + Path path = new Path(pathstr); + Method m = null; + try { + m = fs.getClass().getDeclaredMethod("setStoragePolicy", + new Class<?>[] { Path.class, String.class }); + m.setAccessible(true); + } catch (NoSuchMethodException e) { + ret = "FileSystem doesn't support setStoragePolicy"; + m = null; + } catch (SecurityException e) { + ret = "No access to setStoragePolicy on FileSystem from the SecurityManager"; + m = null; // could happen on setAccessible() or getDeclaredMethod() + } + if (m != null) { + try { + m.invoke(fs, path, storagePolicy); + if (logger.isDebugEnabled()) { + logger.debug("Set storagePolicy=" + storagePolicy + " for path=" + path); + } + } catch (Exception e) { + logger.error("invoke set storage policy error : " + e); --- End diff -- Thanks for making the changes as requested. You might have overlooked this. Changing '+' to ',' (make it as a parameter) would help to see the stack in the log file. Other wise only the exception name alone will be logged. > add create option storage policy > -------------------------------- > > Key: TRAFODION-3026 > URL: https://issues.apache.org/jira/browse/TRAFODION-3026 > Project: Apache Trafodion > Issue Type: New Feature > Reporter: liu ming > Assignee: liu ming > Priority: Major > > HDFS support HSM, it is possible to specify the storage policy in HBase > column family attribute, so it can use the underlying storage policy -- This message was sent by Atlassian JIRA (v7.6.3#76005)