Examples of ClientResponseImpl


Examples of org.voltdb.ClientResponseImpl

                                       long deltaNanos,
                                       long nowNanos,
                                       long timeoutNanos,
                                       long handle,
                                       boolean ignoreBackpressure) {
            ClientResponseImpl r = new ClientResponseImpl(
                    ClientResponse.CONNECTION_TIMEOUT,
                    ClientResponse.UNINITIALIZED_APP_STATUS_CODE,
                    "",
                    new VoltTable[0],
                    String.format("No response received in the allotted time (set to %d ms).",
                            TimeUnit.NANOSECONDS.toMillis(timeoutNanos)));
            r.setClientHandle(handle);
            r.setClientRoundtrip(deltaNanos);
            r.setClusterRoundtrip((int)TimeUnit.NANOSECONDS.toMillis(deltaNanos));
            try {
                callback.clientCallback(r);
            } catch (Throwable e1) {
                uncaughtException( callback, r, e1);
            }

            //Drain needs to know when all callbacks have been invoked
            final int remainingToInvoke = m_callbacksToInvoke.decrementAndGet();
            assert(remainingToInvoke >= 0);

            m_rateLimiter.transactionResponseReceived(nowNanos, -1, ignoreBackpressure);
            updateStatsForTimeout(procName, r.getClientRoundtripNanos(), r.getClusterRoundtrip());
        }
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

        }

        @Override
        public void handleMessage(ByteBuffer buf, Connection c) {
            long nowNanos = System.nanoTime();
            ClientResponseImpl response = new ClientResponseImpl();
            try {
                response.initFromBuffer(buf);
            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

            // track the timestamp of the most recent read on this connection
            m_lastResponseTimeNanos = nowNanos;

            final long handle = response.getClientHandle();

            // handle ping response and get out
            if (handle == PING_HANDLE) {
                m_outstandingPing = false;
                return;
            } else if (handle == ASYNC_TOPO_HANDLE) {
                /*
                 * Really didn't want to add this block because it is not DRY
                 * for the exception handling, but trying to set + reset the async topo callback
                 * turned out to be pretty challenging
                 */
                ProcedureCallback cb = new TopoUpdateCallback();
                try {
                    cb.clientCallback(response);
                } catch (Exception e) {
                    uncaughtException(cb, response, e);
                }

                return;
            }

            //Race with expiration thread to be the first to remove the callback
            //from the map and process it
            final CallbackBookeeping stuff = m_callbacks.remove(response.getClientHandle());

            // presumably (hopefully) this is a response for a timed-out message
            if (stuff == null) {
                // also ignore internal (topology and procedure) calls
                if (handle >= 0) {
                    // notify any listeners of the late response
                    for (ClientStatusListenerExt listener : m_listeners) {
                        listener.lateProcedureResponse(
                                response,
                                m_connection.getHostnameOrIP(),
                                m_connection.getRemotePort());
                    }
                }
            }
            // handle a proper callback
            else {
                final long callTimeNanos = stuff.timestampNanos;
                final long deltaNanos = Math.max(1, nowNanos - callTimeNanos);
                final ProcedureCallback cb = stuff.callback;
                assert(cb != null);
                final byte status = response.getStatus();
                boolean abort = false;
                boolean error = false;
                if (status == ClientResponse.USER_ABORT || status == ClientResponse.GRACEFUL_FAILURE) {
                    abort = true;
                } else if (status != ClientResponse.SUCCESS) {
                    error = true;
                }

                int clusterRoundTrip = response.getClusterRoundtrip();
                m_rateLimiter.transactionResponseReceived(nowNanos, clusterRoundTrip, stuff.ignoreBackpressure);
                updateStats(stuff.name, deltaNanos, clusterRoundTrip, abort, error, false);
                response.setClientRoundtrip(deltaNanos);
                assert(response.getHash() == null); // make sure it didn't sneak into wire protocol
                try {
                    cb.clientCallback(response);
                } catch (Exception e) {
                    uncaughtException(cb, response, e);
                }
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

                }
            }

            //Invoke callbacks for all queued invocations with a failure response
            final ClientResponse r =
                new ClientResponseImpl(
                        ClientResponse.CONNECTION_LOST, new VoltTable[0],
                        "Connection to database host (" + m_connection.getHostnameAndIPAndPort() +
                ") was lost before a response was received");
            for (Map.Entry<Long, CallbackBookeeping> e : m_callbacks.entrySet()) {
                //Check for race with other threads
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

                                  Pair<Long, byte[]> currentHashinatorConfig) {
        m_mispartitioned = mispartitioned;
        m_invocation = invocation;
        m_currentHashinatorConfig = currentHashinatorConfig;
        m_commit = false;
        m_response = new ClientResponseImpl(ClientResponse.TXN_RESTART, new VoltTable[]{}, "Mispartitioned");
    }
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

        m_clientInterfaceHandle = buf.getLong();
        m_connectionId = buf.getLong();
        m_readOnly = buf.get() == 1;
        m_recovering = buf.get() == 1;
        m_mispartitioned = buf.get() == 1;
        m_response = new ClientResponseImpl();
        m_response.initFromBuffer(buf);
        m_commit = (m_response.getStatus() == ClientResponseImpl.SUCCESS);
        if (m_mispartitioned) {
            long hashinatorVersion = buf.getLong();
            byte[] hashinatorBytes = new byte[buf.getInt()];
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

    }


    public void pokeLastCallback(final byte status, final String message) throws Exception
    {
        ClientResponse clientResponse = new ClientResponseImpl(status, new VoltTable[0], message);
        m_lastCallback.clientCallback(clientResponse);
    }
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

        m_lastCallback.clientCallback(clientResponse);
    }

    public void pokeAllPendingCallbacks(final byte status, final String message) throws Exception
    {
        ClientResponse clientResponse = new ClientResponseImpl(status, new VoltTable[0], message);
        ProcedureCallback callback = null;
        while ((callback = m_callbacks.poll()) != null) {
            callback.clientCallback(clientResponse);
        }
    }
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

        }
        else
        {
            lastOrigTxnId = originalTxnId;
        }
        return new ClientResponseImpl(ClientResponse.SUCCESS, new VoltTable[0], "");
    }
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

        /**
         * Handle an incoming message
         * @throws IOException
         */
        public void handleInput(ByteBuffer message, Connection connection) throws IOException {
            ClientResponseImpl response = new ClientResponseImpl();
            response.initFromBuffer(message);
            ProcedureCallback cb = null;
            cb = m_callbacks.remove(response.getClientHandle());
            if (cb != null) {
                try {
                    cb.clientCallback(response);
                } catch (Throwable t) {
                    t.printStackTrace();
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

                new VoltTable.ColumnInfo("foobar", VoltType.STRING)
        );
        table.addRow("howmanylicksdoesittaketogettothecenterofatootsiepop");

        InitiateResponseMessage iresponse = new InitiateResponseMessage(itask);
        iresponse.setResults( new ClientResponseImpl(ClientResponse.GRACEFUL_FAILURE,
                new VoltTable[] { table, table }, "knockknockbananna"));
        iresponse.setClientHandle(99);

        InitiateResponseMessage iresponse2 = (InitiateResponseMessage) checkVoltMessage(iresponse);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.