Package org.apache.accumulo.core.client

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


  String indexTableName;
 
  @Override
  public void setUp(State state) throws Exception {
   
    Connector conn = state.getConnector();
    Instance instance = state.getInstance();
   
    SortedSet<Text> splits = new TreeSet<Text>();
    for (int i = 1; i < 256; i++) {
      splits.add(new Text(String.format("%04x", i << 8)));
    }
   
    String hostname = InetAddress.getLocalHost().getHostName().replaceAll("[-.]", "_");
    String pid = state.getPid();
   
    imageTableName = String.format("img_%s_%s_%d", hostname, pid, System.currentTimeMillis());
    state.set("imageTableName", imageTableName);
   
    indexTableName = String.format("img_ndx_%s_%s_%d", hostname, pid, System.currentTimeMillis());
    state.set("indexTableName", indexTableName);
   
    try {
      conn.tableOperations().create(imageTableName);
      conn.tableOperations().addSplits(imageTableName, splits);
      log.debug("Created table " + imageTableName + " (id:" + Tables.getNameToIdMap(instance).get(imageTableName) + ")");
    } catch (TableExistsException e) {
      log.error("Table " + imageTableName + " already exists.");
      throw e;
    }
   
    try {
      conn.tableOperations().create(indexTableName);
      log.debug("Created table " + indexTableName + " (id:" + Tables.getNameToIdMap(instance).get(indexTableName) + ")");
    } catch (TableExistsException e) {
      log.error("Table " + imageTableName + " already exists.");
      throw e;
    }
   
    Random rand = new Random();
    if (rand.nextInt(10) < 5) {
      // setup locality groups
      Map<String,Set<Text>> groups = getLocalityGroups();
     
      conn.tableOperations().setLocalityGroups(imageTableName, groups);
      log.debug("Configured locality groups for " + imageTableName + " groups = " + groups);
    }
   
    state.set("numWrites", Long.valueOf(0));
    state.set("totalWrites", Long.valueOf(0));
View Full Code Here


      // verify that the test is being run by root
      verifyHasOnlyTheseSystemPermissions(getConnector(), getConnector().whoami(), SystemPermission.values());
     
      // create the test user
      getConnector().securityOperations().createLocalUser(TEST_USER, TEST_PASS);
      Connector test_user_conn = getInstance().getConnector(TEST_USER, TEST_PASS);
      verifyHasNoSystemPermissions(getConnector(), TEST_USER, SystemPermission.values());
     
      // test each permission
      for (SystemPermission perm : SystemPermission.values()) {
        log.debug("Verifying the " + perm + " permission");
View Full Code Here

   
    @Override
    public void run() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException, MutationsRejectedException {
      // create the test user
      getConnector().securityOperations().createLocalUser(TEST_USER, TEST_PASS);
      Connector test_user_conn = getInstance().getConnector(TEST_USER, TEST_PASS);
     
      // check for read-only access to metadata table
      verifyHasOnlyTheseTablePermissions(getConnector(), getConnector().whoami(), Constants.METADATA_TABLE_NAME, TablePermission.READ,
          TablePermission.ALTER_TABLE);
      verifyHasOnlyTheseTablePermissions(getConnector(), TEST_USER, Constants.METADATA_TABLE_NAME, TablePermission.READ);
View Full Code Here

   
    long reserved = Utils.reserveTable(tableInfo.tableID, tid, false, true, TableOperation.EXPORT);
    if (reserved > 0)
      return reserved;
   
    Connector conn = master.getConnector();
   
    checkOffline(conn);
   
    Scanner metaScanner = conn.createScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS);
    metaScanner.setRange(new KeyExtent(new Text(tableInfo.tableID), null, null).toMetadataRange());
   
    // scan for locations
    metaScanner.fetchColumnFamily(Constants.METADATA_CURRENT_LOCATION_COLUMN_FAMILY);
    metaScanner.fetchColumnFamily(Constants.METADATA_FUTURE_LOCATION_COLUMN_FAMILY);
View Full Code Here

    return 0;
  }
 
  @Override
  public Repo<Master> call(long tid, Master master) throws Exception {
    Connector conn = master.getConnector();
   
    try {
      exportTable(master.getFileSystem(), conn, tableInfo.tableName, tableInfo.tableID, tableInfo.exportDir);
    } catch (IOException ioe) {
      throw new ThriftTableOperationException(tableInfo.tableID, tableInfo.tableName, TableOperation.EXPORT, TableOperationExceptionType.OTHER,
View Full Code Here

    for (int i = 0; i < 9 && !success; i++) {
      try {
        exec("insert a b c d -l foo", false, "does not have authorization", true, new ErrorMessageCallback() {
          public String getErrorMessage() {
            try {
              Connector c = new ZooKeeperInstance(cluster.getInstanceName(), cluster.getZooKeepers()).getConnector("root", new PasswordToken(secret));
              return "Current auths for root are: " + c.securityOperations().getUserAuthorizations("root").toString();
            } catch (Exception e) {
              return "Could not check authorizations";
            }
          }
        });
        success = true;
      } catch (AssertionError e) {
        Thread.sleep(200);
      }
    }
    // If we still couldn't do it, try again and let it fail
    if (!success) {
      exec("insert a b c d -l foo", false, "does not have authorization", true, new ErrorMessageCallback() {
        public String getErrorMessage() {
          try {
            Connector c = new ZooKeeperInstance(cluster.getInstanceName(), cluster.getZooKeepers()).getConnector("root", new PasswordToken(secret));
            return "Current auths for root are: " + c.securityOperations().getUserAuthorizations("root").toString();
          } catch (Exception e) {
            return "Could not check authorizations";
          }
        }
      });
View Full Code Here

    for (int i = 0; i < 6; i++) {
      exec("insert " + i + " cf cq value", true);
    }

    ZooKeeperInstance instance = new ZooKeeperInstance(cluster.getInstanceName(), cluster.getZooKeepers());
    Connector connector = instance.getConnector("root", new PasswordToken(secret));
    final Scanner s = connector.createScanner(table, Constants.NO_AUTHS);
    IteratorSetting cfg = new IteratorSetting(30, SlowIterator.class);
    cfg.addOption("sleepTime", "500");
    s.addScanIterator(cfg);

    Thread thread = new Thread() {
View Full Code Here

    return getFiles(tableId).size();
  }
 
  private String getTableId(String tableName) throws Exception {
    ZooKeeperInstance zki = new ZooKeeperInstance(cluster.getInstanceName(), cluster.getZooKeepers());
    Connector conn = zki.getConnector("root", new PasswordToken(secret));
   
    for (int i = 0; i < 5; i++) {
      Map<String,String> nameToId = conn.tableOperations().tableIdMap();
      if (nameToId.containsKey(tableName)) {
        return nameToId.get(tableName);
      } else {
        Thread.sleep(1000);
      }
View Full Code Here

    if (opts.seed == null)
      r = new Random();
    else {
      r = new Random(opts.seed);
    }
    Connector connector = opts.getConnector();
    BatchWriter bw = connector.createBatchWriter(opts.tableName, bwOpts.getBatchWriterConfig());
   
    // reuse the ColumnVisibility object to improve performance
    ColumnVisibility cv = opts.visiblity;
  
    // Generate num unique row ids in the given range
View Full Code Here

  Iterator<Entry<Key,Value>> iter;
 
  public MetaDataTableScanner(Instance instance, TCredentials auths, Range range, CurrentState state) {
    // scan over metadata table, looking for tablets in the wrong state based on the live servers and online tables
    try {
      Connector connector = instance.getConnector(auths.getPrincipal(), CredentialHelper.extractToken(auths));
      mdScanner = connector.createBatchScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS, 8);
      configureScanner(mdScanner, state);
      mdScanner.setRanges(Collections.singletonList(range));
      iter = mdScanner.iterator();
    } catch (Exception ex) {
      mdScanner.close();
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.client.Connector

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.