use of org.apache.geode.cache.execute.Function in project geode by apache.
the class PRClientServerRegionFunctionExecutionSingleHopDUnitTest method testServerSingleKeyExecution_SocketTimeOut.
@Test
public void testServerSingleKeyExecution_SocketTimeOut() {
createScenario();
Function function = new TestFunction(true, TestFunction.TEST_FUNCTION_SOCKET_TIMEOUT);
registerFunctionAtServer(function);
isByName = Boolean.TRUE;
// add expected exception for server going down after wait
final IgnoredException expectedEx = IgnoredException.addIgnoredException(DistributedSystemDisconnectedException.class.getName(), server1);
try {
client.invoke(() -> PRClientServerRegionFunctionExecutionSingleHopDUnitTest.serverSingleKeyExecutionSocketTimeOut(isByName));
} finally {
expectedEx.remove();
}
}
use of org.apache.geode.cache.execute.Function in project geode by apache.
the class PRClientServerRegionFunctionExecutionSingleHopDUnitTest method testBucketFilter.
/*
* Execution of the function on server with bucket as filter
*/
@Test
public void testBucketFilter() {
createScenarioForBucketFilter();
Function function = new TestFunction(true, TestFunction.TEST_FUNCTION_BUCKET_FILTER);
registerFunctionAtServer(function);
Set<Integer> bucketFilterSet = new HashSet<Integer>();
bucketFilterSet.add(3);
bucketFilterSet.add(6);
bucketFilterSet.add(8);
client.invoke(() -> PRClientServerTestBase.serverBucketFilterExecution(bucketFilterSet));
bucketFilterSet.clear();
// Test single filter
bucketFilterSet.add(7);
client.invoke(() -> PRClientServerTestBase.serverBucketFilterExecution(bucketFilterSet));
}
use of org.apache.geode.cache.execute.Function in project geode by apache.
the class PRClientServerRegionFunctionExecutionSingleHopDUnitTest method testServerSingleKeyExecution_byName.
/*
* Execution of the function on server with single key as the routing object and using the name of
* the function
*/
@Test
public void testServerSingleKeyExecution_byName() {
createScenario();
Function function = new TestFunction(true, TEST_FUNCTION2);
registerFunctionAtServer(function);
isByName = new Boolean(true);
client.invoke(() -> PRClientServerRegionFunctionExecutionSingleHopDUnitTest.serverSingleKeyExecution(isByName));
}
use of org.apache.geode.cache.execute.Function in project geode by apache.
the class PRClientServerRegionFunctionExecutionSingleHopDUnitTest method executeFunction.
public static void executeFunction() throws ServerException, InterruptedException {
Region region = cache.getRegion(PartitionedRegionName);
assertNotNull(region);
final HashSet testKeysSet = new HashSet();
for (int i = (totalNumBuckets.intValue() * 10); i > 0; i--) {
testKeysSet.add("execKey-" + i);
}
DistributedSystem.setThreadsSocketPolicy(false);
Function function = new TestFunction(true, TEST_FUNCTION2);
FunctionService.registerFunction(function);
Execution dataSet = FunctionService.onRegion(region);
try {
ResultCollector rc1 = dataSet.withFilter(testKeysSet).setArguments(Boolean.TRUE).execute(function.getId());
HashMap resultMap = ((HashMap) rc1.getResult());
assertEquals(3, resultMap.size());
Iterator mapIterator = resultMap.entrySet().iterator();
Map.Entry entry = null;
ArrayList resultListForMember = null;
while (mapIterator.hasNext()) {
entry = (Map.Entry) mapIterator.next();
resultListForMember = (ArrayList) entry.getValue();
for (Object result : resultListForMember) {
assertEquals(Boolean.TRUE, result);
}
}
} catch (Exception e) {
LogWriterUtils.getLogWriter().info("Got an exception : " + e.getMessage());
assertTrue(e instanceof EOFException || e instanceof SocketException || e instanceof SocketTimeoutException || e instanceof ServerException || e instanceof IOException || e instanceof CacheClosedException);
}
}
use of org.apache.geode.cache.execute.Function in project geode by apache.
the class PRClientServerRegionFunctionExecutionSingleHopDUnitTest method testserverMultiKeyExecution_byInstance.
/*
* Execution of the function on server with set multiple keys as the routing object and using the
* instance of the function
*/
@Test
public void testserverMultiKeyExecution_byInstance() {
createScenario();
Function function = new TestFunction(true, TEST_FUNCTION2);
registerFunctionAtServer(function);
isByName = new Boolean(false);
client.invoke(() -> PRClientServerRegionFunctionExecutionSingleHopDUnitTest.serverMultiKeyExecution(isByName));
}
Aggregations