Search in sources :

Example 1 with IterInfo

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

the class ActiveCompactionImpl method getIterators.

@Override
public List<IteratorSetting> getIterators() {
    ArrayList<IteratorSetting> ret = new ArrayList<>();
    for (IterInfo ii : tac.getSsiList()) {
        IteratorSetting settings = new IteratorSetting(ii.getPriority(), ii.getIterName(), ii.getClassName());
        Map<String, String> options = tac.getSsio().get(ii.getIterName());
        settings.addOptions(options);
        ret.add(settings);
    }
    return ret;
}
Also used : IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) ArrayList(java.util.ArrayList) IterInfo(org.apache.accumulo.core.dataImpl.thrift.IterInfo)

Example 2 with IterInfo

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

the class IterConfigUtilTest method testInvalidIteratorFormats.

/**
 * Iterators should not contain dots in the name. Also, if the split size on "." is greater than
 * one, it should be 3, i.e., itername.opt.optname
 */
@Test
public void testInvalidIteratorFormats() {
    Map<String, String> data = new HashMap<>();
    Map<String, Map<String, String>> options = new HashMap<>();
    AccumuloConfiguration conf;
    // create iterator with 'dot' in name
    List<IterInfo> iterators = new ArrayList<>();
    try {
        data.put(Property.TABLE_ITERATOR_SCAN_PREFIX + "foo.bar", "50," + SummingCombiner.class.getName());
        conf = new ConfigurationCopy(data);
        iterators = IterConfigUtil.parseIterConf(IteratorScope.scan, iterators, options, conf);
    } catch (IllegalArgumentException ex) {
        log.debug("caught expected exception: " + ex.getMessage());
    }
    data.clear();
    iterators.clear();
    options.clear();
    // second part must be 'opt'.
    try {
        data.put(Property.TABLE_ITERATOR_SCAN_PREFIX + "foo.bar.baz", "49," + SummingCombiner.class.getName());
        conf = new ConfigurationCopy(data);
        iterators = IterConfigUtil.parseIterConf(IteratorScope.scan, iterators, options, conf);
    } catch (IllegalArgumentException ex) {
        log.debug("caught expected exception: " + ex.getMessage());
    }
    data.clear();
    iterators.clear();
    options.clear();
    // create iterator with invalid option format
    try {
        data.put(Property.TABLE_ITERATOR_SCAN_PREFIX + "foobar", "48," + SummingCombiner.class.getName());
        data.put(Property.TABLE_ITERATOR_SCAN_PREFIX + "foobar.opt", "fakevalue");
        conf = new ConfigurationCopy(data);
        iterators = IterConfigUtil.parseIterConf(IteratorScope.scan, iterators, options, conf);
        assertEquals(1, iterators.size());
        IterInfo ii = iterators.get(0);
        assertEquals(new IterInfo(48, SummingCombiner.class.getName(), "foobar"), ii);
    } catch (IllegalArgumentException ex) {
        log.debug("caught expected exception: " + ex.getMessage());
    }
    data.clear();
    iterators.clear();
    options.clear();
    // create iterator with 'opt' in incorrect position
    try {
        data.put(Property.TABLE_ITERATOR_SCAN_PREFIX + "foobaz", "47," + SummingCombiner.class.getName());
        data.put(Property.TABLE_ITERATOR_SCAN_PREFIX + "foobaz.fake.opt", "fakevalue");
        conf = new ConfigurationCopy(data);
        iterators = IterConfigUtil.parseIterConf(IteratorScope.scan, iterators, options, conf);
        assertEquals(1, iterators.size());
        IterInfo ii = iterators.get(0);
        assertEquals(new IterInfo(47, SummingCombiner.class.getName(), "foobaz"), ii);
    } catch (IllegalArgumentException ex) {
        log.debug("caught expected exception: " + ex.getMessage());
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) IterInfo(org.apache.accumulo.core.dataImpl.thrift.IterInfo) MultiIteratorTest(org.apache.accumulo.core.iterators.system.MultiIteratorTest) Test(org.junit.jupiter.api.Test)

Example 3 with IterInfo

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

the class IterConfigUtilTest method onlyReadsRelevantIteratorScopeConfigurations.

@Test
public void onlyReadsRelevantIteratorScopeConfigurations() {
    Map<String, String> data = new HashMap<>();
    // Make some configuration items, one with a bogus scope
    data.put(Property.TABLE_ITERATOR_SCAN_PREFIX + "foo", "50," + SummingCombiner.class.getName());
    data.put(Property.TABLE_ITERATOR_SCAN_PREFIX + "foo.opt.all", "true");
    data.put(Property.TABLE_ITERATOR_PREFIX + ".fakescope.bar", "50," + SummingCombiner.class.getName());
    data.put(Property.TABLE_ITERATOR_SCAN_PREFIX + "foo.opt.fakeopt", "fakevalue");
    AccumuloConfiguration conf = new ConfigurationCopy(data);
    List<IterInfo> iterators = IterConfigUtil.parseIterConf(IteratorScope.scan, EMPTY_ITERS, new HashMap<>(), conf);
    assertEquals(1, iterators.size());
    IterInfo ii = iterators.get(0);
    assertEquals(new IterInfo(50, SummingCombiner.class.getName(), "foo"), ii);
}
Also used : HashMap(java.util.HashMap) IterInfo(org.apache.accumulo.core.dataImpl.thrift.IterInfo) MultiIteratorTest(org.apache.accumulo.core.iterators.system.MultiIteratorTest) Test(org.junit.jupiter.api.Test)

Example 4 with IterInfo

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

the class ScannerOptions method removeScanIterator.

@Override
public synchronized void removeScanIterator(String iteratorName) {
    checkArgument(iteratorName != null, "iteratorName is null");
    // if no iterators are set, we don't have it, so it is already removed
    if (serverSideIteratorList.isEmpty()) {
        return;
    }
    for (IterInfo ii : serverSideIteratorList) {
        if (ii.iterName.equals(iteratorName)) {
            serverSideIteratorList.remove(ii);
            break;
        }
    }
    serverSideIteratorOptions.remove(iteratorName);
}
Also used : IterInfo(org.apache.accumulo.core.dataImpl.thrift.IterInfo)

Example 5 with IterInfo

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

the class ScannerOptions method addScanIterator.

@Override
public synchronized void addScanIterator(IteratorSetting si) {
    checkArgument(si != null, "si is null");
    if (serverSideIteratorList.isEmpty()) {
        serverSideIteratorList = new ArrayList<>();
    }
    for (IterInfo ii : serverSideIteratorList) {
        if (ii.iterName.equals(si.getName())) {
            throw new IllegalArgumentException("Iterator name is already in use " + si.getName());
        }
        if (ii.getPriority() == si.getPriority()) {
            throw new IllegalArgumentException("Iterator priority is already in use " + si.getPriority());
        }
    }
    serverSideIteratorList.add(new IterInfo(si.getPriority(), si.getIteratorClass(), si.getName()));
    if (serverSideIteratorOptions.isEmpty()) {
        serverSideIteratorOptions = new HashMap<>();
    }
    serverSideIteratorOptions.computeIfAbsent(si.getName(), k -> new HashMap<>()).putAll(si.getOptions());
}
Also used : SortedSet(java.util.SortedSet) Text(org.apache.hadoop.io.Text) HashMap(java.util.HashMap) IterInfo(org.apache.accumulo.core.dataImpl.thrift.IterInfo) TextUtil(org.apache.accumulo.core.util.TextUtil) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Objects.requireNonNull(java.util.Objects.requireNonNull) Map(java.util.Map) Key(org.apache.accumulo.core.data.Key) Value(org.apache.accumulo.core.data.Value) SamplerConfiguration(org.apache.accumulo.core.client.sample.SamplerConfiguration) Iterator(java.util.Iterator) Column(org.apache.accumulo.core.data.Column) Set(java.util.Set) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Authorizations(org.apache.accumulo.core.security.Authorizations) ScannerBase(org.apache.accumulo.core.client.ScannerBase) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) List(java.util.List) Entry(java.util.Map.Entry) Collections(java.util.Collections) HashMap(java.util.HashMap) IterInfo(org.apache.accumulo.core.dataImpl.thrift.IterInfo)

Aggregations

IterInfo (org.apache.accumulo.core.dataImpl.thrift.IterInfo)17 ArrayList (java.util.ArrayList)12 HashMap (java.util.HashMap)11 Map (java.util.Map)10 Key (org.apache.accumulo.core.data.Key)7 TreeMap (java.util.TreeMap)6 Value (org.apache.accumulo.core.data.Value)6 Range (org.apache.accumulo.core.data.Range)4 List (java.util.List)3 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)3 ArrayByteSequence (org.apache.accumulo.core.data.ArrayByteSequence)3 Column (org.apache.accumulo.core.data.Column)3 TabletFile (org.apache.accumulo.core.metadata.TabletFile)3 IOException (java.io.IOException)2 Collections (java.util.Collections)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 Entry (java.util.Map.Entry)2 Set (java.util.Set)2 SortedMap (java.util.SortedMap)2