Package voldemort.store.socket.clientrequest

Examples of voldemort.store.socket.clientrequest.ClientRequestExecutor


        long startTimeNs = -1;

        if(logger.isDebugEnabled()) {
            startTimeMs = System.currentTimeMillis();
        }
        ClientRequestExecutor clientRequestExecutor = pool.checkout(destination);
        String debugMsgStr = "";

        startTimeNs = System.nanoTime();

        BlockingClientRequest<T> blockingClientRequest = null;
        try {
            blockingClientRequest = new BlockingClientRequest<T>(delegate, timeoutMs);
            clientRequestExecutor.addClientRequest(blockingClientRequest,
                                                   timeoutMs,
                                                   System.nanoTime() - startTimeNs);

            boolean awaitResult = blockingClientRequest.await();

            if(awaitResult == false) {
                blockingClientRequest.timeOut();
            }

            if(logger.isDebugEnabled())
                debugMsgStr += "success";

            return blockingClientRequest.getResult();
        } catch(InterruptedException e) {

            if(logger.isDebugEnabled())
                debugMsgStr += "unreachable: " + e.getMessage();

            throw new UnreachableStoreException("Failure in " + operationName + " on "
                                                + destination + ": " + e.getMessage(), e);
        } catch(IOException e) {
            clientRequestExecutor.close();

            if(logger.isDebugEnabled())
                debugMsgStr += "failure: " + e.getMessage();

            throw new UnreachableStoreException("Failure in " + operationName + " on "
                                                + destination + ": " + e.getMessage(), e);
        } finally {
            if(blockingClientRequest != null && !blockingClientRequest.isComplete()) {
                // close the executor if we timed out
                clientRequestExecutor.close();
            }
            // Record operation time
            long opTimeNs = Utils.elapsedTimeNs(startTimeNs, System.nanoTime());
            if (stats != null) {
                stats.recordSyncOpTimeNs(destination, opTimeNs);
            }
            if(logger.isDebugEnabled()) {
                logger.debug("Sync request end, type: "
                             + operationName
                             + " requestRef: "
                             + System.identityHashCode(delegate)
                             + " totalTimeNs: "
                             + opTimeNs
                             + " start time: "
                             + startTimeMs
                             + " end time: "
                             + System.currentTimeMillis()
                             + " client:"
                             + clientRequestExecutor.getSocketChannel().socket().getLocalAddress()
                             + ":"
                             + clientRequestExecutor.getSocketChannel().socket().getLocalPort()
                             + " server: "
                             + clientRequestExecutor.getSocketChannel()
                                                    .socket()
                                                    .getRemoteSocketAddress() + " outcome: "
                             + debugMsgStr);
            }
View Full Code Here


        this.server.stop();
    }

    @Test
    public void testTwoCheckoutsGetTheSameSocket() throws Exception {
        ClientRequestExecutor sas1 = pool.checkout(dest1);
        pool.checkin(dest1, sas1);
        ClientRequestExecutor sas2 = pool.checkout(dest1);
        assertTrue(sas1 == sas2);
    }
View Full Code Here

        assertTrue(sas1 == sas2);
    }

    @Test
    public void testClosingDeactivates() throws Exception {
        ClientRequestExecutor sas1 = pool.checkout(dest1);
        sas1.close();
        pool.checkin(dest1, sas1);
        ClientRequestExecutor sas2 = pool.checkout(dest1);
        assertTrue(sas1 != sas2);
    }
View Full Code Here

                     pool.getStats().getCount(ClientSocketStats.Tracked.CONNECTION_CREATED_EVENT));
    }

    @Test
    public void testSocketClosedWhenCheckedInAfterPoolKeyClosed() throws Exception {
        ClientRequestExecutor sas1 = pool.checkout(dest1);
        ClientRequestExecutor sas2 = pool.checkout(dest1);
        assertTrue(sas1 != sas2);
        pool.checkin(dest1, sas1);
        pool.close(dest1);
        pool.checkin(dest1, sas2);
        pool.close(dest1);
View Full Code Here

TOP

Related Classes of voldemort.store.socket.clientrequest.ClientRequestExecutor

Copyright © 2018 www.massapicom. 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.