类org.apache.hadoop.hbase.client.TableDescriptor源码实例Demo

下面列出了怎么用org.apache.hadoop.hbase.client.TableDescriptor的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: phoenix   文件: FlappingAlterTableIT.java
@Test
public void testNewColumnFamilyInheritsTTLOfEmptyCF() throws Exception {
    Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
    String ddl = "CREATE TABLE " + dataTableFullName + " (\n"
            +"ID1 VARCHAR(15) NOT NULL,\n"
            +"ID2 VARCHAR(15) NOT NULL,\n"
            +"CREATED_DATE DATE,\n"
            +"CREATION_TIME BIGINT,\n"
            +"LAST_USED DATE,\n"
            +"CONSTRAINT PK PRIMARY KEY (ID1, ID2)) TTL = 1000";
    Connection conn1 = DriverManager.getConnection(getUrl(), props);
    conn1.createStatement().execute(ddl);
    ddl = "ALTER TABLE " + dataTableFullName + " ADD CF.STRING VARCHAR";
    conn1.createStatement().execute(ddl);
    try (Admin admin = conn1.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
        TableDescriptor tableDesc = admin.getDescriptor(TableName.valueOf(dataTableFullName));
        ColumnFamilyDescriptor[] columnFamilies = tableDesc.getColumnFamilies();
        assertEquals(2, columnFamilies.length);
        assertEquals("0", columnFamilies[0].getNameAsString());
        assertEquals(1000, columnFamilies[0].getTimeToLive());
        assertEquals("CF", columnFamilies[1].getNameAsString());
        assertEquals(1000, columnFamilies[1].getTimeToLive());
    }
}
 
源代码2 项目: hbase   文件: TestDeleteMobTable.java
@Test
public void testDeleteMobTable() throws Exception {
  final TableName tableName = TableName.valueOf(name.getMethodName());
  TableDescriptor tableDescriptor = createTableDescriptor(tableName, true);
  ColumnFamilyDescriptor familyDescriptor = tableDescriptor.getColumnFamily(FAMILY);

  String fileName = null;
  Table table = createTableWithOneFile(tableDescriptor);
  try {
    // the mob file exists
    Assert.assertEquals(1, countMobFiles(tableName, familyDescriptor.getNameAsString()));
    Assert.assertEquals(0, countArchiveMobFiles(tableName, familyDescriptor.getNameAsString()));
    fileName = assertHasOneMobRow(table, tableName, familyDescriptor.getNameAsString());
    Assert.assertFalse(mobArchiveExist(tableName, familyDescriptor.getNameAsString(), fileName));
    Assert.assertTrue(mobTableDirExist(tableName));
  } finally {
    table.close();
    TEST_UTIL.deleteTable(tableName);
  }

  Assert.assertFalse(TEST_UTIL.getAdmin().tableExists(tableName));
  Assert.assertEquals(0, countMobFiles(tableName, familyDescriptor.getNameAsString()));
  Assert.assertEquals(1, countArchiveMobFiles(tableName, familyDescriptor.getNameAsString()));
  Assert.assertTrue(mobArchiveExist(tableName, familyDescriptor.getNameAsString(), fileName));
  Assert.assertFalse(mobTableDirExist(tableName));
}
 
源代码3 项目: hbase   文件: HMaster.java
@Override
public long deleteColumn(final TableName tableName, final byte[] columnName,
    final long nonceGroup, final long nonce) throws IOException {
  checkInitialized();
  checkTableExists(tableName);

  return modifyTable(tableName, new TableDescriptorGetter() {

    @Override
    public TableDescriptor get() throws IOException {
      TableDescriptor old = getTableDescriptors().get(tableName);

      if (!old.hasColumnFamily(columnName)) {
        throw new InvalidFamilyOperationException("Family '" + Bytes.toString(columnName)
            + "' does not exist, so it cannot be deleted");
      }
      if (old.getColumnFamilyCount() == 1) {
        throw new InvalidFamilyOperationException("Family '" + Bytes.toString(columnName)
            + "' is the only column family in the table, so it cannot be deleted");
      }
      return TableDescriptorBuilder.newBuilder(old).removeColumnFamily(columnName).build();
    }
  }, nonceGroup, nonce, true);
}
 
源代码4 项目: hbase   文件: TestStoreFileRefresherChore.java
private HRegion initHRegion(TableDescriptor htd, byte[] startKey, byte[] stopKey, int replicaId)
    throws IOException {
  Configuration conf = TEST_UTIL.getConfiguration();
  Path tableDir = CommonFSUtils.getTableDir(testDir, htd.getTableName());

  RegionInfo info = RegionInfoBuilder.newBuilder(htd.getTableName()).setStartKey(startKey)
      .setEndKey(stopKey).setRegionId(0L).setReplicaId(replicaId).build();
  HRegionFileSystem fs =
      new FailingHRegionFileSystem(conf, tableDir.getFileSystem(conf), tableDir, info);
  final Configuration walConf = new Configuration(conf);
  CommonFSUtils.setRootDir(walConf, tableDir);
  final WALFactory wals = new WALFactory(walConf, "log_" + replicaId);
  ChunkCreator.initialize(MemStoreLABImpl.CHUNK_SIZE_DEFAULT, false, 0, 0, 0, null);
  HRegion region =
      new HRegion(fs, wals.getWAL(info),
          conf, htd, null);

  region.initialize();

  return region;
}
 
源代码5 项目: hbase   文件: SnapshotScannerHDFSAclController.java
@Override
public void postStartMaster(ObserverContext<MasterCoprocessorEnvironment> c) throws IOException {
  if (!initialized) {
    return;
  }
  try (Admin admin = c.getEnvironment().getConnection().getAdmin()) {
    if (admin.tableExists(PermissionStorage.ACL_TABLE_NAME)) {
      // Check if acl table has 'm' CF, if not, add 'm' CF
      TableDescriptor tableDescriptor = admin.getDescriptor(PermissionStorage.ACL_TABLE_NAME);
      boolean containHdfsAclFamily = Arrays.stream(tableDescriptor.getColumnFamilies()).anyMatch(
        family -> Bytes.equals(family.getName(), SnapshotScannerHDFSAclStorage.HDFS_ACL_FAMILY));
      if (!containHdfsAclFamily) {
        TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableDescriptor)
            .setColumnFamily(ColumnFamilyDescriptorBuilder
                .newBuilder(SnapshotScannerHDFSAclStorage.HDFS_ACL_FAMILY).build());
        admin.modifyTable(builder.build());
      }
      aclTableInitialized = true;
    } else {
      throw new TableNotFoundException("Table " + PermissionStorage.ACL_TABLE_NAME
          + " is not created yet. Please check if " + getClass().getName()
          + " is configured after " + AccessController.class.getName());
    }
  }
}
 
源代码6 项目: hbase   文件: FSTableDescriptors.java
/**
 * Update table descriptor on the file system
 * @throws IOException Thrown if failed update.
 * @throws NotImplementedException if in read only mode
 */
@VisibleForTesting
Path updateTableDescriptor(TableDescriptor td) throws IOException {
  if (fsreadonly) {
    throw new NotImplementedException("Cannot update a table descriptor - in read only mode");
  }
  TableName tableName = td.getTableName();
  Path tableDir = getTableDir(tableName);
  Path p = writeTableDescriptor(fs, td, tableDir, getTableInfoPath(tableDir));
  if (p == null) {
    throw new IOException("Failed update");
  }
  LOG.info("Updated tableinfo=" + p);
  if (usecache) {
    this.cache.put(td.getTableName(), td);
  }
  return p;
}
 
源代码7 项目: hbase   文件: TestRSGroupsBasics.java
@Test
public void testNamespaceCreateAndAssign() throws Exception {
  LOG.info("testNamespaceCreateAndAssign");
  String nsName = TABLE_PREFIX + "_foo";
  final TableName tableName = TableName.valueOf(nsName, TABLE_PREFIX + "_testCreateAndAssign");
  RSGroupInfo appInfo = addGroup("appInfo", 1);
  ADMIN.createNamespace(NamespaceDescriptor.create(nsName)
    .addConfiguration(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP, "appInfo").build());
  final TableDescriptor desc = TableDescriptorBuilder.newBuilder(tableName)
    .setColumnFamily(ColumnFamilyDescriptorBuilder.of("f")).build();
  ADMIN.createTable(desc);
  // wait for created table to be assigned
  TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate<Exception>() {
    @Override
    public boolean evaluate() throws Exception {
      return getTableRegionMap().get(desc.getTableName()) != null;
    }
  });
  ServerName targetServer = getServerName(appInfo.getServers().iterator().next());
  // verify it was assigned to the right group
  Assert.assertEquals(1, ADMIN.getRegions(targetServer).size());
}
 
源代码8 项目: hbase   文件: TestDeleteMobTable.java
private Table createTableWithOneFile(TableDescriptor tableDescriptor) throws IOException {
  Table table = TEST_UTIL.createTable(tableDescriptor, null);
  try {
    // insert data
    byte[] value = generateMobValue(10);
    byte[] row = Bytes.toBytes("row");
    Put put = new Put(row);
    put.addColumn(FAMILY, QF, EnvironmentEdgeManager.currentTime(), value);
    table.put(put);

    // create an hfile
    TEST_UTIL.getAdmin().flush(tableDescriptor.getTableName());
  } catch (IOException e) {
    table.close();
    throw e;
  }
  return table;
}
 
源代码9 项目: atlas   文件: HBaseAtlasCoprocessor.java
@Override
public void postCloneSnapshot(ObserverContext<MasterCoprocessorEnvironment> observerContext, SnapshotDescription snapshot, TableDescriptor tableDescriptor) throws IOException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> HBaseAtlasCoprocessor.postCloneSnapshot()");
    }

    try {
        activatePluginClassLoader();
        implMasterObserver.postCloneSnapshot(observerContext,snapshot,tableDescriptor);
    } finally {
        deactivatePluginClassLoader();
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("<== HBaseAtlasCoprocessor.postCloneSnapshot()");
    }
}
 
源代码10 项目: hbase   文件: TestRegionSplitPolicy.java
@Test
public void testCreateDefault() throws IOException {
  conf.setLong(HConstants.HREGION_MAX_FILESIZE, 1234L);
  TableDescriptor td = TableDescriptorBuilder.newBuilder(TABLENAME).build();
  doReturn(td).when(mockRegion).getTableDescriptor();
  // Using a default HTD, should pick up the file size from
  // configuration.
  ConstantSizeRegionSplitPolicy policy =
    (ConstantSizeRegionSplitPolicy) RegionSplitPolicy.create(mockRegion, conf);
  assertWithinJitter(1234L, policy.getDesiredMaxFileSize());

  // If specified in HTD, should use that
  td = TableDescriptorBuilder.newBuilder(TABLENAME).setMaxFileSize(9999L).build();
  doReturn(td).when(mockRegion).getTableDescriptor();
  policy = (ConstantSizeRegionSplitPolicy) RegionSplitPolicy.create(mockRegion, conf);
  assertWithinJitter(9999L, policy.getDesiredMaxFileSize());
}
 
源代码11 项目: hbase   文件: RestoreTool.java
/**
 * Get table descriptor
 * @param tableName is the table backed up
 * @return {@link TableDescriptor} saved in backup image of the table
 */
TableDescriptor getTableDesc(TableName tableName) throws IOException {
  Path tableInfoPath = this.getTableInfoPath(tableName);
  SnapshotDescription desc = SnapshotDescriptionUtils.readSnapshotInfo(fs, tableInfoPath);
  SnapshotManifest manifest = SnapshotManifest.open(conf, fs, tableInfoPath, desc);
  TableDescriptor tableDescriptor = manifest.getTableDescriptor();
  if (!tableDescriptor.getTableName().equals(tableName)) {
    LOG.error("couldn't find Table Desc for table: " + tableName + " under tableInfoPath: "
            + tableInfoPath.toString());
    LOG.error("tableDescriptor.getNameAsString() = "
            + tableDescriptor.getTableName().getNameAsString());
    throw new FileNotFoundException("couldn't find Table Desc for table: " + tableName
        + " under tableInfoPath: " + tableInfoPath.toString());
  }
  return tableDescriptor;
}
 
源代码12 项目: hbase   文件: IntegrationTestBackupRestore.java
private void createTable(TableName tableName) throws Exception {
  long startTime, endTime;

  TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableName);

  TableDescriptor desc = builder.build();
  ColumnFamilyDescriptorBuilder cbuilder =
      ColumnFamilyDescriptorBuilder.newBuilder(COLUMN_NAME.getBytes(Charset.defaultCharset()));
  ColumnFamilyDescriptor[] columns = new ColumnFamilyDescriptor[] { cbuilder.build() };
  LOG.info("Creating table {} with {} splits.", tableName,
    regionsCountPerServer * regionServerCount);
  startTime = System.currentTimeMillis();
  HBaseTestingUtility.createPreSplitLoadTestTable(util.getConfiguration(), desc, columns,
    regionsCountPerServer);
  util.waitTableAvailable(tableName);
  endTime = System.currentTimeMillis();
  LOG.info("Pre-split table created successfully in {}ms.", (endTime - startTime));
}
 
源代码13 项目: phoenix   文件: SetPropertyIT.java
@Test
public void testSetHTableAndHColumnProperties() throws Exception {
    Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
    String ddl = "CREATE TABLE " + dataTableFullName + " (\n"
            +"ID1 VARCHAR(15) NOT NULL,\n"
            +"ID2 VARCHAR(15) NOT NULL,\n"
            +"CREATED_DATE DATE,\n"
            +"CREATION_TIME BIGINT,\n"
            +"LAST_USED DATE,\n"
            +"CONSTRAINT PK PRIMARY KEY (ID1, ID2)) " + generateDDLOptions("SALT_BUCKETS = 8");
    Connection conn1 = DriverManager.getConnection(getUrl(), props);
    conn1.createStatement().execute(ddl);
    ddl = "ALTER TABLE " + dataTableFullName + " SET COMPACTION_ENABLED = FALSE, REPLICATION_SCOPE = 1";
    conn1.createStatement().execute(ddl);
    try (Admin admin = conn1.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) {
        TableDescriptor tableDesc = admin.getDescriptor(TableName.valueOf(dataTableFullName));
        ColumnFamilyDescriptor[] columnFamilies = tableDesc.getColumnFamilies();
        assertEquals(1, columnFamilies.length);
        assertEquals("0", columnFamilies[0].getNameAsString());
        assertEquals(1, columnFamilies[0].getScope());
        assertEquals(false, tableDesc.isCompactionEnabled());
    }
}
 
源代码14 项目: hbase   文件: MasterProcedureTestingUtility.java
public static void validateColumnFamilyDeletion(final HMaster master, final TableName tableName,
    final String family) throws IOException {
  // verify htd
  TableDescriptor htd = master.getTableDescriptors().get(tableName);
  assertTrue(htd != null);
  assertFalse(htd.hasColumnFamily(Bytes.toBytes(family)));

  // verify fs
  final FileSystem fs = master.getMasterFileSystem().getFileSystem();
  final Path tableDir =
    CommonFSUtils.getTableDir(master.getMasterFileSystem().getRootDir(), tableName);
  for (Path regionDir : FSUtils.getRegionDirs(fs, tableDir)) {
    final Path familyDir = new Path(regionDir, family);
    assertFalse(family + " family dir should not exist", fs.exists(familyDir));
  }
}
 
源代码15 项目: hbase   文件: SnapshotTestingUtils.java
private SnapshotBuilder createSnapshot(final String snapshotName, final String tableName,
    final int numRegions, final int version) throws IOException {
  TableDescriptor htd = createHtd(tableName);
  RegionData[] regions = createTable(htd, numRegions);

  SnapshotProtos.SnapshotDescription desc = SnapshotProtos.SnapshotDescription.newBuilder()
    .setTable(htd.getTableName().getNameAsString())
    .setName(snapshotName)
    .setVersion(version)
    .build();

  Path workingDir = SnapshotDescriptionUtils.getWorkingSnapshotDir(desc, rootDir, conf);
  FileSystem workingFs = workingDir.getFileSystem(conf);
  SnapshotDescriptionUtils.writeSnapshotInfo(desc, workingDir, workingFs);
  return new SnapshotBuilder(conf, fs, rootDir, htd, desc, regions);
}
 
@Override
public TableDescriptor preCreateTableRegionsInfos(
    ObserverContext<MasterCoprocessorEnvironment> ctx, TableDescriptor desc)
    throws IOException {
  TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(desc);
  for (ColumnFamilyDescriptor cfd : desc.getColumnFamilies()) {
    builder.modifyColumnFamily(
        ColumnFamilyDescriptorBuilder.newBuilder(cfd).setMaxVersions(1).build());
  }
  return builder.build();
}
 
源代码17 项目: hbase   文件: MasterCoprocessorHost.java
public void preCloneSnapshot(final SnapshotDescription snapshot,
    final TableDescriptor hTableDescriptor) throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.preCloneSnapshot(this, snapshot, hTableDescriptor);
    }
  });
}
 
源代码18 项目: hbase   文件: TestNamespaceReplication.java
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  TestReplicationBase.setUpBeforeClass();

  connection1 = ConnectionFactory.createConnection(CONF1);
  connection2 = ConnectionFactory.createConnection(CONF2);
  admin1 = connection1.getAdmin();
  admin2 = connection2.getAdmin();

  admin1.createNamespace(NamespaceDescriptor.create(ns1).build());
  admin1.createNamespace(NamespaceDescriptor.create(ns2).build());
  admin2.createNamespace(NamespaceDescriptor.create(ns1).build());
  admin2.createNamespace(NamespaceDescriptor.create(ns2).build());

  TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tabAName);
  builder.setColumnFamily(ColumnFamilyDescriptorBuilder
    .newBuilder(f1Name).setScope(HConstants.REPLICATION_SCOPE_GLOBAL).build());
  builder.setColumnFamily(ColumnFamilyDescriptorBuilder
    .newBuilder(f2Name).setScope(HConstants.REPLICATION_SCOPE_GLOBAL).build());
  TableDescriptor tabA = builder.build();
  admin1.createTable(tabA);
  admin2.createTable(tabA);

  builder = TableDescriptorBuilder.newBuilder(tabBName);
  builder.setColumnFamily(ColumnFamilyDescriptorBuilder
    .newBuilder(f1Name).setScope(HConstants.REPLICATION_SCOPE_GLOBAL).build());
  builder.setColumnFamily(ColumnFamilyDescriptorBuilder
    .newBuilder(f2Name).setScope(HConstants.REPLICATION_SCOPE_GLOBAL).build());
  TableDescriptor tabB = builder.build();
  admin1.createTable(tabB);
  admin2.createTable(tabB);
}
 
源代码19 项目: hbase   文件: SecureTestUtil.java
@Override
public void postCompletedCreateTableAction(
    final ObserverContext<MasterCoprocessorEnvironment> ctx,
    TableDescriptor desc, RegionInfo[] regions) throws IOException {
  // the AccessController test, some times calls only and directly the
  // postCompletedCreateTableAction()
  if (tableCreationLatch != null) {
    tableCreationLatch.countDown();
  }
}
 
源代码20 项目: hbase   文件: TestMergeTableRegionsProcedure.java
private List<RegionInfo> createTable(final TableName tableName) throws Exception {
  TableDescriptor desc = TableDescriptorBuilder.newBuilder(tableName)
    .setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILY)).build();
  byte[][] splitRows = new byte[initialRegionCount - 1][];
  for (int i = 0; i < splitRows.length; ++i) {
    splitRows[i] = Bytes.toBytes(String.format("%d", i));
  }
  admin.createTable(desc, splitRows);
  return assertRegionCount(tableName, initialRegionCount);
}
 
源代码21 项目: spliceengine   文件: SpliceHRegion.java
public SpliceHRegion(final Path tableDir, final WAL wal, final FileSystem fs,
                     final Configuration confParam, final RegionInfo regionInfo,
                     final TableDescriptor htd, final RegionServerServices rsServices,
                     Set<String> compactedFilesPaths) throws IOException{

    super(tableDir, wal, fs, confParam, regionInfo, htd, rsServices);
    openHRegion(null);
    setCompactedFiles(compactedFilesPaths);
}
 
源代码22 项目: hbase   文件: MasterCoprocessorHost.java
public void postCloneSnapshot(final SnapshotDescription snapshot,
    final TableDescriptor hTableDescriptor) throws IOException {
  execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() {
    @Override
    public void call(MasterObserver observer) throws IOException {
      observer.postCloneSnapshot(this, snapshot, hTableDescriptor);
    }
  });
}
 
源代码23 项目: hbase   文件: RegionReplicaReplicationEndpoint.java
/**
 * returns true if the specified entry must be replicated. We should always replicate meta
 * operations (e.g. flush) and use the user HTD flag to decide whether or not replicate the
 * memstore.
 */
private boolean requiresReplication(Optional<TableDescriptor> tableDesc,
    Entry entry) {
  // empty edit does not need to be replicated
  if (entry.getEdit().isEmpty() || !tableDesc.isPresent()) {
    return false;
  }
  // meta edits (e.g. flush) must be always replicated
  return entry.getEdit().isMetaEdit() || tableDesc.get().hasRegionMemStoreReplication();
}
 
源代码24 项目: hbase   文件: TestFileArchiverNotifierImpl.java
@Test
public void testSnapshotSizePersistence() throws IOException {
  final Admin admin = TEST_UTIL.getAdmin();
  final TableName tn = TableName.valueOf(testName.getMethodName());
  if (admin.tableExists(tn)) {
    admin.disableTable(tn);
    admin.deleteTable(tn);
  }
  TableDescriptor desc = TableDescriptorBuilder.newBuilder(tn).setColumnFamily(
      ColumnFamilyDescriptorBuilder.of(QuotaTableUtil.QUOTA_FAMILY_USAGE)).build();
  admin.createTable(desc);

  FileArchiverNotifierImpl notifier = new FileArchiverNotifierImpl(conn, conf, fs, tn);
  List<SnapshotWithSize> snapshotsWithSizes = new ArrayList<>();
  try (Table table = conn.getTable(tn)) {
    // Writing no values will result in no records written.
    verify(table, () -> {
      notifier.persistSnapshotSizes(table, snapshotsWithSizes);
      assertEquals(0, count(table));
    });

    verify(table, () -> {
      snapshotsWithSizes.add(new SnapshotWithSize("ss1", 1024L));
      snapshotsWithSizes.add(new SnapshotWithSize("ss2", 4096L));
      notifier.persistSnapshotSizes(table, snapshotsWithSizes);
      assertEquals(2, count(table));
      assertEquals(1024L, extractSnapshotSize(table, tn, "ss1"));
      assertEquals(4096L, extractSnapshotSize(table, tn, "ss2"));
    });
  }
}
 
源代码25 项目: hbase   文件: RemoveColumnAction.java
@Override
public void perform() throws Exception {
  TableDescriptor tableDescriptor = admin.getDescriptor(tableName);
  ColumnFamilyDescriptor[] columnDescriptors = tableDescriptor.getColumnFamilies();

  if (columnDescriptors.length <= (protectedColumns == null ? 1 : protectedColumns.size())) {
    return;
  }

  int index = random.nextInt(columnDescriptors.length);
  while(protectedColumns != null &&
        protectedColumns.contains(columnDescriptors[index].getNameAsString())) {
    index = random.nextInt(columnDescriptors.length);
  }
  byte[] colDescName = columnDescriptors[index].getName();
  getLogger().debug("Performing action: Removing " + Bytes.toString(colDescName)+ " from "
      + tableName.getNameAsString());

  TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableDescriptor);
  builder.removeColumnFamily(colDescName);

  // Don't try the modify if we're stopping
  if (context.isStopping()) {
    return;
  }
  admin.modifyTable(builder.build());
}
 
源代码26 项目: hbase   文件: HBaseTestingUtility.java
/**
 * Create a region with it's own WAL. Be sure to call
 * {@link HBaseTestingUtility#closeRegionAndWAL(HRegion)} to clean up all resources.
 */
public static HRegion createRegionAndWAL(final RegionInfo info, final Path rootDir,
    final Configuration conf, final TableDescriptor htd, boolean initialize)
    throws IOException {
  ChunkCreator.initialize(MemStoreLABImpl.CHUNK_SIZE_DEFAULT, false, 0, 0, 0, null);
  WAL wal = createWal(conf, rootDir, info);
  return HRegion.createHRegion(info, rootDir, conf, htd, wal, initialize);
}
 
源代码27 项目: hbase   文件: IntegrationTestDDLMasterFailover.java
@Override
void perform() throws IOException {
  TableDescriptor selected = selectTable(disabledTables);
  ColumnFamilyDescriptor cfd = selectFamily(selected);
  if (selected == null || cfd == null) {
    return;
  }

  Admin admin = connection.getAdmin();
  try {
    if (selected.getColumnFamilyCount() < 2) {
      LOG.info("No enough column families to delete in table " + selected.getTableName());
      return;
    }
    TableName tableName = selected.getTableName();
    LOG.info("Deleting column family: " + cfd + " from table: " + tableName);
    admin.deleteColumnFamily(tableName, cfd.getName());
    // assertion
    TableDescriptor freshTableDesc = admin.getDescriptor(tableName);
    Assert.assertFalse("Column family: " + cfd + " was not added",
        freshTableDesc.hasColumnFamily(cfd.getName()));
    Assert.assertTrue(
      "After delete column family, Table: " + tableName + " is not disabled",
      admin.isTableDisabled(tableName));
    disabledTables.put(tableName, freshTableDesc);
    LOG.info("Deleted column family: " + cfd + " from table: " + tableName);
  } catch (Exception e) {
    LOG.warn("Caught exception in action: " + this.getClass());
    throw e;
  } finally {
    admin.close();
  }
}
 
源代码28 项目: hbase   文件: TestWALSplitToHFile.java
private Pair<TableDescriptor, RegionInfo> setupTableAndRegion() throws IOException {
  final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
  final TableDescriptor td = createBasic3FamilyTD(tableName);
  final RegionInfo ri = RegionInfoBuilder.newBuilder(tableName).build();
  final Path tableDir = CommonFSUtils.getTableDir(this.rootDir, tableName);
  deleteDir(tableDir);
  FSTableDescriptors.createTableDescriptorForTableDirectory(fs, tableDir, td, false);
  HRegion region = HBaseTestingUtility.createRegionAndWAL(ri, rootDir, this.conf, td);
  HBaseTestingUtility.closeRegionAndWAL(region);
  return new Pair<>(td, ri);
}
 
源代码29 项目: hbase   文件: TestMobStoreCompaction.java
private static HRegion setMobThreshold(HRegion region, byte[] cfName, long modThreshold) {
  ColumnFamilyDescriptor cfd = ColumnFamilyDescriptorBuilder
          .newBuilder(region.getTableDescriptor().getColumnFamily(cfName))
          .setMobThreshold(modThreshold)
          .build();
  TableDescriptor td = TableDescriptorBuilder
          .newBuilder(region.getTableDescriptor())
          .removeColumnFamily(cfName)
          .setColumnFamily(cfd)
          .build();
  region.setTableDescriptor(td);
  return region;
}
 
源代码30 项目: hbase   文件: RSGroupInfoManagerImpl.java
@Override
public synchronized void removeRSGroup(String groupName) throws IOException {
  RSGroupInfo rsGroupInfo = getRSGroupInfo(groupName);
  int serverCount = rsGroupInfo.getServers().size();
  if (serverCount > 0) {
    throw new ConstraintException("RSGroup " + groupName + " has " + serverCount +
        " servers; you must remove these servers from the RSGroup before" +
        " the RSGroup can be removed.");
  }
  for (TableDescriptor td : masterServices.getTableDescriptors().getAll().values()) {
    if (td.getRegionServerGroup().map(groupName::equals).orElse(false)) {
      throw new ConstraintException("RSGroup " + groupName + " is already referenced by " +
          td.getTableName() + "; you must remove all the tables from the rsgroup before " +
          "the rsgroup can be removed.");
    }
  }
  for (NamespaceDescriptor ns : masterServices.getClusterSchema().getNamespaces()) {
    String nsGroup = ns.getConfigurationValue(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP);
    if (nsGroup != null && nsGroup.equals(groupName)) {
      throw new ConstraintException(
          "RSGroup " + groupName + " is referenced by namespace: " + ns.getName());
    }
  }
  Map<String, RSGroupInfo> rsGroupMap = holder.groupName2Group;
  if (!rsGroupMap.containsKey(groupName) || groupName.equals(RSGroupInfo.DEFAULT_GROUP)) {
    throw new ConstraintException(
      "Group " + groupName + " does not exist or is a reserved " + "group");
  }
  Map<String, RSGroupInfo> newGroupMap = Maps.newHashMap(rsGroupMap);
  newGroupMap.remove(groupName);
  flushConfig(newGroupMap);
}
 
 同包方法