use of org.apache.geode.internal.cache.functions.TestFunction in project geode by apache.
the class ClientServerFunctionExecutionDUnitTest method testServerExecution_SocketTimeOut.
/*
* Execution of the function on server using the name of the function
*/
@Test
public void testServerExecution_SocketTimeOut() {
createScenario();
function = new TestFunction(true, TestFunction.TEST_FUNCTION_SOCKET_TIMEOUT);
registerFunctionAtServer(function);
isByName = new Boolean(true);
toRegister = new Boolean(true);
LogWriterUtils.getLogWriter().info("ClientServerFFunctionExecutionDUnitTest#testServerSingleKeyExecution_byName : Starting test");
client.invoke(() -> ClientServerFunctionExecutionDUnitTest.serverExecution(isByName, function, toRegister));
client.invoke(() -> ClientServerFunctionExecutionDUnitTest.allServerExecution(isByName, function, toRegister));
}
use of org.apache.geode.internal.cache.functions.TestFunction in project geode by apache.
the class ClientServerFunctionExecutionDUnitTest method testServerExecution_sendException.
@Test
public void testServerExecution_sendException() {
createScenario();
// function = new TestFunction1();
function = new TestFunction(true, TestFunction.TEST_FUNCTION_SEND_EXCEPTION);
registerFunctionAtServer(function);
isByName = new Boolean(true);
toRegister = new Boolean(true);
LogWriterUtils.getLogWriter().info("ClientServerFFunctionExecutionDUnitTest#testServerSingleKeyExecution_byName : Starting test");
client.invoke(() -> ClientServerFunctionExecutionDUnitTest.serverExecution_SendException(isByName, function, toRegister));
client.invoke(() -> ClientServerFunctionExecutionDUnitTest.allServerExecution_SendException(isByName, function, toRegister));
}
use of org.apache.geode.internal.cache.functions.TestFunction in project geode by apache.
the class PRClientServerRegionFunctionExecutionDUnitTest method serverSingleKeyExecution.
public static void serverSingleKeyExecution(Boolean isByName, Boolean toRegister) throws Exception {
Region region = cache.getRegion(PartitionedRegionName);
assertNotNull(region);
final String testKey = "execKey";
final Set testKeysSet = new HashSet();
testKeysSet.add(testKey);
DistributedSystem.setThreadsSocketPolicy(false);
Function function = new TestFunction(true, TEST_FUNCTION2);
if (toRegister.booleanValue()) {
FunctionService.registerFunction(function);
} else {
FunctionService.unregisterFunction(function.getId());
assertNull(FunctionService.getFunction(function.getId()));
}
Execution dataSet = FunctionService.onRegion(region);
try {
execute(dataSet, testKeysSet, Boolean.TRUE, function, isByName);
} catch (Exception ex) {
if (!(ex.getMessage().contains("No target node found for KEY = " + testKey) || ex.getMessage().startsWith("Server could not send the reply") || ex.getMessage().startsWith("Unexpected exception during"))) {
throw ex;
}
}
region.put(testKey, new Integer(1));
ResultCollector rs = execute(dataSet, testKeysSet, Boolean.TRUE, function, isByName);
assertEquals(Boolean.TRUE, ((List) rs.getResult()).get(0));
ResultCollector rs2 = execute(dataSet, testKeysSet, testKey, function, isByName);
assertEquals(new Integer(1), ((List) rs2.getResult()).get(0));
HashMap putData = new HashMap();
putData.put(testKey + "1", new Integer(2));
putData.put(testKey + "2", new Integer(3));
ResultCollector rs1 = execute(dataSet, testKeysSet, putData, function, isByName);
assertEquals(Boolean.TRUE, ((List) rs1.getResult()).get(0));
assertEquals(new Integer(2), region.get(testKey + "1"));
assertEquals(new Integer(3), region.get(testKey + "2"));
}
use of org.apache.geode.internal.cache.functions.TestFunction in project geode by apache.
the class PRClientServerRegionFunctionExecutionDUnitTest method testBucketFilterOverride.
@Test
public void testBucketFilterOverride() {
createScenarioForBucketFilter();
Function function = new TestFunction(true, TestFunction.TEST_FUNCTION_BUCKET_FILTER);
registerFunctionAtServer(function);
// test multi key filter
Set<Integer> bucketFilterSet = new HashSet<Integer>();
bucketFilterSet.add(3);
bucketFilterSet.add(6);
bucketFilterSet.add(8);
Set<Integer> keyFilterSet = new HashSet<Integer>();
keyFilterSet.add(75);
keyFilterSet.add(25);
client.invoke(() -> PRClientServerTestBase.serverBucketFilterOverrideExecution(bucketFilterSet, keyFilterSet));
}
use of org.apache.geode.internal.cache.functions.TestFunction in project geode by apache.
the class PRClientServerRegionFunctionExecutionFailoverDUnitTest method testServerFailoverWithTwoServerAliveHA.
/*
* Ensure that the while executing the function if the servers is down then the execution is
* failover to other available server
*/
@Test
public void testServerFailoverWithTwoServerAliveHA() throws InterruptedException {
IgnoredException.addIgnoredException("FunctionInvocationTargetException");
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(() -> PRClientServerRegionFunctionExecutionDUnitTest.stopServerHA());
server3.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.stopServerHA());
client.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.putOperation());
int AsyncInvocationArrSize = 1;
AsyncInvocation[] async = new AsyncInvocation[AsyncInvocationArrSize];
async[0] = client.invokeAsync(() -> PRClientServerRegionFunctionExecutionDUnitTest.executeFunctionHA());
server2.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.startServerHA());
server3.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.startServerHA());
server1.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.stopServerHA());
client.invoke(() -> PRClientServerRegionFunctionExecutionDUnitTest.verifyDeadAndLiveServers(new Integer(1), new Integer(2)));
ThreadUtils.join(async[0], 6 * 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());
}
Aggregations