Search in sources :

Example 11 with ServerConnectivityException

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

the class ClientTypeRegistration method addImportedEnum.

@Override
public void addImportedEnum(int enumId, EnumInfo importedInfo) {
    Collection<Pool> pools = getAllPools();
    ServerConnectivityException lastException = null;
    for (Pool pool : pools) {
        try {
            sendEnumIdToPool(importedInfo, enumId, pool);
        } catch (ServerConnectivityException e) {
            lastException = e;
            break;
        }
    }
    if (lastException == null) {
        return;
    }
    throw returnCorrectExceptionForFailure(pools, enumId, lastException);
}
Also used : ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) ExecutablePool(org.apache.geode.cache.client.internal.ExecutablePool) Pool(org.apache.geode.cache.client.Pool)

Example 12 with ServerConnectivityException

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

the class ServerFunctionExecutor method executeOnServer.

private ResultCollector executeOnServer(Function function, ResultCollector rc, byte hasResult) {
    FunctionStats stats = FunctionStats.getFunctionStats(function.getId());
    try {
        validateExecution(function, null);
        long start = stats.startTime();
        stats.startFunctionExecution(true);
        ExecuteFunctionOp.execute(this.pool, function, this, args, memberMappedArg, this.allServers, hasResult, rc, this.isFnSerializationReqd, UserAttributes.userAttributes.get(), groups);
        stats.endFunctionExecution(start, true);
        rc.endResults();
        return rc;
    } catch (FunctionException functionException) {
        stats.endFunctionExecutionWithException(true);
        throw functionException;
    } catch (ServerConnectivityException exception) {
        throw exception;
    } catch (Exception exception) {
        stats.endFunctionExecutionWithException(true);
        throw new FunctionException(exception);
    }
}
Also used : ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) FunctionException(org.apache.geode.cache.execute.FunctionException) FunctionException(org.apache.geode.cache.execute.FunctionException) CacheClosedException(org.apache.geode.cache.CacheClosedException) ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException)

Example 13 with ServerConnectivityException

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

the class ServerFunctionExecutor method executeOnServerNoAck.

private void executeOnServerNoAck(String functionId, byte hasResult, boolean isHA, boolean optimizeForWrite) {
    FunctionStats stats = FunctionStats.getFunctionStats(functionId);
    try {
        validateExecution(null, null);
        long start = stats.startTime();
        stats.startFunctionExecution(false);
        ExecuteFunctionNoAckOp.execute(this.pool, functionId, args, memberMappedArg, this.allServers, hasResult, this.isFnSerializationReqd, isHA, optimizeForWrite, groups);
        stats.endFunctionExecution(start, false);
    } catch (FunctionException functionException) {
        stats.endFunctionExecutionWithException(false);
        throw functionException;
    } catch (ServerConnectivityException exception) {
        throw exception;
    } catch (Exception exception) {
        stats.endFunctionExecutionWithException(false);
        throw new FunctionException(exception);
    }
}
Also used : ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) FunctionException(org.apache.geode.cache.execute.FunctionException) FunctionException(org.apache.geode.cache.execute.FunctionException) CacheClosedException(org.apache.geode.cache.CacheClosedException) ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException)

Example 14 with ServerConnectivityException

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

the class OpExecutorImplJUnitTest method testExecuteOncePerServer.

@Test
public void testExecuteOncePerServer() throws Exception {
    OpExecutorImpl exec = new OpExecutorImpl(manager, queueManager, endpointManager, riTracker, -1, 10, false, cancelCriterion, null);
    manager.numServers = 5;
    try {
        exec.execute(new Op() {

            @Override
            public Object attempt(Connection cnx) throws Exception {
                throw new IOException("Something didn't work");
            }

            @Override
            public boolean useThreadLocalConnection() {
                return true;
            }
        });
        fail("Should have got an exception");
    } catch (ServerConnectivityException expected) {
    // do nothing
    }
    assertEquals(1, borrows);
    assertEquals(4, exchanges);
    assertEquals(1, returns);
    assertEquals(6, invalidateConnections);
    assertEquals(6, serverCrashes);
}
Also used : ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) IOException(java.io.IOException) NoAvailableServersException(org.apache.geode.cache.client.NoAvailableServersException) SocketTimeoutException(java.net.SocketTimeoutException) ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) ServerOperationException(org.apache.geode.cache.client.ServerOperationException) IOException(java.io.IOException) UnitTest(org.apache.geode.test.junit.categories.UnitTest) ClientServerTest(org.apache.geode.test.junit.categories.ClientServerTest) Test(org.junit.Test)

Example 15 with ServerConnectivityException

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

the class OpExecutorImplJUnitTest method testRetryFailedServers.

@Test
public void testRetryFailedServers() throws Exception {
    OpExecutorImpl exec = new OpExecutorImpl(manager, queueManager, endpointManager, riTracker, 10, 10, false, cancelCriterion, null);
    manager.numServers = 5;
    try {
        exec.execute(new Op() {

            @Override
            public Object attempt(Connection cnx) throws Exception {
                throw new IOException("Something didn't work");
            }

            @Override
            public boolean useThreadLocalConnection() {
                return true;
            }
        });
        fail("Should have got an exception");
    } catch (ServerConnectivityException expected) {
    // do nothing
    }
    assertEquals(1, borrows);
    assertEquals(10, exchanges);
    assertEquals(1, returns);
    assertEquals(11, invalidateConnections);
    assertEquals(11, serverCrashes);
}
Also used : ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) IOException(java.io.IOException) NoAvailableServersException(org.apache.geode.cache.client.NoAvailableServersException) SocketTimeoutException(java.net.SocketTimeoutException) ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) ServerOperationException(org.apache.geode.cache.client.ServerOperationException) IOException(java.io.IOException) UnitTest(org.apache.geode.test.junit.categories.UnitTest) ClientServerTest(org.apache.geode.test.junit.categories.ClientServerTest) Test(org.junit.Test)

Aggregations

ServerConnectivityException (org.apache.geode.cache.client.ServerConnectivityException)44 ServerOperationException (org.apache.geode.cache.client.ServerOperationException)25 FunctionException (org.apache.geode.cache.execute.FunctionException)17 IOException (java.io.IOException)16 Region (org.apache.geode.cache.Region)13 NoAvailableServersException (org.apache.geode.cache.client.NoAvailableServersException)13 QueryInvocationTargetException (org.apache.geode.cache.query.QueryInvocationTargetException)12 ServerRefusedConnectionException (org.apache.geode.cache.client.ServerRefusedConnectionException)10 ServerLocation (org.apache.geode.distributed.internal.ServerLocation)10 List (java.util.List)9 ArrayList (java.util.ArrayList)8 CacheClosedException (org.apache.geode.cache.CacheClosedException)8 Pool (org.apache.geode.cache.client.Pool)6 ExecutablePool (org.apache.geode.cache.client.internal.ExecutablePool)6 Test (org.junit.Test)6 SocketTimeoutException (java.net.SocketTimeoutException)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 Set (java.util.Set)4 Execution (org.apache.geode.cache.execute.Execution)4