use of org.apache.geode.internal.cache.functions.TestFunction in project geode by apache.
the class PRClientServerRegionFunctionExecutionFailoverDUnitTest method testOnRegionFailoverNonHA.
/*
* Ensure that the while executing the function if the servers are down then the execution
* shouldn't failover to other available server
*/
@Test
public void testOnRegionFailoverNonHA() throws InterruptedException {
// See #47489 before
// enabling it
createScenario();
IgnoredException.addIgnoredException("FunctionInvocationTargetException");
server1.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.createReplicatedRegion());
server2.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.createReplicatedRegion());
server3.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.createReplicatedRegion());
client.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.createProxyRegion(NetworkUtils.getServerHostName(server1.getHost())));
Function function = new TestFunction(true, TestFunction.TEST_FUNCTION_NONHA_REGION);
registerFunctionAtServer(function);
client.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.regionSingleKeyExecutionNonHA(Boolean.FALSE, function, Boolean.FALSE));
client.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.verifyMetaData(new Integer(1), new Integer(0)));
}
use of org.apache.geode.internal.cache.functions.TestFunction in project geode by apache.
the class PRClientServerRegionFunctionExecutionFailoverDUnitTest method testOnRegionFailoverWithTwoServerDownHA.
@Test
public void testOnRegionFailoverWithTwoServerDownHA() throws InterruptedException {
IgnoredException.addIgnoredException("FunctionInvocationTargetException");
createScenario();
server1.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.createReplicatedRegion());
server2.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.createReplicatedRegion());
server3.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.createReplicatedRegion());
client.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.createProxyRegion(NetworkUtils.getServerHostName(server1.getHost())));
Function function = new TestFunction(true, TestFunction.TEST_FUNCTION_HA_REGION);
registerFunctionAtServer(function);
client.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.regionExecutionHATwoServerDown(Boolean.FALSE, function, Boolean.FALSE));
client.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.verifyMetaData(new Integer(2), new Integer(1)));
}
use of org.apache.geode.internal.cache.functions.TestFunction in project geode by apache.
the class PRClientServerRegionFunctionExecutionFailoverDUnitTest method executeFunction.
public static Object executeFunction() {
Execution execute = FunctionService.onRegion(region);
ResultCollector rc = execute.setArguments(Boolean.TRUE).execute(new TestFunction(true, TestFunction.TEST_FUNCTION_LASTRESULT));
LogWriterUtils.getLogWriter().info("Exeuction Result :" + rc.getResult());
List l = ((List) rc.getResult());
return l;
}
use of org.apache.geode.internal.cache.functions.TestFunction in project geode by apache.
the class PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest method testserverMultiKeyExecution_byName.
/*
* Execution of the function on server with set multiple keys as the routing object and using the
* name of the function
*/
@Test
public void testserverMultiKeyExecution_byName() {
createScenario();
Function function = new TestFunction(true, TEST_FUNCTION2);
registerFunctionAtServer(function);
isByName = new Boolean(true);
client.invoke(() -> PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.serverMultiKeyExecution(isByName));
server1.invoke(() -> PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.checkBucketsOnServer());
server2.invoke(() -> PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.checkBucketsOnServer());
server3.invoke(() -> PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.checkBucketsOnServer());
}
use of org.apache.geode.internal.cache.functions.TestFunction in project geode by apache.
the class PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest method serverAllKeyExecution.
public static void serverAllKeyExecution(Boolean isByName) {
Region region = cache.getRegion(PartitionedRegionName);
assertNotNull(region);
final HashSet testKeysSet = new HashSet();
for (int i = (totalNumBuckets.intValue() / 2); 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 {
int j = 0;
HashSet origVals = new HashSet();
for (Iterator i = testKeysSet.iterator(); i.hasNext(); ) {
Integer val = new Integer(j++);
origVals.add(val);
region.put(i.next(), val);
}
ResultCollector rc1 = executeOnAll(dataSet, Boolean.TRUE, function, isByName);
List resultList = (List) ((List) rc1.getResult());
LogWriterUtils.getLogWriter().info("Result size : " + resultList.size());
LogWriterUtils.getLogWriter().info("Result are SSSS : " + resultList);
assertEquals(3, resultList.size());
Iterator resultIterator = resultList.iterator();
Map.Entry entry = null;
DistributedMember key = null;
List resultListForMember = new ArrayList();
// }
for (Object result : resultList) {
assertEquals(Boolean.TRUE, result);
}
List l2 = null;
ResultCollector rc2 = executeOnAll(dataSet, testKeysSet, function, isByName);
l2 = ((List) rc2.getResult());
assertEquals(3, l2.size());
HashSet foundVals = new HashSet();
for (Iterator i = l2.iterator(); i.hasNext(); ) {
ArrayList subL = (ArrayList) (i.next());
assertTrue(subL.size() > 0);
for (Iterator subI = subL.iterator(); subI.hasNext(); ) {
assertTrue(foundVals.add(subI.next()));
}
}
assertEquals(origVals, foundVals);
} catch (Exception e) {
Assert.fail("Test failed after the put operation", e);
}
}
Aggregations