use of org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.CompactionDescriptor in project hbase by apache.
the class ProtobufUtil method toCompactionDescriptor.
public static CompactionDescriptor toCompactionDescriptor(HRegionInfo info, byte[] regionName, byte[] family, List<Path> inputPaths, List<Path> outputPaths, Path storeDir) {
// compaction descriptor contains relative paths.
// input / output paths are relative to the store dir
// store dir is relative to region dir
CompactionDescriptor.Builder builder = CompactionDescriptor.newBuilder().setTableName(UnsafeByteOperations.unsafeWrap(info.getTable().toBytes())).setEncodedRegionName(UnsafeByteOperations.unsafeWrap(regionName == null ? info.getEncodedNameAsBytes() : regionName)).setFamilyName(UnsafeByteOperations.unsafeWrap(family)).setStoreHomeDir(//make relative
storeDir.getName());
for (Path inputPath : inputPaths) {
//relative path
builder.addCompactionInput(inputPath.getName());
}
for (Path outputPath : outputPaths) {
builder.addCompactionOutput(outputPath.getName());
}
builder.setRegionName(UnsafeByteOperations.unsafeWrap(info.getRegionName()));
return builder.build();
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.CompactionDescriptor in project hbase by apache.
the class HStore method writeCompactionWalRecord.
/**
* Writes the compaction WAL record.
* @param filesCompacted Files compacted (input).
* @param newFiles Files from compaction.
*/
private void writeCompactionWalRecord(Collection<StoreFile> filesCompacted, Collection<StoreFile> newFiles) throws IOException {
if (region.getWAL() == null)
return;
List<Path> inputPaths = new ArrayList<>(filesCompacted.size());
for (StoreFile f : filesCompacted) {
inputPaths.add(f.getPath());
}
List<Path> outputPaths = new ArrayList<>(newFiles.size());
for (StoreFile f : newFiles) {
outputPaths.add(f.getPath());
}
HRegionInfo info = this.region.getRegionInfo();
CompactionDescriptor compactionDescriptor = ProtobufUtil.toCompactionDescriptor(info, family.getName(), inputPaths, outputPaths, fs.getStoreDir(getFamily().getNameAsString()));
// Fix reaching into Region to get the maxWaitForSeqId.
// Does this method belong in Region altogether given it is making so many references up there?
// Could be Region#writeCompactionMarker(compactionDescriptor);
WALUtil.writeCompactionMarker(this.region.getWAL(), this.region.getReplicationScope(), this.region.getRegionInfo(), compactionDescriptor, this.region.getMVCC());
}
Aggregations