Search in sources :

Example 36 with FunctionInvocationTargetException

use of org.apache.geode.cache.execute.FunctionInvocationTargetException in project geode by apache.

the class OnGroupsFunctionExecutionDUnitTest method testP2PIgnoreMemberFailure.

@Test
public void testP2PIgnoreMemberFailure() {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    VM vm2 = host.getVM(2);
    final String regionName = getName();
    initVM(vm0, "g0,mg", regionName, false);
    initVM(vm1, "g1", regionName, false);
    initVM(vm2, "g0,g1,g2", regionName, false);
    vm0.invoke(new SerializableCallable() {

        @Override
        public Object call() throws Exception {
            DistributedSystem ds = getSystem();
            Execution e1 = FunctionService.onMembers("g1");
            ArrayList<String> args = new ArrayList<String>();
            args.add("shutdown");
            args.add("g2");
            e1 = e1.setArguments(args);
            ((AbstractExecution) e1).setIgnoreDepartedMembers(true);
            ArrayList l = (ArrayList) e1.execute(new OnGroupsExceptionFunction()).getResult();
            assertEquals(2, l.size());
            if (l.get(0) instanceof FunctionInvocationTargetException) {
                assertTrue((Boolean) l.get(1));
            } else if (l.get(0) instanceof Boolean) {
                assertTrue(l.get(1) instanceof FunctionInvocationTargetException);
            } else {
                fail("expected to find a Boolean or throwable at index 0");
            }
            return null;
        }
    });
}
Also used : ArrayList(java.util.ArrayList) Host(org.apache.geode.test.dunit.Host) DistributedSystem(org.apache.geode.distributed.DistributedSystem) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) FunctionInvocationTargetException(org.apache.geode.cache.execute.FunctionInvocationTargetException) FunctionException(org.apache.geode.cache.execute.FunctionException) CacheClosedException(org.apache.geode.cache.CacheClosedException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Execution(org.apache.geode.cache.execute.Execution) VM(org.apache.geode.test.dunit.VM) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) FunctionInvocationTargetException(org.apache.geode.cache.execute.FunctionInvocationTargetException) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

FunctionInvocationTargetException (org.apache.geode.cache.execute.FunctionInvocationTargetException)36 ArrayList (java.util.ArrayList)20 FunctionException (org.apache.geode.cache.execute.FunctionException)19 CacheClosedException (org.apache.geode.cache.CacheClosedException)16 ResultCollector (org.apache.geode.cache.execute.ResultCollector)13 Execution (org.apache.geode.cache.execute.Execution)11 Region (org.apache.geode.cache.Region)10 List (java.util.List)9 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)9 InternalFunctionInvocationTargetException (org.apache.geode.internal.cache.execute.InternalFunctionInvocationTargetException)9 IOException (java.io.IOException)8 HashSet (java.util.HashSet)8 DistributedMember (org.apache.geode.distributed.DistributedMember)8 CliMetaData (org.apache.geode.management.cli.CliMetaData)8 Result (org.apache.geode.management.cli.Result)7 IgnoredException (org.apache.geode.test.dunit.IgnoredException)7 AbstractExecution (org.apache.geode.internal.cache.execute.AbstractExecution)6 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)6 Test (org.junit.Test)6 CliCommand (org.springframework.shell.core.annotation.CliCommand)6