@Override protected Object executeOnServer(ServerLocation p_server, Op op, boolean accessed, boolean onlyUseExistingCnx) { throw new 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); } }
@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); } } } }
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; } } }
exToThrow = new ServerConnectivityException(msg, cause);
throw new ServerConnectivityException("Tried the same primary server twice.", e);
@Test public void executeWithServerAffinityAndRetryCountGreaterThansTxRetryAttemptThrowsServerConnectivityException() { 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(opExecutor.TX_RETRY_ATTEMPT + 1); assertThatThrownBy( () -> opExecutor.executeWithServerAffinity(serverLocation, txSynchronizationOp)) .isSameAs(serverConnectivityException); }
@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()); }
throw new ServerConnectivityException( "Could not create a new connection to server " + server);
exception = new NoSubscriptionServersAvailableException(exception); } else { exception = new ServerConnectivityException(exception.getMessage(), exception);
/** * Creates a new InternalDistributedMember for use in notifying membership listeners. The version * information in the ID is set to Version.CURRENT. * * @param location the coordinates of the server */ public InternalDistributedMember(ServerLocation location) { this.hostName = location.getHostName(); final InetAddress addr; try { addr = hostnameResolver.getInetAddress(location); } catch (UnknownHostException e) { throw new ServerConnectivityException("Unable to resolve server location " + location, e); } netMbr = MemberFactory.newNetMember(addr, location.getPort()); netMbr.setVmKind(ClusterDistributionManager.NORMAL_DM_TYPE); versionObj = Version.CURRENT; netMbr.setVersion(versionObj); }
@Override protected void sendMessage(Connection cnx) throws Exception { HeapDataOutputStream hdos = new HeapDataOutputStream(Version.CURRENT); byte[] secureBytes = null; hdos.writeLong(cnx.getConnectionID()); Object userId = UserAttributes.userAttributes.get().getServerToId().get(cnx.getServer()); if (userId == null) { // This will ensure that this op is retried on another server, unless // the retryCount is exhausted. Fix for Bug 41501 throw new ServerConnectivityException("Connection error while authenticating user"); } hdos.writeLong((Long) userId); try { secureBytes = ((ConnectionImpl) cnx).encryptBytes(hdos.toByteArray()); } finally { hdos.close(); } getMessage().setSecurePart(secureBytes); getMessage().send(false); }
throw new ServerConnectivityException("Received error connecting to server", e); } finally { if (this.serverAffinity.get() && this.affinityServerLocation.get() == null) {
throw new ServerConnectivityException("Connection error while authenticating user");