JBoss Cache SVN: r5820 - core/trunk/src/test/java/org/jboss/cache/marshall.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-09 08:32:19 -0400 (Fri, 09 May 2008)
New Revision: 5820
Modified:
core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java
Log:
Fixed test
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java 2008-05-09 12:24:21 UTC (rev 5819)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java 2008-05-09 12:32:19 UTC (rev 5820)
@@ -86,8 +86,10 @@
final CacheMarshaller200 cm200 = new CacheMarshaller200();
c.setInactiveOnStartup(false);
c.setUseRegionBasedMarshalling(true);
+ c.setCacheMarshaller(cm200);
cr.registerComponent(cm200, CacheMarshaller200.class);
cr.rewire();
+ cr.start();
RegionManager rm = cr.getComponent(RegionManager.class);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
16 years, 7 months
JBoss Cache SVN: r5819 - core/trunk/src/main/java/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-09 08:24:21 -0400 (Fri, 09 May 2008)
New Revision: 5819
Modified:
core/trunk/src/main/java/org/jboss/cache/DataContainer.java
Log:
Changed priority of start method
Modified: core/trunk/src/main/java/org/jboss/cache/DataContainer.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DataContainer.java 2008-05-09 12:24:09 UTC (rev 5818)
+++ core/trunk/src/main/java/org/jboss/cache/DataContainer.java 2008-05-09 12:24:21 UTC (rev 5819)
@@ -55,7 +55,7 @@
createRootNode();
}
- @Start(priority = 25)
+ @Start(priority = 12)
private void createRootNode()
{
// create a new root temporarily.
16 years, 7 months
JBoss Cache SVN: r5818 - core/trunk/src/main/java/org/jboss/cache/factories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-09 08:24:09 -0400 (Fri, 09 May 2008)
New Revision: 5818
Modified:
core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
Log:
Added toString
Modified: core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-05-09 12:23:53 UTC (rev 5817)
+++ core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-05-09 12:24:09 UTC (rev 5818)
@@ -925,5 +925,14 @@
{
ReflectionUtil.invokeAccessibly(component.instance, method, null);
}
+
+
+ public String toString()
+ {
+ return "PrioritizedMethod{" +
+ "method=" + method +
+ ", priority=" + priority +
+ '}';
+ }
}
}
16 years, 7 months
JBoss Cache SVN: r5817 - core/trunk/src/test/java/org/jboss/cache/transaction.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-09 08:23:53 -0400 (Fri, 09 May 2008)
New Revision: 5817
Modified:
core/trunk/src/test/java/org/jboss/cache/transaction/PrepareCommitContentionTest.java
Log:
Rewire after injection in a running cache
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/PrepareCommitContentionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/PrepareCommitContentionTest.java 2008-05-09 11:49:19 UTC (rev 5816)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/PrepareCommitContentionTest.java 2008-05-09 12:23:53 UTC (rev 5817)
@@ -62,6 +62,7 @@
RPCManager origRpcManager = cr.getComponent(RPCManager.class);
delegatingRPCManager.delegate = origRpcManager;
cr.registerComponent(delegatingRPCManager, RPCManager.class);
+ cr.rewire();
c1.getTransactionManager().begin();
c1.put("/a", "k", "v");
16 years, 7 months
JBoss Cache SVN: r5816 - in core/trunk/src: test/java/org/jboss/cache/marshall and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-09 07:49:19 -0400 (Fri, 09 May 2008)
New Revision: 5816
Removed:
core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller220.java
Modified:
core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java
core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
Log:
Removed unnecessary CacheMarshaller220
Deleted: core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller220.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller220.java 2008-05-09 11:48:48 UTC (rev 5815)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller220.java 2008-05-09 11:49:19 UTC (rev 5816)
@@ -1,82 +0,0 @@
-package org.jboss.cache.marshall;
-
-import org.jboss.cache.Fqn;
-import org.jboss.cache.StringFqn;
-
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * An evolution of {@link CacheMarshaller210}, to allow for {@link org.jboss.cache.StringFqn}s.
- *
- * @author Manik Surtani
- * @since 2.2.0
- */
-public class CacheMarshaller220 extends CacheMarshaller210
-{
- public CacheMarshaller220()
- {
- initLogger();
- // disabled, since this is always disabled in JBC 2.0.0.
- // Java ObjectOutputStreams will have it's own built-in ref counting. No need to repeat this.
- useRefs = false;
- }
-
- @Override
- protected void marshallFqn(Fqn fqn, ObjectOutputStream out, Map<Object, Integer> refMap) throws Exception
- {
- boolean isRoot = fqn.isRoot();
- out.writeBoolean(isRoot);
- if (!isRoot)
- {
- if (fqn.getClass().equals(StringFqn.class))
- {
- out.writeShort(-1);
- marshallString(((StringFqn) fqn).getStringRepresentation(), out);
- }
- else
- {
- out.writeShort(fqn.size());
- for (Object o : fqn.peekElements())
- {
- marshallObject(o, out, refMap);
- }
- }
- }
- }
-
- @Override
- protected Fqn unmarshallFqn(ObjectInputStream in, UnmarshalledReferences refMap) throws Exception
- {
-
- boolean isRoot = in.readBoolean();
- Fqn fqn;
- if (!isRoot)
- {
- int numElements = in.readShort();
- if (numElements == -1)
- {
- // this is a "new" StringFqn.
- fqn = Fqn.fromString(unmarshallString(in));
- }
- else
- {
- // an "old-style" mixed-type Fqn
- List<Object> elements = new ArrayList<Object>(numElements);
- for (int i = 0; i < numElements; i++)
- {
- elements.add(unmarshallObject(in, refMap));
- }
- fqn = Fqn.fromList(elements);
- }
- }
- else
- {
- fqn = Fqn.ROOT;
- }
- return fqn;
- }
-}
\ No newline at end of file
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java 2008-05-09 11:48:48 UTC (rev 5815)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java 2008-05-09 11:49:19 UTC (rev 5816)
@@ -279,30 +279,20 @@
marshallers.put(VERSION_200, marshaller);
}
break;
- case VERSION_210:
- marshaller = marshallers.get(VERSION_210);
- if (marshaller == null)
- {
- am = new CacheMarshaller210();
- marshaller = am;
- componentRegistry.wireDependencies(am);
- am.init();
- marshallers.put(VERSION_210, marshaller);
- }
- break;
case VERSION_220:
+ case VERSION_210:
knownVersion = true;
default:
if (!knownVersion && log.isWarnEnabled())
log.warn("Unknown replication version String. Falling back to the default marshaller installed.");
- marshaller = marshallers.get(VERSION_220);
+ marshaller = marshallers.get(VERSION_210);
if (marshaller == null)
{
- am = new CacheMarshaller220();
+ am = new CacheMarshaller210();
marshaller = am;
componentRegistry.wireDependencies(am);
am.init();
- marshallers.put(VERSION_220, marshaller);
+ marshallers.put(VERSION_210, marshaller);
}
break;
}
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java 2008-05-09 11:48:48 UTC (rev 5815)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java 2008-05-09 11:49:19 UTC (rev 5816)
@@ -28,7 +28,7 @@
{
protected String currentVersion;
protected int currentVersionShort;
- protected Class expectedMarshallerClass, latestMarshallerClass = CacheMarshaller220.class;
+ protected Class expectedMarshallerClass, latestMarshallerClass = CacheMarshaller210.class;
protected VersionAwareMarshaller marshaller;
protected RegionManager regionManager;
protected Configuration c;
@@ -89,7 +89,7 @@
assertEquals(CacheMarshaller200.class, marshaller.getMarshaller(20).getClass());
assertEquals(CacheMarshaller210.class, marshaller.getMarshaller(21).getClass());
- assert marshaller.marshallers.size() == 3 : "Should have 3 marshallers now";
+ assert marshaller.marshallers.size() == 2 : "Should have 2 marshallers now";
}
public void testStringBasedFqn() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java 2008-05-09 11:48:48 UTC (rev 5815)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java 2008-05-09 11:49:19 UTC (rev 5816)
@@ -42,7 +42,7 @@
public void testMarshallerSelection()
{
VersionAwareMarshaller marshaller = createVAMandRestartCache("2.2.0.GA");
- assertEquals(CacheMarshaller220.class, marshaller.defaultMarshaller.getClass());
+ assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
marshaller = createVAMandRestartCache("2.1.0.GA");
assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
@@ -51,25 +51,25 @@
assertEquals(CacheMarshaller200.class, marshaller.defaultMarshaller.getClass());
marshaller = createVAMandRestartCache("1.4.0.GA");
- assertEquals(CacheMarshaller220.class, marshaller.defaultMarshaller.getClass());
+ assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
marshaller = createVAMandRestartCache("1.5.0.GA");
- assertEquals(CacheMarshaller220.class, marshaller.defaultMarshaller.getClass());
+ assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
marshaller = createVAMandRestartCache("1.3.0.GA");
- assertEquals(CacheMarshaller220.class, marshaller.defaultMarshaller.getClass());
+ assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
marshaller = createVAMandRestartCache("1.3.0.SP2");
- assertEquals(CacheMarshaller220.class, marshaller.defaultMarshaller.getClass());
+ assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
marshaller = createVAMandRestartCache("1.3.1.GA");
- assertEquals(CacheMarshaller220.class, marshaller.defaultMarshaller.getClass());
+ assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
marshaller = createVAMandRestartCache("1.2.4.SP2");
- assertEquals(CacheMarshaller220.class, marshaller.defaultMarshaller.getClass());
+ assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
marshaller = createVAMandRestartCache("1.2.3");
- assertEquals(CacheMarshaller220.class, marshaller.defaultMarshaller.getClass());
+ assertEquals(CacheMarshaller210.class, marshaller.defaultMarshaller.getClass());
}
public void testVersionHeaderDefaultCurrent() throws Exception
16 years, 7 months
JBoss Cache SVN: r5815 - in core/trunk/src: test/java/org/jboss/cache/transaction/isolationlevels and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-09 07:48:48 -0400 (Fri, 09 May 2008)
New Revision: 5815
Modified:
core/trunk/src/main/java/org/jboss/cache/lock/LockStrategyFactory.java
core/trunk/src/test/java/org/jboss/cache/transaction/isolationlevels/SerializableTest.java
Log:
LockStrategyFactory should be non-volatile
Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockStrategyFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/LockStrategyFactory.java 2008-05-09 11:21:17 UTC (rev 5814)
+++ core/trunk/src/main/java/org/jboss/cache/lock/LockStrategyFactory.java 2008-05-09 11:48:48 UTC (rev 5815)
@@ -8,6 +8,7 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.factories.annotations.NonVolatile;
import org.jboss.cache.factories.annotations.Start;
@@ -16,6 +17,7 @@
*
* @author Ben Wang
*/
+@NonVolatile
public class LockStrategyFactory
{
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/isolationlevels/SerializableTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/isolationlevels/SerializableTest.java 2008-05-09 11:21:17 UTC (rev 5814)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/isolationlevels/SerializableTest.java 2008-05-09 11:48:48 UTC (rev 5815)
@@ -1,11 +1,13 @@
package org.jboss.cache.transaction.isolationlevels;
import org.jboss.cache.lock.IsolationLevel;
+import org.testng.annotations.Test;
/**
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.0.0
*/
+@Test(groups = "functional")
public class SerializableTest extends IsolationLevelTestBase
{
public SerializableTest()
16 years, 7 months
JBoss Cache SVN: r5814 - in core/trunk/src: main/java/org/jboss/cache/factories and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-09 07:21:17 -0400 (Fri, 09 May 2008)
New Revision: 5814
Modified:
core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
Log:
Fixed breakages
Modified: core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-05-08 16:36:55 UTC (rev 5813)
+++ core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-05-09 11:21:17 UTC (rev 5814)
@@ -21,9 +21,6 @@
* This is a special instance of a {@link ComponentFactory} which contains bootstrap information for the
* {@link org.jboss.cache.factories.ComponentRegistry}.
* <p/>
- * E.g., {@link #bootstrap(LifecycleManager , CacheSPI, org.jboss.cache.config.Configuration)} is used to create a cache, a
- * {@link org.jboss.cache.factories.ComponentRegistry}, and then wire dependencies as needed.
- * <p/>
* In JBoss Cache 2.0.x, this was a singleton and you had to use {@link #getInstance()} to obtain an instance. From
* JBoss Cache 2.1.x onwards, this is no longer a singleton and you can use the default no-arg constructor to obtain
* a reference. {@link #getInstance()} has been deprecated and modified to return a new instance of this class.
@@ -130,7 +127,6 @@
this.configuration = configuration;
componentRegistry.registerComponent(spi, CacheSPI.class);
- componentRegistry.wire();
}
/**
Modified: core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-05-08 16:36:55 UTC (rev 5813)
+++ core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-05-09 11:21:17 UTC (rev 5814)
@@ -460,14 +460,6 @@
}
/**
- * Marks state as wired. Used by the DefaultCacheFactory after it has added the BootstrapFactory and CacheSPI components.
- */
- public void wire()
- {
- state = CacheStatus.CREATED;
- }
-
- /**
* Rewires components. Can only be called if the current state is WIRED or STARTED.
*/
public void rewire()
Modified: core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2008-05-08 16:36:55 UTC (rev 5813)
+++ core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2008-05-09 11:21:17 UTC (rev 5814)
@@ -250,6 +250,7 @@
TestingUtil.extractComponentRegistry(cache1).registerComponent(barfingRpcManager, RPCManager.class);
cache1.getConfiguration().getRuntimeConfig().setRPCManager(barfingRpcManager);
+ TestingUtil.extractComponentRegistry(cache1).rewire();
try
{
16 years, 7 months
JBoss Cache SVN: r5813 - in core/trunk/src: main/java/org/jboss/cache/commands/remote and 4 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-08 12:36:55 -0400 (Thu, 08 May 2008)
New Revision: 5813
Modified:
core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java
core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
core/trunk/src/main/java/org/jboss/cache/util/reflect/ReflectionUtil.java
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
core/trunk/src/test/java/org/jboss/cache/marshall/AbstractVersionAwareMarshallerTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java
core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
Log:
Fixed breakages
Modified: core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-05-08 11:41:43 UTC (rev 5812)
+++ core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-05-08 16:36:55 UTC (rev 5813)
@@ -8,7 +8,6 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.factories.BootstrapFactory;
import org.jboss.cache.factories.ComponentFactory;
import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.factories.XmlConfigurationParser;
@@ -126,14 +125,10 @@
private void bootstrap(CacheSPI spi, Configuration configuration)
{
// injection bootstrap stuff
- componentRegistry = new ComponentRegistry(configuration);
+ componentRegistry = new ComponentRegistry(configuration, spi);
componentRegistry.registerDefaultClassLoader(defaultClassLoader);
this.configuration = configuration;
- BootstrapFactory bf = new BootstrapFactory(spi, configuration, componentRegistry);
- componentRegistry.registerComponent(bf, BootstrapFactory.class);
- // make sure we set the CacheLifecycleManager and CacheSPI instance in the component registry.
- //componentRegistry.registerComponent(lifecycleManager, LifecycleManager.class);
componentRegistry.registerComponent(spi, CacheSPI.class);
componentRegistry.wire();
}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java 2008-05-08 11:41:43 UTC (rev 5812)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java 2008-05-08 16:36:55 UTC (rev 5813)
@@ -36,7 +36,7 @@
private static final Log log = LogFactory.getLog(ClusteredGetCommand.class);
private static boolean trace = log.isTraceEnabled();
- public ClusteredGetCommand(Boolean searchBackupSubtrees, DataCommand dataCommand)
+ public ClusteredGetCommand(boolean searchBackupSubtrees, DataCommand dataCommand)
{
this.searchBackupSubtrees = searchBackupSubtrees;
this.dataCommand = dataCommand;
Modified: core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-05-08 11:41:43 UTC (rev 5812)
+++ core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-05-08 16:36:55 UTC (rev 5813)
@@ -3,6 +3,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheException;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.CacheStatus;
import org.jboss.cache.Version;
import org.jboss.cache.config.Configuration;
@@ -93,7 +94,7 @@
*
* @param configuration configuration with which this is created
*/
- public ComponentRegistry(Configuration configuration)
+ public ComponentRegistry(Configuration configuration, CacheSPI cache)
{
try
{
@@ -101,6 +102,7 @@
registerDefaultClassLoader(null);
registerComponent(this, ComponentRegistry.class);
registerComponent(configuration, Configuration.class);
+ registerComponent(new BootstrapFactory(cache, configuration, this), BootstrapFactory.class);
}
catch (Exception e)
{
@@ -186,11 +188,8 @@
*/
public void registerComponent(Object component, Class type)
{
- Component c = new Component();
+
String name = type.getName();
- c.name = name;
- c.nonVolatile = component.getClass().isAnnotationPresent(NonVolatile.class);
- c.instance = component;
Component old = componentLookup.get(name);
if (old != null)
@@ -204,17 +203,24 @@
}
}
- if (trace) log.trace("Registering component " + c + " under name " + name);
-
+ Component c;
if (old != null)
{
- if (trace) log.trace("Replacing old component " + old);
+ if (trace) log.trace("Replacing old component " + old + " with new instance " + component);
old.instance = component;
+ c = old;
+
+ if (state == CacheStatus.STARTED) populateLifecycleMethods();
}
else
{
+ c = new Component();
+ c.name = name;
+ c.instance = component;
+ if (trace) log.trace("Registering component " + c + " under name " + name);
componentLookup.put(name, c);
}
+ c.nonVolatile = component.getClass().isAnnotationPresent(NonVolatile.class);
addComponentDependencies(c);
// inject dependencies for this component
c.injectDependencies();
@@ -229,7 +235,7 @@
{
Class type = c.instance.getClass();
List<CachedMethod> methods = ReflectionUtil.getAllCachedMethods(type, Inject.class);
-
+ c.injectionMethods.clear();
for (CachedMethod m : methods) c.injectionMethods.add(m);
}
Modified: core/trunk/src/main/java/org/jboss/cache/util/reflect/ReflectionUtil.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/reflect/ReflectionUtil.java 2008-05-08 11:41:43 UTC (rev 5812)
+++ core/trunk/src/main/java/org/jboss/cache/util/reflect/ReflectionUtil.java 2008-05-08 16:36:55 UTC (rev 5813)
@@ -181,7 +181,7 @@
catch (Exception e)
{
throw new CacheException("Unable to invoke method " + method + " on object instance " + instance +
- (parameters != null ? " with parameters " + Arrays.asList(parameters) : ""));
+ (parameters != null ? " with parameters " + Arrays.asList(parameters) : ""), e);
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2008-05-08 11:41:43 UTC (rev 5812)
+++ core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2008-05-08 16:36:55 UTC (rev 5813)
@@ -12,6 +12,7 @@
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
+import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.misc.TestingUtil;
@@ -172,7 +173,9 @@
List<Address> memberList = originalRpcManager.getMembers();
expect(rpcManager.getMembers()).andReturn(memberList).anyTimes();
// inject a mock RPC manager so that we can test whether calls made are sync or async.
- TestingUtil.extractComponentRegistry(cache1).registerComponent(rpcManager, RPCManager.class);
+ ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache1);
+ cr.registerComponent(rpcManager, RPCManager.class);
+ cr.rewire();
// invalidations will not trigger any rpc call sfor PFER
if (!isUsingInvalidation())
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/AbstractVersionAwareMarshallerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/AbstractVersionAwareMarshallerTest.java 2008-05-08 11:41:43 UTC (rev 5812)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/AbstractVersionAwareMarshallerTest.java 2008-05-08 16:36:55 UTC (rev 5813)
@@ -3,7 +3,6 @@
import org.jboss.cache.CacheStatus;
import org.jboss.cache.RegionManager;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.CommandsFactory;
import org.jboss.cache.factories.ComponentRegistry;
/**
@@ -23,15 +22,14 @@
protected VersionAwareMarshaller createVAMandRestartCache(RegionManager rm)
{
- cr.registerComponent(rm, RegionManager.class);
- VersionAwareMarshaller vam = (VersionAwareMarshaller) cr.getComponent(Marshaller.class);
if (cr.getState() == CacheStatus.STARTED) cr.stop();
-
- CommandsFactory cf = cr.getComponent(CommandsFactory.class);
- if (cf == null) cf = new CommandsFactory();
- cr.registerComponent(cf, CommandsFactory.class);
-
- cr.start();
- return vam;
+ cr.registerComponent(rm, RegionManager.class);
+ cr.create();
+ cr.rewire();
+ // force cache mode
+ VersionAwareMarshaller m = (VersionAwareMarshaller) cr.getComponent(Marshaller.class);
+ m.init();
+ m.initReplicationVersions();
+ return m;
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java 2008-05-08 11:41:43 UTC (rev 5812)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java 2008-05-08 16:36:55 UTC (rev 5813)
@@ -10,7 +10,6 @@
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
import org.jboss.cache.commands.remote.ClusteredGetCommand;
-import org.jboss.cache.factories.ComponentRegistry;
import org.testng.annotations.Test;
import java.io.ByteArrayInputStream;
@@ -87,9 +86,8 @@
final CacheMarshaller200 cm200 = new CacheMarshaller200();
c.setInactiveOnStartup(false);
c.setUseRegionBasedMarshalling(true);
- ComponentRegistry cr = new ComponentRegistry(c);
cr.registerComponent(cm200, CacheMarshaller200.class);
- cr.start();
+ cr.rewire();
RegionManager rm = cr.getComponent(RegionManager.class);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -97,7 +95,7 @@
final Fqn region = Fqn.fromString("/hello");
Region r = rm.getRegion(region, true);
r.registerContextClassLoader(this.getClass().getClassLoader());
- cm200.objectToObjectStream(new ClusteredGetCommand(null, null), oos, region);
+ cm200.objectToObjectStream(new ClusteredGetCommand(false, null), oos, region);
oos.close();
final byte[] stream = baos.toByteArray();
@@ -180,7 +178,7 @@
byte magic = in.readByte();
assert magic != CacheMarshaller200.MAGICNUMBER_FQN : "The stream should NOT start with an Fqn!";
- assert magic == CacheMarshaller200.MAGICNUMBER_NULL : "Should start with a NULL";
+ assert magic == CacheMarshaller200.MAGICNUMBER_NULL : "Should start with a NULL. Instead, was " + magic;
assert in.readByte() == CacheMarshaller200.MAGICNUMBER_BOOLEAN : "Should have a boolean magic number before the boolean value";
assert in.readBoolean() : "The boolean written to the stream should be true";
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java 2008-05-08 11:41:43 UTC (rev 5812)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java 2008-05-08 16:36:55 UTC (rev 5813)
@@ -13,6 +13,7 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.ComponentRegistry;
+import org.jboss.cache.invocation.CacheInvocationDelegate;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;
import org.testng.annotations.AfterMethod;
@@ -35,14 +36,13 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- regionManager = new RegionManager();
c = new Configuration();
c.setUseRegionBasedMarshalling(false);
c.setInactiveOnStartup(false);
c.setReplVersionString(currentVersion);
- cr = new ComponentRegistry(c);
- //c.setUseReferenceCounting(true);
- marshaller = createVAMandRestartCache(regionManager);
+ cr = new ComponentRegistry(c, new CacheInvocationDelegate());
+ marshaller = createVAMandRestartCache(new RegionManager());
+ regionManager = cr.getComponent(RegionManager.class);
}
@AfterMethod(alwaysRun = true)
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java 2008-05-08 11:41:43 UTC (rev 5812)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java 2008-05-08 16:36:55 UTC (rev 5813)
@@ -13,6 +13,7 @@
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.interceptors.MarshalledValueInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.invocation.CacheInvocationDelegate;
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
import org.jboss.cache.misc.TestingUtil;
import org.jboss.cache.notifications.annotation.CacheListener;
@@ -217,7 +218,7 @@
MarshalledValue mv = new MarshalledValue(pojo);
Configuration c = new Configuration();
- ComponentRegistry cr = new ComponentRegistry(c);
+ ComponentRegistry cr = new ComponentRegistry(c, new CacheInvocationDelegate());
Marshaller marshaller = new CacheMarshaller210();
cr.registerComponent(marshaller, Marshaller.class);
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java 2008-05-08 11:41:43 UTC (rev 5812)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java 2008-05-08 16:36:55 UTC (rev 5813)
@@ -4,9 +4,7 @@
import org.jboss.cache.commands.ReversibleCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.CommandsFactory;
-import org.jboss.cache.factories.ComponentRegistry;
import static org.testng.AssertJUnit.assertEquals;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -46,7 +44,6 @@
prepareComand = new PrepareCommand(null, list, null, true);
CacheMarshaller210 cm210 = new CacheMarshaller210();
- ComponentRegistry registry = new ComponentRegistry(new Configuration());
CommandsFactory factory = new CommandsFactory();
cm210.injectCommandsFactory(factory);
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java 2008-05-08 11:41:43 UTC (rev 5812)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java 2008-05-08 16:36:55 UTC (rev 5813)
@@ -9,6 +9,7 @@
import org.jboss.cache.Version;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.ComponentRegistry;
+import org.jboss.cache.invocation.CacheInvocationDelegate;
import org.jboss.util.stream.MarshalledValueInputStream;
import static org.testng.AssertJUnit.assertEquals;
import org.testng.annotations.AfterMethod;
@@ -29,7 +30,7 @@
@BeforeMethod
public void setUp()
{
- cr = new ComponentRegistry(new Configuration());
+ cr = new ComponentRegistry(new Configuration(), new CacheInvocationDelegate());
}
@AfterMethod
16 years, 7 months
JBoss Cache SVN: r5812 - in benchmarks/benchmark-fwk/trunk/cache-products: jbosscache-2.1.0/src/org/cachebench/cachewrappers and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-08 07:41:43 -0400 (Thu, 08 May 2008)
New Revision: 5812
Modified:
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.0.0/src/org/cachebench/cachewrappers/JBossCache200Wrapper.java
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/src/org/cachebench/cachewrappers/JBossCache210Wrapper.java
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/src/org/cachebench/cachewrappers/JBossCache220Wrapper.java
Log:
Added the ability to run in LOCAL mode as well.
Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.0.0/src/org/cachebench/cachewrappers/JBossCache200Wrapper.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.0.0/src/org/cachebench/cachewrappers/JBossCache200Wrapper.java 2008-05-08 11:24:35 UTC (rev 5811)
+++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.0.0/src/org/cachebench/cachewrappers/JBossCache200Wrapper.java 2008-05-08 11:41:43 UTC (rev 5812)
@@ -17,6 +17,7 @@
{
private Cache cache;
private Log log = LogFactory.getLog(JBossCache200Wrapper.class);
+ private boolean inLocalMode;
public void init(Map parameters) throws Exception
{
@@ -27,6 +28,7 @@
log.info("Running follwing JBossCacheVersion: " + org.jboss.cache.Version.version);
log.info("Running follwing JBossCacheCodeName: " + org.jboss.cache.Version.codename);
cache = DefaultCacheFactory.getInstance().createCache(configFile);
+ inLocalMode = parameters.containsKey("localOnly");
}
public void setUp() throws Exception
@@ -59,7 +61,7 @@
public int getNumMembers()
{
- return cache.getMembers().size();
+ return inLocalMode ? 0 : cache.getMembers().size();
}
public String getInfo()
Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/src/org/cachebench/cachewrappers/JBossCache210Wrapper.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/src/org/cachebench/cachewrappers/JBossCache210Wrapper.java 2008-05-08 11:24:35 UTC (rev 5811)
+++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/src/org/cachebench/cachewrappers/JBossCache210Wrapper.java 2008-05-08 11:41:43 UTC (rev 5812)
@@ -1,14 +1,14 @@
package org.cachebench.cachewrappers;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.cachebench.CacheWrapper;
import org.jboss.cache.Cache;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.marshall.NodeData;
-import org.jboss.cache.buddyreplication.GravitateResult;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.cachebench.CacheWrapper;
import java.util.Map;
@@ -20,14 +20,16 @@
{
private Cache cache;
private Log log = LogFactory.getLog(JBossCache210Wrapper.class);
+ private boolean inLocalMode;
public void init(Map parameters) throws Exception
{
log.info("Creating cache with the following configuration: " + parameters);
- cache = DefaultCacheFactory.getInstance().createCache((String)parameters.get("config"));
+ cache = DefaultCacheFactory.getInstance().createCache((String) parameters.get("config"));
log.info("Running cache with following config: " + cache.getConfiguration());
log.info("Running follwing JBossCacheVersion: " + org.jboss.cache.Version.version);
log.info("Running follwing JBossCacheCodeName: " + org.jboss.cache.Version.codename);
+ inLocalMode = parameters.containsKey("localOnly");
}
public void setUp() throws Exception
@@ -60,7 +62,7 @@
public int getNumMembers()
{
- return cache.getMembers().size();
+ return inLocalMode ? 0 : cache.getMembers().size();
}
public String getInfo()
Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/src/org/cachebench/cachewrappers/JBossCache220Wrapper.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/src/org/cachebench/cachewrappers/JBossCache220Wrapper.java 2008-05-08 11:24:35 UTC (rev 5811)
+++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/src/org/cachebench/cachewrappers/JBossCache220Wrapper.java 2008-05-08 11:41:43 UTC (rev 5812)
@@ -3,7 +3,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.cachebench.CacheWrapper;
-import org.jboss.cache.*;
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.marshall.NodeData;
@@ -17,14 +21,16 @@
{
private Cache cache;
private Log log = LogFactory.getLog(JBossCache220Wrapper.class);
+ private boolean inLocalMode;
public void init(Map parameters) throws Exception
{
log.info("Creating cache with the following configuration: " + parameters);
- cache = DefaultCacheFactory.getInstance().createCache((String)parameters.get("config"));
+ cache = DefaultCacheFactory.getInstance().createCache((String) parameters.get("config"));
log.info("Running cache with following config: " + cache.getConfiguration());
log.info("Running follwing JBossCacheVersion: " + org.jboss.cache.Version.version);
log.info("Running follwing JBossCacheCodeName: " + org.jboss.cache.Version.codename);
+ inLocalMode = parameters.containsKey("localOnly");
}
public void setUp() throws Exception
@@ -57,7 +63,7 @@
public int getNumMembers()
{
- return cache.getMembers().size();
+ return inLocalMode ? 0 : cache.getMembers().size();
}
public String getInfo()
16 years, 7 months
JBoss Cache SVN: r5811 - in benchmarks/benchmark-fwk/trunk: cache-products/ehcache-1.4.1/conf and 8 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-08 07:24:35 -0400 (Thu, 08 May 2008)
New Revision: 5811
Added:
benchmarks/benchmark-fwk/trunk/cache-products/ehcache-1.4.1/conf/ehcache-local.xml
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.0.0/conf/pess-local.xml
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-local.xml
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/conf/pess-local.xml
benchmarks/benchmark-fwk/trunk/runLocalNode.sh
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ClusterAwareReportGenerator.java
benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/ClusteredCacheTest.java
Modified:
benchmarks/benchmark-fwk/trunk/cache-products/ehcache-1.4.1/src/org/cachebench/cachewrappers/EHCacheWrapper.java
benchmarks/benchmark-fwk/trunk/src/org/cachebench/CacheBenchmarkRunner.java
benchmarks/benchmark-fwk/trunk/src/org/cachebench/config/Configuration.java
benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ClusterReportGenerator.java
benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/ReplicationOccursTest.java
benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSimulatorTest.java
Log:
Added the ability to run in LOCAL mode as well.
Copied: benchmarks/benchmark-fwk/trunk/cache-products/ehcache-1.4.1/conf/ehcache-local.xml (from rev 5799, benchmarks/benchmark-fwk/trunk/cache-products/ehcache-1.4.1/conf/ehcache-repl-sync.xml)
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/ehcache-1.4.1/conf/ehcache-local.xml (rev 0)
+++ benchmarks/benchmark-fwk/trunk/cache-products/ehcache-1.4.1/conf/ehcache-local.xml 2008-05-08 11:24:35 UTC (rev 5811)
@@ -0,0 +1,325 @@
+<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ehcache.xsd">
+
+ <!--
+ DiskStore configuration
+
+ Sets the path to the directory where cache files are created.
+
+ If the path is a Java System Property it is replaced by its value in the
+ running VM.
+
+ The following properties are translated:
+ * user.home - User's home directory
+ * user.dir - User's current working directory
+ * java.io.tmpdir - Default temp file path
+
+ Subdirectories can be specified below the property e.g. java.io.tmpdir/one
+ -->
+ <diskStore path="java.io.tmpdir"/>
+
+ <!--
+ Specifies a CacheManagerEventListenerFactory, be used to create a CacheManagerPeerProvider,
+ which is notified when Caches are added or removed from the CacheManager.
+
+ The attributes of CacheManagerEventListenerFactory are:
+ * class - a fully qualified factory class name
+ * properties - comma separated properties having meaning only to the factory.
+
+ Sets the fully qualified class name to be registered as the CacheManager event listener.
+
+ The events include:
+ * adding a Cache
+ * removing a Cache
+
+ Callbacks to listener methods are synchronous and unsynchronized. It is the responsibility
+ of the implementer to safely handle the potential performance and thread safety issues
+ depending on what their listener is doing.
+
+ If no class is specified, no listener is created. There is no default.
+ -->
+ <cacheManagerEventListenerFactory class="" properties=""/>
+
+
+ <!--
+ (Enable for distributed operation)
+
+ Specifies a CacheManagerPeerProviderFactory which will be used to create a
+ CacheManagerPeerProvider, which discovers other CacheManagers in the cluster.
+
+ The attributes of cacheManagerPeerProviderFactory are:
+ * class - a fully qualified factory class name
+ * properties - comma separated properties having meaning only to the factory.
+
+ Ehcache comes with a built-in RMI-based distribution system with two means of discovery of
+ CacheManager peers participating in the cluster:
+ * automatic, using a multicast group. This one automatically discovers peers and detects
+ changes such as peers entering and leaving the group
+ * manual, using manual rmiURL configuration. A hardcoded list of peers is provided at
+ configuration time.
+
+ Configuring Automatic Discovery:
+ Automatic discovery is configured as per the following example:
+ <cacheManagerPeerProviderFactory
+ class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
+ properties="peerDiscovery=automatic, multicastGroupAddress=230.0.0.1,
+ multicastGroupPort=4446, timeToLive=32"/>
+
+ Valid properties are:
+ * peerDiscovery (mandatory) - specify "automatic"
+ * multicastGroupAddress (mandatory) - specify a valid multicast group address
+ * multicastGroupPort (mandatory) - specify a dedicated port for the multicast heartbeat
+ traffic
+ * timeToLive - specify a value between 0 and 255 which determines how far the packets will propagate.
+ By convention, the restrictions are:
+ 0 - the same host
+ 1 - the same subnet
+ 32 - the same site
+ 64 - the same region
+ 128 - the same continent
+ 255 - unrestricted
+
+ Configuring Manual Discovery:
+ Manual discovery is configured as per the following example:
+ <cacheManagerPeerProviderFactory class=
+ "net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
+ properties="peerDiscovery=manual,
+ rmiUrls=//server1:40000/sampleCache1|//server2:40000/sampleCache1
+ | //server1:40000/sampleCache2|//server2:40000/sampleCache2"/>
+
+ Valid properties are:
+ * peerDiscovery (mandatory) - specify "manual"
+ * rmiUrls (mandatory) - specify a pipe separated list of rmiUrls, in the form
+ //hostname:port
+
+ The hostname is the hostname of the remote CacheManager peer. The port is the listening
+ port of the RMICacheManagerPeerListener of the remote CacheManager peer.
+
+ An alternate CacheManagerPeerProviderFactory can be used for JNDI discovery of other
+ CacheManagers in the cluster. Only manual discovery is supported.
+
+ For cacheManagerPeerProviderFactory specify class
+ net.sf.ehcache.distribution.JNDIManualRMICacheManagerPeerProviderFactoryerFactory.
+
+ Correspondingly for cacheManagerPeerListenerFactory specify class
+ net.sf.ehcache.distribution.JNDIRMICacheManagerPeerListenerFactoryory.
+
+ Configuring JNDI Manual Discovery:
+ Manual JNDI discovery is configured as per the following example:
+ <cacheManagerPeerProviderFactory class=
+ "net.sf.ehcache.distribution.JNDIManualRMICacheManagerPeerProviderFactoryerFactory"
+ properties="peerDiscovery=manual, stashContexts=true, stashRemoteCachePeers=true,
+ jndiUrls=t3//server1:40000/sampleCache1|t3//server2:40000/sampleCache1
+ |t3//server1:40000/sampleCache2|t3//server2:40000/sampleCache2"/>
+
+ Valid properties are:
+ * peerDiscovery (mandatory) - specify "manual"
+ * stashContexts (optional) - specify "true" or "false". Defaults to true.
+ java.naming.Context objects are stashed for performance.
+ * stashRemoteCachePeers (optional) - specify "true" or "false". Defaults to true.
+ CachePeer objects are stashed for performance.
+ * jndiUrls (mandatory) - specify a pipe separated list of jndiUrls,
+ in the form protocol//hostname:port
+ -->
+ <cacheManagerPeerProviderFactory
+ class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
+ properties="peerDiscovery=automatic,
+ multicastGroupAddress=228.1.2.3,
+ multicastGroupPort=48866, timeToLive=64"/>
+
+
+ <!--
+ (Enable for distributed operation)
+
+ Specifies a CacheManagerPeerListenerFactory which will be used to create a
+ CacheManagerPeerListener, which
+ listens for messages from cache replicators participating in the cluster.
+
+ The attributes of cacheManagerPeerListenerFactory are:
+ class - a fully qualified factory class name
+ properties - comma separated properties having meaning only to the factory.
+
+ Ehcache comes with a built-in RMI-based distribution system. The listener component is
+ RMICacheManagerPeerListener which is configured using
+ RMICacheManagerPeerListenerFactory. It is configured as per the following example:
+
+ <cacheManagerPeerListenerFactory
+ class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
+ properties="hostName=fully_qualified_hostname_or_ip,
+ port=40001,
+ socketTimeoutMillis=120000"/>
+
+ All properties are optional. They are:
+ * hostName - the hostName of the host the listener is running on. Specify
+ where the host is multihomed and you want to control the interface over which cluster
+ messages are received. Defaults to the host name of the default interface if not
+ specified.
+ * port - the port the listener listens on. This defaults to a free port if not specified.
+ * socketTimeoutMillis - the number of ms client sockets will stay open when sending
+ messages to the listener. This should be long enough for the slowest message.
+ If not specified it defaults 120000ms.
+
+
+ An alternate CacheManagerPeerListenerFactory can be also be used for JNDI binding of
+ listeners for messages from cache replicators participating in the cluster. For
+ cacheManagerPeerListenerFactory specify
+ class net.sf.ehcache.distribution.JNDIRMICacheManagerPeerListenerFactory.
+ Correspondingly for cacheManagerPeerProviderFactory specify class
+ net.sf.ehcache.distribution.JNDIManualRMICacheManagerPeerProviderFactoryerFactory.
+ Properties for JNDIRMICacheManagerPeerListenerFactory are the same as
+ RMICacheManagerPeerListenerFactory.
+
+ -->
+ <cacheManagerPeerListenerFactory
+ class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
+ properties="hostName=127.0.0.1, socketTimeoutMillis=120000"/>
+
+
+ <!-- Cache configuration.
+
+ The following attributes are required.
+
+ name:
+ Sets the name of the cache. This is used to identify the cache. It must be unique.
+
+ maxElementsInMemory:
+ Sets the maximum number of objects that will be created in memory
+
+ maxElementsOnDisk:
+ Sets the maximum number of objects that will be maintained in the DiskStore
+ The default value is zero, meaning unlimited.
+
+ eternal:
+ Sets whether elements are eternal. If eternal, timeouts are ignored and the
+ element is never expired.
+
+ overflowToDisk:
+ Sets whether elements can overflow to disk when the memory store
+ has reached the maxInMemory limit.
+
+ The following attributes are optional.
+
+ timeToIdleSeconds:
+ Sets the time to idle for an element before it expires.
+ i.e. The maximum amount of time between accesses before an element expires
+ Is only used if the element is not eternal.
+ Optional attribute. A value of 0 means that an Element can idle for infinity.
+ The default value is 0.
+
+ timeToLiveSeconds:
+ Sets the time to live for an element before it expires.
+ i.e. The maximum time between creation time and when an element expires.
+ Is only used if the element is not eternal.
+ Optional attribute. A value of 0 means that and Element can live for infinity.
+ The default value is 0.
+
+ diskPersistent:
+ Whether the disk store persists between restarts of the Virtual Machine.
+ The default value is false.
+
+ diskExpiryThreadIntervalSeconds:
+ The number of seconds between runs of the disk expiry thread. The default value
+ is 120 seconds.
+
+ memoryStoreEvictionPolicy:
+ Policy would be enforced upon reaching the maxElementsInMemory limit. Default
+ policy is Least Recently Used (specified as LRU). Other policies available -
+ First In First Out (specified as FIFO) and Less Frequently Used
+ (specified as LFU)
+
+ Cache elements can also contain sub elements which take the same format of a factory class
+ and properties. Defined sub-elements are:
+
+ * cacheEventListenerFactory - Enables registration of listeners for cache events, such as
+ put, remove, update, and expire.
+
+ * bootstrapCacheLoaderFactory - Specifies a BootstrapCacheLoader, which is called by a
+ cache on initialisation to prepopulate itself.
+
+ Each cache that will be distributed needs to set a cache event listener which replicates
+ messages to the other CacheManager peers. For the built-in RMI implementation this is done
+ by adding a cacheEventListenerFactory element of type RMICacheReplicatorFactory to each
+ distributed cache's configuration as per the following example:
+
+ <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
+ properties="replicateAsynchronously=true,
+ replicatePuts=true,
+ replicateUpdates=true,
+ replicateUpdatesViaCopy=true,
+ replicateRemovals=true "/>
+
+ The RMICacheReplicatorFactory recognises the following properties:
+
+ * replicatePuts=true|false - whether new elements placed in a cache are
+ replicated to others. Defaults to true.
+
+ * replicateUpdates=true|false - whether new elements which override an
+ element already existing with the same key are replicated. Defaults to true.
+
+ * replicateRemovals=true - whether element removals are replicated. Defaults to true.
+
+ * replicateAsynchronously=true | false - whether replications are
+ asynchronous (true) or synchronous (false). Defaults to true.
+
+ * replicateUpdatesViaCopy=true | false - whether the new elements are
+ copied to other caches (true), or whether a remove message is sent. Defaults to true.
+
+ * asynchronousReplicationIntervalMillis=<number of milliseconds> - The asynchronous
+ replicator runs at a set interval of milliseconds. The default is 1000. The minimum
+ is 10. This property is only applicable if replicateAsynchronously=true
+
+ The RMIBootstrapCacheLoader bootstraps caches in clusters where RMICacheReplicators are
+ used. It is configured as per the following example:
+
+ <bootstrapCacheLoaderFactory
+ class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
+ properties="bootstrapAsynchronously=true, maximumChunkSizeBytes=5000000"/>
+
+ The RMIBootstrapCacheLoaderFactory recognises the following optional properties:
+
+ * bootstrapAsynchronously=true|false - whether the bootstrap happens in the background
+ after the cache has started. If false, bootstrapping must complete before the cache is
+ made available. The default value is true.
+
+ * maximumChunkSizeBytes=<integer> - Caches can potentially be very large, larger than the
+ memory limits of the VM. This property allows the bootstraper to fetched elements in
+ chunks. The default chunk size is 5000000 (5MB).
+
+ -->
+
+ <!--
+ Mandatory Default Cache configuration. These settings will be applied to caches
+ created programmtically using CacheManager.add(String cacheName)
+ -->
+ <defaultCache
+ maxElementsInMemory="10000"
+ eternal="false"
+ timeToIdleSeconds="120"
+ timeToLiveSeconds="120"
+ overflowToDisk="false"
+ maxElementsOnDisk="10000000"
+ diskPersistent="false"
+ diskExpiryThreadIntervalSeconds="120"
+ memoryStoreEvictionPolicy="LRU"
+ />
+
+ <!--
+ Sample caches. Following are some example caches. Remove these before use.
+ -->
+
+ <!--
+ NOTE that the cache benchmarking fwk looks for a cache named "cache".
+ -->
+
+ <!--
+ Sample distributed cache named sampleDistributedCache2.
+ This cache replicates using specific properties.
+ It only replicates updates and does so synchronously via copy
+ -->
+ <cache name="cache"
+ maxElementsInMemory="10000"
+ eternal="false"
+ timeToIdleSeconds="100"
+ timeToLiveSeconds="100"
+ overflowToDisk="false">
+ </cache>
+</ehcache>
Modified: benchmarks/benchmark-fwk/trunk/cache-products/ehcache-1.4.1/src/org/cachebench/cachewrappers/EHCacheWrapper.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/ehcache-1.4.1/src/org/cachebench/cachewrappers/EHCacheWrapper.java 2008-05-08 11:23:24 UTC (rev 5810)
+++ benchmarks/benchmark-fwk/trunk/cache-products/ehcache-1.4.1/src/org/cachebench/cachewrappers/EHCacheWrapper.java 2008-05-08 11:24:35 UTC (rev 5811)
@@ -51,7 +51,7 @@
}
manager = new CacheManager(c);
-
+ setUp();
logger.debug("Finish Initializing the cache");
}
@@ -144,7 +144,12 @@
*/
public Object get(Object key) throws Exception
{
- return getSerializable((Serializable) key);
+ Object s = getSerializable((Serializable) key);
+ if (s instanceof Element)
+ {
+ return ((Element) s).getValue();
+ }
+ else return s;
}
public int getNumMembers()
Added: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.0.0/conf/pess-local.xml
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.0.0/conf/pess-local.xml (rev 0)
+++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.0.0/conf/pess-local.xml 2008-05-08 11:24:35 UTC (rev 5811)
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Sample for total replication. -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<server>
+
+ <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
+
+
+ <!-- ==================================================================== -->
+ <!-- Defines TreeCache configuration -->
+ <!-- ==================================================================== -->
+
+ <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+ name="jboss.cache:service=testTreeCache">
+
+ <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>
+ <!--
+ 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">15000</attribute>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <attribute name="LockAcquisitionTimeout">10000</attribute>
+ </mbean>
+</server>
Added: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-local.xml
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-local.xml (rev 0)
+++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.1.0/conf/pess-local.xml 2008-05-08 11:24:35 UTC (rev 5811)
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Sample for total replication. -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<server>
+
+ <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
+
+
+ <!-- ==================================================================== -->
+ <!-- Defines TreeCache configuration -->
+ <!-- ==================================================================== -->
+
+ <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+ name="jboss.cache:service=testTreeCache">
+
+ <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>
+ <!--
+ 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">15000</attribute>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <attribute name="LockAcquisitionTimeout">10000</attribute>
+ </mbean>
+</server>
Copied: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/conf/pess-local.xml (from rev 5799, benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/conf/pess-repl-sync.xml)
===================================================================
--- benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/conf/pess-local.xml (rev 0)
+++ benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-2.2.0/conf/pess-local.xml 2008-05-08 11:24:35 UTC (rev 5811)
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Sample for total replication. -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<server>
+
+ <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
+
+
+ <!-- ==================================================================== -->
+ <!-- Defines TreeCache configuration -->
+ <!-- ==================================================================== -->
+
+ <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+ name="jboss.cache:service=testTreeCache">
+
+ <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>
+ <!--
+ 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">15000</attribute>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <attribute name="LockAcquisitionTimeout">10000</attribute>
+ </mbean>
+</server>
Copied: benchmarks/benchmark-fwk/trunk/runLocalNode.sh (from rev 5797, benchmarks/benchmark-fwk/trunk/runNode.sh)
===================================================================
--- benchmarks/benchmark-fwk/trunk/runLocalNode.sh (rev 0)
+++ benchmarks/benchmark-fwk/trunk/runLocalNode.sh 2008-05-08 11:24:35 UTC (rev 5811)
@@ -0,0 +1,61 @@
+#!/bin/bash
+# author: Mircea.Markus(a)jboss.com
+# cygwin users: add the scripts from :pserver:anoncvs@cygwin.com:/cvs/cygwin-apps/wrappers/java to the $cygwin_home/usr/local/bin
+# those would make an automatic conversion from unix CLASSPATH to win classpath, needed when executing java -cp
+
+preferIPv4Stack=true
+DEBUG=debug
+CACHE_PRODUCT=${1}
+TEST_CFG=${2}
+hostname=`hostname`
+PIDFILE=PID.${hostname}.pid
+
+if [ -z $1 ]
+then
+ echo Usage:
+ echo
+ echo ./runNode.sh [cache product to test] [test config file]
+ echo param [cache product to test] : must be one of the directories names under './cache-products'
+ echo param [test config file] : configuration file to use with the cache product. Typically resides in './cache-products/XXX/conf/'
+ echo
+ echo Example: './runNode.sh jbosscache-2.0.0 repl_async.xml' will start the 1st node running an instance of jbc2.0.0 in standalone [LOCAL] mode using the repl_async configuration.
+ exit 1
+fi
+
+#libraries needed by the fwk, add them to the classpath
+for JAR in ./lib/*
+do
+ CLASSPATH=$CLASSPATH:$JAR
+done
+
+export CLASSPATH=$CLASSPATH:./conf:./classes/production/Framework
+
+configFile=./cache-products/${CACHE_PRODUCT}/config.sh
+
+#first check whether the config file exists and load it
+if [ -f ${configFile} ]
+then
+ . ${configFile}
+ echo Calling ${configFile} exit code is $?
+else
+ echo could not find config file ${configFile}, aborting!
+ exit 2
+fi
+
+#. ./bindAddress.sh
+#echo bind address exit code is $?
+
+JVM_OPTIONS="${JVM_OPTIONS} -DcacheBenchFwk.cachePrioductName=${CACHE_PRODUCT} -DcacheBenchFwk.cacheConfigFile=${TEST_CFG} -Djava.net.preferIPv4Stack=${preferIPv4Stack} -DlocalOnly=true"
+TO_EXECUTE="java $JVM_OPTIONS -cp $CLASSPATH org.cachebench.CacheBenchmarkRunner"
+
+if [ "$DEBUG" = "debug" ]
+then
+ echo Executing:
+ echo ${TO_EXECUTE}
+ echo
+fi
+
+${TO_EXECUTE}
+echo $!>${PIDFILE}
+echo "Return code from benchmark runner is $?"
+
Modified: benchmarks/benchmark-fwk/trunk/src/org/cachebench/CacheBenchmarkRunner.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/CacheBenchmarkRunner.java 2008-05-08 11:23:24 UTC (rev 5810)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/CacheBenchmarkRunner.java 2008-05-08 11:24:35 UTC (rev 5811)
@@ -4,9 +4,16 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.cachebench.cluster.ClusterBarrier;
-import org.cachebench.config.*;
+import org.cachebench.config.CacheWarmupConfig;
+import org.cachebench.config.ConfigBuilder;
+import org.cachebench.config.Configuration;
+import org.cachebench.config.Report;
+import org.cachebench.config.TestCase;
+import org.cachebench.config.TestConfig;
+import org.cachebench.reportgenerators.ClusterAwareReportGenerator;
import org.cachebench.reportgenerators.ReportGenerator;
import org.cachebench.tests.CacheTest;
+import org.cachebench.tests.ClusteredCacheTest;
import org.cachebench.tests.results.BaseTestResult;
import org.cachebench.tests.results.TestResult;
import org.cachebench.utils.Instantiator;
@@ -15,9 +22,9 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.HashMap;
/**
@@ -37,6 +44,7 @@
String configuraton;
int clusterSize;
Map<String, String> systemParams = new HashMap<String, String>();
+ boolean localOnly;
public static void main(String[] args)
{
@@ -63,10 +71,12 @@
String configuraton = System.getProperty("cacheBenchFwk.cacheConfigFile");
String cacheProductName = System.getProperty("cacheBenchFwk.cachePrioductName");
String clusterSize = System.getProperty("clusterSize");
+ localOnly = Boolean.getBoolean("localOnly");
if (configuraton != null) systemParams.put("config", configuraton);
if (cacheProductName != null) systemParams.put("cacheProductName", cacheProductName);
if (clusterSize != null) systemParams.put("clusterSize", clusterSize);
+ if (localOnly) systemParams.put("localOnly", "TRUE");
}
private CacheBenchmarkRunner()
@@ -126,19 +136,19 @@
cache = getCacheWrapperInstance(test);
if (cache != null)
{
- Map<String,String> params = test.getParams();
+ Map<String, String> params = test.getParams();
// now add the config file, if any is passed in:
params.putAll(systemParams);
logger.info("Initialising cache with params " + params);
cache.init(params);
- barrier("BEFORE_WARMUP");
+ if (!localOnly) barrier("BEFORE_WARMUP");
warmupCache(test, cache);
- barrier("AFTER_WARMUP");
+ if (!localOnly) barrier("AFTER_WARMUP");
//now start testing
cache.setUp();
List<TestResult> resultsForCache = runTestsOnCache(cache, test);
- barrier("AFTER_TEST_RUN");
+ if (!localOnly) barrier("AFTER_TEST_RUN");
shutdownCache(cache);
results.addAll(resultsForCache);
}
@@ -148,7 +158,8 @@
try
{
shutdownCache(cache);
- } catch (Exception e1)
+ }
+ catch (Exception e1)
{
//ignore
}
@@ -221,17 +232,23 @@
private List<TestResult> runTestsOnCache(CacheWrapper cache, TestCase testCase)
{
List<TestResult> results = new ArrayList<TestResult>();
- for (TestConfig testConfig: testCase.getTests())
+ for (TestConfig testConfig : testCase.getTests())
{
- CacheTest testConfigClass = getCacheTest(testConfig);
- if (testConfigClass != null)
+ CacheTest testInstance = getCacheTest(testConfig);
+ if (testInstance instanceof ClusteredCacheTest && localOnly)
{
+ logger.warn("Skipping replicated tests since this is in local mode!");
+ continue;
+ }
+
+ if (testInstance != null)
+ {
TestResult result;
String testName = testConfig.getName();
String testCaseName = testCase.getName();
try
{
- result = testConfigClass.doTest(testName, cache, testCaseName, conf.getSampleSize(), conf.getNumThreads());
+ result = testInstance.doTest(testName, cache, testCaseName, conf.getSampleSize(), conf.getNumThreads());
}
catch (Exception e)
{
@@ -246,7 +263,7 @@
logger.warn("Test case : " + testCaseName + ", Test : " + testName + " - Failed due to", e);
errorLogger.error("Test case : " + testCaseName + ", Test : " + testName + " - Failed : " + e.getMessage(), e);
}
- if (!result.isTestPassed() && testCase.isStopOnFailure())
+ if (!result.isTestPassed() && testCase.isStopOnFailure())
{
logger.warn("The test '" + testCase + "/" + testName + "' failed, exiting...");
System.exit(1);
@@ -272,6 +289,8 @@
generator = getReportGenerator(report);
if (generator != null)
{
+ if (generator instanceof ClusterAwareReportGenerator && localOnly)
+ throw new IllegalArgumentException("Configured to run in local mode only, cannot use a clustered report generator!");
Map<String, String> params = report.getParams();
params.putAll(systemParams);
generator.setConfigParams(params);
@@ -283,7 +302,7 @@
}
else
{
- logger.info("Report not Generated - See logs for reasons");
+ logger.info("Report not generated - See logs for reasons!!");
}
}
catch (Exception e)
@@ -337,6 +356,7 @@
try
{
cacheTestClass = (CacheTest) Instantiator.getInstance().createClass(testConfig.getTestClass());
+ conf.setLocalOnly(localOnly);
cacheTestClass.setConfiguration(conf);
}
catch (Exception e)
Modified: benchmarks/benchmark-fwk/trunk/src/org/cachebench/config/Configuration.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/config/Configuration.java 2008-05-08 11:23:24 UTC (rev 5810)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/config/Configuration.java 2008-05-08 11:24:35 UTC (rev 5811)
@@ -14,6 +14,7 @@
private int sleepBetweenTests;
private boolean gcBetweenTestsEnabled;
private boolean emptyCacheBetweenTests;
+ private boolean localOnly;
private ClusterConfig clusterConfig;
@@ -22,7 +23,16 @@
private List<Report> reports = new ArrayList<Report>();
private int numThreads;
+ public boolean isLocalOnly()
+ {
+ return localOnly;
+ }
+ public void setLocalOnly(boolean localOnly)
+ {
+ this.localOnly = localOnly;
+ }
+
public int getSampleSize()
{
return sampleSize;
Added: benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ClusterAwareReportGenerator.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ClusterAwareReportGenerator.java (rev 0)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ClusterAwareReportGenerator.java 2008-05-08 11:24:35 UTC (rev 5811)
@@ -0,0 +1,8 @@
+package org.cachebench.reportgenerators;
+
+/**
+ * Marker interface
+ */
+public interface ClusterAwareReportGenerator extends ReportGenerator
+{
+}
Modified: benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ClusterReportGenerator.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ClusterReportGenerator.java 2008-05-08 11:23:24 UTC (rev 5810)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/reportgenerators/ClusterReportGenerator.java 2008-05-08 11:24:35 UTC (rev 5811)
@@ -17,7 +17,7 @@
*
* @author Mircea.Markus(a)jboss.com
*/
-public class ClusterReportGenerator extends AbstractReportGenerator
+public class ClusterReportGenerator extends AbstractReportGenerator implements ClusterAwareReportGenerator
{
private static Log log = LogFactory.getLog(ClusterReportGenerator.class);
private String reportGeneratorClassName;
@@ -38,6 +38,7 @@
barrier.setConfig(this.clusterConfig);
barrier.setAcknowledge(false);
barrier.barrier(results);
+
log.trace(" Starting generating. Is master? " + clusterConfig.isMaster());
if (clusterConfig.isMaster())
{
@@ -45,10 +46,13 @@
log.trace("Received following results: " + results);
generateReport(barrier.getReceivedMessages());
}
- } catch (Exception e)
+ }
+ catch (Exception e)
{
log.error("Error while generating report!", e);
- } finally {
+ }
+ finally
+ {
barrierUntilReportIsGenerated();
}
}
@@ -103,7 +107,8 @@
{
log.debug("Using generator class: " + genClassName);
return (AbstractReportGenerator) Class.forName(genClassName).newInstance();
- } catch (Exception e)
+ }
+ catch (Exception e)
{
log.error("Could not instantiate report generators", e);
throw new IllegalStateException(e);
Added: benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/ClusteredCacheTest.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/ClusteredCacheTest.java (rev 0)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/ClusteredCacheTest.java 2008-05-08 11:24:35 UTC (rev 5811)
@@ -0,0 +1,10 @@
+package org.cachebench.tests;
+
+/**
+ * Empty marker interface
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ */
+public interface ClusteredCacheTest extends CacheTest
+{
+}
Modified: benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/ReplicationOccursTest.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/ReplicationOccursTest.java 2008-05-08 11:23:24 UTC (rev 5810)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/ReplicationOccursTest.java 2008-05-08 11:24:35 UTC (rev 5811)
@@ -3,11 +3,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.cachebench.CacheWrapper;
-import org.cachebench.tests.results.StatisticTestResult;
import org.cachebench.cluster.ClusterBarrier;
import org.cachebench.config.Configuration;
import org.cachebench.config.TestCase;
import org.cachebench.config.TestConfig;
+import org.cachebench.tests.results.StatisticTestResult;
import java.net.SocketAddress;
import java.util.Collection;
@@ -19,7 +19,8 @@
*
* @author Mircea.Markus(a)jboss.com
*/
-public class ReplicationOccursTest implements CacheTest {
+public class ReplicationOccursTest implements ClusteredCacheTest
+{
public static final Log log = LogFactory.getLog(ReplicationOccursTest.class);
private Configuration conf;
@@ -27,11 +28,13 @@
private static final int REPLICATION_TRY_COUNT = 5;
private static final int REPLICATION_TRY_SLEEP = 2000;
- public void setConfiguration(Configuration configuration) {
+ public void setConfiguration(Configuration configuration)
+ {
this.conf = configuration;
}
- public StatisticTestResult doTest(String testName, CacheWrapper cache, String testCaseName, int sampleSize, int numThreads) throws Exception {
+ public StatisticTestResult doTest(String testName, CacheWrapper cache, String testCaseName, int sampleSize, int numThreads) throws Exception
+ {
log.trace("TestCase = '" + testCaseName + "', TestName = " + testName);
barrierBeforeReplicationTest();
@@ -39,7 +42,8 @@
tryToPut(cache, currentNodeIndex);
Thread.sleep(REPLICATION_TRY_SLEEP);//just to make sure that prev barrier closed its sockets etc
- if (conf.getClusterConfig().getClusterSize() == 1) {
+ if (conf.getClusterConfig().getClusterSize() == 1)
+ {
log.info("Cluster size is one, no replication expected");
StatisticTestResult result = new StatisticTestResult();
result.setTestPassed(true);
@@ -50,23 +54,29 @@
boolean allNodesReplicated = checkReplicationSeveralTimes(testName, cache, testCaseName);
Map<SocketAddress, Object> receivedValues = broadcastReplicationResult(allNodesReplicated);
- try {
+ try
+ {
cache.empty();
- } catch (Throwable e)
+ }
+ catch (Throwable e)
{
log.warn("Fail to cleanup cache after replication test", e);
}
return allReplicatedFine(receivedValues);
}
- private void tryToPut(CacheWrapper cache, Integer currentNodeIndex) throws Exception {
+ private void tryToPut(CacheWrapper cache, Integer currentNodeIndex) throws Exception
+ {
int tryCount = 0;
- while (tryCount < 5) {
- try {
+ while (tryCount < 5)
+ {
+ try
+ {
cache.put(PREFIX + currentNodeIndex, "true");
return;
}
- catch (Throwable e) {
+ catch (Throwable e)
+ {
log.warn("Error while trying to put data: ", e);
tryCount++;
}
@@ -77,9 +87,12 @@
* If caches replicate async, then try several times.
*/
private boolean checkReplicationSeveralTimes(String testName, CacheWrapper cache, String testCaseName)
- throws Exception {
- for (int i = 0; i < REPLICATION_TRY_COUNT; i++) {
- if (nodesReplicated(cache, testCaseName, testName)) {
+ throws Exception
+ {
+ for (int i = 0; i < REPLICATION_TRY_COUNT; i++)
+ {
+ if (nodesReplicated(cache, testCaseName, testName))
+ {
return true;
}
log.info("Replication test failed, " + (i + 1) + " tries so far. Sleeping for " + REPLICATION_TRY_SLEEP
@@ -90,7 +103,8 @@
}
private Map<SocketAddress, Object> broadcastReplicationResult(boolean allNodesReplicated)
- throws Exception {
+ throws Exception
+ {
ClusterBarrier barrier = new ClusterBarrier();
barrier.setConfig(conf.getClusterConfig());
barrier.barrier(String.valueOf(allNodesReplicated));
@@ -100,18 +114,22 @@
}
private void barrierBeforeReplicationTest()
- throws Exception {
+ throws Exception
+ {
ClusterBarrier barrier = new ClusterBarrier();
barrier.setAcknowledge(true);
barrier.setConfig(conf.getClusterConfig());
barrier.barrier("BEFORE_REPLICATION_OCCURS_BARRIER");
}
- private StatisticTestResult allReplicatedFine(Map<SocketAddress, Object> receivedValues) {
+ private StatisticTestResult allReplicatedFine(Map<SocketAddress, Object> receivedValues)
+ {
StatisticTestResult result = new StatisticTestResult();
result.setSkipReport(true);
- for (Object value : receivedValues.values()) {
- if (!"true".equals(value)) {
+ for (Object value : receivedValues.values())
+ {
+ if (!"true".equals(value))
+ {
log.info("Replication was not successful on the entire cluster!");
result.setTestPassed(false);
return result;
@@ -122,45 +140,57 @@
return result;
}
- private boolean isPartialReplication(String testCaseName, String testName) {
+ private boolean isPartialReplication(String testCaseName, String testName)
+ {
TestCase testCase = conf.getTestCase(testCaseName);
TestConfig thisConfig = testCase.getTest(testName);
return thisConfig.existsParam("partialReplication") &&
"true".equalsIgnoreCase(thisConfig.getParamValue("partialReplication"));
}
- private boolean nodesReplicated(CacheWrapper cache, String testCaseName, String testName) throws Exception {
+ private boolean nodesReplicated(CacheWrapper cache, String testCaseName, String testName) throws Exception
+ {
int clusterSize = conf.getClusterConfig().getClusterSize();
int replicaCount = 0;
- for (int i = 0; i < clusterSize; i++) {
+ for (int i = 0; i < clusterSize; i++)
+ {
int currentNodeIndex = conf.getClusterConfig().getCurrentNodeIndex();
- if (i == currentNodeIndex) {
+ if (i == currentNodeIndex)
+ {
continue;
}
Object data = tryGet(cache, i);
- if (data == null || !"true".equals(data)) {
+ if (data == null || !"true".equals(data))
+ {
log.trace("Cache with index " + i + " did *NOT* replicate");
- } else {
+ }
+ else
+ {
log.trace("Cache with index " + i + " replicated here ");
replicaCount++;
}
}
log.info("Number of caches that replicated here is " + replicaCount);
- if (isPartialReplication(testCaseName, testName)) {
+ if (isPartialReplication(testCaseName, testName))
+ {
return verifyClusterReplication(replicaCount);
}
return replicaCount == conf.getClusterConfig().getClusterSize() - 1;
}
- private Object tryGet(CacheWrapper cache, int i) throws Exception {
+ private Object tryGet(CacheWrapper cache, int i) throws Exception
+ {
int tryCont = 0;
while (tryCont < 5)
{
- try {
+ try
+ {
return cache.getReplicatedData(PREFIX + i);
- } catch (Throwable e) {
- tryCont ++;
}
+ catch (Throwable e)
+ {
+ tryCont++;
+ }
}
return null;
}
@@ -169,21 +199,24 @@
* Checks whether the sum of replciations across the cluster is bigger than the number of nodes in the cluster, in
* other words each node replicated at least once.
*/
- private boolean verifyClusterReplication(int replicaCount) throws Exception {
+ private boolean verifyClusterReplication(int replicaCount) throws Exception
+ {
ClusterBarrier barrier = new ClusterBarrier();
barrier.setConfig(conf.getClusterConfig());
barrier.barrier(replicaCount);
Collection recievedValues = barrier.getReceivedMessages().values();
log.trace("Recieved the following repilcation counts: " + recievedValues);
int totalValue = 0;
- for (Object val : recievedValues) {
+ for (Object val : recievedValues)
+ {
totalValue += Integer.valueOf(val.toString());
}
log.info("********** Overall replication count is: " + totalValue);
//this means SOME replication occurred. This does not mean, though, that all nodes replicated successfuly.
//correct condition would be >= this.conf.getClusterConfig().getClusterSize()
//todo/FIXME - this seem not to work with all the products, so we will accept 'some replication'
- if (totalValue < this.conf.getClusterConfig().getClusterSize()) {
+ if (totalValue < this.conf.getClusterConfig().getClusterSize())
+ {
log.warn("The replication was not total, but partial!!");
}
boolean isReplicationSuccess = totalValue > 0;
Modified: benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSimulatorTest.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSimulatorTest.java 2008-05-08 11:23:24 UTC (rev 5810)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSimulatorTest.java 2008-05-08 11:24:35 UTC (rev 5811)
@@ -8,12 +8,12 @@
import org.cachebench.config.TestConfig;
import org.cachebench.tests.results.TestResult;
+import java.util.Date;
import java.util.Random;
-import java.util.Date;
/**
* Simulates work with a web session.
- *
+ *
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
@@ -76,7 +76,7 @@
Random r = new Random();
int randomAction;
int randomAttribute;
- long start=System.currentTimeMillis();
+ long start = System.currentTimeMillis();
for (int i = 0; i < numberOfRequests; i++)
{
logRunCount(i);
@@ -90,11 +90,13 @@
buf = (byte[]) cacheWrapper.get(getSessionEntry(randomAttribute));
totalBytesRead += buf.length;
reads++;
- } catch (Throwable e)
+ }
+ catch (Throwable e)
{
- log.warn("Error appeared whilst reading from cache:" + e.getMessage());
+ log.warn("Error appeared whilst reading from cache:" + e.getMessage(), e);
}
- } else
+ }
+ else
{ // write
buf = new byte[this.sizeOfAnAttribute];
try
@@ -102,9 +104,10 @@
cacheWrapper.put(getSessionEntry(randomAttribute), buf);
totalBytesWritten += buf.length;
writes++;
- } catch (Throwable e)
+ }
+ catch (Throwable e)
{
- log.warn("Error appeared whilst writing to cache:" + e.getMessage());
+ log.warn("Error appeared whilst writing to cache:" + e.getMessage(), e);
}
}
}
@@ -122,7 +125,7 @@
{
if (i % LOG_AFTER_OPERATION_COUNT == 0)
{
- log.info("SessionSimulatorTest performed " + i + " oprations");
+ log.info("SessionSimulatorTest performed " + i + " operations");
}
}
@@ -130,11 +133,14 @@
{
for (int i = 0; i < numberOfAttributes; i++)
{
- try {
+ try
+ {
cacheWrapper.put(getSessionEntry(i), new byte[sizeOfAnAttribute]);
- } catch (Throwable e) {
- log.warn("Error while initializing the session: " , e);
}
+ catch (Throwable e)
+ {
+ log.warn("Error while initializing the session: ", e);
+ }
}
}
@@ -143,9 +149,9 @@
return sessionId + i;
}
- private void readParams ()
+ private void readParams()
{
- sessionId = SESSION_PREFIX + configuration.getClusterConfig().getCurrentNodeIndex();
+ sessionId = SESSION_PREFIX + getNodeIndex();
log.debug("Session id is: " + sessionId);
numberOfRequests = thisTestConfig.getIntValue("numberOfRequest");
numberOfAttributes = thisTestConfig.getIntValue("numberOfAttributes");
@@ -157,6 +163,6 @@
public String getNodeIndex()
{
- return configuration.getClusterConfig().getCurrentNodeIndex() + "";
+ return configuration.isLocalOnly() ? "0" : configuration.getClusterConfig().getCurrentNodeIndex() + "";
}
}
16 years, 7 months