Exemple #1
0
        public virtual void TestReadNodesFromConfig()
        {
            StaticMapping mapping = NewInstance();
            Configuration conf    = new Configuration();

            conf.Set(StaticMapping.KeyHadoopConfiguredNodeMapping, "n1=/r1,n2=/r2");
            mapping.SetConf(conf);
            //even though we have inserted elements into the list, because
            //it is driven by the script key in the configuration, it still
            //thinks that it is single rack
            AssertSingleSwitch(mapping);
            IList <string> l1 = new AList <string>(3);

            l1.AddItem("n1");
            l1.AddItem("unknown");
            l1.AddItem("n2");
            IList <string> resolved = mapping.Resolve(l1);

            Assert.Equal(3, resolved.Count);
            Assert.Equal("/r1", resolved[0]);
            Assert.Equal(NetworkTopology.DefaultRack, resolved[1]);
            Assert.Equal("/r2", resolved[2]);
            IDictionary <string, string> switchMap = mapping.GetSwitchMap();
            string topology = mapping.DumpTopology();

            Log.Info(topology);
            Assert.Equal(topology, 2, switchMap.Count);
            Assert.Equal(topology, "/r1", switchMap["n1"]);
            NUnit.Framework.Assert.IsNull(topology, switchMap["unknown"]);
        }
Exemple #2
0
        public virtual void TestAddResolveNodes()
        {
            StaticMapping mapping = NewInstance();

            StaticMapping.AddNodeToRack("n1", "/r1");
            IList <string> queryList = CreateQueryList();
            IList <string> resolved  = mapping.Resolve(queryList);

            Assert.Equal(2, resolved.Count);
            Assert.Equal("/r1", resolved[0]);
            Assert.Equal(NetworkTopology.DefaultRack, resolved[1]);
            // get the switch map and examine it
            IDictionary <string, string> switchMap = mapping.GetSwitchMap();
            string topology = mapping.DumpTopology();

            Log.Info(topology);
            Assert.Equal(topology, 1, switchMap.Count);
            Assert.Equal(topology, "/r1", switchMap["n1"]);
        }