Package org.apache.accumulo.core.client.admin

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


    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

 
  @Test
  public void localityGroupChange() throws Exception {
    // Make changes to locality groups and ensure nothing is lostssh
    final Connector connector = getConnector();
    TableOperations to = connector.tableOperations();
    to.create("test_ingest");
    String[] config = new String[] {"lg1:colf", null, "lg1:colf,xyz", "lg1:colf,xyz;lg2:c1,c2"};
    int i = 0;
    for (String cfg : config) {
      to.setLocalityGroups("test_ingest", getGroups(cfg));
      ingest(connector, ROWS * (i + 1), 1, 50, ROWS * i);
      to.flush("test_ingest", null, null, true);
      verify(connector, 0, 1, 50, ROWS * (i + 1));
      i++;
    }
    to.delete("test_ingest");
    to.create("test_ingest");
    config = new String[] {"lg1:colf", null, "lg1:colf,xyz", "lg1:colf;lg2:colf",};
    i = 1;
    for (String cfg : config) {
      ingest(connector, ROWS * i, 1, 50, 0);
      ingest(connector, ROWS * i, 1, 50, 0, "xyz");
      to.setLocalityGroups("test_ingest", getGroups(cfg));
      to.flush("test_ingest", null, null, true);
      verify(connector, ROWS * i, 1, 50, 0);
      verify(connector, ROWS * i, 1, 50, 0, "xyz");
      i++;
    }
  }
View Full Code Here

    // Name as option will work
    ts.exec("setiter -scan -class org.apache.accumulo.core.iterators.ColumnFamilyCounter -p 30 -name cfcounter", true);

    String expectedKey = "table.iterator.scan.cfcounter";
    String expectedValue = "30,org.apache.accumulo.core.iterators.ColumnFamilyCounter";
    TableOperations tops = conn.tableOperations();
    checkTableForProperty(tops, tableName, expectedKey, expectedValue);

    ts.exec("deletetable " + tableName, true);
    tableName = tableName + "1";
View Full Code Here

  @Test
  public void testImport() throws Throwable {
    ImportTestFilesAndData dataAndFiles = prepareTestFiles();
    Instance instance = new MockInstance("foo");
    Connector connector = instance.getConnector("user", new PasswordToken(new byte[0]));
    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++) {
      Assert.assertTrue(iterator.hasNext());
      Entry<Key,Value> kv = iterator.next();
View Full Code Here

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

  @Test(expected = IOException.class)
  public void testFailsWithNonEmptyFailureDirectory() throws Throwable {
    Instance instance = new MockInstance("foo");
    Connector connector = instance.getConnector("user", new PasswordToken(new byte[0]));
    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

  @Test
  public void testDeleteRows() throws Exception {
    Instance instance = new MockInstance("rows");
    Connector connector = instance.getConnector("user", new PasswordToken("foo".getBytes()));
    TableOperations to = connector.tableOperations();
    to.create("test");
    BatchWriter bw = connector.createBatchWriter("test", new BatchWriterConfig());
    for (int r = 0; r < 20; r++) {
      Mutation m = new Mutation("" + r);
      for (int c = 0; c < 5; c++) {
        m.put(new Text("cf"), new Text("" + c), new Value(("" + c).getBytes()));
      }
      bw.addMutation(m);
    }
    bw.flush();
    to.deleteRows("test", new Text("1"), new Text("2"));
    Scanner s = connector.createScanner("test", Authorizations.EMPTY);
    int oneCnt = 0;
    for (Entry<Key,Value> entry : s) {
      char rowStart = entry.getKey().getRow().toString().charAt(0);
      Assert.assertTrue(rowStart != '2');
View Full Code Here

  @Test
  public void testDeleteRowsWithNullKeys() throws Exception {
    Instance instance = new MockInstance("rows");
    Connector connector = instance.getConnector("user", new PasswordToken("foo"));
    TableOperations to = connector.tableOperations();
    to.create("test2");
    BatchWriter bw = connector.createBatchWriter("test2", new BatchWriterConfig());
    for (int r = 0; r < 30; r++) {
      Mutation m = new Mutation(Integer.toString(r));
      for (int c = 0; c < 5; c++) {
        m.put(new Text("cf"), new Text(Integer.toString(c)), new Value(Integer.toString(c).getBytes()));
      }
      bw.addMutation(m);
    }
    bw.flush();

    // test null end
    // will remove rows 4 through 9 (6 * 5 = 30 entries)
    to.deleteRows("test2", new Text("30"), null);
    Scanner s = connector.createScanner("test2", Authorizations.EMPTY);
    int rowCnt = 0;
    for (Entry<Key,Value> entry : s) {
      String rowId = entry.getKey().getRow().toString();
      Assert.assertFalse(rowId.startsWith("30"));
      rowCnt++;
    }
    s.close();
    Assert.assertEquals(120, rowCnt);

    // test null start
    // will remove 0-1, 10-19, 2
    to.deleteRows("test2", null, new Text("2"));
    s = connector.createScanner("test2", Authorizations.EMPTY);
    rowCnt = 0;
    for (Entry<Key,Value> entry : s) {
      char rowStart = entry.getKey().getRow().toString().charAt(0);
      Assert.assertTrue(rowStart >= '2');
      rowCnt++;
    }
    s.close();
    Assert.assertEquals(55, rowCnt);

    // test null start and end
    // deletes everything still left
    to.deleteRows("test2", null, null);
    s = connector.createScanner("test2", Authorizations.EMPTY);
    rowCnt = 0;
    for (@SuppressWarnings("unused")
    Entry<Key,Value> entry : s) {
      rowCnt++;
    }
    s.close();
    to.delete("test2");
    Assert.assertEquals(0, rowCnt);

  }
View Full Code Here

  @Test
  public void testTableIdMap() throws Exception {
    Instance inst = new MockInstance("testTableIdMap");
    Connector conn = inst.getConnector("root", new PasswordToken(""));
    TableOperations tops = conn.tableOperations();
    tops.create("foo");

    // Should get a table ID, not the table name
    Assert.assertNotEquals("foo", tops.tableIdMap().get("foo"));
  }
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.client.admin.TableOperations

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.