Esempio n. 1
0
 public _CacheLoader_175(ValueQueue.QueueRefiller <E> refiller, float lowWatermark,
                         int numValues)
 {
     this.refiller     = refiller;
     this.lowWatermark = lowWatermark;
     this.numValues    = numValues;
 }
Esempio n. 2
0
 /// <summary>Constructor takes the following tunable configuration parameters</summary>
 /// <param name="numValues">
 /// The number of values cached in the Queue for a
 /// particular key.
 /// </param>
 /// <param name="lowWatermark">
 /// The ratio of (number of current entries/numValues)
 /// below which the <code>fillQueueForKey()</code> funciton will be
 /// invoked to fill the Queue.
 /// </param>
 /// <param name="expiry">
 /// Expiry time after which the Key and associated Queue are
 /// evicted from the cache.
 /// </param>
 /// <param name="numFillerThreads">Number of threads to use for the filler thread</param>
 /// <param name="policy">
 /// The SyncGenerationPolicy to use when client
 /// calls "getAtMost"
 /// </param>
 /// <param name="refiller">implementation of the QueueRefiller</param>
 public ValueQueue(int numValues, float lowWatermark, long expiry, int numFillerThreads
                   , ValueQueue.SyncGenerationPolicy policy, ValueQueue.QueueRefiller <E> refiller)
 {
     // Return atleast 1 value
     // Return min(n, lowWatermark * numValues) values
     // Return n values
     Preconditions.CheckArgument(numValues > 0, "\"numValues\" must be > 0");
     Preconditions.CheckArgument(((lowWatermark > 0) && (lowWatermark <= 1)), "\"lowWatermark\" must be > 0 and <= 1"
                                 );
     Preconditions.CheckArgument(expiry > 0, "\"expiry\" must be > 0");
     Preconditions.CheckArgument(numFillerThreads > 0, "\"numFillerThreads\" must be > 0"
                                 );
     Preconditions.CheckNotNull(policy, "\"policy\" must not be null");
     this.refiller     = refiller;
     this.policy       = policy;
     this.numValues    = numValues;
     this.lowWatermark = lowWatermark;
     keyQueues         = CacheBuilder.NewBuilder().ExpireAfterAccess(expiry, TimeUnit.Milliseconds
                                                                     ).Build(new _CacheLoader_175(refiller, lowWatermark, numValues));
     executor = new ThreadPoolExecutor(numFillerThreads, numFillerThreads, 0L, TimeUnit
                                       .Milliseconds, queue, new ThreadFactoryBuilder().SetDaemon(true).SetNameFormat(RefillThread
                                                                                                                      ).Build());
 }
Esempio n. 3
0
 public ValueQueue(int numValues, float lowWaterMark, long expiry, int numFillerThreads
                   , ValueQueue.QueueRefiller <E> fetcher)
     : this(numValues, lowWaterMark, expiry, numFillerThreads, ValueQueue.SyncGenerationPolicy
            .All, fetcher)
 {
 }