/** * Set the source path (directory/file) to the specified storage policy. * @param path The source path (directory/file). * @param policyName The name of the storage policy: 'HOT', 'COLD', etc. * See see hadoop 2.6+ org.apache.hadoop.hdfs.protocol.HdfsConstants for possible list e.g * 'COLD', 'WARM', 'HOT', 'ONE_SSD', 'ALL_SSD', 'LAZY_PERSIST'. */ public void setStoragePolicy(Path path, String policyName) { FSUtils.setStoragePolicy(this.fs, path, policyName); }
/** * Configure block storage policy for CF after the directory is created. */ static void configureStoragePolicy(final Configuration conf, final FileSystem fs, byte[] tableAndFamily, Path cfPath) { if (null == conf || null == fs || null == tableAndFamily || null == cfPath) { return; } String policy = conf.get(STORAGE_POLICY_PROPERTY_CF_PREFIX + Bytes.toString(tableAndFamily), conf.get(STORAGE_POLICY_PROPERTY)); FSUtils.setStoragePolicy(fs, cfPath, policy); }
/** * Set the directory of CF to the specified storage policy. <br> * <i>"LAZY_PERSIST"</i>, <i>"ALL_SSD"</i>, <i>"ONE_SSD"</i>, <i>"HOT"</i>, <i>"WARM"</i>, * <i>"COLD"</i> <br> * <br> * See {@link org.apache.hadoop.hdfs.protocol.HdfsConstants} for more details. * @param familyName The name of column family. * @param policyName The name of the storage policy: 'HOT', 'COLD', etc. * See see hadoop 2.6+ org.apache.hadoop.hdfs.protocol.HdfsConstants for possible list e.g * 'COLD', 'WARM', 'HOT', 'ONE_SSD', 'ALL_SSD', 'LAZY_PERSIST'. */ public void setStoragePolicy(String familyName, String policyName) { FSUtils.setStoragePolicy(this.fs, getStoreDir(familyName), policyName); }
policyName = this.conf.get(HStore.BLOCK_STORAGE_POLICY_KEY); FSUtils.setStoragePolicy(this.fs, dir, policyName);
/** * Note: currently the default policy is set to defer to HDFS and this case is to verify the * logic, will need to remove the check if the default policy is changed */ private void verifyNoHDFSApiInvocationForDefaultPolicy() { FileSystem testFs = new AlwaysFailSetStoragePolicyFileSystem(); // There should be no exception thrown when setting to default storage policy, which indicates // the HDFS API hasn't been called try { FSUtils.setStoragePolicy(testFs, new Path("non-exist"), HConstants.DEFAULT_WAL_STORAGE_POLICY, true); } catch (IOException e) { Assert.fail("Should have bypassed the FS API when setting default storage policy"); } // There should be exception thrown when given non-default storage policy, which indicates the // HDFS API has been called try { FSUtils.setStoragePolicy(testFs, new Path("non-exist"), "HOT", true); Assert.fail("Should have invoked the FS API but haven't"); } catch (IOException e) { // expected given an invalid path } }
FSUtils.setStoragePolicy(fs, testDir, storagePolicy);
/** * Configure block storage policy for CF after the directory is created. */ static void configureStoragePolicy(final Configuration conf, final FileSystem fs, byte[] tableAndFamily, Path cfPath) { if (null == conf || null == fs || null == tableAndFamily || null == cfPath) { return; } String policy = conf.get(STORAGE_POLICY_PROPERTY_CF_PREFIX + Bytes.toString(tableAndFamily), conf.get(STORAGE_POLICY_PROPERTY)); FSUtils.setStoragePolicy(fs, cfPath, policy); }
/** * Configure block storage policy for CF after the directory is created. */ static void configureStoragePolicy(final Configuration conf, final FileSystem fs, byte[] tableAndFamily, Path cfPath) { if (null == conf || null == fs || null == tableAndFamily || null == cfPath) { return; } String policy = conf.get(STORAGE_POLICY_PROPERTY_CF_PREFIX + Bytes.toString(tableAndFamily), conf.get(STORAGE_POLICY_PROPERTY)); FSUtils.setStoragePolicy(fs, cfPath, policy); }
/** * Note: currently the default policy is set to defer to HDFS and this case is to verify the * logic, will need to remove the check if the default policy is changed */ private void verifyNoHDFSApiInvocationForDefaultPolicy() { FileSystem testFs = new AlwaysFailSetStoragePolicyFileSystem(); // There should be no exception thrown when setting to default storage policy, which indicates // the HDFS API hasn't been called try { FSUtils.setStoragePolicy(testFs, new Path("non-exist"), HConstants.DEFAULT_WAL_STORAGE_POLICY, true); } catch (IOException e) { Assert.fail("Should have bypassed the FS API when setting default storage policy"); } // There should be exception thrown when given non-default storage policy, which indicates the // HDFS API has been called try { FSUtils.setStoragePolicy(testFs, new Path("non-exist"), "HOT", true); Assert.fail("Should have invoked the FS API but haven't"); } catch (IOException e) { // expected given an invalid path } }
FSUtils.setStoragePolicy(fs, conf, this.fullPathLogDir, HConstants.WAL_STORAGE_POLICY, HConstants.DEFAULT_WAL_STORAGE_POLICY); this.logFileSuffix = (suffix == null) ? "" : URLEncoder.encode(suffix, "UTF8");
FSUtils.setStoragePolicy(fs, testDir, storagePolicy);