Examples of Scan


Examples of org.apache.hadoop.hbase.client.Scan

      new ObjectArrayList<KeyValue>(this.keys.size());

    StopWatch stopWatch = new StopWatch();
    stopWatch.start();

    InternalScanner scanner = region.getScanner(new Scan());
    boolean moreRows;
    int id = 0;
    do {
      List<KeyValue> nextRow = new ArrayList<KeyValue>();
      moreRows = scanner.next(nextRow);
View Full Code Here

Examples of org.apache.hadoop.hbase.client.Scan

    doFsCommand(shell, new String [] {"-lsr", "/"});
    TEST_UTIL.startMiniHBaseCluster(1, 1);

    for(String table: tables) {
      int count = 0;
      for(Result res: new HTable(TEST_UTIL.getConfiguration(), table).getScanner(new Scan())) {
        assertEquals(currentKeys[count++], Bytes.toString(res.getRow()));
      }
      Assert.assertEquals(currentKeys.length, count);
    }
    assertEquals(2, TEST_UTIL.getHBaseAdmin().listNamespaceDescriptors().length);

    //verify ACL table is migrated
    HTable secureTable = new HTable(conf, AccessControlLists.ACL_TABLE_NAME);
    ResultScanner scanner = secureTable.getScanner(new Scan());
    int count = 0;
    for(Result r : scanner) {
      count++;
    }
    assertEquals(3, count);
View Full Code Here

Examples of org.apache.hadoop.hbase.client.Scan

        TEST_UTIL.getHBaseAdmin().cloneSnapshot(table+"_snapshot"+i, table+"_clone"+i);
        FSUtils.logFileSystemState(FileSystem.get(TEST_UTIL.getConfiguration()),
            FSUtils.getRootDir(TEST_UTIL.getConfiguration()),
            LOG);
        int count = 0;
        for(Result res: new HTable(TEST_UTIL.getConfiguration(), table+"_clone"+i).getScanner(new
            Scan())) {
          assertEquals(snapshots[i-1][count++], Bytes.toString(res.getRow()));
        }
        Assert.assertEquals(table+"_snapshot"+i, snapshots[i-1].length, count);
      }
View Full Code Here

Examples of org.apache.hadoop.hbase.client.Scan

  public void testRenameUsingSnapshots() throws Exception {
    String newNS = "newNS";
    TEST_UTIL.getHBaseAdmin().createNamespace(NamespaceDescriptor.create(newNS).build());
    for(String table: tables) {
      int count = 0;
      for(Result res: new HTable(TEST_UTIL.getConfiguration(), table).getScanner(new
          Scan())) {
        assertEquals(currentKeys[count++], Bytes.toString(res.getRow()));
      }
      TEST_UTIL.getHBaseAdmin().snapshot(table + "_snapshot3", table);
      final String newTableName = newNS + TableName.NAMESPACE_DELIM + table + "_clone3";
      TEST_UTIL.getHBaseAdmin().cloneSnapshot(table + "_snapshot3", newTableName);
      Thread.sleep(1000);
      count = 0;
      for(Result res: new HTable(TEST_UTIL.getConfiguration(), newTableName).getScanner(new
          Scan())) {
        assertEquals(currentKeys[count++], Bytes.toString(res.getRow()));
      }
      FSUtils.logFileSystemState(TEST_UTIL.getTestFileSystem(), TEST_UTIL.getDefaultRootDirPath()
          , LOG);
      Assert.assertEquals(newTableName, currentKeys.length, count);
      TEST_UTIL.getHBaseAdmin().flush(newTableName);
      TEST_UTIL.getHBaseAdmin().majorCompact(newTableName);
      TEST_UTIL.waitFor(30000, new Waiter.Predicate<IOException>() {
        @Override
        public boolean evaluate() throws IOException {
          try {
            return TEST_UTIL.getHBaseAdmin().getCompactionState(newTableName) ==
                AdminProtos.GetRegionInfoResponse.CompactionState.NONE;
          } catch (InterruptedException e) {
            throw new IOException(e);
          }
        }
      });
    }

    String nextNS = "nextNS";
    TEST_UTIL.getHBaseAdmin().createNamespace(NamespaceDescriptor.create(nextNS).build());
    for(String table: tables) {
      String srcTable = newNS + TableName.NAMESPACE_DELIM + table + "_clone3";
      TEST_UTIL.getHBaseAdmin().snapshot(table + "_snapshot4", srcTable);
      String newTableName = nextNS + TableName.NAMESPACE_DELIM + table + "_clone4";
      TEST_UTIL.getHBaseAdmin().cloneSnapshot(table+"_snapshot4", newTableName);
      FSUtils.logFileSystemState(TEST_UTIL.getTestFileSystem(), TEST_UTIL.getDefaultRootDirPath(),
        LOG);
      int count = 0;
      for(Result res: new HTable(TEST_UTIL.getConfiguration(), newTableName).getScanner(new
          Scan())) {
        assertEquals(currentKeys[count++], Bytes.toString(res.getRow()));
      }
      Assert.assertEquals(newTableName, currentKeys.length, count);
    }
View Full Code Here

Examples of org.apache.hadoop.hbase.client.Scan

   *
   * @param firstRow  The first row to start at.
   * @throws IOException When restarting fails.
   */
  public void restart(byte[] firstRow) throws IOException {
    currentScan = new Scan(scan);
    currentScan.setStartRow(firstRow);
    currentScan.setAttribute(Scan.SCAN_ATTRIBUTES_METRICS_ENABLE,
      Bytes.toBytes(Boolean.TRUE));
    this.scanner = this.htable.getScanner(currentScan);
    if (logScannerActivity) {
View Full Code Here

Examples of org.apache.hadoop.hbase.client.Scan

    // load table descriptor
    HTableDescriptor htd = FSTableDescriptors.getTableDescriptorFromFs(fs,
        snapshotDir);

    Scan scan = TableMapReduceUtil.convertStringToScan(conf
      .get(TableInputFormat.SCAN));
    Path tableDir = new Path(conf.get(TABLE_DIR_KEY));

    List<InputSplit> splits = new ArrayList<InputSplit>();
    for (String regionName : snapshotRegionNames) {
      // load region descriptor
      Path regionDir = new Path(snapshotDir, regionName);
      HRegionInfo hri = HRegionFileSystem.loadRegionInfoFileContent(fs,
          regionDir);

      if (CellUtil.overlappingKeys(scan.getStartRow(), scan.getStopRow(),
          hri.getStartKey(), hri.getEndKey())) {
        // compute HDFS locations from snapshot files (which will get the locations for
        // referred hfiles)
        List<String> hosts = getBestLocations(conf,
          HRegion.computeHDFSBlocksDistribution(conf, htd, hri, tableDir));
View Full Code Here

Examples of org.apache.hadoop.hbase.client.Scan

    public void map(ImmutableBytesWritable row, final Result value,
                    Context context)
        throws IOException {
      if (replicatedScanner == null) {
        Configuration conf = context.getConfiguration();
        final Scan scan = new Scan();
        scan.setCaching(conf.getInt(TableInputFormat.SCAN_CACHEDROWS, 1));
        long startTime = conf.getLong(NAME + ".startTime", 0);
        long endTime = conf.getLong(NAME + ".endTime", Long.MAX_VALUE);
        String families = conf.get(NAME + ".families", null);
        if(families != null) {
          String[] fams = families.split(",");
          for(String fam : fams) {
            scan.addFamily(Bytes.toBytes(fam));
          }
        }
        scan.setTimeRange(startTime, endTime);
        HConnectionManager.execute(new HConnectable<Void>(conf) {
          @Override
          public Void connect(HConnection conn) throws IOException {
            String zkClusterKey = conf.get(NAME + ".peerQuorumAddress");
            Configuration peerConf = HBaseConfiguration.create(conf);
            ZKUtil.applyClusterKeyToConf(peerConf, zkClusterKey);

            HTable replicatedTable = new HTable(peerConf, conf.get(NAME + ".tableName"));
            scan.setStartRow(value.getRow());
            replicatedScanner = replicatedTable.getScanner(scan);
            return null;
          }
        });
      }
View Full Code Here

Examples of org.apache.hadoop.hbase.client.Scan

    TableRecordReader trr = this.tableRecordReader;
    // if no table record reader was provided use default
    if (trr == null) {
      trr = new TableRecordReader();
    }
    Scan sc = new Scan(this.scan);
    sc.setStartRow(tSplit.getStartRow());
    sc.setStopRow(tSplit.getEndRow());
    trr.setScan(sc);
    trr.setHTable(table);
    return trr;
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.client.Scan

   * Gets the scan defining the actual details like columns etc.
   *
   * @return The internal scan instance.
   */
  public Scan getScan() {
    if (this.scan == null) this.scan = new Scan();
    return scan;
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.client.Scan

    LOG.info("Peer Quorum Address: " + peerQuorumAddress);

    Job job = new Job(conf, NAME + "_" + tableName);
    job.setJarByClass(VerifyReplication.class);

    Scan scan = new Scan();
    scan.setTimeRange(startTime, endTime);
    if(families != null) {
      String[] fams = families.split(",");
      for(String fam : fams) {
        scan.addFamily(Bytes.toBytes(fam));
      }
    }
    TableMapReduceUtil.initTableMapperJob(tableName, scan,
        Verifier.class, null, null, job);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.