use of org.smartdata.model.CompressionFileState in project SSM by Intel-bigdata.
the class TestCompressionFileDao method testGetCompressionInfo.
@Test
public void testGetCompressionInfo() throws Exception {
long originalLen = 100;
long compressedLen = 50;
CompressionFileState compressionInfo = new CompressionFileState("/test1", 131072, compressionImpl, originalLen, compressedLen, originalPos.toArray(new Long[0]), compressedPos.toArray(new Long[0]));
CompressionFileState compressionInfo2 = new CompressionFileState("/test2", 131072, compressionImpl, originalPos.toArray(new Long[0]), compressedPos.toArray(new Long[0]));
compressionFileDao.insert(compressionInfo);
compressionFileDao.insert(compressionInfo2);
CompressionFileState dbcompressionInfo = compressionFileDao.getInfoByPath("/test1");
Assert.assertTrue(dbcompressionInfo.getPath().equals("/test1"));
Assert.assertTrue(dbcompressionInfo.getBufferSize() == 131072);
Assert.assertTrue(dbcompressionInfo.getCompressionImpl().equals(compressionImpl));
Assert.assertTrue(dbcompressionInfo.getOriginalPos()[0].equals(9000L));
Assert.assertTrue(dbcompressionInfo.getCompressedPos()[1].equals(2000L));
Assert.assertTrue(compressionFileDao.getAll().size() == 2);
Assert.assertEquals(originalLen, dbcompressionInfo.getOriginalLength());
Assert.assertEquals(compressedLen, dbcompressionInfo.getCompressedLength());
}
use of org.smartdata.model.CompressionFileState in project SSM by Intel-bigdata.
the class TestCompressionFileDao method testInsertDeleteCompressionFiles.
@Test
public void testInsertDeleteCompressionFiles() throws Exception {
CompressionFileState compressionInfo = new CompressionFileState("/test", 131072, compressionImpl, originalPos.toArray(new Long[0]), compressedPos.toArray(new Long[0]));
// insert test
compressionFileDao.insert(compressionInfo);
Assert.assertTrue(compressionFileDao.getInfoByPath("/test").getOriginalPos()[0].equals(9000L));
// delete test
compressionFileDao.deleteByPath("/test");
Assert.assertTrue(compressionFileDao.getAll().size() == 0);
}
use of org.smartdata.model.CompressionFileState in project SSM by Intel-bigdata.
the class SmartFileSystem method getFileLinkStatus.
@Override
public FileStatus getFileLinkStatus(final Path f) throws IOException {
FileStatus fileStatus = super.getFileLinkStatus(f);
if (fileStatus.getLen() == 0) {
Path target = getLinkTarget(f);
FileState fileState = smartDFSClient.getFileState(getPathName(target));
if (fileState instanceof CompactFileState) {
fileStatus = getFileStatus(target);
}
} else {
Path target = getLinkTarget(f);
FileState fileState = smartDFSClient.getFileState(getPathName(target));
if (fileState instanceof CompressionFileState) {
fileStatus = getFileStatus(target);
}
}
return fileStatus;
}
use of org.smartdata.model.CompressionFileState in project SSM by Intel-bigdata.
the class SmartFileSystem method listStatus.
@Override
public FileStatus[] listStatus(Path p) throws IOException {
FileStatus[] oldStatus = super.listStatus(p);
ArrayList<FileStatus> newStatus = new ArrayList<>(oldStatus.length);
for (FileStatus status : oldStatus) {
if (oldStatus == null) {
newStatus.add(null);
continue;
}
if (status.getLen() == 0) {
FileState fileState = smartDFSClient.getFileState(getPathName(status.getPath()));
if (fileState instanceof CompactFileState) {
long len = ((CompactFileState) fileState).getFileContainerInfo().getLength();
newStatus.add(new FileStatus(len, status.isDirectory(), status.getReplication(), status.getBlockSize(), status.getModificationTime(), status.getAccessTime(), status.getPermission(), status.getOwner(), status.getGroup(), status.isSymlink() ? status.getSymlink() : null, status.getPath()));
} else {
newStatus.add(status);
}
} else {
FileState fileState = smartDFSClient.getFileState(getPathName(status.getPath()));
if (fileState instanceof CompressionFileState) {
long len = ((CompressionFileState) fileState).getOriginalLength();
newStatus.add(new FileStatus(len, status.isDirectory(), status.getReplication(), status.getBlockSize(), status.getModificationTime(), status.getAccessTime(), status.getPermission(), status.getOwner(), status.getGroup(), status.isSymlink() ? status.getSymlink() : null, status.getPath()));
} else {
newStatus.add(status);
}
}
}
return newStatus.toArray(new FileStatus[oldStatus.length]);
}
use of org.smartdata.model.CompressionFileState in project SSM by Intel-bigdata.
the class CheckCompressAction method execute.
@Override
protected void execute() throws Exception {
if (srcPath == null) {
throw new IOException("File path is not given!");
}
// Consider directory case.
if (dfsClient.getFileInfo(srcPath).isDir()) {
appendLog("The given path is a directory, " + "not applicable to checking compression status.");
return;
}
FileState fileState = HadoopUtil.getFileState(dfsClient, srcPath);
if (fileState instanceof CompressionFileState) {
appendLog("The given file has already been compressed by SSM.");
appendLog("The compression codec is " + ((CompressionFileState) fileState).getCompressionImpl());
appendLog("The original file length is " + ((CompressionFileState) fileState).getOriginalLength());
appendLog("The current file length is " + ((CompressionFileState) fileState).getCompressedLength());
return;
}
appendLog("The given file is not compressed.");
}
Aggregations