Search in sources :

Example 11 with IterInfo

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

the class IteratorUtilTest 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<>();
    List<IterInfo> iterators = new ArrayList<>();
    Map<String, Map<String, String>> options = new HashMap<>();
    AccumuloConfiguration conf;
    // create iterator with 'dot' in name
    try {
        data.put(Property.TABLE_ITERATOR_SCAN_PREFIX + "foo.bar", "50," + SummingCombiner.class.getName());
        conf = new ConfigurationCopy(data);
        IteratorUtil.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);
        IteratorUtil.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);
        IteratorUtil.parseIterConf(IteratorScope.scan, iterators, options, conf);
        Assert.assertEquals(1, iterators.size());
        IterInfo ii = iterators.get(0);
        Assert.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);
        IteratorUtil.parseIterConf(IteratorScope.scan, iterators, options, conf);
        Assert.assertEquals(1, iterators.size());
        IterInfo ii = iterators.get(0);
        Assert.assertEquals(new IterInfo(47, SummingCombiner.class.getName(), "foobaz"), ii);
    } catch (IllegalArgumentException ex) {
        log.debug("caught expected exception: " + ex.getMessage());
    }
}
Also used : ConfigurationCopy(org.apache.accumulo.core.conf.ConfigurationCopy) 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) AccumuloConfiguration(org.apache.accumulo.core.conf.AccumuloConfiguration) Test(org.junit.Test) MultiIteratorTest(org.apache.accumulo.core.iterators.system.MultiIteratorTest)

Example 12 with IterInfo

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

the class VerifyTabletAssignments method checkTabletServer.

private static void checkTabletServer(ClientContext context, Entry<HostAndPort, List<KeyExtent>> entry, HashSet<KeyExtent> failures) throws ThriftSecurityException, TException, NoSuchScanIDException {
    TabletClientService.Iface client = ThriftUtil.getTServerClient(entry.getKey(), context);
    Map<TKeyExtent, List<TRange>> batch = new TreeMap<>();
    for (KeyExtent keyExtent : entry.getValue()) {
        Text row = keyExtent.getEndRow();
        Text row2 = null;
        if (row == null) {
            row = keyExtent.getPrevEndRow();
            if (row != null) {
                row = new Text(row);
                row.append(new byte[] { 'a' }, 0, 1);
            } else {
                row = new Text("1234567890");
            }
            row2 = new Text(row);
            row2.append(new byte[] { '!' }, 0, 1);
        } else {
            row = new Text(row);
            row2 = new Text(row);
            row.getBytes()[row.getLength() - 1] = (byte) (row.getBytes()[row.getLength() - 1] - 1);
        }
        Range r = new Range(row, true, row2, false);
        batch.put(keyExtent.toThrift(), Collections.singletonList(r.toThrift()));
    }
    TInfo tinfo = Tracer.traceInfo();
    Map<String, Map<String, String>> emptyMapSMapSS = Collections.emptyMap();
    List<IterInfo> emptyListIterInfo = Collections.emptyList();
    List<TColumn> emptyListColumn = Collections.emptyList();
    InitialMultiScan is = client.startMultiScan(tinfo, context.rpcCreds(), batch, emptyListColumn, emptyListIterInfo, emptyMapSMapSS, Authorizations.EMPTY.getAuthorizationsBB(), false, null, 0L, null);
    if (is.result.more) {
        MultiScanResult result = client.continueMultiScan(tinfo, is.scanID);
        checkFailures(entry.getKey(), failures, result);
        while (result.more) {
            result = client.continueMultiScan(tinfo, is.scanID);
            checkFailures(entry.getKey(), failures, result);
        }
    }
    client.closeMultiScan(tinfo, is.scanID);
    ThriftUtil.returnClient((TServiceClient) client);
}
Also used : TInfo(org.apache.accumulo.core.trace.thrift.TInfo) TColumn(org.apache.accumulo.core.data.thrift.TColumn) InitialMultiScan(org.apache.accumulo.core.data.thrift.InitialMultiScan) Text(org.apache.hadoop.io.Text) TKeyExtent(org.apache.accumulo.core.data.thrift.TKeyExtent) TreeMap(java.util.TreeMap) TRange(org.apache.accumulo.core.data.thrift.TRange) Range(org.apache.accumulo.core.data.Range) TKeyExtent(org.apache.accumulo.core.data.thrift.TKeyExtent) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) IterInfo(org.apache.accumulo.core.data.thrift.IterInfo) MultiScanResult(org.apache.accumulo.core.data.thrift.MultiScanResult) ArrayList(java.util.ArrayList) List(java.util.List) TabletClientService(org.apache.accumulo.core.tabletserver.thrift.TabletClientService) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 13 with IterInfo

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

the class MetadataLocationObtainer method lookupTablet.

@Override
public TabletLocations lookupTablet(ClientContext context, TabletLocation src, Text row, Text stopRow, TabletLocator parent) throws AccumuloSecurityException, AccumuloException {
    try {
        OpTimer timer = null;
        if (log.isTraceEnabled()) {
            log.trace("tid={} Looking up in {} row={} extent={} tserver={}", Thread.currentThread().getId(), src.tablet_extent.getTableId(), TextUtil.truncate(row), src.tablet_extent, src.tablet_location);
            timer = new OpTimer().start();
        }
        Range range = new Range(row, true, stopRow, true);
        TreeMap<Key, Value> encodedResults = new TreeMap<>();
        TreeMap<Key, Value> results = new TreeMap<>();
        // Use the whole row iterator so that a partial mutations is not read. The code that extracts locations for tablets does a sanity check to ensure there is
        // only one location. Reading a partial mutation could make it appear there are multiple locations when there are not.
        List<IterInfo> serverSideIteratorList = new ArrayList<>();
        serverSideIteratorList.add(new IterInfo(10000, WholeRowIterator.class.getName(), "WRI"));
        Map<String, Map<String, String>> serverSideIteratorOptions = Collections.emptyMap();
        boolean more = ThriftScanner.getBatchFromServer(context, range, src.tablet_extent, src.tablet_location, encodedResults, locCols, serverSideIteratorList, serverSideIteratorOptions, Constants.SCAN_BATCH_SIZE, Authorizations.EMPTY, false, 0L, null);
        decodeRows(encodedResults, results);
        if (more && results.size() == 1) {
            range = new Range(results.lastKey().followingKey(PartialKey.ROW_COLFAM_COLQUAL_COLVIS_TIME), true, new Key(stopRow).followingKey(PartialKey.ROW), false);
            encodedResults.clear();
            more = ThriftScanner.getBatchFromServer(context, range, src.tablet_extent, src.tablet_location, encodedResults, locCols, serverSideIteratorList, serverSideIteratorOptions, Constants.SCAN_BATCH_SIZE, Authorizations.EMPTY, false, 0L, null);
            decodeRows(encodedResults, results);
        }
        if (timer != null) {
            timer.stop();
            log.trace("tid={} Got {} results from {} in {}", Thread.currentThread().getId(), results.size(), src.tablet_extent, String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)));
        }
        return MetadataLocationObtainer.getMetadataLocationEntries(results);
    } catch (AccumuloServerException ase) {
        if (log.isTraceEnabled())
            log.trace("{} lookup failed, {} server side exception", src.tablet_extent.getTableId(), src.tablet_location);
        throw ase;
    } catch (NotServingTabletException e) {
        if (log.isTraceEnabled())
            log.trace("{} lookup failed, {} not serving {}", src.tablet_extent.getTableId(), src.tablet_location, src.tablet_extent);
        parent.invalidateCache(src.tablet_extent);
    } catch (AccumuloException e) {
        if (log.isTraceEnabled())
            log.trace("{} lookup failed", src.tablet_extent.getTableId(), e);
        parent.invalidateCache(context.getInstance(), src.tablet_location);
    }
    return null;
}
Also used : AccumuloException(org.apache.accumulo.core.client.AccumuloException) NotServingTabletException(org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException) ArrayList(java.util.ArrayList) Range(org.apache.accumulo.core.data.Range) TreeMap(java.util.TreeMap) IterInfo(org.apache.accumulo.core.data.thrift.IterInfo) AccumuloServerException(org.apache.accumulo.core.client.impl.AccumuloServerException) OpTimer(org.apache.accumulo.core.util.OpTimer) Value(org.apache.accumulo.core.data.Value) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) Key(org.apache.accumulo.core.data.Key) PartialKey(org.apache.accumulo.core.data.PartialKey)

Example 14 with IterInfo

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

Example 15 with IterInfo

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

the class CompressedIterators method decompress.

public IterConfig decompress(ByteBuffer iterators) {
    IterConfig config = new IterConfig();
    UnsynchronizedBuffer.Reader in = new UnsynchronizedBuffer.Reader(iterators);
    int num = in.readVInt();
    for (int i = 0; i < num; i++) {
        String name = symbolTable.get(in.readVInt());
        String iterClass = symbolTable.get(in.readVInt());
        int prio = in.readVInt();
        config.ssiList.add(new IterInfo(prio, iterClass, name));
        int numOpts = in.readVInt();
        HashMap<String, String> opts = new HashMap<>();
        for (int j = 0; j < numOpts; j++) {
            String key = symbolTable.get(in.readVInt());
            String val = symbolTable.get(in.readVInt());
            opts.put(key, val);
        }
        config.ssio.put(name, opts);
    }
    return config;
}
Also used : UnsynchronizedBuffer(org.apache.accumulo.core.util.UnsynchronizedBuffer) HashMap(java.util.HashMap) IterInfo(org.apache.accumulo.core.data.thrift.IterInfo)

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