Examples of FutureResult


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

        }
        RequestID id = (RequestID) anID;
        FutureResult[] results;
        results = (FutureResult[]) responses.get(id.id);
        for (int i = 0; i < results.length; i++) {
            FutureResult result = results[i];
            if ( null == result.peek() ) {
                result.set(aResult);
                break;
            }
        }
    }
View Full Code Here

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

        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

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

         Fqn fqn = Fqn.fromString("/a/b/c/" + Integer.toString(i + 1));
         region.putNodeEvent(new EvictedEventNode(fqn, EvictedEventNode.ADD_NODE_EVENT));        
      }
     
      Executor executor = new ThreadedExecutor();
      FutureResult future = new FutureResult();

      Runnable command = future.setter(new ProcessEvictionRegion(region, algorithm));
      executor.execute(command);
     
      try
      {
         future.timedGet(20000);
      }
      catch(TimeoutException te)
      {
         log.error("Region eviction processing did not finish on time", te);
         fail("Region eviction processing should have finished by now, something is wrong. Recycle queue may have filled up.");
View Full Code Here

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

        if( appendSegmentOffset > rolloverFence && file.canActivateNextSegment() ) {
         
          // don't delay the next overflow notification.
          overflowNotificationTime -= OVERFLOW_RENOTIFICATION_DELAY;
           
          final FutureResult result = new FutureResult();
          try {
              executor.execute(new Runnable() {
                  public void run() {
                      try {
                          result.set( queuedActivateNextSegment() );                   
                      } catch (Throwable e) {
                          result.setException(e);
                      }
                  }           
            });
                appendSegmentIndex = ((Byte)result.get()).byteValue();
                appendSegmentOffset = Segment.SEGMENT_HEADER_SIZE;
               
            } catch (InterruptedException e) {
                throw (IOException)new IOException("Interrupted.").initCause(e);
            } catch (InvocationTargetException e) {
View Full Code Here

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

        }
      }
    }
   
      // Run this in the queued executor thread.
      final FutureResult result = new FutureResult();
      try {
          executor.execute(new Runnable() {
              public void run() {
                  try {
                      result.set( queuedGetNextRecordLocation(lastLocation) );                   
                  } catch (Throwable e) {
                      result.setException(e);
                  }
              }           
        });         
            return (RecordLocationImpl)result.get();
        } catch (InterruptedException e) {
            throw (IOException)new IOException("Interrupted.").initCause(e);
        } catch (InvocationTargetException e) {
            if( e.getTargetException() instanceof InvalidRecordLocationException)
                throw new InvalidRecordLocationException(e.getTargetException().getMessage(),e.getTargetException());
View Full Code Here

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

   * @throws InvalidRecordLocationException
   * @throws IOException
   */
  public byte[] read(final RecordLocationImpl location) throws IOException, InvalidRecordLocationException {     
      // Run this in the queued executor thread.
      final FutureResult result = new FutureResult();     
      try {
          executor.execute(new Runnable() {
              public void run() {
                  try {
                      result.set( queuedRead(location) );                   
                  } catch (Throwable e) {
                      result.setException(e);
                  }
              }
        });
            return (byte[])result.get();
        } catch (InterruptedException e) {
            throw (IOException)new IOException("Interrupted.").initCause(e);
        } catch (InvocationTargetException e) {
            if( e.getTargetException() instanceof InvalidRecordLocationException)
                throw new InvalidRecordLocationException(e.getTargetException().getMessage(),e.getTargetException());
View Full Code Here

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

                // don't delay the next overflow notification.
                overflowNotificationTime -= OVERFLOW_RENOTIFICATION_DELAY;
               
            } else {
               
                final FutureResult result = new FutureResult();
                try {
                    executor.execute(new Runnable() {
                        public void run() {
                            try {
                                result.set(queuedActivateNextLogFile());
                            } catch (Throwable e) {
                                result.setException(e);
                            }
                        }
                    });
                   
                    Location location = (Location) result.get();
                    appendLogFileId = location.getLogFileId();
                    appendLogFileOffset = location.getLogFileOffset();
   
                } catch (InterruptedException e) {
                    throw (IOException) new IOException("Interrupted.").initCause(e);
View Full Code Here

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

                return file.getFirstActiveLogLocation();
            }
        }

        // Run this in the queued executor thread.
        final FutureResult result = new FutureResult();
        try {
            executor.execute(new Runnable() {
                public void run() {
                    try {
                        result.set(queuedGetNextRecordLocation((Location) lastLocation));
                    } catch (Throwable e) {
                        result.setException(e);
                    }
                }
            });
            return (Location) result.get();
        } catch (InterruptedException e) {
            throw (IOException) new IOException("Interrupted.").initCause(e);
        } catch (InvocationTargetException e) {
            return (RecordLocation) unwrapException(e);
           
View Full Code Here

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

     * @throws IOException
     */
    public Packet read(final RecordLocation l) throws IOException, InvalidRecordLocationException {
        final Location location = (Location) l;
        // Run this in the queued executor thread.
        final FutureResult result = new FutureResult();
        try {
            executor.execute(new Runnable() {
                public void run() {
                    try {
                        result.set(file.readPacket(location));
                    } catch (Throwable e) {
                        result.setException(e);
                    }
                }
            });
            return (Packet) result.get();
        } catch (InterruptedException e) {
            throw (IOException) new IOException("Interrupted.").initCause(e);
        } catch (InvocationTargetException e) {
            if (e.getTargetException() instanceof InvalidRecordLocationException)
                throw new InvalidRecordLocationException(e.getTargetException().getMessage(), e.getTargetException());
View Full Code Here

Examples of org.apache.geronimo.remoting.transport.async.Correlator.FutureResult

    }

    public Msg sendRequest(URI to, Msg data) throws TransportException {
        AsyncMsg d = (AsyncMsg) data;
        PooledAsynchChannel c = getNextAvailable();
        FutureResult requestId = responseManager.getNextFutureResult();

        try {
            d.type = AsyncMsg.REQUEST_TYPE;
            d.to = to.toString();
            d.requestId = requestId.getID();

            if (log.isTraceEnabled())
                log.trace("sending request data for request: " + requestId.getID());
            c.send(d);

        } finally {
            safeClose(c);
        }

        try {
            Msg result = (AsyncMsg) requestId.poll(Registry.REQUEST_TIMEOUT);
            if (log.isTraceEnabled())
                log.trace("response data was corelated for request: " + requestId.getID());
            if (result == null)
                throw new TransportException("Request time out.");
            return result;
        } catch (InterruptedException e) {
            throw new TransportException(e.getMessage());
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.