use of alluxio.client.file.policy.LocalFirstPolicy in project alluxio by Alluxio.
the class SpecificTierWriteIntegrationTest method writeFileAndCheckUsage.
/**
* Writes a file into a specified tier, and then verifies the expected bytes on each tier.
*
* @param writeTier the specific tier to write the file to
* @param memBytes the expected number of bytes used in the MEM tier
* @param ssdBytes the expected number of bytes used in the SSD tier
* @param hddBytes the expected number of bytes used in the HDD tier
* @throws Exception when an error occurs
*/
private void writeFileAndCheckUsage(int writeTier, long memBytes, long ssdBytes, long hddBytes) throws Exception {
FileOutStream os = mFileSystem.createFile(new AlluxioURI("/tier-" + writeTier + "_" + CommonUtils.randomAlphaNumString(5)), CreateFileOptions.defaults().setWriteTier(writeTier).setWriteType(WriteType.MUST_CACHE).setLocationPolicy(new LocalFirstPolicy()));
os.write(BufferUtils.getIncreasingByteArray(FILE_SIZE));
os.close();
HeartbeatScheduler.execute(HeartbeatContext.WORKER_BLOCK_SYNC);
long totalBytes = memBytes + ssdBytes + hddBytes;
Assert.assertEquals("Total bytes used", totalBytes, mLocalAlluxioClusterResource.get().getMaster().getInternalMaster().getBlockMaster().getUsedBytes());
Map<String, Long> bytesOnTiers = mLocalAlluxioClusterResource.get().getMaster().getInternalMaster().getBlockMaster().getUsedBytesOnTiers();
Assert.assertEquals("MEM tier usage", memBytes, bytesOnTiers.get("MEM").longValue());
Assert.assertEquals("SSD tier usage", ssdBytes, bytesOnTiers.get("SSD").longValue());
Assert.assertEquals("HDD tier usage", hddBytes, bytesOnTiers.get("HDD").longValue());
}
use of alluxio.client.file.policy.LocalFirstPolicy in project alluxio by Alluxio.
the class FileOutStreamIntegrationTest method writeSpecifyLocal.
/**
* Tests writing to a file and specify the location to be localhost.
*/
@Test
public void writeSpecifyLocal() throws Exception {
AlluxioURI filePath = new AlluxioURI(PathUtils.uniqPath());
final int length = 2;
try (FileOutStream os = mFileSystem.createFile(filePath, CreateFileOptions.defaults().setWriteType(mWriteType).setLocationPolicy(new LocalFirstPolicy()))) {
os.write((byte) 0);
os.write((byte) 1);
}
if (mWriteType.getAlluxioStorageType().isStore()) {
checkFileInAlluxio(filePath, length);
}
if (mWriteType.getUnderStorageType().isSyncPersist()) {
checkFileInUnderStorage(filePath, length);
}
}
use of alluxio.client.file.policy.LocalFirstPolicy in project alluxio by Alluxio.
the class OutStreamOptionsTest method defaults.
/**
* Tests that building an {@link OutStreamOptions} with the defaults works.
*/
@Test
public void defaults() throws IOException {
AlluxioStorageType alluxioType = AlluxioStorageType.STORE;
UnderStorageType ufsType = UnderStorageType.SYNC_PERSIST;
Configuration.set(PropertyKey.USER_BLOCK_SIZE_BYTES_DEFAULT, "64MB");
Configuration.set(PropertyKey.USER_FILE_WRITE_TYPE_DEFAULT, WriteType.CACHE_THROUGH.toString());
Configuration.set(PropertyKey.USER_FILE_WRITE_TIER_DEFAULT, Constants.LAST_TIER);
OutStreamOptions options = OutStreamOptions.defaults();
Assert.assertEquals(alluxioType, options.getAlluxioStorageType());
Assert.assertEquals(64 * Constants.MB, options.getBlockSizeBytes());
Assert.assertTrue(options.getLocationPolicy() instanceof LocalFirstPolicy);
Assert.assertEquals("test_user", options.getOwner());
Assert.assertEquals("test_group", options.getGroup());
Assert.assertEquals(Mode.defaults().applyFileUMask(), options.getMode());
Assert.assertEquals(Constants.NO_TTL, options.getTtl());
Assert.assertEquals(TtlAction.DELETE, options.getTtlAction());
Assert.assertEquals(ufsType, options.getUnderStorageType());
Assert.assertEquals(WriteType.CACHE_THROUGH, options.getWriteType());
Assert.assertEquals(Constants.LAST_TIER, options.getWriteTier());
ConfigurationTestUtils.resetConfiguration();
}
Aggregations