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

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, 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 test() throws Exception {
    Connector c = getConnector();
    TableOperations to = c.tableOperations();
    String tableName = getUniqueNames(1)[0];
    to.create(tableName);
    TestIngest.Opts opts = new TestIngest.Opts();
    opts.tableName = tableName;
    TestIngest.ingest(c, opts, new BatchWriterOpts());
    to.flush(tableName, null, null, true);
    VerifyIngest.Opts vopts = new VerifyIngest.Opts();
    vopts.tableName = tableName;
    VerifyIngest.verifyIngest(c, vopts, new ScannerOpts());
    String id = to.tableIdMap().get(tableName);
    Scanner s = c.createScanner(MetadataTable.NAME, Authorizations.EMPTY);
    s.setRange(new KeyExtent(new Text(id), null, null).toMetadataRange());
    s.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
    assertTrue(FunctionalTestUtils.count(s) > 0);
    FileSystem fs = FileSystem.get(CachedConfiguration.getInstance());
    assertTrue(fs.listStatus(new Path(rootPath() + "/accumulo/tables/" + id)).length > 0);
    to.delete(tableName);
    assertEquals(0, FunctionalTestUtils.count(s));
    try {
      assertEquals(0, fs.listStatus(new Path(rootPath() + "/accumulo/tables/" + id)).length);
    } catch (FileNotFoundException ex) {
      // that's fine, too
    }
    assertNull(to.tableIdMap().get(tableName));
    to.create(tableName);
    TestIngest.ingest(c, opts, new BatchWriterOpts());
    VerifyIngest.verifyIngest(c, vopts, new ScannerOpts());
    to.delete(tableName);
  }
View Full Code Here

  @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

 
  @Test(timeout = 6 * 60 * 1000)
  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

  public void verifyTableOperationsExceptions() throws Exception {
    String tableName = namespace + ".1";
    IteratorSetting setting = new IteratorSetting(200, VersioningIterator.class);
    Text a = new Text("a");
    Text z = new Text("z");
    TableOperations ops = c.tableOperations();

    // this one doesn't throw an exception, so don't fail; just check that it works
    assertFalse(ops.exists(tableName));

    // table operations that should throw an AccumuloException caused by NamespaceNotFoundException
    int numRun = 0;
    ACCUMULOEXCEPTIONS_NAMESPACENOTFOUND: for (int i = 0;; ++i)
      try {
        switch (i) {
          case 0:
            ops.create(tableName);
            fail();
          case 1:
            ops.create("a");
            ops.clone("a", tableName, true, Collections.<String,String> emptyMap(), Collections.<String> emptySet());
            fail();
          case 2:
            ops.importTable(tableName, System.getProperty("user.dir") + "/target");
            fail();
          default:
            // break out of infinite loop
            assertEquals(3, i); // check test integrity
            assertEquals(3, numRun); // check test integrity
            break ACCUMULOEXCEPTIONS_NAMESPACENOTFOUND;
        }
      } catch (Exception e) {
        numRun++;
        if (!(e instanceof AccumuloException) || !(e.getCause() instanceof NamespaceNotFoundException))
          throw new Exception("Case " + i + " resulted in " + e.getClass().getName(), e);
      }

    // table operations that should throw an AccumuloException caused by a TableNotFoundException caused by a NamespaceNotFoundException
    // these are here because we didn't declare TableNotFoundException in the API :(
    numRun = 0;
    ACCUMULOEXCEPTIONS_TABLENOTFOUND: for (int i = 0;; ++i)
      try {
        switch (i) {
          case 0:
            ops.removeConstraint(tableName, 0);
            fail();
          case 1:
            ops.removeProperty(tableName, "a");
            fail();
          case 2:
            ops.setProperty(tableName, "a", "b");
            fail();
          default:
            // break out of infinite loop
            assertEquals(3, i); // check test integrity
            assertEquals(3, numRun); // check test integrity
            break ACCUMULOEXCEPTIONS_TABLENOTFOUND;
        }
      } catch (Exception e) {
        numRun++;
        if (!(e instanceof AccumuloException) || !(e.getCause() instanceof TableNotFoundException)
            || !(e.getCause().getCause() instanceof NamespaceNotFoundException))
          throw new Exception("Case " + i + " resulted in " + e.getClass().getName(), e);
      }

    // table operations that should throw a TableNotFoundException caused by NamespaceNotFoundException
    numRun = 0;
    TABLENOTFOUNDEXCEPTIONS: for (int i = 0;; ++i)
      try {
        switch (i) {
          case 0:
            ops.addConstraint(tableName, NumericValueConstraint.class.getName());
            fail();
          case 1:
            ops.addSplits(tableName, new TreeSet<Text>());
            fail();
          case 2:
            ops.attachIterator(tableName, setting);
            fail();
          case 3:
            ops.cancelCompaction(tableName);
            fail();
          case 4:
            ops.checkIteratorConflicts(tableName, setting, EnumSet.allOf(IteratorScope.class));
            fail();
          case 5:
            ops.clearLocatorCache(tableName);
            fail();
          case 6:
            ops.clone(tableName, "2", true, Collections.<String,String> emptyMap(), Collections.<String> emptySet());
            fail();
          case 7:
            ops.compact(tableName, a, z, true, true);
            fail();
          case 8:
            ops.delete(tableName);
            fail();
          case 9:
            ops.deleteRows(tableName, a, z);
            fail();
          case 10:
            ops.splitRangeByTablets(tableName, new Range(), 10);
            fail();
          case 11:
            ops.exportTable(tableName, namespace + "_dir");
            fail();
          case 12:
            ops.flush(tableName, a, z, true);
            fail();
          case 13:
            ops.getDiskUsage(Collections.singleton(tableName));
            fail();
          case 14:
            ops.getIteratorSetting(tableName, "a", IteratorScope.scan);
            fail();
          case 15:
            ops.getLocalityGroups(tableName);
            fail();
          case 16:
            ops.getMaxRow(tableName, Authorizations.EMPTY, a, true, z, true);
            fail();
          case 17:
            ops.getProperties(tableName);
            fail();
          case 18:
            ops.importDirectory(tableName, "", "", false);
            fail();
          case 19:
            ops.testClassLoad(tableName, VersioningIterator.class.getName(), SortedKeyValueIterator.class.getName());
            fail();
          case 20:
            ops.listConstraints(tableName);
            fail();
          case 21:
            ops.listIterators(tableName);
            fail();
          case 22:
            ops.listSplits(tableName);
            fail();
          case 23:
            ops.merge(tableName, a, z);
            fail();
          case 24:
            ops.offline(tableName, true);
            fail();
          case 25:
            ops.online(tableName, true);
            fail();
          case 26:
            ops.removeIterator(tableName, "a", EnumSet.of(IteratorScope.scan));
            fail();
          case 27:
            ops.rename(tableName, tableName + "2");
            fail();
          case 28:
            ops.setLocalityGroups(tableName, Collections.<String,Set<Text>> emptyMap());
            fail();
          default:
            // break out of infinite loop
            assertEquals(29, i); // check test integrity
            assertEquals(29, numRun); // check test integrity
View Full Code Here

    if (!caught)
      throw new Exception("batch scan did not fail");

    // remove the bad agg so accumulo can shutdown
    TableOperations to = c.tableOperations();
    for (Entry<String,String> e : to.getProperties(tableName)) {
      to.removeProperty(tableName, e.getKey());
    }

    UtilWaitThread.sleep(500);

    // should be able to scan now
View Full Code Here

      tableName = state.getString("indexTableName");
    }
   
    // check if chosen table exists
    Connector conn = state.getConnector();
    TableOperations tableOps = conn.tableOperations();
    if (tableOps.exists(tableName) == false) {
      log.error("Table " + tableName + " does not exist!");
      return;
    }
   
    // choose a random action
    int num = rand.nextInt(10);
    if (num > 6) {
      log.debug("Retrieving info for " + tableName);
      tableOps.getLocalityGroups(tableName);
      tableOps.getProperties(tableName);
      tableOps.getSplits(tableName);
      tableOps.list();
    } else {
      log.debug("Clearing locator cache for " + tableName);
      tableOps.clearLocatorCache(tableName);
    }
  }
View Full Code Here

 
  @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

    @Before
    public void setUp() throws Exception {
        Instance instance = new MockInstance();
        conn = instance.getConnector("user", "password");

        TableOperations tableOperations = conn.tableOperations();
        tableOperations.create(TABLE_NAME);
        tableOperations.removeIterator(TABLE_NAME, "vers", EnumSet.allOf(IteratorUtil.IteratorScope.class));

        BatchWriter writer = conn.createBatchWriter("foo", 1024, 0, 1);

        Mutation m = new Mutation("a");
        m.put("1", "b", 1L, "a-b1");
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.