commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1779350 - in /commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine: AbstractCacheEventQueue.java CacheEventQueue.java PooledCacheEventQueue.java
Date Wed, 18 Jan 2017 15:59:11 GMT
Author: tv
Date: Wed Jan 18 15:59:11 2017
New Revision: 1779350

URL: http://svn.apache.org/viewvc?rev=1779350&view=rev
Log:
Deprecate isAlive() logic

Modified:
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/AbstractCacheEventQueue.java
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheEventQueue.java
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/PooledCacheEventQueue.java

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/AbstractCacheEventQueue.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/AbstractCacheEventQueue.java?rev=1779350&r1=1779349&r2=1779350&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/AbstractCacheEventQueue.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/AbstractCacheEventQueue.java
Wed Jan 18 15:59:11 2017
@@ -64,9 +64,6 @@ public abstract class AbstractCacheEvent
     /** in milliseconds */
     private int waitBeforeRetry;
 
-    /** this is true if there is any worker thread. */
-    private final AtomicBoolean alive = new AtomicBoolean(false);
-
     /**
      * This means that the queue is functional. If we reached the max number of failures,
the queue
      * is marked as non functional and will never work again.
@@ -108,21 +105,27 @@ public abstract class AbstractCacheEvent
      * If they queue has an active thread it is considered alive.
      * <p>
      * @return The alive value
+     * 
+     * @deprecated The alive-logic is not used 
      */
-    @Override
+    @Deprecated
+	@Override
     public boolean isAlive()
     {
-        return alive.get();
+        return true;
     }
 
     /**
      * Sets whether the queue is actively processing -- if there are working threads.
      * <p>
      * @param aState
+     * 
+     * @deprecated The alive-logic is not used 
      */
-    public void setAlive( boolean aState )
+    @Deprecated
+	public void setAlive( boolean aState )
     {
-        alive.set(aState);
+        // do nothing
     }
 
     /**
@@ -179,17 +182,9 @@ public abstract class AbstractCacheEvent
      * @throws IOException
      */
     @Override
-    public synchronized void addPutEvent( ICacheElement<K, V> ce )
-        throws IOException
+    public void addPutEvent( ICacheElement<K, V> ce )
     {
-        if ( isWorking() )
-        {
-            put( new PutEvent( ce ) );
-        }
-        else if ( log.isWarnEnabled() )
-        {
-            log.warn( "Not enqueuing Put Event for [" + this + "] because it's non-functional."
);
-        }
+        put( new PutEvent( ce ) );
     }
 
     /**
@@ -200,54 +195,28 @@ public abstract class AbstractCacheEvent
      * @throws IOException
      */
     @Override
-    public synchronized void addRemoveEvent( K key )
-        throws IOException
+    public void addRemoveEvent( K key )
     {
-        if ( isWorking() )
-        {
-            put( new RemoveEvent( key ) );
-        }
-        else if ( log.isWarnEnabled() )
-        {
-            log.warn( "Not enqueuing Remove Event for [" + this + "] because it's non-functional."
);
-        }
+        put( new RemoveEvent( key ) );
     }
 
     /**
      * This adds a remove all event to the queue. When it is processed, all elements will
be removed
      * from the cache.
-     * <p>
-     * @throws IOException
      */
     @Override
-    public synchronized void addRemoveAllEvent()
-        throws IOException
+    public void addRemoveAllEvent()
     {
-        if ( isWorking() )
-        {
-            put( new RemoveAllEvent() );
-        }
-        else if ( log.isWarnEnabled() )
-        {
-            log.warn( "Not enqueuing RemoveAll Event for [" + this + "] because it's non-functional."
);
-        }
+        put( new RemoveAllEvent() );
     }
 
     /**
-     * @throws IOException
+     * This adds a dispose event to the queue. When it is processed, the cache is shut down
      */
     @Override
-    public synchronized void addDisposeEvent()
-        throws IOException
+    public void addDisposeEvent()
     {
-        if ( isWorking() )
-        {
-            put( new DisposeEvent() );
-        }
-        else if ( log.isWarnEnabled() )
-        {
-            log.warn( "Not enqueuing Dispose Event for [" + this + "] because it's non-functional."
);
-        }
+        put( new DisposeEvent() );
     }
 
     /**
@@ -293,8 +262,7 @@ public abstract class AbstractCacheEvent
                         log.warn( "Error while running event from Queue: " + this
                             + ". Dropping Event and marking Event Queue as non-functional."
);
                     }
-                    setWorking( false );
-                    setAlive( false );
+                    destroy();
                     return;
                 }
                 if ( log.isInfoEnabled() )
@@ -312,10 +280,7 @@ public abstract class AbstractCacheEvent
                     {
                         log.warn( "Interrupted while sleeping for retry on event " + this
+ "." );
                     }
-                    // TODO consider if this is best. maybe we should just
-                    // destroy
-                    setWorking( false );
-                    setAlive( false );
+                    destroy();
                 }
             }
         }
@@ -342,10 +307,8 @@ public abstract class AbstractCacheEvent
          * Constructor for the PutEvent object.
          * <p>
          * @param ice
-         * @throws IOException
          */
         PutEvent( ICacheElement<K, V> ice )
-            throws IOException
         {
             this.ice = ice;
         }
@@ -391,10 +354,8 @@ public abstract class AbstractCacheEvent
          * Constructor for the RemoveEvent object
          * <p>
          * @param key
-         * @throws IOException
          */
         RemoveEvent( K key )
-            throws IOException
         {
             this.key = key;
         }

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheEventQueue.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheEventQueue.java?rev=1779350&r1=1779349&r2=1779350&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheEventQueue.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheEventQueue.java
Wed Jan 18 15:59:11 2017
@@ -88,7 +88,6 @@ public class CacheEventQueue<K, V>
             TimeUnit.MILLISECONDS,
             queue,
             new DaemonThreadFactory("CacheEventQueue.QProcessor-" + getCacheName()));
-        setAlive(true);
     }
 
     /**

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/PooledCacheEventQueue.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/PooledCacheEventQueue.java?rev=1779350&r1=1779349&r2=1779350&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/PooledCacheEventQueue.java
(original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/PooledCacheEventQueue.java
Wed Jan 18 15:59:11 2017
@@ -88,7 +88,6 @@ public class PooledCacheEventQueue<K, V>
         // this will share the same pool with other event queues by default.
         pool = ThreadPoolManager.getInstance().getPool(
                 (threadPoolName == null) ? "cache_event_queue" : threadPoolName );
-        setAlive(true);
     }
 
     /**
@@ -106,9 +105,9 @@ public class PooledCacheEventQueue<K, V>
     @Override
     public synchronized void destroy()
     {
-        if ( isAlive() )
+        if ( isWorking() )
         {
-            setAlive(false);
+            setWorking(false);
             pool.shutdownNow();
             if ( log.isInfoEnabled() )
             {
@@ -139,8 +138,7 @@ public class PooledCacheEventQueue<K, V>
 
         ArrayList<IStatElement<?>> elems = new ArrayList<IStatElement<?>>();
 
-        elems.add(new StatElement<Boolean>( "Working", Boolean.valueOf(super.isWorking())
) );
-        elems.add(new StatElement<Boolean>( "Alive", Boolean.valueOf(this.isAlive())
) );
+        elems.add(new StatElement<Boolean>( "Working", Boolean.valueOf(isWorking())
) );
         elems.add(new StatElement<Boolean>( "Empty", Boolean.valueOf(this.isEmpty())
) );
 
         if ( pool.getQueue() != null )



Mime
View raw message