LuceneIndexForPartitionedRegion extends LuceneIndexImpl { @Override public void dumpFiles(final String directory) { ResultCollector results = FunctionService.onRegion(getDataRegion()) .setArguments(new String[] {directory, indexName}).execute(DumpDirectoryFiles.ID); results.getResult(); } LuceneIndexForPartitionedRegion(String indexName, String regionPath, InternalCache cache); @Override boolean isIndexingInProgress(); PartitionedRegion getFileAndChunkRegion(); FileSystemStats getFileSystemStats(); String createFileRegionName(); void close(); @Override void dumpFiles(final String directory); @Override void destroy(boolean initiator); @Override boolean isIndexAvailable(int id); static final String FILES_REGION_SUFFIX; }
@Test public void dumpFilesShouldInvokeDumpFunction() { boolean withPersistence = false; String name = "indexName"; String regionPath = "regionName"; String[] fields = new String[] {"field1", "field2"}; InternalCache cache = Fakes.cache(); initializeScenario(withPersistence, regionPath, cache); AsyncEventQueue aeq = mock(AsyncEventQueue.class); DumpDirectoryFiles function = new DumpDirectoryFiles(); FunctionService.registerFunction(function); LuceneIndexForPartitionedRegion index = new LuceneIndexForPartitionedRegion(name, regionPath, cache); index = spy(index); when(index.getFieldNames()).thenReturn(fields); doReturn(aeq).when(index).createAEQ(any(), any()); index.setupRepositoryManager(null); index.createAEQ(cache.getRegionAttributes(regionPath), aeq.getId()); index.initialize(); PartitionedRegion region = (PartitionedRegion) cache.getRegion(regionPath); ResultCollector collector = mock(ResultCollector.class); when(region.executeFunction(eq(function), any(), any(), anyBoolean())).thenReturn(collector); index.dumpFiles("directory"); verify(region).executeFunction(eq(function), any(), any(), anyBoolean()); }