use of org.smartdata.model.CompactFileState 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;
}
use of org.smartdata.model.CompactFileState in project SSM by Intel-bigdata.
the class SmartDFSClient method getBlockLocations.
@Override
public BlockLocation[] getBlockLocations(String src, long start, long length) throws IOException {
BlockLocation[] blockLocations = super.getBlockLocations(src, start, length);
if (blockLocations.length == 0) {
FileState fileState = getFileState(src);
if (fileState instanceof CompactFileState) {
String containerFile = ((CompactFileState) fileState).getFileContainerInfo().getContainerFilePath();
long offset = ((CompactFileState) fileState).getFileContainerInfo().getOffset();
blockLocations = super.getBlockLocations(containerFile, offset + start, length);
for (BlockLocation blockLocation : blockLocations) {
blockLocation.setOffset(blockLocation.getOffset() - offset);
}
return blockLocations;
}
} else {
FileState fileState = getFileState(src);
if (fileState instanceof CompressionFileState) {
CompressionFileState compressionInfo = (CompressionFileState) fileState;
Long[] originalPos = compressionInfo.getOriginalPos().clone();
Long[] compressedPos = compressionInfo.getCompressedPos().clone();
int startIndex = compressionInfo.getPosIndexByOriginalOffset(start);
int endIndex = compressionInfo.getPosIndexByOriginalOffset(start + length - 1);
long compressedStart = compressedPos[startIndex];
long compressedLength = 0;
if (endIndex < compressedPos.length - 1) {
compressedLength = compressedPos[endIndex + 1] - compressedStart;
} else {
compressedLength = compressionInfo.getCompressedLength() - compressedStart;
}
LocatedBlocks originalLocatedBlocks = super.getLocatedBlocks(src, compressedStart, compressedLength);
List<LocatedBlock> blocks = new ArrayList<>();
for (LocatedBlock block : originalLocatedBlocks.getLocatedBlocks()) {
// TODO handle CDH2.6 storage type
// blocks.add(new LocatedBlock(
// block.getBlock(),
// block.getLocations(),
// block.getStorageIDs(),
// block.getStorageTypes(),
// compressionInfo
// .getPosIndexByCompressedOffset(block.getStartOffset()),
// block.isCorrupt(),
// block.getCachedLocations()
// ));
blocks.add(new LocatedBlock(block.getBlock(), block.getLocations(), compressionInfo.getPosIndexByCompressedOffset(block.getStartOffset()), block.isCorrupt()));
}
LocatedBlock lastLocatedBlock = originalLocatedBlocks.getLastLocatedBlock();
long fileLength = compressionInfo.getOriginalLength();
return new LocatedBlocks(fileLength, originalLocatedBlocks.isUnderConstruction(), blocks, lastLocatedBlock, originalLocatedBlocks.isLastBlockComplete(), originalLocatedBlocks.getFileEncryptionInfo()).getLocatedBlocks().toArray(new BlockLocation[0]);
}
}
return blockLocations;
}
use of org.smartdata.model.CompactFileState in project SSM by Intel-bigdata.
the class SmartDFSClient method getFileLinkInfo.
@Override
public HdfsFileStatus getFileLinkInfo(String src) throws IOException {
HdfsFileStatus fileStatus = super.getFileLinkInfo(src);
if (fileStatus.getLen() == 0) {
String target = super.getLinkTarget(src);
FileState fileState = getFileState(target);
if (fileState instanceof CompactFileState) {
fileStatus = getFileInfo(target);
}
}
return fileStatus;
}
use of org.smartdata.model.CompactFileState in project SSM by Intel-bigdata.
the class MetaStore method insertUpdateFileState.
public void insertUpdateFileState(FileState fileState) throws MetaStoreException {
try {
// Update corresponding tables according to the file state
fileStateDao.insertUpdate(fileState);
switch(fileState.getFileType()) {
case COMPACT:
CompactFileState compactFileState = (CompactFileState) fileState;
smallFileDao.insertUpdate(compactFileState);
break;
case COMPRESSION:
CompressionFileState compressionFileState = (CompressionFileState) fileState;
compressionFileDao.insertUpdate(compressionFileState);
break;
case S3:
break;
default:
}
} catch (Exception e) {
throw new MetaStoreException(e);
}
}
Aggregations