JBoss Cache SVN: r5120 - in core/trunk/src/main/java/org/jboss/cache: factories and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-01-14 05:42:35 -0500 (Mon, 14 Jan 2008)
New Revision: 5120
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
core/trunk/src/main/java/org/jboss/cache/factories/TransactionManagerFactory.java
Log:
Moved logging from TMF to CacheImpl
Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2008-01-11 21:27:24 UTC (rev 5119)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2008-01-14 10:42:35 UTC (rev 5120)
@@ -586,6 +586,10 @@
log.info("Interceptor chain is:\n" + CachePrinter.printInterceptorChain(interceptorChain));
}
+ if (configuration.getNodeLockingScheme() == Configuration.NodeLockingScheme.OPTIMISTIC && transactionManager == null)
+ {
+ log.fatal("No transaction manager lookup class has been defined. Transactions cannot be used and thus OPTIMISTIC locking cannot be used! Expect errors!!");
+ }
correctRootNodeType();
Modified: core/trunk/src/main/java/org/jboss/cache/factories/TransactionManagerFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/TransactionManagerFactory.java 2008-01-11 21:27:24 UTC (rev 5119)
+++ core/trunk/src/main/java/org/jboss/cache/factories/TransactionManagerFactory.java 2008-01-14 10:42:35 UTC (rev 5120)
@@ -1,6 +1,5 @@
package org.jboss.cache.factories;
-import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.ConfigurationException;
import org.jboss.cache.factories.annotations.DefaultFactoryFor;
import org.jboss.cache.transaction.TransactionManagerLookup;
@@ -16,8 +15,6 @@
@DefaultFactoryFor(classes = {TransactionManager.class})
public class TransactionManagerFactory extends ComponentFactory
{
- boolean messageLogged = false;
-
@Override
@SuppressWarnings("unchecked")
protected <T> T construct(String componentName, Class<T> componentType)
@@ -49,21 +46,6 @@
transactionManager = lookup.getTransactionManager();
configuration.getRuntimeConfig().setTransactionManager(transactionManager);
}
- else
- {
- if (!messageLogged)
- {
- messageLogged = true;
- if (configuration.getNodeLockingScheme() == Configuration.NodeLockingScheme.OPTIMISTIC)
- {
- log.fatal("No transaction manager lookup class has been defined. Transactions cannot be used and thus OPTIMISTIC locking cannot be used");
- }
- else
- {
- log.info("No transaction manager lookup class has been defined. Transactions cannot be used");
- }
- }
- }
}
catch (Exception e)
{
16 years, 12 months
JBoss Cache SVN: r5119 - in core/trunk/src: main/resources/META-INF and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-01-11 16:27:24 -0500 (Fri, 11 Jan 2008)
New Revision: 5119
Added:
core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionAlgorithm.java
core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicy.java
core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicyConfig.java
core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionQueue.java
core/trunk/src/main/resources/META-INF/local-null-eviction-service.xml
core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPolicyTest.java
Log:
[JBCACHE-1215] NullEvictionPolicy
Added: core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionAlgorithm.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionAlgorithm.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionAlgorithm.java 2008-01-11 21:27:24 UTC (rev 5119)
@@ -0,0 +1,45 @@
+/**
+ *
+ */
+package org.jboss.cache.eviction;
+
+import org.jboss.cache.Region;
+
+/**
+ * Algorithm for {@link NullEvictionPolicy}.
+ *
+ * @author Brian Stansberry
+ */
+public class NullEvictionAlgorithm implements EvictionAlgorithm
+{
+ /** Singleton instance of this class. */
+ public static final NullEvictionAlgorithm INSTANCE = new NullEvictionAlgorithm();
+
+ /**
+ * Constructs a new NullEvictionAlgorithm.
+ */
+ private NullEvictionAlgorithm()
+ {
+ }
+
+ /**
+ * Returns {@link NullEvictionQueue#INSTANCE}.
+ */
+ public EvictionQueue getEvictionQueue()
+ {
+ return NullEvictionQueue.INSTANCE;
+ }
+
+ /** No-op */
+ public void process(Region region) throws EvictionException
+ {
+ // no-op
+ }
+
+ /** No-op */
+ public void resetEvictionQueue(Region region)
+ {
+ // no-op
+ }
+
+}
Property changes on: core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionAlgorithm.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicy.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicy.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicy.java 2008-01-11 21:27:24 UTC (rev 5119)
@@ -0,0 +1,69 @@
+/**
+ *
+ */
+package org.jboss.cache.eviction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.EvictionPolicyConfig;
+
+/**
+ * Eviction policy that does nothing and always tells the eviction
+ * interceptor an event can be ignored, saving the overhead of
+ * constructing and processing event objects. Basically useful
+ * as a default policy for a cache or subtree that is
+ * shared between multiple usages, some of which don't
+ * want eviction.
+ *
+ * @author Brian Stansberry
+ */
+public class NullEvictionPolicy implements EvictionPolicy
+{
+ private static final Log log = LogFactory.getLog(NullEvictionPolicy.class);
+
+ private CacheSPI cache;
+
+ /**
+ * Constructs a new NullEvictionPolicy.
+ */
+ public NullEvictionPolicy()
+ {
+ }
+
+ /** Returns <code>true</code> */
+ public boolean canIgnoreEvent(Fqn fqn, NodeEventType eventType)
+ {
+ return true;
+ }
+
+ /** No-op */
+ public void evict(Fqn fqn) throws Exception
+ {
+ log.debug("evict should not be called on NullEvictionPolicy");
+ }
+
+ /** Returns {@link NullEvictionAlgorithm#INSTANCE}. */
+ public EvictionAlgorithm getEvictionAlgorithm()
+ {
+ return NullEvictionAlgorithm.INSTANCE;
+ }
+
+ /** Returns {@link NullEvictionPolicyConfig}. */
+ public Class<? extends EvictionPolicyConfig> getEvictionConfigurationClass()
+ {
+ return NullEvictionPolicyConfig.class;
+ }
+
+ public CacheSPI getCache()
+ {
+ return cache;
+ }
+
+ public void setCache(CacheSPI cache)
+ {
+ this.cache = cache;
+ }
+
+}
Property changes on: core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicy.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicyConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicyConfig.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicyConfig.java 2008-01-11 21:27:24 UTC (rev 5119)
@@ -0,0 +1,49 @@
+/**
+ *
+ */
+package org.jboss.cache.eviction;
+
+import org.jboss.cache.config.ConfigurationComponent;
+import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.config.EvictionPolicyConfig;
+
+/**
+ * Configuration class for {@link NullEvictionPolicy}.
+ *
+ * @author Brian Stansberry
+ */
+public class NullEvictionPolicyConfig
+ extends ConfigurationComponent
+ implements EvictionPolicyConfig
+{
+
+ private static final long serialVersionUID = -6591180473728241737L;
+
+ /**
+ * Constructs a new NullEvictionPolicyConfig.
+ */
+ public NullEvictionPolicyConfig()
+ {
+ }
+
+ /**
+ * Returns {@link NullEvictionPolicy}.
+ */
+ public String getEvictionPolicyClass()
+ {
+ return NullEvictionPolicy.class.getName();
+ }
+
+ /** No-op */
+ public void reset()
+ {
+ // no-op
+ }
+
+ /** No-op */
+ public void validate() throws ConfigurationException
+ {
+ // no-op
+ }
+
+}
Property changes on: core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionPolicyConfig.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionQueue.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionQueue.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionQueue.java 2008-01-11 21:27:24 UTC (rev 5119)
@@ -0,0 +1,119 @@
+/**
+ *
+ */
+package org.jboss.cache.eviction;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import org.jboss.cache.Fqn;
+
+/**
+ * A queue that does nothing.
+ *
+ * @author Brian Stansberry
+ */
+public class NullEvictionQueue implements EvictionQueue
+{
+ /** Singleton instance of this class. */
+ public static final NullEvictionQueue INSTANCE = new NullEvictionQueue();
+
+ /**
+ * Constructs a new NullEvictionQueue.
+ */
+ private NullEvictionQueue()
+ {
+ }
+
+ /** No-op */
+ public void addNodeEntry(NodeEntry entry)
+ {
+ // no-op
+ }
+
+ /** No-op */
+ public void clear()
+ {
+ // no-op
+ }
+
+ /** Returns <code>false</code> */
+ public boolean containsNodeEntry(NodeEntry entry)
+ {
+ return false;
+ }
+
+ /** Returns <code>null</code> */
+ public NodeEntry getFirstNodeEntry()
+ {
+ return null;
+ }
+
+ /** Returns <code>null</code> */
+ public NodeEntry getNodeEntry(Fqn fqn)
+ {
+ return null;
+ }
+
+ /** Returns <code>null</code> */
+ public NodeEntry getNodeEntry(String fqn)
+ {
+ return null;
+ }
+
+ /** Returns <code>0</code> */
+ public int getNumberOfElements()
+ {
+ return 0;
+ }
+
+ /** Returns <code>0</code> */
+ public int getNumberOfNodes()
+ {
+ return 0;
+ }
+
+ /**
+ * Returns an <code>Iterator</code> whose
+ * <code>hasNext()</code> returns <code>false</code>.
+ */
+ public Iterator iterate()
+ {
+ return NullQueueIterator.INSTANCE;
+ }
+
+ /** No-op */
+ public void modifyElementCount(int difference)
+ {
+ // no-op
+ }
+
+ /** No-op */
+ public void removeNodeEntry(NodeEntry entry)
+ {
+ // no-op
+ }
+
+ static class NullQueueIterator implements Iterator
+ {
+ private static final NullQueueIterator INSTANCE = new NullQueueIterator();
+
+ private NullQueueIterator() {}
+
+ public boolean hasNext()
+ {
+ return false;
+ }
+
+ public Object next()
+ {
+ throw new NoSuchElementException("No more elements");
+ }
+
+ public void remove()
+ {
+ throw new IllegalStateException("Must call next() before remove()");
+ }
+ }
+
+}
Property changes on: core/trunk/src/main/java/org/jboss/cache/eviction/NullEvictionQueue.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/trunk/src/main/resources/META-INF/local-null-eviction-service.xml
===================================================================
--- core/trunk/src/main/resources/META-INF/local-null-eviction-service.xml (rev 0)
+++ core/trunk/src/main/resources/META-INF/local-null-eviction-service.xml 2008-01-11 21:27:24 UTC (rev 5119)
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Sample JBoss Cache Service Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<server>
+
+ <!-- ==================================================================== -->
+ <!-- Defines JBoss Cache configuration -->
+ <!-- ==================================================================== -->
+
+ <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+ name="jboss.cache:service=Cache">
+
+ <depends>jboss:service=Naming</depends>
+ <depends>jboss:service=TransactionManager</depends>
+
+ <!--
+ Configure the TransactionManager
+ -->
+ <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
+ </attribute>
+
+
+ <!--
+ Node locking level : SERIALIZABLE
+ REPEATABLE_READ (default)
+ READ_COMMITTED
+ READ_UNCOMMITTED
+ NONE
+ -->
+ <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
+
+ <!--
+ Valid modes are LOCAL
+ REPL_ASYNC
+ REPL_SYNC
+ INVALIDATION_ASYNC
+ INVALIDATION_SYNC
+ -->
+ <attribute name="CacheMode">LOCAL</attribute>
+
+ <!-- Name of cluster. Needs to be the same for all TreeCache nodes in a
+ cluster in order to find each other.
+ -->
+ <attribute name="ClusterName">JBossCache-Cluster</attribute>
+
+ <!--Uncomment next three statements to enable JGroups multiplexer.
+ This configuration is dependent on the JGroups multiplexer being
+ registered in an MBean server such as JBossAS. -->
+ <!--
+ <depends>jgroups.mux:name=Multiplexer</depends>
+ <attribute name="MultiplexerService">jgroups.mux:name=Multiplexer</attribute>
+ <attribute name="MultiplexerStack">fc-fast-minimalthreads</attribute>
+ -->
+
+ <!-- JGroups protocol stack properties NOT NEEDED since CacheMode is LOCAL -->
+
+
+ <!--
+ The max amount of time (in milliseconds) we wait until the
+ state (ie. the contents of the cache) are retrieved from
+ existing members in a clustered environment
+ -->
+ <attribute name="StateRetrievalTimeout">20000</attribute>
+
+ <!--
+ Number of milliseconds to wait until all responses for a
+ synchronous call have been received.
+ -->
+ <attribute name="SyncReplTimeout">20000</attribute>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <attribute name="LockAcquisitionTimeout">15000</attribute>
+
+ <!-- Specific eviction policy configurations. This is LRU -->
+ <attribute name="EvictionPolicyConfig">
+ <config>
+ <attribute name="wakeUpIntervalSeconds">1</attribute>
+ <!-- This defaults to 200000 if not specified -->
+ <attribute name="eventQueueSize">200000</attribute>
+ <attribute name="policyClass">org.jboss.cache.eviction.NullEvictionPolicy</attribute>
+
+ <!-- Cache wide default -->
+ <region name="/_default_">
+ <attribute name="maxNodes">5000</attribute>
+ <attribute name="timeToLiveSeconds">1</attribute>
+ </region>
+ <region name="/test" policyClass="org.jboss.cache.eviction.NullEvictionPolicy">
+ <attribute name="maxNodes">10000</attribute>
+ <attribute name="timeToLiveSeconds">1</attribute>
+ </region>
+ <region name="/lru" policyClass="org.jboss.cache.eviction.LRUPolicy">
+ <attribute name="maxNodes">10000</attribute>
+ <attribute name="timeToLiveSeconds">1</attribute>
+ </region>
+ </config>
+ </attribute>
+ </mbean>
+
+
+</server>
Added: core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionConfigTest.java 2008-01-11 21:27:24 UTC (rev 5119)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.eviction;
+
+import static org.testng.AssertJUnit.fail;
+
+import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.xml.XmlHelper;
+import org.testng.annotations.Test;
+import org.w3c.dom.Element;
+
+/**
+ * Unit tests for NullEvictionPolicyConfig.
+ *
+ * @author Daniel Huang (dhuang(a)jboss.org)
+ * @version $Revision: 4444 $
+ */
+@Test(groups = {"functional"})
+public class NullEvictionConfigTest
+{
+ /**
+ * Creates a bunch of region elements with LRU configs and confirms
+ * that NullEvictionPolicyConfig doesn't barf.
+ *
+ * @throws Exception
+ */
+ public void testXMLParsing() throws Exception
+ {
+ String xml =
+ "<region name=\"/org/jboss/data\">\n" +
+ "<attribute name=\"maxNodes\">5000</attribute>\n" +
+ "<attribute name=\"timeToLiveSeconds\">1000</attribute>\n" +
+ "</region>";
+
+ testConfigBlock(xml);
+
+ xml = "<region name=\"/maxAgeTest/\">\n" +
+ "<attribute name=\"maxNodes\">10000</attribute>\n" +
+ "<attribute name=\"timeToLiveSeconds\">8</attribute>\n" +
+ "<attribute name=\"maxAgeSeconds\">10</attribute>\n" +
+ "</region>";
+
+ testConfigBlock(xml);
+
+ xml = "<region name=\"/maxAgeTest/\">\n" +
+ "<attribute name=\"maxNodes\">10000</attribute>\n" +
+ "<attribute name=\"maxAgeSeconds\">10</attribute>\n" +
+ "</region>";
+
+ testConfigBlock(xml);
+
+ xml = "<region name=\"/maxAgeTest/\">\n" +
+ "<attribute name=\"timeToLiveSeconds\">8</attribute>\n" +
+ "<attribute name=\"maxAgeSeconds\">10</attribute>\n" +
+ "</region>";
+
+ testConfigBlock(xml);
+
+ xml = "<region name=\"/maxAgeTest/\"/>\n";
+
+ testConfigBlock(xml);
+ }
+
+ /**
+ * FIXME Comment this
+ *
+ * @param xml
+ * @throws Exception
+ */
+ private void testConfigBlock(String xml) throws Exception
+ {
+ Element element = XmlHelper.stringToElement(xml);
+ NullEvictionPolicyConfig config = new NullEvictionPolicyConfig();
+ try
+ {
+ XmlConfigurationParser.parseEvictionPolicyConfig(element, config);
+ }
+ catch (Exception e)
+ {
+ fail(e.getMessage());
+ }
+ }
+}
Added: core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPolicyTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/NullEvictionPolicyTest.java 2008-01-11 21:27:24 UTC (rev 5119)
@@ -0,0 +1,113 @@
+package org.jboss.cache.eviction;
+
+
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.misc.TestingUtil;
+import static org.testng.AssertJUnit.*;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Unit tests for LRU Policy.
+ *
+ * @author Ben Wang, Feb 11, 2004
+ * @author Daniel Huang - dhuang(a)jboss.org
+ * @version $Revision: 4880 $
+ */
+@Test(groups = {"functional"})
+public class NullEvictionPolicyTest
+{
+ CacheSPI<Object, Object> cache_;
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp() throws Exception
+ {
+ cache_ = null;
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception
+ {
+ if (cache_ != null)
+ {
+ cache_.stop();
+ cache_.destroy();
+ }
+ }
+
+ /**
+ * Builds a cache was null eviction by default and in "/test" region,
+ * LRU in "/lru" region. Does a mix of puts/reads/removes, wakes for
+ * eviction thread to kick in, checks that nothing was evicted from the
+ * null policy regions but was from lru region.
+ */
+ public void testEviction()
+ {
+ cache_ = (CacheSPI<Object, Object>) new DefaultCacheFactory().createCache("META-INF/local-null-eviction-service.xml", false);// read in generic local xml
+ cache_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ cache_.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
+ cache_.start();
+
+ String dfltRootStr = "/a/";
+ String testRootStr = "/test/";
+ String lruRootStr = "/lru/";
+
+ for (int i = 0; i < 20; i++)
+ {
+ if (i % 1 == 0 || i % 3 == 0)
+ {
+ Fqn dflt = Fqn.fromString(dfltRootStr + i);
+ Fqn test = Fqn.fromString(testRootStr + i);
+ Fqn lru = Fqn.fromString(lruRootStr + i);
+ cache_.put(dflt, "key", "value");
+ cache_.put(test, "key", "value");
+ cache_.put(lru, "key", "value");
+ }
+ else
+ {
+ Fqn dflt = Fqn.fromString(dfltRootStr + (i - 1));
+ Fqn test = Fqn.fromString(testRootStr + (i - 1));
+ Fqn lru = Fqn.fromString(lruRootStr + (i - 1));
+ if (i % 2 == 0)
+ {
+ assertEquals("value", cache_.get(dflt, "key"));
+ assertEquals("value", cache_.get(test, "key"));
+ assertEquals("value", cache_.get(lru, "key"));
+ }
+ else
+ {
+ cache_.removeNode(dflt);
+ cache_.removeNode(test);
+ cache_.removeNode(lru);
+ }
+ }
+ }
+
+ TestingUtil.sleepThread(2500);
+
+ for (int i = 0; i < 20; i++)
+ {
+ Fqn dflt = Fqn.fromString(dfltRootStr + i);
+ Fqn test = Fqn.fromString(testRootStr + i);
+ Fqn lru = Fqn.fromString(lruRootStr + i);
+
+ if (i % 1 == 0)
+ {
+ assertEquals("value", cache_.get(dflt, "key"));
+ assertEquals("value", cache_.get(test, "key"));
+ assertNull(cache_.get(lru, "key"));
+ }
+ else if (i % 3 == 0)
+ {
+ assertNull(cache_.get(dflt, "key"));
+ assertNull(cache_.get(test, "key"));
+ assertNull(cache_.get(lru, "key"));
+ }
+ }
+ }
+
+}
16 years, 12 months
JBoss Cache SVN: r5118 - core/trunk/src/main/java/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2008-01-11 10:54:20 -0500 (Fri, 11 Jan 2008)
New Revision: 5118
Modified:
core/trunk/src/main/java/org/jboss/cache/Cache.java
Log:
Javadoc @link fixes
Modified: core/trunk/src/main/java/org/jboss/cache/Cache.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Cache.java 2008-01-11 14:32:29 UTC (rev 5117)
+++ core/trunk/src/main/java/org/jboss/cache/Cache.java 2008-01-11 15:54:20 UTC (rev 5118)
@@ -95,16 +95,16 @@
Node<K, V> getRoot();
/**
- * Adds a {@link @org.jboss.cache.notifications.annotation.CacheListener}-annotated object to the entire cache. The object passed in needs to be properly annotated with the
- * {@link @org.jboss.cache.notifications.annotation.CacheListener} annotation otherwise an {@link org.jboss.cache.notifications.IncorrectCacheListenerException} will be thrown.
+ * Adds a {@link org.jboss.cache.notifications.annotation.CacheListener}-annotated object to the entire cache. The object passed in needs to be properly annotated with the
+ * {@link org.jboss.cache.notifications.annotation.CacheListener} annotation otherwise an {@link org.jboss.cache.notifications.IncorrectCacheListenerException} will be thrown.
*
* @param listener listener to add
*/
void addCacheListener(Object listener);
/**
- * Adds a {@link @org.jboss.cache.notifications.annotation.CacheListener}-annotated object to a given region. The object passed in needs to be properly annotated with the
- * {@link @org.jboss.cache.notifications.annotation.CacheListener} annotation otherwise an {@link org.jboss.cache.notifications.IncorrectCacheListenerException} will be thrown.
+ * Adds a {@link org.jboss.cache.notifications.annotation.CacheListener}-annotated object to a given region. The object passed in needs to be properly annotated with the
+ * {@link org.jboss.cache.notifications.annotation.CacheListener} annotation otherwise an {@link org.jboss.cache.notifications.IncorrectCacheListenerException} will be thrown.
*
* @param region region to add listener to
* @param listener listener to add
@@ -112,16 +112,16 @@
void addCacheListener(Fqn<?> region, Object listener);
/**
- * Removes a {@link @org.jboss.cache.notifications.annotation.CacheListener}-annotated object from the cache. The object passed in needs to be properly annotated with the
- * {@link @org.jboss.cache.notifications.annotation.CacheListener} annotation otherwise an {@link org.jboss.cache.notifications.IncorrectCacheListenerException} will be thrown.
+ * Removes a {@link org.jboss.cache.notifications.annotation.CacheListener}-annotated object from the cache. The object passed in needs to be properly annotated with the
+ * {@link org.jboss.cache.notifications.annotation.CacheListener} annotation otherwise an {@link org.jboss.cache.notifications.IncorrectCacheListenerException} will be thrown.
*
* @param listener listener to remove
*/
void removeCacheListener(Object listener);
/**
- * Removes a {@link @org.jboss.cache.notifications.annotation.CacheListener}-annotated object from a given region. The object passed in needs to be properly annotated with the
- * {@link @org.jboss.cache.notifications.annotation.CacheListener} annotation otherwise an {@link org.jboss.cache.notifications.IncorrectCacheListenerException} will be thrown.
+ * Removes a {@link org.jboss.cache.notifications.annotation.CacheListener}-annotated object from a given region. The object passed in needs to be properly annotated with the
+ * {@link org.jboss.cache.notifications.annotation.CacheListener} annotation otherwise an {@link org.jboss.cache.notifications.IncorrectCacheListenerException} will be thrown.
*
* @param region region from which to remove listener
* @param listener listener to remove
16 years, 12 months
JBoss Cache SVN: r5117 - core/trunk/src/test/java/org/jboss/cache/factories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-01-11 09:32:29 -0500 (Fri, 11 Jan 2008)
New Revision: 5117
Modified:
core/trunk/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java
Log:
Added buddy replication cfg to test
Modified: core/trunk/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java 2008-01-11 14:07:10 UTC (rev 5116)
+++ core/trunk/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java 2008-01-11 14:32:29 UTC (rev 5117)
@@ -3,6 +3,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.interceptors.OptimisticLockingInterceptor;
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
@@ -78,6 +79,19 @@
assert c.getCacheLoaderManager().getCacheLoader() instanceof DummyInMemoryCacheLoader;
}
+ public void testBuddyManager()
+ {
+ assert c.getBuddyManager() == null;
+
+ BuddyReplicationConfig brc = new BuddyReplicationConfig();
+ brc.setEnabled(true);
+ c.getConfiguration().setBuddyReplicationConfig(brc);
+
+ c.start();
+ assert c.getBuddyManager() != null;
+ assert c.getBuddyManager().isEnabled();
+ }
+
public void testInterceptors()
{
assert TestingUtil.findInterceptor(c, OptimisticLockingInterceptor.class) == null;
16 years, 12 months
JBoss Cache SVN: r5116 - in core/trunk/src: test/java/org/jboss/cache/factories and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-01-11 09:07:10 -0500 (Fri, 11 Jan 2008)
New Revision: 5116
Added:
core/trunk/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
Log:
Ensure that late configuration of transaction managers, etc are allowed. Added test for tis.
Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2008-01-10 15:56:22 UTC (rev 5115)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java 2008-01-11 14:07:10 UTC (rev 5116)
@@ -549,6 +549,16 @@
}
}
+ private void removeConfigurationDependentComponents()
+ {
+ // remove the Interceptor.class component though, since it may pertain to an old config
+ componentRegistry.unregisterComponent(Interceptor.class);
+ componentRegistry.unregisterComponent(Marshaller.class);
+ componentRegistry.unregisterComponent(TransactionManager.class);
+ componentRegistry.unregisterComponent(BuddyManager.class);
+ componentRegistry.unregisterComponent(CacheLoaderManager.class);
+ }
+
/**
* The actual start implementation.
*
@@ -559,9 +569,10 @@
{
// re-wire all dependencies in case stuff has changed since the cache was created
- // remove the Interceptor.class component though, since it may pertain to an old config
- componentRegistry.unregisterComponent(Interceptor.class);
+ // remove any components whose construction may have depended upon a configuration that may have changed.
+ removeConfigurationDependentComponents();
+ // this will recreate any missing components based on the current config
componentRegistry.updateDependencies();
componentRegistry.wireDependencies(root);
Added: core/trunk/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/factories/LateConfigurationTest.java 2008-01-11 14:07:10 UTC (rev 5116)
@@ -0,0 +1,115 @@
+package org.jboss.cache.factories;
+
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.interceptors.OptimisticLockingInterceptor;
+import org.jboss.cache.loader.DummyInMemoryCacheLoader;
+import org.jboss.cache.marshall.AbstractMarshaller;
+import org.jboss.cache.marshall.VersionAwareMarshaller;
+import org.jboss.cache.misc.TestingUtil;
+import org.jboss.cache.transaction.DummyTransactionManager;
+import org.jboss.cache.transaction.DummyTransactionManagerLookup;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 2.1.0
+ */
+@Test(groups = "functional")
+public class LateConfigurationTest
+{
+ CacheSPI c;
+
+ @BeforeMethod
+ public void setUp()
+ {
+ c = (CacheSPI) new DefaultCacheFactory().createCache(false);
+ }
+
+ @AfterMethod
+ public void tearDown()
+ {
+ TestingUtil.killCaches(c);
+ }
+
+ public void testTransactionManager()
+ {
+ assert c.getTransactionManager() == null;
+
+ c.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+
+ assert c.getTransactionManager() == null;
+ c.start();
+ assert c.getTransactionManager() == DummyTransactionManager.getInstance();
+ }
+
+ public void testTransactionManagerinRuntime()
+ {
+ assert c.getTransactionManager() == null;
+
+ c.getConfiguration().getRuntimeConfig().setTransactionManager(DummyTransactionManager.getInstance());
+
+ assert c.getTransactionManager() == null;
+ c.start();
+ assert c.getTransactionManager() == DummyTransactionManager.getInstance();
+ }
+
+
+ public void testCacheLoader()
+ {
+ assert c.getCacheLoaderManager() != null;
+ assert c.getCacheLoaderManager().getCacheLoader() == null;
+
+ CacheLoaderConfig clc = new CacheLoaderConfig();
+ CacheLoaderConfig.IndividualCacheLoaderConfig iclc = new CacheLoaderConfig.IndividualCacheLoaderConfig();
+ iclc.setCacheLoader(new DummyInMemoryCacheLoader());
+ clc.addIndividualCacheLoaderConfig(iclc);
+ c.getConfiguration().setCacheLoaderConfig(clc);
+
+ c.start();
+ assert c.getCacheLoaderManager() != null;
+ assert c.getCacheLoaderManager().getCacheLoader() instanceof DummyInMemoryCacheLoader;
+ }
+
+ public void testInterceptors()
+ {
+ assert TestingUtil.findInterceptor(c, OptimisticLockingInterceptor.class) == null;
+
+ c.getConfiguration().setNodeLockingScheme("OPTIMISTIC");
+ assert TestingUtil.findInterceptor(c, OptimisticLockingInterceptor.class) == null;
+ c.start();
+ assert TestingUtil.findInterceptor(c, OptimisticLockingInterceptor.class) != null;
+ }
+
+ public void testCacheMarshaller()
+ {
+ assert c.getMarshaller() instanceof VersionAwareMarshaller;
+
+ c.getConfiguration().setCacheMarshaller(new AbstractMarshaller()
+ {
+ public void objectToObjectStream(Object obj, ObjectOutputStream out) throws Exception
+ {
+ }
+
+ public Object objectFromObjectStream(ObjectInputStream in) throws Exception
+ {
+ return null;
+ }
+
+ public void objectToObjectStream(Object obj, ObjectOutputStream out, Fqn region)
+ {
+ }
+ });
+
+ c.start();
+
+ assert !(c.getMarshaller() instanceof VersionAwareMarshaller) && c.getMarshaller() != null;
+ }
+}
16 years, 12 months
JBoss Cache SVN: r5115 - core/trunk/src/main/docbook/userguide/en/modules.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-01-10 10:56:22 -0500 (Thu, 10 Jan 2008)
New Revision: 5115
Modified:
core/trunk/src/main/docbook/userguide/en/modules/cache_loaders.xml
core/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml
Log:
Documented TCP Cacheloader shutdown hook and marshalled value config elements
Modified: core/trunk/src/main/docbook/userguide/en/modules/cache_loaders.xml
===================================================================
--- core/trunk/src/main/docbook/userguide/en/modules/cache_loaders.xml 2008-01-10 15:55:35 UTC (rev 5114)
+++ core/trunk/src/main/docbook/userguide/en/modules/cache_loaders.xml 2008-01-10 15:56:22 UTC (rev 5115)
@@ -35,7 +35,6 @@
</mediaobject>
</figure>
-
<para>The interaction between JBoss Cache and a
<literal>CacheLoader</literal>
implementation is as follows. When
@@ -931,11 +930,19 @@
dependency injection).
</para>
- <para>The TcpDelegatingCacheLoader is configured with the host and
- port of the remote TcpCacheServer, and uses this to communicate to
- it.
+ <para>
+ As of JBoss Cache 2.1.0, the TcpDelegatingCacheLoader transparently handles reconnects if the connection
+ to the TcpCacheServer is lost.
</para>
+ <para>The TcpDelegatingCacheLoader is configured with the host and port of the remote TcpCacheServer, and uses this to communicate to
+ it. In addition, 2 new optional parameters are used to control transparent reconnecting to the TcpCacheServer.
+ The <literal>timeout</literal> property (defaults to 5000) specifies the length of time the cache loader must continue
+ retrying to connect to the TcpCacheServer before giving up and throwing an exception. The <literal>reconnectWaitTime</literal>
+ (defaults to 500) is how long the cache loader should wait before attempting a reconnect if it detects a communication failure.
+ The last two parameters can be used to add a level of fault tolerance to the cache loader, do deal with TcpCacheServer restarts.
+ </para>
+
<para>The configuration looks as follows:</para>
<programlisting>
@@ -947,6 +954,8 @@
<properties>
host=myRemoteServer
port=7500
+ timeout=10000
+ reconnectWaitTime=250
</properties>
</cacheloader>
</config>
Modified: core/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml
===================================================================
--- core/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml 2008-01-10 15:55:35 UTC (rev 5114)
+++ core/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml 2008-01-10 15:56:22 UTC (rev 5115)
@@ -116,7 +116,13 @@
<!-- Max number of milliseconds to wait for a lock acquisition -->
<attribute name="LockAcquisitionTimeout">15000</attribute>
+ <!-- Shutdown hook behavior. Valid choices are: DEFAULT, REGISTER and DONT_REGISTER.
+ If this element is omitted, DEFAULT is used. -->
+ <attribute name="ShutdownHookBehavior">DEFAULT</attribute>
+ <!-- Enables or disables lazy unmarshalling. If omitted, the default is that lazy unmarshalling is enabled. -->
+ <attribute name="UseLazyDeserialization">true</attribute>
+
<!-- Specific eviction policy configurations. This is LRU -->
<attribute name="EvictionConfig">
<config>
@@ -656,6 +662,35 @@
</para>
</entry>
</row>
+
+ <row>
+ <entry>
+ <para>ShutdownHookBehavior</para>
+ </entry>
+
+ <entry>
+ <para>An optional parameter that controls whether JBoss Cache registers a shutdown hook with the JVM
+ runtime. Allowed values are <literal>DEFAULT</literal>, <literal>REGISTER</literal> and
+ <literal>DONT_REGISTER</literal>. <literal>REGISTER</literal> and <literal>DONT_REGISTER</literal>
+ forces or suppresses the registration of a shutdown hook, respectively, and <literal>DEFAULT</literal>
+ registers one if an MBean server (other than the JDK default) cannot be found and it is assumed that the
+ cache is running in a managed environment. The default if unspecified is, as expected, <literal>DEFAULT</literal>.
+ </para>
+ </entry>
+ </row>
+
+ <row>
+ <entry>
+ <para>UseLazyDeserialization</para>
+ </entry>
+
+ <entry>
+ <para>An optional parameter that can be used to enable or disable the use of lazy deserialization
+ for cached objects. Defaults to <literal>true</literal>.
+ </para>
+ </entry>
+ </row>
+
</tbody>
</tgroup>
</informaltable>
16 years, 12 months
JBoss Cache SVN: r5114 - core/trunk/src/main/java/org/jboss/cache/factories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-01-10 10:55:35 -0500 (Thu, 10 Jan 2008)
New Revision: 5114
Modified:
core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
Log:
Only wire if we are "moving up"
Modified: core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-01-10 14:48:25 UTC (rev 5113)
+++ core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-01-10 15:55:35 UTC (rev 5114)
@@ -809,7 +809,7 @@
stop();
break;
case WIRED:
- wire();
+ if (increase) wire();
break;
case STARTED:
start();
16 years, 12 months
JBoss Cache SVN: r5113 - benchmarks/benchmark-fwk/trunk/src/org/cachebench/smartfrog.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-01-10 09:48:25 -0500 (Thu, 10 Jan 2008)
New Revision: 5113
Modified:
benchmarks/benchmark-fwk/trunk/src/org/cachebench/smartfrog/CacheBenchmarkPrim.java
Log:
added extra logging
Modified: benchmarks/benchmark-fwk/trunk/src/org/cachebench/smartfrog/CacheBenchmarkPrim.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/smartfrog/CacheBenchmarkPrim.java 2008-01-10 14:32:02 UTC (rev 5112)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/smartfrog/CacheBenchmarkPrim.java 2008-01-10 14:48:25 UTC (rev 5113)
@@ -112,9 +112,7 @@
int exitValue = process.waitFor();
if (exitValue != 0 )
{
- log.info("Exiting with exit code: " + exitValue);
- sfTerminate(new TerminationRecord(TerminationRecord.ABNORMAL, "we have an NOT zero exit code: " + exitValue
- + ", originated from " + getNodeDescription(), null));
+ log.warn("Script exited with code: " + exitValue);
}
correctTerminationOfTestsIfNeeded();
16 years, 12 months
JBoss Cache SVN: r5112 - benchmarks/benchmark-fwk/trunk.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-01-10 09:32:02 -0500 (Thu, 10 Jan 2008)
New Revision: 5112
Modified:
benchmarks/benchmark-fwk/trunk/runNode.sh
Log:
added extra logging
Modified: benchmarks/benchmark-fwk/trunk/runNode.sh
===================================================================
--- benchmarks/benchmark-fwk/trunk/runNode.sh 2008-01-10 14:30:43 UTC (rev 5111)
+++ benchmarks/benchmark-fwk/trunk/runNode.sh 2008-01-10 14:32:02 UTC (rev 5112)
@@ -50,4 +50,5 @@
echo executing:
echo $TO_EXECUTE
java $JVM_OPTIONS -cp $CLASSPATH org.cachebench.CacheBenchmarkRunner
+echo "Return code from benchmark runner is $?"
16 years, 12 months
JBoss Cache SVN: r5111 - in benchmarks/benchmark-fwk/trunk: src/org/cachebench/smartfrog and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-01-10 09:30:43 -0500 (Thu, 10 Jan 2008)
New Revision: 5111
Modified:
benchmarks/benchmark-fwk/trunk/runNode.sh
benchmarks/benchmark-fwk/trunk/src/org/cachebench/smartfrog/CacheBenchmarkPrim.java
Log:
added extra logging
Modified: benchmarks/benchmark-fwk/trunk/runNode.sh
===================================================================
--- benchmarks/benchmark-fwk/trunk/runNode.sh 2008-01-10 11:38:01 UTC (rev 5110)
+++ benchmarks/benchmark-fwk/trunk/runNode.sh 2008-01-10 14:30:43 UTC (rev 5111)
@@ -14,7 +14,7 @@
echo "testConfig : must be one of the directories names under 'cache-products'"
echo "cluster size"
echo "Ex: ./runNode.sh 0 jbosscache-2.0.0 3"
- exit 0
+ exit 1
fi
export SYS_PROPS="-DcurrentIndex=$1 -Djava.net.preferIPv4Stack=$preferIPv4Stack"
@@ -40,9 +40,10 @@
if [ -f $configFile ]
then
. $configFile
+ echo "Calling $configFile exit code is $?"
else
echo could not find config file $configFile, exit!
- exit 1
+ exit 2
fi
TO_EXECUTE="java $JVM_OPTIONS -cp $CLASSPATH org.cachebench.CacheBenchmarkRunner"
Modified: benchmarks/benchmark-fwk/trunk/src/org/cachebench/smartfrog/CacheBenchmarkPrim.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/smartfrog/CacheBenchmarkPrim.java 2008-01-10 11:38:01 UTC (rev 5110)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/smartfrog/CacheBenchmarkPrim.java 2008-01-10 14:30:43 UTC (rev 5111)
@@ -110,8 +110,9 @@
}
bufferedReader.close();
int exitValue = process.waitFor();
- if (exitValue != 0)
+ if (exitValue != 0 )
{
+ log.info("Exiting with exit code: " + exitValue);
sfTerminate(new TerminationRecord(TerminationRecord.ABNORMAL, "we have an NOT zero exit code: " + exitValue
+ ", originated from " + getNodeDescription(), null));
}
16 years, 12 months