Search in sources :

Example 1 with IterInfo

use of org.apache.accumulo.core.data.thrift.IterInfo in project accumulo by apache.

the class IteratorUtil method loadIterators.

public static <K extends WritableComparable<?>, V extends Writable> SortedKeyValueIterator<K, V> loadIterators(IteratorScope scope, SortedKeyValueIterator<K, V> source, KeyExtent extent, AccumuloConfiguration conf, List<IteratorSetting> iterators, IteratorEnvironment env) throws IOException {
    List<IterInfo> ssiList = new ArrayList<>();
    Map<String, Map<String, String>> ssio = new HashMap<>();
    for (IteratorSetting is : iterators) {
        ssiList.add(new IterInfo(is.getPriority(), is.getIteratorClass(), is.getName()));
        ssio.put(is.getName(), is.getOptions());
    }
    return loadIterators(scope, source, extent, conf, ssiList, ssio, env, true);
}
Also used : TIteratorSetting(org.apache.accumulo.core.tabletserver.thrift.TIteratorSetting) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IterInfo(org.apache.accumulo.core.data.thrift.IterInfo) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 2 with IterInfo

use of org.apache.accumulo.core.data.thrift.IterInfo in project accumulo by apache.

the class IteratorUtil method parseIterConf.

public static void parseIterConf(IteratorScope scope, List<IterInfo> iters, Map<String, Map<String, String>> allOptions, AccumuloConfiguration conf) {
    final Property scopeProperty = getProperty(scope);
    final String scopePropertyKey = scopeProperty.getKey();
    for (Entry<String, String> entry : conf.getAllPropertiesWithPrefix(scopeProperty).entrySet()) {
        String suffix = entry.getKey().substring(scopePropertyKey.length());
        String[] suffixSplit = suffix.split("\\.", 3);
        if (suffixSplit.length == 1) {
            String[] sa = entry.getValue().split(",");
            int prio = Integer.parseInt(sa[0]);
            String className = sa[1];
            iters.add(new IterInfo(prio, className, suffixSplit[0]));
        } else if (suffixSplit.length == 3 && suffixSplit[1].equals("opt")) {
            String iterName = suffixSplit[0];
            String optName = suffixSplit[2];
            Map<String, String> options = allOptions.get(iterName);
            if (options == null) {
                options = new HashMap<>();
                allOptions.put(iterName, options);
            }
            options.put(optName, entry.getValue());
        } else {
            throw new IllegalArgumentException("Invalid iterator format: " + entry.getKey());
        }
    }
    Collections.sort(iters, new IterInfoComparator());
}
Also used : HashMap(java.util.HashMap) Property(org.apache.accumulo.core.conf.Property) IterInfo(org.apache.accumulo.core.data.thrift.IterInfo) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) DefaultKeySizeConstraint(org.apache.accumulo.core.constraints.DefaultKeySizeConstraint)

Example 3 with IterInfo

use of org.apache.accumulo.core.data.thrift.IterInfo in project accumulo by apache.

the class IteratorUtil method loadIterators.

public static <K extends WritableComparable<?>, V extends Writable> SortedKeyValueIterator<K, V> loadIterators(SortedKeyValueIterator<K, V> source, Collection<IterInfo> iters, Map<String, Map<String, String>> iterOpts, IteratorEnvironment env, boolean useAccumuloClassLoader, String context, Map<String, Class<? extends SortedKeyValueIterator<K, V>>> classCache) throws IOException {
    // wrap the source in a SynchronizedIterator in case any of the additional configured iterators want to use threading
    SortedKeyValueIterator<K, V> prev = source;
    try {
        for (IterInfo iterInfo : iters) {
            Class<? extends SortedKeyValueIterator<K, V>> clazz = null;
            log.trace("Attempting to load iterator class {}", iterInfo.className);
            if (classCache != null) {
                clazz = classCache.get(iterInfo.className);
                if (clazz == null) {
                    clazz = loadClass(useAccumuloClassLoader, context, iterInfo);
                    classCache.put(iterInfo.className, clazz);
                }
            } else {
                clazz = loadClass(useAccumuloClassLoader, context, iterInfo);
            }
            SortedKeyValueIterator<K, V> skvi = clazz.newInstance();
            Map<String, String> options = iterOpts.get(iterInfo.iterName);
            if (options == null)
                options = Collections.emptyMap();
            skvi.init(prev, options, env);
            prev = skvi;
        }
    } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
        log.error(e.toString());
        throw new RuntimeException(e);
    }
    return prev;
}
Also used : IterInfo(org.apache.accumulo.core.data.thrift.IterInfo)

Example 4 with IterInfo

use of org.apache.accumulo.core.data.thrift.IterInfo in project accumulo by apache.

the class CollectTabletStats method readFilesUsingIterStack.

private static int readFilesUsingIterStack(VolumeManager fs, ServerConfigurationFactory aconf, List<FileRef> files, Authorizations auths, KeyExtent ke, String[] columns, boolean useTableIterators) throws Exception {
    SortedKeyValueIterator<Key, Value> reader;
    List<SortedKeyValueIterator<Key, Value>> readers = new ArrayList<>(files.size());
    for (FileRef file : files) {
        FileSystem ns = fs.getVolumeByPath(file.path()).getFileSystem();
        readers.add(FileOperations.getInstance().newReaderBuilder().forFile(file.path().toString(), ns, ns.getConf()).withTableConfiguration(aconf.getSystemConfiguration()).build());
    }
    List<IterInfo> emptyIterinfo = Collections.emptyList();
    Map<String, Map<String, String>> emptySsio = Collections.emptyMap();
    TableConfiguration tconf = aconf.getTableConfiguration(ke.getTableId());
    reader = createScanIterator(ke, readers, auths, new byte[] {}, new HashSet<>(), emptyIterinfo, emptySsio, useTableIterators, tconf);
    HashSet<ByteSequence> columnSet = createColumnBSS(columns);
    reader.seek(new Range(ke.getPrevEndRow(), false, ke.getEndRow(), true), columnSet, columnSet.size() == 0 ? false : true);
    int count = 0;
    while (reader.hasTop()) {
        count++;
        reader.next();
    }
    return count;
}
Also used : ArrayList(java.util.ArrayList) SortedKeyValueIterator(org.apache.accumulo.core.iterators.SortedKeyValueIterator) Range(org.apache.accumulo.core.data.Range) IterInfo(org.apache.accumulo.core.data.thrift.IterInfo) FileRef(org.apache.accumulo.server.fs.FileRef) FileSystem(org.apache.hadoop.fs.FileSystem) Value(org.apache.accumulo.core.data.Value) Map(java.util.Map) SortedMap(java.util.SortedMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Key(org.apache.accumulo.core.data.Key) TableConfiguration(org.apache.accumulo.server.conf.TableConfiguration) ByteSequence(org.apache.accumulo.core.data.ByteSequence) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) HashSet(java.util.HashSet)

Example 5 with IterInfo

use of org.apache.accumulo.core.data.thrift.IterInfo 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

IterInfo (org.apache.accumulo.core.data.thrift.IterInfo)16 ArrayList (java.util.ArrayList)11 HashMap (java.util.HashMap)11 Map (java.util.Map)10 TreeMap (java.util.TreeMap)8 Key (org.apache.accumulo.core.data.Key)4 Value (org.apache.accumulo.core.data.Value)4 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)3 ArrayByteSequence (org.apache.accumulo.core.data.ArrayByteSequence)3 Range (org.apache.accumulo.core.data.Range)3 FileRef (org.apache.accumulo.server.fs.FileRef)3 SortedMap (java.util.SortedMap)2 AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)2 ConfigurationCopy (org.apache.accumulo.core.conf.ConfigurationCopy)2 ByteSequence (org.apache.accumulo.core.data.ByteSequence)2 SortedKeyValueIterator (org.apache.accumulo.core.iterators.SortedKeyValueIterator)2 MultiIteratorTest (org.apache.accumulo.core.iterators.system.MultiIteratorTest)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1