Esempio n. 1
0
            private bool ShouldDefer()
            {
                /* If revocationTimeMs == 0, this is an immediate uncache request.
                 * No clients were anchored at the time we made the request. */
                if (this.revocationTimeMs == 0)
                {
                    return(false);
                }
                /* Let's check if any clients still have this block anchored. */
                bool anchored = !this._enclosing.dataset.datanode.GetShortCircuitRegistry().ProcessBlockMunlockRequest
                                    (this.key);

                if (!anchored)
                {
                    FsDatasetCache.Log.Debug("Uncaching {} now that it is no longer in use " + "by any clients."
                                             , this.key);
                    return(false);
                }
                long delta = this.revocationTimeMs - Org.Apache.Hadoop.Util.Time.MonotonicNow();

                if (delta < 0)
                {
                    FsDatasetCache.Log.Warn("Forcibly uncaching {} after {} " + "because client(s) {} refused to stop using it."
                                            , this.key, DurationFormatUtils.FormatDurationHMS(this.revocationTimeMs), this._enclosing
                                            .dataset.datanode.GetShortCircuitRegistry().GetClientNames(this.key));
                    return(false);
                }
                FsDatasetCache.Log.Info("Replica {} still can't be uncached because some " + "clients continue to use it.  Will wait for {}"
                                        , this.key, DurationFormatUtils.FormatDurationHMS(delta));
                return(true);
            }
Esempio n. 2
0
        internal virtual void UncacheBlock(string bpid, long blockId)
        {
            lock (this)
            {
                ExtendedBlockId      key       = new ExtendedBlockId(blockId, bpid);
                FsDatasetCache.Value prevValue = mappableBlockMap[key];
                bool deferred = false;
                if (!dataset.datanode.GetShortCircuitRegistry().ProcessBlockMunlockRequest(key))
                {
                    deferred = true;
                }
                if (prevValue == null)
                {
                    Log.Debug("Block with id {}, pool {} does not need to be uncached, " + "because it is not currently in the mappableBlockMap."
                              , blockId, bpid);
                    numBlocksFailedToUncache.IncrementAndGet();
                    return;
                }
                switch (prevValue.state)
                {
                case FsDatasetCache.State.Caching:
                {
                    Log.Debug("Cancelling caching for block with id {}, pool {}.", blockId, bpid);
                    mappableBlockMap[key] = new FsDatasetCache.Value(prevValue.mappableBlock, FsDatasetCache.State
                                                                     .CachingCancelled);
                    break;
                }

                case FsDatasetCache.State.Cached:
                {
                    mappableBlockMap[key] = new FsDatasetCache.Value(prevValue.mappableBlock, FsDatasetCache.State
                                                                     .Uncaching);
                    if (deferred)
                    {
                        Log.Debug("{} is anchored, and can't be uncached now.  Scheduling it " + "for uncaching in {} "
                                  , key, DurationFormatUtils.FormatDurationHMS(revocationPollingMs));
                        deferredUncachingExecutor.Schedule(new FsDatasetCache.UncachingTask(this, key, revocationMs
                                                                                            ), revocationPollingMs, TimeUnit.Milliseconds);
                    }
                    else
                    {
                        Log.Debug("{} has been scheduled for immediate uncaching.", key);
                        uncachingExecutor.Execute(new FsDatasetCache.UncachingTask(this, key, 0));
                    }
                    break;
                }

                default:
                {
                    Log.Debug("Block with id {}, pool {} does not need to be uncached, " + "because it is in state {}."
                              , blockId, bpid, prevValue.state);
                    numBlocksFailedToUncache.IncrementAndGet();
                    break;
                }
                }
            }
        }