use of co.cask.cdap.messaging.TopicMetadataCacheSupplier in project cdap by caskdata.
the class MessageTableRegionObserver method start.
@Override
public void start(CoprocessorEnvironment e) throws IOException {
if (e instanceof RegionCoprocessorEnvironment) {
RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e;
HTableDescriptor tableDesc = env.getRegion().getTableDesc();
String metadataTableNamespace = tableDesc.getValue(Constants.MessagingSystem.HBASE_METADATA_TABLE_NAMESPACE);
String hbaseNamespacePrefix = tableDesc.getValue(Constants.Dataset.TABLE_PREFIX);
prefixLength = Integer.valueOf(tableDesc.getValue(Constants.MessagingSystem.HBASE_MESSAGING_TABLE_PREFIX_NUM_BYTES));
String sysConfigTablePrefix = HTableNameConverter.getSysConfigTablePrefix(hbaseNamespacePrefix);
CConfigurationReader cConfReader = new CConfigurationReader(env.getConfiguration(), sysConfigTablePrefix);
txStateCacheSupplier = getTransactionStateCacheSupplier(hbaseNamespacePrefix, env.getConfiguration());
txStateCache = txStateCacheSupplier.get();
topicMetadataCacheSupplier = new TopicMetadataCacheSupplier(env, cConfReader, hbaseNamespacePrefix, metadataTableNamespace, new HBase10ScanBuilder());
topicMetadataCache = topicMetadataCacheSupplier.get();
}
}
use of co.cask.cdap.messaging.TopicMetadataCacheSupplier in project cdap by caskdata.
the class PayloadTableRegionObserver method start.
@Override
public void start(CoprocessorEnvironment e) throws IOException {
if (e instanceof RegionCoprocessorEnvironment) {
RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e;
HTableDescriptor tableDesc = env.getRegion().getTableDesc();
String metadataTableNamespace = tableDesc.getValue(Constants.MessagingSystem.HBASE_METADATA_TABLE_NAMESPACE);
String hbaseNamespacePrefix = tableDesc.getValue(Constants.Dataset.TABLE_PREFIX);
prefixLength = Integer.valueOf(tableDesc.getValue(Constants.MessagingSystem.HBASE_MESSAGING_TABLE_PREFIX_NUM_BYTES));
String sysConfigTablePrefix = HTableNameConverter.getSysConfigTablePrefix(hbaseNamespacePrefix);
CConfigurationReader cConfReader = new CConfigurationReader(env.getConfiguration(), sysConfigTablePrefix);
topicMetadataCacheSupplier = new TopicMetadataCacheSupplier(env, cConfReader, hbaseNamespacePrefix, metadataTableNamespace, new DefaultScanBuilder());
topicMetadataCache = topicMetadataCacheSupplier.get();
}
}
use of co.cask.cdap.messaging.TopicMetadataCacheSupplier in project cdap by caskdata.
the class PayloadTableRegionObserver method start.
@Override
public void start(CoprocessorEnvironment e) throws IOException {
if (e instanceof RegionCoprocessorEnvironment) {
RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e;
HTableDescriptor tableDesc = env.getRegion().getTableDesc();
String metadataTableNamespace = tableDesc.getValue(Constants.MessagingSystem.HBASE_METADATA_TABLE_NAMESPACE);
String hbaseNamespacePrefix = tableDesc.getValue(Constants.Dataset.TABLE_PREFIX);
prefixLength = Integer.valueOf(tableDesc.getValue(Constants.MessagingSystem.HBASE_MESSAGING_TABLE_PREFIX_NUM_BYTES));
String sysConfigTablePrefix = HTableNameConverter.getSysConfigTablePrefix(hbaseNamespacePrefix);
CConfigurationReader cConfReader = new CConfigurationReader(env.getConfiguration(), sysConfigTablePrefix);
topicMetadataCacheSupplier = new TopicMetadataCacheSupplier(env, cConfReader, hbaseNamespacePrefix, metadataTableNamespace, new DefaultScanBuilder());
topicMetadataCache = topicMetadataCacheSupplier.get();
}
}
use of co.cask.cdap.messaging.TopicMetadataCacheSupplier in project cdap by caskdata.
the class PayloadTableRegionObserver method start.
@Override
public void start(CoprocessorEnvironment e) throws IOException {
if (e instanceof RegionCoprocessorEnvironment) {
RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e;
HTableDescriptor tableDesc = env.getRegion().getTableDesc();
String metadataTableNamespace = tableDesc.getValue(Constants.MessagingSystem.HBASE_METADATA_TABLE_NAMESPACE);
String hbaseNamespacePrefix = tableDesc.getValue(Constants.Dataset.TABLE_PREFIX);
prefixLength = Integer.valueOf(tableDesc.getValue(Constants.MessagingSystem.HBASE_MESSAGING_TABLE_PREFIX_NUM_BYTES));
String sysConfigTablePrefix = HTableNameConverter.getSysConfigTablePrefix(hbaseNamespacePrefix);
CConfigurationReader cConfReader = new CConfigurationReader(env.getConfiguration(), sysConfigTablePrefix);
topicMetadataCacheSupplier = new TopicMetadataCacheSupplier(env, cConfReader, hbaseNamespacePrefix, metadataTableNamespace, new DefaultScanBuilder());
topicMetadataCache = topicMetadataCacheSupplier.get();
}
}
use of co.cask.cdap.messaging.TopicMetadataCacheSupplier in project cdap by caskdata.
the class ReferenceCountedSupplierTests method testSupplier.
@Test
public void testSupplier() throws Exception {
// ReferenceCountSupplier is created only once per CacheSupplier class. Thus it is fine to create separate
// CacheSupplier objects
CacheSupplier cConfSupplier = new CConfigurationCacheSupplier(null, null, DUMMY_PROPERTY, Integer.MAX_VALUE);
testGetSupplier(Lists.newArrayList(cConfSupplier));
testReleaseSupplier(Lists.newArrayList(cConfSupplier));
// Test to make sure we handle more releases than gets.
for (int i = 0; i < 10; i++) {
cConfSupplier.release();
}
// Test increase and decrease of counts for cConf supplier
testGetSupplier(Lists.<CacheSupplier>newArrayList(new CConfigurationCacheSupplier(null, null, DUMMY_PROPERTY, Integer.MAX_VALUE)));
testReleaseSupplier(Lists.<CacheSupplier>newArrayList(new CConfigurationCacheSupplier(null, null, DUMMY_PROPERTY, Integer.MAX_VALUE)));
// Repeat the tests for TopicMetadata CacheSupplier
testGetSupplier(Lists.<CacheSupplier>newArrayList(new TopicMetadataCacheSupplier(null, null, null, null, null)));
testReleaseSupplier(Lists.<CacheSupplier>newArrayList(new TopicMetadataCacheSupplier(null, null, null, null, null)));
testGetSupplier(Lists.<CacheSupplier>newArrayList(new TopicMetadataCacheSupplier(null, null, null, null, null)));
testReleaseSupplier(Lists.<CacheSupplier>newArrayList(new TopicMetadataCacheSupplier(null, null, null, null, null)));
// Tests multiple suppliers at the same time
List<CacheSupplier> cacheSupplierList = new ArrayList<>();
cacheSupplierList.add(new CConfigurationCacheSupplier(null, null, DUMMY_PROPERTY, Integer.MAX_VALUE));
cacheSupplierList.add(new TopicMetadataCacheSupplier(null, null, null, null, null));
testGetSupplier(cacheSupplierList);
testReleaseSupplier(cacheSupplierList);
}
Aggregations