예제 #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);
     }
 }
예제 #2
0
        private void AddMappingProvider(string providerName, Type providerClass)
        {
            Configuration newConf = PrepareConf(providerName);
            GroupMappingServiceProvider provider = (GroupMappingServiceProvider)ReflectionUtils
                                                   .NewInstance(providerClass, newConf);

            providersList.AddItem(provider);
        }
 public JniBasedUnixGroupsNetgroupMappingWithFallback()
 {
     if (NativeCodeLoader.IsNativeCodeLoaded())
     {
         this.impl = new JniBasedUnixGroupsNetgroupMapping();
     }
     else
     {
         Log.Info("Falling back to shell based");
         this.impl = new ShellBasedUnixGroupsNetgroupMapping();
     }
     if (Log.IsDebugEnabled())
     {
         Log.Debug("Group mapping impl=" + impl.GetType().FullName);
     }
 }