use of org.apache.accumulo.core.tabletserver.thrift.CompactionReason in project accumulo by apache.
the class CompactionInfo method toThrift.
public ActiveCompaction toThrift() {
CompactionType type;
if (compactor.hasIMM())
if (compactor.getFilesToCompact().size() > 0)
type = CompactionType.MERGE;
else
type = CompactionType.MINOR;
else if (!compactor.willPropogateDeletes())
type = CompactionType.FULL;
else
type = CompactionType.MAJOR;
CompactionReason reason;
if (compactor.hasIMM()) {
switch(compactor.getMinCReason()) {
case USER:
reason = CompactionReason.USER;
break;
case CLOSE:
reason = CompactionReason.CLOSE;
break;
case SYSTEM:
default:
reason = CompactionReason.SYSTEM;
break;
}
} else {
switch(compactor.getMajorCompactionReason()) {
case USER:
reason = CompactionReason.USER;
break;
case CHOP:
reason = CompactionReason.CHOP;
break;
case IDLE:
reason = CompactionReason.IDLE;
break;
case NORMAL:
default:
reason = CompactionReason.SYSTEM;
break;
}
}
List<IterInfo> iiList = new ArrayList<>();
Map<String, Map<String, String>> iterOptions = new HashMap<>();
for (IteratorSetting iterSetting : compactor.getIterators()) {
iiList.add(new IterInfo(iterSetting.getPriority(), iterSetting.getIteratorClass(), iterSetting.getName()));
iterOptions.put(iterSetting.getName(), iterSetting.getOptions());
}
List<String> filesToCompact = new ArrayList<>();
for (FileRef ref : compactor.getFilesToCompact()) filesToCompact.add(ref.toString());
return new ActiveCompaction(compactor.extent.toThrift(), System.currentTimeMillis() - compactor.getStartTime(), filesToCompact, compactor.getOutputFile(), type, reason, localityGroup, entriesRead, entriesWritten, iiList, iterOptions);
}
Aggregations