Пример #1
0
        /**
         * Mark a specified resource as absent. If the resource is already marked as absent, its max-tries value is
         * incremented.
         *
         * @param resourceID the resource to mark as absent.
         */
        synchronized public final void markResourceAbsent(String resourceID)
        {
            AbsentResourceEntry entry = (AbsentResourceEntry)this.possiblyAbsent.get(resourceID);

            if (entry == null)
            {
                this.possiblyAbsent.put(resourceID, entry = new AbsentResourceEntry());
            }

            ++entry.numTries;
            entry.timeOfLastMark = System.currentTimeMillis();
        }
Пример #2
0
        /**
         * Indicates whether a resource is considered absent.
         *
         * @param resourceID the resource in question.
         *
         * @return true if the resource is considered absent, otherwise false.
         */
        synchronized public final bool isResourceAbsent(String resourceID)
        {
            AbsentResourceEntry entry = (AbsentResourceEntry)this.possiblyAbsent.get(resourceID);

            if (entry == null)
            {
                return(false);
            }

            long timeSinceLastMark = System.currentTimeMillis() - entry.timeOfLastMark;

            if (timeSinceLastMark > this.tryAgainInterval)
            {
                this.possiblyAbsent.remove(resourceID);
                return(false);
            }

            return(timeSinceLastMark < this.minCheckInterval || entry.numTries > this.maxTries);
        }