Examples of ClientResponseImpl


Examples of org.voltdb.ClientResponseImpl

        }

        public void createWork(long now, long handle, String name, FastSerializable f, ProcedureCallback callback) {
            synchronized (this) {
                if (!m_isConnected) {
                    final ClientResponse r = new ClientResponseImpl(-1, -1, -1, Status.ABORT_CONNECTION_LOST,
                            new VoltTable[0], "Connection to database host (" + m_hostname +
                            ") was lost before a response was received");
                    callback.clientCallback(r);
                    return;
                }
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

            stats.update(roundTrip, clusterRoundTrip, abort, error, restartCounter);
        }

        @Override
        public void handleMessage(ByteBuffer buf, Connection c) {
            ClientResponseImpl response = null;
            FastDeserializer fds = new FastDeserializer(buf);
            try {
                response = fds.readObject(ClientResponseImpl.class);
            } catch (IOException e) {
                LOG.error("Invalid ClientResponse object returned by " + this, e);
                return;
            }
            if (response == null) {
                LOG.warn("Got back null ClientResponse. Ignoring...");
                return;
            }
           
            final Long clientHandle = new Long(response.getClientHandle());
            final Status status = response.getStatus();
            final long now = System.currentTimeMillis();
            CallbackValues stuff = null;
            synchronized (this) {
                stuff = m_callbacks.remove(clientHandle);
                if (stuff != null) {
                    m_invocationsCompleted++;
                    // this.lastSeenClientHandles.add(clientHandle);
                }
            } // SYNCH

            if (stuff != null) {
                long callTime = stuff.time;
                int delta = (int)(now - callTime);
                ProcedureCallback cb = stuff.callback;
                boolean abort = false;
                boolean error = false;
               
                if (debug.val) {
                    Map<String, Object> m0 = new LinkedHashMap<String, Object>();
                    m0.put("Txn #", response.getTransactionId());
                    m0.put("Status", response.getStatus());
                    m0.put("ClientHandle", clientHandle);
                    m0.put("RestartCounter", response.getRestartCounter());
                    m0.put("Callback", (cb != null ? cb.getClass().getSimpleName() : null));
                   
                    Map<String, Object> m1 = new LinkedHashMap<String, Object>();
                    m1.put("Connection", this);
                    m1.put("Completed Invocations", m_invocationsCompleted);
                    m1.put("Error Invocations", m_invocationErrors);
                    m1.put("Abort Invocations", m_invocationAborts);
                    LOG.debug("ClientResponse Information:\n" + StringUtil.formatMaps(m0, m1));
                }
               
                if (status == Status.ABORT_USER || status == Status.ABORT_GRACEFUL) {
                    m_invocationAborts++;
                    abort = true;
                } else if (status != Status.OK) {
                    m_invocationErrors++;
                    error = true;
                }
                int clusterRoundTrip = response.getClusterRoundtrip();
                if (m_nanoseconds) clusterRoundTrip /= 1000000;
                if (clusterRoundTrip < 0) clusterRoundTrip = 0;
               
                this.updateStats(stuff.name, delta, clusterRoundTrip, abort, error, response.getRestartCounter());
               
                if (cb != null) {
                    response.setClientRoundtrip(delta);
                    try {
                        cb.clientCallback(response);
                    } catch (Exception e) {
                        uncaughtException(cb, response, e);
                    }
                    m_callbacksToInvoke.decrementAndGet();
                } else if (m_isConnected) {
                    // TODO: what's the right error path here?
                    LOG.warn("No callback available for clientHandle " + clientHandle);
                }
            }
            else {
                LOG.warn(String.format("Failed to get callback for client handle #%d from %s",
                                       clientHandle, this, response.toString()
                ));
            }
        }
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

                }
                m_isConnected = false;

                //Invoke callbacks for all queued invocations with a failure response
                final ClientResponse r =
                    new ClientResponseImpl(-1, -1, -1, Status.ABORT_CONNECTION_LOST,
                        new VoltTable[0], "Connection to database host (" + m_hostname +
                        ") was lost before a response was received");
                for (final CallbackValues cbv : m_callbacks.values()) {
                    cbv.callback.clientCallback(r);
                }
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

                        BASE_PARTITION,
                        new PartitionSet(BASE_PARTITION),
                        catalog_procs[i % 2],
                        TARGET_PARAMS[i % 2]);
           
            ClientResponseImpl cresponse = new ClientResponseImpl(txnId[i],
                                                                  0l,
                                                                  BASE_PARTITION,
                                                                  Status.OK,
                                                                  HStoreConstants.EMPTY_RESULT,
                                                                  "");
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

    public static byte[] serializeResponse(VoltTable[] results, long clientHandle) {
        // Serialize the results
        Hstoreservice.Status status = Hstoreservice.Status.OK;
        String extra = null;
        ClientResponseImpl response = new ClientResponseImpl(-1, clientHandle, -1, status, results, extra);
        response.setClientHandle(clientHandle);
        FastSerializer out = new FastSerializer();
        try {
            out.writeObject(response);
        } catch (IOException e) {
            throw new RuntimeException(e);
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

                 */
                final long delta = Math.max(1, System.nanoTime() - nowNanos);
                final long timeout = timeoutNanos == Distributer.USE_DEFAULT_TIMEOUT ? m_distributer.getProcedureTimeoutNanos() : timeoutNanos;
                try {
                    if (backpressureBarrier(nowNanos, timeout - delta)) {
                        final 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).",
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

                        Thread.yield();
                    }
                }
                while (message.hasRemaining());
                message.flip();
                ClientResponseImpl response = new ClientResponseImpl();
                response.initFromBuffer(message);
                return response;
            }
        });
    }
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

                Object rpartitionParam = HashinatorLite.valueToBytes(toSend.fetchRow(0).get(
                        m_partitionedColumnIndex, m_partitionColumnType));
                m_clientImpl.callProcedure(callback, m_procName, rpartitionParam, m_tableName, toSend);
            }
        } catch (IOException e) {
            final ClientResponse r = new ClientResponseImpl(
                    ClientResponse.CONNECTION_LOST, new VoltTable[0],
                    "Connection to database was lost");
            callback.clientCallback(r);
        }
        toSend.clearRowData();
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

    }

    void generateError(Object rowHandle, Object[] objectList, String errMessage) {
        VoltTable[] dummyTable = new VoltTable[1];
        dummyTable[0] = new VoltTable(m_colInfo);
        ClientResponse dummyResponse = new ClientResponseImpl(ClientResponse.GRACEFUL_FAILURE,
                dummyTable, errMessage);
        m_notificationCallBack.failureCallback(rowHandle, objectList, dummyResponse);
        m_loaderCompletedCnt.incrementAndGet();
    }
View Full Code Here

Examples of org.voltdb.ClientResponseImpl

            //Check for disconnect
            if (!m_isConnected) {
                //Check if the disconnect or expiration already handled the callback
                if (m_callbacks.remove(handle) == null) return;
                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");
                try {
                    callback.clientCallback(r);
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.