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

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


        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

         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

        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

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

                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

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

/*      */   public synchronized long next()
/*      */   {
/* 2153 */     long res = 0L;
/*      */     try {
/* 2155 */       if (this.nextResult_ == null) {
/* 2156 */         this.nextResult_ = new FutureResult();
/* 2157 */         this.nextResult_.set(new Long(getDelegate().next()));
/*      */       }
/* 2159 */       FutureResult currentResult = this.nextResult_;
/*      */
/* 2161 */       this.nextResult_ = new FutureResult();
/* 2162 */       Runnable r = this.nextResult_.setter(delegatedNextFunction());
/* 2163 */       getExecutor().execute(r);
/*      */
/* 2165 */       res = ((Long)currentResult.get()).longValue();
/*      */     }
/*      */     catch (InterruptedException ex)
/*      */     {
/* 2169 */       Thread.currentThread().interrupt();
/*      */     }
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.