org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder Java Examples

The following examples show how to use org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FSUtils.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean accept(Path p, @CheckForNull Boolean isDir) {
  try {
    // throws IAE if invalid
    ColumnFamilyDescriptorBuilder.isLegalColumnFamilyName(Bytes.toBytes(p.getName()));
  } catch (IllegalArgumentException iae) {
    // path name is an invalid family name and thus is excluded.
    return false;
  }

  try {
    return isDirectory(fs, isDir, p);
  } catch (IOException ioe) {
    // Maybe the file was moved or the fs was disconnected.
    LOG.warn("Skipping file {} due to IOException", p, ioe);
    return false;
  }
}
 
Example #2
Source File: TestAtomicOperation.java    From hbase with Apache License 2.0 6 votes vote down vote up
private void initHRegion (byte [] tableName, String callingMethod, int [] maxVersions,
  byte[] ... families)
throws IOException {
  TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
    new TableDescriptorBuilder.ModifyableTableDescriptor(TableName.valueOf(tableName));

  int i=0;
  for(byte [] family : families) {
    ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor familyDescriptor =
      new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(family);
    familyDescriptor.setMaxVersions(maxVersions != null ? maxVersions[i++] : 1);
    tableDescriptor.setColumnFamily(familyDescriptor);
  }
  RegionInfo info = RegionInfoBuilder.newBuilder(tableDescriptor.getTableName()).build();
  region = TEST_UTIL.createLocalHRegion(info, tableDescriptor);
}
 
Example #3
Source File: TransactionProcessorTest.java    From phoenix-tephra with Apache License 2.0 6 votes vote down vote up
private HRegion updateTtl(HRegion region, byte[] family, long ttl) throws Exception {
  region.close();
  TableDescriptorBuilder tableBuilder =
      TableDescriptorBuilder.newBuilder(region.getTableDescriptor());
  ColumnFamilyDescriptorBuilder cfd =
      ColumnFamilyDescriptorBuilder.newBuilder(tableBuilder.build().getColumnFamily(family));
  if (ttl > 0) {
    cfd.setValue(Bytes.toBytes(TxConstants.PROPERTY_TTL), Bytes.toBytes(String.valueOf(ttl)));
  }
  cfd.setMaxVersions(10);
  tableBuilder.removeColumnFamily(family);
  tableBuilder.addColumnFamily(cfd.build());
  return HRegion
      .openHRegion(region.getRegionInfo(), tableBuilder.build(), region.getWAL(), conf,
        new LocalRegionServerServices(conf, ServerName
            .valueOf(InetAddress.getLocalHost().getHostName(), 0, System.currentTimeMillis())),
        null);
}
 
Example #4
Source File: HBaseTestingUtility.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Create a table.
 * @param tableName
 * @param families
 * @param numVersions
 * @param splitKeys
 * @return A Table instance for the created table.
 * @throws IOException
 */
public Table createTable(TableName tableName, byte[][] families, int numVersions,
    byte[][] splitKeys) throws IOException {
  TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
    new TableDescriptorBuilder.ModifyableTableDescriptor(tableName);
  for (byte[] family : families) {
    ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor familyDescriptor =
      new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(family)
        .setMaxVersions(numVersions);
    if (isNewVersionBehaviorEnabled()) {
      familyDescriptor.setNewVersionBehavior(true);
    }
    tableDescriptor.setColumnFamily(familyDescriptor);
  }
  if (splitKeys != null) {
    getAdmin().createTable(tableDescriptor, splitKeys);
  } else {
    getAdmin().createTable(tableDescriptor);
  }
  // HBaseAdmin only waits for regions to appear in hbase:meta we should wait until they are
  // assigned
  waitUntilAllRegionsAssigned(tableName);
  return getConnection().getTable(tableName);
}
 
Example #5
Source File: TestMaster.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Test
public void testMoveThrowsUnknownRegionException() throws IOException {
  final TableName tableName = TableName.valueOf(name.getMethodName());
  TableDescriptorBuilder tableDescriptorBuilder =
    TableDescriptorBuilder.newBuilder(tableName);
  ColumnFamilyDescriptor columnFamilyDescriptor =
    ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("value")).build();
  tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptor);

  admin.createTable(tableDescriptorBuilder.build());
  try {
    RegionInfo hri = RegionInfoBuilder.newBuilder(tableName)
        .setStartKey(Bytes.toBytes("A"))
        .setEndKey(Bytes.toBytes("Z"))
        .build();
    admin.move(hri.getEncodedNameAsBytes());
    fail("Region should not be moved since it is fake");
  } catch (IOException ioe) {
    assertTrue(ioe instanceof UnknownRegionException);
  } finally {
    TEST_UTIL.deleteTable(tableName);
  }
}
 
Example #6
Source File: BackupSystemTable.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Get backup system table descriptor
 * @return table's descriptor
 */
public static TableDescriptor getSystemTableForBulkLoadedDataDescriptor(Configuration conf) {
  TableDescriptorBuilder builder =
      TableDescriptorBuilder.newBuilder(getTableNameForBulkLoadedData(conf));

  ColumnFamilyDescriptorBuilder colBuilder =
      ColumnFamilyDescriptorBuilder.newBuilder(SESSIONS_FAMILY);
  colBuilder.setMaxVersions(1);
  Configuration config = HBaseConfiguration.create();
  int ttl = config.getInt(BackupRestoreConstants.BACKUP_SYSTEM_TTL_KEY,
    BackupRestoreConstants.BACKUP_SYSTEM_TTL_DEFAULT);
  colBuilder.setTimeToLive(ttl);
  ColumnFamilyDescriptor colSessionsDesc = colBuilder.build();
  builder.setColumnFamily(colSessionsDesc);
  colBuilder = ColumnFamilyDescriptorBuilder.newBuilder(META_FAMILY);
  colBuilder.setTimeToLive(ttl);
  builder.setColumnFamily(colBuilder.build());
  return builder.build();
}
 
Example #7
Source File: IntegrationTestWithCellVisibilityLoadAndVerify.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Override
public int runTestFromCommandLine() throws Exception {
  IntegrationTestingUtility.setUseDistributedCluster(getConf());
  int numPresplits = getConf().getInt("loadmapper.numPresplits", 5);
  // create HTableDescriptor for specified table
  TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
    new TableDescriptorBuilder.ModifyableTableDescriptor(getTablename());
  tableDescriptor.setColumnFamily(
    new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(TEST_FAMILY));

  try (Connection conn = ConnectionFactory.createConnection(getConf());
      Admin admin = conn.getAdmin()) {
    admin.createTable(tableDescriptor, Bytes.toBytes(0L), Bytes.toBytes(-1L), numPresplits);
  }
  doLoad(getConf(), tableDescriptor);
  doVerify(getConf(), tableDescriptor);
  getTestingUtil(getConf()).deleteTable(getTablename());
  return 0;
}
 
Example #8
Source File: TestSwitchToStreamRead.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws IOException {
  UTIL.getConfiguration().setLong(StoreScanner.STORESCANNER_PREAD_MAX_BYTES, 2048);
  StringBuilder sb = new StringBuilder(256);
  for (int i = 0; i < 255; i++) {
    sb.append((char) ThreadLocalRandom.current().nextInt('A', 'z' + 1));
  }
  VALUE_PREFIX = sb.append("-").toString();
  REGION = UTIL.createLocalHRegion(
    TableDescriptorBuilder.newBuilder(TABLE_NAME)
      .setColumnFamily(
        ColumnFamilyDescriptorBuilder.newBuilder(FAMILY).setBlocksize(1024).build())
      .build(),
    null, null);
  for (int i = 0; i < 900; i++) {
    REGION
      .put(new Put(Bytes.toBytes(i)).addColumn(FAMILY, QUAL, Bytes.toBytes(VALUE_PREFIX + i)));
  }
  REGION.flush(true);
  for (int i = 900; i < 1000; i++) {
    REGION
      .put(new Put(Bytes.toBytes(i)).addColumn(FAMILY, QUAL, Bytes.toBytes(VALUE_PREFIX + i)));
  }
}
 
Example #9
Source File: TestAccessController2.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateTableWithGroupPermissions() throws Exception {
  grantGlobal(TEST_UTIL, TESTGROUP_1_NAME, Action.CREATE);
  try {
    AccessTestAction createAction = new AccessTestAction() {
      @Override
      public Object run() throws Exception {
        TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
          new TableDescriptorBuilder.ModifyableTableDescriptor(testTable.getTableName());
        tableDescriptor.setColumnFamily(
          new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(TEST_FAMILY));
        try (Connection connection =
            ConnectionFactory.createConnection(TEST_UTIL.getConfiguration())) {
          try (Admin admin = connection.getAdmin()) {
            admin.createTable(tableDescriptor);
          }
        }
        return null;
      }
    };
    verifyAllowed(createAction, TESTGROUP1_USER1);
    verifyDenied(createAction, TESTGROUP2_USER1);
  } finally {
    revokeGlobal(TEST_UTIL, TESTGROUP_1_NAME, Action.CREATE);
  }
}
 
Example #10
Source File: TestGzipFilter.java    From hbase with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  TEST_UTIL.startMiniCluster();
  REST_TEST_UTIL.startServletContainer(TEST_UTIL.getConfiguration());
  client = new Client(new Cluster().add("localhost",
    REST_TEST_UTIL.getServletPort()));
  Admin admin = TEST_UTIL.getAdmin();
  if (admin.tableExists(TABLE)) {
    return;
  }
  TableDescriptorBuilder tableDescriptorBuilder =
    TableDescriptorBuilder.newBuilder(TABLE);
  ColumnFamilyDescriptor columnFamilyDescriptor =
    ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes(CFA)).build();
  tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptor);
  admin.createTable(tableDescriptorBuilder.build());
}
 
Example #11
Source File: TestMinVersions.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Test
public void testMinVersionsWithKeepDeletedCellsTTL() throws Exception {
  int ttl = 4;
  ColumnFamilyDescriptor cfd =
    ColumnFamilyDescriptorBuilder.newBuilder(c0)
      .setVersionsWithTimeToLive(ttl, 2).build();
  verifyVersionedCellKeyValues(ttl, cfd);

  cfd = ColumnFamilyDescriptorBuilder.newBuilder(c0)
    .setMinVersions(2)
    .setMaxVersions(Integer.MAX_VALUE)
    .setTimeToLive(ttl)
    .setKeepDeletedCells(KeepDeletedCells.TTL)
    .build();
  verifyVersionedCellKeyValues(ttl, cfd);
}
 
Example #12
Source File: TestFilterFromRegionSide.java    From hbase with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
  TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
    new TableDescriptorBuilder.ModifyableTableDescriptor(TABLE_NAME);

  for (byte[] family : FAMILIES) {
    ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor familyDescriptor =
      new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(family);
    tableDescriptor.setColumnFamily(familyDescriptor);
  }
  RegionInfo info = RegionInfoBuilder.newBuilder(tableDescriptor.getTableName()).build();
  REGION = HBaseTestingUtility.createRegionAndWAL(info, TEST_UTIL.getDataTestDir(),
    TEST_UTIL.getConfiguration(), tableDescriptor);
  for(Put put:createPuts(ROWS, FAMILIES, QUALIFIERS, VALUE)){
    REGION.put(put);
  }
}
 
Example #13
Source File: TestNamespaceAuditor.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Test(expected = QuotaExceededException.class)
public void testCloneSnapshotQuotaExceed() throws Exception {
  String nsp = prefix + "_testTableQuotaExceedWithCloneSnapshot";
  NamespaceDescriptor nspDesc =
      NamespaceDescriptor.create(nsp).addConfiguration(TableNamespaceManager.KEY_MAX_TABLES, "1")
          .build();
  ADMIN.createNamespace(nspDesc);
  assertNotNull("Namespace descriptor found null.", ADMIN.getNamespaceDescriptor(nsp));
  TableName tableName = TableName.valueOf(nsp + TableName.NAMESPACE_DELIM + "table1");
  TableName cloneTableName = TableName.valueOf(nsp + TableName.NAMESPACE_DELIM + "table2");
  ColumnFamilyDescriptor columnFamilyDescriptor =
    ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("fam1")).build();
  TableDescriptorBuilder tableDescOne = TableDescriptorBuilder
    .newBuilder(tableName);
  tableDescOne.setColumnFamily(columnFamilyDescriptor);
  ADMIN.createTable(tableDescOne.build());
  String snapshot = "snapshot_testTableQuotaExceedWithCloneSnapshot";
  ADMIN.snapshot(snapshot, tableName);
  ADMIN.cloneSnapshot(snapshot, cloneTableName);
  ADMIN.deleteSnapshot(snapshot);
}
 
Example #14
Source File: TestTruncateTableProcedure.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Test
public void testTruncatePreserveWithReplicaRegionAfterSplit() throws Exception {
  String[] families = new String[] { "f1", "f2" };
  byte[][] splitKeys =
    new byte[][] { Bytes.toBytes("a"), Bytes.toBytes("b"), Bytes.toBytes("c") };
  TableName tableName = TableName.valueOf(name.getMethodName());

  // create a table with region replications
  TableDescriptor htd = TableDescriptorBuilder.newBuilder(tableName).setRegionReplication(3)
    .setColumnFamilies(Arrays.stream(families)
      .map(fam -> ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes(fam)).build())
      .collect(Collectors.toList()))
    .build();
  RegionInfo[] regions = ModifyRegionUtils.createRegionInfos(htd, splitKeys);
  ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor();
  long procId = ProcedureTestingUtility.submitAndWait(procExec,
    new CreateTableProcedure(procExec.getEnvironment(), htd, regions));
  ProcedureTestingUtility.assertProcNotFailed(procExec.getResult(procId));

  splitAndTruncate(tableName, regions, 3);
}
 
Example #15
Source File: HBaseTestingUtility.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Create a table.
 * @param tableName
 * @param family
 * @param splitRows
 * @return A Table instance for the created table.
 * @throws IOException
 */
public Table createTable(TableName tableName, byte[] family, byte[][] splitRows)
    throws IOException {
  TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
    new TableDescriptorBuilder.ModifyableTableDescriptor(tableName);
  ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor familyDescriptor =
    new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(family);
  if (isNewVersionBehaviorEnabled()) {
    familyDescriptor.setNewVersionBehavior(true);
  }
  tableDescriptor.setColumnFamily(familyDescriptor);
  getAdmin().createTable(tableDescriptor, splitRows);
  // HBaseAdmin only waits for regions to appear in hbase:meta we should wait until they are
  // assigned
  waitUntilAllRegionsAssigned(tableName);
  return getConnection().getTable(tableName);
}
 
Example #16
Source File: TestFIFOCompactionPolicy.java    From hbase with Apache License 2.0 6 votes vote down vote up
private HStore prepareData() throws IOException {
  Admin admin = TEST_UTIL.getAdmin();
  TableDescriptor desc = TableDescriptorBuilder.newBuilder(tableName)
      .setValue(DefaultStoreEngine.DEFAULT_COMPACTION_POLICY_CLASS_KEY,
        FIFOCompactionPolicy.class.getName())
      .setValue(HConstants.HBASE_REGION_SPLIT_POLICY_KEY,
        DisabledRegionSplitPolicy.class.getName())
      .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(family).setTimeToLive(1).build())
      .build();
  admin.createTable(desc);
  Table table = TEST_UTIL.getConnection().getTable(tableName);
  TimeOffsetEnvironmentEdge edge =
      (TimeOffsetEnvironmentEdge) EnvironmentEdgeManager.getDelegate();
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      byte[] value = new byte[128 * 1024];
      ThreadLocalRandom.current().nextBytes(value);
      table.put(new Put(Bytes.toBytes(i * 10 + j)).addColumn(family, qualifier, value));
    }
    admin.flush(tableName);
    edge.increment(1001);
  }
  return getStoreWithName(tableName);
}
 
Example #17
Source File: IntegrationTestIngestWithMOB.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Override
protected void initTable() throws IOException {
  super.initTable();

  TableName tableName = getTablename();
  try (Connection connection = ConnectionFactory.createConnection();
       Admin admin = connection.getAdmin()) {
    HTableDescriptor tableDesc = new HTableDescriptor(admin.getDescriptor(tableName));
    LOG.info("Disabling table " + getTablename());
    admin.disableTable(tableName);
    ColumnFamilyDescriptor mobColumn = tableDesc.getColumnFamily(mobColumnFamily);
    ColumnFamilyDescriptor cfd = ColumnFamilyDescriptorBuilder.newBuilder(mobColumn)
      .setMobEnabled(true)
      .setMobThreshold((long) threshold)
      .build();
    admin.modifyColumnFamily(tableName, cfd);
    LOG.info("Enabling table " + getTablename());
    admin.enableTable(tableName);
  }
}
 
Example #18
Source File: TestBlocksScanned.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Test
public void testBlocksScannedWithEncoding() throws Exception {
  byte [] tableName = Bytes.toBytes("TestBlocksScannedWithEncoding");
  TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
    new TableDescriptorBuilder.ModifyableTableDescriptor(TableName.valueOf(tableName));

  tableDescriptor.setColumnFamily(
      new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(FAMILY)
      .setMaxVersions(10)
      .setBlockCacheEnabled(true)
      .setDataBlockEncoding(DataBlockEncoding.FAST_DIFF)
      .setBlocksize(BLOCK_SIZE)
      .setCompressionType(Compression.Algorithm.NONE)
      );
  _testBlocksScanned(tableDescriptor);
}
 
Example #19
Source File: TestNamespaceReplicationWithBulkLoadedData.java    From hbase with Apache License 2.0 6 votes vote down vote up
private static void startFourthCluster() throws Exception {
  LOG.info("Setup Zk to same one from UTIL1 and UTIL2 and UTIL3");
  UTIL4.setZkCluster(UTIL1.getZkCluster());
  UTIL4.startMiniCluster(NUM_SLAVES1);

  TableDescriptor table = TableDescriptorBuilder.newBuilder(tableName)
      .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(famName).setMaxVersions(100)
          .setScope(HConstants.REPLICATION_SCOPE_GLOBAL).build())
      .setColumnFamily(ColumnFamilyDescriptorBuilder.of(noRepfamName)).build();

  Connection connection4 = ConnectionFactory.createConnection(CONF4);
  try (Admin admin4 = connection4.getAdmin()) {
    admin4.createTable(table, HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE);
  }
  UTIL4.waitUntilAllRegionsAssigned(tableName);
}
 
Example #20
Source File: TestCoprocessorMetrics.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Test
public void testRegionObserverMultiCoprocessor() throws IOException {
  final TableName tableName = TableName.valueOf(name.getMethodName());
  try (Connection connection = ConnectionFactory.createConnection(UTIL.getConfiguration());
       Admin admin = connection.getAdmin()) {
    admin.createTable(
      new TableDescriptorBuilder.ModifyableTableDescriptor(tableName)
        .setColumnFamily(
          new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(foo))
        // add the coprocessor for the region. We add two different coprocessors
        .setCoprocessor(CustomRegionObserver.class.getName())
        .setCoprocessor(CustomRegionObserver2.class.getName()));
    try (Table table = connection.getTable(tableName)) {
      table.get(new Get(foo));
      table.get(new Get(foo)); // 2 gets
    }
  }

  // we will have two counters coming from two coprocs, in two different MetricRegistries
  assertPreGetRequestsCounter(CustomRegionObserver.class);
  assertPreGetRequestsCounter(CustomRegionObserver2.class);
}
 
Example #21
Source File: VisibilityController.java    From hbase with Apache License 2.0 6 votes vote down vote up
/********************************* Master related hooks **********************************/

  @Override
  public void postStartMaster(ObserverContext<MasterCoprocessorEnvironment> ctx) throws IOException {
    // Need to create the new system table for labels here
    if (!MetaTableAccessor.tableExists(ctx.getEnvironment().getConnection(), LABELS_TABLE_NAME)) {
      TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
        new TableDescriptorBuilder.ModifyableTableDescriptor(LABELS_TABLE_NAME);
      ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor familyDescriptor =
        new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(LABELS_TABLE_FAMILY);
      familyDescriptor.setBloomFilterType(BloomType.NONE);
      // We will cache all the labels. No need of normal
      // table block cache.
      familyDescriptor.setBlockCacheEnabled(false);
      tableDescriptor.setColumnFamily(familyDescriptor);
      // Let the "labels" table having only one region always. We are not expecting too many labels in
      // the system.
      tableDescriptor.setValue(HTableDescriptor.SPLIT_POLICY,
          DisabledRegionSplitPolicy.class.getName());
      try (Admin admin = ctx.getEnvironment().getConnection().getAdmin()) {
        admin.createTable(tableDescriptor);
      }
    }
  }
 
Example #22
Source File: AccessController.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Create the ACL table
 * @throws IOException
 */
private static void createACLTable(Admin admin) throws IOException {
  /** Table descriptor for ACL table */
  ColumnFamilyDescriptor cfd =
      ColumnFamilyDescriptorBuilder.newBuilder(PermissionStorage.ACL_LIST_FAMILY).
      setMaxVersions(1).
      setInMemory(true).
      setBlockCacheEnabled(true).
      setBlocksize(8 * 1024).
      setBloomFilterType(BloomType.NONE).
      setScope(HConstants.REPLICATION_SCOPE_LOCAL).build();
  TableDescriptor td =
      TableDescriptorBuilder.newBuilder(PermissionStorage.ACL_TABLE_NAME).
        setColumnFamily(cfd).build();
  admin.createTable(td);
}
 
Example #23
Source File: TestScannerWithCorruptHFile.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Test(expected = DoNotRetryIOException.class)
public void testScanOnCorruptHFile() throws IOException {
  TableName tableName = TableName.valueOf(name.getMethodName());
  TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
    new TableDescriptorBuilder.ModifyableTableDescriptor(tableName);
  tableDescriptor.setCoprocessor(CorruptHFileCoprocessor.class.getName());
  tableDescriptor.setColumnFamily(
    new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(FAMILY_NAME));
  Table table = TEST_UTIL.createTable(tableDescriptor, null);
  try {
    loadTable(table, 1);
    scan(table);
  } finally {
    table.close();
  }
}
 
Example #24
Source File: BaseTestHBaseFsck.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Setup a clean table with a mob-enabled column.
 *
 * @param tablename The name of a table to be created.
 * @throws Exception
 */
void setupMobTable(TableName tablename) throws Exception {
  TableDescriptorBuilder tableDescriptorBuilder =
    TableDescriptorBuilder.newBuilder(tablename);
  ColumnFamilyDescriptor columnFamilyDescriptor =
    ColumnFamilyDescriptorBuilder
      .newBuilder(FAM)
      .setMobEnabled(true)
      .setMobThreshold(0).build();
  // If a table has no CF's it doesn't get checked
  tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptor);
  createTable(TEST_UTIL, tableDescriptorBuilder.build(), SPLITS);

  tbl = connection.getTable(tablename, tableExecutorService);
  List<Put> puts = new ArrayList<>(ROWKEYS.length);
  for (byte[] row : ROWKEYS) {
    Put p = new Put(row);
    p.addColumn(FAM, Bytes.toBytes("val"), row);
    puts.add(p);
  }
  tbl.put(puts);
}
 
Example #25
Source File: TestMobStoreCompaction.java    From hbase with Apache License 2.0 6 votes vote down vote up
private void init(Configuration conf, long mobThreshold) throws Exception {
  this.conf = conf;
  this.mobCellThreshold = mobThreshold;
  HBaseTestingUtility UTIL = new HBaseTestingUtility(conf);

  compactionThreshold = conf.getInt("hbase.hstore.compactionThreshold", 3);
  tableDescriptor = UTIL.createModifyableTableDescriptor(name.getMethodName());
  familyDescriptor =
    new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(COLUMN_FAMILY);
  familyDescriptor.setMobEnabled(true);
  familyDescriptor.setMobThreshold(mobThreshold);
  familyDescriptor.setMaxVersions(1);
  tableDescriptor.modifyColumnFamily(familyDescriptor);

  RegionInfo regionInfo = RegionInfoBuilder.newBuilder(tableDescriptor.getTableName()).build();
  region = HBaseTestingUtility.createRegionAndWAL(regionInfo,
    UTIL.getDataTestDir(), conf, tableDescriptor, new MobFileCache(conf));
  fs = FileSystem.get(conf);
}
 
Example #26
Source File: TestHTableDescriptor.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Test(expected=IllegalArgumentException.class)
public void testAddDuplicateFamilies() {
  TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
    new TableDescriptorBuilder.ModifyableTableDescriptor(
      TableName.valueOf(name.getMethodName()));
  byte[] familyName = Bytes.toBytes("cf");
  ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor familyDescriptor =
    new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(familyName)
      .setBlocksize(1000);
  tableDescriptor.setColumnFamily(familyDescriptor);
  assertEquals(1000, tableDescriptor.getColumnFamily(familyName).getBlocksize());
  familyDescriptor =
    new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(familyName)
      .setBlocksize(2000);
  tableDescriptor.setColumnFamily(familyDescriptor);
}
 
Example #27
Source File: SnapshotTestingUtils.java    From hbase with Apache License 2.0 5 votes vote down vote up
public static void createTable(final HBaseTestingUtility util, final TableName tableName,
    int regionReplication, int nRegions, final byte[]... families)
    throws IOException, InterruptedException {
  TableDescriptorBuilder builder
    = TableDescriptorBuilder
        .newBuilder(tableName)
        .setRegionReplication(regionReplication);
  for (byte[] family : families) {
    builder.setColumnFamily(ColumnFamilyDescriptorBuilder.of(family));
  }
  byte[][] splitKeys = getSplitKeys(nRegions);
  util.createTable(builder.build(), splitKeys);
  assertEquals((splitKeys.length + 1) * regionReplication,
      util.getAdmin().getRegions(tableName).size());
}
 
Example #28
Source File: TestParallelPut.java    From hbase with Apache License 2.0 5 votes vote down vote up
private HRegion initHRegion(byte [] tableName, String callingMethod, byte[] ... families)
    throws IOException {
  TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
    new TableDescriptorBuilder.ModifyableTableDescriptor(TableName.valueOf(tableName));
  for(byte [] family : families) {
    tableDescriptor.setColumnFamily(
      new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(family));
  }
  RegionInfo info = RegionInfoBuilder.newBuilder(tableDescriptor.getTableName()).build();
  return HBTU.createLocalHRegion(info, tableDescriptor);
}
 
Example #29
Source File: TestScannerWithBulkload.java    From hbase with Apache License 2.0 5 votes vote down vote up
private static void createTable(Admin admin, TableName tableName) throws IOException {
  TableDescriptorBuilder tableDescriptorBuilder =
    TableDescriptorBuilder.newBuilder(tableName);
  ColumnFamilyDescriptor columnFamilyDescriptor =
    ColumnFamilyDescriptorBuilder
      .newBuilder(Bytes.toBytes("col"))
      .setMaxVersions(3).build();
  tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptor);
  admin.createTable(tableDescriptorBuilder.build());
}
 
Example #30
Source File: SerialReplicationTestBase.java    From hbase with Apache License 2.0 5 votes vote down vote up
protected final TableName createTable() throws IOException, InterruptedException {
  TableName tableName = TableName.valueOf(name.getMethodName());
  UTIL.getAdmin().createTable(
    TableDescriptorBuilder.newBuilder(tableName).setColumnFamily(ColumnFamilyDescriptorBuilder
      .newBuilder(CF).setScope(HConstants.REPLICATION_SCOPE_GLOBAL).build()).build());
  UTIL.waitTableAvailable(tableName);
  return tableName;
}