public void TestAcceptLast()
        {
            string       xml    = "<remote-addresses xmlns=\"http://schemas.tangosol.com/cache\"><socket-address><address>127.0.0.1</address><port>80</port></socket-address><socket-address><address>127.0.0.1</address><port>81</port></socket-address></remote-addresses>";
            IXmlDocument config = XmlHelper.LoadXml(new StringReader(xml));

            Assert.IsNotNull(config);

            ConfigurableAddressProviderFactory factory = new ConfigurableAddressProviderFactory();

            factory.Config = config;
            IAddressProvider addrProvider = factory.CreateAddressProvider();

            Assert.IsNotNull(addrProvider);
            Assert.IsInstanceOf(typeof(ConfigurableAddressProvider), addrProvider);

            string addrProviderString = addrProvider.ToString();

            Assert.IsTrue(addrProviderString.Equals("[127.0.0.1:81,127.0.0.1:80]") ||
                          addrProviderString.Equals("[127.0.0.1:80,127.0.0.1:81]"));

            IPEndPoint addr = addrProvider.NextAddress;

            Assert.IsNotNull(addr);
            addrProvider.Reject(null);
            addr = addrProvider.NextAddress;
            Assert.IsNotNull(addr);
            addrProvider.Accept();
            addr = addrProvider.NextAddress;
            Assert.IsNotNull(addr);
        }
        public void TestCreateAddressProvider2()
        {
            string       xml    = "<remote-addresses xmlns=\"http://schemas.tangosol.com/cache\"><address-provider><class-name>Tangosol.Net.ConfigurableAddressProviderTests+LoopbackAddressProvider, Coherence.Tests</class-name></address-provider></remote-addresses>";
            IXmlDocument config = XmlHelper.LoadXml(new StringReader(xml));

            Assert.IsNotNull(config);

            ConfigurableAddressProviderFactory factory = new ConfigurableAddressProviderFactory();

            factory.Config = config.GetElement("address-provider");
            IAddressProvider addrProvider = factory.CreateAddressProvider();

            Assert.IsNotNull(addrProvider);
            Assert.IsInstanceOf(typeof(LoopbackAddressProvider), addrProvider);
        }
        public void TestCreateAddressProvider1()
        {
            string       xml    = "<remote-addresses xmlns=\"http://schemas.tangosol.com/cache\"><socket-address><address>10.0.0.120</address><port>80</port></socket-address><socket-address><address>10.0.0.121</address><port>8080</port></socket-address></remote-addresses>";
            IXmlDocument config = XmlHelper.LoadXml(new StringReader(xml));

            Assert.IsNotNull(config);

            ConfigurableAddressProviderFactory factory = new ConfigurableAddressProviderFactory();

            factory.Config = config;
            IAddressProvider addrProvider = factory.CreateAddressProvider();

            Assert.IsNotNull(addrProvider);

            string addrProviderString = addrProvider.ToString();

            Assert.IsTrue(addrProviderString.Equals("[10.0.0.121:8080,10.0.0.120:80]") ||
                          addrProviderString.Equals("[10.0.0.120:80,10.0.0.121:8080]"));

            Assert.IsInstanceOf(typeof(ConfigurableAddressProvider), addrProvider);
        }
示例#4
0
        /// <summary>
        /// Parse and configure address provider information.
        /// </summary>
        private void ParseAddressProviderConfig()
        {
            IDictionary addressProviderMap = new HashDictionary();

            var config = Config.FindElement("cluster-config/address-providers");

            if (config != null)
            {
                for (var addressProviders = config.GetElements("address-provider");
                     addressProviders.MoveNext();)
                {
                    var xmlAddressProvider = (IXmlElement)addressProviders.Current;
                    var name = xmlAddressProvider.GetAttribute("id").GetString();

                    ConfigurableAddressProviderFactory factory = new ConfigurableAddressProviderFactory();
                    factory.Config = xmlAddressProvider;

                    addressProviderMap.Add(name, factory);
                }
            }

            AddressProviderMap = addressProviderMap;
        }