Examples of TableOperations


Examples of org.apache.accumulo.core.client.admin.TableOperations

    try {
      final String table1 = "testTableRenameSameWriters_table1", table2 = "testTableRenameSameWriters_table2";
      final String newTable1 = "testTableRenameSameWriters_newTable1", newTable2 = "testTableRenameSameWriters_newTable2";

      TableOperations tops = connector.tableOperations();
      tops.create(table1);
      tops.create(table2);

      BatchWriter bw1 = mtbw.getBatchWriter(table1), bw2 = mtbw.getBatchWriter(table2);

      Mutation m1 = new Mutation("foo");
      m1.put("col1", "", "val1");
      m1.put("col2", "", "val2");

      bw1.addMutation(m1);
      bw2.addMutation(m1);

      tops.rename(table1, newTable1);
      tops.rename(table2, newTable2);

      Mutation m2 = new Mutation("bar");
      m2.put("col1", "", "val1");
      m2.put("col2", "", "val2");
View Full Code Here

Examples of org.apache.accumulo.core.client.admin.TableOperations

    try {
      final String table1 = "testTableRenameNewWriters_table1", table2 = "testTableRenameNewWriters_table2";
      final String newTable1 = "testTableRenameNewWriters_newTable1", newTable2 = "testTableRenameNewWriters_newTable2";

      TableOperations tops = connector.tableOperations();
      tops.create(table1);
      tops.create(table2);

      BatchWriter bw1 = mtbw.getBatchWriter(table1), bw2 = mtbw.getBatchWriter(table2);

      Mutation m1 = new Mutation("foo");
      m1.put("col1", "", "val1");
      m1.put("col2", "", "val2");

      bw1.addMutation(m1);
      bw2.addMutation(m1);

      tops.rename(table1, newTable1);

      // MTBW is still caching this name to the correct table, but we should invalidate its cache
      // after seeing the rename
      try {
        bw1 = mtbw.getBatchWriter(table1);
        Assert.fail("Should not be able to find this table");
      } catch (TableNotFoundException e) {
        // pass
      }

      tops.rename(table2, newTable2);

      try {
        bw2 = mtbw.getBatchWriter(table2);
        Assert.fail("Should not be able to find this table");
      } catch (TableNotFoundException e) {
View Full Code Here

Examples of org.apache.accumulo.core.client.admin.TableOperations

    try {
      final String table1 = "testTableRenameNewWritersNoCaching_table1", table2 = "testTableRenameNewWritersNoCaching_table2";
      final String newTable1 = "testTableRenameNewWritersNoCaching_newTable1", newTable2 = "testTableRenameNewWritersNoCaching_newTable2";

      TableOperations tops = connector.tableOperations();
      tops.create(table1);
      tops.create(table2);

      BatchWriter bw1 = mtbw.getBatchWriter(table1), bw2 = mtbw.getBatchWriter(table2);

      Mutation m1 = new Mutation("foo");
      m1.put("col1", "", "val1");
      m1.put("col2", "", "val2");

      bw1.addMutation(m1);
      bw2.addMutation(m1);

      tops.rename(table1, newTable1);
      tops.rename(table2, newTable2);

      try {
        bw1 = mtbw.getBatchWriter(table1);
        Assert.fail("Should not have gotten batchwriter for " + table1);
      } catch (TableNotFoundException e) {
View Full Code Here

Examples of org.apache.accumulo.core.client.admin.TableOperations

    // expressly set number of tservers since we assert it later, in case the default changes
    config.setNumTservers(NUM_TSERVERS);
    accumulo = new MiniAccumuloClusterImpl(config);
    accumulo.start();
    // create a table to ensure there are some entries in the !0 table
    TableOperations tableops = accumulo.getConnector("root","superSecret").tableOperations();
    tableops.create(TEST_TABLE);
    testTableID = tableops.tableIdMap().get(TEST_TABLE);

    Scanner s = accumulo.getConnector("root", "superSecret").createScanner(TEST_TABLE, Authorizations.EMPTY);
    for (@SuppressWarnings("unused") Entry<Key,Value> e : s) {}
  }
View Full Code Here

Examples of org.apache.accumulo.core.client.admin.TableOperations

    String hostname = InetAddress.getLocalHost().getHostName().replaceAll("[-.]", "_");
    String pid = state.getPid();
    tableName = String.format("bulk_%s_%s_%d", hostname, pid, System.currentTimeMillis());
    log.info("Starting bulk test on " + tableName);
   
    TableOperations tableOps = state.getConnector().tableOperations();
    try {
      if (!tableOps.exists(getTableName())) {
        tableOps.create(getTableName());
        IteratorSetting is = new IteratorSetting(10, org.apache.accumulo.core.iterators.user.SummingCombiner.class);
        SummingCombiner.setEncodingType(is, LongCombiner.Type.STRING);
        SummingCombiner.setCombineAllColumns(is, true);
        tableOps.attachIterator(getTableName(), is);
      }
    } catch (TableExistsException ex) {
      // expected if there are multiple walkers
    }
    state.set("rand", rand);
View Full Code Here

Examples of org.apache.accumulo.core.client.admin.TableOperations

 
  @Override
  public long balance(SortedMap<TServerInstance,TabletServerStatus> current, Set<KeyExtent> migrations, List<TabletMigration> migrationsOut) {
    long minBalanceTime = 5 * 1000;
    // Iterate over the tables and balance each of them
    TableOperations t = getTableOperations();
    if (t == null)
      return minBalanceTime;
    for (String s : t.tableIdMap().values()) {
      ArrayList<TabletMigration> newMigrations = new ArrayList<TabletMigration>();
      long tableBalanceTime = getBalancerForTable(s).balance(current, migrations, newMigrations);
      if (tableBalanceTime < minBalanceTime)
        minBalanceTime = tableBalanceTime;
      migrationsOut.addAll(newMigrations);
View Full Code Here

Examples of org.apache.accumulo.core.client.admin.TableOperations

  public void testImport() throws Throwable {
    ImportTestFilesAndData dataAndFiles = prepareTestFiles();
    Instance instance = new MockInstance("foo");
    Connector connector = instance.getConnector(new AuthInfo("user", ByteBuffer
        .wrap(new byte[0]), "foo"));
    TableOperations tableOperations = connector.tableOperations();
    tableOperations.create("a_table");
    tableOperations.importDirectory("a_table",
        dataAndFiles.importPath.toString(),
        dataAndFiles.failurePath.toString(), false);
    Scanner scanner = connector.createScanner("a_table", new Authorizations());
    Iterator<Entry<Key, Value>> iterator = scanner.iterator();
    for (int i = 0; i < 5; i++) {
View Full Code Here

Examples of org.apache.accumulo.core.client.admin.TableOperations

  @Test(expected = TableNotFoundException.class)
  public void testFailsWithNoTable() throws Throwable {
    Instance instance = new MockInstance("foo");
    Connector connector = instance.getConnector(new AuthInfo("user", ByteBuffer
        .wrap(new byte[0]), "foo"));
    TableOperations tableOperations = connector.tableOperations();
    ImportTestFilesAndData testFiles = prepareTestFiles();
    tableOperations.importDirectory("doesnt_exist_table",
        testFiles.importPath.toString(), testFiles.failurePath.toString(),
        false);
  }
View Full Code Here

Examples of org.apache.accumulo.core.client.admin.TableOperations

  @Test(expected = IOException.class)
  public void testFailsWithNonEmptyFailureDirectory() throws Throwable {
    Instance instance = new MockInstance("foo");
    Connector connector = instance.getConnector(new AuthInfo("user", ByteBuffer
        .wrap(new byte[0]), "foo"));
    TableOperations tableOperations = connector.tableOperations();
    ImportTestFilesAndData testFiles = prepareTestFiles();
    FileSystem fs = testFiles.failurePath.getFileSystem(new Configuration());
    fs.open(testFiles.failurePath.suffix("/something")).close();
    tableOperations.importDirectory("doesnt_exist_table",
        testFiles.importPath.toString(), testFiles.failurePath.toString(),
        false);
  }
View Full Code Here

Examples of org.apache.accumulo.core.client.admin.TableOperations

    }
    if (!caught)
      throw new Exception("batch scan did not fail");
   
    // remove the bad agg so accumulo can shutdown
    TableOperations to = getConnector().tableOperations();
    for (Entry<String,String> e : to.getProperties("tt")) {
      to.removeProperty("tt", e.getKey());
    }
   
    UtilWaitThread.sleep(500);
   
    // should be able to scan now
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.