Package java.util.concurrent

Examples of java.util.concurrent.Future


            if (postJoinOperations != null && postJoinOperations.length > 0) {
                final Collection<MemberImpl> members = clusterService.getMemberList();
                calls = new ArrayList<Future>(members.size());
                for (MemberImpl member : members) {
                    if (!member.localMember()) {
                        Future f = nodeEngine.getOperationService().createInvocationBuilder(ClusterServiceImpl.SERVICE_NAME,
                                new PostJoinOperation(postJoinOperations), member.getAddress())
                                .setTryCount(10).setTryPauseMillis(100).invoke();
                        calls.add(f);
                    }
                }
            }

            if (postJoinOp != null) {
                postJoinOp.setNodeEngine(nodeEngine);
                OperationAccessor.setCallerAddress(postJoinOp, getCallerAddress());
                OperationAccessor.setConnection(postJoinOp, getConnection());
                postJoinOp.setResponseHandler(ResponseHandlerFactory.createEmptyResponseHandler());
                nodeEngine.getOperationService().runOperation(postJoinOp);
            }

            if (calls != null) {
                for (Future f : calls) {
                    try {
                        f.get(1, TimeUnit.SECONDS);
                    } catch (InterruptedException ignored) {
                    } catch (TimeoutException ignored) {
                    } catch (ExecutionException e) {
                        final ILogger logger = nodeEngine.getLogger(FinalizeJoinOperation.class);
                        if (logger.isFinestEnabled()) {
View Full Code Here


    public boolean cancel(boolean mayInterruptIfRunning) {
        if (isDone() || cancelled) {
            return false;
        }

        Future f = invokeCancelOperation(mayInterruptIfRunning);
        try {
            Boolean b = (Boolean) f.get();
            if (b != null && b) {
                setError(new CancellationException());
                cancelled = true;
                return true;
            }
View Full Code Here

            ((BaseTransactionRequest) request).setClientThreadId(threadId);
        }
        final SerializationService ss = client.getSerializationService();
        final ClientInvocationServiceImpl invocationService = (ClientInvocationServiceImpl)client.getInvocationService();
        try {
            final Future f = invocationService.send(request, connection);
            return ss.toObject(f.get()) ;
        } catch (Exception e) {
            throw ExceptionUtil.rethrow(e);
        }
    }
View Full Code Here

    protected void onShutdown() {
    }

    protected <T> T invoke(ClientRequest req, Object key) {
        try {
            final Future future = getInvocationService().invokeOnKeyOwner(req, key);
            Object result = future.get();
            return toObject(result);
        } catch (Exception e) {
            throw ExceptionUtil.rethrow(e);
        }
    }
View Full Code Here

                            claimingMaster = true;
                            Collection<Future<Boolean>> responses = new LinkedList<Future<Boolean>>();
                            for (Address address : colPossibleAddresses) {
                                if (node.getConnectionManager().getConnection(address) != null) {
                                    logger.finest( "Claiming myself as master node!");
                                    Future future = node.nodeEngine.getOperationService().createInvocationBuilder(
                                            ClusterServiceImpl.SERVICE_NAME, new MasterClaim(), address)
                                            .setTryCount(1).invoke();
                                    responses.add(future);
                                }
                            }
View Full Code Here

        }
    }

    protected <T> T invokeInterruptibly(ClientRequest req, Object key)throws InterruptedException {
        try {
            final Future future = getInvocationService().invokeOnKeyOwner(req, key);
            Object result = future.get();
            return toObject(result);
        } catch (Exception e) {
            throw ExceptionUtil.rethrowAllowInterrupted(e);
        }
    }
View Full Code Here

        return getContext().getInvocationService();
    }

    protected <T> T invoke(ClientRequest req) {
        try {
            final Future future = getInvocationService().invokeOnRandomTarget(req);
            Object result = future.get();
            return toObject(result);
        } catch (Exception e) {
            throw ExceptionUtil.rethrow(e);
        }
    }
View Full Code Here

        }
    }

    protected <T> T invoke(ClientRequest req, Address address) {
        try {
            final Future future = getInvocationService().invokeOnTarget(req, address);
            Object result = future.get();
            return toObject(result);
        } catch (Exception e) {
            throw ExceptionUtil.rethrow(e);
        }
    }
View Full Code Here

        for (MemberImpl member : members) {
            if (member.localMember()) {
                getService().shutdownExecutor(name);
            } else {
                Future f = submitShutdownOperation(operationService, member);
                calls.add(f);
            }
        }
        for (Future f : calls) {
            try {
                f.get(1, TimeUnit.SECONDS);
            } catch (Exception exception) {
                if (logger.isFinestEnabled()) {
                    logger.finest(exception);
                }
            }
View Full Code Here

    private boolean doAwait(long time, TimeUnit unit, long threadId) throws InterruptedException {
        try {
            long timeout = unit.toMillis(time);
            Data key = lockProxy.getKeyData();
            AwaitOperation op = new AwaitOperation(namespace, key, threadId, timeout, conditionId);
            Future f = invoke(op);
            return Boolean.TRUE.equals(f.get());
        } catch (Throwable t) {
            throw rethrowAllowInterrupted(t);
        }
    }
View Full Code Here

TOP

Related Classes of java.util.concurrent.Future

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.