JBoss Cache SVN: r6432 - core/trunk/src/main/java/org/jboss/cache/commands/write.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-30 06:39:40 -0400 (Wed, 30 Jul 2008)
New Revision: 6432
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java
Log:
Added debug
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java 2008-07-30 09:27:21 UTC (rev 6431)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java 2008-07-30 10:39:40 UTC (rev 6432)
@@ -64,6 +64,8 @@
}
Object oldValue = n.putDirect(key, value);
+ if (trace) log.trace("Old value is " + oldValue + ", dataLoaded=" + n.isDataLoaded());
+
if (notifier.shouldNotifyOnNodeModified())
{
Map newData = Collections.singletonMap(key, value);
16 years, 5 months
JBoss Cache SVN: r6431 - core/trunk/src/test/java/org/jboss/cache/commands/read.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-30 05:27:21 -0400 (Wed, 30 Jul 2008)
New Revision: 6431
Removed:
core/trunk/src/test/java/org/jboss/cache/commands/read/GravitateDataCommandTest.java
Log:
Updated GravitateDataCommand test
Deleted: core/trunk/src/test/java/org/jboss/cache/commands/read/GravitateDataCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/read/GravitateDataCommandTest.java 2008-07-30 09:26:18 UTC (rev 6430)
+++ core/trunk/src/test/java/org/jboss/cache/commands/read/GravitateDataCommandTest.java 2008-07-30 09:27:21 UTC (rev 6431)
@@ -1,148 +0,0 @@
-package org.jboss.cache.commands.read;
-
-import static org.easymock.EasyMock.createStrictControl;
-import static org.easymock.EasyMock.expect;
-import org.easymock.IMocksControl;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
-import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.buddyreplication.GravitateResult;
-import org.jboss.cache.invocation.InvocationContext;
-import org.jboss.cache.invocation.LegacyInvocationContext;
-import org.jboss.cache.mock.MockNodesFixture;
-import org.jboss.cache.mock.NodeSpiMock;
-import org.jgroups.stack.IpAddress;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.util.ArrayList;
-import java.util.Collections;
-
-/**
- * Tester class for {@link org.jboss.cache.commands.read.GravitateDataCommand}
- *
- * @author Mircea.Markus(a)jboss.com
- * @since 2.2
- */
-@Test(groups = "unit")
-public class GravitateDataCommandTest
-{
- GravitateDataCommand command;
- DataContainer containerMock;
- CacheSPI spiMock;
- IMocksControl control;
- Fqn fqn = Fqn.fromString("/dummy");
- InvocationContext ctx;
- BuddyFqnTransformer fqnTransformer = new BuddyFqnTransformer();
-
- @BeforeMethod
- public void setUp()
- {
- control = createStrictControl();
- containerMock = control.createMock(DataContainer.class);
- spiMock = control.createMock(CacheSPI.class);
- command = new GravitateDataCommand(fqn, true, new IpAddress());
- command.initialize(containerMock, spiMock, new BuddyFqnTransformer());
- ctx = new LegacyInvocationContext(containerMock);
- }
-
- public void testNonexistentNode()
- {
- command.setSearchSubtrees(false);
- expect(spiMock.getNode(fqn)).andReturn(null);
- control.replay();
- assert GravitateResult.noDataFound().equals(command.perform(ctx));
- }
-
- public void testExistentNodeInTheCache()
- {
- MockNodesFixture nodes = new MockNodesFixture();
- command.setSearchSubtrees(false);
-
- expect(spiMock.getNode(fqn)).andReturn(nodes.adfNode);
- ArrayList arrayList = new ArrayList();
- expect(containerMock.buildNodeData(Collections.EMPTY_LIST, nodes.adfNode, false)).andReturn(arrayList);
- control.replay();
- GravitateResult result = (GravitateResult) command.perform(ctx);
- control.verify();
-
- assert result != null;
- assert result.getNodeData() == arrayList;
- }
-
- public void testNodeDoesExistsInBackupAndNoDead()
- {
- MockNodesFixture nodes = new MockNodesFixture();
- expect(spiMock.getNode(fqn)).andReturn(null);
- expect(containerMock.peek(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN)).andReturn(nodes.abNode);
-
- Fqn firstSearch = Fqn.fromString(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN + "/c/dummy");
- expect(spiMock.getNode(firstSearch)).andReturn(nodes.abcNode);
-
- ArrayList listReference = new ArrayList();
- expect(containerMock.buildNodeData(Collections.EMPTY_LIST, nodes.abcNode, false)).andReturn(listReference);
-
- control.replay();
- GravitateResult result = (GravitateResult) command.perform(ctx);
- assert result.getNodeData() == listReference;
- control.verify();
- }
-
- public void testNodeDoesNotExistsInBackupAndNoDead()
- {
- MockNodesFixture nodes = new MockNodesFixture();
- expect(spiMock.getNode(fqn)).andReturn(null);
- expect(containerMock.peek(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN)).andReturn(nodes.adfNode);
-
- control.checkOrder(false);
- Fqn firstSearch = Fqn.fromString(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN + "/g/dummy");
- expect(spiMock.getNode(firstSearch)).andReturn(null);
- Fqn secondSearch = Fqn.fromString(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN + "/h/dummy");
- expect(spiMock.getNode(secondSearch)).andReturn(null);
- control.checkOrder(true);
-
- control.replay();
- assert GravitateResult.noDataFound().equals(command.perform(ctx));
- control.verify();
- }
-
- public void testDeadBeackup() throws Exception
- {
- NodeSpiMock root = new NodeSpiMock(Fqn.ROOT);
-
- //add first dead child
- IpAddress firstAddress = new IpAddress("127.0.0.1", 1234);
- NodeSpiMock firstDeadNode = (NodeSpiMock) root.addChildDirect(fqnTransformer.getDeadBackupRoot(firstAddress));
- firstDeadNode.addChildDirect(Fqn.fromElements(0));
- firstDeadNode.addChildDirect(Fqn.fromElements(1));
- firstDeadNode.addChildDirect(Fqn.fromElements(2));
-
- //add second dead child
- IpAddress secondAddress = new IpAddress("127.0.0.1", 4321);
- NodeSpiMock secondDeadNode = (NodeSpiMock) root.addChildDirect(fqnTransformer.getDeadBackupRoot(secondAddress));
- secondDeadNode.addChildDirect(Fqn.fromElements(0));
-
-
- expect(spiMock.getNode(fqn)).andReturn(null);
- NodeSPI buddyBackupRoot = (NodeSPI) root.getChild(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
- expect(containerMock.peek(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN)).andReturn(buddyBackupRoot);
-
- control.checkOrder(false);
- expect(spiMock.getChildrenNames(firstDeadNode.getFqn())).andReturn(firstDeadNode.getChildrenNames());
- Object fqnElement = fqn.getLastElement();//this is only composed from one element
- expect(spiMock.peek(Fqn.fromRelativeElements(firstDeadNode.getFqn(), 0, fqnElement), false)).andReturn(null);
- expect(spiMock.peek(Fqn.fromRelativeElements(firstDeadNode.getFqn(), 1, fqnElement), false)).andReturn(null);
- expect(spiMock.peek(Fqn.fromRelativeElements(firstDeadNode.getFqn(), 2, fqnElement), false)).andReturn(null);
-
- expect(spiMock.getChildrenNames(secondDeadNode.getFqn())).andReturn(secondDeadNode.getChildrenNames());
- expect(spiMock.peek(Fqn.fromRelativeElements(secondDeadNode.getFqn(), 0, fqnElement), false)).andReturn(null);
- control.checkOrder(true);
-
- control.replay();
- assert GravitateResult.noDataFound().equals(command.perform(ctx));
- control.verify();
- }
-}
16 years, 5 months
JBoss Cache SVN: r6430 - in core/trunk/src: main/java/org/jboss/cache/commands/read and 2 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-30 05:26:18 -0400 (Wed, 30 Jul 2008)
New Revision: 6430
Added:
core/trunk/src/test/java/org/jboss/cache/commands/legacy/read/
core/trunk/src/test/java/org/jboss/cache/commands/legacy/read/GravitateDataCommandTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/legacy/read/LegacyGravitateDataCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java
Log:
Updated GravitateDataCommand test
Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/read/LegacyGravitateDataCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/legacy/read/LegacyGravitateDataCommand.java 2008-07-30 09:20:46 UTC (rev 6429)
+++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/read/LegacyGravitateDataCommand.java 2008-07-30 09:26:18 UTC (rev 6430)
@@ -30,10 +30,16 @@
* @return a Set of child node names that hang directly off the backup tree root, or null if the backup tree root doesn't exist.
*/
@Override
+ @SuppressWarnings("unchecked")
protected Set<Object> getBackupRoots()
{
NodeSPI backupSubtree = dataContainer.peek(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
if (backupSubtree == null) return null;
return backupSubtree.getChildrenNamesDirect();
}
+
+ void setSearchSubtrees(boolean searchSubtrees)
+ {
+ this.searchSubtrees = searchSubtrees;
+ }
}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java 2008-07-30 09:20:46 UTC (rev 6429)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java 2008-07-30 09:26:18 UTC (rev 6430)
@@ -38,7 +38,7 @@
private CacheSPI spi;
/* parametres */
- private boolean searchSubtrees;
+ protected boolean searchSubtrees;
private Address localAddress;
private static final Log log = LogFactory.getLog(GravitateDataCommand.class);
@@ -241,9 +241,4 @@
", searchSubtrees=" + searchSubtrees +
'}';
}
-
- void setSearchSubtrees(boolean searchSubtrees)
- {
- this.searchSubtrees = searchSubtrees;
- }
}
Copied: core/trunk/src/test/java/org/jboss/cache/commands/legacy/read/GravitateDataCommandTest.java (from rev 6425, core/trunk/src/test/java/org/jboss/cache/commands/read/GravitateDataCommandTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/legacy/read/GravitateDataCommandTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/commands/legacy/read/GravitateDataCommandTest.java 2008-07-30 09:26:18 UTC (rev 6430)
@@ -0,0 +1,148 @@
+package org.jboss.cache.commands.legacy.read;
+
+import static org.easymock.EasyMock.createStrictControl;
+import static org.easymock.EasyMock.expect;
+import org.easymock.IMocksControl;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DataContainer;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
+import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.buddyreplication.GravitateResult;
+import org.jboss.cache.invocation.InvocationContext;
+import org.jboss.cache.invocation.LegacyInvocationContext;
+import org.jboss.cache.mock.MockNodesFixture;
+import org.jboss.cache.mock.NodeSpiMock;
+import org.jgroups.stack.IpAddress;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.Collections;
+
+/**
+ * Tester class for {@link org.jboss.cache.commands.read.GravitateDataCommand}
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 2.2
+ */
+@Test(groups = "unit")
+public class GravitateDataCommandTest
+{
+ LegacyGravitateDataCommand command;
+ DataContainer containerMock;
+ CacheSPI spiMock;
+ IMocksControl control;
+ Fqn fqn = Fqn.fromString("/dummy");
+ InvocationContext ctx;
+ BuddyFqnTransformer fqnTransformer = new BuddyFqnTransformer();
+
+ @BeforeMethod
+ public void setUp()
+ {
+ control = createStrictControl();
+ containerMock = control.createMock(DataContainer.class);
+ spiMock = control.createMock(CacheSPI.class);
+ command = new LegacyGravitateDataCommand(fqn, true, new IpAddress());
+ command.initialize(containerMock, spiMock, new BuddyFqnTransformer());
+ ctx = new LegacyInvocationContext(containerMock);
+ }
+
+ public void testNonexistentNode()
+ {
+ command.setSearchSubtrees(false);
+ expect(spiMock.getNode(fqn)).andReturn(null);
+ control.replay();
+ assert GravitateResult.noDataFound().equals(command.perform(ctx));
+ }
+
+ public void testExistentNodeInTheCache()
+ {
+ MockNodesFixture nodes = new MockNodesFixture();
+ command.setSearchSubtrees(false);
+
+ expect(spiMock.getNode(fqn)).andReturn(nodes.adfNode);
+ ArrayList arrayList = new ArrayList();
+ expect(containerMock.buildNodeData(Collections.EMPTY_LIST, nodes.adfNode, false)).andReturn(arrayList);
+ control.replay();
+ GravitateResult result = (GravitateResult) command.perform(ctx);
+ control.verify();
+
+ assert result != null;
+ assert result.getNodeData() == arrayList;
+ }
+
+ public void testNodeDoesExistsInBackupAndNoDead()
+ {
+ MockNodesFixture nodes = new MockNodesFixture();
+ expect(spiMock.getNode(fqn)).andReturn(null);
+ expect(containerMock.peek(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN)).andReturn(nodes.abNode);
+
+ Fqn firstSearch = Fqn.fromString(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN + "/c/dummy");
+ expect(spiMock.getNode(firstSearch)).andReturn(nodes.abcNode);
+
+ ArrayList listReference = new ArrayList();
+ expect(containerMock.buildNodeData(Collections.EMPTY_LIST, nodes.abcNode, false)).andReturn(listReference);
+
+ control.replay();
+ GravitateResult result = (GravitateResult) command.perform(ctx);
+ assert result.getNodeData() == listReference;
+ control.verify();
+ }
+
+ public void testNodeDoesNotExistsInBackupAndNoDead()
+ {
+ MockNodesFixture nodes = new MockNodesFixture();
+ expect(spiMock.getNode(fqn)).andReturn(null);
+ expect(containerMock.peek(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN)).andReturn(nodes.adfNode);
+
+ control.checkOrder(false);
+ Fqn firstSearch = Fqn.fromString(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN + "/g/dummy");
+ expect(spiMock.getNode(firstSearch)).andReturn(null);
+ Fqn secondSearch = Fqn.fromString(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN + "/h/dummy");
+ expect(spiMock.getNode(secondSearch)).andReturn(null);
+ control.checkOrder(true);
+
+ control.replay();
+ assert GravitateResult.noDataFound().equals(command.perform(ctx));
+ control.verify();
+ }
+
+ public void testDeadBeackup() throws Exception
+ {
+ NodeSpiMock root = new NodeSpiMock(Fqn.ROOT);
+
+ //add first dead child
+ IpAddress firstAddress = new IpAddress("127.0.0.1", 1234);
+ NodeSpiMock firstDeadNode = (NodeSpiMock) root.addChildDirect(fqnTransformer.getDeadBackupRoot(firstAddress));
+ firstDeadNode.addChildDirect(Fqn.fromElements(0));
+ firstDeadNode.addChildDirect(Fqn.fromElements(1));
+ firstDeadNode.addChildDirect(Fqn.fromElements(2));
+
+ //add second dead child
+ IpAddress secondAddress = new IpAddress("127.0.0.1", 4321);
+ NodeSpiMock secondDeadNode = (NodeSpiMock) root.addChildDirect(fqnTransformer.getDeadBackupRoot(secondAddress));
+ secondDeadNode.addChildDirect(Fqn.fromElements(0));
+
+
+ expect(spiMock.getNode(fqn)).andReturn(null);
+ NodeSPI buddyBackupRoot = (NodeSPI) root.getChild(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
+ expect(containerMock.peek(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN)).andReturn(buddyBackupRoot);
+
+ control.checkOrder(false);
+ expect(spiMock.getChildrenNames(firstDeadNode.getFqn())).andReturn(firstDeadNode.getChildrenNames());
+ Object fqnElement = fqn.getLastElement();//this is only composed from one element
+ expect(spiMock.peek(Fqn.fromRelativeElements(firstDeadNode.getFqn(), 0, fqnElement), false)).andReturn(null);
+ expect(spiMock.peek(Fqn.fromRelativeElements(firstDeadNode.getFqn(), 1, fqnElement), false)).andReturn(null);
+ expect(spiMock.peek(Fqn.fromRelativeElements(firstDeadNode.getFqn(), 2, fqnElement), false)).andReturn(null);
+
+ expect(spiMock.getChildrenNames(secondDeadNode.getFqn())).andReturn(secondDeadNode.getChildrenNames());
+ expect(spiMock.peek(Fqn.fromRelativeElements(secondDeadNode.getFqn(), 0, fqnElement), false)).andReturn(null);
+ control.checkOrder(true);
+
+ control.replay();
+ assert GravitateResult.noDataFound().equals(command.perform(ctx));
+ control.verify();
+ }
+}
16 years, 5 months
JBoss Cache SVN: r6429 - core/trunk/src/test/java/org/jboss/cache/api/nodevalidity.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-30 05:20:46 -0400 (Wed, 30 Jul 2008)
New Revision: 6429
Modified:
core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedPessNodeValidityTest.java
Log:
Disable state transfer for this test
Modified: core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedPessNodeValidityTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedPessNodeValidityTest.java 2008-07-30 09:12:38 UTC (rev 6428)
+++ core/trunk/src/test/java/org/jboss/cache/api/nodevalidity/InvalidatedPessNodeValidityTest.java 2008-07-30 09:20:46 UTC (rev 6429)
@@ -56,6 +56,8 @@
CacheLoaderConfig clc = new CacheLoaderConfig();
clc.addIndividualCacheLoaderConfig(iclc);
cache.getConfiguration().setCacheLoaderConfig(clc);
+ // disable state transfer!!
+ cache.getConfiguration().setFetchInMemoryState(false);
cache.start();
16 years, 5 months
JBoss Cache SVN: r6428 - core/branches/2.2.X/src/main/java/org/jboss/cache/util.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-30 05:12:38 -0400 (Wed, 30 Jul 2008)
New Revision: 6428
Modified:
core/branches/2.2.X/src/main/java/org/jboss/cache/util/ImmutableListCopy.java
core/branches/2.2.X/src/main/java/org/jboss/cache/util/ImmutableSetCopy.java
Log:
Made immutable collections externalizable
Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/util/ImmutableListCopy.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/util/ImmutableListCopy.java 2008-07-30 09:10:13 UTC (rev 6427)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/util/ImmutableListCopy.java 2008-07-30 09:12:38 UTC (rev 6428)
@@ -2,6 +2,10 @@
import net.jcip.annotations.Immutable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.lang.reflect.Array;
import java.util.AbstractList;
import java.util.Collection;
@@ -22,12 +26,14 @@
* <p/>
*
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
*/
@Immutable
-public class ImmutableListCopy<E> extends AbstractList<E>
+public class ImmutableListCopy<E> extends AbstractList<E> implements Externalizable
{
- private final E[] elements;
- private final int size;
+ private static final long serialVersionUID = 10929568968966L;
+ private E[] elements;
+ private int size;
/**
* Only one copy constructor since the list is immutable.
@@ -156,7 +162,7 @@
public final E get(int index)
{
- assertIndexInRange(index);
+ if (index >= size || index < 0) throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
return elements[index];
}
@@ -218,11 +224,35 @@
return new ImmutableSubList<E>(fromIndex, toIndex);
}
- private void assertIndexInRange(int index)
+ /**
+ * Format:
+ * - entry array size (int)
+ * - elements (Object)
+ *
+ * @param out stream to write to
+ * @throws IOException
+ */
+ public void writeExternal(ObjectOutput out) throws IOException
{
- if (index >= size || index < 0) throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
+ out.writeInt(size);
+ for (E e : elements) out.writeObject(e);
}
+ /**
+ * See {@link #writeExternal(java.io.ObjectOutput)} for serialization format
+ *
+ * @param in stream
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ @SuppressWarnings("unchecked")
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ size = in.readInt();
+ elements = (E[]) new Object[size];
+ for (int i = 0; i < size; i++) elements[i] = (E) in.readObject();
+ }
+
private class ImmutableIterator implements ListIterator<E>
{
int cursor = 0;
@@ -305,7 +335,7 @@
ImmutableSubList(int fromIndex, int toIndex)
{
if (fromIndex < 0 || toIndex > ImmutableListCopy.this.size || fromIndex > toIndex)
- throw new IllegalArgumentException("fromIndex(" + fromIndex + "), toIndex(" + toIndex + "), size (" + ImmutableListCopy.this.size + ")");
+ throw new IllegalArgumentException("fromIndex(" + fromIndex + "), toIndex(" + toIndex + "), size (" + ImmutableListCopy.this.size + "), List=" + ImmutableListCopy.this.toString());
offset = fromIndex;
size = toIndex - fromIndex;
}
Modified: core/branches/2.2.X/src/main/java/org/jboss/cache/util/ImmutableSetCopy.java
===================================================================
--- core/branches/2.2.X/src/main/java/org/jboss/cache/util/ImmutableSetCopy.java 2008-07-30 09:10:13 UTC (rev 6427)
+++ core/branches/2.2.X/src/main/java/org/jboss/cache/util/ImmutableSetCopy.java 2008-07-30 09:12:38 UTC (rev 6428)
@@ -2,6 +2,10 @@
import net.jcip.annotations.Immutable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.AbstractSet;
import java.util.Collection;
import java.util.Iterator;
@@ -20,12 +24,14 @@
*
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @see org.jboss.cache.util.ImmutableListCopy
+ * @since 3.0
*/
@Immutable
-public class ImmutableSetCopy<E> extends AbstractSet<E>
+public class ImmutableSetCopy<E> extends AbstractSet<E> implements Externalizable
{
- private final E[] elements;
- private final int size;
+ private static final long serialVersionUID = 11929568968766L;
+ private E[] elements;
+ private int size;
@SuppressWarnings("unchecked")
public ImmutableSetCopy(Collection<E> set)
@@ -105,4 +111,33 @@
{
return size;
}
+
+ /**
+ * Format:
+ * - entry array size (int)
+ * - elements (Object)
+ *
+ * @param out stream to write to
+ * @throws IOException
+ */
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ out.writeInt(size);
+ for (E e : elements) out.writeObject(e);
+ }
+
+ /**
+ * See {@link #writeExternal(java.io.ObjectOutput)} for serialization format
+ *
+ * @param in stream
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ @SuppressWarnings("unchecked")
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ size = in.readInt();
+ elements = (E[]) new Object[size];
+ for (int i = 0; i < size; i++) elements[i] = (E) in.readObject();
+ }
}
16 years, 5 months
JBoss Cache SVN: r6427 - core/trunk/src/main/java/org/jboss/cache/util.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-30 05:10:13 -0400 (Wed, 30 Jul 2008)
New Revision: 6427
Modified:
core/trunk/src/main/java/org/jboss/cache/util/ImmutableListCopy.java
core/trunk/src/main/java/org/jboss/cache/util/ImmutableMapCopy.java
core/trunk/src/main/java/org/jboss/cache/util/ImmutableSetCopy.java
Log:
Made immutable collections externalizable
Modified: core/trunk/src/main/java/org/jboss/cache/util/ImmutableListCopy.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/ImmutableListCopy.java 2008-07-30 09:01:40 UTC (rev 6426)
+++ core/trunk/src/main/java/org/jboss/cache/util/ImmutableListCopy.java 2008-07-30 09:10:13 UTC (rev 6427)
@@ -2,6 +2,10 @@
import net.jcip.annotations.Immutable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.lang.reflect.Array;
import java.util.AbstractList;
import java.util.Collection;
@@ -25,10 +29,11 @@
* @since 3.0
*/
@Immutable
-public class ImmutableListCopy<E> extends AbstractList<E>
+public class ImmutableListCopy<E> extends AbstractList<E> implements Externalizable
{
- private final E[] elements;
- private final int size;
+ private static final long serialVersionUID = 10929568968966L;
+ private E[] elements;
+ private int size;
/**
* Only one copy constructor since the list is immutable.
@@ -219,6 +224,35 @@
return new ImmutableSubList<E>(fromIndex, toIndex);
}
+ /**
+ * Format:
+ * - entry array size (int)
+ * - elements (Object)
+ *
+ * @param out stream to write to
+ * @throws IOException
+ */
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ out.writeInt(size);
+ for (E e : elements) out.writeObject(e);
+ }
+
+ /**
+ * See {@link #writeExternal(java.io.ObjectOutput)} for serialization format
+ *
+ * @param in stream
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ @SuppressWarnings("unchecked")
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ size = in.readInt();
+ elements = (E[]) new Object[size];
+ for (int i = 0; i < size; i++) elements[i] = (E) in.readObject();
+ }
+
private class ImmutableIterator implements ListIterator<E>
{
int cursor = 0;
Modified: core/trunk/src/main/java/org/jboss/cache/util/ImmutableMapCopy.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/ImmutableMapCopy.java 2008-07-30 09:01:40 UTC (rev 6426)
+++ core/trunk/src/main/java/org/jboss/cache/util/ImmutableMapCopy.java 2008-07-30 09:10:13 UTC (rev 6427)
@@ -26,6 +26,7 @@
@Immutable
public class ImmutableMapCopy<K, V> extends AbstractMap<K, V> implements Externalizable // externalizable for client code that may serialize this map
{
+ private static final long serialVersionUID = 10929568968766L;
private Entry<K, V>[] table;
private int size;
Modified: core/trunk/src/main/java/org/jboss/cache/util/ImmutableSetCopy.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/ImmutableSetCopy.java 2008-07-30 09:01:40 UTC (rev 6426)
+++ core/trunk/src/main/java/org/jboss/cache/util/ImmutableSetCopy.java 2008-07-30 09:10:13 UTC (rev 6427)
@@ -2,6 +2,10 @@
import net.jcip.annotations.Immutable;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.util.AbstractSet;
import java.util.Collection;
import java.util.Iterator;
@@ -23,10 +27,11 @@
* @since 3.0
*/
@Immutable
-public class ImmutableSetCopy<E> extends AbstractSet<E>
+public class ImmutableSetCopy<E> extends AbstractSet<E> implements Externalizable
{
- private final E[] elements;
- private final int size;
+ private static final long serialVersionUID = 11929568968766L;
+ private E[] elements;
+ private int size;
@SuppressWarnings("unchecked")
public ImmutableSetCopy(Collection<E> set)
@@ -106,4 +111,33 @@
{
return size;
}
+
+ /**
+ * Format:
+ * - entry array size (int)
+ * - elements (Object)
+ *
+ * @param out stream to write to
+ * @throws IOException
+ */
+ public void writeExternal(ObjectOutput out) throws IOException
+ {
+ out.writeInt(size);
+ for (E e : elements) out.writeObject(e);
+ }
+
+ /**
+ * See {@link #writeExternal(java.io.ObjectOutput)} for serialization format
+ *
+ * @param in stream
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ @SuppressWarnings("unchecked")
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+ {
+ size = in.readInt();
+ elements = (E[]) new Object[size];
+ for (int i = 0; i < size; i++) elements[i] = (E) in.readObject();
+ }
}
16 years, 5 months
JBoss Cache SVN: r6426 - core/trunk/src/main/java/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-30 05:01:40 -0400 (Wed, 30 Jul 2008)
New Revision: 6426
Modified:
core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
Log:
Incorrect cast
Modified: core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-07-30 08:56:14 UTC (rev 6425)
+++ core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-07-30 09:01:40 UTC (rev 6426)
@@ -9,7 +9,6 @@
import org.jboss.cache.factories.annotations.NonVolatile;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.factories.annotations.Stop;
-import org.jboss.cache.invocation.NodeInvocationDelegate;
import org.jboss.cache.lock.LockManager;
import org.jboss.cache.marshall.NodeData;
@@ -35,7 +34,7 @@
/**
* Root node.
*/
- private volatile NodeInvocationDelegate root;
+ private volatile NodeSPI root;
private volatile InternalNode rootInternal;
/**
@@ -132,7 +131,7 @@
}
else
{
- this.root = (NodeInvocationDelegate) root;
+ this.root = (NodeSPI) root;
if (usingMvcc)
{
if (log.isDebugEnabled()) log.debug("Setting rootInternal to " + this.root.getDelegationTarget());
16 years, 5 months
JBoss Cache SVN: r6425 - core/trunk/src/main/java/org/jboss/cache/util.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-30 04:56:14 -0400 (Wed, 30 Jul 2008)
New Revision: 6425
Modified:
core/trunk/src/main/java/org/jboss/cache/util/FastCopyHashMap.java
Log:
Moved SuppressWarnings from method body.
Allow null keys
Modified: core/trunk/src/main/java/org/jboss/cache/util/FastCopyHashMap.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/FastCopyHashMap.java 2008-07-30 08:50:56 UTC (rev 6424)
+++ core/trunk/src/main/java/org/jboss/cache/util/FastCopyHashMap.java 2008-07-30 08:56:14 UTC (rev 6425)
@@ -40,6 +40,8 @@
*/
public class FastCopyHashMap<K, V> extends AbstractMap<K, V> implements Map<K, V>, Cloneable, Serializable
{
+
+ private static final Object NULL = new Object();
private static final long serialVersionUID = 10929568968762L;
/**
@@ -108,14 +110,13 @@
putAll(data);
}
+ @SuppressWarnings("unchecked")
private void init(int initialCapacity, float loadFactor)
{
int c = 1;
for (; c < initialCapacity; c <<= 1) ;
- @SuppressWarnings("unchecked")
- Entry<K, V>[] table = (Entry<K, V>[]) new Entry[c];
- this.table = table;
+ this.table = (Entry<K, V>[]) new Entry[c];
threshold = (int) (c * loadFactor);
}
@@ -166,8 +167,7 @@
public V get(Object key)
{
- if (key == null)
- throw new IllegalArgumentException("Null keys are not allowed");
+ if (key == null) key = NULL;
int hash = hash(key);
int length = table.length;
@@ -188,8 +188,7 @@
public boolean containsKey(Object key)
{
- if (key == null)
- throw new IllegalArgumentException("Null keys are not allowed");
+ if (key == null) key = NULL;
int hash = hash(key);
int length = table.length;
@@ -217,10 +216,10 @@
return false;
}
+ @SuppressWarnings("unchecked")
public V put(K key, V value)
{
- if (key == null)
- throw new IllegalArgumentException("Null keys are not allowed");
+ if (key == null) key = (K) NULL;
Entry<K, V>[] table = this.table;
@@ -256,6 +255,7 @@
}
+ @SuppressWarnings("unchecked")
private void resize(int from)
{
int newLength = from << 1;
@@ -264,7 +264,6 @@
if (newLength > MAXIMUM_CAPACITY || newLength <= from)
return;
- @SuppressWarnings("unchecked")
Entry<K, V>[] newTable = new Entry[newLength];
Entry<K, V>[] old = table;
@@ -307,8 +306,7 @@
public V remove(Object key)
{
- if (key == null)
- throw new IllegalArgumentException("Null keys are not allowed");
+ if (key == null) key = NULL;
Entry<K, V>[] table = this.table;
int length = table.length;
@@ -376,11 +374,11 @@
size = 0;
}
+ @SuppressWarnings("unchecked")
public Object clone()
{
try
{
- @SuppressWarnings("unchecked")
FastCopyHashMap<K, V> clone = (FastCopyHashMap<K, V>) super.clone();
clone.table = table.clone();
clone.entrySet = null;
@@ -470,10 +468,10 @@
}
}
+ @SuppressWarnings("unchecked")
private void putForCreate(K key, V value)
{
- if (key == null)
- throw new IllegalArgumentException("Null keys are not allowed");
+ if (key == null) key = (K) NULL;
Entry<K, V>[] table = this.table;
int hash = hash(key);
@@ -560,6 +558,7 @@
return table[current];
}
+ @SuppressWarnings("unchecked")
public void remove()
{
if (modCount != expectedCount)
@@ -609,7 +608,6 @@
if (i < current && current <= delete && table == FastCopyHashMap.this.table)
{
int remaining = length - current;
- @SuppressWarnings("unchecked")
Entry<K, V>[] newTable = (Entry<K, V>[]) new Entry[remaining];
System.arraycopy(table, current, newTable, 0, remaining);
16 years, 5 months
JBoss Cache SVN: r6424 - core/trunk/src/test/java/org/jboss/cache/loader.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-30 04:50:56 -0400 (Wed, 30 Jul 2008)
New Revision: 6424
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheServerTest.java
Log:
Disabled for now
Modified: core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheServerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheServerTest.java 2008-07-30 08:49:00 UTC (rev 6423)
+++ core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheServerTest.java 2008-07-30 08:50:56 UTC (rev 6424)
@@ -23,7 +23,8 @@
* @author Brian Stansberry
* @version $Id$
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional"}, enabled = false)
+// TODO Re-enable!
public class TcpCacheServerTest
{
static TcpCacheServer cache_server = null;
16 years, 5 months
JBoss Cache SVN: r6423 - core/trunk/src/test/java/org/jboss/cache/loader.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-30 04:49:00 -0400 (Wed, 30 Jul 2008)
New Revision: 6423
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
Log:
Disabled TcpCLT for now
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-07-29 22:55:16 UTC (rev 6422)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-07-30 08:49:00 UTC (rev 6423)
@@ -19,7 +19,6 @@
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
@@ -42,7 +41,7 @@
* @author Bela Ban
* @version $Id$
*/
-@Test(groups = {"functional"})
+//@Test(groups = {"functional"})
abstract public class CacheLoaderTestsBase extends AbstractCacheLoaderTestBase
{
private static final Log log = LogFactory.getLog(CacheLoaderTestsBase.class);
16 years, 5 months