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

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


      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);
    }
   
    if (rand.nextInt(10) < 3) {
      Map<String,Set<Text>> groups = tableOps.getLocalityGroups(state.getString("imageTableName"));
     
      if (groups.size() == 0) {
        log.debug("Adding locality groups to " + state.getString("imageTableName"));
        groups = ImageFixture.getLocalityGroups();
      } else {
        log.debug("Removing locality groups from " + state.getString("imageTableName"));
        groups = new HashMap<String,Set<Text>>();
      }
     
      tableOps.setLocalityGroups(state.getString("imageTableName"), groups);
    }
  }
View Full Code Here


   
    String tablename = WikipediaConfiguration.getTableName(ingestConf);
   
    Connector connector = WikipediaConfiguration.getConnector(ingestConf);
   
    TableOperations tops = connector.tableOperations();
   
    createTables(tops, tablename);
   
    ingestJob.setMapperClass(WikipediaPartitionedMapper.class);
    ingestJob.setNumReduceTasks(0);
View Full Code Here

   
    String user = WikipediaConfiguration.getUser(conf);
    byte[] password = WikipediaConfiguration.getPassword(conf);
    Connector connector = WikipediaConfiguration.getConnector(conf);
   
    TableOperations tops = connector.tableOperations();
   
    createTables(tops, tablename);
   
    configureJob(job);
   
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", Constants.NO_AUTHS);
    for (Entry<Key,Value> entry : s) {
      Assert.assertTrue(entry.getKey().getRow().toString().charAt(0) != '1');
    }
  }
View Full Code Here

        ZooKeeperInstance inst = new ZooKeeperInstance(
                accumuloCluster.getInstanceName(),
                accumuloCluster.getZooKeepers());
        Connector c = inst.getConnector("root", new PasswordToken("password"));

        TableOperations tops = c.tableOperations();
        if (!tops.exists("airports")) {
            tops.create("airports");
        }

        if (!tops.exists("flights")) {
            tops.create("flights");
        }

        BatchWriterConfig config = new BatchWriterConfig();
        config.setMaxWriteThreads(1);
        config.setMaxLatency(100000l, TimeUnit.MILLISECONDS);
View Full Code Here

        ZooKeeperInstance inst = new ZooKeeperInstance(
                accumuloCluster.getInstanceName(),
                accumuloCluster.getZooKeepers());
        Connector c = inst.getConnector("root", new PasswordToken("password"));

        TableOperations tops = c.tableOperations();
        if (!tops.exists("airports")) {
            tops.create("airports");
        }

        if (!tops.exists("flights")) {
            tops.create("flights");
        }

        BatchWriterConfig config = new BatchWriterConfig();
        config.setMaxWriteThreads(1);
        config.setMaxLatency(100000l, TimeUnit.MILLISECONDS);
View Full Code Here

    conf.set(AccumuloConnectionParameters.INSTANCE_NAME, miniCluster.getInstanceName());
  }

  protected void createAccumuloTable(Connector conn) throws TableExistsException,
      TableNotFoundException, AccumuloException, AccumuloSecurityException {
    TableOperations tops = conn.tableOperations();
    if (tops.exists(TABLE_NAME)) {
      tops.delete(TABLE_NAME);
    }

    tops.create(TABLE_NAME);

    boolean[] booleans = new boolean[] {true, false, true};
    byte [] bytes = new byte [] { Byte.MIN_VALUE, -1, Byte.MAX_VALUE };
    short [] shorts = new short [] { Short.MIN_VALUE, -1, Short.MAX_VALUE };
    int [] ints = new int [] { Integer.MIN_VALUE, -1, Integer.MAX_VALUE };
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.