public virtual void OnSuccess(LocatedFileStatusFetcher.ProcessInitialInputPathCallable.Result
                               result)
 {
     try
     {
         if (result.errors != null)
         {
             this._enclosing.RegisterInvalidInputError(result.errors);
         }
         if (result.matchedFileStatuses != null)
         {
             foreach (FileStatus matched in result.matchedFileStatuses)
             {
                 this._enclosing.runningTasks.IncrementAndGet();
                 ListenableFuture <LocatedFileStatusFetcher.ProcessInputDirCallable.Result> future =
                     this._enclosing.exec.Submit(new LocatedFileStatusFetcher.ProcessInputDirCallable
                                                     (result.fs, matched, this._enclosing.recursive, this._enclosing.inputFilter));
                 Futures.AddCallback(future, this._enclosing.processInputDirCallback);
             }
         }
         this._enclosing.DecrementRunningAndCheckCompletion();
     }
     catch (Exception t)
     {
         // Exception within the callback
         this._enclosing.RegisterError(t);
     }
 }
 public virtual void OnSuccess(LocatedFileStatusFetcher.ProcessInputDirCallable.Result
                               result)
 {
     try
     {
         if (result.locatedFileStatuses.Count != 0)
         {
             this._enclosing.resultQueue.AddItem(result.locatedFileStatuses);
         }
         if (result.dirsNeedingRecursiveCalls.Count != 0)
         {
             foreach (FileStatus fileStatus in result.dirsNeedingRecursiveCalls)
             {
                 this._enclosing.runningTasks.IncrementAndGet();
                 ListenableFuture <LocatedFileStatusFetcher.ProcessInputDirCallable.Result> future =
                     this._enclosing.exec.Submit(new LocatedFileStatusFetcher.ProcessInputDirCallable
                                                     (result.fs, fileStatus, this._enclosing.recursive, this._enclosing.inputFilter));
                 Futures.AddCallback(future, this._enclosing.processInputDirCallback);
             }
         }
         this._enclosing.DecrementRunningAndCheckCompletion();
     }
     catch (Exception t)
     {
         // Error within the callback itself.
         this._enclosing.RegisterError(t);
     }
 }
Example #3
0
 internal static Org.Apache.Hadoop.Hdfs.Qjournal.Client.QuorumCall <KEY, RESULT> Create
 <Key, Result>(IDictionary <KEY, ListenableFuture <RESULT> > calls)
 {
     Org.Apache.Hadoop.Hdfs.Qjournal.Client.QuorumCall <KEY, RESULT> qr = new Org.Apache.Hadoop.Hdfs.Qjournal.Client.QuorumCall
                                                                          <KEY, RESULT>();
     foreach (KeyValuePair <KEY, ListenableFuture <RESULT> > e in calls)
     {
         Preconditions.CheckArgument(e.Value != null, "null future for key: " + e.Key);
         Futures.AddCallback(e.Value, new _FutureCallback_68(qr, e));
     }
     return(qr);
 }
Example #4
0
        public override ListenableFuture <Void> SendEdits(long segmentTxId, long firstTxnId
                                                          , int numTxns, byte[] data)
        {
            try
            {
                ReserveQueueSpace(data.Length);
            }
            catch (LoggerTooFarBehindException e)
            {
                return(Futures.ImmediateFailedFuture(e));
            }
            // When this batch is acked, we use its submission time in order
            // to calculate how far we are lagging.
            long submitNanos            = Runtime.NanoTime();
            ListenableFuture <Void> ret = null;

            try
            {
                ret = singleThreadExecutor.Submit(new _Callable_378(this, segmentTxId, firstTxnId
                                                                    , numTxns, data, submitNanos));
            }
            finally
            {
                if (ret == null)
                {
                    // it didn't successfully get submitted,
                    // so adjust the queue size back down.
                    UnreserveQueueSpace(data.Length);
                }
                else
                {
                    // It was submitted to the queue, so adjust the length
                    // once the call completes, regardless of whether it
                    // succeeds or fails.
                    Futures.AddCallback(ret, new _FutureCallback_428(this, data));
                }
            }
            return(ret);
        }
 /// <summary>Start executing and return FileStatuses based on the parameters specified
 ///     </summary>
 /// <returns>fetched file statuses</returns>
 /// <exception cref="System.Exception"/>
 /// <exception cref="System.IO.IOException"/>
 public virtual IEnumerable <FileStatus> GetFileStatuses()
 {
     // Increment to make sure a race between the first thread completing and the
     // rest being scheduled does not lead to a termination.
     runningTasks.IncrementAndGet();
     foreach (Path p in inputDirs)
     {
         runningTasks.IncrementAndGet();
         ListenableFuture <LocatedFileStatusFetcher.ProcessInitialInputPathCallable.Result>
         future = exec.Submit(new LocatedFileStatusFetcher.ProcessInitialInputPathCallable
                                  (p, conf, inputFilter));
         Futures.AddCallback(future, processInitialInputPathCallback);
     }
     runningTasks.DecrementAndGet();
     Lock.Lock();
     try
     {
         while (runningTasks.Get() != 0 && unknownError == null)
         {
             condition.Await();
         }
     }
     finally
     {
         Lock.Unlock();
     }
     this.exec.ShutdownNow();
     if (this.unknownError != null)
     {
         if (this.unknownError is Error)
         {
             throw (Error)this.unknownError;
         }
         else
         {
             if (this.unknownError is RuntimeException)
             {
                 throw (RuntimeException)this.unknownError;
             }
             else
             {
                 if (this.unknownError is IOException)
                 {
                     throw (IOException)this.unknownError;
                 }
                 else
                 {
                     if (this.unknownError is Exception)
                     {
                         throw (Exception)this.unknownError;
                     }
                     else
                     {
                         throw new IOException(this.unknownError);
                     }
                 }
             }
         }
     }
     if (this.invalidInputErrors.Count != 0)
     {
         if (this.newApi)
         {
             throw new InvalidInputException(invalidInputErrors);
         }
         else
         {
             throw new InvalidInputException(invalidInputErrors);
         }
     }
     return(Iterables.Concat(resultQueue));
 }