当前位置: 首页>>代码示例>>Java>>正文


Java TableExistsException类代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.TableExistsException的典型用法代码示例。如果您正苦于以下问题:Java TableExistsException类的具体用法?Java TableExistsException怎么用?Java TableExistsException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TableExistsException类属于org.apache.hadoop.hbase包,在下文中一共展示了TableExistsException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepareCreate

import org.apache.hadoop.hbase.TableExistsException; //导入依赖的package包/类
private boolean prepareCreate(final MasterProcedureEnv env) throws IOException {
  final TableName tableName = getTableName();
  if (MetaTableAccessor.tableExists(env.getMasterServices().getConnection(), tableName)) {
    setFailure("master-create-table", new TableExistsException(getTableName()));
    return false;
  }
  // During master initialization, the ZK state could be inconsistent from failed DDL
  // in the past. If we fail here, it would prevent master to start.  We should force
  // setting the system table state regardless the table state.
  boolean skipTableStateCheck =
      !(env.getMasterServices().isInitialized()) && tableName.isSystemTable();
  if (!skipTableStateCheck) {
    TableStateManager tsm = env.getMasterServices().getAssignmentManager().getTableStateManager();
    if (tsm.isTableState(tableName, true, ZooKeeperProtos.Table.State.ENABLING,
        ZooKeeperProtos.Table.State.ENABLED)) {
      LOG.warn("The table " + tableName + " does not exist in meta but has a znode. " +
             "run hbck to fix inconsistencies.");
      setFailure("master-create-table", new TableExistsException(getTableName()));
      return false;
    }
  }
  return true;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:24,代码来源:CreateTableProcedure.java

示例2: testCreateExisting

import org.apache.hadoop.hbase.TableExistsException; //导入依赖的package包/类
@Test(timeout=60000, expected=TableExistsException.class)
public void testCreateExisting() throws Exception {
  final TableName tableName = TableName.valueOf("testCreateExisting");
  final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
  final HTableDescriptor htd = MasterProcedureTestingUtility.createHTD(tableName, "f");
  final HRegionInfo[] regions = ModifyRegionUtils.createHRegionInfos(htd, null);

  // create the table
  long procId1 = procExec.submitProcedure(
    new CreateTableProcedure(procExec.getEnvironment(), htd, regions), nonceGroup, nonce);

  // create another with the same name
  ProcedurePrepareLatch latch2 = new ProcedurePrepareLatch.CompatibilityLatch();
  long procId2 = procExec.submitProcedure(
    new CreateTableProcedure(procExec.getEnvironment(), htd, regions, latch2),
    nonceGroup + 1,
    nonce + 1);

  ProcedureTestingUtility.waitProcedure(procExec, procId1);
  ProcedureTestingUtility.assertProcNotFailed(procExec.getResult(procId1));

  ProcedureTestingUtility.waitProcedure(procExec, procId2);
  latch2.await();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:25,代码来源:TestCreateTableProcedure.java

示例3: setupTable

import org.apache.hadoop.hbase.TableExistsException; //导入依赖的package包/类
/**
 * Creates a table with given table name and specified number of column
 * families if the table does not already exist.
 */
private void setupTable(final Connection connection, TableName table, int cfs)
throws IOException {
  try {
    LOG.info("Creating table " + table);
    HTableDescriptor htd = new HTableDescriptor(table);
    for (int i = 0; i < cfs; i++) {
      htd.addFamily(new HColumnDescriptor(family(i)));
    }
    try (Admin admin = connection.getAdmin()) {
      admin.createTable(htd);
    }
  } catch (TableExistsException tee) {
    LOG.info("Table " + table + " already exists");
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:TestLoadIncrementalHFilesSplitRecovery.java

示例4: create

import org.apache.hadoop.hbase.TableExistsException; //导入依赖的package包/类
public static void create() throws Exception {
	HBaseAdmin admin = new HBaseAdmin(cfg);
	if (admin.tableExists(tableName)) {
		System.out.println("[info]table has created!");
	} else {
		try {
			TableName table = TableName.valueOf(tableName);
			HTableDescriptor tableDescriptor = new HTableDescriptor(table);
			tableDescriptor.addFamily(new HColumnDescriptor(familyName));

			admin.createTable(tableDescriptor);
		} catch (TableExistsException e) {
			System.out.println("[warning] table exists!");
		}
	}
	System.out.println("[info]create table success!");
}
 
开发者ID:gglinux,项目名称:wifi,代码行数:18,代码来源:HBaseTable.java

示例5: create

import org.apache.hadoop.hbase.TableExistsException; //导入依赖的package包/类
public static void create() throws Exception
{
	HBaseAdmin admin = new HBaseAdmin(cfg);
	if (admin.tableExists(tableName)) {
		System.out.println("[info]table has created!");
	} else {
		TableName table = TableName.valueOf(tableName);
		HTableDescriptor tableDescriptor = new HTableDescriptor(table);
		tableDescriptor.addFamily(new HColumnDescriptor(familyName));
		try{
			admin.createTable(tableDescriptor);
		}catch(TableExistsException e)
		{
			System.out.println("[warning] table exists!");
		}
	}
	System.out.println("[info]create table success!");
}
 
开发者ID:gglinux,项目名称:wifi,代码行数:19,代码来源:HBaseTable.java

示例6: createPruneTable

import org.apache.hadoop.hbase.TableExistsException; //导入依赖的package包/类
/**
 * Create the prune state table given the {@link TableName} if the table doesn't exist already.
 *
 * @param stateTable prune state table name
 */
protected void createPruneTable(TableName stateTable) throws IOException {
  try (Admin admin = this.connection.getAdmin()) {
    if (admin.tableExists(stateTable)) {
      LOG.debug("Not creating pruneStateTable {} since it already exists.",
                stateTable.getNameWithNamespaceInclAsString());
      return;
    }

    HTableDescriptor htd = new HTableDescriptor(stateTable);
    htd.addFamily(new HColumnDescriptor(DataJanitorState.FAMILY).setMaxVersions(1));
    admin.createTable(htd);
    LOG.info("Created pruneTable {}", stateTable.getNameWithNamespaceInclAsString());
  } catch (TableExistsException ex) {
    // Expected if the prune state table is being created at the same time by another client
    LOG.debug("Not creating pruneStateTable {} since it already exists.",
              stateTable.getNameWithNamespaceInclAsString(), ex);
  }
}
 
开发者ID:apache,项目名称:incubator-tephra,代码行数:24,代码来源:HBaseTransactionPruningPlugin.java

示例7: createPruneTable

import org.apache.hadoop.hbase.TableExistsException; //导入依赖的package包/类
/**
 * Create the prune state table given the {@link TableName} if the table doesn't exist already.
 *
 * @param stateTable prune state table name
 */
protected void createPruneTable(TableName stateTable) throws IOException {
  try {
    if (hBaseAdmin.tableExists(stateTable)) {
      LOG.debug("Not creating pruneStateTable {}:{} since it already exists.",
                stateTable.getNamespaceAsString(), stateTable.getNameAsString());
      return;
    }

    HTableDescriptor htd = new HTableDescriptor(stateTable);
    htd.addFamily(new HColumnDescriptor(DataJanitorState.FAMILY).setMaxVersions(1));
    hBaseAdmin.createTable(htd);
    LOG.info("Created pruneTable {}:{}", stateTable.getNamespaceAsString(), stateTable.getNameAsString());
  } catch (TableExistsException ex) {
    // Expected if the prune state table is being created at the same time by another client
    LOG.debug("Not creating pruneStateTable {}:{} since it already exists.",
              stateTable.getNamespaceAsString(), stateTable.getNameAsString(), ex);
  }
}
 
开发者ID:apache,项目名称:incubator-tephra,代码行数:24,代码来源:HBaseTransactionPruningPlugin.java

示例8: createPruneTable

import org.apache.hadoop.hbase.TableExistsException; //导入依赖的package包/类
/**
 * Create the prune state table given the {@link TableName} if the table doesn't exist already.
 *
 * @param stateTable prune state table name
 */
protected void createPruneTable(TableName stateTable) throws IOException {
  try (Admin admin = this.connection.getAdmin()) {
    if (admin.tableExists(stateTable)) {
      LOG.debug("Not creating pruneStateTable {}:{} since it already exists.",
                stateTable.getNamespaceAsString(), stateTable.getNameAsString());
      return;
    }

    HTableDescriptor htd = new HTableDescriptor(stateTable);
    htd.addFamily(new HColumnDescriptor(DataJanitorState.FAMILY).setMaxVersions(1));
    admin.createTable(htd);
    LOG.info("Created pruneTable {}:{}", stateTable.getNamespaceAsString(), stateTable.getNameAsString());
  } catch (TableExistsException ex) {
    // Expected if the prune state table is being created at the same time by another client
    LOG.debug("Not creating pruneStateTable {}:{} since it already exists.",
              stateTable.getNamespaceAsString(), stateTable.getNameAsString(), ex);
  }
}
 
开发者ID:apache,项目名称:incubator-tephra,代码行数:24,代码来源:HBaseTransactionPruningPlugin.java

示例9: CloneSnapshotHandler

import org.apache.hadoop.hbase.TableExistsException; //导入依赖的package包/类
public CloneSnapshotHandler(final MasterServices masterServices,
    final SnapshotDescription snapshot, final HTableDescriptor hTableDescriptor,
    final MasterMetrics metricsMaster)
    throws NotAllMetaRegionsOnlineException, TableExistsException, IOException {
  super(masterServices, masterServices.getMasterFileSystem(),
    masterServices.getServerManager(), hTableDescriptor,
    masterServices.getConfiguration(), null, masterServices.getCatalogTracker(),
    masterServices.getAssignmentManager());
  this.metricsMaster = metricsMaster;

  // Snapshot information
  this.snapshot = snapshot;

  // Monitor
  this.monitor = new ForeignExceptionDispatcher();
  this.status = TaskMonitor.get().createStatus("Cloning  snapshot '" + snapshot.getName() +
    "' to table " + hTableDescriptor.getNameAsString());
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:19,代码来源:CloneSnapshotHandler.java

示例10: checkAndSetEnablingTable

import org.apache.hadoop.hbase.TableExistsException; //导入依赖的package包/类
static void checkAndSetEnablingTable(final AssignmentManager assignmentManager,
    final TableName tableName) throws IOException {
  // If we have multiple client threads trying to create the table at the
  // same time, given the async nature of the operation, the table
  // could be in a state where hbase:meta table hasn't been updated yet in
  // the process() function.
  // Use enabling state to tell if there is already a request for the same
  // table in progress. This will introduce a new zookeeper call. Given
  // createTable isn't a frequent operation, that should be ok.
  // TODO: now that we have table locks, re-evaluate above -- table locks are not enough.
  // We could have cleared the hbase.rootdir and not zk.  How can we detect this case?
  // Having to clean zk AND hdfs is awkward.
  try {
    if (!assignmentManager.getTableStateManager().setTableStateIfNotInStates(tableName,
      ZooKeeperProtos.Table.State.ENABLING,
      ZooKeeperProtos.Table.State.ENABLING,
      ZooKeeperProtos.Table.State.ENABLED)) {
      throw new TableExistsException(tableName);
    }
  } catch (CoordinatedStateException e) {
    throw new IOException("Unable to ensure that the table will be" +
      " enabling because of a ZooKeeper issue", e);
  }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:25,代码来源:CreateTableHandler.java

示例11: createTableIfMissing

import org.apache.hadoop.hbase.TableExistsException; //导入依赖的package包/类
private void createTableIfMissing() throws IOException {
  try {
    HTableDescriptor ihtd = new HTableDescriptor(TableName.valueOf(TABLE_NAME));
    for (byte[] family : FAMILIES) {
      ihtd.addFamily(new HColumnDescriptor(family));
    }
    IndexSpecification iSpec = new IndexSpecification("ScanIndex");
    iSpec.addIndexColumn(new HColumnDescriptor(Bytes.toString(FAMILY_A)),
      Bytes.toString(QUALIFIER_NAME) + "1", ValueType.String, 10);
    TableIndices indices = new TableIndices();
    indices.addIndex(iSpec);
    HBaseAdmin admin = new IndexAdmin(util.getConfiguration());
    admin.createTable(ihtd);
    admin.close();
  } catch (TableExistsException tee) {
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:18,代码来源:TestAcidGuaranteesForIndex.java

示例12: prepareCreate

import org.apache.hadoop.hbase.TableExistsException; //导入依赖的package包/类
private boolean prepareCreate(final MasterProcedureEnv env) throws IOException {
  final TableName tableName = getTableName();
  if (MetaTableAccessor.tableExists(env.getMasterServices().getConnection(), tableName)) {
    setFailure("master-create-table", new TableExistsException(getTableName()));
    return false;
  }

  // check that we have at least 1 CF
  if (tableDescriptor.getColumnFamilyCount() == 0) {
    setFailure("master-create-table", new DoNotRetryIOException("Table " +
        getTableName().toString() + " should have at least one column family."));
    return false;
  }

  return true;
}
 
开发者ID:apache,项目名称:hbase,代码行数:17,代码来源:CreateTableProcedure.java

示例13: testCreateExisting

import org.apache.hadoop.hbase.TableExistsException; //导入依赖的package包/类
@Test(expected=TableExistsException.class)
public void testCreateExisting() throws Exception {
  final TableName tableName = TableName.valueOf(name.getMethodName());
  final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
  final TableDescriptor htd = MasterProcedureTestingUtility.createHTD(tableName, "f");
  final RegionInfo[] regions = ModifyRegionUtils.createRegionInfos(htd, null);

  // create the table
  long procId1 = procExec.submitProcedure(
    new CreateTableProcedure(procExec.getEnvironment(), htd, regions));

  // create another with the same name
  ProcedurePrepareLatch latch2 = new ProcedurePrepareLatch.CompatibilityLatch();
  long procId2 = procExec.submitProcedure(
    new CreateTableProcedure(procExec.getEnvironment(), htd, regions, latch2));

  ProcedureTestingUtility.waitProcedure(procExec, procId1);
  ProcedureTestingUtility.assertProcNotFailed(procExec.getResult(procId1));

  ProcedureTestingUtility.waitProcedure(procExec, procId2);
  latch2.await();
}
 
开发者ID:apache,项目名称:hbase,代码行数:23,代码来源:TestCreateTableProcedure.java

示例14: testCloneSnapshotToSameTable

import org.apache.hadoop.hbase.TableExistsException; //导入依赖的package包/类
@Test(timeout=60000)
public void testCloneSnapshotToSameTable() throws Exception {
  // take the snapshot
  SnapshotProtos.SnapshotDescription snapshotDesc = getSnapshot();

  final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
  final TableName clonedTableName = TableName.valueOf(snapshotDesc.getTable());
  final HTableDescriptor htd = createHTableDescriptor(clonedTableName, CF);

  long procId = ProcedureTestingUtility.submitAndWait(
    procExec, new CloneSnapshotProcedure(procExec.getEnvironment(), htd, snapshotDesc));
  Procedure<?> result = procExec.getResult(procId);
  assertTrue(result.isFailed());
  LOG.debug("Clone snapshot failed with exception: " + result.getException());
  assertTrue(
    ProcedureTestingUtility.getExceptionCause(result) instanceof TableExistsException);
}
 
开发者ID:apache,项目名称:hbase,代码行数:18,代码来源:TestCloneSnapshotProcedure.java

示例15: setupTable

import org.apache.hadoop.hbase.TableExistsException; //导入依赖的package包/类
/**
 * Creates a table with given table name and specified number of column
 * families if the table does not already exist.
 */
public void setupTable(TableName table, int cfs) throws IOException {
  try {
    LOG.info("Creating table " + table);
    HTableDescriptor htd = new HTableDescriptor(table);
    htd.addCoprocessor(MyObserver.class.getName());
    MyObserver.sleepDuration = this.sleepDuration;
    for (int i = 0; i < 10; i++) {
      htd.addFamily(new HColumnDescriptor(family(i)));
    }

    UTIL.getAdmin().createTable(htd);
  } catch (TableExistsException tee) {
    LOG.info("Table " + table + " already exists");
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:20,代码来源:TestHRegionServerBulkLoad.java


注:本文中的org.apache.hadoop.hbase.TableExistsException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。