use of org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment in project phoenix by apache.
the class TestNonTxIndexBuilder method setup.
/**
* Test setup so that {@link NonTxIndexBuilder#getIndexUpdate(Mutation, IndexMetaData)} can be
* called, where any read requests to
* {@link LocalTable#getCurrentRowState(Mutation, Collection, boolean)} are read from our test
* field 'currentRowCells'
*/
@Before
public void setup() throws Exception {
RegionCoprocessorEnvironment env = Mockito.mock(RegionCoprocessorEnvironment.class);
Configuration conf = new Configuration(false);
conf.set(NonTxIndexBuilder.CODEC_CLASS_NAME_KEY, PhoenixIndexCodec.class.getName());
Mockito.when(env.getConfiguration()).thenReturn(conf);
// the following is used by LocalTable#getCurrentRowState()
Region mockRegion = Mockito.mock(Region.class);
Mockito.when(env.getRegion()).thenReturn(mockRegion);
Mockito.when(mockRegion.getScanner(Mockito.any(Scan.class))).thenAnswer(new Answer<RegionScanner>() {
@Override
public RegionScanner answer(InvocationOnMock invocation) throws Throwable {
Scan sArg = (Scan) invocation.getArguments()[0];
TimeRange timeRange = sArg.getTimeRange();
return getMockTimeRangeRegionScanner(timeRange);
}
});
// the following is called by PhoenixIndexCodec#getIndexUpserts() , getIndexDeletes()
HRegionInfo mockRegionInfo = Mockito.mock(HRegionInfo.class);
Mockito.when(mockRegion.getRegionInfo()).thenReturn(mockRegionInfo);
Mockito.when(mockRegionInfo.getStartKey()).thenReturn(Bytes.toBytes("a"));
Mockito.when(mockRegionInfo.getEndKey()).thenReturn(Bytes.toBytes("z"));
mockIndexMetaData = Mockito.mock(PhoenixIndexMetaData.class);
Mockito.when(mockIndexMetaData.isImmutableRows()).thenReturn(false);
Mockito.when(mockIndexMetaData.getIndexMaintainers()).thenReturn(Collections.singletonList(getTestIndexMaintainer()));
indexBuilder = new NonTxIndexBuilder();
indexBuilder.setup(env);
}
use of org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment in project phoenix by apache.
the class TestLocalTableState method testScannerForMutableRows.
@Test(expected = ScannerCreatedException.class)
public void testScannerForMutableRows() throws Exception {
IndexMetaData indexMetaData = new IndexMetaData() {
@Override
public boolean isImmutableRows() {
return false;
}
@Override
public boolean ignoreNewerMutations() {
return false;
}
};
Put m = new Put(row);
m.add(fam, qual, ts, val);
// setup mocks
Configuration conf = new Configuration(false);
RegionCoprocessorEnvironment env = Mockito.mock(RegionCoprocessorEnvironment.class);
Mockito.when(env.getConfiguration()).thenReturn(conf);
Region region = Mockito.mock(Region.class);
Mockito.when(env.getRegion()).thenReturn(region);
Mockito.when(region.getScanner(Mockito.any(Scan.class))).thenThrow(new ScannerCreatedException("Should not open scanner when data is immutable"));
LocalHBaseState state = new LocalTable(env);
LocalTableState table = new LocalTableState(env, state, m);
//add the kvs from the mutation
table.addPendingUpdates(KeyValueUtil.ensureKeyValues(m.get(fam, qual)));
// setup the lookup
ColumnReference col = new ColumnReference(fam, qual);
table.setCurrentTimestamp(ts);
table.getIndexedColumnsTableState(Arrays.asList(col), false, false, indexMetaData);
}
use of org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment in project cdap by caskdata.
the class DefaultTransactionProcessor method start.
@Override
public void start(CoprocessorEnvironment e) throws IOException {
if (e instanceof RegionCoprocessorEnvironment) {
RegionCoprocessorEnvironment env = (RegionCoprocessorEnvironment) e;
HTableDescriptor tableDesc = env.getRegion().getTableDesc();
String hbaseNamespacePrefix = tableDesc.getValue(Constants.Dataset.TABLE_PREFIX);
this.sysConfigTablePrefix = HTableNameConverter.getSysConfigTablePrefix(hbaseNamespacePrefix);
this.cConfCacheSupplier = new CConfigurationCacheSupplier(env.getConfiguration(), sysConfigTablePrefix, TxConstants.Manager.CFG_TX_MAX_LIFETIME, TxConstants.Manager.DEFAULT_TX_MAX_LIFETIME);
this.cConfCache = cConfCacheSupplier.get();
}
// Need to create the cConf cache before calling start on the parent, since it is required for
// initializing some properties in the parent class.
super.start(e);
}
use of org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment 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 DefaultScanBuilder());
topicMetadataCache = topicMetadataCacheSupplier.get();
}
}
use of org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment 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();
}
}
Aggregations