Search in sources :

Example 11 with IterInfo

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

the class ClientSideIteratorScanner method iterator.

@Override
public Iterator<Entry<Key, Value>> iterator() {
    smi.scanner.setBatchSize(size);
    smi.scanner.setTimeout(timeOut, MILLISECONDS);
    smi.scanner.setBatchTimeout(batchTimeOut, MILLISECONDS);
    smi.scanner.setReadaheadThreshold(readaheadThreshold);
    if (isolated)
        smi.scanner.enableIsolation();
    else
        smi.scanner.disableIsolation();
    smi.samplerConfig = getSamplerConfiguration();
    final TreeMap<Integer, IterInfo> tm = new TreeMap<>();
    for (IterInfo iterInfo : serverSideIteratorList) {
        tm.put(iterInfo.getPriority(), iterInfo);
    }
    SortedKeyValueIterator<Key, Value> skvi;
    try {
        IteratorEnvironment env = new ClientSideIteratorEnvironment(getSamplerConfiguration() != null, getIteratorSamplerConfigurationInternal());
        IterLoad iterLoad = new IterLoad().iters(tm.values()).iterOpts(serverSideIteratorOptions).iterEnv(env).useAccumuloClassLoader(false);
        skvi = IterConfigUtil.loadIterators(smi, iterLoad);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    final Set<ByteSequence> colfs = new TreeSet<>();
    for (Column c : this.getFetchedColumns()) {
        colfs.add(new ArrayByteSequence(c.getColumnFamily()));
    }
    try {
        skvi.seek(range, colfs, true);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return new IteratorAdapter(skvi);
}
Also used : IteratorAdapter(org.apache.accumulo.core.iterators.IteratorAdapter) IteratorEnvironment(org.apache.accumulo.core.iterators.IteratorEnvironment) IOException(java.io.IOException) TreeMap(java.util.TreeMap) IterInfo(org.apache.accumulo.core.dataImpl.thrift.IterInfo) IterLoad(org.apache.accumulo.core.conf.IterLoad) Column(org.apache.accumulo.core.data.Column) TreeSet(java.util.TreeSet) Value(org.apache.accumulo.core.data.Value) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) Key(org.apache.accumulo.core.data.Key) ByteSequence(org.apache.accumulo.core.data.ByteSequence) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence)

Example 12 with IterInfo

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

Example 13 with IterInfo

use of org.apache.accumulo.core.dataImpl.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.endRow();
        Text row2 = null;
        if (row == null) {
            row = keyExtent.prevEndRow();
            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 = TraceUtil.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, 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, context);
}
Also used : TInfo(org.apache.accumulo.core.trace.thrift.TInfo) TColumn(org.apache.accumulo.core.dataImpl.thrift.TColumn) InitialMultiScan(org.apache.accumulo.core.dataImpl.thrift.InitialMultiScan) Text(org.apache.hadoop.io.Text) TKeyExtent(org.apache.accumulo.core.dataImpl.thrift.TKeyExtent) TreeMap(java.util.TreeMap) Range(org.apache.accumulo.core.data.Range) TRange(org.apache.accumulo.core.dataImpl.thrift.TRange) TKeyExtent(org.apache.accumulo.core.dataImpl.thrift.TKeyExtent) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) IterInfo(org.apache.accumulo.core.dataImpl.thrift.IterInfo) MultiScanResult(org.apache.accumulo.core.dataImpl.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 14 with IterInfo

use of org.apache.accumulo.core.dataImpl.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.tableId(), 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, 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, 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(SECONDS)));
        }
        return MetadataLocationObtainer.getMetadataLocationEntries(results);
    } catch (AccumuloServerException ase) {
        if (log.isTraceEnabled())
            log.trace("{} lookup failed, {} server side exception", src.tablet_extent.tableId(), src.tablet_location);
        throw ase;
    } catch (AccumuloException e) {
        if (log.isTraceEnabled())
            log.trace("{} lookup failed", src.tablet_extent.tableId(), e);
        parent.invalidateCache(context, src.tablet_location);
    }
    return null;
}
Also used : AccumuloException(org.apache.accumulo.core.client.AccumuloException) ArrayList(java.util.ArrayList) Range(org.apache.accumulo.core.data.Range) TreeMap(java.util.TreeMap) IterInfo(org.apache.accumulo.core.dataImpl.thrift.IterInfo) AccumuloServerException(org.apache.accumulo.core.clientImpl.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 15 with IterInfo

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

the class CompactionInfo method toThrift.

public ActiveCompaction toThrift() {
    TCompactionType type;
    if (compactor.hasIMM())
        if (!compactor.getFilesToCompact().isEmpty())
            type = TCompactionType.MERGE;
        else
            type = TCompactionType.MINOR;
    else if (!compactor.willPropagateDeletes())
        type = TCompactionType.FULL;
    else
        type = TCompactionType.MAJOR;
    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> files = compactor.getFilesToCompact().stream().map(StoredTabletFile::getPathStr).collect(Collectors.toList());
    return new ActiveCompaction(compactor.extent.toThrift(), System.currentTimeMillis() - compactor.getStartTime(), files, compactor.getOutputFile(), type, reason, localityGroup, entriesRead, entriesWritten, iiList, iterOptions);
}
Also used : ActiveCompaction(org.apache.accumulo.core.tabletserver.thrift.ActiveCompaction) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IterInfo(org.apache.accumulo.core.dataImpl.thrift.IterInfo) Map(java.util.Map) HashMap(java.util.HashMap) TCompactionType(org.apache.accumulo.core.tabletserver.thrift.TCompactionType)

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