use of alluxio.wire.FileInfo in project alluxio by Alluxio.
the class FileSystemClientRestApiTest method listStatus.
@Test
public void listStatus() throws Exception {
AlluxioURI uri = new AlluxioURI("/file");
writeFile(uri, null);
String result = new TestCase(mHostname, mPort, PATHS_PREFIX + uri.toString() + "/" + PathsRestServiceHandler.LIST_STATUS, NO_PARAMS, HttpMethod.POST, null, TestCaseOptions.defaults().setBody(ListStatusOptions.defaults())).call();
List<FileInfo> fileInfos = new ObjectMapper().readValue(result, new TypeReference<List<FileInfo>>() {
});
FileInfo fileInfo = Iterables.getOnlyElement(fileInfos);
Assert.assertEquals(uri.getPath(), fileInfo.getPath());
Assert.assertEquals(0, fileInfo.getLength());
}
use of alluxio.wire.FileInfo in project alluxio by Alluxio.
the class FileSystemClientRestApiTest method setAttribute.
@Test
public void setAttribute() throws Exception {
AlluxioURI uri = new AlluxioURI("/file");
writeFile(uri, null);
new TestCase(mHostname, mPort, PATHS_PREFIX + uri.toString() + "/" + PathsRestServiceHandler.SET_ATTRIBUTE, NO_PARAMS, HttpMethod.POST, null, TestCaseOptions.defaults().setBody(SetAttributeOptions.defaults().setMode(Mode.defaults()))).run();
FileInfo fileInfo = mFileSystemMaster.getFileInfo(uri);
Assert.assertEquals(uri.toString(), fileInfo.getPath());
}
use of alluxio.wire.FileInfo in project alluxio by Alluxio.
the class FileSystemClientRestApiTest method upload.
@Test
public void upload() throws Exception {
AlluxioURI uri = new AlluxioURI("/file");
String message = "Greetings traveller!";
writeFile(uri, message.getBytes());
String result = new TestCase(mHostname, mPort, PATHS_PREFIX + uri.toString() + "/" + PathsRestServiceHandler.GET_STATUS, NO_PARAMS, HttpMethod.POST, null).call();
FileInfo fileInfo = new ObjectMapper().readValue(result, FileInfo.class);
Assert.assertEquals(message.length(), fileInfo.getLength());
}
use of alluxio.wire.FileInfo in project alluxio by Alluxio.
the class FileSystemMasterIntegrationTest method ttlExpiredCreateFile.
@Test
public void ttlExpiredCreateFile() throws Exception {
mFsMaster.createDirectory(new AlluxioURI("/testFolder"), CreateDirectoryOptions.defaults());
long ttl = 1;
CreateFileOptions options = CreateFileOptions.defaults().setTtl(ttl);
long fileId = mFsMaster.createFile(new AlluxioURI("/testFolder/testFile1"), options);
FileInfo folderInfo = mFsMaster.getFileInfo(mFsMaster.getFileId(new AlluxioURI("/testFolder/testFile1")));
Assert.assertEquals(fileId, folderInfo.getFileId());
Assert.assertEquals(ttl, folderInfo.getTtl());
// Sleep for the ttl expiration.
CommonUtils.sleepMs(2 * TTL_CHECKER_INTERVAL_MS);
HeartbeatScheduler.execute(HeartbeatContext.MASTER_TTL_CHECK);
mThrown.expect(FileDoesNotExistException.class);
mFsMaster.getFileInfo(fileId);
}
use of alluxio.wire.FileInfo in project alluxio by Alluxio.
the class FileSystemMasterIntegrationTest method lastModificationTimeRename.
@Test
public void lastModificationTimeRename() throws Exception {
AlluxioURI srcPath = new AlluxioURI("/testFolder/testFile1");
AlluxioURI dstPath = new AlluxioURI("/testFolder/testFile2");
mFsMaster.createDirectory(new AlluxioURI("/testFolder"), CreateDirectoryOptions.defaults());
mFsMaster.createFile(srcPath, CreateFileOptions.defaults());
RenameOptions options = RenameOptions.defaults().setOperationTimeMs(TEST_TIME_MS);
mFsMaster.rename(srcPath, dstPath, options);
FileInfo folderInfo = mFsMaster.getFileInfo(mFsMaster.getFileId(new AlluxioURI("/testFolder")));
Assert.assertEquals(TEST_TIME_MS, folderInfo.getLastModificationTimeMs());
}
Aggregations