Search in sources :

Example 1 with CompactionReason

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);
}
Also used : ActiveCompaction(org.apache.accumulo.core.tabletserver.thrift.ActiveCompaction) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CompactionReason(org.apache.accumulo.core.tabletserver.thrift.CompactionReason) IterInfo(org.apache.accumulo.core.data.thrift.IterInfo) CompactionType(org.apache.accumulo.core.tabletserver.thrift.CompactionType) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) FileRef(org.apache.accumulo.server.fs.FileRef) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)1 IterInfo (org.apache.accumulo.core.data.thrift.IterInfo)1 ActiveCompaction (org.apache.accumulo.core.tabletserver.thrift.ActiveCompaction)1 CompactionReason (org.apache.accumulo.core.tabletserver.thrift.CompactionReason)1 CompactionType (org.apache.accumulo.core.tabletserver.thrift.CompactionType)1 FileRef (org.apache.accumulo.server.fs.FileRef)1