Examples of MultiTableBatchWriter


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

  static final Text CONTENT_COLUMN_FAMILY = new Text("content");
 
  @Override
  public void visit(State state, Properties props) throws Exception {
   
    MultiTableBatchWriter mtbw = state.getMultiTableBatchWriter();
   
    BatchWriter imagesBW = mtbw.getBatchWriter(state.getString("imageTableName"));
    BatchWriter indexBW = mtbw.getBatchWriter(state.getString("indexTableName"));
   
    String uuid = UUID.randomUUID().toString();
    Mutation m = new Mutation(new Text(uuid));
   
    // create a fake image between 4KB and 1MB
View Full Code Here

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

    byte[] pass = args[3].getBytes();
    String tableName = args[4];
   
    ZooKeeperInstance instance = new ZooKeeperInstance(instanceName, zooKeepers);
    Connector connector = instance.getConnector(user, pass);
    MultiTableBatchWriter mtbw = connector.createMultiTableBatchWriter(200000l, 300, 4);
   
    BatchWriter bw = null;
   
    if (!connector.tableOperations().exists(tableName))
      connector.tableOperations().create(tableName);
    bw = mtbw.getBatchWriter(tableName);
   
    Text colf = new Text("colfam");
    System.out.println("writing ...");
    for (int i = 0; i < 10000; i++) {
      Mutation m = new Mutation(new Text(String.format("row_%d", i)));
      for (int j = 0; j < 5; j++) {
        m.put(colf, new Text(String.format("colqual_%d", j)), new Value((String.format("value_%d_%d", i, j)).getBytes()));
      }
      bw.addMutation(m);
      if (i % 100 == 0)
        System.out.println(i);
    }
   
    mtbw.close();
  }
View Full Code Here

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

    KeyExtent last = new KeyExtent();
    String directory = null;
    Set<String> knownFiles = new HashSet<String>();
   
    int count = 0;
    final MultiTableBatchWriter writer = opts.getConnector().createMultiTableBatchWriter(bwOpts.getBatchWriterConfig());
   
    // collect the list of known files and the directory for each extent
    for (Entry<Key,Value> entry : scanner) {
      Key key = entry.getKey();
      KeyExtent ke = new KeyExtent(key.getRow(), (Text) null);
      // when the key extent changes
      if (!ke.equals(last)) {
        if (directory != null) {
          // add any files in the directory unknown to the key extent
          count += addUnknownFiles(fs, directory, knownFiles, last, writer, opts.update);
        }
        directory = null;
        knownFiles.clear();
        last = ke;
      }
      if (Constants.METADATA_DIRECTORY_COLUMN.hasColumns(key)) {
        directory = entry.getValue().toString();
        log.debug("Found directory " + directory + " for row " + key.getRow().toString());
      } else if (key.compareColumnFamily(Constants.METADATA_DATAFILE_COLUMN_FAMILY) == 0) {
        String filename = key.getColumnQualifier().toString();
        knownFiles.add(filename);
        log.debug("METADATA file found: " + filename);
      }
    }
    if (directory != null) {
      // catch the last key extent
      count += addUnknownFiles(fs, directory, knownFiles, last, writer, opts.update);
    }
    log.info("There were " + count + " files that are unknown to the metadata table");
    writer.close();
  }
View Full Code Here

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

  @Test
  public void testMockMultiTableBatchWriter() throws Exception {
    Connector c = new MockConnector("root", new MockInstance());
    c.tableOperations().create("a");
    c.tableOperations().create("b");
    MultiTableBatchWriter bw = c.createMultiTableBatchWriter(new BatchWriterConfig());
    Mutation m1 = new Mutation("r1");
    m1.put("cf1", "cq1", 1, "v1");
    BatchWriter b = bw.getBatchWriter("a");
    b.addMutation(m1);
    b.flush();
    b = bw.getBatchWriter("b");
    b.addMutation(m1);
    b.flush();
   
    Scanner scanner = c.createScanner("a", Constants.NO_AUTHS);
    int count = 0;
View Full Code Here

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

    ClientOnRequiredTable opts = new ClientOnRequiredTable();
    BatchWriterOpts bwOpts = new BatchWriterOpts();
    opts.parseArgs(InsertWithBatchWriter.class.getName(), args, bwOpts);
   
    Connector connector = opts.getConnector();
    MultiTableBatchWriter mtbw = connector.createMultiTableBatchWriter(bwOpts.getBatchWriterConfig());
   
    if (!connector.tableOperations().exists(opts.tableName))
      connector.tableOperations().create(opts.tableName);
    BatchWriter bw = mtbw.getBatchWriter(opts.tableName);
   
    Text colf = new Text("colfam");
    System.out.println("writing ...");
    for (int i = 0; i < 10000; i++) {
      Mutation m = new Mutation(new Text(String.format("row_%d", i)));
      for (int j = 0; j < 5; j++) {
        m.put(colf, new Text(String.format("colqual_%d", j)), new Value((String.format("value_%d_%d", i, j)).getBytes()));
      }
      bw.addMutation(m);
      if (i % 100 == 0)
        System.out.println(i);
    }
    mtbw.close();
  }
View Full Code Here

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

 
  @Override
  public void tearDown(State state) throws Exception {
    // We have resources we need to clean up
    if (state.isMultiTableBatchWriterInitialized()) {
      MultiTableBatchWriter mtbw = state.getMultiTableBatchWriter();
      try {
        mtbw.close();
      } catch (MutationsRejectedException e) {
        log.error("Ignoring mutations that weren't flushed", e);
      }
     
      // Reset the MTBW on the state to null
View Full Code Here

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

  static final Text CONTENT_COLUMN_FAMILY = new Text("content");
 
  @Override
  public void visit(State state, Properties props) throws Exception {
   
    MultiTableBatchWriter mtbw = state.getMultiTableBatchWriter();
   
    BatchWriter imagesBW = mtbw.getBatchWriter(state.getString("imageTableName"));
    BatchWriter indexBW = mtbw.getBatchWriter(state.getString("indexTableName"));
   
    String uuid = UUID.randomUUID().toString();
    Mutation m = new Mutation(new Text(uuid));
   
    // create a fake image between 4KB and 1MB
View Full Code Here

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

 
  @Override
  public void tearDown(State state) throws Exception {
    // We have resources we need to clean up
    if (state.isMultiTableBatchWriterInitialized()) {
      MultiTableBatchWriter mtbw = state.getMultiTableBatchWriter();
      try {
        mtbw.close();
      } catch (MutationsRejectedException e) {
        log.error("Ignoring mutations that weren't flushed", e);
      }
     
      // Reset the MTBW on the state to null
View Full Code Here

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

    KeyExtent last = new KeyExtent();
    String directory = null;
    Set<String> knownFiles = new HashSet<String>();
   
    int count = 0;
    final MultiTableBatchWriter writer = opts.getConnector().createMultiTableBatchWriter(bwOpts.getBatchWriterConfig());
   
    // collect the list of known files and the directory for each extent
    for (Entry<Key,Value> entry : scanner) {
      Key key = entry.getKey();
      KeyExtent ke = new KeyExtent(key.getRow(), (Text) null);
      // when the key extent changes
      if (!ke.equals(last)) {
        if (directory != null) {
          // add any files in the directory unknown to the key extent
          count += addUnknownFiles(fs, directory, knownFiles, last, writer, opts.update);
        }
        directory = null;
        knownFiles.clear();
        last = ke;
      }
      if (TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.hasColumns(key)) {
        directory = entry.getValue().toString();
        log.debug("Found directory " + directory + " for row " + key.getRow().toString());
      } else if (key.compareColumnFamily(DataFileColumnFamily.NAME) == 0) {
        String filename = key.getColumnQualifier().toString();
        knownFiles.add(filename);
        log.debug("METADATA file found: " + filename);
      }
    }
    if (directory != null) {
      // catch the last key extent
      count += addUnknownFiles(fs, directory, knownFiles, last, writer, opts.update);
    }
    log.info("There were " + count + " files that are unknown to the metadata table");
    writer.close();
  }
View Full Code Here

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

   
    if (!opts.readonly) {
      for (String table : tableNames)
        connector.tableOperations().create(table);
     
      MultiTableBatchWriter b;
      try {
        b = connector.createMultiTableBatchWriter(bwOpts.getBatchWriterConfig());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
     
      // populate
      for (int i = 0; i < opts.count; i++) {
        Mutation m = new Mutation(new Text(String.format("%06d", i)));
        m.put(new Text("col" + Integer.toString((i % 3) + 1)), new Text("qual"), new Value("junk".getBytes(Constants.UTF8)));
        b.getBatchWriter(tableNames.get(i % tableNames.size())).addMutation(m);
      }
      try {
        b.close();
      } catch (MutationsRejectedException e) {
        throw new RuntimeException(e);
      }
    }
    try {
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.