Search in sources :

Example 11 with NoAvailableServersException

use of org.apache.geode.cache.client.NoAvailableServersException in project geode by apache.

the class SecurityTestUtils method doContainsKeysP.

private static void doContainsKeysP(final int num, final int multiUserIndex, final int expectedResult, final boolean expectedValue) {
    assertTrue(num <= KEYS.length);
    Region region = null;
    try {
        if (multiUserAuthMode) {
            region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
        } else {
            region = getCache().getRegion(REGION_NAME);
        }
        assertNotNull(region);
    } catch (Exception ex) {
        if (expectedResult == OTHER_EXCEPTION) {
            getLogWriter().info("Got expected exception when doing containsKey: " + ex);
        } else {
            fail("Got unexpected exception when doing containsKey", ex);
        }
    }
    for (int index = 0; index < num; ++index) {
        boolean result = false;
        try {
            result = region.containsKeyOnServer(KEYS[index]);
            if (expectedResult != NO_EXCEPTION) {
                fail("Expected a NotAuthorizedException while doing containsKey");
            }
        } catch (NoAvailableServersException ex) {
            if (expectedResult == NO_AVAILABLE_SERVERS) {
                getLogWriter().info("Got expected NoAvailableServers when doing containsKey: " + ex.getCause());
                continue;
            } else {
                fail("Got unexpected exception when doing containsKey", ex);
            }
        } catch (ServerConnectivityException ex) {
            if ((expectedResult == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) {
                getLogWriter().info("Got expected NotAuthorizedException when doing containsKey: " + ex.getCause());
                continue;
            } else if (expectedResult == OTHER_EXCEPTION) {
                getLogWriter().info("Got expected exception when doing containsKey: " + ex);
            } else {
                fail("Got unexpected exception when doing containsKey", ex);
            }
        } catch (Exception ex) {
            if (expectedResult == OTHER_EXCEPTION) {
                getLogWriter().info("Got expected exception when doing containsKey: " + ex);
            } else {
                fail("Got unexpected exception when doing containsKey", ex);
            }
        }
        assertEquals(expectedValue, result);
    }
}
Also used : ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) NoAvailableServersException(org.apache.geode.cache.client.NoAvailableServersException) Region(org.apache.geode.cache.Region) ServerRefusedConnectionException(org.apache.geode.cache.client.ServerRefusedConnectionException) NoAvailableServersException(org.apache.geode.cache.client.NoAvailableServersException) QueryInvocationTargetException(org.apache.geode.cache.query.QueryInvocationTargetException) FunctionException(org.apache.geode.cache.execute.FunctionException) ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) ServerOperationException(org.apache.geode.cache.client.ServerOperationException) IOException(java.io.IOException)

Example 12 with NoAvailableServersException

use of org.apache.geode.cache.client.NoAvailableServersException in project geode by apache.

the class SecurityTestUtils method doGetAllP.

private static void doGetAllP(final int multiUserIndex, final int expectedResult, final boolean useTX) {
    Region region = null;
    try {
        if (multiUserAuthMode) {
            region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
        } else {
            region = getCache().getRegion(REGION_NAME);
        }
        assertNotNull(region);
    } catch (Exception ex) {
        if (expectedResult == OTHER_EXCEPTION) {
            getLogWriter().info("Got expected exception when doing getAll: " + ex);
        } else {
            fail("Got unexpected exception when doing getAll", ex);
        }
    }
    try {
        List keys = new ArrayList();
        keys.add("key1");
        keys.add("key2");
        if (useTX) {
            getCache().getCacheTransactionManager().begin();
        }
        Map entries = region.getAll(keys);
        // Also check getEntry()
        region.getEntry("key1");
        if (useTX) {
            getCache().getCacheTransactionManager().commit();
        }
        assertNotNull(entries);
        if ((expectedResult == NOTAUTHZ_EXCEPTION)) {
            assertEquals(0, entries.size());
        } else if ((expectedResult == NO_EXCEPTION)) {
            assertEquals(2, entries.size());
            assertEquals("value1", entries.get("key1"));
            assertEquals("value2", entries.get("key2"));
        }
    } catch (NoAvailableServersException ex) {
        if (expectedResult == NO_AVAILABLE_SERVERS) {
            getLogWriter().info("Got expected NoAvailableServers when doing getAll: " + ex.getCause());
        } else {
            fail("Got unexpected exception when doing getAll", ex);
        }
    } catch (ServerConnectivityException ex) {
        if ((expectedResult == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) {
            getLogWriter().info("Got expected NotAuthorizedException when doing getAll: " + ex.getCause());
        } else if (expectedResult == OTHER_EXCEPTION) {
            getLogWriter().info("Got expected exception when doing getAll: " + ex);
        } else {
            fail("Got unexpected exception when doing getAll", ex);
        }
    } catch (Exception ex) {
        if (expectedResult == OTHER_EXCEPTION) {
            getLogWriter().info("Got expected exception when doing getAll: " + ex);
        } else {
            fail("Got unexpected exception when doing getAll", ex);
        }
    }
}
Also used : ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) NoAvailableServersException(org.apache.geode.cache.client.NoAvailableServersException) ArrayList(java.util.ArrayList) Region(org.apache.geode.cache.Region) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ServerRefusedConnectionException(org.apache.geode.cache.client.ServerRefusedConnectionException) NoAvailableServersException(org.apache.geode.cache.client.NoAvailableServersException) QueryInvocationTargetException(org.apache.geode.cache.query.QueryInvocationTargetException) FunctionException(org.apache.geode.cache.execute.FunctionException) ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) ServerOperationException(org.apache.geode.cache.client.ServerOperationException) IOException(java.io.IOException)

Example 13 with NoAvailableServersException

use of org.apache.geode.cache.client.NoAvailableServersException in project geode by apache.

the class SecurityTestUtils method doDestroysP.

private static void doDestroysP(final int num, final int multiUserIndex, final int expectedResult) {
    assertTrue(num <= KEYS.length);
    Region region = null;
    try {
        if (multiUserAuthMode) {
            region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
        } else {
            region = getCache().getRegion(REGION_NAME);
        }
        assertNotNull(region);
    } catch (Exception ex) {
        if (expectedResult == OTHER_EXCEPTION) {
            getLogWriter().info("Got expected exception when doing destroys: " + ex);
        } else {
            fail("Got unexpected exception when doing destroys", ex);
        }
    }
    for (int index = 0; index < num; ++index) {
        try {
            region.destroy(KEYS[index]);
            if (expectedResult != NO_EXCEPTION) {
                fail("Expected a NotAuthorizedException while doing destroys");
            }
        } catch (NoAvailableServersException ex) {
            if (expectedResult == NO_AVAILABLE_SERVERS) {
                getLogWriter().info("Got expected NoAvailableServers when doing destroys: " + ex.getCause());
                continue;
            } else {
                fail("Got unexpected exception when doing destroys", ex);
            }
        } catch (ServerConnectivityException ex) {
            if ((expectedResult == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) {
                getLogWriter().info("Got expected NotAuthorizedException when doing destroys: " + ex.getCause());
                continue;
            } else if (expectedResult == OTHER_EXCEPTION) {
                getLogWriter().info("Got expected exception when doing destroys: " + ex);
            } else {
                fail("Got unexpected exception when doing destroys", ex);
            }
        } catch (Exception ex) {
            if (expectedResult == OTHER_EXCEPTION) {
                getLogWriter().info("Got expected exception when doing destroys: " + ex);
            } else {
                fail("Got unexpected exception when doing destroys", ex);
            }
        }
    }
}
Also used : ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) NoAvailableServersException(org.apache.geode.cache.client.NoAvailableServersException) Region(org.apache.geode.cache.Region) ServerRefusedConnectionException(org.apache.geode.cache.client.ServerRefusedConnectionException) NoAvailableServersException(org.apache.geode.cache.client.NoAvailableServersException) QueryInvocationTargetException(org.apache.geode.cache.query.QueryInvocationTargetException) FunctionException(org.apache.geode.cache.execute.FunctionException) ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) ServerOperationException(org.apache.geode.cache.client.ServerOperationException) IOException(java.io.IOException)

Example 14 with NoAvailableServersException

use of org.apache.geode.cache.client.NoAvailableServersException in project geode by apache.

the class SecurityTestUtils method doPutsP.

private static void doPutsP(final int num, final int multiUserIndex, final int expectedResult, final boolean newVals) {
    assertTrue(num <= KEYS.length);
    Region region = getRegion(multiUserIndex, expectedResult);
    for (int index = 0; index < num; ++index) {
        try {
            if (newVals) {
                region.put(KEYS[index], NVALUES[index]);
            } else {
                region.put(KEYS[index], VALUES[index]);
            }
            if (expectedResult != NO_EXCEPTION) {
                fail("Expected a NotAuthorizedException while doing puts");
            }
        } catch (NoAvailableServersException ex) {
            if (expectedResult == NO_AVAILABLE_SERVERS) {
                getLogWriter().info("Got expected NoAvailableServers when doing puts: " + ex.getCause());
                continue;
            } else {
                fail("Got unexpected exception when doing puts", ex);
            }
        } catch (ServerConnectivityException ex) {
            if ((expectedResult == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) {
                getLogWriter().info("Got expected NotAuthorizedException when doing puts: " + ex.getCause());
                continue;
            }
            if ((expectedResult == AUTHREQ_EXCEPTION) && (ex.getCause() instanceof AuthenticationRequiredException)) {
                getLogWriter().info("Got expected AuthenticationRequiredException when doing puts: " + ex.getCause());
                continue;
            }
            if ((expectedResult == AUTHFAIL_EXCEPTION) && (ex.getCause() instanceof AuthenticationFailedException)) {
                getLogWriter().info("Got expected AuthenticationFailedException when doing puts: " + ex.getCause());
                continue;
            } else if (expectedResult == OTHER_EXCEPTION) {
                getLogWriter().info("Got expected exception when doing puts: " + ex);
            } else {
                fail("Got unexpected exception when doing puts", ex);
            }
        } catch (Exception ex) {
            if (expectedResult == OTHER_EXCEPTION) {
                getLogWriter().info("Got expected exception when doing puts: " + ex);
            } else {
                fail("Got unexpected exception when doing puts", ex);
            }
        }
    }
}
Also used : ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) NoAvailableServersException(org.apache.geode.cache.client.NoAvailableServersException) Region(org.apache.geode.cache.Region) ServerRefusedConnectionException(org.apache.geode.cache.client.ServerRefusedConnectionException) NoAvailableServersException(org.apache.geode.cache.client.NoAvailableServersException) QueryInvocationTargetException(org.apache.geode.cache.query.QueryInvocationTargetException) FunctionException(org.apache.geode.cache.execute.FunctionException) ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) ServerOperationException(org.apache.geode.cache.client.ServerOperationException) IOException(java.io.IOException)

Aggregations

NoAvailableServersException (org.apache.geode.cache.client.NoAvailableServersException)14 IOException (java.io.IOException)13 Region (org.apache.geode.cache.Region)11 ServerConnectivityException (org.apache.geode.cache.client.ServerConnectivityException)10 ServerOperationException (org.apache.geode.cache.client.ServerOperationException)10 ServerRefusedConnectionException (org.apache.geode.cache.client.ServerRefusedConnectionException)10 FunctionException (org.apache.geode.cache.execute.FunctionException)10 QueryInvocationTargetException (org.apache.geode.cache.query.QueryInvocationTargetException)10 PoolImpl (org.apache.geode.cache.client.internal.PoolImpl)3 LocalRegion (org.apache.geode.internal.cache.LocalRegion)3 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)3 CancelException (org.apache.geode.CancelException)2 Endpoint (org.apache.geode.cache.client.internal.Endpoint)2 SelectResults (org.apache.geode.cache.query.SelectResults)2 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)2 AsyncInvocation (org.apache.geode.test.dunit.AsyncInvocation)2 Host (org.apache.geode.test.dunit.Host)2 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)2 VM (org.apache.geode.test.dunit.VM)2 ArrayList (java.util.ArrayList)1