Package org.apache.accumulo.core.client

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


    BatchWriterOpts batch_writer_opts = new BatchWriterOpts();
    opts.parseArgs(Write.class.getName(), args, batch_writer_opts);
   
    opts.check();
   
    Connector c = opts.getConnector();
   
    if(opts.clear_table && c.tableOperations().exists(opts.getTableName())) {
      try {
      c.tableOperations().delete(opts.getTableName());
      } catch(TableNotFoundException e) {
        System.err.println("Couldn't delete the table because it doesn't exist any more.");
      }
    }
   
    if(!c.tableOperations().exists(opts.getTableName())) {
      try {
        c.tableOperations().create(opts.getTableName());
      } catch (TableExistsException e) {
        System.err.println("Couldn't create table ourselves, but that's ok. Continuing.");
      }
    }

    long writeDelay = opts.write_delay;
    if (writeDelay < 0) {
      writeDelay = 0;
    }

    DataWriter dw = new DataWriter(c.createBatchWriter(opts.getTableName(), batch_writer_opts.getBatchWriterConfig()),
        new RandomMutations(
            //rows
            new RandomByteArrays(
                new RandomWithinRange(
                    opts.row_seed,
View Full Code Here


    opts.parseArgs(ContinuousBatchWalker.class.getName(), args, scanOpts, bsOpts);
   
    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) {
      Set<Text> batch = getBatch(scanner, opts.min, opts.max, scanOpts.scanBatchSize, r);
      List<Range> ranges = new ArrayList<Range>(batch.size());
View Full Code Here

public class BatchWrite extends Test {
 
  @Override
  public void visit(State state, Properties props) throws Exception {
    Connector conn = state.getConnector();
   
    Random rand = (Random) state.get("rand");
   
    @SuppressWarnings("unchecked")
    List<String> tableNames = (List<String>) state.get("tables");
   
    String tableName = tableNames.get(rand.nextInt(tableNames.size()));
   
    try {
      BatchWriter bw = conn.createBatchWriter(tableName, new BatchWriterConfig());
      try {
        int numRows = rand.nextInt(100000);
        for (int i = 0; i < numRows; i++) {
          Mutation m = new Mutation(String.format("%016x", (rand.nextLong() & 0x7fffffffffffffffl)));
          long val = (rand.nextLong() & 0x7fffffffffffffffl);
View Full Code Here

 
  private void sort(State state, FileSystem fs, String tableName, String seqFile, String outputDir, String workDir, int maxSplits) throws Exception {
   
    PrintStream out = new PrintStream(new BufferedOutputStream(fs.create(new Path(workDir + "/splits.txt"))), false, Constants.UTF8.name());
   
    Connector conn = state.getConnector();
   
    Collection<Text> splits = conn.tableOperations().listSplits(tableName, maxSplits);
    for (Text split : splits)
      out.println(new String(Base64.encodeBase64(TextUtil.getBytes(split)), Constants.UTF8));
   
    out.close();
   
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);
      }
View Full Code Here

   
    Random r = new Random();

    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));
View Full Code Here

   
    return splits;
  }
 
  static void createIndexTable(Logger log, State state, String suffix, Random rand) throws Exception {
    Connector conn = state.getConnector();
    String name = (String) state.get("indexTableName") + suffix;
    int numPartitions = (Integer) state.get("numPartitions");
    boolean enableCache = (Boolean) state.get("cacheIndex");
    conn.tableOperations().create(name);
    conn.tableOperations().addSplits(name, genSplits(numPartitions, rand.nextInt(numPartitions) + 1, "%06x"));
   
    if (enableCache) {
      conn.tableOperations().setProperty(name, Property.TABLE_INDEXCACHE_ENABLED.getKey(), "true");
      conn.tableOperations().setProperty(name, Property.TABLE_BLOCKCACHE_ENABLED.getKey(), "true");
     
      log.info("Enabled caching for table " + name);
    }
  }
View Full Code Here

    state.set("numPartitions", Integer.valueOf(numPartitions));
    state.set("cacheIndex", rand.nextDouble() < .5);
    state.set("rand", rand);
    state.set("nextDocID", Long.valueOf(0));
   
    Connector conn = state.getConnector();
   
    createIndexTable(this.log, state, "", rand);
   
    String docTableName = (String) state.get("docTableName");
    conn.tableOperations().create(docTableName);
    conn.tableOperations().addSplits(docTableName, genSplits(0xff, rand.nextInt(32) + 1, "%02x"));
   
    if (rand.nextDouble() < .5) {
      conn.tableOperations().setProperty((String) state.get("docTableName"), Property.TABLE_BLOOM_ENABLED.getKey(), "true");
      log.info("Enabled bloom filters for table " + (String) state.get("docTableName"));
    }
  }
View Full Code Here

      // Reset the MTBW on the state to null
      state.resetMultiTableBatchWriter();
    }

    Connector conn = state.getConnector();
   
    conn.tableOperations().delete((String) state.get("indexTableName"));
    conn.tableOperations().delete((String) state.get("docTableName"));
   
    log.debug("Exiting shard test");
  }
View Full Code Here

    int numVerifications = rand.nextInt(maxVerify - 1) + 1;
   
    indexTableName = state.getString("indexTableName");
    imageTableName = state.getString("imageTableName");
   
    Connector conn = state.getConnector();
   
    Scanner indexScanner = conn.createScanner(indexTableName, new Authorizations());
    Scanner imageScanner = conn.createScanner(imageTableName, new Authorizations());
   
    String uuid = UUID.randomUUID().toString();
   
    MessageDigest alg = MessageDigest.getInstance("SHA-1");
    alg.update(uuid.getBytes(Constants.UTF8));
View Full Code Here

TOP

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

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.