当前位置: 首页>>代码示例>>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;未经允许,请勿转载。