[jbosscache-commits] JBoss Cache SVN: r7382 - in core/trunk/src: main/java/org/jboss/cache/invocation and 1 other directories.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Tue Jan 6 06:16:00 EST 2009
Author: manik.surtani at jboss.com
Date: 2009-01-06 06:15:59 -0500 (Tue, 06 Jan 2009)
New Revision: 7382
Modified:
core/trunk/src/main/java/org/jboss/cache/Cache.java
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
core/trunk/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingSetDataTest.java
Log:
Removed setData() from public interface for micro releases.
Modified: core/trunk/src/main/java/org/jboss/cache/Cache.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Cache.java 2009-01-06 11:08:41 UTC (rev 7381)
+++ core/trunk/src/main/java/org/jboss/cache/Cache.java 2009-01-06 11:15:59 UTC (rev 7382)
@@ -543,7 +543,6 @@
*
* @param i the interceptor to add
* @param position the position to add the interceptor
- *
* @since 3.0
*/
void addInterceptor(CommandInterceptor i, int position);
@@ -554,7 +553,6 @@
*
* @param i interceptor to add
* @param afterInterceptor interceptor type after which to place custom interceptor
- *
* @since 3.0
*/
void addInterceptor(CommandInterceptor i, Class<? extends CommandInterceptor> afterInterceptor);
@@ -575,30 +573,4 @@
* @since 3.0
*/
void removeInterceptor(Class<? extends CommandInterceptor> interceptorType);
-
- /**
- * Sets all of the mappings from the specified map in a {@link Node}, replacing the
- * existing data of that node, or creates a new node with the data.
- * The operation is essentially the inverse of {@link #getData(Fqn)}.
- * <p/>
- * For caches that write to a cache loader, this operation is the most efficient,
- * as the existing data need not be loaded to be merged.
- *
- * @param fqn <b><i>absolute</i></b> {@link Fqn} to the {@link Node} to set the data for
- * @param data mappings to copy
- * @throws IllegalStateException if the cache is not in a started state
- * @since 3.1
- */
- void setData(Fqn fqn, Map<? extends K, ? extends V> data);
-
- /**
- * Convenience method that takes a string representation of an Fqn. Otherwise identical to {@link #replace(Fqn, java.util.Map)}
- *
- * @param fqn String representation of the Fqn
- * @param data data map to insert
- * @throws IllegalStateException if the cache is not in a started state
- * @since 3.1
- */
- void setData(String fqn, Map<? extends K, ? extends V> data);
-
}
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2009-01-06 11:08:41 UTC (rev 7381)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2009-01-06 11:15:59 UTC (rev 7382)
@@ -23,18 +23,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.DataContainer;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.NodeNotExistsException;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.RPCManager;
-import org.jboss.cache.Region;
-import org.jboss.cache.RegionManager;
-import org.jboss.cache.Version;
+import org.jboss.cache.*;
import org.jboss.cache.batch.BatchContainer;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.buddyreplication.GravitateResult;
@@ -381,8 +370,14 @@
{
assertIsConstructed();
// assume a null ctx is meant to "un-set" the context?
- if (ctx == null) invocationContextContainer.remove();
- else invocationContextContainer.set(ctx);
+ if (ctx == null)
+ {
+ invocationContextContainer.remove();
+ }
+ else
+ {
+ invocationContextContainer.set(ctx);
+ }
}
public Address getLocalAddress()
@@ -543,7 +538,9 @@
else
{
if (log.isDebugEnabled())
+ {
log.debug("putForExternalRead() called with Fqn " + fqn + " and this node already exists. This method is hence a no op.");
+ }
}
}
@@ -608,14 +605,18 @@
public void startBatch()
{
if (!configuration.isInvocationBatchingEnabled())
+ {
throw new ConfigurationException("Invocation batching not enabled in current configuration! Please use the <invocationBatching /> element.");
+ }
batchContainer.startBatch();
}
public void endBatch(boolean successful)
{
if (!configuration.isInvocationBatchingEnabled())
+ {
throw new ConfigurationException("Invocation batching not enabled in current configuration! Please use the <invocationBatching /> element.");
+ }
batchContainer.endBatch(successful);
}
@@ -627,9 +628,13 @@
GetChildrenNamesCommand command = commandsFactory.buildGetChildrenNamesCommand(fqn);
Set<Object> retval = (Set<Object>) invoker.invoke(ctx, command);
if (retval != null)
+ {
retval = Immutables.immutableSetWrap(retval); // this is already copied in the command
+ }
else
+ {
retval = Collections.emptySet();
+ }
return retval;
}
@@ -657,8 +662,9 @@
throw new IllegalStateException("Cache not in STARTED state!");
}
}
-
- private void invokePut(Fqn fqn, Map<? extends K, ? extends V> data, boolean erase) {
+
+ private void invokePut(Fqn fqn, Map<? extends K, ? extends V> data, boolean erase)
+ {
InvocationContext ctx = invocationContextContainer.get();
cacheStatusCheck(ctx);
PutDataMapCommand command = commandsFactory.buildPutDataMapCommand(null, fqn, data);
@@ -666,6 +672,8 @@
invoker.invoke(ctx, command);
}
+
+ // TODO: Add these to the public interface in 3.1.0.
public void setData(Fqn fqn, Map<? extends K, ? extends V> data)
{
invokePut(fqn, data, true);
Modified: core/trunk/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingSetDataTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingSetDataTest.java 2009-01-06 11:08:41 UTC (rev 7381)
+++ core/trunk/src/test/java/org/jboss/cache/loader/UnnecessaryLoadingSetDataTest.java 2009-01-06 11:15:59 UTC (rev 7382)
@@ -1,13 +1,6 @@
package org.jboss.cache.loader;
import static org.easymock.EasyMock.*;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertTrue;
-import static org.testng.AssertJUnit.assertEquals;
-
-import java.util.HashMap;
-import java.util.Map;
-
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.NodeSPI;
@@ -16,16 +9,23 @@
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.util.CachePrinter;
import org.jboss.cache.util.TestingUtil;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertTrue;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* TODO merge with {@link UnnecessaryLoadingTest}.
+ *
* @author Elias Ross
* @since 3.0.0
*/
- at Test(groups = {"functional", "mvcc"})
+ at Test(groups = {"functional", "mvcc"}, enabled = false, description = "To do with the setData() method on Cache, which will only be valid in 3.1.0.GA.")
public class UnnecessaryLoadingSetDataTest
{
private CacheSPI<Object, Object> cache;
@@ -33,12 +33,13 @@
private Fqn parent = Fqn.fromString("/parent");
@DataProvider(name = "locking")
- public Object[][] createData1() {
- return new Object[][] {
- // TODO
- // { NodeLockingScheme.PESSIMISTIC },
- { NodeLockingScheme.MVCC },
- };
+ public Object[][] createData1()
+ {
+ return new Object[][]{
+ // TODO
+ // { NodeLockingScheme.PESSIMISTIC },
+ {NodeLockingScheme.MVCC},
+ };
}
private void setUp(NodeLockingScheme locking) throws Exception
@@ -56,8 +57,9 @@
reset(mockCacheLoader);
}
-
- public static CacheLoader createMockCacheLoader() throws Exception {
+
+ public static CacheLoader createMockCacheLoader() throws Exception
+ {
CacheLoader mockCacheLoader = createMock(CacheLoader.class);
expect(mockCacheLoader.getConfig()).andReturn(null).anyTimes();
@@ -76,7 +78,7 @@
replay(mockCacheLoader);
return mockCacheLoader;
}
-
+
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
@@ -97,7 +99,7 @@
replay(mockCacheLoader);
TestingUtil.killCaches(cache);
- cache = null;
+ cache = null;
}
protected void assertDataLoaded(Fqn f)
@@ -111,18 +113,18 @@
assertFalse("Data should not be loaded for node " + f, n != null && n.isDataLoaded());
}
- @Test(dataProvider="locking")
+ @Test(dataProvider = "locking")
public void testDontLoadWithSetData(NodeLockingScheme locking) throws Exception
{
System.err.println(locking);
System.err.println(locking);
setUp(locking);
-
+
Map<Object, Object> m0 = new HashMap<Object, Object>();
m0.put("replace", "replace");
Map<Object, Object> m1 = new HashMap<Object, Object>();
m1.put("new", "new");
-
+
mockCacheLoader.put(eq(parent), eq(m0));
mockCacheLoader.put(eq(parent), eq(m1));
mockCacheLoader.put(eq(parent), eq(m0));
@@ -131,19 +133,19 @@
mockCacheLoader.exists(parent);
expectLastCall().andStubThrow(new IllegalStateException("no need to call exists()"));
replay(mockCacheLoader);
-
+
assertDataNotLoaded(parent);
- cache.setData(parent, m0);
+// cache.setData(parent, m0);
assertDataLoaded(parent);
- cache.setData(parent, m1);
+// cache.setData(parent, m1);
assertEquals(m1, cache.peek(parent, false).getData());
-
+
// force removal, see if load happens
cache.evict(parent);
- cache.setData(parent, m0);
+// cache.setData(parent, m0);
// assertDataLoaded(parent);
assertEquals(m0, cache.peek(parent, false).getData());
-
+
verify(mockCacheLoader);
CachePrinter.printCacheDetails(cache);
cache.toString();
More information about the jbosscache-commits
mailing list