public AddSiblingService(CompositeService parent, Org.Apache.Hadoop.Service.Service
                          serviceToAdd, Service.STATE triggerState)
     : base("ParentStateManipulatorService")
 {
     this.parent       = parent;
     this.serviceToAdd = serviceToAdd;
     this.triggerState = triggerState;
 }
        /// <exception cref="System.Exception"/>
        public virtual void TestAddUninitedSiblingInStart()
        {
            CompositeService parent  = new CompositeService("parent");
            BreakableService sibling = new BreakableService();

            parent.AddService(new TestCompositeService.AddSiblingService(parent, sibling, Service.STATE
                                                                         .Started));
            parent.Init(new Configuration());
            AssertInState(Service.STATE.Notinited, sibling);
            parent.Start();
            parent.Stop();
            Assert.Equal("Incorrect number of services", 2, parent.GetServices
                             ().Count);
        }
        /// <exception cref="System.Exception"/>
        public virtual void TestAddStartedChildBeforeInit()
        {
            CompositeService parent = new CompositeService("parent");
            BreakableService child  = new BreakableService();

            child.Init(new Configuration());
            child.Start();
            TestCompositeService.AddSiblingService.AddChildToService(parent, child);
            try
            {
                parent.Init(new Configuration());
                NUnit.Framework.Assert.Fail("Expected an exception, got " + parent);
            }
            catch (ServiceStateException)
            {
            }
            //expected
            parent.Stop();
        }
        /// <exception cref="System.Exception"/>
        public virtual void TestAddUninitedSiblingInInit()
        {
            CompositeService parent  = new CompositeService("parent");
            BreakableService sibling = new BreakableService();

            parent.AddService(new TestCompositeService.AddSiblingService(parent, sibling, Service.STATE
                                                                         .Inited));
            parent.Init(new Configuration());
            try
            {
                parent.Start();
                NUnit.Framework.Assert.Fail("Expected an exception, got " + parent);
            }
            catch (ServiceStateException)
            {
            }
            //expected
            parent.Stop();
            Assert.Equal("Incorrect number of services", 2, parent.GetServices
                             ().Count);
        }
 /// <summary>Expose addService method</summary>
 /// <param name="parent">parent service</param>
 /// <param name="child">child to add</param>
 public static void AddChildToService(CompositeService parent, Org.Apache.Hadoop.Service.Service
                                      child)
 {
     parent.AddService(child);
 }
 public virtual void AddTestService(CompositeService service)
 {
     AddService(service);
 }
Beispiel #7
0
 public CompositeServiceShutdownHook(CompositeService compositeService)
 {
     this.compositeService = compositeService;
 }