public void ClusterConfigurations_Get_Test()
        {
            var option = new FastDFSOption()
            {
                ClusterConfigurations = new List <ClusterConfiguration>()
                {
                    new ClusterConfiguration()
                    {
                        Name    = "cluster1",
                        Charset = "utf-8",
                        TrackerMaxConnection = 1,
                        StorageMaxConnection = 2,
                        Trackers             = new List <Tracker>()
                        {
                            new Tracker("127.0.0.1", 22122)
                        }
                    }
                }
            };

            var options = Options.Create <FastDFSOption>(option);
            IClusterSelector clusterSelector = new DefaultClusterSelector(options);

            var configuration = clusterSelector.Get("cluster1");

            Assert.Equal("cluster1", configuration.Name);
            Assert.Equal(1, configuration.TrackerMaxConnection);
            Assert.Equal(2, configuration.StorageMaxConnection);
        }
        public void ClusterConfigurations_Empty_Test()
        {
            var option = new FastDFSOption();

            var options = Options.Create <FastDFSOption>(option);
            IClusterSelector clusterSelector = new DefaultClusterSelector(options);

            Assert.Throws <ArgumentNullException>(() =>
            {
                clusterSelector.Get("cluster1");
            });
        }
Esempio n. 3
0
        private void Setup(FakeLogger logger, int concurrentClusterCount = 3, int mode = 0)
        {
            if (!Directory.Exists("test\\AsyncClusterTest\\"))
            {
                Directory.CreateDirectory("test\\AsyncClusterTest\\");
            }
            for (var i = 0; i < 10; i++)
            {
                if (File.Exists($"test\\AsyncClusterTest\\test{i}.dat"))
                {
                    File.Delete($"test\\AsyncClusterTest\\test{i}.dat");
                }
            }
            fakeProcessorFactory = new FakeProcessorFactory(mode);
            var clusterOptionCreator = new DefaultClusterOptionCreator(fakeProcessorFactory);
            var clusterSelector      = new DefaultClusterSelector();

            option = new ClusteringOption(concurrentClusterCount, clusterOptionCreator, clusterSelector);
            asyncClusterManager = new AsyncClusterManager(option, logger);
        }
        public void ClusterConfigurations_Get_Default_Test()
        {
            var option = new FastDFSOption()
            {
                ClusterConfigurations = new List <ClusterConfiguration>()
                {
                    new ClusterConfiguration()
                    {
                        Name    = "cluster2",
                        Charset = "utf-8"
                    }
                }
            };

            var options = Options.Create <FastDFSOption>(option);
            IClusterSelector clusterSelector = new DefaultClusterSelector(options);

            var configuration = clusterSelector.Get("cluster1");

            Assert.Equal("cluster2", configuration.Name);
        }