Package org.hbase.async

Examples of org.hbase.async.Scanner$GetNextRowsRequest


      long ping_start_time = start_time;
      LOG.info("Starting to fsck data covered by " + query);
      long kvcount = 0;
      long rowcount = 0;
      final Bytes.ByteMap<Seen> seen = new Bytes.ByteMap<Seen>();
      final Scanner scanner = Internal.getScanner(query);
      ArrayList<ArrayList<KeyValue>> rows;
     
      // store every data point for the row in here
      final TreeMap<Long, ArrayList<DP>> previous =
        new TreeMap<Long, ArrayList<DP>>();
      while ((rows = scanner.nextRows().joinUninterruptibly()) != null) {
        for (final ArrayList<KeyValue> row : rows) {
          rowcount++;
          previous.clear();
         
          // Take a copy of the row-key because we're going to zero-out the
View Full Code Here


  /**
   * Performs a tree synchronization using a table scanner across the UID table
   * @return 0 if completed successfully, something else if an error occurred
   */
  public void run() {
    final Scanner scanner = getScanner();

    // start the process by loading all of the trees in the system
    final List<Tree> trees;
    try {
      trees = Tree.fetchAllTrees(tsdb).joinUninterruptibly();
      LOG.info("[" + thread_id + "] Complete");
    } catch (Exception e) {
      LOG.error("[" + thread_id + "] Unexpected Exception", e);
      throw new RuntimeException("[" + thread_id + "] Unexpected exception", e);
    }
   
    if (trees == null) {
      LOG.warn("No tree definitions were found");
      return;
    } else {
      boolean has_enabled_tree = false;
      for (Tree tree : trees) {
        if (tree.getEnabled()) {
          has_enabled_tree = true;
          break;
        }
      }
      if (!has_enabled_tree) {
        LOG.warn("No enabled trees were found");
        return;
      }
      LOG.info("Found [" + trees.size() + "] trees");
    }
   
    // setup an array for storing the tree processing calls so we can block
    // until each call has completed
    final ArrayList<Deferred<Boolean>> tree_calls =
      new ArrayList<Deferred<Boolean>>();
   
    final Deferred<Boolean> completed = new Deferred<Boolean>();

    /**
     * Scanner callback that loops through the UID table recursively until
     * the scanner returns a null row set.
     */
    final class TsuidScanner implements Callback<Deferred<Boolean>,
      ArrayList<ArrayList<KeyValue>>> {

      /**
       * Fetches the next set of rows from the scanner, adding this class as a
       * callback
       * @return A meaningless deferred used to wait on until processing has
       * completed
       */
      public Deferred<Boolean> scan() {
        return scanner.nextRows().addCallbackDeferring(this);
      }
     
      @Override
      public Deferred<Boolean> call(ArrayList<ArrayList<KeyValue>> rows)
          throws Exception {
View Full Code Here

    final byte[] end_row =
      Arrays.copyOfRange(Bytes.fromLong(end_id), 8 - metric_width, 8);

    LOG.debug("[" + thread_id + "] Start row: " + UniqueId.uidToString(start_row));
    LOG.debug("[" + thread_id + "] End row: " + UniqueId.uidToString(end_row));
    final Scanner scanner = tsdb.getClient().newScanner(tsdb.metaTable());
    scanner.setStartKey(start_row);
    scanner.setStopKey(end_row);
    scanner.setFamily("name".getBytes(CHARSET));
    scanner.setQualifier("ts_meta".getBytes(CHARSET));
    return scanner;
  }
View Full Code Here

    final byte[] end_row =
      Arrays.copyOfRange(Bytes.fromLong(end_id), 8 - metric_width, 8);

    LOG.debug("[" + thread_id + "] Start row: " + UniqueId.uidToString(start_row));
    LOG.debug("[" + thread_id + "] End row: " + UniqueId.uidToString(end_row));
    final Scanner scanner = tsdb.getClient().newScanner(tsdb.dataTable());
    scanner.setStartKey(start_row);
    scanner.setStopKey(end_row);
    scanner.setFamily("t".getBytes(Charset.forName("ISO-8859-1")));
    return scanner;
  }
View Full Code Here

    // scan all of the rows starting with the tree ID. We can't just delete the
    // rows as there may be other types of data. Thus we have to check the
    // qualifiers of every column to see if it's safe to delete
    final byte[] start = idToBytes(tree_id);
    final byte[] end = idToBytes(tree_id + 1);
    final Scanner scanner = tsdb.getClient().newScanner(tsdb.treeTable());
    scanner.setStartKey(start);
    scanner.setStopKey(end);  
    scanner.setFamily(TREE_FAMILY);
   
    final Deferred<Boolean> completed = new Deferred<Boolean>();
   
    /**
     * Scanner callback that loops through all rows between tree id and
     * tree id++ searching for tree related columns to delete.
     */
    final class DeleteTreeScanner implements Callback<Deferred<Boolean>,
      ArrayList<ArrayList<KeyValue>>> {
 
      // list where we'll store delete requests for waiting on
      private final ArrayList<Deferred<Object>> delete_deferreds =
        new ArrayList<Deferred<Object>>();
     
      /**
       * Fetches the next set of rows from the scanner and adds this class as
       * a callback
       * @return The list of delete requests when the scanner returns a null set
       */
      public Deferred<Boolean> deleteTree() {
        return scanner.nextRows().addCallbackDeferring(this);
      }
     
      @Override
      public Deferred<Boolean> call(ArrayList<ArrayList<KeyValue>> rows)
          throws Exception {
View Full Code Here

  private static Scanner setupAllTreeScanner(final TSDB tsdb) {
    final byte[] start = new byte[TREE_ID_WIDTH];
    final byte[] end = new byte[TREE_ID_WIDTH];
    Arrays.fill(end, (byte)0xFF);
   
    final Scanner scanner = tsdb.getClient().newScanner(tsdb.treeTable());
    scanner.setStartKey(start);
    scanner.setStopKey(end);  
    scanner.setFamily(TREE_FAMILY);
   
    // set the filter to match only on TREE_ID_WIDTH row keys
    final StringBuilder buf = new StringBuilder(20);
    buf.append("(?s)"  // Ensure we use the DOTALL flag.
        + "^\\Q");
    buf.append("\\E(?:.{").append(TREE_ID_WIDTH).append("})$");
    scanner.setKeyRegexp(buf.toString(), CHARSET);
    return scanner;
  }
View Full Code Here

    final ArrayList<Query> queries = new ArrayList<Query>();
    CliQuery.parseCommandLineQuery(args, tsdb, queries, null, null);

    final StringBuilder buf = new StringBuilder();
    for (final Query query : queries) {
      final Scanner scanner = Internal.getScanner(query);
      ArrayList<ArrayList<KeyValue>> rows;
      while ((rows = scanner.nextRows().joinUninterruptibly()) != null) {
        for (final ArrayList<KeyValue> row : rows) {
          buf.setLength(0);
          final byte[] key = row.get(0).key();
          final long base_time = Internal.baseTime(tsdb, key);
          final String metric = Internal.metricName(tsdb, key);
View Full Code Here

  @PrepareForTest({HBaseClient.class, Scanner.class})
  @Test
  public void suggestWithNoMatch() {
    uid = new UniqueId(client, table, kind, 3);

    final Scanner fake_scanner = mock(Scanner.class);
    when(client.newScanner(table))
      .thenReturn(fake_scanner);

    when(fake_scanner.nextRows())
      .thenReturn(Deferred.<ArrayList<ArrayList<KeyValue>>>fromResult(null));
    // Watch this! ______,^   I'm writing C++ in Java!

    final List<String> suggestions = uid.suggest("nomatch");
    assertEquals(0, suggestions.size())// No results.
View Full Code Here

  @PrepareForTest({HBaseClient.class, Scanner.class})
  @Test
  public void suggestWithMatches() {
    uid = new UniqueId(client, table, kind, 3);

    final Scanner fake_scanner = mock(Scanner.class);
    when(client.newScanner(table))
      .thenReturn(fake_scanner);

    final ArrayList<ArrayList<KeyValue>> rows = new ArrayList<ArrayList<KeyValue>>(2);
    final byte[] foo_bar_id = { 0, 0, 1 };
    {
      ArrayList<KeyValue> row = new ArrayList<KeyValue>(1);
      row.add(new KeyValue("foo.bar".getBytes(), ID, kind_array, foo_bar_id));
      rows.add(row);
      row = new ArrayList<KeyValue>(1);
      row.add(new KeyValue("foo.baz".getBytes(), ID, kind_array,
                           new byte[] { 0, 0, 2 }));
      rows.add(row);
    }
    when(fake_scanner.nextRows())
      .thenReturn(Deferred.<ArrayList<ArrayList<KeyValue>>>fromResult(rows))
      .thenReturn(Deferred.<ArrayList<ArrayList<KeyValue>>>fromResult(null));
    // Watch this! ______,^   I'm writing C++ in Java!

    final List<String> suggestions = uid.suggest("foo");
View Full Code Here

    }
  }

  static List<Deferred<Boolean>> doList(HBaseClient client)
      throws Throwable {
    final Scanner scanner = client.newScanner(TABLE_NAME);
    scanner.setFamily(INFO_FAM);
    scanner.setQualifier(PASSWORD_COL);

    ArrayList<ArrayList<KeyValue>> rows = null;
    ArrayList<Deferred<Boolean>> workers
      = new ArrayList<Deferred<Boolean>>();
    while ((rows = scanner.nextRows(1).joinUninterruptibly()) != null) {
      LOG.info("received a page of users.");
      for (ArrayList<KeyValue> row : rows) {
        KeyValue kv = row.get(0);
        byte[] expected = kv.value();
        String userId = new String(kv.key());
View Full Code Here

TOP

Related Classes of org.hbase.async.Scanner$GetNextRowsRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.