org.apache.hadoop.hbase.client.TableDescriptorBuilder Java Examples
The following examples show how to use
org.apache.hadoop.hbase.client.TableDescriptorBuilder.
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: RowResourceBase.java From hbase with Apache License 2.0 | 7 votes |
@Before public void beforeMethod() throws Exception { Admin admin = TEST_UTIL.getAdmin(); if (admin.tableExists(TABLE_NAME)) { TEST_UTIL.deleteTable(TABLE_NAME); } TableDescriptorBuilder tableDescriptorBuilder = TableDescriptorBuilder.newBuilder(TableName.valueOf(TABLE)); ColumnFamilyDescriptor columnFamilyDescriptor = ColumnFamilyDescriptorBuilder .newBuilder(Bytes.toBytes(CFA)).build(); tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptor); columnFamilyDescriptor = ColumnFamilyDescriptorBuilder .newBuilder(Bytes.toBytes(CFB)).build(); tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptor); admin.createTable(tableDescriptorBuilder.build()); }
Example #2
Source File: PhoenixHBaseAccessor.java From ambari-metrics with Apache License 2.0 | 6 votes |
private boolean setDurabilityForTable(String tableName, TableDescriptorBuilder tableDescriptorBuilder, TableDescriptor tableDescriptor) { String tableDurability = metricsConf.get("timeline.metrics." + tableName + ".durability", ""); if (StringUtils.isEmpty(tableDurability) || tableDescriptor.getDurability().toString().equals(tableDurability)) { return false; } if (StringUtils.isNotEmpty(tableDurability)) { LOG.info("Setting WAL option " + tableDurability + " for table : " + tableName); boolean validDurability = true; if ("SKIP_WAL".equals(tableDurability)) { tableDescriptorBuilder.setDurability(Durability.SKIP_WAL); } else if ("SYNC_WAL".equals(tableDurability)) { tableDescriptorBuilder.setDurability(Durability.SYNC_WAL); } else if ("ASYNC_WAL".equals(tableDurability)) { tableDescriptorBuilder.setDurability(Durability.ASYNC_WAL); } else if ("FSYNC_WAL".equals(tableDurability)) { tableDescriptorBuilder.setDurability(Durability.FSYNC_WAL); } else { LOG.info("Unknown value for durability : " + tableDurability); validDurability = false; } return validDurability; } return false; }
Example #3
Source File: AddColumnAction.java From hbase with Apache License 2.0 | 6 votes |
@Override public void perform() throws Exception { TableDescriptor tableDescriptor = admin.getDescriptor(tableName); ColumnFamilyDescriptor columnDescriptor = null; while (columnDescriptor == null || tableDescriptor.getColumnFamily(columnDescriptor.getName()) != null) { columnDescriptor = ColumnFamilyDescriptorBuilder.of(RandomStringUtils.randomAlphabetic(5)); } // Don't try the modify if we're stopping if (context.isStopping()) { return; } getLogger().debug("Performing action: Adding " + columnDescriptor + " to " + tableName); TableDescriptor modifiedTable = TableDescriptorBuilder.newBuilder(tableDescriptor) .setColumnFamily(columnDescriptor).build(); admin.modifyTable(modifiedTable); }
Example #4
Source File: IntegrationTestWithCellVisibilityLoadAndVerify.java From hbase with Apache License 2.0 | 6 votes |
@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 #5
Source File: TestMobDataBlockEncoding.java From hbase with Apache License 2.0 | 6 votes |
public void setUp(long threshold, String TN, DataBlockEncoding encoding) throws Exception { tableDescriptor = new TableDescriptorBuilder.ModifyableTableDescriptor(TableName.valueOf(TN)); columnFamilyDescriptor = new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(family); columnFamilyDescriptor.setMobEnabled(true); columnFamilyDescriptor.setMobThreshold(threshold); columnFamilyDescriptor.setMaxVersions(4); columnFamilyDescriptor.setDataBlockEncoding(encoding); tableDescriptor.setColumnFamily(columnFamilyDescriptor); admin = TEST_UTIL.getAdmin(); admin.createTable(tableDescriptor); table = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration()) .getTable(TableName.valueOf(TN)); }
Example #6
Source File: TransactionProcessorTest.java From phoenix-tephra with Apache License 2.0 | 6 votes |
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 #7
Source File: HMaster.java From hbase with Apache License 2.0 | 6 votes |
@Override public long modifyColumn(final TableName tableName, final ColumnFamilyDescriptor descriptor, 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(descriptor.getName())) { throw new InvalidFamilyOperationException("Family '" + descriptor.getNameAsString() + "' does not exist, so it cannot be modified"); } return TableDescriptorBuilder.newBuilder(old).modifyColumnFamily(descriptor).build(); } }, nonceGroup, nonce, true); }
Example #8
Source File: BackupSystemTable.java From hbase with Apache License 2.0 | 6 votes |
/** * Get backup system table descriptor * @return table's descriptor */ public static TableDescriptor getSystemTableDescriptor(Configuration conf) { TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(getTableName(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 #9
Source File: HBaseTestingUtility.java From hbase with Apache License 2.0 | 6 votes |
public HTableDescriptor createTableDescriptor(final TableName tableName, byte[][] families, int maxVersions) { TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor = new TableDescriptorBuilder.ModifyableTableDescriptor(tableName); for (byte[] family : families) { ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor familyDescriptor = new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(family) .setMaxVersions(maxVersions); if (isNewVersionBehaviorEnabled()) { familyDescriptor.setNewVersionBehavior(true); } tableDescriptor.setColumnFamily(familyDescriptor); } return new HTableDescriptor(tableDescriptor); }
Example #10
Source File: TestMasterOperationsForRegionReplicas.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testCreateTableWithSingleReplica() throws Exception { final int numRegions = 3; final int numReplica = 1; final TableName tableName = TableName.valueOf(name.getMethodName()); try { TableDescriptor desc = TableDescriptorBuilder.newBuilder(tableName).setRegionReplication(numReplica) .setColumnFamily(ColumnFamilyDescriptorBuilder.of("family")).build(); ADMIN.createTable(desc, Bytes.toBytes("A"), Bytes.toBytes("Z"), numRegions); TEST_UTIL.waitUntilAllRegionsAssigned(tableName); TEST_UTIL.waitUntilNoRegionsInTransition(); validateNumberOfRowsInMeta(tableName, numRegions, ADMIN.getConnection()); List<RegionInfo> hris = MetaTableAccessor.getTableRegions(ADMIN.getConnection(), tableName); assertEquals(numRegions * numReplica, hris.size()); } finally { ADMIN.disableTable(tableName); ADMIN.deleteTable(tableName); } }
Example #11
Source File: HBaseTestingUtility.java From hbase with Apache License 2.0 | 6 votes |
/** * Create a table. * @param tableName * @param families * @param numVersions * @return A Table instance for the created table. * @throws IOException */ public Table createTable(TableName tableName, byte[][] families, int[] numVersions) throws IOException { TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor = new TableDescriptorBuilder.ModifyableTableDescriptor(tableName); int i = 0; for (byte[] family : families) { ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor familyDescriptor = new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(family) .setMaxVersions(numVersions[i]); if (isNewVersionBehaviorEnabled()) { familyDescriptor.setNewVersionBehavior(true); } tableDescriptor.setColumnFamily(familyDescriptor); i++; } 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 #12
Source File: TestAccessController.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testTableCreate() throws Exception { AccessTestAction createTable = new AccessTestAction() { @Override public Object run() throws Exception { TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor = new TableDescriptorBuilder.ModifyableTableDescriptor( TableName.valueOf(name.getMethodName())); tableDescriptor.setColumnFamily( new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(TEST_FAMILY)); ACCESS_CONTROLLER.preCreateTable(ObserverContextImpl.createAndPrepare(CP_ENV), tableDescriptor, null); return null; } }; // verify that superuser can create tables verifyAllowed(createTable, SUPERUSER, USER_ADMIN, USER_GROUP_CREATE, USER_GROUP_ADMIN); // all others should be denied verifyDenied(createTable, USER_CREATE, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ, USER_GROUP_WRITE); }
Example #13
Source File: RSGroupableBalancerTestBase.java From hbase with Apache License 2.0 | 6 votes |
/** * Construct table descriptors evenly distributed between the groups. * @param hasBogusTable there is a table that does not determine the group * @return the list of table descriptors */ protected static Map<TableName, TableDescriptor> constructTableDesc(boolean hasBogusTable) { Map<TableName, TableDescriptor> tds = new HashMap<>(); int index = rand.nextInt(groups.length); for (int i = 0; i < tables.length; i++) { int grpIndex = (i + index) % groups.length; String groupName = groups[grpIndex]; TableDescriptor htd = TableDescriptorBuilder.newBuilder(tables[i]).setRegionServerGroup(groupName).build(); tds.put(htd.getTableName(), htd); } if (hasBogusTable) { tds.put(table0, TableDescriptorBuilder.newBuilder(table0).setRegionServerGroup("").build()); } return tds; }
Example #14
Source File: SpaceQuotaHelperForTests.java From hbase with Apache License 2.0 | 6 votes |
TableName createTableInNamespace(NamespaceDescriptor nd) throws Exception { final Admin admin = testUtil.getAdmin(); final TableName tn = TableName.valueOf(nd.getName(), testName.getMethodName() + counter.getAndIncrement()); // Delete the old table if (admin.tableExists(tn)) { admin.disableTable(tn); admin.deleteTable(tn); } // Create the table TableDescriptor tableDesc = TableDescriptorBuilder.newBuilder(tn) .setColumnFamily(ColumnFamilyDescriptorBuilder.of(F1)).build(); admin.createTable(tableDesc); return tn; }
Example #15
Source File: TestTableDescriptorModificationFromClient.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testDeleteColumn() throws IOException { Admin admin = TEST_UTIL.getAdmin(); // Create a table with two families TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor = new TableDescriptorBuilder.ModifyableTableDescriptor(TABLE_NAME); tableDescriptor.setColumnFamily( new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(FAMILY_0)); tableDescriptor.setColumnFamily( new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(FAMILY_1)); admin.createTable(tableDescriptor); admin.disableTable(TABLE_NAME); try { // Verify the table descriptor verifyTableDescriptor(TABLE_NAME, FAMILY_0, FAMILY_1); // Modify the table removing one family and verify the descriptor admin.deleteColumnFamily(TABLE_NAME, FAMILY_1); verifyTableDescriptor(TABLE_NAME, FAMILY_0); } finally { admin.deleteTable(TABLE_NAME); } }
Example #16
Source File: HBaseTestingUtility.java From hbase with Apache License 2.0 | 6 votes |
/** * Creates a pre-split table for load testing. If the table already exists, * logs a warning and continues. * @return the number of regions the table was split into */ public static int createPreSplitLoadTestTable(Configuration conf, TableName tableName, byte[] columnFamily, Algorithm compression, DataBlockEncoding dataBlockEncoding, int numRegionsPerServer, int regionReplication, Durability durability) throws IOException { TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor = new TableDescriptorBuilder.ModifyableTableDescriptor(tableName); tableDescriptor.setDurability(durability); tableDescriptor.setRegionReplication(regionReplication); ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor familyDescriptor = new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(columnFamily); familyDescriptor.setDataBlockEncoding(dataBlockEncoding); familyDescriptor.setCompressionType(compression); return createPreSplitLoadTestTable(conf, tableDescriptor, familyDescriptor, numRegionsPerServer); }
Example #17
Source File: TestMiniClusterLoadSequential.java From hbase with Apache License 2.0 | 6 votes |
protected void prepareForLoadTest() throws IOException { LOG.info("Starting load test: dataBlockEncoding=" + dataBlockEncoding + ", isMultiPut=" + isMultiPut); numKeys = numKeys(); Admin admin = TEST_UTIL.getAdmin(); while (admin.getClusterMetrics(EnumSet.of(Option.LIVE_SERVERS)) .getLiveServerMetrics().size() < NUM_RS) { LOG.info("Sleeping until " + NUM_RS + " RSs are online"); Threads.sleepWithoutInterrupt(1000); } admin.close(); TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor = new TableDescriptorBuilder.ModifyableTableDescriptor(TABLE); ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor familyDescriptor = new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(CF) .setCompressionType(compression) .setDataBlockEncoding(dataBlockEncoding); createPreSplitLoadTestTable(tableDescriptor, familyDescriptor); LoadTestDataGenerator dataGen = new MultiThreadedAction.DefaultDataGenerator(CF); writerThreads = prepareWriterThreads(dataGen, conf, TABLE); readerThreads = prepareReaderThreads(dataGen, conf, TABLE, 100); }
Example #18
Source File: TestProcedurePriority.java From hbase with Apache License 2.0 | 6 votes |
@BeforeClass public static void setUp() throws Exception { UTIL.getConfiguration().setLong(ProcedureExecutor.WORKER_KEEP_ALIVE_TIME_CONF_KEY, 5000); UTIL.getConfiguration().setInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, 4); UTIL.getConfiguration().set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, MyCP.class.getName()); UTIL.startMiniCluster(3); CORE_POOL_SIZE = UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor().getCorePoolSize(); TABLE_COUNT = 50 * CORE_POOL_SIZE; List<Future<?>> futures = new ArrayList<>(); AsyncAdmin admin = UTIL.getAsyncConnection().getAdmin(); Semaphore concurrency = new Semaphore(10); for (int i = 0; i < TABLE_COUNT; i++) { concurrency.acquire(); futures.add(admin .createTable(TableDescriptorBuilder.newBuilder(TableName.valueOf(TABLE_NAME_PREFIX + i)) .setColumnFamily(ColumnFamilyDescriptorBuilder.of(CF)).build()) .whenComplete((r, e) -> concurrency.release())); } for (Future<?> future : futures) { future.get(3, TimeUnit.MINUTES); } UTIL.getAdmin().balance(true); UTIL.waitUntilNoRegionsInTransition(); }
Example #19
Source File: TestFSTableDescriptorForceCreation.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testShouldNotCreateTheSameTableDescriptorIfForcefulCreationIsFalse() throws IOException { final String name = this.name.getMethodName(); FileSystem fs = FileSystem.get(UTIL.getConfiguration()); // Cleanup old tests if any detritus laying around. Path rootdir = new Path(UTIL.getDataTestDir(), name); FSTableDescriptors fstd = new FSTableDescriptors(fs, rootdir); TableDescriptor htd = TableDescriptorBuilder.newBuilder(TableName.valueOf(name)).build(); fstd.update(htd); assertFalse("Should not create new table descriptor", fstd.createTableDescriptor(htd, false)); }
Example #20
Source File: TestCatalogJanitor.java From hbase with Apache License 2.0 | 5 votes |
/** * @return A TableDescriptor with a tableName of current method name and a column family that is * MockMasterServices.DEFAULT_COLUMN_FAMILY_NAME) */ private TableDescriptor createTableDescriptorForCurrentMethod() { ColumnFamilyDescriptor columnFamilyDescriptor = ColumnFamilyDescriptorBuilder .newBuilder(Bytes.toBytes(MockMasterServices.DEFAULT_COLUMN_FAMILY_NAME)).build(); return TableDescriptorBuilder.newBuilder(TableName.valueOf(this.name.getMethodName())) .setColumnFamily(columnFamilyDescriptor).build(); }
Example #21
Source File: TestReplicationEditsDroppedWithDroppedTable.java From hbase with Apache License 2.0 | 5 votes |
private void createTable(TableName tableName) throws Exception { TableDescriptor desc = TableDescriptorBuilder.newBuilder(tableName).setColumnFamily( ColumnFamilyDescriptorBuilder.newBuilder(FAMILY) .setScope(HConstants.REPLICATION_SCOPE_GLOBAL).build() ).build(); admin1.createTable(desc); admin2.createTable(desc); utility1.waitUntilAllRegionsAssigned(tableName); utility2.waitUntilAllRegionsAssigned(tableName); }
Example #22
Source File: TestPostIncrementAndAppendBeforeWAL.java From hbase with Apache License 2.0 | 5 votes |
private void createTableWithCoprocessor(TableName tableName, String coprocessor) throws IOException { TableDescriptor tableDesc = TableDescriptorBuilder.newBuilder(tableName) .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(CF1_BYTES).build()) .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(CF2_BYTES).build()) .setCoprocessor(coprocessor).build(); connection.getAdmin().createTable(tableDesc); }
Example #23
Source File: TestBlocksScanned.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testBlocksScanned() throws Exception { byte [] tableName = Bytes.toBytes("TestBlocksScanned"); TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor = new TableDescriptorBuilder.ModifyableTableDescriptor(TableName.valueOf(tableName)); tableDescriptor.setColumnFamily( new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(FAMILY) .setMaxVersions(10) .setBlockCacheEnabled(true) .setBlocksize(BLOCK_SIZE) .setCompressionType(Compression.Algorithm.NONE) ); _testBlocksScanned(tableDescriptor); }
Example #24
Source File: HBaseFsck.java From hbase with Apache License 2.0 | 5 votes |
/** * To fabricate a .tableinfo file with following contents<br> * 1. the correct tablename <br> * 2. the correct colfamily list<br> * 3. the default properties for both {@link TableDescriptor} and {@link ColumnFamilyDescriptor}<br> * @throws IOException */ private boolean fabricateTableInfo(FSTableDescriptors fstd, TableName tableName, Set<String> columns) throws IOException { if (columns ==null || columns.isEmpty()) return false; TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableName); for (String columnfamimly : columns) { builder.setColumnFamily(ColumnFamilyDescriptorBuilder.of(columnfamimly)); } fstd.createTableDescriptor(builder.build(), true); return true; }
Example #25
Source File: TestNotCleanupCompactedFileWhenRegionWarmup.java From hbase with Apache License 2.0 | 5 votes |
@Before public void before() throws Exception { TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(TABLE_NAME); builder.setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILY)); admin.createTable(builder.build()); TEST_UTIL.waitTableAvailable(TABLE_NAME); table = TEST_UTIL.getConnection().getTable(TABLE_NAME); }
Example #26
Source File: TestMasterObserverPostCalls.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testPostDeleteNamespace() throws IOException { final Admin admin = UTIL.getAdmin(); final String ns = "postdeletens"; final TableName tn1 = TableName.valueOf(ns, "table1"); admin.createNamespace(NamespaceDescriptor.create(ns).build()); admin.createTable(TableDescriptorBuilder.newBuilder(tn1) .setColumnFamily(ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes("f1")).build()) .build()); HMaster master = UTIL.getMiniHBaseCluster().getMaster(); MasterObserverForTest observer = master.getMasterCoprocessorHost().findCoprocessor( MasterObserverForTest.class); int preCount = observer.postHookCalls.get(); try { admin.deleteNamespace(ns); fail("Deleting a non-empty namespace should be disallowed"); } catch (IOException e) { // Pass } int postCount = observer.postHookCalls.get(); assertEquals("Expected no invocations of postDeleteNamespace when the operation fails", preCount, postCount); // Disable and delete the table so that we can delete the NS. admin.disableTable(tn1); admin.deleteTable(tn1); // Validate that the postDeletNS hook is invoked preCount = observer.postHookCalls.get(); admin.deleteNamespace(ns); postCount = observer.postHookCalls.get(); assertEquals("Expected 1 invocation of postDeleteNamespace", preCount + 1, postCount); }
Example #27
Source File: TestNewVersionBehaviorFromClientSide.java From hbase with Apache License 2.0 | 5 votes |
private Table createTable() throws IOException { TableName tableName = TableName.valueOf(name.getMethodName()); TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor = new TableDescriptorBuilder.ModifyableTableDescriptor(tableName); ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor familyDescriptor = new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(FAMILY); familyDescriptor.setNewVersionBehavior(true); familyDescriptor.setMaxVersions(3); tableDescriptor.setColumnFamily(familyDescriptor); TEST_UTIL.getAdmin().createTable(tableDescriptor); return TEST_UTIL.getConnection().getTable(tableName); }
Example #28
Source File: TestIgnoreUnknownFamily.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testSplit() throws IOException, InterruptedException, ExecutionException, TimeoutException { TableName tableName = TableName.valueOf(name.getMethodName()); Admin admin = UTIL.getAdmin(); admin.createTable(TableDescriptorBuilder.newBuilder(tableName) .setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILY)).build()); RegionInfo region = admin.getRegions(tableName).get(0); addStoreFileToKnownFamily(region); admin.splitRegionAsync(region.getRegionName(), Bytes.toBytes(0)).get(30, TimeUnit.SECONDS); }
Example #29
Source File: TestVerifyReplication.java From hbase with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUpBeforeClass() throws Exception { TestReplicationBase.setUpBeforeClass(); TableDescriptor peerTable = TableDescriptorBuilder.newBuilder(peerTableName).setColumnFamily( ColumnFamilyDescriptorBuilder.newBuilder(noRepfamName).setMaxVersions(100) .build()).build(); Connection connection2 = ConnectionFactory.createConnection(CONF2); try (Admin admin2 = connection2.getAdmin()) { admin2.createTable(peerTable, HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE); } htable3 = connection2.getTable(peerTableName); }
Example #30
Source File: TestDefaultMemStore.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testShouldFlushMeta() throws Exception { // write an edit in the META and ensure the shouldFlush (that the periodic memstore // flusher invokes) returns true after SYSTEM_CACHE_FLUSH_INTERVAL (even though // the MEMSTORE_PERIODIC_FLUSH_INTERVAL is set to a higher value) Configuration conf = new Configuration(); conf.setInt(HRegion.MEMSTORE_PERIODIC_FLUSH_INTERVAL, HRegion.SYSTEM_CACHE_FLUSH_INTERVAL * 10); HBaseTestingUtility hbaseUtility = new HBaseTestingUtility(conf); Path testDir = hbaseUtility.getDataTestDir(); EnvironmentEdgeForMemstoreTest edge = new EnvironmentEdgeForMemstoreTest(); EnvironmentEdgeManager.injectEdge(edge); edge.setCurrentTimeMillis(1234); WALFactory wFactory = new WALFactory(conf, "1234"); TableDescriptors tds = new FSTableDescriptors(conf); FSTableDescriptors.tryUpdateMetaTableDescriptor(conf); HRegion meta = HRegion.createHRegion(RegionInfoBuilder.FIRST_META_REGIONINFO, testDir, conf, tds.get(TableName.META_TABLE_NAME), wFactory.getWAL(RegionInfoBuilder.FIRST_META_REGIONINFO)); // parameterized tests add [#] suffix get rid of [ and ]. TableDescriptor desc = TableDescriptorBuilder .newBuilder(TableName.valueOf(name.getMethodName().replaceAll("[\\[\\]]", "_"))) .setColumnFamily(ColumnFamilyDescriptorBuilder.of("foo")).build(); RegionInfo hri = RegionInfoBuilder.newBuilder(desc.getTableName()) .setStartKey(Bytes.toBytes("row_0200")).setEndKey(Bytes.toBytes("row_0300")).build(); HRegion r = HRegion.createHRegion(hri, testDir, conf, desc, wFactory.getWAL(hri)); addRegionToMETA(meta, r); edge.setCurrentTimeMillis(1234 + 100); StringBuilder sb = new StringBuilder(); assertTrue(meta.shouldFlush(sb) == false); edge.setCurrentTimeMillis(edge.currentTime() + HRegion.SYSTEM_CACHE_FLUSH_INTERVAL + 1); assertTrue(meta.shouldFlush(sb) == true); }