/// <summary>
 /// Create a client for a distributed binomial ladder filter
 /// </summary>
 /// <param name="numberOfShards">The number of shards that the bit array of the binomial ladder filter will be divided into.
 /// The greater the number of shards, the more evently it can be distributed.  However, the number of shards should still
 /// be a few orders of magnitude smaller than the ladder height.</param>
 /// <param name="defaultHeightOfLadder">The default ladder height for elements on the ladder.</param>
 /// <param name="shardToHostMapping">An object that maps each shard number to the host responsible for that shard.</param>
 /// <param name="configurationKey">A key used to protect the hashing from algorithmic complexity attacks.
 /// This key should not be unique to the application using the filter and should not be known to any untrusted
 /// systems that might control which elements get sent to the filter.  If an attacker could submit elements to the filter
 /// and knew this key, the attacker could arrange for all elements to go to the same shard and in so doing overload that shard.</param>
 /// <param name="mininmumCacheFreshnessRequired">The maximum time that an element should be kept in the cache of elements at the top of their ladder.
 /// In other words, how long to bound the possible time that an element may still appear to be at the top of its ladder in the cache
 /// when it is no longer at the top of the ladder based on the filter array.  Defaults to one minute.</param>
 public DistributedBinomialLadderFilterClient(int numberOfShards, int defaultHeightOfLadder, IDistributedResponsibilitySet<RemoteHost> shardToHostMapping, string configurationKey, TimeSpan? mininmumCacheFreshnessRequired = null)
 {
     NumberOfShards = numberOfShards;
     MaxLadderHeight = defaultHeightOfLadder;
     MinimumCacheFreshnessRequired = mininmumCacheFreshnessRequired ?? new TimeSpan(0,0,1);
     CacheOfElementsAtTopOfLadder = new FixedSizeLruCache<string, DateTime>(2*NumberOfShards);
     ShardHashFunction = new UniversalHashFunction(configurationKey);
     ShardToHostMapping = shardToHostMapping;
 }
Ejemplo n.º 2
0
 public DistributedBinomialLadderFilterClient(int numberOfShards, int defaultHeightOfLadder, IDistributedResponsibilitySet <RemoteHost> shardToHostMapping, string configurationKey, TimeSpan?mininmumCacheFreshnessRequired = null)
 {
     NumberOfShards  = numberOfShards;
     MaxLadderHeight = defaultHeightOfLadder;
     MinimumCacheFreshnessRequired = mininmumCacheFreshnessRequired ?? new TimeSpan(0, 0, 1);
     CacheOfElementsAtTopOfLadder  = new FixedSizeLruCache <string, DateTime>(2 * NumberOfShards);
     ShardHashFunction             = new UniversalHashFunction(configurationKey);
     ShardToHostMapping            = shardToHostMapping;
 }
Ejemplo n.º 3
0
        public Simulator(ExperimentalConfiguration myExperimentalConfiguration, BlockingAlgorithmOptions options = default(BlockingAlgorithmOptions))
        {
            MyExperimentalConfiguration = myExperimentalConfiguration;
            if (options == null)
                options = new BlockingAlgorithmOptions();
            CreditLimits = new[]
            {
                // 3 per hour
                new LimitPerTimePeriod(new TimeSpan(1, 0, 0), 3f),
                // 6 per day (24 hours, not calendar day)
                new LimitPerTimePeriod(new TimeSpan(1, 0, 0, 0), 6f),
                // 10 per week
                new LimitPerTimePeriod(new TimeSpan(6, 0, 0, 0), 10f),
                // 15 per month
                new LimitPerTimePeriod(new TimeSpan(30, 0, 0, 0), 15f)
            };
            //We are testing with local server now
            MyResponsibleHosts = new MaxWeightHashing<RemoteHost>("FIXME-uniquekeyfromconfig");
            //configuration.MyResponsibleHosts.Add("localhost", new RemoteHost { Uri = new Uri("http://localhost:80"), IsLocalHost = true });
            RemoteHost localHost = new RemoteHost { Uri = new Uri("http://localhost:80") };
            MyResponsibleHosts.Add("localhost", localHost);

            MyUserAccountClient = new UserAccountClient(MyResponsibleHosts, localHost);
            MyLoginAttemptClient = new LoginAttemptClient(MyResponsibleHosts, localHost);

            MemoryUsageLimiter memoryUsageLimiter = new MemoryUsageLimiter();

            MyUserAccountController = new UserAccountController(MyUserAccountClient,
                MyLoginAttemptClient, memoryUsageLimiter, options, StableStore,
                CreditLimits);
            MyLoginAttemptController = new LoginAttemptController(MyLoginAttemptClient, MyUserAccountClient,
                memoryUsageLimiter, options, StableStore);

            MyUserAccountController.SetLoginAttemptClient(MyLoginAttemptClient);
            MyUserAccountClient.SetLocalUserAccountController(MyUserAccountController);

            MyLoginAttemptController.SetUserAccountClient(MyUserAccountClient);
            MyLoginAttemptClient.SetLocalLoginAttemptController(MyLoginAttemptController);
            //fix outofmemory bug by setting the loginattempt field to null
            StableStore.LoginAttempts = null;
        }
Ejemplo n.º 4
0
 public LoginAttemptClient(IDistributedResponsibilitySet<RemoteHost> responsibleHosts, RemoteHost localHost)
 {
     _localHost = localHost;
     _responsibleHosts = responsibleHosts;
 }
 public LoginAttemptClient(IDistributedResponsibilitySet <RemoteHost> responsibleHosts, RemoteHost localHost)
 {
     _localHost        = localHost;
     _responsibleHosts = responsibleHosts;
 }
Ejemplo n.º 6
0
 public UserAccountClient(IDistributedResponsibilitySet<RemoteHost> responsibleHosts, RemoteHost localHost)
 {
     _responsibleHosts = responsibleHosts;
     _localHost = localHost;
 }