當前位置: 首頁>>代碼示例>>Java>>正文


Java TableName類代碼示例

本文整理匯總了Java中org.apache.hadoop.hbase.TableName的典型用法代碼示例。如果您正苦於以下問題:Java TableName類的具體用法?Java TableName怎麽用?Java TableName使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TableName類屬於org.apache.hadoop.hbase包,在下文中一共展示了TableName類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testCreateTableCalledTwiceAndFirstOneInProgress

import org.apache.hadoop.hbase.TableName; //導入依賴的package包/類
@Test (timeout=300000)
public void testCreateTableCalledTwiceAndFirstOneInProgress() throws Exception {
  final TableName tableName = TableName.valueOf("testCreateTableCalledTwiceAndFirstOneInProgress");
  final MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
  final HMaster m = cluster.getMaster();
  final HTableDescriptor desc = new HTableDescriptor(tableName);
  desc.addFamily(new HColumnDescriptor(FAMILYNAME));
  final HRegionInfo[] hRegionInfos = new HRegionInfo[] { new HRegionInfo(desc.getTableName(), null,
      null) };
  CustomCreateTableHandler handler = new CustomCreateTableHandler(m, m.getMasterFileSystem(),
      desc, cluster.getConfiguration(), hRegionInfos, m);
  handler.prepare();
  throwException = true;
  handler.process();
  throwException = false;
  CustomCreateTableHandler handler1 = new CustomCreateTableHandler(m, m.getMasterFileSystem(),
      desc, cluster.getConfiguration(), hRegionInfos, m);
  handler1.prepare();
  handler1.process();
  for (int i = 0; i < 100; i++) {
    if (!TEST_UTIL.getHBaseAdmin().isTableAvailable(tableName)) {
      Thread.sleep(200);
    }
  }
  assertTrue(TEST_UTIL.getHBaseAdmin().isTableEnabled(tableName));
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:27,代碼來源:TestCreateTableHandler.java

示例2: disableTable

import org.apache.hadoop.hbase.TableName; //導入依賴的package包/類
public void disableTable(Connection connection, TableName tableName) throws IOException {
    Admin admin = null;
    try {
        admin = connection.getAdmin();
        if(admin.tableExists(tableName)){
            admin.disableTable(tableName);
        }
    } finally {
        if(admin!=null) {
            admin.close();
        }
    }
}
 
開發者ID:TFdream,項目名稱:hbase-tutorials,代碼行數:14,代碼來源:HBaseCrudDemo.java

示例3: preStoreScannerOpen

import org.apache.hadoop.hbase.TableName; //導入依賴的package包/類
@Override
public KeyValueScanner preStoreScannerOpen(
    final ObserverContext<RegionCoprocessorEnvironment> c, Store store, final Scan scan,
    final NavigableSet<byte[]> targetCols, KeyValueScanner s) throws IOException {
  TableName tn = store.getTableName();
  if (!tn.isSystemTable()) {
    Long newTtl = ttls.get(store.getTableName());
    Integer newVersions = versions.get(store.getTableName());
    ScanInfo oldSI = store.getScanInfo();
    HColumnDescriptor family = store.getFamily();
    ScanInfo scanInfo = new ScanInfo(TEST_UTIL.getConfiguration(),
        family.getName(), family.getMinVersions(),
        newVersions == null ? family.getMaxVersions() : newVersions,
        newTtl == null ? oldSI.getTtl() : newTtl, family.getKeepDeletedCells(),
        oldSI.getTimeToPurgeDeletes(), oldSI.getComparator());
    return new StoreScanner(store, scanInfo, scan, targetCols,
        ((HStore) store).getHRegion().getReadpoint(IsolationLevel.READ_COMMITTED));
  } else {
    return s;
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:22,代碼來源:TestCoprocessorScanPolicy.java

示例4: postModifyTable

import org.apache.hadoop.hbase.TableName; //導入依賴的package包/類
@Override
public void postModifyTable(ObserverContext<MasterCoprocessorEnvironment> c,
    TableName tableName, final HTableDescriptor htd) throws IOException {
  final Configuration conf = c.getEnvironment().getConfiguration();
  // default the table owner to current user, if not specified.
  final String owner = (htd.getOwnerString() != null) ? htd.getOwnerString() :
    getActiveUser().getShortName();
  User.runAsLoginUser(new PrivilegedExceptionAction<Void>() {
    @Override
    public Void run() throws Exception {
      UserPermission userperm = new UserPermission(Bytes.toBytes(owner),
        htd.getTableName(), null, Action.values());
      AccessControlLists.addUserPermission(conf, userperm);
      return null;
    }
  });
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:18,代碼來源:AccessController.java

示例5: createColumnFamily

import org.apache.hadoop.hbase.TableName; //導入依賴的package包/類
private void createColumnFamily(HColumnDescriptor family, TableName table)
    throws IOException {
  try {
    admin.addColumn(table, family);
  } catch (InvalidFamilyOperationException e) {
    if (!hasFamily(family, table)) {
      //Schroedinger's cat: InvalidFamilyOperationException (cf exists) but does not exist at the same time
      throw new IllegalStateException("Column family should exist but does not", e);
    }
    //columnFamily was created in the meantime
    return;
  }
  waitForColumnFamilyCreation(family, table);
  log.info("Created column family '{}' in HBase table '{}'", family.getNameAsString(),
      table.getNameAsString());
}
 
開發者ID:bakdata,項目名稱:ignite-hbase,代碼行數:17,代碼來源:AdminContext.java

示例6: parseStatString

import org.apache.hadoop.hbase.TableName; //導入依賴的package包/類
/**
 * create map based on statDesc
 * 1. for set, "family qualifier DataType set [v1] [v2] [...]"
 * 2. for array, "family qualifier DataType min max parts"
 */
public static Map<TableName, LCStatInfo2> parseStatString(IndexTableRelation indexTableRelation,
    String statDesc) throws IOException {
  Map<TableName, LCStatInfo2> map = new HashMap<>();
  String[] lines = statDesc.split(LC_TABLE_DESC_RANGE_DELIMITER);
  for (String line : lines) {
    String[] parts = line.split("\t");
    byte[] family = Bytes.toBytes(parts[0]);
    byte[] qualifier = Bytes.toBytes(parts[1]);
    TableName tableName = indexTableRelation.getIndexTableName(family, qualifier);
    LCStatInfo2 statInfo;
    try {
      if ("set".equalsIgnoreCase(parts[3])) {
        statInfo = new LCStatInfo2(family, qualifier, DataType.valueOf(parts[2]), parts, 4);
      } else {
        statInfo = new LCStatInfo2(family, qualifier, DataType.valueOf(parts[2]),
            Integer.valueOf(parts[5]), parts[3], parts[4]);
      }
    } catch (IOException e) {
      throw new IOException("exception for parsing line: " + line, e);
    }
    map.put(tableName, statInfo);
  }
  return map;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:30,代碼來源:LCStatInfo2.java

示例7: HBaseEventStoreTable

import org.apache.hadoop.hbase.TableName; //導入依賴的package包/類
/**
 * Private constructor
 */
private HBaseEventStoreTable(final EventStoreTimeIntervalEnum timeInterval,
                             final StroomPropertyService propertyService,
                             final HBaseConnection hBaseConnection,
                             final UniqueIdCache uniqueIdCache,
                             final StatisticDataPointAdapterFactory statisticDataPointAdapterFactory) {
    super(hBaseConnection);
    this.displayName = timeInterval.longName() + DISPLAY_NAME_POSTFIX;
    this.tableName = TableName.valueOf(Bytes.toBytes(timeInterval.shortName() + TABLE_NAME_POSTFIX));
    this.timeInterval = timeInterval;
    this.propertyService = propertyService;
    this.rowKeyBuilder = new SimpleRowKeyBuilder(uniqueIdCache, timeInterval);
    this.statisticDataPointAdapterFactory = statisticDataPointAdapterFactory;

    for (StatisticType statisticType : StatisticType.values()) {
        putCounterMap.put(statisticType, new LongAdder());
    }

    init();
}
 
開發者ID:gchq,項目名稱:stroom-stats,代碼行數:23,代碼來源:HBaseEventStoreTable.java

示例8: parsePut

import org.apache.hadoop.hbase.TableName; //導入依賴的package包/類
@Override protected Map<TableName, Put> parsePut(Put put, boolean serverSide) {
  Map<TableName, Put> map = new HashMap<>();
  byte[] row = put.getRow();
  for (Map.Entry<byte[], List<Cell>> entry : put.getFamilyCellMap().entrySet()) {
    byte[] family = entry.getKey();
    for (Cell cell : entry.getValue()) {
      byte[] q = CellUtil.cloneQualifier(cell);
      if (tableRelation.isIndexColumn(family, q)) {
        TableName indexTableName = tableRelation.getIndexTableName(family, q);
        Put newPut = new Put(getIndexRow(row, CellUtil.cloneValue(cell)));
        if (serverSide) newPut
            .addColumn(IndexType.SEDONDARY_FAMILY_BYTES, (byte[]) null, cell.getTimestamp(),
                null);
        else newPut.addColumn(IndexType.SEDONDARY_FAMILY_BYTES, null, null);
        map.put(indexTableName, newPut);
      }
    }
  }
  tableRelation.getIndexFamilyMap();
  return map;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:22,代碼來源:IndexPutParser.java

示例9: createTableAndWriteDataWithLabels

import org.apache.hadoop.hbase.TableName; //導入依賴的package包/類
private static Table createTableAndWriteDataWithLabels(TableName tableName, String... labelExps)
    throws Exception {
  Table table = null;
  try {
    table = TEST_UTIL.createTable(tableName, fam);
    int i = 1;
    List<Put> puts = new ArrayList<Put>();
    for (String labelExp : labelExps) {
      Put put = new Put(Bytes.toBytes("row" + i));
      put.add(fam, qual, HConstants.LATEST_TIMESTAMP, value);
      put.setCellVisibility(new CellVisibility(labelExp));
      puts.add(put);
      i++;
    }
    table.put(puts);
  } finally {
    if (table != null) {
      table.close();
    }
  }
  return table;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:23,代碼來源:TestVisibilityLabelsWithACL.java

示例10: setup

import org.apache.hadoop.hbase.TableName; //導入依賴的package包/類
@Override
public void setup(Context context) throws IOException {
  conf = context.getConfiguration();
  recordsToWrite = conf.getLong(NUM_TO_WRITE_KEY, NUM_TO_WRITE_DEFAULT);
  String tableName = conf.get(TABLE_NAME_KEY, TABLE_NAME_DEFAULT);
  numBackReferencesPerRow = conf.getInt(NUM_BACKREFS_KEY, NUM_BACKREFS_DEFAULT);
  this.connection = ConnectionFactory.createConnection(conf);
  mutator = connection.getBufferedMutator(
      new BufferedMutatorParams(TableName.valueOf(tableName))
          .writeBufferSize(4 * 1024 * 1024));

  String taskId = conf.get("mapreduce.task.attempt.id");
  Matcher matcher = Pattern.compile(".+_m_(\\d+_\\d+)").matcher(taskId);
  if (!matcher.matches()) {
    throw new RuntimeException("Strange task ID: " + taskId);
  }
  shortTaskId = matcher.group(1);

  rowsWritten = context.getCounter(Counters.ROWS_WRITTEN);
  refsWritten = context.getCounter(Counters.REFERENCES_WRITTEN);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:22,代碼來源:IntegrationTestLoadAndVerify.java

示例11: testMaxKeyValueSize

import org.apache.hadoop.hbase.TableName; //導入依賴的package包/類
@Test
public void testMaxKeyValueSize() throws Exception {
  byte [] TABLE = Bytes.toBytes("testMaxKeyValueSize");
  Configuration conf = TEST_UTIL.getConfiguration();
  String oldMaxSize = conf.get(ConnectionConfiguration.MAX_KEYVALUE_SIZE_KEY);
  Table ht = TEST_UTIL.createTable(TABLE, FAMILY);
  byte[] value = new byte[4 * 1024 * 1024];
  Put put = new Put(ROW);
  put.add(FAMILY, QUALIFIER, value);
  ht.put(put);
  try {
    TEST_UTIL.getConfiguration().setInt(
        ConnectionConfiguration.MAX_KEYVALUE_SIZE_KEY, 2 * 1024 * 1024);
    // Create new table so we pick up the change in Configuration.
    try (Connection connection =
        ConnectionFactory.createConnection(TEST_UTIL.getConfiguration())) {
      try (Table t = connection.getTable(TableName.valueOf(FAMILY))) {
        put = new Put(ROW);
        put.add(FAMILY, QUALIFIER, value);
        t.put(put);
      }
    }
    fail("Inserting a too large KeyValue worked, should throw exception");
  } catch(Exception e) {}
  conf.set(ConnectionConfiguration.MAX_KEYVALUE_SIZE_KEY, oldMaxSize);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:27,代碼來源:TestFromClientSide.java

示例12: grantOnTableUsingAccessControlClient

import org.apache.hadoop.hbase.TableName; //導入依賴的package包/類
/**
 * Grant permissions on a table to the given user using AccessControlClient. Will wait until all
 * active AccessController instances have updated their permissions caches or will
 * throw an exception upon timeout (10 seconds).
 */
public static void grantOnTableUsingAccessControlClient(final HBaseTestingUtility util,
    final Connection connection, final String user, final TableName table, final byte[] family,
    final byte[] qualifier, final Permission.Action... actions) throws Exception {
  SecureTestUtil.updateACLs(util, new Callable<Void>() {
    @Override
    public Void call() throws Exception {
      try {
        AccessControlClient.grant(connection, table, user, family, qualifier, actions);
      } catch (Throwable t) {
        t.printStackTrace();
      }
      return null;
    }
  });
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:21,代碼來源:SecureTestUtil.java

示例13: assignRegions

import org.apache.hadoop.hbase.TableName; //導入依賴的package包/類
protected static void assignRegions(final MasterProcedureEnv env,
    final TableName tableName, final List<HRegionInfo> regions)
    throws HBaseException, IOException {
  ProcedureSyncWait.waitRegionServers(env);

  final AssignmentManager assignmentManager = env.getMasterServices().getAssignmentManager();

  // Mark the table as Enabling
  assignmentManager.getTableStateManager().setTableState(tableName,
      ZooKeeperProtos.Table.State.ENABLING);

  // Trigger immediate assignment of the regions in round-robin fashion
  ModifyRegionUtils.assignRegions(assignmentManager, regions);

  // Enable table
  assignmentManager.getTableStateManager()
    .setTableState(tableName, ZooKeeperProtos.Table.State.ENABLED);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:19,代碼來源:CreateTableProcedure.java

示例14: createTable

import org.apache.hadoop.hbase.TableName; //導入依賴的package包/類
private void createTable(Admin admin, TableName tableName, boolean setVersion,
    boolean acl) throws IOException {
  if (!admin.tableExists(tableName)) {
    HTableDescriptor htd = new HTableDescriptor(tableName);
    HColumnDescriptor family = new HColumnDescriptor(FAMILY_NAME);
    if (setVersion) {
      family.setMaxVersions(DEFAULT_TABLES_COUNT);
    }
    htd.addFamily(family);
    admin.createTable(htd);
    if (acl) {
      LOG.info("Granting permissions for user " + USER.getShortName());
      Permission.Action[] actions = { Permission.Action.READ };
      try {
        AccessControlClient.grant(ConnectionFactory.createConnection(getConf()), tableName,
            USER.getShortName(), null, null, actions);
      } catch (Throwable e) {
        LOG.fatal("Error in granting permission for the user " + USER.getShortName(), e);
        throw new IOException(e);
      }
    }
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:24,代碼來源:IntegrationTestBigLinkedListWithVisibility.java

示例15: find

import org.apache.hadoop.hbase.TableName; //導入依賴的package包/類
@Override
public <T> List<T> find(TableName tableName, final List<Scan> scanList, final
ResultsExtractor<T> action) {
    assertAccessAvailable();
    return execute(tableName, new TableCallback<List<T>>() {
        @Override
        public List<T> doInTable(Table table) throws Throwable {
            List<T> result = new ArrayList<>(scanList.size());
            for (Scan scan : scanList) {
                final ResultScanner scanner = table.getScanner(scan);
                try {
                    T t = action.extractData(scanner);
                    result.add(t);
                } finally {
                    scanner.close();
                }
            }
            return result;
        }
    });
}
 
開發者ID:fchenxi,項目名稱:easyhbase,代碼行數:22,代碼來源:HbaseTemplate2.java


注:本文中的org.apache.hadoop.hbase.TableName類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。