Package EDU.oswego.cs.dl.util.concurrent

Examples of EDU.oswego.cs.dl.util.concurrent.FutureResult


    }

    public Message request(Destination destination, Message message, long timeout) throws JMSException {
        // lets create a correlationID
        String correlationID = createCorrelationID();
        FutureResult future = new FutureResultHandler();
        synchronized (this) {
            requests.put(correlationID, future);
        }
        message.setJMSCorrelationID(correlationID);
        oneWay(destination, message);

        try {
            if (timeout < 0) {
                return (Message) future.get();
            }
            else if (timeout == 0) {
                return (Message) future.peek();
            }
            else {
                return (Message) future.timedGet(timeout);
            }
        }
        catch (Exception e) {
            throw createJMSException(e);
        }
View Full Code Here


            }
        } else {
            FutureResult[] futures = new FutureResult[commands.length];
            for (int i = 0; i < commands.length; i++) {
                final Command c = commands[i];
                futures[i] = new FutureResult();
                Runnable r = futures[i].setter(new Callable() {
                    public Object call() throws Exception {
                        return c.call();
                    }
                });
View Full Code Here

    {
        int timeout = irca.getGetTimeoutMillis();

        try
        {
            FutureResult future = new FutureResult();
            Runnable command = future.setter( new Callable()
            {
                public Object call()
                    throws IOException
                {
                    return remote.get( cacheName, key, getListenerId() );
                }
            } );

            // execute using the pool
            pool.execute( command );

            // used timed get in order to timeout
            ICacheElement ice = (ICacheElement) future.timedGet( timeout );
            if ( log.isDebugEnabled() )
            {
                if ( ice == null )
                {
                    log.debug( "nothing found in remote cache" );
View Full Code Here

            }
        } else {
            FutureResult[] futures = new FutureResult[commands.length];
            for (int i = 0; i < commands.length; i++) {
                final Command c = commands[i];
                futures[i] = new FutureResult();
                Runnable r = futures[i].setter(new Callable() {
                    public Object call() throws Exception {
                        return c.call();
                    }
                });
View Full Code Here

            }
        } else {
            FutureResult[] futures = new FutureResult[commands.length];
            for (int i = 0; i < commands.length; i++) {
                final Command c = commands[i];
                futures[i] = new FutureResult();
                Runnable r = futures[i].setter(new Callable() {
                    public Object call() throws Exception {
                        return c.call();
                    }
                });
View Full Code Here

      {
         FutureResult[] futures = new FutureResult[commands.length];
         for (int i = 0; i < commands.length; i++)
         {
            final Command c = commands[i];
            futures[i] = new FutureResult();
            Runnable r = futures[i].setter(new Callable()
            {
               public Object call() throws Exception
               {
                  return c.call();
View Full Code Here

        header.addHeader(MsgHeaderConstants.BODY_TYPE, MsgBody.Type.REQUEST);
        header.addHeader(MsgHeaderConstants.TOPOLOGY_VERSION, new Integer(0));
       
        msg.getBody().setContent(localNodeInfo);

        final FutureResult result = new FutureResult();
        setMsgProducerOut(new MsgOutInterceptor() {
            public void push(Msg aMsg) {
                result.set(aMsg);
            }
        });
        getMsgConsumerOut().push(msg);
        Msg reply;
        try {
            // waits 3 seconds for a reply.
            reply = (Msg) result.get();
            reply = (Msg) result.timedGet(3000);
        } catch (TimeoutException e) {
            throw new NodeException("Join request submitted by " +
                localNodeInfo + " to " + remoteNodeInfo + " has timed out.");
        } catch (InterruptedException e) {
            throw new NodeException(e);
View Full Code Here

     * @return Request identifier and FutureResults.
     */
    private IDTOFutureResult createID(NodeInfo[] aTargetNodes) {
        FutureResult[] results = new FutureResult[aTargetNodes.length];
        for (int i = 0; i < results.length; i++) {
            results[i] = new FutureResult();
        }
        int idAsInt;
        synchronized (seqMemBarrier) {
            // Implementation note: it is unlikely to have more than
            // MAX_CONCURRENT_REQUEST Threads sending requests concurrently;
View Full Code Here

            log.error("Invalid request ID {" + anID + "}");
            return;
        }
        synchronized (results) {
            for (int i = 0; i < results.length; i++) {
                FutureResult result = results[i];
                if ( null == result.peek() ) {
                    result.set(aResult);
                    break;
                }
            }
        }
    }
View Full Code Here

        RequestID id;
        int mapID = responses.allocateId();
        id = new RequestID(mapID);
        FutureResult[] results = new FutureResult[aTargetNodes.length];
        for (int i = 0; i < results.length; i++) {
            results[i] = new FutureResult();
        }
        responses.put(mapID, results);
        return id;
    }
View Full Code Here

TOP

Related Classes of EDU.oswego.cs.dl.util.concurrent.FutureResult

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.