Example #1
0
 public BrokenLifecycleEvent(Org.Apache.Hadoop.Service.Service service, string action
                             )
     : base("Lifecycle Failure during " + action + " state is " + service.GetServiceState
                ())
 {
     state = service.GetServiceState();
 }
Example #2
0
        /// <summary>Stop the services in reverse order</summary>
        /// <param name="numOfServicesStarted">index from where the stop should work</param>
        /// <param name="stopOnlyStartedServices">
        /// flag to say "only start services that are
        /// started, not those that are NOTINITED or INITED.
        /// </param>
        /// <exception cref="RuntimeException">
        /// the first exception raised during the
        /// stop process -<i>after all services are stopped</i>
        /// </exception>
        private void Stop(int numOfServicesStarted, bool stopOnlyStartedServices)
        {
            // stop in reverse order of start
            Exception firstException = null;
            IList <Org.Apache.Hadoop.Service.Service> services = GetServices();

            for (int i = numOfServicesStarted - 1; i >= 0; i--)
            {
                Org.Apache.Hadoop.Service.Service service = services[i];
                if (Log.IsDebugEnabled())
                {
                    Log.Debug("Stopping service #" + i + ": " + service);
                }
                Service.STATE state = service.GetServiceState();
                //depending on the stop police
                if (state == Service.STATE.Started || (!stopOnlyStartedServices && state == Service.STATE
                                                       .Inited))
                {
                    Exception ex = ServiceOperations.StopQuietly(Log, service);
                    if (ex != null && firstException == null)
                    {
                        firstException = ex;
                    }
                }
            }
            //after stopping all services, rethrow the first exception raised
            if (firstException != null)
            {
                throw ServiceStateException.Convert(firstException);
            }
        }
Example #3
0
 public static void AssertServiceInState(Org.Apache.Hadoop.Service.Service service
                                         , Service.STATE state)
 {
     NUnit.Framework.Assert.IsNotNull("Null service", service);
     Assert.Equal("Service in wrong state: " + service, state, service
                  .GetServiceState());
 }
 public virtual void StateChanged(Org.Apache.Hadoop.Service.Service service)
 {
     lock (this)
     {
         notifyingState = service.GetServiceState();
         Runtime.NotifyAll(this);
     }
 }
 public virtual void StateChanged(Org.Apache.Hadoop.Service.Service service)
 {
     lock (this)
     {
         eventCount++;
         lastService = service;
         lastState   = service.GetServiceState();
         stateEventList.AddItem(lastState);
         if (lastState == failingState)
         {
             failureCount++;
             throw new BreakableService.BrokenLifecycleEvent(service, "Failure entering " + lastState
                                                             + " for " + service.GetName());
         }
     }
 }
 private void AssertInState(Service.STATE expected, Org.Apache.Hadoop.Service.Service
                            service)
 {
     Assert.Equal("Service state should have been " + expected + " in "
                  + service, expected, service.GetServiceState());
 }
Example #7
0
 /// <summary>Callback for a state change event: log it</summary>
 /// <param name="service">the service that has changed.</param>
 public virtual void StateChanged(Org.Apache.Hadoop.Service.Service service)
 {
     log.Info("Entry to state " + service.GetServiceState() + " for " + service.GetName
                  ());
 }