Package org.elasticsearch.common.util.concurrent

Examples of org.elasticsearch.common.util.concurrent.AbstractRunnable


        try {
            receivedResponses.put(id, new PingCollection());
            sendPingRequest(id);
            // try and send another ping request halfway through (just in case someone woke up during it...)
            // this can be a good trade-off to nailing the initial lookup or un-delivered messages
            threadPool.schedule(TimeValue.timeValueMillis(timeout.millis() / 2), ThreadPool.Names.GENERIC, new AbstractRunnable() {
                @Override
                public void onFailure(Throwable t) {
                    logger.warn("[{}] failed to send second ping request", t, id);
                    finalizePingCycle(id, listener);
                }

                @Override
                public void doRun() {
                    sendPingRequest(id);
                    threadPool.schedule(TimeValue.timeValueMillis(timeout.millis() / 2), ThreadPool.Names.GENERIC, new AbstractRunnable() {
                        @Override
                        public void onFailure(Throwable t) {
                            logger.warn("[{}] failed to send third ping request", t, id);
                            finalizePingCycle(id, listener);
                        }

                        @Override
                        public void doRun() {
                            // make one last ping, but finalize as soon as all nodes have responded or a timeout has past
                            PingCollection collection = receivedResponses.get(id);
                            FinalizingPingCollection finalizingPingCollection = new FinalizingPingCollection(id, collection, collection.size(), listener);
                            receivedResponses.put(id, finalizingPingCollection);
                            logger.trace("[{}] sending last pings", id);
                            sendPingRequest(id);
                            threadPool.schedule(TimeValue.timeValueMillis(timeout.millis() / 4), ThreadPool.Names.GENERIC, new AbstractRunnable() {
                                @Override
                                public void onFailure(Throwable t) {
                                    logger.warn("[{}] failed to finalize ping", t, id);
                                }
View Full Code Here


            return internalCollection.toArray();
        }

        void finish() {
            // spawn another thread as we may be running on a network thread
            threadPool.generic().execute(new AbstractRunnable() {
                @Override
                public void onFailure(Throwable t) {
                    logger.error("failed to call ping listener", t);
                }
View Full Code Here

        // wait for the merges outside of the read lock
        if (optimize.waitForMerge()) {
            waitForMerges(optimize.flush());
        } else if (optimize.flush()) {
            // we only need to monitor merges for async calls if we are going to flush
            threadPool.executor(ThreadPool.Names.OPTIMIZE).execute(new AbstractRunnable() {
                @Override
                public void onFailure(Throwable t) {
                    logger.error("Exception while waiting for merges asynchronously after optimize", t);
                }
                @Override
View Full Code Here

            request.readFrom(stream);
            if (handler.executor() == ThreadPool.Names.SAME) {
                //noinspection unchecked
                handler.messageReceived(request, transportChannel);
            } else {
                threadPool.executor(handler.executor()).execute(new AbstractRunnable() {
                    @Override
                    protected void doRun() throws Exception {
                        //noinspection unchecked
                        handler.messageReceived(request, transportChannel);
                    }
View Full Code Here

                });
            } else {
                if (internalRequest.request().operationThreaded()) {
                    internalRequest.request().beforeLocalFork();
                    try {
                        threadPool.executor(executor).execute(new AbstractRunnable() {
                            @Override
                            protected void doRun() {
                                try {
                                    shardOperationOnReplica(shardRequest);
                                } catch (Throwable e) {
View Full Code Here

            } catch (RejectedExecutionException e) {
                logger.debug("Ping execution rejected", e);
                // The RejectedExecutionException can come from the fact unicastConnectExecutor is at its max down in sendPings
                // But don't bail here, we can retry later on after the send ping has been scheduled.
            }
            threadPool.schedule(TimeValue.timeValueMillis(timeout.millis() / 2), ThreadPool.Names.GENERIC, new AbstractRunnable() {
                @Override
                protected void doRun() {
                    sendPings(timeout, null, sendPingsHandler);
                    threadPool.schedule(TimeValue.timeValueMillis(timeout.millis() / 2), ThreadPool.Names.GENERIC, new AbstractRunnable() {
                        @Override
                        protected void doRun() throws Exception {
                            sendPings(timeout, TimeValue.timeValueMillis(timeout.millis() / 2), sendPingsHandler);
                            sendPingsHandler.close();
                            for (DiscoveryNode node : sendPingsHandler.nodeToDisconnect) {
View Full Code Here

TOP

Related Classes of org.elasticsearch.common.util.concurrent.AbstractRunnable

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.