use of org.apache.geode.internal.cache.functions.TestFunction in project geode by apache.
the class PRClientServerRegionFunctionExecutionFailoverDUnitTest method testOnRegionFailoverNonHASingleHop.
/*
* 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 testOnRegionFailoverNonHASingleHop() throws InterruptedException {
// See #47489
// before enabling
// it
ArrayList commonAttributes = createCommonServerAttributes("TestPartitionedRegion", null, 0, 13, null);
createClientServerScenarioSingleHop(commonAttributes, 20, 20, 20);
server1.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.createReplicatedRegion());
server2.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.createReplicatedRegion());
server3.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.createReplicatedRegion());
client.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.createProxyRegion(NetworkUtils.getServerHostName(server1.getHost())));
// Make sure the buckets are created.
client.invoke(new SerializableRunnable() {
@Override
public void run() {
region = (LocalRegion) cache.getRegion(PRClientServerTestBase.PartitionedRegionName);
for (int i = 0; i < 13; i++) {
region.put(i, i);
}
}
});
// Make sure the client metadata is up to date.
client.invoke(() -> PRClientServerRegionFunctionExecutionFailoverDUnitTest.fetchMetaData());
Function function = new TestFunction(true, TestFunction.TEST_FUNCTION_NONHA_REGION);
registerFunctionAtServer(function);
final Function function2 = new TestFunction(true, TestFunction.TEST_FUNCTION_NONHA_NOP);
registerFunctionAtServer(function);
client.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.regionSingleKeyExecutionNonHA(Boolean.FALSE, function, Boolean.FALSE));
// This validation doesn't work because the client may
// still be asynchronously recording the departure of the
// failed server
// System.err.println("Trying the second function");
// //Make sure the client can now execute a function
// //on the server
// client.invoke(new SerializableRunnable() {
// @Override
// public void run() {
// ResultCollector rs = FunctionService.onRegion(region).execute(function2);
// rs.getResult();
// }
// });
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 PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest method testserverMultiKeyExecutionNoResult_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 testserverMultiKeyExecutionNoResult_byName() {
createScenario();
Function function = new TestFunction(false, TEST_FUNCTION7);
registerFunctionAtServer(function);
isByName = new Boolean(true);
client.invoke(() -> PRClientServerRegionFunctionExecutionNoSingleHopDUnitTest.serverMultiKeyExecutionNoResult(isByName));
}
use of org.apache.geode.internal.cache.functions.TestFunction in project geode by apache.
the class PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest method testServerCacheClosedFailoverWithTwoServerAliveHA.
/*
* Ensure that the while executing the function if the servers is down then the execution is
* failover to other available server
*/
@Test
public void testServerCacheClosedFailoverWithTwoServerAliveHA() throws InterruptedException {
IgnoredException.addIgnoredException("FunctionInvocationTargetException");
IgnoredException.addIgnoredException("Connection reset");
IgnoredException.addIgnoredException("SocketTimeoutException");
IgnoredException.addIgnoredException("ServerConnectivityException");
IgnoredException.addIgnoredException("Socket Closed");
ArrayList commonAttributes = createCommonServerAttributes("TestPartitionedRegion", null, 1, 13, null);
createClientServerScenarion(commonAttributes, 20, 20, 20);
Function function = new TestFunction(true, TestFunction.TEST_FUNCTION_HA);
registerFunctionAtServer(function);
server2.invoke(() -> PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest.stopServerHA());
server3.invoke(() -> PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest.stopServerHA());
client.invoke(() -> PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest.putOperation());
int AsyncInvocationArrSize = 1;
AsyncInvocation[] async = new AsyncInvocation[AsyncInvocationArrSize];
async[0] = client.invokeAsync(() -> PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest.executeFunctionHA());
server2.invoke(() -> PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest.startServerHA());
server3.invoke(() -> PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest.startServerHA());
server1.invoke(() -> PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest.closeCacheHA());
client.invoke(() -> PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest.verifyDeadAndLiveServers(new Integer(1), new Integer(2)));
ThreadUtils.join(async[0], 5 * 60 * 1000);
if (async[0].getException() != null) {
Assert.fail("UnExpected Exception Occurred : ", async[0].getException());
}
List l = (List) async[0].getReturnValue();
assertEquals(2, l.size());
}
use of org.apache.geode.internal.cache.functions.TestFunction in project geode by apache.
the class PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest method testserverMultiKeyExecutionOnASingleBucket_byName.
/*
* Ensure that the execution is limited to a single bucket put another way, that the routing logic
* works correctly such that there is not extra execution
*/
@Test
public void testserverMultiKeyExecutionOnASingleBucket_byName() {
createScenario();
Function function = new TestFunction(true, TEST_FUNCTION2);
registerFunctionAtServer(function);
isByName = new Boolean(true);
client.invoke(() -> PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest.serverMultiKeyExecutionOnASingleBucket(isByName));
}
use of org.apache.geode.internal.cache.functions.TestFunction in project geode by apache.
the class PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest method testServerSingleKeyExecution_byInstance.
/*
* Execution of the function on server with single key as the routing object and using the
* instance of the function
*/
@Test
public void testServerSingleKeyExecution_byInstance() {
createScenario();
Function function = new TestFunction(true, TEST_FUNCTION2);
registerFunctionAtServer(function);
isByName = new Boolean(false);
client.invoke(() -> PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest.serverSingleKeyExecution(isByName));
}
Aggregations