/// <summary>Constructor</summary> /// <param name="cacheName">name to identify the cache by</param> /// <param name="percentage">percentage of total java heap space used by this cache</param> /// <param name="expirationTime">time for an entry to expire in nanoseconds</param> public RetryCache(string cacheName, double percentage, long expirationTime) { int capacity = LightWeightGSet.ComputeCapacity(percentage, cacheName); capacity = capacity > 16 ? capacity : 16; this.set = new LightWeightCache <RetryCache.CacheEntry, RetryCache.CacheEntry>(capacity , capacity, expirationTime, 0); this.expirationTime = expirationTime; this.cacheName = cacheName; this.retryCacheMetrics = RetryCacheMetrics.Create(this); }
public virtual void Setup() { conf = new HdfsConfiguration(); conf.SetBoolean(DFSConfigKeys.DfsNamenodeEnableRetryCacheKey, true); conf.SetInt(DFSConfigKeys.DfsClientTestDropNamenodeResponseNumKey, 2); cluster = new MiniDFSCluster.Builder(conf).NnTopology(MiniDFSNNTopology.SimpleHATopology ()).NumDataNodes(3).Build(); cluster.WaitActive(); cluster.TransitionToActive(namenodeId); HATestUtil.SetFailoverConfigurations(cluster, conf); filesystem = (DistributedFileSystem)HATestUtil.ConfigureFailoverFs(cluster, conf); namesystem = cluster.GetNamesystem(namenodeId); metrics = namesystem.GetRetryCache().GetMetricsForTests(); }
public virtual void TestNames() { RetryCache cache = Org.Mockito.Mockito.Mock <RetryCache>(); Org.Mockito.Mockito.When(cache.GetCacheName()).ThenReturn(cacheName); RetryCacheMetrics metrics = RetryCacheMetrics.Create(cache); metrics.IncrCacheHit(); metrics.IncrCacheCleared(); metrics.IncrCacheCleared(); metrics.IncrCacheUpdated(); metrics.IncrCacheUpdated(); metrics.IncrCacheUpdated(); CheckMetrics(1, 2, 3); }