Package org.apache.accumulo.core.client

Examples of org.apache.accumulo.core.client.Scanner


    bw.addMutation(m1);

    bw.flush();

    Scanner scanner = getConnector().createScanner("test", new Authorizations());

    int count = 0;
    for (Entry<Key,Value> entry : scanner) {
      count++;
      if (!entry.getValue().toString().equals("5")) {
        throw new Exception("Unexpected value " + entry.getValue());
      }
    }

    if (count != 1) {
      throw new Exception("Unexpected count " + count);
    }

    if (countThreads() < 2) {
      printThreadNames();
      throw new Exception("Not seeing expected threads");
    }

    CleanUp.shutdownNow();

    Mutation m2 = new Mutation("r2");
    m2.put("cf1", "cq1", 1, "6");

    try {
      bw.addMutation(m1);
      bw.flush();
      throw new Exception("batch writer did not fail");
    } catch (Exception e) {

    }

    try {
      // expect this to fail also, want to clean up batch writer threads
      bw.close();
      throw new Exception("batch writer close not fail");
    } catch (Exception e) {

    }

    try {
      count = 0;
      Iterator<Entry<Key,Value>> iter = scanner.iterator();
      while (iter.hasNext()) {
        iter.next();
        count++;
      }
      throw new Exception("scanner did not fail");
View Full Code Here


      return;
    }
   
    String user = state.getConnector().whoami();
    Authorizations auths = state.getConnector().securityOperations().getUserAuthorizations(user);
    Scanner scanner = state.getConnector().createScanner(Setup.getTableName(), auths);
    scanner.fetchColumnFamily(BulkPlusOne.CHECK_COLUMN_FAMILY);
    for (Entry<Key,Value> entry : scanner) {
      byte[] value = entry.getValue().get();
      if (!Arrays.equals(value, zero)) {
        throw new Exception("Bad key at " + entry);
      }
    }
   
    scanner.clearColumns();
    scanner.fetchColumnFamily(BulkPlusOne.MARKER_CF);
    RowIterator rowIter = new RowIterator(scanner);
   
    while (rowIter.hasNext()) {
      Iterator<Entry<Key,Value>> row = rowIter.next();
      long prev = 0;
View Full Code Here

  }
   
  public static void main(String args[]) throws Exception {
    ClientOnRequiredTable opts = new ClientOnRequiredTable();
    opts.parseArgs(Verify.class.getName(), args);
    Scanner scanner = opts.getConnector().createScanner(opts.tableName, opts.auths);
    scanner.fetchColumnFamily(BulkPlusOne.CHECK_COLUMN_FAMILY);
    Text startBadRow = null;
    Text lastBadRow = null;
    Value currentBadValue = null;
    for (Entry<Key,Value> entry : scanner) {
      // System.out.println("Entry: " + entry);
View Full Code Here

   
    Random r = new Random();
    Authorizations auths = opts.randomAuths.getAuths(r);

    Connector conn = opts.getConnector();
    Scanner scanner = ContinuousUtil.createScanner(conn, opts.getTableName(), auths);
    scanner.setBatchSize(scanOpts.scanBatchSize);
   
    BatchScanner bs = conn.createBatchScanner(opts.getTableName(), auths, bsOpts.scanThreads);
    bs.setTimeout(bsOpts.scanTimeout, TimeUnit.MILLISECONDS);

    while (true) {
View Full Code Here

  @Override
  public void visit(State state, Properties props) throws Exception {
    log.debug("checking balance");
    Map<String,Long> counts = new HashMap<String,Long>();
    Scanner scanner = state.getConnector().createScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS);
    scanner.fetchColumnFamily(Constants.METADATA_CURRENT_LOCATION_COLUMN_FAMILY);
    for (Entry<Key,Value> entry : scanner) {
      String location = entry.getKey().getColumnQualifier().toString();
      Long count = counts.get(location);
      if (count == null)
        count = Long.valueOf(0);
View Full Code Here

      bw.addMutation(m);
    }
   
    bw.close();
   
    Scanner scanner = getConnector().createScanner("foo", new Authorizations());
   
    setupIter(scanner);
    verify(scanner, 1, 999);
   
    BatchScanner bscanner = getConnector().createBatchScanner("foo", new Authorizations(), 3);
View Full Code Here

  public static void main(String[] args) throws Exception {
    ScanOpts opts = new ScanOpts();
    opts.parseArgs(Scan.class.getName(), args);
   
    Connector connector = opts.getConnector();
    Scanner scanner = connector.createScanner(opts.getTableName(), new Authorizations());
   
    if (opts.isolate) {
      scanner.enableIsolation();
    }
   
    Random tablet_index_generator = new Random(opts.scan_seed);
   
    LoopControl scanning_condition = opts.continuous ? new ContinuousLoopControl() :
                                                       new IterativeLoopControl(opts.scan_iterations);
   
    while(scanning_condition.keepScanning()) {
      Range range = pickRange(connector.tableOperations(), opts.getTableName(),
          tablet_index_generator);
      scanner.setRange(range);
      if (opts.batch_size > 0) {
        scanner.setBatchSize(opts.batch_size);
      }
      try {
        consume(scanner);
      } catch (Exception e) {
        System.err.println(
View Full Code Here

    long distance = 1000000000000l;
   
    Connector conn = opts.getConnector();
    Authorizations auths = opts.randomAuths.getAuths(r);
    Scanner scanner = ContinuousUtil.createScanner(conn, opts.getTableName(), auths);
    scanner.setBatchSize(scanOpts.scanBatchSize);
   
    double delta = Math.min(.05, .05 / (opts.numToScan / 1000.0));
   
    while (true) {
      long startRow = ContinuousIngest.genLong(opts.min, opts.max - distance, r);
      byte[] scanStart = ContinuousIngest.genRow(startRow);
      byte[] scanStop = ContinuousIngest.genRow(startRow + distance);
     
      scanner.setRange(new Range(new Text(scanStart), new Text(scanStop)));
     
      int count = 0;
      Iterator<Entry<Key,Value>> iter = scanner.iterator();
     
      long t1 = System.currentTimeMillis();
     
      while (iter.hasNext()) {
        Entry<Key,Value> entry = iter.next();
View Full Code Here

  }
 
  private void runLatencyTest() throws Exception {
    // should automatically flush after 3 seconds
    BatchWriter bw = getConnector().createBatchWriter("bwlt", new BatchWriterConfig().setMaxLatency(2000, TimeUnit.MILLISECONDS));
    Scanner scanner = getConnector().createScanner("bwlt", Constants.NO_AUTHS);
   
    Mutation m = new Mutation(new Text(String.format("r_%10d", 1)));
    m.put(new Text("cf"), new Text("cq"), new Value("1".getBytes(Constants.UTF8)));
    bw.addMutation(m);
   
View Full Code Here

    bw.close();
  }
 
  private void runFlushTest() throws AccumuloException, AccumuloSecurityException, TableNotFoundException, MutationsRejectedException, Exception {
    BatchWriter bw = getConnector().createBatchWriter("bwft", new BatchWriterConfig());
    Scanner scanner = getConnector().createScanner("bwft", Constants.NO_AUTHS);
    Random r = new Random();
   
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < NUM_TO_FLUSH; j++) {
        int row = i * NUM_TO_FLUSH + j;
       
        Mutation m = new Mutation(new Text(String.format("r_%10d", row)));
        m.put(new Text("cf"), new Text("cq"), new Value(("" + row).getBytes()));
        bw.addMutation(m);
      }
     
      bw.flush();
     
      // do a few random lookups into the data just flushed
     
      for (int k = 0; k < 10; k++) {
        int rowToLookup = r.nextInt(NUM_TO_FLUSH) + i * NUM_TO_FLUSH;
       
        scanner.setRange(new Range(new Text(String.format("r_%10d", rowToLookup))));
       
        Iterator<Entry<Key,Value>> iter = scanner.iterator();
       
        if (!iter.hasNext())
          throw new Exception(" row " + rowToLookup + " not found after flush");
       
        Entry<Key,Value> entry = iter.next();
       
        if (iter.hasNext())
          throw new Exception("Scanner returned too much");
       
        verifyEntry(rowToLookup, entry);
      }
     
      // scan all data just flushed
      scanner.setRange(new Range(new Text(String.format("r_%10d", i * NUM_TO_FLUSH)), true, new Text(String.format("r_%10d", (i + 1) * NUM_TO_FLUSH)), false));
      Iterator<Entry<Key,Value>> iter = scanner.iterator();
     
      for (int j = 0; j < NUM_TO_FLUSH; j++) {
        int row = i * NUM_TO_FLUSH + j;
       
        if (!iter.hasNext())
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.client.Scanner

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.