org.apache.hadoop.hbase.client.TableDescriptor Java Examples
The following examples show how to use
org.apache.hadoop.hbase.client.TableDescriptor.
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: TestDeleteMobTable.java From hbase with Apache License 2.0 | 6 votes |
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; }
Example #2
Source File: SnapshotScannerHDFSAclController.java From hbase with Apache License 2.0 | 6 votes |
@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()); } } }
Example #3
Source File: IntegrationTestBackupRestore.java From hbase with Apache License 2.0 | 6 votes |
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)); }
Example #4
Source File: MasterProcedureTestingUtility.java From hbase with Apache License 2.0 | 6 votes |
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)); } }
Example #5
Source File: SnapshotTestingUtils.java From hbase with Apache License 2.0 | 6 votes |
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); }
Example #6
Source File: FSTableDescriptors.java From hbase with Apache License 2.0 | 6 votes |
/** * 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; }
Example #7
Source File: TestStoreFileRefresherChore.java From hbase with Apache License 2.0 | 6 votes |
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; }
Example #8
Source File: TestRSGroupsBasics.java From hbase with Apache License 2.0 | 6 votes |
@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()); }
Example #9
Source File: HMaster.java From hbase with Apache License 2.0 | 6 votes |
@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); }
Example #10
Source File: TestDeleteMobTable.java From hbase with Apache License 2.0 | 6 votes |
@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)); }
Example #11
Source File: SetPropertyIT.java From phoenix with Apache License 2.0 | 6 votes |
@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()); } }
Example #12
Source File: RestoreTool.java From hbase with Apache License 2.0 | 6 votes |
/** * 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; }
Example #13
Source File: TestRegionSplitPolicy.java From hbase with Apache License 2.0 | 6 votes |
@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()); }
Example #14
Source File: HBaseAtlasCoprocessor.java From atlas with Apache License 2.0 | 6 votes |
@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()"); } }
Example #15
Source File: FlappingAlterTableIT.java From phoenix with Apache License 2.0 | 6 votes |
@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()); } }
Example #16
Source File: TestRegionSplitPolicy.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testGetSplitPoint() throws IOException { TableDescriptor td = TableDescriptorBuilder.newBuilder(TABLENAME).build(); doReturn(td).when(mockRegion).getTableDescriptor(); ConstantSizeRegionSplitPolicy policy = (ConstantSizeRegionSplitPolicy) RegionSplitPolicy.create(mockRegion, conf); // For no stores, should not split assertFalse(policy.shouldSplit()); assertNull(policy.getSplitPoint()); // Add a store above the requisite size. Should split. HStore mockStore = mock(HStore.class); doReturn(2000L).when(mockStore).getSize(); doReturn(true).when(mockStore).canSplit(); doReturn(Optional.of(Bytes.toBytes("store 1 split"))).when(mockStore).getSplitPoint(); stores.add(mockStore); assertEquals("store 1 split", Bytes.toString(policy.getSplitPoint())); // Add a bigger store. The split point should come from that one HStore mockStore2 = mock(HStore.class); doReturn(4000L).when(mockStore2).getSize(); doReturn(true).when(mockStore2).canSplit(); doReturn(Optional.of(Bytes.toBytes("store 2 split"))).when(mockStore2).getSplitPoint(); stores.add(mockStore2); assertEquals("store 2 split", Bytes.toString(policy.getSplitPoint())); }
Example #17
Source File: TestMasterProcedureEvents.java From hbase with Apache License 2.0 | 5 votes |
@After public void tearDown() throws Exception { for (TableDescriptor htd: UTIL.getAdmin().listTableDescriptors()) { LOG.info("Tear down, remove table=" + htd.getTableName()); UTIL.deleteTable(htd.getTableName()); } }
Example #18
Source File: RSGroupInfoManagerImpl.java From hbase with Apache License 2.0 | 5 votes |
@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); }
Example #19
Source File: TestFSTableDescriptors.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testCacheConsistency() throws IOException, InterruptedException { final String name = this.name.getMethodName(); FileSystem fs = FileSystem.get(UTIL.getConfiguration()); // Cleanup old tests if any debris laying around. Path rootdir = new Path(UTIL.getDataTestDir(), name); FSTableDescriptors chtds = new FSTableDescriptorsTest(fs, rootdir); FSTableDescriptors nonchtds = new FSTableDescriptorsTest(fs, rootdir, false); final int count = 10; // Write out table infos via non-cached FSTableDescriptors for (int i = 0; i < count; i++) { nonchtds.createTableDescriptor(TableDescriptorBuilder.newBuilder(TableName.valueOf(name + i)).build()); } // Calls to getAll() won't increase the cache counter, do per table. for (int i = 0; i < count; i++) { assertTrue(chtds.get(TableName.valueOf(name + i)) != null); } assertTrue(nonchtds.getAll().size() == chtds.getAll().size()); // add a new entry for random table name. TableName random = TableName.valueOf("random"); TableDescriptor htd = TableDescriptorBuilder.newBuilder(random).build(); nonchtds.createTableDescriptor(htd); // random will only increase the cachehit by 1 assertEquals(nonchtds.getAll().size(), chtds.getAll().size() + 1); for (Map.Entry<String, TableDescriptor> entry: nonchtds.getAll().entrySet()) { String t = (String) entry.getKey(); TableDescriptor nchtd = entry.getValue(); assertTrue("expected " + htd.toString() + " got: " + chtds.get(TableName.valueOf(t)).toString(), (nchtd.equals(chtds.get(TableName.valueOf(t))))); } }
Example #20
Source File: SetPropertyIT.java From phoenix with Apache License 2.0 | 5 votes |
@Test public void testSetHColumnPropertyAndAddColumnForNewCFForTableWithOnlyPKCols() throws Exception { Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); conn.setAutoCommit(false); try { String ddl = "create table " + dataTableFullName + " (" + " id char(1) NOT NULL," + " col1 integer NOT NULL," + " col2 bigint NOT NULL," + " CONSTRAINT NAME_PK PRIMARY KEY (id, col1, col2)" + " ) " + generateDDLOptions("TTL=86400, SALT_BUCKETS = 4, DEFAULT_COLUMN_FAMILY='XYZ'"); conn.createStatement().execute(ddl); ddl = "ALTER TABLE " + dataTableFullName + " ADD NEWCF.COL3 INTEGER IN_MEMORY=true"; conn.createStatement().execute(ddl); conn.commit(); try (Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin()) { TableDescriptor tableDesc = admin.getDescriptor(TableName.valueOf(dataTableFullName)); ColumnFamilyDescriptor[] columnFamilies = tableDesc.getColumnFamilies(); assertEquals(2, columnFamilies.length); assertEquals("NEWCF", columnFamilies[0].getNameAsString()); assertEquals(true, columnFamilies[0].isInMemory()); assertEquals("XYZ", columnFamilies[1].getNameAsString()); assertEquals(false, columnFamilies[1].isInMemory()); } } finally { conn.close(); } }
Example #21
Source File: HRegionFileSystem.java From hbase with Apache License 2.0 | 5 votes |
/** * Check whether region has Reference file * @param htd table desciptor of the region * @return true if region has reference file * @throws IOException */ public boolean hasReferences(final TableDescriptor htd) throws IOException { for (ColumnFamilyDescriptor family : htd.getColumnFamilies()) { if (hasReferences(family.getNameAsString())) { return true; } } return false; }
Example #22
Source File: IndexVerificationOutputRepository.java From phoenix with Apache License 2.0 | 5 votes |
public void createOutputTable(Connection connection) throws IOException, SQLException { ConnectionQueryServices queryServices = connection.unwrap(PhoenixConnection.class).getQueryServices(); Admin admin = queryServices.getAdmin(); TableName outputTableName = TableName.valueOf(OUTPUT_TABLE_NAME); if (!admin.tableExists(outputTableName)) { ColumnFamilyDescriptor columnDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(OUTPUT_TABLE_COLUMN_FAMILY). setTimeToLive(MetaDataProtocol.DEFAULT_LOG_TTL).build(); TableDescriptor tableDescriptor = TableDescriptorBuilder.newBuilder(outputTableName). setColumnFamily(columnDescriptor).build(); admin.createTable(tableDescriptor); outputTable = admin.getConnection().getTable(outputTableName); } }
Example #23
Source File: TestSerialization.java From hbase with Apache License 2.0 | 5 votes |
private RegionInfo createRandomRegion(final String name) { TableDescriptorBuilder tableDescriptorBuilder = TableDescriptorBuilder.newBuilder(TableName.valueOf(name)); String[] families = new String[] { "info", "anchor" }; for (int i = 0; i < families.length; i++) { ColumnFamilyDescriptor columnFamilyDescriptor = ColumnFamilyDescriptorBuilder.newBuilder(Bytes.toBytes(families[i])).build(); tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptor); } TableDescriptor tableDescriptor = tableDescriptorBuilder.build(); return RegionInfoBuilder.newBuilder(tableDescriptor.getTableName()).build(); }
Example #24
Source File: AbstractTestLogRolling.java From hbase with Apache License 2.0 | 5 votes |
protected Table createTestTable(String tableName) throws IOException { // Create the test table and open it TableDescriptor desc = TableDescriptorBuilder.newBuilder(TableName.valueOf(getName())) .setColumnFamily(ColumnFamilyDescriptorBuilder.of(HConstants.CATALOG_FAMILY)).build(); admin.createTable(desc); return TEST_UTIL.getConnection().getTable(desc.getTableName()); }
Example #25
Source File: MasterCoprocessorHost.java From hbase with Apache License 2.0 | 5 votes |
public void preRestoreSnapshot(final SnapshotDescription snapshot, final TableDescriptor hTableDescriptor) throws IOException { execOperation(coprocEnvironments.isEmpty() ? null : new MasterObserverOperation() { @Override public void call(MasterObserver observer) throws IOException { observer.preRestoreSnapshot(this, snapshot, hTableDescriptor); } }); }
Example #26
Source File: TestRegionCoprocessorHost.java From hbase with Apache License 2.0 | 5 votes |
@Before public void setup() throws IOException { conf = HBaseConfiguration.create(); conf.setBoolean(COPROCESSORS_ENABLED_CONF_KEY, true); conf.setBoolean(USER_COPROCESSORS_ENABLED_CONF_KEY, true); TableName tableName = TableName.valueOf(name.getMethodName()); regionInfo = RegionInfoBuilder.newBuilder(tableName).build(); // config a same coprocessor with system coprocessor TableDescriptor tableDesc = TableDescriptorBuilder.newBuilder(tableName) .setCoprocessor(SimpleRegionObserver.class.getName()).build(); region = mock(HRegion.class); when(region.getRegionInfo()).thenReturn(regionInfo); when(region.getTableDescriptor()).thenReturn(tableDesc); rsServices = mock(RegionServerServices.class); }
Example #27
Source File: MasterRpcServices.java From hbase with Apache License 2.0 | 5 votes |
@Override public GetRSGroupInfoOfTableResponse getRSGroupInfoOfTable(RpcController controller, GetRSGroupInfoOfTableRequest request) throws ServiceException { TableName tableName = ProtobufUtil.toTableName(request.getTableName()); LOG.info( master.getClientIdAuditPrefix() + " initiates rsgroup info retrieval, table=" + tableName); try { if (master.getMasterCoprocessorHost() != null) { master.getMasterCoprocessorHost().preGetRSGroupInfoOfTable(tableName); } GetRSGroupInfoOfTableResponse resp; TableDescriptor td = master.getTableDescriptors().get(tableName); if (td == null) { resp = GetRSGroupInfoOfTableResponse.getDefaultInstance(); } else { RSGroupInfo rsGroupInfo = RSGroupUtil.getRSGroupInfo(master, master.getRSGroupInfoManager(), tableName) .orElse(master.getRSGroupInfoManager().getRSGroup(RSGroupInfo.DEFAULT_GROUP)); resp = GetRSGroupInfoOfTableResponse.newBuilder() .setRSGroupInfo(ProtobufUtil.toProtoGroupInfo(rsGroupInfo)).build(); } if (master.getMasterCoprocessorHost() != null) { master.getMasterCoprocessorHost().postGetRSGroupInfoOfTable(tableName); } return resp; } catch (IOException e) { throw new ServiceException(e); } }
Example #28
Source File: TransactionProcessor.java From phoenix-tephra with Apache License 2.0 | 5 votes |
@Override public void start(CoprocessorEnvironment e) throws IOException { if (e instanceof RegionCoprocessorEnvironment) { RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e; this.cacheSupplier = getTransactionStateCacheSupplier(env); this.cache = cacheSupplier.get(); TableDescriptor tableDesc = env.getRegion().getTableDescriptor(); for (ColumnFamilyDescriptor columnDesc : tableDesc.getColumnFamilies()) { byte[] columnTTL = columnDesc.getValue(Bytes.toBytes(TxConstants.PROPERTY_TTL)); long ttl = 0; if (columnTTL != null) { try { ttl = Long.parseLong(Bytes.toString(columnTTL)); LOG.info("Family " + columnDesc.getNameAsString() + " has TTL of " + ttl); } catch (NumberFormatException nfe) { LOG.warn("Invalid TTL value configured for column family " + columnDesc.getNameAsString() + ", value = " + Bytes.toString(columnTTL)); } } ttlByFamily.put(columnDesc.getName(), ttl); } this.allowEmptyValues = getAllowEmptyValues(env, tableDesc); this.txMaxLifetimeMillis = getTxMaxLifetimeMillis(env); this.readNonTxnData = Boolean.valueOf(tableDesc.getValue(TxConstants.READ_NON_TX_DATA)); if (readNonTxnData) { LOG.info("Reading pre-existing data enabled for table " + tableDesc.getTableName().getNameAsString()); } initializePruneState(env); } }
Example #29
Source File: TestVerifyReplicationAdjunct.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: ChangeSplitPolicyAction.java From hbase with Apache License 2.0 | 5 votes |
@Override public void perform() throws Exception { HBaseTestingUtility util = context.getHBaseIntegrationTestingUtility(); Admin admin = util.getAdmin(); getLogger().info("Performing action: Change split policy of table " + tableName); TableDescriptor tableDescriptor = admin.getDescriptor(tableName); TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(tableDescriptor); String chosenPolicy = possiblePolicies[random.nextInt(possiblePolicies.length)]; builder.setRegionSplitPolicyClassName(chosenPolicy); getLogger().info("Changing " + tableName + " split policy to " + chosenPolicy); admin.modifyTable(builder.build()); }