[jboss-cvs] JBossCache/src/org/jboss/cache/notifications ...

Manik Surtani manik at jboss.org
Fri Jun 15 08:37:56 EDT 2007


  User: msurtani
  Date: 07/06/15 08:37:56

  Modified:    src/org/jboss/cache/notifications  Notifier.java
  Log:
  Patched tests to deal with async notifications being emitted, plus proper notifier shutdown/draining
  
  Revision  Changes    Path
  1.31      +21 -1     JBossCache/src/org/jboss/cache/notifications/Notifier.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Notifier.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/notifications/Notifier.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -b -r1.30 -r1.31
  --- Notifier.java	14 Jun 2007 17:56:07 -0000	1.30
  +++ Notifier.java	15 Jun 2007 12:37:56 -0000	1.31
  @@ -27,6 +27,7 @@
   import java.util.concurrent.Executor;
   import java.util.concurrent.ExecutorService;
   import java.util.concurrent.Executors;
  +import java.util.concurrent.TimeUnit;
   
   /**
    * Helper class that handles all notifications to registered listeners.
  @@ -86,11 +87,30 @@
         numExecutors = cache.getConfiguration().getNumberOfNotifierThreads();
      }
   
  -   public void stop()
  +   /**
  +    * Drains any pending notifications.  Won't accept any new notifications while this method is blocking.  It shuts down
  +    * and nullifies the executor service used to deliver notifications.
  +    * <p/>
  +    * This method does not destroy the Notifier instance - it can still be reused as the executor service is re-initialised
  +    * lazily when used next.
  +    */
  +   public void drainNotificationQueue()
      {
         if (executor != null)
         {
            executor.shutdown();
  +         try
  +         {
  +            while (!executor.isTerminated()) executor.awaitTermination(500, TimeUnit.MILLISECONDS);
  +         }
  +         catch (InterruptedException ie)
  +         {
  +            Thread.currentThread().interrupt();
  +         }
  +         finally
  +         {
  +            executor = null;
  +         }
         }
      }
   
  
  
  



More information about the jboss-cvs-commits mailing list