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

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


     * @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

            }
        } 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

        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

        }
      }
    }
   
      // 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

   * @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

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.