use of org.apache.geode.internal.cache.execute.AbstractExecution in project geode by apache.
the class DiskStoreCommands method getDiskStoreListing.
@SuppressWarnings("unchecked")
protected List<DiskStoreDetails> getDiskStoreListing(Set<DistributedMember> members) {
final Execution membersFunctionExecutor = getMembersFunctionExecutor(members);
if (membersFunctionExecutor instanceof AbstractExecution) {
((AbstractExecution) membersFunctionExecutor).setIgnoreDepartedMembers(true);
}
final ResultCollector<?, ?> resultCollector = membersFunctionExecutor.execute(new ListDiskStoresFunction());
final List<?> results = (List<?>) resultCollector.getResult();
final List<DiskStoreDetails> distributedSystemMemberDiskStores = new ArrayList<DiskStoreDetails>(results.size());
for (final Object result : results) {
if (result instanceof Set) {
// ignore FunctionInvocationTargetExceptions and other
// Exceptions...
distributedSystemMemberDiskStores.addAll((Set<DiskStoreDetails>) result);
}
}
Collections.sort(distributedSystemMemberDiskStores);
return distributedSystemMemberDiskStores;
}
use of org.apache.geode.internal.cache.execute.AbstractExecution in project geode by apache.
the class CliUtil method executeFunction.
/***
* Executes a function with arguments on a set of members , ignores the departed members.
*
* @param function Function to be executed.
* @param args Arguments passed to the function, pass null if you wish to pass no arguments to the
* function.
* @param targetMembers Set of members on which the function is to be executed.
*
* @return ResultCollector
*/
public static ResultCollector<?, ?> executeFunction(final Function function, Object args, final Set<DistributedMember> targetMembers) {
Execution execution = null;
if (args != null) {
execution = FunctionService.onMembers(targetMembers).setArguments(args);
} else {
execution = FunctionService.onMembers(targetMembers);
}
((AbstractExecution) execution).setIgnoreDepartedMembers(true);
return execution.execute(function);
}
use of org.apache.geode.internal.cache.execute.AbstractExecution in project geode by apache.
the class CliUtil method executeFunction.
/***
* Executes a function with arguments on a member , ignores the departed member.
*
* @param function Function to be executed
* @param args Arguments passed to the function, pass null if you wish to pass no arguments to the
* function.
* @param targetMember Member on which the function is to be executed.
* @return ResultCollector
*/
public static ResultCollector<?, ?> executeFunction(final Function function, Object args, final DistributedMember targetMember) {
Execution execution = null;
if (args != null) {
execution = FunctionService.onMember(targetMember).setArguments(args);
} else {
execution = FunctionService.onMember(targetMember);
}
((AbstractExecution) execution).setIgnoreDepartedMembers(true);
return execution.execute(function);
}
use of org.apache.geode.internal.cache.execute.AbstractExecution in project geode by apache.
the class LuceneIndexCommandsJUnitTest method testListIndexWithStats.
@Test
public void testListIndexWithStats() {
final InternalCache mockCache = mock(InternalCache.class, "InternalCache");
final String serverName = "mockServer";
final AbstractExecution mockFunctionExecutor = mock(AbstractExecution.class, "Function Executor");
final ResultCollector mockResultCollector = mock(ResultCollector.class, "ResultCollector");
final LuceneIndexStats mockIndexStats1 = getMockIndexStats(1, 10, 5, 1);
final LuceneIndexStats mockIndexStats2 = getMockIndexStats(2, 20, 10, 2);
final LuceneIndexStats mockIndexStats3 = getMockIndexStats(3, 30, 15, 3);
String[] searchableFields = { "field1", "field2", "field3" };
Map<String, Analyzer> fieldAnalyzers = new HashMap<>();
fieldAnalyzers.put("field1", new StandardAnalyzer());
fieldAnalyzers.put("field2", new KeywordAnalyzer());
fieldAnalyzers.put("field3", null);
final LuceneIndexDetails indexDetails1 = createIndexDetails("memberFive", "/Employees", searchableFields, fieldAnalyzers, mockIndexStats1, true, serverName);
final LuceneIndexDetails indexDetails2 = createIndexDetails("memberSix", "/Employees", searchableFields, fieldAnalyzers, mockIndexStats2, true, serverName);
final LuceneIndexDetails indexDetails3 = createIndexDetails("memberTen", "/Employees", searchableFields, fieldAnalyzers, mockIndexStats3, true, serverName);
final List<Set<LuceneIndexDetails>> results = new ArrayList<>();
results.add(CollectionUtils.asSet(indexDetails2, indexDetails1, indexDetails3));
when(mockFunctionExecutor.execute(isA(LuceneListIndexFunction.class))).thenReturn(mockResultCollector);
when(mockResultCollector.getResult()).thenReturn(results);
final LuceneIndexCommands commands = createIndexCommands(mockCache, mockFunctionExecutor);
CommandResult result = (CommandResult) commands.listIndex(true);
TabularResultData data = (TabularResultData) result.getResultData();
assertEquals(Arrays.asList("memberFive", "memberSix", "memberTen"), data.retrieveAllValues("Index Name"));
assertEquals(Arrays.asList("/Employees", "/Employees", "/Employees"), data.retrieveAllValues("Region Path"));
assertEquals(Arrays.asList("[field1, field2, field3]", "[field1, field2, field3]", "[field1, field2, field3]"), data.retrieveAllValues("Indexed Fields"));
assertEquals(Arrays.asList("{field1=StandardAnalyzer, field2=KeywordAnalyzer}", "{field1=StandardAnalyzer, field2=KeywordAnalyzer}", "{field1=StandardAnalyzer, field2=KeywordAnalyzer}"), data.retrieveAllValues("Field Analyzer"));
assertEquals(Arrays.asList("1", "2", "3"), data.retrieveAllValues("Query Executions"));
assertEquals(Arrays.asList("10", "20", "30"), data.retrieveAllValues("Commits"));
assertEquals(Arrays.asList("5", "10", "15"), data.retrieveAllValues("Updates"));
assertEquals(Arrays.asList("1", "2", "3"), data.retrieveAllValues("Documents"));
}
Aggregations