Package org.apache.accumulo.core.client

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


      writer.putPersistentData(ZooUtil.getRoot(instance) + "/" + type + "/" + tid, new byte[] {}, NodeExistsPolicy.OVERWRITE);
      writer.putPersistentData(ZooUtil.getRoot(instance) + "/" + type + "/" + tid + "-running", new byte[] {}, NodeExistsPolicy.OVERWRITE);
    }
   
    public static void stop(String type, long tid) throws KeeperException, InterruptedException {
      Instance instance = HdfsZooInstance.getInstance();
      IZooReaderWriter writer = ZooReaderWriter.getInstance();
      writer.recursiveDelete(ZooUtil.getRoot(instance) + "/" + type + "/" + tid, NodeMissingPolicy.SKIP);
    }
View Full Code Here


      IZooReaderWriter writer = ZooReaderWriter.getInstance();
      writer.recursiveDelete(ZooUtil.getRoot(instance) + "/" + type + "/" + tid, NodeMissingPolicy.SKIP);
    }
   
    public static void cleanup(String type, long tid) throws KeeperException, InterruptedException {
      Instance instance = HdfsZooInstance.getInstance();
      IZooReaderWriter writer = ZooReaderWriter.getInstance();
      writer.recursiveDelete(ZooUtil.getRoot(instance) + "/" + type + "/" + tid, NodeMissingPolicy.SKIP);
      writer.recursiveDelete(ZooUtil.getRoot(instance) + "/" + type + "/" + tid + "-running", NodeMissingPolicy.SKIP);
    }
View Full Code Here

   *           if the table name set on the configuration doesn't exist
   */
  protected static TabletLocator getTabletLocator(Configuration conf) throws TableNotFoundException {
    if (conf.getBoolean(MOCK, false))
      return new MockTabletLocator();
    Instance instance = getInstance(conf);
    String username = getUsername(conf);
    byte[] password = getPassword(conf);
    String tableName = getTablename(conf);
    return TabletLocator.getInstance(instance, new AuthInfo(username, ByteBuffer.wrap(password), instance.getInstanceID()),
        new Text(Tables.getTableId(instance, tableName)));
  }
View Full Code Here

  Map<String,Map<KeyExtent,List<Range>>> binOfflineTable(JobContext job, String tableName, List<Range> ranges) throws TableNotFoundException,
      AccumuloException, AccumuloSecurityException {

    Map<String,Map<KeyExtent,List<Range>>> binnedRanges = new HashMap<String,Map<KeyExtent,List<Range>>>();

    Instance instance = getInstance(InputFormatBase.getConfiguration(job));
    Connector conn = instance.getConnector(getUsername(InputFormatBase.getConfiguration(job)), getPassword(InputFormatBase.getConfiguration(job)));
    String tableId = Tables.getTableId(instance, tableName);

    if (Tables.getTableState(instance, tableId) != TableState.OFFLINE) {
      Tables.clearCache(instance);
      if (Tables.getTableState(instance, tableId) != TableState.OFFLINE) {
View Full Code Here

        .get(VALUE_REGEX);
    Set<Pair<Text,Text>> fetchedColumns = getFetchedColumns(conf);
    Authorizations auths = getAuthorizations(conf);
    byte[] password = getPassword(conf);
    String username = getUsername(conf);
    Instance instance = getInstance(conf);
    List<AccumuloIterator> iterators = getIterators(conf);
    List<AccumuloIteratorOption> options = getIteratorOptions(conf);
    Level logLevel = getLogLevel(conf);

    if (ranges.isEmpty()) {
      ranges = new ArrayList<Range>(1);
      ranges.add(new Range());
    }

    // get the metadata information for these ranges
    Map<String,Map<KeyExtent,List<Range>>> binnedRanges = new HashMap<String,Map<KeyExtent,List<Range>>>();
    TabletLocator tl;
    try {
      if (isOfflineScan(InputFormatBase.getConfiguration(job))) {
        binnedRanges = binOfflineTable(job, tableName, ranges);
        while (binnedRanges == null) {
          // Some tablets were still online, try again
          UtilWaitThread.sleep(100 + (int) (Math.random() * 100)); // sleep randomly between 100 and 200 ms
          binnedRanges = binOfflineTable(job, tableName, ranges);
        }
      } else {
        String tableId = null;
        tl = getTabletLocator(InputFormatBase.getConfiguration(job));
        // its possible that the cache could contain complete, but old information about a tables tablets... so clear it
        tl.invalidateCache();
        while (!tl.binRanges(ranges, binnedRanges).isEmpty()) {
          if (!(instance instanceof MockInstance)) {
            if (tableId == null)
              tableId = Tables.getTableId(instance, tableName);
            if (!Tables.exists(instance, tableId))
              throw new TableDeletedException(tableId);
            if (Tables.getTableState(instance, tableId) == TableState.OFFLINE)
              throw new TableOfflineException(instance, tableId);
          }
          binnedRanges.clear();
          log.warn("Unable to locate bins for specified ranges. Retrying.");
          UtilWaitThread.sleep(100 + (int) (Math.random() * 100)); // sleep randomly between 100 and 200 ms
          tl.invalidateCache();
        }
      }
    } catch (Exception e) {
      throw new IOException(e);
    }

    ArrayList<InputSplit> splits = new ArrayList<InputSplit>(ranges.size());
    HashMap<Range,ArrayList<String>> splitsToAdd = null;

    if (!autoAdjust)
      splitsToAdd = new HashMap<Range,ArrayList<String>>();

    HashMap<String,String> hostNameCache = new HashMap<String,String>();

    for (Entry<String,Map<KeyExtent,List<Range>>> tserverBin : binnedRanges.entrySet()) {
      String ip = tserverBin.getKey().split(":", 2)[0];
      String location = hostNameCache.get(ip);
      if (location == null) {
        InetAddress inetAddress = InetAddress.getByName(ip);
        location = inetAddress.getHostName();
        hostNameCache.put(ip, location);
      }

      for (Entry<KeyExtent,List<Range>> extentRanges : tserverBin.getValue().entrySet()) {
        Range ke = extentRanges.getKey().toDataRange();
        for (Range r : extentRanges.getValue()) {
          if (autoAdjust) {
            // divide ranges into smaller ranges, based on the
            // tablets
            splits.add(new RangeInputSplit(ke.clip(r), new String[] {location}));
          } else {
            // don't divide ranges
            ArrayList<String> locations = splitsToAdd.get(r);
            if (locations == null)
              locations = new ArrayList<String>(1);
            locations.add(location);
            splitsToAdd.put(r, locations);
          }
        }
      }
    }

    if (!autoAdjust)
      for (Entry<Range,ArrayList<String>> entry : splitsToAdd.entrySet())
        splits.add(new RangeInputSplit(entry.getKey(), entry.getValue().toArray(new String[0])));

    for (InputSplit inputSplit : splits) {
      RangeInputSplit split = (RangeInputSplit) inputSplit;

      split.setTable(tableName);
      split.setOffline(offline);
      split.setIsolatedScan(isolated);
      split.setUsesLocalIterators(localIterators);
      split.setMockInstance(mockInstance);
      split.setMaxVersions(maxVersions);
      split.setRowRegex(rowRegex);
      split.setColfamRegex(colfamRegex);
      split.setColqualRegex(colqualRegex);
      split.setValueRegex(valueRegex);
      split.setFetchedColumns(fetchedColumns);
      split.setUsername(username);
      split.setPassword(password);
      split.setInstanceName(instance.getInstanceName());
      split.setZooKeepers(instance.getZooKeepers());
      split.setAuths(auths);
      split.setIterators(iterators);
      split.setOptions(options);
      split.setLogLevel(logLevel);
    }
View Full Code Here

  /**
   * @deprecated not for client use
   */
  @Deprecated
  private static ZooCache getTablePropCache() {
    Instance inst = HdfsZooInstance.getInstance();
    if (tablePropCache == null)
      synchronized (TableConfiguration.class) {
        if (tablePropCache == null)
          tablePropCache = new ZooCache(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut(), new TableConfWatcher(inst.getInstanceID()));
      }
    return tablePropCache;
  }
View Full Code Here

   */
  public static TabletLocator getTabletLocator(Class<?> implementingClass, Configuration conf) throws TableNotFoundException {
    String instanceType = conf.get(enumToConfKey(implementingClass, InstanceOpts.TYPE));
    if ("MockInstance".equals(instanceType))
      return new MockTabletLocator();
    Instance instance = getInstance(implementingClass, conf);
    String tableName = getInputTableName(implementingClass, conf);
    return TabletLocator.getInstance(instance, new Text(Tables.getTableId(instance, tableName)));
  }
View Full Code Here

        case ALTER_TABLE:
          tableName = "__ALTER_TABLE_WITH_PERM_TEST__";
          String table2 = tableName + "2";
          root_conn.tableOperations().create(tableName);
          tableId = Tables.getNameToIdMap(root_conn.getInstance()).get(tableName);
          Instance instance = root_conn.getInstance();
          test_user_conn.tableOperations().setProperty(tableName, Property.TABLE_BLOOM_ERRORRATE.getKey(), "003.14159%");
          if (!ServerConfiguration.getTableConfiguration(instance, tableId).get(Property.TABLE_BLOOM_ERRORRATE).equals("003.14159%"))
            throw new IllegalStateException("Should be able to set a table property");
          test_user_conn.tableOperations().removeProperty(tableName, Property.TABLE_BLOOM_ERRORRATE.getKey());
          if (ServerConfiguration.getTableConfiguration(instance, tableId).get(Property.TABLE_BLOOM_ERRORRATE).equals("003.14159%"))
View Full Code Here

 
  public static void main(String[] args) throws Exception {
    final Logger log = Logger.getLogger(ZombieTServer.class);
    Random random = new Random(System.currentTimeMillis() % 1000);
    int port = random.nextInt(30000) + 2000;
    Instance instance = HdfsZooInstance.getInstance();
   
    TransactionWatcher watcher = new TransactionWatcher();
    final ThriftClientHandler tch = new ThriftClientHandler(instance, watcher);
    Processor<Iface> processor = new Processor<Iface>(tch);
    ServerPort serverPort = TServerUtils.startTServer(port, processor, "ZombieTServer", "walking dead", 2, 1000, 10*1024*1024);
 
View Full Code Here

  }
 
  @Test
  public void testMockConnectorReturnsCorrectInstance() throws AccumuloException, AccumuloSecurityException {
    String name = "an-interesting-instance-name";
    Instance mockInstance = new MockInstance(name);
    assertEquals(mockInstance, mockInstance.getConnector("foo", new PasswordToken("bar")).getInstance());
    assertEquals(name, mockInstance.getConnector("foo", new PasswordToken("bar")).getInstance().getInstanceName());
  }
View Full Code Here

TOP

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

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.