/// <exception cref="System.Exception"/>
        public virtual void TestRecoverWithMirror()
        {
            mgr.AddToCluserNodeLabels(ToSet("p1", "p2", "p3"));
            mgr.AddToCluserNodeLabels(ToSet("p4"));
            mgr.AddToCluserNodeLabels(ToSet("p5", "p6"));
            mgr.ReplaceLabelsOnNode((IDictionary)ImmutableMap.Of(ToNodeId("n1"), ToSet("p1"),
                                                                 ToNodeId("n2"), ToSet("p2")));
            mgr.ReplaceLabelsOnNode((IDictionary)ImmutableMap.Of(ToNodeId("n3"), ToSet("p3"),
                                                                 ToNodeId("n4"), ToSet("p4"), ToNodeId("n5"), ToSet("p5"), ToNodeId("n6"), ToSet(
                                                                     "p6"), ToNodeId("n7"), ToSet("p6")));

            /*
             * node -> partition p1: n1 p2: n2 p3: n3 p4: n4 p5: n5 p6: n6, n7
             */
            mgr.RemoveFromClusterNodeLabels(ToSet("p1"));
            mgr.RemoveFromClusterNodeLabels(Arrays.AsList("p3", "p5"));

            /*
             * After removed p2: n2 p4: n4 p6: n6, n7
             */
            // shutdown mgr and start a new mgr
            mgr.Stop();
            mgr = new TestFileSystemNodeLabelsStore.MockNodeLabelManager();
            mgr.Init(conf);
            mgr.Start();
            // check variables
            NUnit.Framework.Assert.AreEqual(3, mgr.GetClusterNodeLabels().Count);
            NUnit.Framework.Assert.IsTrue(mgr.GetClusterNodeLabels().ContainsAll(Arrays.AsList
                                                                                     ("p2", "p4", "p6")));
            AssertMapContains(mgr.GetNodeLabels(), ImmutableMap.Of(ToNodeId("n2"), ToSet("p2"
                                                                                         ), ToNodeId("n4"), ToSet("p4"), ToNodeId("n6"), ToSet("p6"), ToNodeId("n7"), ToSet
                                                                       ("p6")));
            AssertLabelsToNodesEquals(mgr.GetLabelsToNodes(), ImmutableMap.Of("p6", ToSet(ToNodeId
                                                                                              ("n6"), ToNodeId("n7")), "p4", ToSet(ToNodeId("n4")), "p2", ToSet(ToNodeId("n2")
                                                                                                                                                                )));
            // stutdown mgr and start a new mgr
            mgr.Stop();
            mgr = new TestFileSystemNodeLabelsStore.MockNodeLabelManager();
            mgr.Init(conf);
            mgr.Start();
            // check variables
            NUnit.Framework.Assert.AreEqual(3, mgr.GetClusterNodeLabels().Count);
            NUnit.Framework.Assert.IsTrue(mgr.GetClusterNodeLabels().ContainsAll(Arrays.AsList
                                                                                     ("p2", "p4", "p6")));
            AssertMapContains(mgr.GetNodeLabels(), ImmutableMap.Of(ToNodeId("n2"), ToSet("p2"
                                                                                         ), ToNodeId("n4"), ToSet("p4"), ToNodeId("n6"), ToSet("p6"), ToNodeId("n7"), ToSet
                                                                       ("p6")));
            AssertLabelsToNodesEquals(mgr.GetLabelsToNodes(), ImmutableMap.Of("p6", ToSet(ToNodeId
                                                                                              ("n6"), ToNodeId("n7")), "p4", ToSet(ToNodeId("n4")), "p2", ToSet(ToNodeId("n2")
                                                                                                                                                                )));
            mgr.Stop();
        }
        public virtual void TestSerilizationAfterRecovery()
        {
            //(timeout = 10000)
            mgr.AddToCluserNodeLabels(ToSet("p1", "p2", "p3"));
            mgr.AddToCluserNodeLabels(ToSet("p4"));
            mgr.AddToCluserNodeLabels(ToSet("p5", "p6"));
            mgr.ReplaceLabelsOnNode(ImmutableMap.Of(ToNodeId("n1"), ToSet("p1"), ToNodeId("n2"
                                                                                          ), ToSet("p2")));
            mgr.ReplaceLabelsOnNode((IDictionary)ImmutableMap.Of(ToNodeId("n3"), ToSet("p3"),
                                                                 ToNodeId("n4"), ToSet("p4"), ToNodeId("n5"), ToSet("p5"), ToNodeId("n6"), ToSet(
                                                                     "p6"), ToNodeId("n7"), ToSet("p6")));

            /*
             * node -> labels
             * p1: n1
             * p2: n2
             * p3: n3
             * p4: n4
             * p5: n5
             * p6: n6, n7
             */
            mgr.RemoveFromClusterNodeLabels(ToSet("p1"));
            mgr.RemoveFromClusterNodeLabels(Arrays.AsList("p3", "p5"));

            /*
             * After removed
             * p2: n2
             * p4: n4
             * p6: n6, n7
             */
            // shutdown mgr and start a new mgr
            mgr.Stop();
            mgr = new TestFileSystemNodeLabelsStore.MockNodeLabelManager();
            mgr.Init(conf);
            mgr.Start();
            // check variables
            NUnit.Framework.Assert.AreEqual(3, mgr.GetClusterNodeLabels().Count);
            NUnit.Framework.Assert.IsTrue(mgr.GetClusterNodeLabels().ContainsAll(Arrays.AsList
                                                                                     ("p2", "p4", "p6")));
            AssertMapContains(mgr.GetNodeLabels(), ImmutableMap.Of(ToNodeId("n2"), ToSet("p2"
                                                                                         ), ToNodeId("n4"), ToSet("p4"), ToNodeId("n6"), ToSet("p6"), ToNodeId("n7"), ToSet
                                                                       ("p6")));
            AssertLabelsToNodesEquals(mgr.GetLabelsToNodes(), ImmutableMap.Of("p6", ToSet(ToNodeId
                                                                                              ("n6"), ToNodeId("n7")), "p4", ToSet(ToNodeId("n4")), "p2", ToSet(ToNodeId("n2")
                                                                                                                                                                )));

            /*
             * Add label p7,p8 then shutdown
             */
            mgr = new TestFileSystemNodeLabelsStore.MockNodeLabelManager();
            mgr.Init(conf);
            mgr.Start();
            mgr.AddToCluserNodeLabels(ToSet("p7", "p8"));
            mgr.Stop();

            /*
             * Restart, add label p9 and shutdown
             */
            mgr = new TestFileSystemNodeLabelsStore.MockNodeLabelManager();
            mgr.Init(conf);
            mgr.Start();
            mgr.AddToCluserNodeLabels(ToSet("p9"));
            mgr.Stop();

            /*
             * Recovery, and see if p9 added
             */
            mgr = new TestFileSystemNodeLabelsStore.MockNodeLabelManager();
            mgr.Init(conf);
            mgr.Start();
            // check variables
            NUnit.Framework.Assert.AreEqual(6, mgr.GetClusterNodeLabels().Count);
            NUnit.Framework.Assert.IsTrue(mgr.GetClusterNodeLabels().ContainsAll(Arrays.AsList
                                                                                     ("p2", "p4", "p6", "p7", "p8", "p9")));
            mgr.Stop();
        }