use of io.cdap.cdap.data2.util.hbase.HBaseTableUtilFactory in project cdap by caskdata.
the class HBaseMetadataTableTestRun method setupBeforeClass.
@BeforeClass
public static void setupBeforeClass() throws Exception {
hConf = HBASE_TEST_BASE.getConfiguration();
hConf.set(HBaseTableUtil.CFG_HBASE_TABLE_COMPRESSION, HBaseTableUtil.CompressionType.NONE.name());
tableUtil = new HBaseTableUtilFactory(cConf).get();
ddlExecutor = new HBaseDDLExecutorFactory(cConf, hConf).get();
ddlExecutor.createNamespaceIfNotExists(tableUtil.getHBaseNamespace(NamespaceId.SYSTEM));
LocationFactory locationFactory = getInjector().getInstance(LocationFactory.class);
tableFactory = new HBaseTableFactory(cConf, hConf, tableUtil, locationFactory);
}
use of io.cdap.cdap.data2.util.hbase.HBaseTableUtilFactory in project cdap by caskdata.
the class HBaseTableCoprocessorTestRun method setupBeforeClass.
@BeforeClass
public static void setupBeforeClass() throws Exception {
hConf = HBASE_TEST_BASE.getConfiguration();
hConf.set(HBaseTableUtil.CFG_HBASE_TABLE_COMPRESSION, HBaseTableUtil.CompressionType.NONE.name());
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
cConf.set(Constants.CFG_HDFS_NAMESPACE, cConf.get(Constants.CFG_LOCAL_DATA_DIR));
cConf.set(Constants.CFG_HDFS_USER, System.getProperty("user.name"));
// Reduce the metadata cache refresh frequency for unit tests
cConf.set(Constants.MessagingSystem.COPROCESSOR_METADATA_CACHE_UPDATE_FREQUENCY_SECONDS, Integer.toString(METADATA_CACHE_EXPIRY));
hBaseAdmin = HBASE_TEST_BASE.getHBaseAdmin();
hBaseAdmin.getConfiguration().set(HBaseTableUtil.CFG_HBASE_TABLE_COMPRESSION, HBaseTableUtil.CompressionType.NONE.name());
tableUtil = new HBaseTableUtilFactory(cConf).get();
ddlExecutor = new HBaseDDLExecutorFactory(cConf, hConf).get();
ddlExecutor.createNamespaceIfNotExists(tableUtil.getHBaseNamespace(NamespaceId.SYSTEM));
LocationFactory locationFactory = getInjector().getInstance(LocationFactory.class);
tableFactory = new HBaseTableFactory(cConf, hBaseAdmin.getConfiguration(), tableUtil, locationFactory);
new ConfigurationWriter(hConf, cConf).write(ConfigurationReader.Type.DEFAULT, cConf);
// write an initial transaction snapshot
invalidList.addAll(ImmutableList.of(V[3], V[5], V[7]));
TransactionSnapshot txSnapshot = TransactionSnapshot.copyFrom(System.currentTimeMillis(), V[6] - 1, V[7], invalidList, // this will set visibility upper bound to V[6]
Maps.newTreeMap(ImmutableSortedMap.of(V[6], new TransactionManager.InProgressTx(V[6] - 1, Long.MAX_VALUE, TransactionManager.InProgressType.SHORT))), new HashMap<Long, TransactionManager.ChangeSet>(), new TreeMap<Long, TransactionManager.ChangeSet>());
HDFSTransactionStateStorage tmpStorage = new HDFSTransactionStateStorage(hConf, new SnapshotCodecProvider(hConf), new TxMetricsCollector());
tmpStorage.startAndWait();
tmpStorage.writeSnapshot(txSnapshot);
tmpStorage.stopAndWait();
}
use of io.cdap.cdap.data2.util.hbase.HBaseTableUtilFactory in project cdap by caskdata.
the class AbstractIncrementHandlerTest method testIncrements.
@Test
public void testIncrements() throws Exception {
TableId tableId = TableId.from(NamespaceId.DEFAULT.getEntityName(), "incrementTest");
createTable(tableId);
try (HTable table = new HBaseTableUtilFactory(cConf).get().createHTable(conf, tableId)) {
byte[] colA = Bytes.toBytes("a");
byte[] row1 = Bytes.toBytes("row1");
// test column containing only increments
table.put(newIncrement(row1, colA, 1));
table.put(newIncrement(row1, colA, 1));
table.put(newIncrement(row1, colA, 1));
assertColumn(table, row1, colA, 3);
// test intermixed increments and puts
table.put(tableUtil.buildPut(row1).add(FAMILY, colA, ts++, Bytes.toBytes(5L)).build());
assertColumn(table, row1, colA, 5);
table.put(newIncrement(row1, colA, 1));
table.put(newIncrement(row1, colA, 1));
assertColumn(table, row1, colA, 7);
// test multiple increment columns
byte[] row2 = Bytes.toBytes("row2");
byte[] colB = Bytes.toBytes("b");
// increment A and B twice at the same timestamp
table.put(newIncrement(row2, colA, 1, 1));
table.put(newIncrement(row2, colB, 1, 1));
table.put(newIncrement(row2, colA, 2, 1));
table.put(newIncrement(row2, colB, 2, 1));
// increment A once more
table.put(newIncrement(row2, colA, 1));
assertColumns(table, row2, new byte[][] { colA, colB }, new long[] { 3, 2 });
// overwrite B with a new put
table.put(tableUtil.buildPut(row2).add(FAMILY, colB, ts++, Bytes.toBytes(10L)).build());
assertColumns(table, row2, new byte[][] { colA, colB }, new long[] { 3, 10 });
}
}
use of io.cdap.cdap.data2.util.hbase.HBaseTableUtilFactory in project cdap by caskdata.
the class HBasePayloadTableTestRun method setupBeforeClass.
@BeforeClass
public static void setupBeforeClass() throws Exception {
hConf = HBASE_TEST_BASE.getConfiguration();
hConf.set(HBaseTableUtil.CFG_HBASE_TABLE_COMPRESSION, HBaseTableUtil.CompressionType.NONE.name());
cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
cConf.set(Constants.CFG_HDFS_NAMESPACE, cConf.get(Constants.CFG_LOCAL_DATA_DIR));
cConf.set(Constants.CFG_HDFS_USER, System.getProperty("user.name"));
tableUtil = new HBaseTableUtilFactory(cConf).get();
ddlExecutor = new HBaseDDLExecutorFactory(cConf, hConf).get();
ddlExecutor.createNamespaceIfNotExists(tableUtil.getHBaseNamespace(NamespaceId.SYSTEM));
LocationFactory locationFactory = getInjector().getInstance(LocationFactory.class);
tableFactory = new HBaseTableFactory(cConf, hConf, tableUtil, locationFactory);
new ConfigurationWriter(hConf, cConf).write(ConfigurationReader.Type.DEFAULT, cConf);
}
use of io.cdap.cdap.data2.util.hbase.HBaseTableUtilFactory in project cdap by caskdata.
the class IncrementHandlerTest method createTable.
@Override
public HTable createTable(TableId tableId) throws Exception {
HBaseTableUtil tableUtil = new HBaseTableUtilFactory(cConf).get();
HTableDescriptorBuilder tableDesc = tableUtil.buildHTableDescriptor(tableId);
HColumnDescriptor columnDesc = new HColumnDescriptor(FAMILY);
columnDesc.setMaxVersions(Integer.MAX_VALUE);
columnDesc.setValue(IncrementHandlerState.PROPERTY_TRANSACTIONAL, "false");
tableDesc.addFamily(columnDesc);
tableDesc.addCoprocessor(IncrementHandler.class.getName());
HTableDescriptor htd = tableDesc.build();
TEST_HBASE.getHBaseAdmin().createTable(htd);
TEST_HBASE.waitUntilTableAvailable(htd.getName(), 5000);
return tableUtil.createHTable(conf, tableId);
}
Aggregations