public void addMigration(KeyExtent tablet, Runnable migrationHandler) {
   if (tablet.isRootTablet()) {
     migrationHandler.run();
   } else if (tablet.isMeta()) {
     defaultMigrationPool.execute(migrationHandler);
   } else {
     migrationPool.execute(migrationHandler);
   }
 }
 public void executeMajorCompaction(KeyExtent tablet, Runnable compactionTask) {
   if (tablet.isRootTablet()) {
     rootMajorCompactionThreadPool.execute(compactionTask);
   } else if (tablet.isMeta()) {
     defaultMajorCompactionThreadPool.execute(compactionTask);
   } else {
     majorCompactionThreadPool.execute(compactionTask);
   }
 }
 public void executeReadAhead(KeyExtent tablet, Runnable task) {
   if (tablet.isRootTablet()) {
     task.run();
   } else if (tablet.isMeta()) {
     defaultReadAheadThreadPool.execute(task);
   } else {
     readAheadThreadPool.execute(task);
   }
 }
 public void executeSplit(KeyExtent tablet, Runnable splitTask) {
   if (tablet.isMeta()) {
     if (tablet.isRootTablet()) {
       log.warn("Saw request to split root tablet, ignoring");
       return;
     }
     defaultSplitThreadPool.execute(splitTask);
   } else {
     splitThreadPool.execute(splitTask);
   }
 }
Exemplo n.º 5
0
  public static boolean getBatchFromServer(
      ClientContext context,
      Range range,
      KeyExtent extent,
      String server,
      SortedMap<Key, Value> results,
      SortedSet<Column> fetchedColumns,
      List<IterInfo> serverSideIteratorList,
      Map<String, Map<String, String>> serverSideIteratorOptions,
      int size,
      Authorizations authorizations,
      boolean retry,
      long batchTimeOut,
      String classLoaderContext)
      throws AccumuloException, AccumuloSecurityException, NotServingTabletException {
    if (server == null) throw new AccumuloException(new IOException());

    final HostAndPort parsedServer = HostAndPort.fromString(server);
    try {
      TInfo tinfo = Tracer.traceInfo();
      TabletClientService.Client client = ThriftUtil.getTServerClient(parsedServer, context);
      try {
        // not reading whole rows (or stopping on row boundries) so there is no need to enable
        // isolation below
        ScanState scanState =
            new ScanState(
                context,
                extent.getTableId(),
                authorizations,
                range,
                fetchedColumns,
                size,
                serverSideIteratorList,
                serverSideIteratorOptions,
                false,
                Constants.SCANNER_DEFAULT_READAHEAD_THRESHOLD,
                null,
                batchTimeOut,
                classLoaderContext);

        TabletType ttype = TabletType.type(extent);
        boolean waitForWrites = !serversWaitedForWrites.get(ttype).contains(server);
        InitialScan isr =
            client.startScan(
                tinfo,
                scanState.context.rpcCreds(),
                extent.toThrift(),
                scanState.range.toThrift(),
                Translator.translate(scanState.columns, Translators.CT),
                scanState.size,
                scanState.serverSideIteratorList,
                scanState.serverSideIteratorOptions,
                scanState.authorizations.getAuthorizationsBB(),
                waitForWrites,
                scanState.isolated,
                scanState.readaheadThreshold,
                null,
                scanState.batchTimeOut,
                classLoaderContext);
        if (waitForWrites) serversWaitedForWrites.get(ttype).add(server);

        Key.decompress(isr.result.results);

        for (TKeyValue kv : isr.result.results) results.put(new Key(kv.key), new Value(kv.value));

        client.closeScan(tinfo, isr.scanID);

        return isr.result.more;
      } finally {
        ThriftUtil.returnClient(client);
      }
    } catch (TApplicationException tae) {
      throw new AccumuloServerException(server, tae);
    } catch (TooManyFilesException e) {
      log.debug("Tablet ({}) has too many files {} : {}", extent, server, e.getMessage());
    } catch (ThriftSecurityException e) {
      log.warn("Security Violation in scan request to {}: {}", server, e.getMessage());
      throw new AccumuloSecurityException(e.user, e.code, e);
    } catch (TException e) {
      log.debug("Error getting transport to {}: {}", server, e.getMessage());
    }

    throw new AccumuloException("getBatchFromServer: failed");
  }