private GatewaySenderException getInitializeConnectionExceptionToThrow( ServerConnectivityException e) { GatewaySenderException gse = null; if (e.getCause() instanceof GemFireSecurityException) { gse = new GatewaySenderException(e.getCause()); } else { List<ServerLocation> servers = this.sender.getProxy().getCurrentServers();
private void authenticateMultiuser(PoolImpl pool, Connection conn, UserAttributes ua) { try { Long userId = (Long) AuthenticateUserOp.executeOn(conn.getServer(), pool, ua.getCredentials()); if (userId != null) { ua.setServerToId(conn.getServer(), userId); if (logger.isDebugEnabled()) { logger.debug("OpExecutorImpl.execute() - multiuser mode - authenticated this user on {}", conn); } } } catch (ServerConnectivityException sce) { Throwable cause = sce.getCause(); if (cause instanceof SocketException || cause instanceof EOFException || cause instanceof IOException || cause instanceof BufferUnderflowException || cause instanceof CancelException || (sce.getMessage() != null && (sce.getMessage().indexOf("Could not create a new connection to server") != -1 || sce.getMessage().indexOf("socket timed out on client") != -1 || sce.getMessage().indexOf("connection was asynchronously destroyed") != -1))) { throw new ServerConnectivityException("Connection error while authenticating user"); } else { throw sce; } } }
@Override protected Object executeOnServer(ServerLocation p_server, Op op, boolean accessed, boolean onlyUseExistingCnx) { throw new ServerConnectivityException(); } };
private Object executeWithPossibleReAuthentication(Connection conn, Op op) throws Exception { try { return conn.execute(op); } catch (ServerConnectivityException sce) { Throwable cause = sce.getCause(); if ((cause instanceof AuthenticationRequiredException && "User authorization attributes not found.".equals(cause.getMessage())) || sce.getMessage().contains("Connection error while authenticating user")) { // (ashetkar) Need a cleaner way of doing above check. // 2nd exception-message above is from AbstractOp.sendMessage() PoolImpl pool = (PoolImpl) PoolManagerImpl.getPMI().find(this.endpointManager.getPoolName()); if (!pool.getMultiuserAuthentication()) { Connection connImpl = this.connectionManager.getConnection(conn); conn.getServer().setUserId((Long) AuthenticateUserOp.executeOn(connImpl, this)); return conn.execute(op); } else { UserAttributes ua = UserAttributes.userAttributes.get(); if (ua != null) { authenticateMultiuser(pool, conn, ua); } return conn.execute(op); } } else { throw sce; } } }
private void sendTypeToPool(PdxType type, int id, Pool pool) { try { AddPDXTypeOp.execute((ExecutablePool) pool, id, type); } catch (ServerConnectivityException serverConnectivityException) { logger.debug("Received an exception sending pdx type to pool {}, {}", pool, serverConnectivityException.getMessage(), serverConnectivityException); throw serverConnectivityException; } }
/** * Used by GatewayBatchOp */ @Override public Object executeOn(Connection conn, Op op, boolean timeoutFatal) { try { return executeWithPossibleReAuthentication(conn, op); } catch (Exception e) { // This method will throw an exception if we need to stop // It also unsets the threadlocal connection and notifies // the connection manager if there are failures. handleException(op, e, conn, 0, true, timeoutFatal); // this shouldn't actually be reached, handle exception will throw something throw new ServerConnectivityException("Received error connecting to server", e); } }
private void sendEnumIdToPool(EnumInfo enumInfo, int id, Pool pool) { try { AddPDXEnumOp.execute((ExecutablePool) pool, id, enumInfo); } catch (ServerConnectivityException serverConnectivityException) { logger.debug("Received an exception sending pdx type to pool {}, {}", pool, serverConnectivityException.getMessage(), serverConnectivityException); throw serverConnectivityException; } }
&& (ex.getCause() instanceof NotAuthorizedException)) { getLogWriter() .info("Got expected NotAuthorizedException when doing puts: " + ex.getCause()); continue; && (ex.getCause() instanceof AuthenticationRequiredException)) { getLogWriter().info( "Got expected AuthenticationRequiredException when doing puts: " + ex.getCause()); continue; && (ex.getCause() instanceof AuthenticationFailedException)) { getLogWriter() .info("Got expected AuthenticationFailedException when doing puts: " + ex.getCause()); continue; } else if (expectedResult == OTHER_EXCEPTION) {
@Override public Object executeOnPrimary(Op op) { if (queueManager == null) { throw new SubscriptionNotEnabledException(); } HashSet attemptedPrimaries = new HashSet(); while (true) { Connection primary = queueManager.getAllConnections().getPrimary(); try { return executeWithPossibleReAuthentication(primary, op); } catch (Exception e) { boolean finalAttempt = !attemptedPrimaries.add(primary.getServer()); handleException(e, primary, 0, finalAttempt); // we shouldn't reach this code, but just in case if (finalAttempt) { throw new ServerConnectivityException("Tried the same primary server twice.", e); } } } }
@Override public EnumInfo getEnumById(int enumId) { Collection<Pool> pools = getAllPools(); ServerConnectivityException lastException = null; for (Pool pool : pools) { try { EnumInfo result = GetPDXEnumByIdOp.execute((ExecutablePool) pool, enumId); if (result != null) { return result; } } catch (ServerConnectivityException e) { logger.debug("Received an exception getting pdx type from pool {}, {}", pool, e.getMessage(), e); // ignore, try the next pool. lastException = e; } } throw returnCorrectExceptionForFailure(pools, enumId, lastException); }
exToThrow = new ServerConnectivityException(msg, cause);
@Override public PdxType getType(int typeId) { Collection<Pool> pools = getAllPools(); ServerConnectivityException lastException = null; for (Pool pool : pools) { try { PdxType type = GetPDXTypeByIdOp.execute((ExecutablePool) pool, typeId); if (type != null) { return type; } } catch (ServerConnectivityException e) { logger.debug("Received an exception getting pdx type from pool {}, {}", pool, e.getMessage(), e); // ignore, try the next pool. lastException = e; } } if (lastException != null) { throw lastException; } else { throw returnCorrectExceptionForFailure(pools, typeId, lastException); } }
@Test public void executeWithServerAffinityWithServerConnectivityExceptionIncrementsRetryCountAndResetsToZero() { OpExecutorImpl opExecutor = spy(new OpExecutorImpl(manager, queueManager, endpointManager, riTracker, -1, 10, true, cancelCriterion, mock(PoolImpl.class))); Op txSynchronizationOp = mock(TXSynchronizationOp.Impl.class); ServerLocation serverLocation = mock(ServerLocation.class); ServerConnectivityException serverConnectivityException = new ServerConnectivityException(); doThrow(serverConnectivityException).when(opExecutor).executeOnServer(serverLocation, txSynchronizationOp, true, false); opExecutor.setupServerAffinity(true); when(((AbstractOp) txSynchronizationOp).getMessage()).thenReturn(mock(Message.class)); opExecutor.setAffinityRetryCount(0); opExecutor.executeWithServerAffinity(serverLocation, txSynchronizationOp); verify(opExecutor, times(1)).setAffinityRetryCount(1); assertEquals(0, opExecutor.getAffinityRetryCount()); }
logger .info(String.format("Unable to prefill pool to minimum because: %s", ex.getMessage())); return false; } finally {
throw new ServerConnectivityException("Tried the same primary server twice.", e);
} catch (ServerConnectivityException e) { if (logger.isDebugEnabled()) { logger.debug("caught exception while executing with affinity:{}", e.getMessage(), e);