Esempio n. 1
0
 /// <exception cref="System.Exception"/>
 protected override void ServiceStop()
 {
     if (drainEventsOnStop)
     {
         blockNewEvents = true;
         Log.Info("AsyncDispatcher is draining to stop, igonring any new events.");
         long endTime = Runtime.CurrentTimeMillis() + GetConfig().GetLong(YarnConfiguration
                                                                          .DispatcherDrainEventsTimeout, YarnConfiguration.DefaultDispatcherDrainEventsTimeout
                                                                          );
         lock (waitForDrained)
         {
             while (!drained && eventHandlingThread != null && eventHandlingThread.IsAlive() &&
                    Runtime.CurrentTimeMillis() < endTime)
             {
                 Sharpen.Runtime.Wait(waitForDrained, 1000);
                 Log.Info("Waiting for AsyncDispatcher to drain. Thread state is :" + eventHandlingThread
                          .GetState());
             }
         }
     }
     stopped = true;
     if (eventHandlingThread != null)
     {
         eventHandlingThread.Interrupt();
         try
         {
             eventHandlingThread.Join();
         }
         catch (Exception ie)
         {
             Log.Warn("Interrupted Exception while stopping", ie);
         }
     }
     // stop all the components
     base.ServiceStop();
 }