Search in sources :

Example 1 with EnvironmentEdge

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);
}
Also used : HashMap(java.util.HashMap) EnvironmentEdge(org.apache.phoenix.util.EnvironmentEdge) HTable(org.apache.hadoop.hbase.client.HTable) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) HBaseAdmin(org.apache.hadoop.hbase.client.HBaseAdmin) Indexer(org.apache.phoenix.hbase.index.Indexer) Region(org.apache.hadoop.hbase.regionserver.Region)

Aggregations

HashMap (java.util.HashMap)1 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)1 HBaseAdmin (org.apache.hadoop.hbase.client.HBaseAdmin)1 HTable (org.apache.hadoop.hbase.client.HTable)1 Region (org.apache.hadoop.hbase.regionserver.Region)1 Indexer (org.apache.phoenix.hbase.index.Indexer)1 EnvironmentEdge (org.apache.phoenix.util.EnvironmentEdge)1