use of org.apache.phoenix.util.EnvironmentEdge in project phoenix by apache.
the class EndToEndCoveredColumnsIndexBuilderIT method setupTest.
/**
* @param tableName name of the table to create for the test
* @return the supporting state for the test
*/
private TestState setupTest(String tableName) throws IOException {
byte[] tableNameBytes = Bytes.toBytes(tableName);
@SuppressWarnings("deprecation") HTableDescriptor desc = new HTableDescriptor(tableNameBytes);
desc.addFamily(FAM1);
// add the necessary simple options to create the builder
Map<String, String> indexerOpts = new HashMap<String, String>();
// just need to set the codec - we are going to set it later, but we need something here or the
// initializer blows up.
indexerOpts.put(NonTxIndexBuilder.CODEC_CLASS_NAME_KEY, CoveredIndexCodecForTesting.class.getName());
Indexer.enableIndexing(desc, NonTxIndexBuilder.class, indexerOpts, Coprocessor.PRIORITY_USER);
// create the table
HBaseAdmin admin = UTIL.getHBaseAdmin();
admin.createTable(desc);
HTable primary = new HTable(UTIL.getConfiguration(), tableNameBytes);
// overwrite the codec so we can verify the current state
Region region = UTIL.getMiniHBaseCluster().getRegions(tableNameBytes).get(0);
Indexer indexer = (Indexer) region.getCoprocessorHost().findCoprocessor(Indexer.class.getName());
NonTxIndexBuilder builder = (NonTxIndexBuilder) indexer.getBuilderForTesting();
VerifyingIndexCodec codec = new VerifyingIndexCodec();
builder.setIndexCodecForTesting(codec);
// setup the Puts we want to write
final long ts = System.currentTimeMillis();
EnvironmentEdge edge = new EnvironmentEdge() {
@Override
public long currentTime() {
return ts;
}
};
EnvironmentEdgeManager.injectEdge(edge);
return new TestState(primary, codec, ts);
}
Aggregations