You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mnemonic.apache.org by ga...@apache.org on 2018/03/11 05:55:09 UTC
mnemonic git commit: MNEMONIC-470: Refactor test cases of collection
module using EntityFactoryProxyHelper
Repository: mnemonic
Updated Branches:
refs/heads/master 7acd26ae4 -> 7c8ab1f1e
MNEMONIC-470: Refactor test cases of collection module using EntityFactoryProxyHelper
Project: http://git-wip-us.apache.org/repos/asf/mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/mnemonic/commit/7c8ab1f1
Tree: http://git-wip-us.apache.org/repos/asf/mnemonic/tree/7c8ab1f1
Diff: http://git-wip-us.apache.org/repos/asf/mnemonic/diff/7c8ab1f1
Branch: refs/heads/master
Commit: 7c8ab1f1e65680133dfc6ccf354cfa73d2d495bd
Parents: 7acd26a
Author: Wang, Gang(Gary) <ga...@apache.org>
Authored: Sat Mar 10 21:27:32 2018 -0800
Committer: Wang, Gang(Gary) <ga...@apache.org>
Committed: Sat Mar 10 21:36:50 2018 -0800
----------------------------------------------------------------------
.../collections/DurableHashMapImpl.java | 43 +---
.../collections/DurableArrayNGTest.java | 128 +-----------
.../collections/DurableHashMapNGTest.java | 196 ++-----------------
.../collections/DurableHashSetNGTest.java | 30 +--
.../DurableSinglyLinkedListNGTest.java | 129 ++----------
...leSinglyLinkedListWithParamHolderNGTest.java | 91 +--------
.../mnemonic/collections/DurableTreeNGTest.java | 30 +--
7 files changed, 64 insertions(+), 583 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mnemonic/blob/7c8ab1f1/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableHashMapImpl.java
----------------------------------------------------------------------
diff --git a/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableHashMapImpl.java b/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableHashMapImpl.java
index de54e85..6ad2746 100644
--- a/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableHashMapImpl.java
+++ b/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableHashMapImpl.java
@@ -17,9 +17,11 @@
package org.apache.mnemonic.collections;
+import org.apache.mnemonic.ConfigurationException;
import org.apache.mnemonic.EntityFactoryProxy;
import org.apache.mnemonic.DurableType;
import org.apache.mnemonic.Durable;
+import org.apache.mnemonic.EntityFactoryProxyHelper;
import org.apache.mnemonic.MemChunkHolder;
import org.apache.mnemonic.MemoryDurableEntity;
import org.apache.mnemonic.OutOfHybridMemory;
@@ -27,9 +29,6 @@ import org.apache.mnemonic.RestorableAllocator;
import org.apache.mnemonic.RestoreDurableEntityError;
import org.apache.mnemonic.RetrieveDurableEntityError;
import org.apache.mnemonic.Utils;
-import org.apache.mnemonic.ParameterHolder;
-
-import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.lang3.ArrayUtils;
import org.flowcomputing.commons.resgc.ReclaimContext;
import sun.misc.Unsafe;
@@ -482,37 +481,15 @@ public class DurableHashMapImpl<A extends RestorableAllocator<A>, K, V>
this.reclaimcontext = rctx;
DurableType gftypes[] = {DurableType.DURABLE};
this.listgftypes = ArrayUtils.addAll(gftypes, genericField);
- EntityFactoryProxy efproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> MapEntry<K, V> restore(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(gfields, factoryproxys, 1);
- return MapEntryFactory.restore(allocator, dpt.getRight(), dpt.getLeft(), phandler, autoreclaim, reclaimcontext);
- }
- @Override
- public <A extends RestorableAllocator<A>> MapEntry<K, V> restore(ParameterHolder<A> ph) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(ph.getGenericTypes(),
- ph.getEntityFactoryProxies(), 1);
- return MapEntryFactory.restore(ph.getAllocator(),
- dpt.getRight(), dpt.getLeft(), ph.getHandler(), ph.getAutoReclaim(), reclaimcontext);
- }
- @Override
- public <A extends RestorableAllocator<A>> MapEntry<K, V> create(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(gfields, factoryproxys, 1);
- return MapEntryFactory.create(allocator, dpt.getRight(), dpt.getLeft(), autoreclaim, reclaimcontext);
- }
- @Override
- public <A extends RestorableAllocator<A>> MapEntry<K, V> create(ParameterHolder<A> ph) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(ph.getGenericTypes(),
- ph.getEntityFactoryProxies(), 1);
- return MapEntryFactory.create(ph.getAllocator(), dpt.getRight(), dpt.getLeft(),
- ph.getAutoReclaim(), reclaimcontext);
- }
+ EntityFactoryProxy efproxies[] = new EntityFactoryProxy[0];
+ try {
+ efproxies = new EntityFactoryProxy[]{
+ new EntityFactoryProxyHelper<MapEntry>(MapEntry.class, 1, reclaimcontext)};
+ } catch (ClassNotFoundException e) {
+ throw new ConfigurationException("Class MapEntry not found");
+ } catch (NoSuchMethodException e) {
+ throw new ConfigurationException("The methods of class MapEntry not found");
}
- };
this.listefproxies = ArrayUtils.addAll(efproxies, factoryProxy);
try {
this.unsafe = Utils.getUnsafe();
http://git-wip-us.apache.org/repos/asf/mnemonic/blob/7c8ab1f1/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableArrayNGTest.java
----------------------------------------------------------------------
diff --git a/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableArrayNGTest.java b/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableArrayNGTest.java
index 24353f6..5bd39a5 100644
--- a/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableArrayNGTest.java
+++ b/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableArrayNGTest.java
@@ -22,20 +22,17 @@ import java.util.Random;
import java.util.zip.Checksum;
import java.util.zip.CRC32;
import java.util.Iterator;
-import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.lang3.ArrayUtils;
+import org.apache.mnemonic.EntityFactoryProxyHelper;
import org.apache.mnemonic.Utils;
import org.apache.mnemonic.NonVolatileMemAllocator;
-import org.apache.mnemonic.RestorableAllocator;
import org.apache.mnemonic.OutOfHybridMemory;
import org.apache.mnemonic.DurableBuffer;
import org.apache.mnemonic.DurableChunk;
import org.apache.mnemonic.DurableType;
-import org.apache.mnemonic.Durable;
import org.apache.mnemonic.EntityFactoryProxy;
import org.apache.mnemonic.Reclaim;
-import org.apache.mnemonic.ParameterHolder;
import org.apache.commons.lang3.RandomUtils;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
@@ -299,33 +296,9 @@ public class DurableArrayNGTest {
}
@Test(enabled = true)
- public void testGetSetArrayDurable() {
+ public void testGetSetArrayDurable() throws NoSuchMethodException, ClassNotFoundException {
DurableType gtypes[] = {DurableType.DURABLE};
- EntityFactoryProxy efproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- return PersonFactory.restore(allocator, factoryproxys, gfields, phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(ParameterHolder<A> ph) {
- return PersonFactory.restore(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- return PersonFactory.create(allocator, factoryproxys, gfields, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(ParameterHolder<A> ph) {
- return PersonFactory.create(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getAutoReclaim());
- }
- }
- };
+ EntityFactoryProxy efproxies[] = {new EntityFactoryProxyHelper<Person>(Person.class)};
Person<Long> person = (Person<Long>) efproxies[0].create(m_act, null, null, false);
person.setName("Alice", false);
@@ -351,7 +324,7 @@ public class DurableArrayNGTest {
}
@Test(enabled = true)
- public void testGetSetArrayLinkedNodeInteger() {
+ public void testGetSetArrayLinkedNodeInteger() throws NoSuchMethodException, ClassNotFoundException {
int val = rand.nextInt();
int capacity = 10;
DurableType gtypes[] = {DurableType.INTEGER};
@@ -359,36 +332,8 @@ public class DurableArrayNGTest {
plln.setItem(val, true);
DurableType arraytypes[] = {DurableType.DURABLE, DurableType.INTEGER};
- EntityFactoryProxy arrayproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Durable restore(A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(gfields, factoryproxys, 1);
- return SinglyLinkedNodeFactory.restore(allocator, dpt.getRight(), dpt.getLeft(), phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable restore(ParameterHolder<A> ph) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(ph.getGenericTypes(),
- ph.getEntityFactoryProxies(), 1);
- return SinglyLinkedNodeFactory.restore(ph.getAllocator(),
- dpt.getRight(), dpt.getLeft(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable create(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(gfields, factoryproxys, 1);
- return SinglyLinkedNodeFactory.create(allocator, dpt.getRight(), dpt.getLeft(), autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable create(ParameterHolder<A> ph) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(ph.getGenericTypes(),
- ph.getEntityFactoryProxies(), 1);
- return SinglyLinkedNodeFactory.create(ph.getAllocator(),
- dpt.getRight(), dpt.getLeft(), ph.getAutoReclaim());
- }
- }
- };
+ EntityFactoryProxy arrayproxies[] = {
+ new EntityFactoryProxyHelper<SinglyLinkedNode>(SinglyLinkedNode.class, 1)};
DurableArray<SinglyLinkedNode<Integer>> array = DurableArrayFactory.create(m_act, arrayproxies,
arraytypes, capacity, false);
@@ -404,33 +349,9 @@ public class DurableArrayNGTest {
}
@Test(enabled = true)
- public void testGetSetArrayofMaps() {
+ public void testGetSetArrayofMaps() throws NoSuchMethodException, ClassNotFoundException {
DurableType gtypes[] = {DurableType.STRING, DurableType.DURABLE};
- EntityFactoryProxy efproxies[] = {null, new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- return PersonFactory.restore(allocator, factoryproxys, gfields, phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(ParameterHolder<A> ph) {
- return PersonFactory.restore(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- return PersonFactory.create(allocator, factoryproxys, gfields, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(ParameterHolder<A> ph) {
- return PersonFactory.create(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getAutoReclaim());
- }
- }
- };
+ EntityFactoryProxy efproxies[] = {null, new EntityFactoryProxyHelper<Person>(Person.class)};
Person<Long> person = (Person<Long>) efproxies[1].create(m_act, null, null, false);
person.setName("Alice", false);
person.setAge((short) 31);
@@ -447,37 +368,8 @@ public class DurableArrayNGTest {
DurableType arraytypes[] = {DurableType.DURABLE};
arraytypes = ArrayUtils.addAll(arraytypes, gtypes);
- EntityFactoryProxy arrayproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> DurableHashMap<String, Person<Long>> restore(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(gfields, factoryproxys, 1);
- return DurableHashMapFactory.restore(allocator, dpt.getRight(), dpt.getLeft(), phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> DurableHashMap<String, Person<Long>> restore(ParameterHolder<A> ph) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(ph.getGenericTypes(),
- ph.getEntityFactoryProxies(), 1);
- return DurableHashMapFactory.restore(ph.getAllocator(),
- dpt.getRight(), dpt.getLeft(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> DurableHashMap<String, Person<Long>> create(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(gfields, factoryproxys, 1);
- return DurableHashMapFactory.create(allocator, dpt.getRight(), dpt.getLeft(), 10, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> DurableHashMap<String, Person<Long>> create(ParameterHolder<A> ph) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(ph.getGenericTypes(),
- ph.getEntityFactoryProxies(), 1);
- return DurableHashMapFactory.create(ph.getAllocator(),
- dpt.getRight(), dpt.getLeft(), 10, ph.getAutoReclaim());
- }
- }
- };
+ EntityFactoryProxy arrayproxies[] = {
+ new EntityFactoryProxyHelper<DurableHashMap>(DurableHashMap.class, 1)};
arrayproxies = ArrayUtils.addAll(arrayproxies, efproxies);
DurableArray<DurableHashMap<String, Person<Long>>> array = DurableArrayFactory.create(m_act, arrayproxies,
http://git-wip-us.apache.org/repos/asf/mnemonic/blob/7c8ab1f1/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableHashMapNGTest.java
----------------------------------------------------------------------
diff --git a/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableHashMapNGTest.java b/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableHashMapNGTest.java
index 7d2df9c..376d739 100644
--- a/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableHashMapNGTest.java
+++ b/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableHashMapNGTest.java
@@ -23,8 +23,8 @@ import java.util.Random;
import java.util.zip.Checksum;
import java.util.zip.CRC32;
+import org.apache.mnemonic.EntityFactoryProxyHelper;
import org.apache.mnemonic.Utils;
-import org.apache.mnemonic.RestorableAllocator;
import org.apache.mnemonic.NonVolatileMemAllocator;
import org.apache.mnemonic.OutOfHybridMemory;
import org.apache.mnemonic.EntityFactoryProxy;
@@ -32,9 +32,6 @@ import org.apache.mnemonic.DurableType;
import org.apache.mnemonic.DurableBuffer;
import org.apache.mnemonic.DurableChunk;
import org.apache.mnemonic.Reclaim;
-import org.apache.mnemonic.Durable;
-import org.apache.mnemonic.ParameterHolder;
-import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.lang3.RandomUtils;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
@@ -192,39 +189,17 @@ public class DurableHashMapNGTest {
}
@Test(enabled = true)
- public void testGetPutKeyDurable() {
+ public void testGetPutKeyDurable() throws NoSuchMethodException, ClassNotFoundException {
DurableType gtypes[] = {DurableType.DURABLE, DurableType.STRING};
- EntityFactoryProxy efproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- return PersonFactory.restore(allocator, factoryproxys, gfields, phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(ParameterHolder<A> ph) {
- return PersonFactory.restore(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- return PersonFactory.create(allocator, factoryproxys, gfields, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(ParameterHolder<A> ph) {
- return PersonFactory.create(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getAutoReclaim());
- }
- } };
+ EntityFactoryProxy efproxies[] = {new EntityFactoryProxyHelper<Person>(Person.class)};
Person<Long> person = (Person<Long>) efproxies[0].create(m_act, null, null, false);
person.setAge((short) 31);
person.setName("Bob", true);
- Person<Long> anotherPerson = (Person<Long>) efproxies[0].create(m_act, null, null, false);
+ Person<Long> anotherPerson =
+ (Person<Long>) efproxies[0].create(m_act, null, null, false);
anotherPerson.setAge((short) 30);
anotherPerson.setName("Alice", true);
@@ -257,33 +232,10 @@ public class DurableHashMapNGTest {
}
@Test(enabled = true)
- public void testGetPutValueDurable() {
+ public void testGetPutValueDurable() throws NoSuchMethodException, ClassNotFoundException {
DurableType gtypes[] = {DurableType.STRING, DurableType.DURABLE};
- EntityFactoryProxy efproxies[] = {null, new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- return PersonFactory.restore(allocator, factoryproxys, gfields, phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(ParameterHolder<A> ph) {
- return PersonFactory.restore(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- return PersonFactory.create(allocator, factoryproxys, gfields, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(ParameterHolder<A> ph) {
- return PersonFactory.create(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getAutoReclaim());
- }
- } };
+ EntityFactoryProxy efproxies[] = {null, new EntityFactoryProxyHelper<Person>(Person.class)};
Person<Long> person = (Person<Long>) efproxies[1].create(m_act, null, null, false);
person.setName("Alice", false);
@@ -314,56 +266,11 @@ public class DurableHashMapNGTest {
}
@Test(enabled = true)
- public void testGetPutKeyValueDurable() {
+ public void testGetPutKeyValueDurable() throws NoSuchMethodException, ClassNotFoundException {
DurableType gtypes[] = {DurableType.DURABLE, DurableType.DURABLE};
- EntityFactoryProxy efproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- return PersonFactory.restore(allocator, factoryproxys, gfields, phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(ParameterHolder<A> ph) {
- return PersonFactory.restore(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- return PersonFactory.create(allocator, factoryproxys, gfields, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(ParameterHolder<A> ph) {
- return PersonFactory.create(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getAutoReclaim());
- }
- }, new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- return PersonFactory.restore(allocator, factoryproxys, gfields, phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(ParameterHolder<A> ph) {
- return PersonFactory.restore(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- return PersonFactory.create(allocator, factoryproxys, gfields, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(ParameterHolder<A> ph) {
- return PersonFactory.create(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getAutoReclaim());
- }
- } };
+ EntityFactoryProxy efproxies[] = {new EntityFactoryProxyHelper<Person>(Person.class),
+ new EntityFactoryProxyHelper<Person>(Person.class)};
Person<Long> person = (Person<Long>) efproxies[0].create(m_act, null, null, false);
person.setAge((short) 31);
@@ -386,86 +293,13 @@ public class DurableHashMapNGTest {
}
@Test(enabled = true)
- public void testGetPutMapOfMapDurable() {
+ public void testGetPutMapOfMapDurable() throws NoSuchMethodException, ClassNotFoundException {
DurableType gtypes[] = {DurableType.STRING, DurableType.DURABLE};
- EntityFactoryProxy efproxies[] = {null, new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- return PersonFactory.restore(allocator, factoryproxys, gfields, phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(ParameterHolder<A> ph) {
- return PersonFactory.restore(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- return PersonFactory.create(allocator, factoryproxys, gfields, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(ParameterHolder<A> ph) {
- return PersonFactory.create(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getAutoReclaim());
- }
- } };
+ EntityFactoryProxy efproxies[] = {null, new EntityFactoryProxyHelper<Person>(Person.class)};
DurableType mapgtypes[] = {DurableType.STRING, DurableType.DURABLE, DurableType.STRING, DurableType.DURABLE};
- EntityFactoryProxy mapefproxies[] = {null, new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Durable restore(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(gfields, factoryproxys, 2);
- return DurableHashMapFactory.restore(allocator, dpt.getRight(), dpt.getLeft(), phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable restore(ParameterHolder<A> ph) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(ph.getGenericTypes(),
- ph.getEntityFactoryProxies(), 2);
- return DurableHashMapFactory.restore(ph.getAllocator(),
- dpt.getRight(), dpt.getLeft(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable create(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(gfields, factoryproxys, 2);
- return DurableHashMapFactory.create(allocator, dpt.getRight(), dpt.getLeft(), mInitialCapacity, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable create(ParameterHolder<A> ph) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(ph.getGenericTypes(),
- ph.getEntityFactoryProxies(), 2);
- return DurableHashMapFactory.create(ph.getAllocator(),
- dpt.getRight(), dpt.getLeft(), mInitialCapacity, ph.getAutoReclaim());
- }
- }, null, new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- return PersonFactory.restore(allocator, factoryproxys, gfields, phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(ParameterHolder<A> ph) {
- return PersonFactory.restore(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- return PersonFactory.create(allocator, factoryproxys, gfields, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(ParameterHolder<A> ph) {
- return PersonFactory.create(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getAutoReclaim());
- }
- } };
+ EntityFactoryProxy mapefproxies[] = {null,
+ new EntityFactoryProxyHelper<DurableHashMap>(DurableHashMap.class, 2), null,
+ new EntityFactoryProxyHelper<Person>(Person.class)};
Person<Long> person = PersonFactory.create(m_act, null, null, false);
person.setAge((short) 31);
http://git-wip-us.apache.org/repos/asf/mnemonic/blob/7c8ab1f1/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableHashSetNGTest.java
----------------------------------------------------------------------
diff --git a/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableHashSetNGTest.java b/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableHashSetNGTest.java
index 5a35174..d37c7b2 100644
--- a/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableHashSetNGTest.java
+++ b/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableHashSetNGTest.java
@@ -22,10 +22,9 @@ import java.nio.ByteBuffer;
import java.util.Random;
import java.util.zip.Checksum;
+import org.apache.mnemonic.EntityFactoryProxyHelper;
import org.apache.mnemonic.Utils;
import org.apache.mnemonic.NonVolatileMemAllocator;
-import org.apache.mnemonic.RestorableAllocator;
-import org.apache.mnemonic.ParameterHolder;
import org.apache.mnemonic.OutOfHybridMemory;
import org.apache.mnemonic.DurableBuffer;
import org.apache.mnemonic.DurableChunk;
@@ -185,32 +184,9 @@ public class DurableHashSetNGTest {
}
@Test(enabled = true)
- public void testAddRemoveDurable() {
+ public void testAddRemoveDurable() throws NoSuchMethodException, ClassNotFoundException {
DurableType gtypes[] = {DurableType.DURABLE};
- EntityFactoryProxy efproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- return PersonFactory.restore(allocator, factoryproxys, gfields, phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(ParameterHolder<A> ph) {
- return PersonFactory.restore(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- return PersonFactory.create(allocator, factoryproxys, gfields, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(ParameterHolder<A> ph) {
- return PersonFactory.create(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getAutoReclaim());
- }
- } };
+ EntityFactoryProxy efproxies[] = {new EntityFactoryProxyHelper<Person>(Person.class)};
Person<Long> person = (Person<Long>) efproxies[0].create(m_act, null, null, false);
person.setAge((short) 31);
http://git-wip-us.apache.org/repos/asf/mnemonic/blob/7c8ab1f1/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableSinglyLinkedListNGTest.java
----------------------------------------------------------------------
diff --git a/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableSinglyLinkedListNGTest.java b/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableSinglyLinkedListNGTest.java
index 3b2ab75..923af07 100644
--- a/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableSinglyLinkedListNGTest.java
+++ b/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableSinglyLinkedListNGTest.java
@@ -23,15 +23,12 @@ import java.util.Iterator;
import java.util.List;
import java.util.Random;
+import org.apache.mnemonic.EntityFactoryProxyHelper;
import org.apache.mnemonic.NonVolatileMemAllocator;
-import org.apache.mnemonic.RestorableAllocator;
-import org.apache.commons.lang3.tuple.Pair;
-import org.apache.mnemonic.Durable;
import org.apache.mnemonic.EntityFactoryProxy;
import org.apache.mnemonic.Reclaim;
import org.apache.mnemonic.Utils;
import org.apache.mnemonic.DurableType;
-import org.apache.mnemonic.ParameterHolder;
import org.testng.AssertJUnit;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
@@ -107,33 +104,12 @@ public class DurableSinglyLinkedListNGTest {
}
@Test(enabled = false)
- public void testNodeValueWithPerson() {
+ public void testNodeValueWithPerson()
+ throws ClassNotFoundException, NoSuchMethodException {
DurableType gtypes[] = {DurableType.DURABLE};
- EntityFactoryProxy efproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- return PersonFactory.restore(allocator, factoryproxys, gfields, phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(ParameterHolder<A> ph) {
- return PersonFactory.restore(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- return PersonFactory.create(allocator, factoryproxys, gfields, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(ParameterHolder<A> ph) {
- return PersonFactory.create(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getAutoReclaim());
- }
- } };
+ EntityFactoryProxy efproxies[] = {
+ new EntityFactoryProxyHelper<Person>(Person.class) };
@SuppressWarnings("unchecked")
Person<Long> person = (Person<Long>) efproxies[0].create(m_act, null, null, false);
@@ -151,36 +127,15 @@ public class DurableSinglyLinkedListNGTest {
@SuppressWarnings("unchecked")
@Test(enabled = false)
- public void testLinkedNodeValueWithPerson() {
+ public void testLinkedNodeValueWithPerson()
+ throws ClassNotFoundException, NoSuchMethodException {
int elem_count = 10;
List<Long> referlist = new ArrayList();
DurableType listgftypes[] = {DurableType.DURABLE};
- EntityFactoryProxy listefproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- return PersonFactory.restore(allocator, factoryproxys, gfields, phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(ParameterHolder<A> ph) {
- return PersonFactory.restore(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- return PersonFactory.create(allocator, factoryproxys, gfields, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(ParameterHolder<A> ph) {
- return PersonFactory.create(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getAutoReclaim());
- }
- } };
+ EntityFactoryProxy listefproxies[] = {
+ new EntityFactoryProxyHelper<Person>(Person.class) };
DurableSinglyLinkedList<Person<Long>> list = DurableSinglyLinkedListFactory.create(m_act, listefproxies,
listgftypes, false);
@@ -230,7 +185,8 @@ public class DurableSinglyLinkedListNGTest {
}
@Test(enabled = true)
- public void testLinkedNodeValueWithLinkedNodeValue() {
+ public void testLinkedNodeValueWithLinkedNodeValue()
+ throws ClassNotFoundException, NoSuchMethodException {
int elem_count = 10;
long slotKeyId = 10;
@@ -239,67 +195,12 @@ public class DurableSinglyLinkedListNGTest {
EntityFactoryProxy[] elem_efproxies = null;
DurableType linkedgftypes[] = {DurableType.DURABLE, DurableType.DOUBLE};
- EntityFactoryProxy linkedefproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Durable restore(A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(gfields, factoryproxys, 1);
- return SinglyLinkedNodeFactory.restore(allocator, dpt.getRight(), dpt.getLeft(), phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable restore(ParameterHolder<A> ph) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(ph.getGenericTypes(),
- ph.getEntityFactoryProxies(), 1);
- return SinglyLinkedNodeFactory.restore(ph.getAllocator(),
- dpt.getRight(), dpt.getLeft(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable create(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(gfields, factoryproxys, 1);
- return SinglyLinkedNodeFactory.create(allocator, dpt.getRight(), dpt.getLeft(), autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable create(ParameterHolder<A> ph) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(ph.getGenericTypes(),
- ph.getEntityFactoryProxies(), 1);
- return SinglyLinkedNodeFactory.create(ph.getAllocator(),
- dpt.getRight(), dpt.getLeft(), ph.getAutoReclaim());
- }
- } };
+ EntityFactoryProxy linkedefproxies[] = {
+ new EntityFactoryProxyHelper<SinglyLinkedNode>(SinglyLinkedNode.class, 1) };
DurableType listgftypes[] = {DurableType.DURABLE, DurableType.DOUBLE};
- EntityFactoryProxy listefproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Durable restore(A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields,
- long phandler, boolean autoreclaim) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(gfields, factoryproxys, 1);
- return DurableSinglyLinkedListFactory.restore(allocator, dpt.getRight(), dpt.getLeft(), phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable restore(ParameterHolder<A> ph) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(ph.getGenericTypes(),
- ph.getEntityFactoryProxies(), 1);
- return DurableSinglyLinkedListFactory.restore(ph.getAllocator(),
- dpt.getRight(), dpt.getLeft(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable create(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(gfields, factoryproxys, 1);
- return DurableSinglyLinkedListFactory.create(allocator, dpt.getRight(), dpt.getLeft(), autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable create(ParameterHolder<A> ph) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(ph.getGenericTypes(),
- ph.getEntityFactoryProxies(), 1);
- return DurableSinglyLinkedListFactory.create(ph.getAllocator(),
- dpt.getRight(), dpt.getLeft(), ph.getAutoReclaim());
- }
- } };
+ EntityFactoryProxy listefproxies[] = {
+ new EntityFactoryProxyHelper<DurableSinglyLinkedList>(DurableSinglyLinkedList.class, 1) };
SinglyLinkedNode<SinglyLinkedNode<Double>> nextnv = null, pre_nextnv = null;
SinglyLinkedNode<Double> elem = null, pre_elem = null, first_elem = null;
http://git-wip-us.apache.org/repos/asf/mnemonic/blob/7c8ab1f1/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableSinglyLinkedListWithParamHolderNGTest.java
----------------------------------------------------------------------
diff --git a/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableSinglyLinkedListWithParamHolderNGTest.java b/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableSinglyLinkedListWithParamHolderNGTest.java
index bf6534b..f0716e3 100644
--- a/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableSinglyLinkedListWithParamHolderNGTest.java
+++ b/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableSinglyLinkedListWithParamHolderNGTest.java
@@ -23,10 +23,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Random;
+import org.apache.mnemonic.EntityFactoryProxyHelper;
import org.apache.mnemonic.NonVolatileMemAllocator;
-import org.apache.mnemonic.RestorableAllocator;
-import org.apache.commons.lang3.tuple.Pair;
-import org.apache.mnemonic.Durable;
import org.apache.mnemonic.EntityFactoryProxy;
import org.apache.mnemonic.Reclaim;
import org.apache.mnemonic.Utils;
@@ -112,33 +110,10 @@ public class DurableSinglyLinkedListWithParamHolderNGTest {
}
@Test(enabled = false)
- public void testNodeValueWithPerson() {
+ public void testNodeValueWithPerson() throws NoSuchMethodException, ClassNotFoundException {
DurableType gtypes[] = {DurableType.DURABLE};
- EntityFactoryProxy efproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- return PersonFactory.restore(allocator, factoryproxys, gfields, phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(ParameterHolder<A> ph) {
- return PersonFactory.restore(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- return PersonFactory.create(allocator, factoryproxys, gfields, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(ParameterHolder<A> ph) {
- return PersonFactory.create(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getAutoReclaim());
- }
- } };
+ EntityFactoryProxy efproxies[] = {new EntityFactoryProxyHelper<Person>(Person.class)};
ph.setAllocator(m_act);
ph.setEntityFactoryProxies(efproxies);
@@ -162,36 +137,13 @@ public class DurableSinglyLinkedListWithParamHolderNGTest {
@SuppressWarnings("unchecked")
@Test(enabled = false)
- public void testLinkedNodeValueWithPerson() {
+ public void testLinkedNodeValueWithPerson() throws NoSuchMethodException, ClassNotFoundException {
int elem_count = 10;
List<Long> referlist = new ArrayList();
DurableType listgftypes[] = {DurableType.DURABLE};
- EntityFactoryProxy listefproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- return PersonFactory.restore(allocator, factoryproxys, gfields, phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(ParameterHolder<A> ph) {
- return PersonFactory.restore(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- return PersonFactory.create(allocator, factoryproxys, gfields, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(ParameterHolder<A> ph) {
- return PersonFactory.create(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getAutoReclaim());
- }
- } };
+ EntityFactoryProxy listefproxies[] = {new EntityFactoryProxyHelper<Person>(Person.class)};
ph.setAllocator(m_act);
ph.setEntityFactoryProxies(listefproxies);
@@ -233,7 +185,7 @@ public class DurableSinglyLinkedListWithParamHolderNGTest {
}
@Test(enabled = true)
- public void testLinkedNodeValueWithLinkedNodeValue() {
+ public void testLinkedNodeValueWithLinkedNodeValue() throws NoSuchMethodException, ClassNotFoundException {
int elem_count = 10;
long slotKeyId = 10;
@@ -244,35 +196,8 @@ public class DurableSinglyLinkedListWithParamHolderNGTest {
EntityFactoryProxy[] elem_efproxies = null;
DurableType linkedgftypes[] = {DurableType.DURABLE, DurableType.DOUBLE};
- EntityFactoryProxy linkedefproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Durable restore(A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(gfields, factoryproxys, 1);
- return DurableSinglyLinkedListFactory.restore(allocator, dpt.getRight(), dpt.getLeft(), phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable restore(ParameterHolder<A> ph) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(ph.getGenericTypes(),
- ph.getEntityFactoryProxies(), 1);
- return DurableSinglyLinkedListFactory.restore(ph.getAllocator(),
- dpt.getRight(), dpt.getLeft(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable create(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(gfields, factoryproxys, 1);
- return DurableSinglyLinkedListFactory.create(allocator, dpt.getRight(), dpt.getLeft(), autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Durable create(ParameterHolder<A> ph) {
- Pair<DurableType[], EntityFactoryProxy[]> dpt = Utils.shiftDurableParams(ph.getGenericTypes(),
- ph.getEntityFactoryProxies(), 1);
- return DurableSinglyLinkedListFactory.create(ph.getAllocator(),
- dpt.getRight(), dpt.getLeft(), ph.getAutoReclaim());
- }
- } };
+ EntityFactoryProxy linkedefproxies[] = {
+ new EntityFactoryProxyHelper<DurableSinglyLinkedList>(DurableSinglyLinkedList.class, 1)};
SinglyLinkedNode<SinglyLinkedNode<Double>> nextnv = null, pre_nextnv = null;
SinglyLinkedNode<Double> elem = null, pre_elem = null, first_elem = null;
http://git-wip-us.apache.org/repos/asf/mnemonic/blob/7c8ab1f1/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableTreeNGTest.java
----------------------------------------------------------------------
diff --git a/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableTreeNGTest.java b/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableTreeNGTest.java
index e8c657f..7047bbb 100644
--- a/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableTreeNGTest.java
+++ b/mnemonic-collections/src/test/java/org/apache/mnemonic/collections/DurableTreeNGTest.java
@@ -21,15 +21,14 @@ package org.apache.mnemonic.collections;
import java.nio.ByteBuffer;
import java.util.Random;
+import org.apache.mnemonic.EntityFactoryProxyHelper;
import org.apache.mnemonic.Utils;
-import org.apache.mnemonic.RestorableAllocator;
import org.apache.mnemonic.NonVolatileMemAllocator;
//import org.apache.mnemonic.OutOfHybridMemory;
import org.apache.mnemonic.EntityFactoryProxy;
import org.apache.mnemonic.DurableType;
import org.apache.mnemonic.Reclaim;
//import org.apache.mnemonic.Durable;
-import org.apache.mnemonic.ParameterHolder;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -240,32 +239,9 @@ public class DurableTreeNGTest {
}
@Test(enabled = true)
- public void testInsertDurable() {
+ public void testInsertDurable() throws NoSuchMethodException, ClassNotFoundException {
DurableType gtypes[] = {DurableType.DURABLE};
- EntityFactoryProxy efproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, long phandler, boolean autoreclaim) {
- return PersonFactory.restore(allocator, factoryproxys, gfields, phandler, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> restore(ParameterHolder<A> ph) {
- return PersonFactory.restore(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getHandler(), ph.getAutoReclaim());
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(
- A allocator, EntityFactoryProxy[] factoryproxys,
- DurableType[] gfields, boolean autoreclaim) {
- return PersonFactory.create(allocator, factoryproxys, gfields, autoreclaim);
- }
- @Override
- public <A extends RestorableAllocator<A>> Person<Long> create(ParameterHolder<A> ph) {
- return PersonFactory.create(ph.getAllocator(),
- ph.getEntityFactoryProxies(), ph.getGenericTypes(), ph.getAutoReclaim());
- }
- } };
+ EntityFactoryProxy efproxies[] = {new EntityFactoryProxyHelper<Person>(Person.class)};
DurableTree<Person<Long>> tree = DurableTreeFactory.create(m_act, efproxies, gtypes, false);
Long handler = tree.getHandler();