Exemplo n.º 1
0
 public Groups(Configuration conf, Timer timer)
 {
     impl = ReflectionUtils.NewInstance(conf.GetClass <GroupMappingServiceProvider>(CommonConfigurationKeys
                                                                                    .HadoopSecurityGroupMapping, typeof(ShellBasedUnixGroupsMapping)), conf);
     cacheTimeout = conf.GetLong(CommonConfigurationKeys.HadoopSecurityGroupsCacheSecs
                                 , CommonConfigurationKeys.HadoopSecurityGroupsCacheSecsDefault) * 1000;
     negativeCacheTimeout = conf.GetLong(CommonConfigurationKeys.HadoopSecurityGroupsNegativeCacheSecs
                                         , CommonConfigurationKeys.HadoopSecurityGroupsNegativeCacheSecsDefault) * 1000;
     warningDeltaMs = conf.GetLong(CommonConfigurationKeys.HadoopSecurityGroupsCacheWarnAfterMs
                                   , CommonConfigurationKeys.HadoopSecurityGroupsCacheWarnAfterMsDefault);
     ParseStaticMapping(conf);
     this.timer = timer;
     this.cache = CacheBuilder.NewBuilder().RefreshAfterWrite(cacheTimeout, TimeUnit.Milliseconds
                                                              ).Ticker(new Groups.TimerToTickerAdapter(timer)).ExpireAfterWrite(10 * cacheTimeout
                                                                                                                                , TimeUnit.Milliseconds).Build(new Groups.GroupCacheLoader(this));
     if (negativeCacheTimeout > 0)
     {
         Com.Google.Common.Cache.Cache <string, bool> tempMap = CacheBuilder.NewBuilder().ExpireAfterWrite
                                                                    (negativeCacheTimeout, TimeUnit.Milliseconds).Ticker(new Groups.TimerToTickerAdapter
                                                                                                                             (timer)).Build();
         negativeCache = Collections.NewSetFromMap(tempMap.AsMap());
     }
     if (Log.IsDebugEnabled())
     {
         Log.Debug("Group mapping impl=" + impl.GetType().FullName + "; cacheTimeout=" + cacheTimeout
                   + "; warningDeltaMs=" + warningDeltaMs);
     }
 }
Exemplo n.º 2
0
 public KeyProviderCache(long expiryMs)
 {
     cache = CacheBuilder.NewBuilder().ExpireAfterAccess(expiryMs, TimeUnit.Milliseconds
                                                         ).RemovalListener(new _RemovalListener_47()).Build();
 }