Search in sources :

Example 1 with QueueConnections

use of org.apache.geode.cache.client.internal.QueueManager.QueueConnections in project geode by apache.

the class OpExecutorImpl method executeOnAllQueueServers.

public void executeOnAllQueueServers(Op op) {
    if (queueManager == null) {
        throw new SubscriptionNotEnabledException();
    }
    RuntimeException lastException = null;
    QueueConnections connections = queueManager.getAllConnectionsNoWait();
    Connection primary = connections.getPrimary();
    if (primary != null) {
        try {
            executeWithPossibleReAuthentication(primary, op);
        } catch (Exception e) {
            try {
                handleException(e, primary, 0, false);
            } catch (RuntimeException e2) {
                lastException = e2;
            }
        }
    }
    List backups = connections.getBackups();
    for (int i = 0; i < backups.size(); i++) {
        Connection conn = (Connection) backups.get(i);
        try {
            executeWithPossibleReAuthentication(conn, op);
        } catch (Exception e) {
            try {
                handleException(e, conn, 0, false);
            } catch (RuntimeException e2) {
                lastException = e2;
            }
        }
    }
    if (lastException != null) {
        throw lastException;
    }
}
Also used : CacheRuntimeException(org.apache.geode.cache.CacheRuntimeException) QueueConnections(org.apache.geode.cache.client.internal.QueueManager.QueueConnections) FunctionInvocationTargetException(org.apache.geode.cache.execute.FunctionInvocationTargetException) FunctionException(org.apache.geode.cache.execute.FunctionException) MessageTooLargeException(org.apache.geode.internal.cache.tier.sockets.MessageTooLargeException) TransactionException(org.apache.geode.cache.TransactionException) SocketException(java.net.SocketException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) SocketTimeoutException(java.net.SocketTimeoutException) ConnectException(java.net.ConnectException) GemFireSecurityException(org.apache.geode.security.GemFireSecurityException) PutAllPartialResultException(org.apache.geode.internal.cache.PutAllPartialResultException) BatchException(org.apache.geode.internal.cache.tier.BatchException) ConnectionDestroyedException(org.apache.geode.cache.client.internal.pooling.ConnectionDestroyedException) InternalFunctionInvocationTargetException(org.apache.geode.internal.cache.execute.InternalFunctionInvocationTargetException) IOException(java.io.IOException) NotSerializableException(java.io.NotSerializableException) CacheRuntimeException(org.apache.geode.cache.CacheRuntimeException) EOFException(java.io.EOFException) BufferUnderflowException(java.nio.BufferUnderflowException) AuthenticationRequiredException(org.apache.geode.security.AuthenticationRequiredException) SynchronizationCommitConflictException(org.apache.geode.cache.SynchronizationCommitConflictException)

Example 2 with QueueConnections

use of org.apache.geode.cache.client.internal.QueueManager.QueueConnections in project geode by apache.

the class OpExecutorImpl method executeOnServer.

private Object executeOnServer(ServerLocation p_server, Op op, boolean accessed, boolean onlyUseExistingCnx) {
    ServerLocation server = p_server;
    boolean returnCnx = true;
    boolean pingOp = (op instanceof PingOp.PingOpImpl);
    Connection conn = null;
    if (pingOp) {
        // not create a pooled cnx when all we have is queue cnxs.
        if (this.queueManager != null) {
            // see if our QueueManager has a connection to this guy that we can send
            // the ping on.
            Endpoint ep = (Endpoint) this.endpointManager.getEndpointMap().get(server);
            if (ep != null) {
                QueueConnections qcs = this.queueManager.getAllConnectionsNoWait();
                conn = qcs.getConnection(ep);
                if (conn != null) {
                    // we found one to do the ping on
                    returnCnx = false;
                }
            }
        }
    }
    if (conn == null) {
        if (useThreadLocalConnection(op, pingOp)) {
            // no need to set threadLocal to null while the op is in progress since
            // 43718 does not impact single-hop
            conn = getActivatedThreadLocalConnectionForSingleHop(server, onlyUseExistingCnx);
            returnCnx = false;
        } else {
            conn = connectionManager.borrowConnection(server, serverTimeout, onlyUseExistingCnx);
        }
    }
    boolean success = true;
    try {
        return executeWithPossibleReAuthentication(conn, op);
    } catch (Exception e) {
        success = false;
        // 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(e, conn, 0, true);
        // this shouldn't actually be reached, handle exception will throw something
        throw new ServerConnectivityException("Received error connecting to server", e);
    } finally {
        if (this.serverAffinity.get() && this.affinityServerLocation.get() == null) {
            if (logger.isDebugEnabled()) {
                logger.debug("setting server affinity to {} server:{}", conn.getEndpoint().getMemberId(), conn.getServer());
            }
            this.affinityServerLocation.set(conn.getServer());
        }
        if (useThreadLocalConnection(op, pingOp)) {
            this.connectionManager.passivate(conn, success);
            setThreadLocalConnectionForSingleHop(server, conn);
        }
        if (returnCnx) {
            connectionManager.returnConnection(conn, accessed);
        }
    }
}
Also used : ServerLocation(org.apache.geode.distributed.internal.ServerLocation) QueueConnections(org.apache.geode.cache.client.internal.QueueManager.QueueConnections) FunctionInvocationTargetException(org.apache.geode.cache.execute.FunctionInvocationTargetException) FunctionException(org.apache.geode.cache.execute.FunctionException) MessageTooLargeException(org.apache.geode.internal.cache.tier.sockets.MessageTooLargeException) TransactionException(org.apache.geode.cache.TransactionException) SocketException(java.net.SocketException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) SocketTimeoutException(java.net.SocketTimeoutException) ConnectException(java.net.ConnectException) GemFireSecurityException(org.apache.geode.security.GemFireSecurityException) PutAllPartialResultException(org.apache.geode.internal.cache.PutAllPartialResultException) BatchException(org.apache.geode.internal.cache.tier.BatchException) ConnectionDestroyedException(org.apache.geode.cache.client.internal.pooling.ConnectionDestroyedException) InternalFunctionInvocationTargetException(org.apache.geode.internal.cache.execute.InternalFunctionInvocationTargetException) IOException(java.io.IOException) NotSerializableException(java.io.NotSerializableException) CacheRuntimeException(org.apache.geode.cache.CacheRuntimeException) EOFException(java.io.EOFException) BufferUnderflowException(java.nio.BufferUnderflowException) AuthenticationRequiredException(org.apache.geode.security.AuthenticationRequiredException) SynchronizationCommitConflictException(org.apache.geode.cache.SynchronizationCommitConflictException)

Example 3 with QueueConnections

use of org.apache.geode.cache.client.internal.QueueManager.QueueConnections in project geode by apache.

the class OpExecutorImpl method executeOnQueuesAndReturnPrimaryResult.

/*
   * (non-Javadoc)
   * 
   * @see
   * org.apache.geode.cache.client.internal.ExecutablePool#executeOnAllQueueServers(org.apache.geode
   * .cache.client.internal.Op)
   */
public Object executeOnQueuesAndReturnPrimaryResult(Op op) {
    if (queueManager == null) {
        throw new SubscriptionNotEnabledException();
    }
    QueueConnections connections = queueManager.getAllConnections();
    List backups = connections.getBackups();
    if (logger.isTraceEnabled(LogMarker.BRIDGE_SERVER)) {
        logger.trace(LogMarker.BRIDGE_SERVER, "sending {} to backups: {}", op, backups);
    }
    for (int i = backups.size() - 1; i >= 0; i--) {
        Connection conn = (Connection) backups.get(i);
        try {
            executeWithPossibleReAuthentication(conn, op);
        } catch (Exception e) {
            handleException(e, conn, 0, false);
        }
    }
    Connection primary = connections.getPrimary();
    HashSet attemptedPrimaries = new HashSet();
    while (true) {
        try {
            if (logger.isTraceEnabled(LogMarker.BRIDGE_SERVER)) {
                logger.trace(LogMarker.BRIDGE_SERVER, "sending {} to primary: {}", op, primary);
            }
            return executeWithPossibleReAuthentication(primary, op);
        } catch (Exception e) {
            if (logger.isTraceEnabled(LogMarker.BRIDGE_SERVER)) {
                logger.trace(LogMarker.BRIDGE_SERVER, "caught exception sending to primary {}", e.getMessage(), e);
            }
            boolean finalAttempt = !attemptedPrimaries.add(primary.getServer());
            handleException(e, primary, 0, finalAttempt);
            primary = queueManager.getAllConnections().getPrimary();
            // we shouldn't reach this code, but just in case
            if (finalAttempt) {
                throw new ServerConnectivityException("Tried the same primary server twice.", e);
            }
        }
    }
}
Also used : QueueConnections(org.apache.geode.cache.client.internal.QueueManager.QueueConnections) FunctionInvocationTargetException(org.apache.geode.cache.execute.FunctionInvocationTargetException) FunctionException(org.apache.geode.cache.execute.FunctionException) MessageTooLargeException(org.apache.geode.internal.cache.tier.sockets.MessageTooLargeException) TransactionException(org.apache.geode.cache.TransactionException) SocketException(java.net.SocketException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) SocketTimeoutException(java.net.SocketTimeoutException) ConnectException(java.net.ConnectException) GemFireSecurityException(org.apache.geode.security.GemFireSecurityException) PutAllPartialResultException(org.apache.geode.internal.cache.PutAllPartialResultException) BatchException(org.apache.geode.internal.cache.tier.BatchException) ConnectionDestroyedException(org.apache.geode.cache.client.internal.pooling.ConnectionDestroyedException) InternalFunctionInvocationTargetException(org.apache.geode.internal.cache.execute.InternalFunctionInvocationTargetException) IOException(java.io.IOException) NotSerializableException(java.io.NotSerializableException) CacheRuntimeException(org.apache.geode.cache.CacheRuntimeException) EOFException(java.io.EOFException) BufferUnderflowException(java.nio.BufferUnderflowException) AuthenticationRequiredException(org.apache.geode.security.AuthenticationRequiredException) SynchronizationCommitConflictException(org.apache.geode.cache.SynchronizationCommitConflictException)

Aggregations

EOFException (java.io.EOFException)3 IOException (java.io.IOException)3 NotSerializableException (java.io.NotSerializableException)3 ConnectException (java.net.ConnectException)3 SocketException (java.net.SocketException)3 SocketTimeoutException (java.net.SocketTimeoutException)3 BufferUnderflowException (java.nio.BufferUnderflowException)3 CacheRuntimeException (org.apache.geode.cache.CacheRuntimeException)3 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)3 SynchronizationCommitConflictException (org.apache.geode.cache.SynchronizationCommitConflictException)3 TransactionException (org.apache.geode.cache.TransactionException)3 QueueConnections (org.apache.geode.cache.client.internal.QueueManager.QueueConnections)3 ConnectionDestroyedException (org.apache.geode.cache.client.internal.pooling.ConnectionDestroyedException)3 FunctionException (org.apache.geode.cache.execute.FunctionException)3 FunctionInvocationTargetException (org.apache.geode.cache.execute.FunctionInvocationTargetException)3 PutAllPartialResultException (org.apache.geode.internal.cache.PutAllPartialResultException)3 InternalFunctionInvocationTargetException (org.apache.geode.internal.cache.execute.InternalFunctionInvocationTargetException)3 BatchException (org.apache.geode.internal.cache.tier.BatchException)3 MessageTooLargeException (org.apache.geode.internal.cache.tier.sockets.MessageTooLargeException)3 AuthenticationRequiredException (org.apache.geode.security.AuthenticationRequiredException)3