Java Code Examples for org.apache.hadoop.hbase.client.TableDescriptorBuilder#setValue()
The following examples show how to use
org.apache.hadoop.hbase.client.TableDescriptorBuilder#setValue() .
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: ThriftUtilities.java From hbase with Apache License 2.0 | 6 votes |
public static TableDescriptor tableDescriptorFromThrift(TTableDescriptor in) { TableDescriptorBuilder builder = TableDescriptorBuilder .newBuilder(tableNameFromThrift(in.getTableName())); for (TColumnFamilyDescriptor column : in.getColumns()) { builder.setColumnFamily(columnFamilyDescriptorFromThrift(column)); } if (in.isSetAttributes()) { for (Map.Entry<ByteBuffer, ByteBuffer> attribute : in.getAttributes().entrySet()) { builder.setValue(attribute.getKey().array(), attribute.getValue().array()); } } if (in.isSetDurability()) { builder.setDurability(durabilityFromThrift(in.getDurability())); } return builder.build(); }
Example 2
Source File: TestClassLoading.java From hbase with Apache License 2.0 | 6 votes |
@Test // HBASE-3516: Test CP Class loading from local file system public void testClassLoadingFromLocalFS() throws Exception { File jarFile = buildCoprocessorJar(cpName3); // create a table that references the jar TableDescriptorBuilder tdb = TableDescriptorBuilder.newBuilder(TableName.valueOf(cpName3)); tdb.setColumnFamily(ColumnFamilyDescriptorBuilder .newBuilder(Bytes.toBytes("test")).build()); tdb.setValue("COPROCESSOR$1", getLocalPath(jarFile) + "|" + cpName3 + "|" + Coprocessor.PRIORITY_USER); TableDescriptor tableDescriptor = tdb.build(); Admin admin = TEST_UTIL.getAdmin(); admin.createTable(tableDescriptor); waitForTable(tableDescriptor.getTableName()); // verify that the coprocessor was loaded boolean found = false; MiniHBaseCluster hbase = TEST_UTIL.getHBaseCluster(); for (HRegion region: hbase.getRegionServer(0).getOnlineRegionsLocalContext()) { if (region.getRegionInfo().getRegionNameAsString().startsWith(cpName3)) { found = (region.getCoprocessorHost().findCoprocessor(cpName3) != null); } } assertTrue("Class " + cpName3 + " was missing on a region", found); }
Example 3
Source File: TestCreateTableProcedure.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testCreateWithoutColumnFamily() throws Exception { final ProcedureExecutor<MasterProcedureEnv> procExec = getMasterProcedureExecutor(); final TableName tableName = TableName.valueOf(name.getMethodName()); // create table with 0 families will fail final TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(MasterProcedureTestingUtility.createHTD(tableName)); // disable sanity check builder.setValue(TableDescriptorChecker.TABLE_SANITY_CHECKS, Boolean.FALSE.toString()); TableDescriptor htd = builder.build(); final RegionInfo[] regions = ModifyRegionUtils.createRegionInfos(htd, null); long procId = ProcedureTestingUtility.submitAndWait(procExec, new CreateTableProcedure(procExec.getEnvironment(), htd, regions)); final Procedure<?> result = procExec.getResult(procId); assertEquals(true, result.isFailed()); Throwable cause = ProcedureTestingUtility.getExceptionCause(result); assertTrue("expected DoNotRetryIOException, got " + cause, cause instanceof DoNotRetryIOException); }
Example 4
Source File: PhoenixHBaseAccessor.java From ambari-metrics with Apache License 2.0 | 5 votes |
private boolean setCompactionPolicyForTable(String tableName, TableDescriptorBuilder tableDescriptorBuilder, TableDescriptor tableDescriptor) { boolean modifyTable = false; String keyConfig = "timeline.metrics." + tableName + ".compaction.policy.key"; String policyConfig = "timeline.metrics." + tableName + ".compaction.policy"; String storeFilesConfig = "timeline.metrics." + tableName + ".blocking.store.files"; String compactionPolicyKey = metricsConf.get(keyConfig, HSTORE_ENGINE_CLASS); String compactionPolicyClass = metricsConf.get(policyConfig, DATE_TIERED_COMPACTION_POLICY); int blockingStoreFiles = hbaseConf.getInt(storeFilesConfig, 60); if (tableName.equals(METRICS_RECORD_TABLE_NAME)) { compactionPolicyKey = metricsConf.get(keyConfig, HSTORE_COMPACTION_CLASS_KEY); compactionPolicyClass = metricsConf.get(policyConfig, FIFO_COMPACTION_POLICY_CLASS); blockingStoreFiles = hbaseConf.getInt(storeFilesConfig, 1000); } if (!compactionPolicyClass.equals(tableDescriptor.getValue(compactionPolicyKey))) { tableDescriptorBuilder.setValue(compactionPolicyKey, compactionPolicyClass); setHbaseBlockingStoreFiles(tableDescriptorBuilder, tableDescriptor, tableName, blockingStoreFiles); modifyTable = true; LOG.info("Setting compaction policy for " + tableName + ", " + compactionPolicyKey + "=" + compactionPolicyClass); } if (!compactionPolicyKey.equals(HSTORE_ENGINE_CLASS)) { tableDescriptorBuilder.removeValue(HSTORE_ENGINE_CLASS.getBytes()); } if (!compactionPolicyKey.equals(HSTORE_COMPACTION_CLASS_KEY)) { tableDescriptorBuilder.removeValue(HSTORE_COMPACTION_CLASS_KEY.getBytes()); } return modifyTable; }
Example 5
Source File: PhoenixHBaseAccessor.java From ambari-metrics with Apache License 2.0 | 5 votes |
private boolean setHbaseBlockingStoreFiles(TableDescriptorBuilder tableDescriptorBuilder, TableDescriptor tableDescriptor, String tableName, int value) { if (!String.valueOf(value).equals(tableDescriptor.getValue(BLOCKING_STORE_FILES_KEY))) { tableDescriptorBuilder.setValue(BLOCKING_STORE_FILES_KEY, String.valueOf(value)); LOG.info("Setting config property " + BLOCKING_STORE_FILES_KEY + " = " + value + " for " + tableName); return true; } return false; }
Example 6
Source File: TestClassLoading.java From hbase with Apache License 2.0 | 5 votes |
@Test // HBASE-6308: Test CP classloader is the CoprocessorClassLoader public void testPrivateClassLoader() throws Exception { File jarFile = buildCoprocessorJar(cpName4); // create a table that references the jar TableDescriptorBuilder tdb = TableDescriptorBuilder.newBuilder(TableName.valueOf(cpName4)); tdb.setColumnFamily(ColumnFamilyDescriptorBuilder .newBuilder(Bytes.toBytes("test")).build()); tdb.setValue("COPROCESSOR$1", getLocalPath(jarFile) + "|" + cpName4 + "|" + Coprocessor.PRIORITY_USER); TableDescriptor tableDescriptor = tdb.build(); Admin admin = TEST_UTIL.getAdmin(); admin.createTable(tableDescriptor); waitForTable(tableDescriptor.getTableName()); // verify that the coprocessor was loaded correctly boolean found = false; MiniHBaseCluster hbase = TEST_UTIL.getHBaseCluster(); for (HRegion region: hbase.getRegionServer(0).getOnlineRegionsLocalContext()) { if (region.getRegionInfo().getRegionNameAsString().startsWith(cpName4)) { Coprocessor cp = region.getCoprocessorHost().findCoprocessor(cpName4); if (cp != null) { found = true; assertEquals("Class " + cpName4 + " was not loaded by CoprocessorClassLoader", cp.getClass().getClassLoader().getClass(), CoprocessorClassLoader.class); } } } assertTrue("Class " + cpName4 + " was missing on a region", found); }
Example 7
Source File: AcidGuaranteesTestBase.java From hbase with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { MemoryCompactionPolicy policy = getMemoryCompactionPolicy(); TableDescriptorBuilder builder = TableDescriptorBuilder.newBuilder(TABLE_NAME) .setValue(CompactingMemStore.COMPACTING_MEMSTORE_TYPE_KEY, policy.name()); if (policy == MemoryCompactionPolicy.EAGER) { builder.setValue(MemStoreLAB.USEMSLAB_KEY, "false"); builder.setValue(CompactingMemStore.IN_MEMORY_FLUSH_THRESHOLD_FACTOR_KEY, "0.9"); } Stream.of(FAMILIES).map(ColumnFamilyDescriptorBuilder::of) .forEachOrdered(builder::setColumnFamily); UTIL.getAdmin().createTable(builder.build()); tool.setConf(UTIL.getConfiguration()); }
Example 8
Source File: TestClassLoading.java From hbase with Apache License 2.0 | 4 votes |
void loadingClassFromLibDirInJar(String libPrefix) throws Exception { FileSystem fs = cluster.getFileSystem(); File innerJarFile1 = buildCoprocessorJar(cpName1); File innerJarFile2 = buildCoprocessorJar(cpName2); File outerJarFile = new File(TEST_UTIL.getDataTestDir().toString(), "outer.jar"); ClassLoaderTestHelper.addJarFilesToJar( outerJarFile, libPrefix, innerJarFile1, innerJarFile2); // copy the jars into dfs fs.copyFromLocalFile(new Path(outerJarFile.getPath()), new Path(fs.getUri().toString() + Path.SEPARATOR)); String jarFileOnHDFS = fs.getUri().toString() + Path.SEPARATOR + outerJarFile.getName(); assertTrue("Copy jar file to HDFS failed.", fs.exists(new Path(jarFileOnHDFS))); LOG.info("Copied jar file to HDFS: " + jarFileOnHDFS); // create a table that references the coprocessors TableDescriptorBuilder tdb = TableDescriptorBuilder.newBuilder(tableName); tdb.setColumnFamily(ColumnFamilyDescriptorBuilder .newBuilder(Bytes.toBytes("test")).build()); // without configuration values tdb.setValue("COPROCESSOR$1", jarFileOnHDFS + "|" + cpName1 + "|" + Coprocessor.PRIORITY_USER); // with configuration values tdb.setValue("COPROCESSOR$2", jarFileOnHDFS + "|" + cpName2 + "|" + Coprocessor.PRIORITY_USER + "|k1=v1,k2=v2,k3=v3"); Admin admin = TEST_UTIL.getAdmin(); if (admin.tableExists(tableName)) { if (admin.isTableEnabled(tableName)) { admin.disableTable(tableName); } admin.deleteTable(tableName); } TableDescriptor tableDescriptor = tdb.build(); admin.createTable(tableDescriptor); waitForTable(tableDescriptor.getTableName()); // verify that the coprocessors were loaded boolean found1 = false, found2 = false, found2_k1 = false, found2_k2 = false, found2_k3 = false; MiniHBaseCluster hbase = TEST_UTIL.getHBaseCluster(); for (HRegion region: hbase.getRegionServer(0).getOnlineRegionsLocalContext()) { if (region.getRegionInfo().getRegionNameAsString().startsWith(tableName.getNameAsString())) { CoprocessorEnvironment env; env = region.getCoprocessorHost().findCoprocessorEnvironment(cpName1); if (env != null) { found1 = true; } env = region.getCoprocessorHost().findCoprocessorEnvironment(cpName2); if (env != null) { found2 = true; Configuration conf = env.getConfiguration(); found2_k1 = conf.get("k1") != null; found2_k2 = conf.get("k2") != null; found2_k3 = conf.get("k3") != null; } } } assertTrue("Class " + cpName1 + " was missing on a region", found1); assertTrue("Class " + cpName2 + " was missing on a region", found2); assertTrue("Configuration key 'k1' was missing on a region", found2_k1); assertTrue("Configuration key 'k2' was missing on a region", found2_k2); assertTrue("Configuration key 'k3' was missing on a region", found2_k3); }