[jboss-cvs] JBossCache/src/org/jboss/cache/eviction ...
Brian Stansberry
brian.stansberry at jboss.com
Wed Oct 11 23:36:46 EDT 2006
User: bstansberry
Date: 06/10/11 23:36:46
Modified: src/org/jboss/cache/eviction
BaseSortedEvictionAlgorithm.java RegionManager.java
Region.java BaseEvictionAlgorithm.java
Added: src/org/jboss/cache/eviction NodeEventType.java
Log:
[JBCACHE-801] Use enum for node event types
Revision Changes Path
1.4 +7 -8 JBossCache/src/org/jboss/cache/eviction/BaseSortedEvictionAlgorithm.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BaseSortedEvictionAlgorithm.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/eviction/BaseSortedEvictionAlgorithm.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- BaseSortedEvictionAlgorithm.java 15 Apr 2006 00:21:13 -0000 1.3
+++ BaseSortedEvictionAlgorithm.java 12 Oct 2006 03:36:46 -0000 1.4
@@ -39,33 +39,32 @@
int count = 0;
while ((node = region.takeLastEventNode()) != null)
{
- int eventType = node.getEvent();
Fqn fqn = node.getFqn();
count++;
- switch (eventType)
+ switch (node.getEventType())
{
- case EvictedEventNode.ADD_NODE_EVENT:
+ case ADD_NODE_EVENT:
this.processAddedNodes(fqn, node.getElementDifference(), node.isResetElementCount());
evictionNodesModified = true;
break;
- case EvictedEventNode.REMOVE_NODE_EVENT:
+ case REMOVE_NODE_EVENT:
this.processRemovedNodes(fqn);
break;
- case EvictedEventNode.VISIT_NODE_EVENT:
+ case VISIT_NODE_EVENT:
this.processVisitedNodes(fqn);
evictionNodesModified = true;
break;
- case EvictedEventNode.ADD_ELEMENT_EVENT:
+ case ADD_ELEMENT_EVENT:
this.processAddedElement(fqn);
evictionNodesModified = true;
break;
- case EvictedEventNode.REMOVE_ELEMENT_EVENT:
+ case REMOVE_ELEMENT_EVENT:
this.processRemovedElement(fqn);
evictionNodesModified = true;
break;
default:
- throw new RuntimeException("Illegal Eviction Event type " + eventType);
+ throw new RuntimeException("Illegal Eviction Event type " + node.getEventType());
}
}
1.22 +3 -3 JBossCache/src/org/jboss/cache/eviction/RegionManager.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: RegionManager.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/eviction/RegionManager.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- RegionManager.java 16 Aug 2006 10:52:50 -0000 1.21
+++ RegionManager.java 12 Oct 2006 03:36:46 -0000 1.22
@@ -34,7 +34,7 @@
*
* @author Ben Wang 02-2004
* @author Daniel Huang (dhuang at jboss.org)
- * @version $Id: RegionManager.java,v 1.21 2006/08/16 10:52:50 msurtani Exp $
+ * @version $Id: RegionManager.java,v 1.22 2006/10/12 03:36:46 bstansberry Exp $
*/
public class RegionManager
{
@@ -345,7 +345,7 @@
public void markNodeCurrentlyInUse(Fqn fqn, long timeout)
{
Region region = this.getRegion(fqn);
- EvictedEventNode markUse = new EvictedEventNode(fqn, EvictedEventNode.MARK_IN_USE_EVENT);
+ EvictedEventNode markUse = new EvictedEventNode(fqn, NodeEventType.MARK_IN_USE_EVENT);
markUse.setInUseTimeout(timeout);
region.putNodeEvent(markUse);
}
@@ -358,7 +358,7 @@
public void unmarkNodeCurrentlyInUse(Fqn fqn)
{
Region region = this.getRegion(fqn);
- EvictedEventNode markNoUse = new EvictedEventNode(fqn, EvictedEventNode.UNMARK_USE_EVENT);
+ EvictedEventNode markNoUse = new EvictedEventNode(fqn, NodeEventType.UNMARK_USE_EVENT);
region.putNodeEvent(markNoUse);
}
1.12 +6 -6 JBossCache/src/org/jboss/cache/eviction/Region.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Region.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/eviction/Region.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- Region.java 8 Jun 2006 17:37:39 -0000 1.11
+++ Region.java 12 Oct 2006 03:36:46 -0000 1.12
@@ -20,7 +20,7 @@
*
* @author Ben Wang 2-2004
* @author Daniel Huang (dhuang at jboss.org)
- * @version $Revision: 1.11 $
+ * @version $Revision: 1.12 $
*/
public class Region
{
@@ -105,22 +105,22 @@
public void setAddedNode(Fqn fqn)
{
- putNodeEvent(fqn, EvictedEventNode.ADD_NODE_EVENT);
+ putNodeEvent(fqn, NodeEventType.ADD_NODE_EVENT);
}
public void setRemovedNode(Fqn fqn)
{
- putNodeEvent(fqn, EvictedEventNode.REMOVE_NODE_EVENT);
+ putNodeEvent(fqn, NodeEventType.REMOVE_NODE_EVENT);
}
public void setVisitedNode(Fqn fqn)
{
- putNodeEvent(fqn, EvictedEventNode.VISIT_NODE_EVENT);
+ putNodeEvent(fqn, NodeEventType.VISIT_NODE_EVENT);
}
- public void putNodeEvent(Fqn fqn, int event)
+ public void putNodeEvent(Fqn fqn, NodeEventType type)
{
- this.putNodeEvent(new EvictedEventNode(fqn, event));
+ this.putNodeEvent(new EvictedEventNode(fqn, type));
}
public void putNodeEvent(EvictedEventNode event)
1.12 +10 -11 JBossCache/src/org/jboss/cache/eviction/BaseEvictionAlgorithm.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BaseEvictionAlgorithm.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/eviction/BaseEvictionAlgorithm.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- BaseEvictionAlgorithm.java 8 Jun 2006 17:37:39 -0000 1.11
+++ BaseEvictionAlgorithm.java 12 Oct 2006 03:36:46 -0000 1.12
@@ -19,7 +19,7 @@
* abstract methods and a policy.
*
* @author Daniel Huang - dhuang at jboss.org 10/2005
- * @version $Revision: 1.11 $
+ * @version $Revision: 1.12 $
*/
public abstract class BaseEvictionAlgorithm implements EvictionAlgorithm
{
@@ -129,37 +129,36 @@
int count = 0;
while ((node = region.takeLastEventNode()) != null)
{
- int eventType = node.getEvent();
Fqn fqn = node.getFqn();
count++;
- switch (eventType)
+ switch (node.getEventType())
{
- case EvictedEventNode.ADD_NODE_EVENT:
+ case ADD_NODE_EVENT:
this.processAddedNodes(fqn,
node.getElementDifference(),
node.isResetElementCount());
break;
- case EvictedEventNode.REMOVE_NODE_EVENT:
+ case REMOVE_NODE_EVENT:
this.processRemovedNodes(fqn);
break;
- case EvictedEventNode.VISIT_NODE_EVENT:
+ case VISIT_NODE_EVENT:
this.processVisitedNodes(fqn);
break;
- case EvictedEventNode.ADD_ELEMENT_EVENT:
+ case ADD_ELEMENT_EVENT:
this.processAddedElement(fqn);
break;
- case EvictedEventNode.REMOVE_ELEMENT_EVENT:
+ case REMOVE_ELEMENT_EVENT:
this.processRemovedElement(fqn);
break;
- case EvictedEventNode.MARK_IN_USE_EVENT:
+ case MARK_IN_USE_EVENT:
this.processMarkInUseNodes(fqn, node.getInUseTimeout());
break;
- case EvictedEventNode.UNMARK_USE_EVENT:
+ case UNMARK_USE_EVENT:
this.processUnmarkInUseNodes(fqn);
break;
default:
- throw new RuntimeException("Illegal Eviction Event type " + eventType);
+ throw new RuntimeException("Illegal Eviction Event type " + node.getEventType());
}
}
1.1 date: 2006/10/12 03:36:46; author: bstansberry; state: Exp;JBossCache/src/org/jboss/cache/eviction/NodeEventType.java
Index: NodeEventType.java
===================================================================
/*
* JBoss, Home of Professional Open Source.
* Copyright 2006, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.cache.eviction;
/**
* Enumeration of the valid event types used to create an
* {@link EvictionEventNode}.
*
* @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
* @version $Revision: 1.1 $
*/
public enum NodeEventType
{
ADD_NODE_EVENT,
REMOVE_NODE_EVENT,
VISIT_NODE_EVENT,
ADD_ELEMENT_EVENT,
REMOVE_ELEMENT_EVENT,
MARK_IN_USE_EVENT,
UNMARK_USE_EVENT
}
More information about the jboss-cvs-commits
mailing list