use of org.smartdata.model.FileState in project SSM by Intel-bigdata.
the class CompressionScheduler method supportCompression.
/**
* Check if the file type support compression action.
*
* @param path
* @return true if the file supports compression action, else false
*/
public boolean supportCompression(String path) throws MetaStoreException, IOException {
if (path == null) {
LOG.warn("File path is not specified.");
return false;
}
if (dfsClient.getFileInfo(path).isDir()) {
LOG.warn("Compression is not applicable to a directory.");
return false;
}
// Current implementation: only normal file type supports compression action
FileState fileState = metaStore.getFileState(path);
if (fileState.getFileType().equals(FileState.FileType.NORMAL) && fileState.getFileStage().equals(FileState.FileStage.DONE)) {
return true;
}
LOG.debug("File " + path + " doesn't support compression action. " + "Type: " + fileState.getFileType() + "; Stage: " + fileState.getFileStage());
return false;
}
use of org.smartdata.model.FileState in project SSM by Intel-bigdata.
the class CompressionScheduler method supportDecompression.
public boolean supportDecompression(String path) throws MetaStoreException, IOException {
if (path == null) {
LOG.warn("File path is not specified!");
return false;
}
// Exclude directory case
if (dfsClient.getFileInfo(path).isDir()) {
LOG.warn("Decompression is not applicable to a directory.");
return false;
}
FileState fileState = metaStore.getFileState(path);
if (fileState instanceof CompressionFileState) {
return true;
}
LOG.debug("A compressed file path should be given!");
return false;
}
use of org.smartdata.model.FileState in project SSM by Intel-bigdata.
the class SmartFileSystem method isFileClosed.
@Override
public boolean isFileClosed(final Path src) throws IOException {
boolean isFileClosed = super.isFileClosed(src);
if (!isFileClosed) {
FileState fileState = smartDFSClient.getFileState(getPathName(src));
if (fileState instanceof CompactFileState) {
String containerFile = ((CompactFileState) fileState).getFileContainerInfo().getContainerFilePath();
isFileClosed = smartDFSClient.isFileClosed(containerFile);
}
}
return isFileClosed;
}
use of org.smartdata.model.FileState in project SSM by Intel-bigdata.
the class SmartDFSClient method getFileChecksum.
@Override
public MD5MD5CRC32FileChecksum getFileChecksum(String src, long length) throws IOException {
MD5MD5CRC32FileChecksum ret = super.getFileChecksum(src, length);
if (ret.getChecksumOpt().getBytesPerChecksum() == 0) {
FileState fileState = getFileState(src);
if (fileState instanceof CompactFileState) {
try {
// Get original checksum for small file.
byte[] bytes = getXAttr(src, SmartConstants.SMART_FILE_CHECKSUM_XATTR_NAME);
ret = new MD5MD5CRC32FileChecksum();
ret.readFields(new DataInputStream(new ByteArrayInputStream(bytes)));
} catch (IOException e) {
throw new IOException("Failed to get checksum for SSM Small File: " + e.getMessage());
}
}
}
return ret;
}
use of org.smartdata.model.FileState in project SSM by Intel-bigdata.
the class SmartDFSClient method isFileClosed.
@Override
public boolean isFileClosed(String src) throws IOException {
boolean isFileClosed = super.isFileClosed(src);
if (!isFileClosed) {
FileState fileState = getFileState(src);
if (fileState instanceof CompactFileState) {
String containerFile = ((CompactFileState) fileState).getFileContainerInfo().getContainerFilePath();
isFileClosed = super.isFileClosed(containerFile);
}
}
return isFileClosed;
}
Aggregations