Package org.apache.accumulo.core.client

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


  @Test
  public void testTableDelete() throws Exception {
    ZooKeeperInstance instance = new ZooKeeperInstance(cluster.getInstanceName(), cluster.getZooKeepers());
    Connector connector = instance.getConnector("root", password);

    BatchWriterConfig config = new BatchWriterConfig();

    TCredentials creds = CredentialHelper.create("root", password, instance.getInstanceID());
    MultiTableBatchWriter mtbw = new MultiTableBatchWriterImpl(instance, creds, config, 60, TimeUnit.SECONDS);
    boolean mutationsRejected = false;
   
View Full Code Here


  public void testOfflineTable() throws Exception {

    ZooKeeperInstance instance = new ZooKeeperInstance(cluster.getInstanceName(), cluster.getZooKeepers());
    Connector connector = instance.getConnector("root", password);

    BatchWriterConfig config = new BatchWriterConfig();

    TCredentials creds = CredentialHelper.create("root", password, instance.getInstanceID());
    MultiTableBatchWriter mtbw = new MultiTableBatchWriterImpl(instance, creds, config, 60, TimeUnit.SECONDS);
    boolean mutationsRejected = false;
View Full Code Here

  public void testOfflineTableWithCache() throws Exception {

    ZooKeeperInstance instance = new ZooKeeperInstance(cluster.getInstanceName(), cluster.getZooKeepers());
    Connector connector = instance.getConnector("root", password);

    BatchWriterConfig config = new BatchWriterConfig();
   
    TCredentials creds = CredentialHelper.create("root", password, instance.getInstanceID());
    MultiTableBatchWriter mtbw = new MultiTableBatchWriterImpl(instance, creds, config, 60, TimeUnit.SECONDS);
    boolean mutationsRejected = false;
View Full Code Here

  public void testOfflineTableWithoutCache() throws Exception {

    ZooKeeperInstance instance = new ZooKeeperInstance(cluster.getInstanceName(), cluster.getZooKeepers());
    Connector connector = instance.getConnector("root", password);

    BatchWriterConfig config = new BatchWriterConfig();

    TCredentials creds = CredentialHelper.create("root", password, instance.getInstanceID());
    MultiTableBatchWriter mtbw = new MultiTableBatchWriterImpl(instance, creds, config, 0, TimeUnit.SECONDS);
    boolean mutationsRejected = false;
View Full Code Here

    ZipInputStream zis = null;
   
    try {
      FileSystem fs = master.getFileSystem();
     
      mbw = master.getConnector().createBatchWriter(Constants.METADATA_TABLE_NAME, new BatchWriterConfig());
     
      zis = new ZipInputStream(fs.open(path));
     
      Map<String,String> fileNameMappings = readMappingFile(fs, tableInfo);
     
View Full Code Here

    return Collections.singletonList(new TableSetup("abc"));
  }
 
  @Override
  public void run() throws Exception {
    BatchWriter bw = getConnector().createBatchWriter("abc", new BatchWriterConfig());
   
    for (int i = 0; i < 100000; i++) {
      Mutation m = new Mutation(new Text(String.format("%08d", i)));
      for (int j = 0; j < 3; j++)
        m.put(new Text("cf1"), new Text("cq" + j), new Value((i + "_" + j).getBytes(Constants.UTF8)));
View Full Code Here

    }
  }

  private void createEntries(Opts opts) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {

    BatchWriter batchWriter = opts.getConnector().createBatchWriter(opts.getTableName(), new BatchWriterConfig());

    Mutation m = new Mutation("row");
    m.put("cf", "cq", "value");

    // Trace the write operation. Note, unless you flush the BatchWriter, you will not capture
View Full Code Here

   
    job.setNumReduceTasks(0);
   
    job.setOutputFormatClass(AccumuloOutputFormat.class);
    opts.setAccumuloConfigs(job);
    BatchWriterConfig bwConfig = new BatchWriterConfig().setMaxMemory(10L * 1000 * 1000);
    AccumuloOutputFormat.setBatchWriterOptions(job, bwConfig);
   
    Configuration conf = job.getConfiguration();
    conf.setLong(NUMROWS, opts.numRows);
    conf.setInt("cloudgen.minkeylength", opts.minKeyLength);
View Full Code Here

  }
 
  @Override
  public void run() throws Exception {
   
    BatchWriter bw = getConnector().createBatchWriter("foo", new BatchWriterConfig());
   
    Mutation m = new Mutation(new Text("r1"));
    m.put(new Text("acf"), new Text("foo"), new Value("1".getBytes(Constants.UTF8)));
   
    bw.addMutation(m);
   
    bw.close();
   
    getConnector().tableOperations().flush("foo", null, null, false);
    UtilWaitThread.sleep(1000);
   
    // minc should fail, so there should be no files
    checkRFiles("foo", 1, 1, 0, 0);
   
    // try to scan table
    Scanner scanner = getConnector().createScanner("foo", Constants.NO_AUTHS);
   
    int count = 0;
    for (@SuppressWarnings("unused")
    Entry<Key,Value> entry : scanner) {
      count++;
    }
   
    if (count != 1)
      throw new Exception("Did not see expected # entries " + count);
   
    // remove the bad iterator
    getConnector().tableOperations().removeProperty("foo", Property.TABLE_ITERATOR_PREFIX.getKey() + "minc.badi");
   
    UtilWaitThread.sleep(5000);
   
    // minc should complete
    checkRFiles("foo", 1, 1, 1, 1);
   
    count = 0;
    for (@SuppressWarnings("unused")
    Entry<Key,Value> entry : scanner) {
      count++;
    }
   
    if (count != 1)
      throw new Exception("Did not see expected # entries " + count);
   
    // now try putting bad iterator back and deleting the table
    getConnector().tableOperations().setProperty("foo", Property.TABLE_ITERATOR_PREFIX.getKey() + "minc.badi", "30," + BadIterator.class.getName());
    bw = getConnector().createBatchWriter("foo", new BatchWriterConfig());
    m = new Mutation(new Text("r2"));
    m.put(new Text("acf"), new Text("foo"), new Value("1".getBytes(Constants.UTF8)));
    bw.addMutation(m);
    bw.close();
   
View Full Code Here

    test2("ct2", false);
    test2("ct3", true);
  }
 
  private void test1() throws Exception {
    BatchWriter bw = getConnector().createBatchWriter("ct", new BatchWriterConfig());
   
    Mutation mut1 = new Mutation(new Text("r1"));
    mut1.put(new Text("cf1"), new Text("cq1"), new Value("123".getBytes(Constants.UTF8)));
   
    bw.addMutation(mut1);
   
    // should not throw any exceptions
    bw.close();
   
    bw = getConnector().createBatchWriter("ct", new BatchWriterConfig());
   
    // create a mutation with a non numeric value
    Mutation mut2 = new Mutation(new Text("r1"));
    mut2.put(new Text("cf1"), new Text("cq1"), new Value("123a".getBytes(Constants.UTF8)));
   
    bw.addMutation(mut2);
   
    boolean sawMRE = false;
   
    try {
      bw.close();
      // should not get here
      throw new Exception("Test failed, constraint did not catch bad mutation");
    } catch (MutationsRejectedException mre) {
      sawMRE = true;
     
      // verify constraint violation summary
      List<ConstraintViolationSummary> cvsl = mre.getConstraintViolationSummaries();
     
      if (cvsl.size() != 1) {
        throw new Exception("Unexpected constraints");
      }
     
      for (ConstraintViolationSummary cvs : cvsl) {
        if (!cvs.constrainClass.equals("org.apache.accumulo.examples.simple.constraints.NumericValueConstraint")) {
          throw new Exception("Unexpected constraint class " + cvs.constrainClass);
        }
       
        if (cvs.numberOfViolatingMutations != 1) {
          throw new Exception("Unexpected # violating mutations " + cvs.numberOfViolatingMutations);
        }
      }
    }
   
    if (!sawMRE) {
      throw new Exception("Did not see MutationsRejectedException");
    }
   
    // verify mutation did not go through
    Scanner scanner = getConnector().createScanner("ct", Constants.NO_AUTHS);
    scanner.setRange(new Range(new Text("r1")));
   
    Iterator<Entry<Key,Value>> iter = scanner.iterator();
    Entry<Key,Value> entry = iter.next();
   
    if (!entry.getKey().getRow().equals(new Text("r1")) || !entry.getKey().getColumnFamily().equals(new Text("cf1"))
        || !entry.getKey().getColumnQualifier().equals(new Text("cq1")) || !entry.getValue().equals(new Value("123".getBytes(Constants.UTF8)))) {
      throw new Exception("Unexpected key or value " + entry.getKey() + " " + entry.getValue());
    }
   
    if (iter.hasNext()) {
      entry = iter.next();
      throw new Exception("Unexpected extra key or value " + entry.getKey() + " " + entry.getValue());
    }
   
    // remove the numeric value constraint
    getConnector().tableOperations().removeConstraint("ct", 1);
    UtilWaitThread.sleep(1000);
   
    // now should be able to add a non numeric value
    bw = getConnector().createBatchWriter("ct", new BatchWriterConfig());
    bw.addMutation(mut2);
    bw.close();
   
    // verify mutation went through
    iter = scanner.iterator();
    entry = iter.next();
   
    if (!entry.getKey().getRow().equals(new Text("r1")) || !entry.getKey().getColumnFamily().equals(new Text("cf1"))
        || !entry.getKey().getColumnQualifier().equals(new Text("cq1")) || !entry.getValue().equals(new Value("123a".getBytes(Constants.UTF8)))) {
      throw new Exception("Unexpected key or value " + entry.getKey() + " " + entry.getValue());
    }
   
    if (iter.hasNext()) {
      entry = iter.next();
      throw new Exception("Unexpected extra key or value " + entry.getKey() + " " + entry.getValue());
    }
   
    // add a constraint that references a non-existant class
    getConnector().tableOperations().setProperty("ct", Property.TABLE_CONSTRAINT_PREFIX + "1", "com.foobar.nonExistantClass");
    UtilWaitThread.sleep(1000);
   
    // add a mutation
    bw = getConnector().createBatchWriter("ct", new BatchWriterConfig());
   
    Mutation mut3 = new Mutation(new Text("r1"));
    mut3.put(new Text("cf1"), new Text("cq1"), new Value("foo".getBytes(Constants.UTF8)));
   
    bw.addMutation(mut3);
   
    sawMRE = false;
   
    try {
      bw.close();
      // should not get here
      throw new Exception("Test failed, mutation went through when table had bad constraints");
    } catch (MutationsRejectedException mre) {
      sawMRE = true;
    }
   
    if (!sawMRE) {
      throw new Exception("Did not see MutationsRejectedException");
    }
   
    // verify the mutation did not go through
    iter = scanner.iterator();
    entry = iter.next();
   
    if (!entry.getKey().getRow().equals(new Text("r1")) || !entry.getKey().getColumnFamily().equals(new Text("cf1"))
        || !entry.getKey().getColumnQualifier().equals(new Text("cq1")) || !entry.getValue().equals(new Value("123a".getBytes(Constants.UTF8)))) {
      throw new Exception("Unexpected key or value " + entry.getKey() + " " + entry.getValue());
    }
   
    if (iter.hasNext()) {
      entry = iter.next();
      throw new Exception("Unexpected extra key or value " + entry.getKey() + " " + entry.getValue());
    }
   
    // remove the bad constraint
    getConnector().tableOperations().removeProperty("ct", Property.TABLE_CONSTRAINT_PREFIX + "1");
    UtilWaitThread.sleep(1000);
   
    // try the mutation again
    bw = getConnector().createBatchWriter("ct", new BatchWriterConfig());
    bw.addMutation(mut3);
    bw.close();
   
    // verify it went through
    iter = scanner.iterator();
View Full Code Here

TOP

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

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.