@Test public void testContainsKey() throws InitializationException, IOException { final String row = "row1"; final String content = "content1"; final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class); final Table table = Mockito.mock(Table.class); when(table.getName()).thenReturn(TableName.valueOf(tableName)); final MockHBaseClientService service = configureHBaseClientService(runner, table); runner.assertValid(service); final HBaseClientService hBaseClientService = runner.getProcessContext().getProperty(TestProcessor.HBASE_CLIENT_SERVICE) .asControllerService(HBaseClientService.class); final DistributedMapCacheClient cacheService = configureHBaseCacheService(runner, hBaseClientService); runner.assertValid(cacheService); final DistributedMapCacheClient hBaseCacheService = runner.getProcessContext().getProperty(TestProcessor.HBASE_CACHE_SERVICE) .asControllerService(DistributedMapCacheClient.class); assertFalse( hBaseCacheService.containsKey(row , stringSerializer ) ); hBaseCacheService.put( row, content, stringSerializer, stringSerializer); assertTrue( hBaseCacheService.containsKey(row, stringSerializer) ); }
@Override public <K> boolean containsKey(final K key, final Serializer<K> keySerializer) throws IOException { final byte[] rowIdBytes = serialize(key, keySerializer); final HBaseRowHandler handler = new HBaseRowHandler(); final List<Column> columnsList = new ArrayList<Column>(0); hBaseClientService.scan(hBaseCacheTableName, rowIdBytes, rowIdBytes, columnsList, authorizations, handler); return (handler.numRows() > 0); }
HBase_1_1_2_ClientMapCacheService extends AbstractControllerService implements DistributedMapCacheClient { @Override public <K> boolean containsKey(final K key, final Serializer<K> keySerializer) throws IOException { final byte[] rowIdBytes = serialize(key, keySerializer); final HBaseRowHandler handler = new HBaseRowHandler(); final List<Column> columnsList = new ArrayList<Column>(0); hBaseClientService.scan(hBaseCacheTableName, rowIdBytes, rowIdBytes, columnsList, authorizations, handler); return (handler.numRows() > 0); } }
HBase_1_1_2_ClientMapCacheService extends AbstractControllerService implements DistributedMapCacheClient { @Override public <K> boolean containsKey(final K key, final Serializer<K> keySerializer) throws IOException { final byte[] rowIdBytes = serialize(key, keySerializer); final HBaseRowHandler handler = new HBaseRowHandler(); final List<Column> columnsList = new ArrayList<Column>(0); hBaseClientService.scan(hBaseCacheTableName, rowIdBytes, rowIdBytes, columnsList, authorizations, handler); return (handler.numRows() > 0); }  }
HBase_1_1_2_ClientMapCacheService extends AbstractControllerService implements DistributedMapCacheClient { @Override public <K> boolean containsKey(final K key, final Serializer<K> keySerializer) throws IOException { final byte[] rowIdBytes = serialize(key, keySerializer); final HBaseRowHandler handler = new HBaseRowHandler(); final List<Column> columnsList = new ArrayList<Column>(0); hBaseClientService.scan(hBaseCacheTableName, rowIdBytes, rowIdBytes, columnsList, authorizations, handler); return (handler.numRows() > 0); }  @OnEnabled void onConfigured(final ConfigurationContext context); @Override boolean putIfAbsent(final K key, final V value, final Serializer<K> keySerializer, final Serializer<V> valueSerializer); @Override void put(final K key, final V value, final Serializer<K> keySerializer, final Serializer<V> valueSerializer); @Override boolean containsKey(final K key, final Serializer<K> keySerializer); @Override V getAndPutIfAbsent(final K key, final V value, final Serializer<K> keySerializer, final Serializer<V> valueSerializer, final Deserializer<V> valueDeserializer); @Override V get(final K key, final Serializer<K> keySerializer, final Deserializer<V> valueDeserializer); @Override boolean remove(final K key, final Serializer<K> keySerializer); @Override long removeByPattern(String regex); @Override void close(); }
HBase_1_1_2_ClientMapCacheService extends AbstractControllerService implements DistributedMapCacheClient { @Override public <K> boolean containsKey(final K key, final Serializer<K> keySerializer) throws IOException { final byte[] rowIdBytes = serialize(key, keySerializer); final HBaseRowHandler handler = new HBaseRowHandler(); final List<Column> columnsList = new ArrayList<Column>(0); hBaseClientService.scan(hBaseCacheTableName, rowIdBytes, rowIdBytes, columnsList, authorizations, handler); return (handler.numRows() > 0); }  @OnEnabled void onConfigured(final ConfigurationContext context); @Override boolean putIfAbsent(final K key, final V value, final Serializer<K> keySerializer, final Serializer<V> valueSerializer); @Override void put(final K key, final V value, final Serializer<K> keySerializer, final Serializer<V> valueSerializer); @Override boolean containsKey(final K key, final Serializer<K> keySerializer); @Override V getAndPutIfAbsent(final K key, final V value, final Serializer<K> keySerializer, final Serializer<V> valueSerializer, final Deserializer<V> valueDeserializer); @Override V get(final K key, final Serializer<K> keySerializer, final Deserializer<V> valueDeserializer); @Override boolean remove(final K key, final Serializer<K> keySerializer); @Override long removeByPattern(String regex); @Override void close(); static final PropertyDescriptor HBASE_CACHE_TABLE_NAME; static final PropertyDescriptor HBASE_COLUMN_FAMILY; static final PropertyDescriptor HBASE_COLUMN_QUALIFIER; }