use of alluxio.client.file.URIStatus in project alluxio by Alluxio.
the class CopyFromLocalCommandTest method copyFromLocalTestWithFullURI.
@Test
public void copyFromLocalTestWithFullURI() throws IOException, AlluxioException {
File testFile = generateFileContent("/srcFileURI", BufferUtils.getIncreasingByteArray(10));
String alluxioURI = "alluxio://" + mLocalAlluxioCluster.getHostname() + ":" + mLocalAlluxioCluster.getMasterRpcPort() + "/destFileURI";
// when
mFsShell.run("copyFromLocal", testFile.getPath(), alluxioURI);
String cmdOut = getCommandOutput(new String[] { "copyFromLocal", testFile.getPath(), alluxioURI });
// then
Assert.assertEquals(cmdOut, mOutput.toString());
AlluxioURI uri = new AlluxioURI("/destFileURI");
URIStatus status = mFileSystem.getStatus(uri);
Assert.assertEquals(10L, status.getLength());
byte[] read = readContent(uri, 10);
Assert.assertTrue(BufferUtils.equalIncreasingByteArray(10, read));
}
use of alluxio.client.file.URIStatus in project alluxio by Alluxio.
the class CopyFromLocalCommandTest method copyFromLocalFileToDstPath.
@Test
public void copyFromLocalFileToDstPath() throws IOException, AlluxioException {
String dataString = "copyFromLocalFileToDstPathTest";
byte[] data = dataString.getBytes();
File localDir = new File(mLocalAlluxioCluster.getAlluxioHome() + "/localDir");
localDir.mkdir();
File localFile = generateFileContent("/localDir/testFile", data);
mFsShell.run("mkdir", "/dstDir");
mFsShell.run("copyFromLocal", localFile.getPath(), "/dstDir");
AlluxioURI uri = new AlluxioURI("/dstDir/testFile");
URIStatus status = mFileSystem.getStatus(uri);
Assert.assertNotNull(status);
byte[] read = readContent(uri, data.length);
Assert.assertEquals(new String(read), dataString);
}
use of alluxio.client.file.URIStatus in project alluxio by Alluxio.
the class CopyFromLocalCommandTest method copyFromLocal.
@Test
public void copyFromLocal() throws IOException, AlluxioException {
File testDir = new File(mLocalAlluxioCluster.getAlluxioHome() + "/testDir");
testDir.mkdir();
File testDirInner = new File(mLocalAlluxioCluster.getAlluxioHome() + "/testDir/testDirInner");
testDirInner.mkdir();
File testFile = generateFileContent("/testDir/testFile", BufferUtils.getIncreasingByteArray(10));
generateFileContent("/testDir/testDirInner/testFile2", BufferUtils.getIncreasingByteArray(10, 20));
mFsShell.run("copyFromLocal", testFile.getParent(), "/testDir");
Assert.assertEquals(getCommandOutput(new String[] { "copyFromLocal", testFile.getParent(), "/testDir" }), mOutput.toString());
AlluxioURI uri1 = new AlluxioURI("/testDir/testFile");
AlluxioURI uri2 = new AlluxioURI("/testDir/testDirInner/testFile2");
URIStatus status1 = mFileSystem.getStatus(uri1);
URIStatus status2 = mFileSystem.getStatus(uri2);
Assert.assertNotNull(status1);
Assert.assertNotNull(status2);
Assert.assertEquals(10, status1.getLength());
Assert.assertEquals(20, status2.getLength());
byte[] read = readContent(uri1, 10);
Assert.assertTrue(BufferUtils.equalIncreasingByteArray(10, read));
read = readContent(uri2, 20);
Assert.assertTrue(BufferUtils.equalIncreasingByteArray(10, 20, read));
}
use of alluxio.client.file.URIStatus in project alluxio by Alluxio.
the class CopyFromLocalCommandTest method copyFromLocalLarge.
@Test
public void copyFromLocalLarge() throws IOException, AlluxioException {
File testFile = new File(mLocalAlluxioCluster.getAlluxioHome() + "/testFile");
testFile.createNewFile();
FileOutputStream fos = new FileOutputStream(testFile);
byte[] toWrite = BufferUtils.getIncreasingByteArray(SIZE_BYTES);
fos.write(toWrite);
fos.close();
mFsShell.run("copyFromLocal", testFile.getAbsolutePath(), "/testFile");
Assert.assertEquals(getCommandOutput(new String[] { "copyFromLocal", testFile.getAbsolutePath(), "/testFile" }), mOutput.toString());
AlluxioURI uri = new AlluxioURI("/testFile");
URIStatus status = mFileSystem.getStatus(uri);
Assert.assertNotNull(status);
Assert.assertEquals(SIZE_BYTES, status.getLength());
try (FileInStream tfis = mFileSystem.openFile(uri, OpenFileOptions.defaults().setReadType(ReadType.NO_CACHE))) {
byte[] read = new byte[SIZE_BYTES];
tfis.read(read);
Assert.assertTrue(BufferUtils.equalIncreasingByteArray(SIZE_BYTES, read));
}
}
use of alluxio.client.file.URIStatus in project alluxio by Alluxio.
the class CpCommandTest method copyFromLocal.
@Test
public void copyFromLocal() throws IOException, AlluxioException {
File testDir = new File(mLocalAlluxioCluster.getAlluxioHome() + "/testDir");
testDir.mkdir();
File testDirInner = new File(mLocalAlluxioCluster.getAlluxioHome() + "/testDir/testDirInner");
testDirInner.mkdir();
File testFile = generateFileContent("/testDir/testFile", BufferUtils.getIncreasingByteArray(10));
generateFileContent("/testDir/testDirInner/testFile2", BufferUtils.getIncreasingByteArray(10, 20));
String[] cmd = new String[] { "cp", "file://" + testFile.getParent(), "/testDir" };
mFsShell.run(cmd);
Assert.assertEquals(getCommandOutput(cmd), mOutput.toString());
AlluxioURI uri1 = new AlluxioURI("/testDir/testFile");
AlluxioURI uri2 = new AlluxioURI("/testDir/testDirInner/testFile2");
URIStatus status1 = mFileSystem.getStatus(uri1);
URIStatus status2 = mFileSystem.getStatus(uri2);
Assert.assertNotNull(status1);
Assert.assertNotNull(status2);
Assert.assertEquals(10, status1.getLength());
Assert.assertEquals(20, status2.getLength());
byte[] read = readContent(uri1, 10);
Assert.assertTrue(BufferUtils.equalIncreasingByteArray(10, read));
read = readContent(uri2, 20);
Assert.assertTrue(BufferUtils.equalIncreasingByteArray(10, 20, read));
}
Aggregations