Search in sources :

Example 26 with ServerConnectivityException

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

the class PoolImpl method killPrimaryEndpoint.

/**
   * Test hook used to simulate a kill of the primaryEndpoint
   */
public // throws ServerException
void killPrimaryEndpoint() {
    boolean ok = false;
    if (this.queueManager != null) {
        QueueManager.QueueConnections cons = this.queueManager.getAllConnections();
        Connection con = cons.getPrimary();
        if (con != null) {
            final String msg = "killing primary endpoint";
            logger.info("<ExpectedException action=add>{}</ExpectedException>", msg);
            Exception e = new Exception(msg);
            try {
                processException(e, con);
            } catch (ServerConnectivityException ignore) {
            } finally {
                logger.info("<ExpectedException action=remove>{}</ExpectedException>", msg);
            }
            // do some validation here that we are no longer connected to "sl"
            ok = true;
        }
    }
    if (!ok) {
        throw new IllegalStateException("primaryEndpoint was null");
    }
}
Also used : ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) CancelException(org.apache.geode.CancelException) CacheClosedException(org.apache.geode.cache.CacheClosedException) ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) PoolCancelledException(org.apache.geode.distributed.PoolCancelledException) NoSubscriptionServersAvailableException(org.apache.geode.cache.NoSubscriptionServersAvailableException) SubscriptionNotEnabledException(org.apache.geode.cache.client.SubscriptionNotEnabledException)

Example 27 with ServerConnectivityException

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

the class ServerFunctionExecutor method executeOnServer.

private ResultCollector executeOnServer(String functionId, ResultCollector rc, byte hasResult, boolean isHA, boolean optimizeForWrite) {
    FunctionStats stats = FunctionStats.getFunctionStats(functionId);
    try {
        validateExecution(null, null);
        long start = stats.startTime();
        stats.startFunctionExecution(true);
        ExecuteFunctionOp.execute(this.pool, functionId, this, args, memberMappedArg, this.allServers, hasResult, rc, this.isFnSerializationReqd, isHA, optimizeForWrite, 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 28 with ServerConnectivityException

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

the class DestroyOp method execute.

/**
   * Does a region entry destroy on a server using connections from the given pool to communicate
   * with the server.
   * 
   * @param pool the pool to use to communicate with the server.
   * @param region the region to do the entry destroy on
   * @param key the entry key to do the destroy on
   * @param event the event for this destroy operation
   * @param callbackArg an optional callback arg to pass to any cache callbacks
   */
public static Object execute(ExecutablePool pool, LocalRegion region, Object key, Object expectedOldValue, Operation operation, EntryEventImpl event, Object callbackArg, boolean prSingleHopEnabled) {
    if (logger.isDebugEnabled()) {
        logger.debug("Preparing DestroyOp for {} operation={}", key, operation);
    }
    DestroyOpImpl op = new DestroyOpImpl(region, key, expectedOldValue, operation, event, callbackArg, prSingleHopEnabled);
    if (prSingleHopEnabled) {
        ClientMetadataService cms = region.getCache().getClientMetadataService();
        ServerLocation server = cms.getBucketServerLocation(region, Operation.DESTROY, key, null, callbackArg);
        if (server != null) {
            try {
                PoolImpl poolImpl = (PoolImpl) pool;
                boolean onlyUseExistingCnx = ((poolImpl.getMaxConnections() != -1 && poolImpl.getConnectionCount() >= poolImpl.getMaxConnections()) ? true : false);
                op.setAllowDuplicateMetadataRefresh(!onlyUseExistingCnx);
                return pool.executeOn(server, op, true, onlyUseExistingCnx);
            } catch (AllConnectionsInUseException e) {
            } catch (ServerConnectivityException e) {
                if (e instanceof ServerOperationException) {
                    // fixed 44656
                    throw e;
                }
                cms.removeBucketServerLocation(server);
            }
        }
    }
    return pool.execute(op);
}
Also used : ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) ServerLocation(org.apache.geode.distributed.internal.ServerLocation) AllConnectionsInUseException(org.apache.geode.cache.client.AllConnectionsInUseException) ServerOperationException(org.apache.geode.cache.client.ServerOperationException)

Example 29 with ServerConnectivityException

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

the class QueryUsingFunctionContextDUnitTest method testQueriesWithFilterKeysOnPRWithRebalancing.

// GEODE-575: ignores lots of exceptions, non-thread-safe test hooks
@Category(FlakyTest.class)
@Test
public void testQueriesWithFilterKeysOnPRWithRebalancing() {
    IgnoredException.addIgnoredException("QueryInvocationTargetException");
    IgnoredException.addIgnoredException("java.net.SocketException");
    IgnoredException.addIgnoredException("ServerConnectivityException");
    IgnoredException.addIgnoredException("FunctionException");
    IgnoredException.addIgnoredException("IOException");
    // Close cache on server1
    server1.invoke(new CacheSerializableRunnable("Set QueryObserver in cache on server1") {

        @Override
        public void run2() throws CacheException {
            class MyQueryObserver extends IndexTrackingQueryObserver {

                @Override
                public void startQuery(Query query) {
                    Region pr = CacheFactory.getAnyInstance().getRegion(PartitionedRegionName1);
                    Region KeyRegion = null;
                    for (int i = 6; i < 9; i++) {
                        KeyRegion = ((PartitionedRegion) pr).getBucketRegion(i);
                        if (KeyRegion != null)
                            KeyRegion.destroyRegion();
                    }
                }
            }
            ;
            QueryObserverHolder.setInstance(new MyQueryObserver());
        }
    });
    client.invoke(new CacheSerializableRunnable("Run function on PR") {

        @Override
        public void run2() throws CacheException {
            Set filter = new HashSet();
            ResultCollector rcollector = null;
            filter.addAll(getFilter(6, 9));
            for (int i = 0; i < queries.length; i++) {
                try {
                    function = new TestQueryFunction("queryFunction");
                    rcollector = FunctionService.onRegion(CacheFactory.getAnyInstance().getRegion(PartitionedRegionName1)).setArguments(queries[i]).withFilter(filter).execute(function);
                    // Should not come here, an exception is expected from above function call.
                    fail("Function call did not fail for query with function context");
                } catch (FunctionException ex) {
                    if (!((ex.getCause() instanceof QueryInvocationTargetException) || (ex.getCause() instanceof ServerConnectivityException))) {
                        if (ex.getCause() instanceof FunctionException) {
                            FunctionException fe = (FunctionException) ex.getCause();
                            if (!fe.getMessage().startsWith("IOException")) {
                                fail("Should have received an QueryInvocationTargetException but recieved" + ex.getMessage());
                            }
                        } else {
                            fail("Should have received an QueryInvocationTargetException but recieved" + ex.getMessage());
                        }
                    }
                }
            }
        // For loop ends here.
        }
    });
    // Close cache on server1
    server1.invoke(new CacheSerializableRunnable("Reset Query Observer on server1") {

        @Override
        public void run2() throws CacheException {
            QueryObserverHolder.reset();
        }
    });
}
Also used : LocalDataSet(org.apache.geode.internal.cache.LocalDataSet) Set(java.util.Set) StructSetOrResultsSet(org.apache.geode.cache.query.functional.StructSetOrResultsSet) HashSet(java.util.HashSet) DefaultQuery(org.apache.geode.cache.query.internal.DefaultQuery) Query(org.apache.geode.cache.query.Query) CacheException(org.apache.geode.cache.CacheException) FunctionException(org.apache.geode.cache.execute.FunctionException) QueryInvocationTargetException(org.apache.geode.cache.query.QueryInvocationTargetException) ServerConnectivityException(org.apache.geode.cache.client.ServerConnectivityException) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Region(org.apache.geode.cache.Region) ResultCollector(org.apache.geode.cache.execute.ResultCollector) HashSet(java.util.HashSet) Category(org.junit.experimental.categories.Category) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 30 with ServerConnectivityException

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

the class ServerFunctionExecutor method executeOnServerNoAck.

private void executeOnServerNoAck(Function function, byte hasResult) {
    FunctionStats stats = FunctionStats.getFunctionStats(function.getId());
    try {
        validateExecution(function, null);
        long start = stats.startTime();
        stats.startFunctionExecution(false);
        ExecuteFunctionNoAckOp.execute(this.pool, function, args, memberMappedArg, this.allServers, hasResult, this.isFnSerializationReqd, 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)

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