use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.
the class CapacityUsageIntegrationTest method createAndWriteFile.
private void createAndWriteFile(AlluxioURI filePath, WriteType writeType, int len) throws IOException, AlluxioException {
ByteBuffer buf = ByteBuffer.allocate(len);
buf.order(ByteOrder.nativeOrder());
for (int k = 0; k < len; k++) {
buf.put((byte) k);
}
CreateFileOptions options = CreateFileOptions.defaults().setWriteType(writeType);
FileOutStream os = mFileSystem.createFile(filePath, options);
os.write(buf.array());
os.close();
}
use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.
the class LineageMasterIntegrationTest method lineageCompleteAndAsyncPersist.
@Test
public void lineageCompleteAndAsyncPersist() throws Exception {
try (LineageMasterClient lineageMasterClient = getLineageMasterClient()) {
ArrayList<String> outFiles = new ArrayList<>();
Collections.addAll(outFiles, OUT_FILE);
lineageMasterClient.createLineage(new ArrayList<String>(), outFiles, mJob);
CreateFileOptions options = CreateFileOptions.defaults().setWriteType(WriteType.MUST_CACHE).setBlockSizeBytes(BLOCK_SIZE_BYTES);
LineageFileSystem fs = (LineageFileSystem) mLocalAlluxioClusterResource.get().getClient();
FileOutStream outputStream = fs.createFile(new AlluxioURI(OUT_FILE), options);
outputStream.write(1);
outputStream.close();
List<LineageInfo> infos = lineageMasterClient.getLineageInfoList();
AlluxioURI uri = new AlluxioURI(infos.get(0).getOutputFiles().get(0));
URIStatus status = getFileSystemMasterClient().getStatus(uri);
Assert.assertNotEquals(PersistenceState.PERSISTED.toString(), status.getPersistenceState());
Assert.assertTrue(status.isCompleted());
IntegrationTestUtils.waitForPersist(mLocalAlluxioClusterResource, uri);
// worker notifies the master
status = getFileSystemMasterClient().getStatus(uri);
Assert.assertEquals(PersistenceState.PERSISTED.toString(), status.getPersistenceState());
}
}
use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.
the class FileSystemTestUtils method createByteFile.
/**
* Creates a simple file with {@code len} bytes.
*
* @param fs a {@link FileSystem} handler
* @param fileURI URI of the file
* @param writeType {@link WriteType} used to create the file
* @param len file size
* @throws IOException if {@code path} is invalid (e.g., illegal URI)
*/
public static void createByteFile(FileSystem fs, AlluxioURI fileURI, WriteType writeType, int len) throws IOException {
CreateFileOptions options = CreateFileOptions.defaults().setWriteType(writeType);
createByteFile(fs, fileURI, options, len);
}
use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.
the class FileSystemTestUtils method createByteFile.
/**
* Creates a simple file with {@code len} bytes.
*
* @param fs a {@link FileSystem} handler
* @param fileName the name of the file to be created
* @param writeType {@link WriteType} used to create the file
* @param len file size
* @param blockCapacityByte block size of the file
* @throws IOException if {@code path} is invalid (e.g., illegal URI)
*/
public static void createByteFile(FileSystem fs, String fileName, WriteType writeType, int len, long blockCapacityByte) throws IOException {
CreateFileOptions options = CreateFileOptions.defaults().setWriteType(writeType).setBlockSizeBytes(blockCapacityByte);
createByteFile(fs, new AlluxioURI(fileName), options, len);
}
use of alluxio.client.file.options.CreateFileOptions in project alluxio by Alluxio.
the class LineageFileSystemTest method getNonLineageStream.
/**
* Tests that a {@link FileOutStream} is returned.
*/
@Test
public void getNonLineageStream() throws Exception {
AlluxioURI path = new AlluxioURI("test");
Mockito.when(mLineageMasterClient.reinitializeFile("test", TEST_BLOCK_SIZE, 0, TtlAction.DELETE)).thenThrow(new LineageDoesNotExistException("lineage does not exist"));
CreateFileOptions options = CreateFileOptions.defaults().setBlockSizeBytes(TEST_BLOCK_SIZE).setTtl(0);
FileOutStream outStream = mAlluxioLineageFileSystem.createFile(path, options);
Assert.assertTrue(outStream != null);
Assert.assertFalse(outStream instanceof LineageFileOutStream);
Assert.assertFalse(outStream instanceof DummyFileOutputStream);
// verify client is released
Mockito.verify(mLineageContext).releaseMasterClient(mLineageMasterClient);
}
Aggregations