HBaseTimestampStorage implements TimestampStorage { @Inject public HBaseTimestampStorage(Configuration hbaseConfig, HBaseTimestampStorageConfig config) throws IOException { connection = ConnectionFactory.createConnection(hbaseConfig); this.table = connection.getTable(TableName.valueOf(config.getTableName())); this.cfName = config.getFamilyName().getBytes(UTF_8); } @Inject  HBaseTimestampStorage(Configuration hbaseConfig, HBaseTimestampStorageConfig config); @Override void updateMaxTimestamp(long previousMaxTimestamp, long newMaxTimestamp); @Override long getMaxTimestamp(); void close();  }
@Test(timeOut = 10_000) public void testHBaseTimestampStorage() throws Exception { final long INITIAL_TS_VALUE = 0; HBaseTimestampStorageConfig config = new HBaseTimestampStorageConfig(); HBaseTimestampStorage tsStorage = new HBaseTimestampStorage(hbaseConf, config); assertEquals(tsStorage.getMaxTimestamp(), INITIAL_TS_VALUE, "Initial value should be " + INITIAL_TS_VALUE); long newTimestamp = 1; tsStorage.updateMaxTimestamp(INITIAL_TS_VALUE, newTimestamp); long wrongTimestamp = 20; try { tsStorage.updateMaxTimestamp(wrongTimestamp, newTimestamp); Assert.fail("Shouldn't update"); } catch (IOException e) { } assertEquals(tsStorage.getMaxTimestamp(), newTimestamp, "Value should be still " + newTimestamp); long veryNewTimestamp = 40; tsStorage.updateMaxTimestamp(newTimestamp, veryNewTimestamp); assertEquals(tsStorage.getMaxTimestamp(), veryNewTimestamp, "Value should be " + veryNewTimestamp); }