The client side of a distributed binomial ladder frequency filter. Binomial ladder filters are used to identify frequently-occuring elements in streams while minimizing the data revealed/stored about infrequently-occuring elements. This client is utilized both by applications using a distributed binomial ladder filter and is also by the servers implementing the server to communicate amongst themselves. For more information about the binomial ladder filter, search its name and "Microsoft Research" to find detailed publications/tech reports.
Наследование: IBinomialLadderFilter
 /// <summary>
 /// Construct the controller (server) for requests to this host for its shards of the binomial ladder filter.
 /// </summary>
 /// <param name="distributedBinomialLadderFilterClient">A client used by this server to access the servers hosting other shards of the filter.</param>
 /// <param name="numberOfBitsPerShard">The number of bits that each shard should contain.</param>
 /// <param name="secretSaltToPreventAlgorithmicComplexityAttacks">
 /// A secret used to salt the filter's hash functions so as to prevent attacks that might try to find collisions in the small space we are hashing to.</param>
 public DistributedBinomialLadderFilterController(DistributedBinomialLadderFilterClient distributedBinomialLadderFilterClient,
     int numberOfBitsPerShard, string secretSaltToPreventAlgorithmicComplexityAttacks)
 {
     FilterClient = distributedBinomialLadderFilterClient;
     NumberOfBitsPerShard = numberOfBitsPerShard;
     SecretSaltToPreventAlgorithmicComplexityAttacks = secretSaltToPreventAlgorithmicComplexityAttacks;
 }
Пример #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddMvc();

            string sqlConnectionString = Configuration["Data:ConnectionString"];
            services.AddDbContext<DbUserAccountContext>(
                opt => opt.UseSqlServer(sqlConnectionString));

            // Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers.
            // You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json.
            // services.AddWebApiConventions();

            BlockingAlgorithmOptions options = new BlockingAlgorithmOptions();

            services.AddSingleton<BlockingAlgorithmOptions>(x => options);

            RemoteHost localHost = new RemoteHost { Uri = new Uri("http://localhost:35358") };
            services.AddSingleton<RemoteHost>(x => localHost);

            MaxWeightHashing<RemoteHost> hosts = new MaxWeightHashing<RemoteHost>(Configuration["Data:UniqueConfigurationSecretPhrase"]);
            hosts.Add("localhost", localHost);
            services.AddSingleton<IDistributedResponsibilitySet<RemoteHost>>(x => hosts);

            string cloudStorageConnectionString = Configuration["Data:StorageConnectionString"];
            CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(cloudStorageConnectionString);
            services.AddSingleton<CloudStorageAccount>(a => cloudStorageAccount);

            services.AddSingleton<MemoryUsageLimiter, MemoryUsageLimiter>();

            if (hosts.Count > 0)
            {
                DistributedBinomialLadderFilterClient dblfClient = new DistributedBinomialLadderFilterClient(
                    options.NumberOfVirtualNodesForDistributedBinomialLadder,
                    options.HeightOfBinomialLadder_H,
                    hosts,
                    options.PrivateConfigurationKey,
                    options.MinimumBinomialLadderFilterCacheFreshness);
                // If running as a distributed system
                services.AddSingleton<IBinomialLadderFilter, DistributedBinomialLadderFilterClient>(x => dblfClient);

                DistributedBinomialLadderFilterController filterController =
                    new DistributedBinomialLadderFilterController(dblfClient, options.NumberOfBitsPerShardInBinomialLadderFilter, options.PrivateConfigurationKey);
                services.AddSingleton<DistributedBinomialLadderFilterController>(x => filterController);

                //services.AddSingleton<IFrequenciesProvider<string>>(x =>
                //    new IncorrectPasswordFrequencyClient(hosts, options.NumberOfRedundantHostsToCachePasswordPopularity));
            }
            else
            {
                BinomialLadderFilter localPasswordBinomialLadderFilter =
                    new BinomialLadderFilter(options.NumberOfBitsInBinomialLadderFilter_N, options.HeightOfBinomialLadder_H);
                services.AddSingleton<IBinomialLadderFilter>(x => localPasswordBinomialLadderFilter);
            }

            LoginAttemptClient<DbUserAccount> loginAttemptClient = new LoginAttemptClient<DbUserAccount>(hosts, localHost);
            services.AddSingleton<IUserAccountRepositoryFactory<DbUserAccount>, DbUserAccountRepositoryFactory>();
            services.AddSingleton<IUserAccountControllerFactory<DbUserAccount>, DbUserAccountControllerFactory>();
            //LoginAttemptController<DbUserAccount> loginAttemptController = new LoginAttemptController<DbUserAccount>( 
            //     new DbUserAccountControllerFactory(cloudStorageAccount), new DbUserAccountRepositoryFactory());
            services.AddSingleton<ILoginAttemptClient, LoginAttemptClient<DbUserAccount>>(i => loginAttemptClient);
            services.AddSingleton<ILoginAttemptController, LoginAttemptController<DbUserAccount>>();
        }