@Override public Entry getEntry(Object key) { if (isInDataSet(key, null)) { return this.proxy.getEntry(key); } else { return null; } }
private boolean reindexUserDataRegion(Integer bucketId, PartitionedRegion userRegion, PartitionedRegion fileRegion, BucketRegion dataBucket, IndexRepository repo) throws IOException { Set<IndexRepository> affectedRepos = new HashSet<IndexRepository>(); for (Object key : dataBucket.keySet()) { Object value = getValue(userRegion.getEntry(key)); if (value != null) { repo.update(key, value); } else { repo.delete(key); } affectedRepos.add(repo); } for (IndexRepository affectedRepo : affectedRepos) { affectedRepo.commit(); } // fileRegion ops (get/put) need bucketId as a callbackArg for PartitionResolver fileRegion.put(APACHE_GEODE_INDEX_COMPLETE, APACHE_GEODE_INDEX_COMPLETE, bucketId); return true; }
@Test public void shouldReturnMapWithKeyAndValue() { PartitionedRegion region = mock(PartitionedRegion.class); InternalRegionFunctionContext context = mock(InternalRegionFunctionContext.class); when(context.getDataSet()).thenReturn(region); ResultSender resultSender = mock(ResultSender.class); when(context.getResultSender()).thenReturn(resultSender); LuceneGetPageFunction function = new LuceneGetPageFunction(); when(context.getLocalDataSet(any())).thenReturn(region); final EntrySnapshot entry = mock(EntrySnapshot.class); when(region.getEntry(any())).thenReturn(entry); final RegionEntry regionEntry = mock(RegionEntry.class); when(entry.getRegionEntry()).thenReturn(regionEntry); when(regionEntry.getValue(any())).thenReturn("value"); when(context.getFilter()).thenReturn((Set) Collections.singleton("key")); function.execute(context); PageResults expectedResults = new PageResults(); expectedResults.add(new PageEntry("key", "value")); verify(resultSender).lastResult(eq(expectedResults)); }