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 2016/04/14 03:51:00 UTC
[4/5] incubator-mnemonic git commit: MNEMONIC-20: Formalize the names
of annotations, classes and methods
MNEMONIC-20: Formalize the names of annotations, classes and methods
Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/679bcdc1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/679bcdc1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/679bcdc1
Branch: refs/heads/master
Commit: 679bcdc151213ca4e1bf57cd6cebddd2ae36841c
Parents: 254238f
Author: Wang, Gang(Gary) <ga...@intel.com>
Authored: Wed Apr 13 18:28:35 2016 -0700
Committer: Wang, Gang(Gary) <ga...@intel.com>
Committed: Wed Apr 13 18:28:35 2016 -0700
----------------------------------------------------------------------
README.md | 53 +-
collections/pom.xml | 4 +-
.../mnemonic/collections/DurableNodeValue.java | 172 ++++
.../collections/NonVolatileNodeValue.java | 172 ----
.../collections/DurableNodeValueNGTest.java | 274 ++++++
.../collections/DurablePersonNGTest.java | 148 +++
.../collections/NonVolatileNodeValueNGTest.java | 274 ------
.../collections/NonVolatilePersonNGTest.java | 148 ---
.../org/apache/mnemonic/collections/Person.java | 42 +-
collections/src/test/resources/testng.xml | 8 +-
core/pom.xml | 2 +-
.../mnemonic/AnnotatedDurableEntityClass.java | 943 +++++++++++++++++++
.../AnnotatedNonVolatileEntityClass.java | 943 -------------------
.../apache/mnemonic/BigDataMemAllocator.java | 278 ------
.../apache/mnemonic/BigDataPMemAllocator.java | 470 ---------
.../apache/mnemonic/CommonDurableAllocator.java | 140 +++
.../apache/mnemonic/CommonPersistAllocator.java | 140 ---
.../main/java/org/apache/mnemonic/Durable.java | 4 +-
.../java/org/apache/mnemonic/DurableEntity.java | 34 +
.../apache/mnemonic/DurableEntityProcessor.java | 147 +++
.../java/org/apache/mnemonic/DurableGetter.java | 38 +
.../java/org/apache/mnemonic/DurableSetter.java | 34 +
.../org/apache/mnemonic/EntityFactoryProxy.java | 2 +-
.../java/org/apache/mnemonic/GenericField.java | 16 +-
.../apache/mnemonic/MemoryDurableEntity.java | 36 +
.../mnemonic/MemoryNonVolatileEntity.java | 36 -
.../apache/mnemonic/NVMAddressTranslator.java | 61 ++
.../org/apache/mnemonic/NonVolatileEntity.java | 34 -
.../mnemonic/NonVolatileEntityProcessor.java | 147 ---
.../org/apache/mnemonic/NonVolatileGetter.java | 38 -
.../mnemonic/NonVolatileMemAllocator.java | 474 ++++++++++
.../org/apache/mnemonic/NonVolatileSetter.java | 34 -
.../org/apache/mnemonic/OutOfHybridMemory.java | 32 +
.../apache/mnemonic/OutOfPersistentMemory.java | 32 -
.../apache/mnemonic/PMAddressTranslator.java | 61 --
.../mnemonic/RetrieveDurableEntityError.java | 35 +
.../RetrieveNonVolatileEntityError.java | 35 -
.../apache/mnemonic/VolatileMemAllocator.java | 278 ++++++
.../javax.annotation.processing.Processor | 2 +-
.../mnemonic/BigDataMemAllocatorNGTest.java | 68 --
.../mnemonic/BigDataPMemAllocatorNGTest.java | 132 ---
.../mnemonic/ByteBufferSerializerNGTest.java | 4 +-
.../apache/mnemonic/DurablePersonNGTest.java | 144 +++
.../MemBufferHolderCachePoolNGTest.java | 8 +-
.../apache/mnemonic/MemClusteringNGTest.java | 28 +-
.../mnemonic/NonVolatileMemAllocatorNGTest.java | 132 +++
.../mnemonic/NonVolatilePersonNGTest.java | 144 ---
.../test/java/org/apache/mnemonic/Person.java | 32 +-
.../mnemonic/VolatileAllocatorNGTest.java | 68 ++
core/src/test/resources/testng.xml | 10 +-
.../java/org/apache/mnemonic/example/Main.java | 4 +-
51 files changed, 3300 insertions(+), 3295 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/679bcdc1/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 6b8d5c2..3feacf0 100644
--- a/README.md
+++ b/README.md
@@ -16,6 +16,7 @@ This library comes up with a new programming model we call it non-volatile objec
* Reduce GC Overheads as the following chart shown (collected from Apache Spark experiments)
* [Coming major feature]: Distributed Object Graphs (DOG)
* [Coming major feature]: Columnar-aware object graphs & collections (Apache Arrow based optimization)
+* [Coming major feature]: Native Massive Object Graph (NMOG) Computing
![Mnemonic_GC_stats](http://nonvolatilecomputing.github.io/Mnemonic/images/mnemonic_GC_stats.png)
@@ -33,14 +34,14 @@ This library comes up with a new programming model we call it non-volatile objec
```java
/**
- * a non-volatile class should be abstract, implement Durable interface and marked with @NonVolatileEntity annotation
+ * a durable class should be abstract, implement Durable interface and marked with @DurableEntity annotation
*/
-@NonVolatileEntity
+@DurableEntity
public abstract class Person<E> implements Durable, Comparable<Person<E>> {
E element; // Generic Type
/**
- * callback for this non-volatile object creation
+ * callback for this durable object creation
*/
@Override
public void initializeAfterCreate() {
@@ -48,7 +49,7 @@ public abstract class Person<E> implements Durable, Comparable<Person<E>> {
}
/**
- * callback for this non-valatile object recovery
+ * callback for this durable object recovery
*/
@Override
public void initializeAfterRestore() {
@@ -64,7 +65,7 @@ public abstract class Person<E> implements Durable, Comparable<Person<E>> {
}
@Test
- public void testOutput() throws RetrieveNonVolatileEntityError {
+ public void testOutput() throws RetrieveDurableEntityError {
System.out.printf("Person %s, Age: %d ( %s ) \n", getName(), getAge(),
null == getMother()? "No Recorded Mother" : "Has Recorded Mother");
}
@@ -77,27 +78,27 @@ public abstract class Person<E> implements Durable, Comparable<Person<E>> {
}
/**
- * Getters and Setters for non-volatile fields marked with @NonVolatileGetter and @NonVolatileSetter
+ * Getters and Setters for non-volatile fields marked with @DurableGetter and @DurableSetter
*/
- @NonVolatileGetter
+ @DurableGetter
abstract public Short getAge();
- @NonVolatileSetter
+ @DurableSetter
abstract public void setAge(Short age);
- @NonVolatileGetter
- abstract public String getName() throws RetrieveNonVolatileEntityError;
- @NonVolatileSetter
- abstract public void setName(String name, boolean destroy) throws OutOfPersistentMemory, RetrieveNonVolatileEntityError;
+ @DurableGetter
+ abstract public String getName() throws RetrieveDurableEntityError;
+ @DurableSetter
+ abstract public void setName(String name, boolean destroy) throws OutOfPersistentMemory, RetrieveDurableEntityError;
- @NonVolatileGetter
- abstract public Person<E> getMother() throws RetrieveNonVolatileEntityError;
- @NonVolatileSetter
- abstract public void setMother(Person<E> mother, boolean destroy) throws RetrieveNonVolatileEntityError;
+ @DurableGetter
+ abstract public Person<E> getMother() throws RetrieveDurableEntityError;
+ @DurableSetter
+ abstract public void setMother(Person<E> mother, boolean destroy) throws RetrieveDurableEntityError;
- @NonVolatileGetter
- abstract public Person<E> getFather() throws RetrieveNonVolatileEntityError;
- @NonVolatileSetter
- abstract public void setFather(Person<E> mother, boolean destroy) throws RetrieveNonVolatileEntityError;
+ @DurableGetter
+ abstract public Person<E> getFather() throws RetrieveDurableEntityError;
+ @DurableSetter
+ abstract public void setFather(Person<E> mother, boolean destroy) throws RetrieveDurableEntityError;
}
```
@@ -107,7 +108,7 @@ public abstract class Person<E> implements Durable, Comparable<Person<E>> {
##### Setup an allocator for non-volatile object graphs.
```java
// create an allocator instance
- BigDataPMemAllocator act = new BigDataPMemAllocator(1024 * 1024 * 8, "./pobj_person.dat", true);
+ NonVolatileMemAllocator act = new NonVolatileMemAllocator(1024 * 1024 * 8, "./pobj_person.dat", true);
// fetch handler store capacity from this non-volatile storage managed by this allocator
KEYCAPACITY = act.handlerCapacity();
@@ -126,7 +127,7 @@ public abstract class Person<E> implements Durable, Comparable<Person<E>> {
person.setName(String.format("Name: [%s]", UUID.randomUUID().toString()), true);
// keep this person on non-volatile handler store
- act.setHandler(keyidx, person.getNonVolatileHandler());
+ act.setHandler(keyidx, person.getHandler());
for (int deep = 0; deep < rand.nextInt(100); ++deep) {
@@ -219,15 +220,15 @@ To run an example:
To run several test cases:
```bash
- $ mvn -Dtest=NonVolatilePersonNGTest test -pl core -DskipTests=false # a testcase for module "core" that requires 'pmalloc' allocator service to pass
+ $ mvn -Dtest=DurablePersonNGTest test -pl core -DskipTests=false # a testcase for module "core" that requires 'pmalloc' allocator service to pass
- $ mvn -Dtest=BigDataMemAllocatorNGTest test -pl core -DskipTests=false # the second testcase for module "core" that requires 'vmem' allocator service to pass
+ $ mvn -Dtest=NonVolatileMemAllocatorNGTest test -pl core -DskipTests=false # the second testcase for module "core" that requires 'vmem' allocator service to pass
$ mvn -Dtest=MemClusteringNGTest test -pl core -DskipTests=false # the third testcase for module "core" that requires 'vmem allocator service to pass
- $ mvn -Dtest=NonVolatileNodeValueNGTest test -pl collections -DskipTests=false # a testcase for module "collection" that requires 'pmalloc' allocator service to pass
+ $ mvn -Dtest=DurableNodeValueNGTest test -pl collections -DskipTests=false # a testcase for module "collection" that requires 'pmalloc' allocator service to pass
- $ mvn -Dtest=NonVolatilePersonNGTest test -pl collections -DskipTests=false # another testcase for module "collection" that requires 'pmalloc' allocator service to pass
+ $ mvn -Dtest=DurablePersonNGTest test -pl collections -DskipTests=false # another testcase for module "collection" that requires 'pmalloc' allocator service to pass
```
### Where is the document ?
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/679bcdc1/collections/pom.xml
----------------------------------------------------------------------
diff --git a/collections/pom.xml b/collections/pom.xml
index cc5bd0b..0210b78 100644
--- a/collections/pom.xml
+++ b/collections/pom.xml
@@ -80,7 +80,7 @@
<configuration>
<compilerArguments>-XDenableSunApiLintControl</compilerArguments>
<processors>
- <processor>${project.parent.groupId}.NonVolatileEntityProcessor</processor>
+ <processor>${project.parent.groupId}.DurableEntityProcessor</processor>
</processors>
</configuration>
</execution>
@@ -91,7 +91,7 @@
<configuration>
<compilerArguments>-XDenableSunApiLintControl</compilerArguments>
<processors>
- <processor>${project.parent.groupId}.NonVolatileEntityProcessor</processor>
+ <processor>${project.parent.groupId}.DurableEntityProcessor</processor>
</processors>
</configuration>
</execution>
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/679bcdc1/collections/src/main/java/org/apache/mnemonic/collections/DurableNodeValue.java
----------------------------------------------------------------------
diff --git a/collections/src/main/java/org/apache/mnemonic/collections/DurableNodeValue.java b/collections/src/main/java/org/apache/mnemonic/collections/DurableNodeValue.java
new file mode 100644
index 0000000..91084a2
--- /dev/null
+++ b/collections/src/main/java/org/apache/mnemonic/collections/DurableNodeValue.java
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mnemonic.collections;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import org.apache.mnemonic.Durable;
+import org.apache.mnemonic.EntityFactoryProxy;
+import org.apache.mnemonic.GenericField;
+import org.apache.mnemonic.DurableEntity;
+import org.apache.mnemonic.DurableGetter;
+import org.apache.mnemonic.DurableSetter;
+
+/**
+ * this class defines a non-volatile node for a generic value to form a
+ * unidirectional link
+ *
+ */
+@DurableEntity
+public abstract class DurableNodeValue<E> implements Durable, Iterable<E> {
+ protected transient EntityFactoryProxy[] m_node_efproxies;
+ protected transient GenericField.GType[] m_node_gftypes;
+
+ /**
+ * creation callback for initialization
+ *
+ */
+ @Override
+ public void initializeAfterCreate() {
+ // System.out.println("Initializing After Created");
+ }
+
+ /**
+ * restore callback for initialization
+ *
+ */
+ @Override
+ public void initializeAfterRestore() {
+ // System.out.println("Initializing After Restored");
+ }
+
+ /**
+ * this function will be invoked by its factory to setup generic related info
+ * to avoid expensive operations from reflection
+ *
+ * @param efproxies
+ * specify a array of factory to proxy the restoring of its generic
+ * field objects
+ *
+ * @param gftypes
+ * specify a array of types corresponding to efproxies
+ */
+ @Override
+ public void setupGenericInfo(EntityFactoryProxy[] efproxies, GenericField.GType[] gftypes) {
+ m_node_efproxies = efproxies;
+ m_node_gftypes = gftypes;
+ }
+
+ /**
+ * get the item value of this node
+ *
+ * @return the item value of this node
+ */
+ @DurableGetter(Id = 1L, EntityFactoryProxies = "m_node_efproxies", GenericFieldTypes = "m_node_gftypes")
+ public abstract E getItem();
+
+ /**
+ * set a value to this node item
+ *
+ * @param value
+ * the value to be set
+ *
+ * @param destroy
+ * true if want to destroy exist one
+ *
+ */
+ @DurableSetter
+ public abstract void setItem(E value, boolean destroy);
+
+ /**
+ * get next node
+ *
+ * @return the next node
+ *
+ */
+ @DurableGetter(Id = 2L, EntityFactoryProxies = "m_node_efproxies", GenericFieldTypes = "m_node_gftypes")
+ public abstract DurableNodeValue<E> getNext();
+
+ /**
+ * set next node
+ *
+ * @param next
+ * specify the next node
+ *
+ * @param destroy
+ * true if want to destroy the exist node
+ */
+ @DurableSetter
+ public abstract void setNext(DurableNodeValue<E> next, boolean destroy);
+
+ /**
+ * get an iterator instance of this list
+ *
+ * @return an iterator of this list
+ */
+ @Override
+ public Iterator<E> iterator() {
+ return new Intr(this);
+ }
+
+ /**
+ * this class defines a iterator for this non-volatile list
+ *
+ */
+ private class Intr implements Iterator<E> {
+
+ protected DurableNodeValue<E> next = null;
+
+ /**
+ * Constructor
+ *
+ * @param head
+ * the start point for this iterator
+ *
+ */
+ Intr(DurableNodeValue<E> head) {
+ next = head;
+ }
+
+ /**
+ * determine the existing of next
+ *
+ * @return true if there is a next node
+ *
+ */
+ @Override
+ public boolean hasNext() {
+ return null != next;
+ }
+
+ /**
+ * get next node
+ *
+ * @return the next node
+ */
+ @Override
+ public E next() {
+ if (null == next) {
+ new NoSuchElementException();
+ }
+ E ret = next.getItem();
+ next = next.getNext();
+ return ret;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/679bcdc1/collections/src/main/java/org/apache/mnemonic/collections/NonVolatileNodeValue.java
----------------------------------------------------------------------
diff --git a/collections/src/main/java/org/apache/mnemonic/collections/NonVolatileNodeValue.java b/collections/src/main/java/org/apache/mnemonic/collections/NonVolatileNodeValue.java
deleted file mode 100644
index c4d3664..0000000
--- a/collections/src/main/java/org/apache/mnemonic/collections/NonVolatileNodeValue.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.mnemonic.collections;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import org.apache.mnemonic.Durable;
-import org.apache.mnemonic.EntityFactoryProxy;
-import org.apache.mnemonic.GenericField;
-import org.apache.mnemonic.NonVolatileEntity;
-import org.apache.mnemonic.NonVolatileGetter;
-import org.apache.mnemonic.NonVolatileSetter;
-
-/**
- * this class defines a non-volatile node for a generic value to form a
- * unidirectional link
- *
- */
-@NonVolatileEntity
-public abstract class NonVolatileNodeValue<E> implements Durable, Iterable<E> {
- protected transient EntityFactoryProxy[] m_node_efproxies;
- protected transient GenericField.GType[] m_node_gftypes;
-
- /**
- * creation callback for initialization
- *
- */
- @Override
- public void initializeAfterCreate() {
- // System.out.println("Initializing After Created");
- }
-
- /**
- * restore callback for initialization
- *
- */
- @Override
- public void initializeAfterRestore() {
- // System.out.println("Initializing After Restored");
- }
-
- /**
- * this function will be invoked by its factory to setup generic related info
- * to avoid expensive operations from reflection
- *
- * @param efproxies
- * specify a array of factory to proxy the restoring of its generic
- * field objects
- *
- * @param gftypes
- * specify a array of types corresponding to efproxies
- */
- @Override
- public void setupGenericInfo(EntityFactoryProxy[] efproxies, GenericField.GType[] gftypes) {
- m_node_efproxies = efproxies;
- m_node_gftypes = gftypes;
- }
-
- /**
- * get the item value of this node
- *
- * @return the item value of this node
- */
- @NonVolatileGetter(Id = 1L, EntityFactoryProxies = "m_node_efproxies", GenericFieldTypes = "m_node_gftypes")
- public abstract E getItem();
-
- /**
- * set a value to this node item
- *
- * @param value
- * the value to be set
- *
- * @param destroy
- * true if want to destroy exist one
- *
- */
- @NonVolatileSetter
- public abstract void setItem(E value, boolean destroy);
-
- /**
- * get next node
- *
- * @return the next node
- *
- */
- @NonVolatileGetter(Id = 2L, EntityFactoryProxies = "m_node_efproxies", GenericFieldTypes = "m_node_gftypes")
- public abstract NonVolatileNodeValue<E> getNext();
-
- /**
- * set next node
- *
- * @param next
- * specify the next node
- *
- * @param destroy
- * true if want to destroy the exist node
- */
- @NonVolatileSetter
- public abstract void setNext(NonVolatileNodeValue<E> next, boolean destroy);
-
- /**
- * get an iterator instance of this list
- *
- * @return an iterator of this list
- */
- @Override
- public Iterator<E> iterator() {
- return new Intr(this);
- }
-
- /**
- * this class defines a iterator for this non-volatile list
- *
- */
- private class Intr implements Iterator<E> {
-
- protected NonVolatileNodeValue<E> next = null;
-
- /**
- * Constructor
- *
- * @param head
- * the start point for this iterator
- *
- */
- Intr(NonVolatileNodeValue<E> head) {
- next = head;
- }
-
- /**
- * determine the existing of next
- *
- * @return true if there is a next node
- *
- */
- @Override
- public boolean hasNext() {
- return null != next;
- }
-
- /**
- * get next node
- *
- * @return the next node
- */
- @Override
- public E next() {
- if (null == next) {
- new NoSuchElementException();
- }
- E ret = next.getItem();
- next = next.getNext();
- return ret;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/679bcdc1/collections/src/test/java/org/apache/mnemonic/collections/DurableNodeValueNGTest.java
----------------------------------------------------------------------
diff --git a/collections/src/test/java/org/apache/mnemonic/collections/DurableNodeValueNGTest.java b/collections/src/test/java/org/apache/mnemonic/collections/DurableNodeValueNGTest.java
new file mode 100644
index 0000000..0cc0095
--- /dev/null
+++ b/collections/src/test/java/org/apache/mnemonic/collections/DurableNodeValueNGTest.java
@@ -0,0 +1,274 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mnemonic.collections;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Random;
+
+import org.apache.mnemonic.NonVolatileMemAllocator;
+import org.apache.mnemonic.CommonDurableAllocator;
+import org.apache.mnemonic.Durable;
+import org.apache.mnemonic.EntityFactoryProxy;
+import org.apache.mnemonic.GenericField;
+import org.apache.mnemonic.Reclaim;
+import org.apache.mnemonic.Utils;
+import org.testng.AssertJUnit;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ *
+ *
+ */
+
+public class DurableNodeValueNGTest {
+ private long cKEYCAPACITY;
+ private Random m_rand;
+ private NonVolatileMemAllocator m_act;
+
+ @BeforeClass
+ public void setUp() {
+ m_rand = Utils.createRandom();
+ m_act = new NonVolatileMemAllocator(Utils.getNonVolatileMemoryAllocatorService("pmalloc"), 1024 * 1024 * 1024,
+ "./pobj_NodeValue.dat", true);
+ cKEYCAPACITY = m_act.handlerCapacity();
+ m_act.setBufferReclaimer(new Reclaim<ByteBuffer>() {
+ @Override
+ public boolean reclaim(ByteBuffer mres, Long sz) {
+ System.out.println(String.format("Reclaim Memory Buffer: %X Size: %s", System.identityHashCode(mres),
+ null == sz ? "NULL" : sz.toString()));
+ return false;
+ }
+ });
+ m_act.setChunkReclaimer(new Reclaim<Long>() {
+ @Override
+ public boolean reclaim(Long mres, Long sz) {
+ System.out.println(String.format("Reclaim Memory Chunk: %X Size: %s", System.identityHashCode(mres),
+ null == sz ? "NULL" : sz.toString()));
+ return false;
+ }
+ });
+
+ for (long i = 0; i < cKEYCAPACITY; ++i) {
+ m_act.setHandler(i, 0L);
+ }
+ }
+
+ @AfterClass
+ public void tearDown() {
+ m_act.close();
+ }
+
+ @Test(enabled = false)
+ public void testSingleNodeValueWithInteger() {
+ int val = m_rand.nextInt();
+ GenericField.GType gtypes[] = {GenericField.GType.INTEGER};
+ DurableNodeValue<Integer> plln = DurableNodeValueFactory.create(m_act, null, gtypes, false);
+ plln.setItem(val, false);
+ Long handler = plln.getHandler();
+ System.err.println("-------------Start to Restore Integer -----------");
+ DurableNodeValue<Integer> plln2 = DurableNodeValueFactory.restore(m_act, null, gtypes, handler, false);
+ AssertJUnit.assertEquals(val, (int) plln2.getItem());
+ }
+
+ @Test(enabled = false)
+ public void testNodeValueWithString() {
+ String val = Utils.genRandomString();
+ GenericField.GType gtypes[] = {GenericField.GType.STRING};
+ DurableNodeValue<String> plln = DurableNodeValueFactory.create(m_act, null, gtypes, false);
+ plln.setItem(val, false);
+ Long handler = plln.getHandler();
+ System.err.println("-------------Start to Restore String-----------");
+ DurableNodeValue<String> plln2 = DurableNodeValueFactory.restore(m_act, null, gtypes, handler, false);
+ AssertJUnit.assertEquals(val, plln2.getItem());
+ }
+
+ @Test(enabled = false)
+ public void testNodeValueWithPerson() {
+
+ Person<Long> person = PersonFactory.create(m_act);
+ person.setAge((short) 31);
+
+ GenericField.GType gtypes[] = {GenericField.GType.DURABLE};
+ EntityFactoryProxy efproxies[] = {new EntityFactoryProxy() {
+ @Override
+ public <A extends CommonDurableAllocator<A>> Durable restore(A allocator, EntityFactoryProxy[] factoryproxys,
+ GenericField.GType[] gfields, long phandler, boolean autoreclaim) {
+ return PersonFactory.restore(allocator, factoryproxys, gfields, phandler, autoreclaim);
+ }
+ } };
+
+ DurableNodeValue<Person<Long>> plln = DurableNodeValueFactory.create(m_act, efproxies, gtypes, false);
+ plln.setItem(person, false);
+ Long handler = plln.getHandler();
+
+ DurableNodeValue<Person<Long>> plln2 = DurableNodeValueFactory.restore(m_act, efproxies, gtypes, handler,
+ false);
+ AssertJUnit.assertEquals(31, (int) plln2.getItem().getAge());
+
+ }
+
+ @Test(enabled = false)
+ public void testLinkedNodeValueWithPerson() {
+
+ int elem_count = 10;
+ List<Long> referlist = new ArrayList();
+
+ GenericField.GType listgftypes[] = {GenericField.GType.DURABLE};
+ EntityFactoryProxy listefproxies[] = {new EntityFactoryProxy() {
+ @Override
+ public <A extends CommonDurableAllocator<A>> Durable restore(A allocator, EntityFactoryProxy[] factoryproxys,
+ GenericField.GType[] gfields, long phandler, boolean autoreclaim) {
+ return PersonFactory.restore(allocator, factoryproxys, gfields, phandler, autoreclaim);
+ }
+ } };
+
+ DurableNodeValue<Person<Long>> firstnv = DurableNodeValueFactory.create(m_act, listefproxies, listgftypes,
+ false);
+
+ DurableNodeValue<Person<Long>> nextnv = firstnv;
+
+ Person<Long> person;
+ long val;
+ DurableNodeValue<Person<Long>> newnv;
+ for (int i = 0; i < elem_count; ++i) {
+ person = PersonFactory.create(m_act);
+ person.setAge((short) m_rand.nextInt(50));
+ person.setName(String.format("Name: [%s]", Utils.genRandomString()), true);
+ nextnv.setItem(person, false);
+ newnv = DurableNodeValueFactory.create(m_act, listefproxies, listgftypes, false);
+ nextnv.setNext(newnv, false);
+ nextnv = newnv;
+ }
+
+ Person<Long> eval;
+ DurableNodeValue<Person<Long>> iternv = firstnv;
+ while (null != iternv) {
+ System.out.printf(" Stage 1 --->\n");
+ eval = iternv.getItem();
+ if (null != eval) {
+ eval.testOutput();
+ }
+ iternv = iternv.getNext();
+ }
+
+ long handler = firstnv.getHandler();
+
+ DurableNodeValue<Person<Long>> firstnv2 = DurableNodeValueFactory.restore(m_act, listefproxies, listgftypes,
+ handler, false);
+
+ for (Person<Long> eval2 : firstnv2) {
+ System.out.printf(" Stage 2 ---> \n");
+ if (null != eval2) {
+ eval2.testOutput();
+ }
+ }
+
+ // Assert.assert, expected);(plist, plist2);
+
+ }
+
+ @Test(enabled = true)
+ public void testLinkedNodeValueWithLinkedNodeValue() {
+
+ int elem_count = 10;
+ long slotKeyId = 10;
+
+ GenericField.GType[] elem_gftypes = {GenericField.GType.DOUBLE};
+ EntityFactoryProxy[] elem_efproxies = null;
+
+ GenericField.GType linkedgftypes[] = {GenericField.GType.DURABLE, GenericField.GType.DOUBLE};
+ EntityFactoryProxy linkedefproxies[] = {new EntityFactoryProxy() {
+ @Override
+ public <A extends CommonDurableAllocator<A>> Durable restore(A allocator, EntityFactoryProxy[] factoryproxys,
+ GenericField.GType[] gfields, long phandler, boolean autoreclaim) {
+ EntityFactoryProxy[] val_efproxies = null;
+ GenericField.GType[] val_gftypes = null;
+ if (null != factoryproxys && factoryproxys.length >= 2) {
+ val_efproxies = Arrays.copyOfRange(factoryproxys, 1, factoryproxys.length);
+ }
+ if (null != gfields && gfields.length >= 2) {
+ val_gftypes = Arrays.copyOfRange(gfields, 1, gfields.length);
+ }
+ return DurableNodeValueFactory.restore(allocator, val_efproxies, val_gftypes, phandler, autoreclaim);
+ }
+ } };
+
+ DurableNodeValue<DurableNodeValue<Double>> nextnv = null, pre_nextnv = null;
+ DurableNodeValue<Double> elem = null, pre_elem = null, first_elem = null;
+
+ Long linkhandler = 0L;
+
+ System.out.printf(" Stage 1 -testLinkedNodeValueWithLinkedNodeValue--> \n");
+
+ pre_nextnv = null;
+ Double val;
+ for (int i = 0; i < elem_count; ++i) {
+ first_elem = null;
+ pre_elem = null;
+ for (int v = 0; v < 3; ++v) {
+ elem = DurableNodeValueFactory.create(m_act, elem_efproxies, elem_gftypes, false);
+ val = m_rand.nextDouble();
+ elem.setItem(val, false);
+ if (null == pre_elem) {
+ first_elem = elem;
+ } else {
+ pre_elem.setNext(elem, false);
+ }
+ pre_elem = elem;
+ System.out.printf("%f ", val);
+ }
+
+ nextnv = DurableNodeValueFactory.create(m_act, linkedefproxies, linkedgftypes, false);
+ nextnv.setItem(first_elem, false);
+ if (null == pre_nextnv) {
+ linkhandler = nextnv.getHandler();
+ } else {
+ pre_nextnv.setNext(nextnv, false);
+ }
+ pre_nextnv = nextnv;
+ System.out.printf(" generated an item... \n");
+ }
+ m_act.setHandler(slotKeyId, linkhandler);
+
+ long handler = m_act.getHandler(slotKeyId);
+
+ DurableNodeValue<DurableNodeValue<Double>> linkedvals = DurableNodeValueFactory.restore(m_act,
+ linkedefproxies, linkedgftypes, handler, false);
+ Iterator<DurableNodeValue<Double>> iter = linkedvals.iterator();
+ Iterator<Double> elemiter = null;
+
+ System.out.printf(" Stage 2 -testLinkedNodeValueWithLinkedNodeValue--> \n");
+ while (iter.hasNext()) {
+ elemiter = iter.next().iterator();
+ while (elemiter.hasNext()) {
+ System.out.printf("%f ", elemiter.next());
+ }
+ System.out.printf(" Fetched an item... \n");
+ }
+
+ // Assert.assert, expected);(plist, plist2);
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/679bcdc1/collections/src/test/java/org/apache/mnemonic/collections/DurablePersonNGTest.java
----------------------------------------------------------------------
diff --git a/collections/src/test/java/org/apache/mnemonic/collections/DurablePersonNGTest.java b/collections/src/test/java/org/apache/mnemonic/collections/DurablePersonNGTest.java
new file mode 100644
index 0000000..7694b6d
--- /dev/null
+++ b/collections/src/test/java/org/apache/mnemonic/collections/DurablePersonNGTest.java
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mnemonic.collections;
+
+import org.apache.mnemonic.NonVolatileMemAllocator;
+import org.apache.mnemonic.OutOfHybridMemory;
+import org.apache.mnemonic.Reclaim;
+import org.apache.mnemonic.RetrieveDurableEntityError;
+import org.apache.mnemonic.Utils;
+import org.testng.annotations.Test;
+import java.nio.ByteBuffer;
+import java.util.Random;
+import java.util.UUID;
+
+/**
+ *
+ *
+ */
+
+public class DurablePersonNGTest {
+ private long cKEYCAPACITY;
+
+ @Test(expectedExceptions = { OutOfHybridMemory.class })
+ public void testGenPeople() throws OutOfHybridMemory, RetrieveDurableEntityError {
+ Random rand = Utils.createRandom();
+ NonVolatileMemAllocator act = new NonVolatileMemAllocator(Utils.getNonVolatileMemoryAllocatorService("pmalloc"),
+ 1024 * 1024 * 8, "./pobj_person.dat", true);
+ cKEYCAPACITY = act.handlerCapacity();
+ act.setBufferReclaimer(new Reclaim<ByteBuffer>() {
+ @Override
+ public boolean reclaim(ByteBuffer mres, Long sz) {
+ System.out.println(String.format("Reclaim Memory Buffer: %X Size: %s", System.identityHashCode(mres),
+ null == sz ? "NULL" : sz.toString()));
+ return false;
+ }
+ });
+ act.setChunkReclaimer(new Reclaim<Long>() {
+ @Override
+ public boolean reclaim(Long mres, Long sz) {
+ System.out.println(String.format("Reclaim Memory Chunk: %X Size: %s", System.identityHashCode(mres),
+ null == sz ? "NULL" : sz.toString()));
+ return false;
+ }
+ });
+
+ for (long i = 0; i < cKEYCAPACITY; ++i) {
+ act.setHandler(i, 0L);
+ }
+
+ Person<Integer> mother;
+ Person<Integer> person;
+
+ long keyidx = 0;
+ long val;
+
+ try {
+ while (true) {
+ // if (keyidx >= KEYCAPACITY) break;
+
+ keyidx %= cKEYCAPACITY;
+
+ System.out.printf("************ Generating People on Key %d ***********\n", keyidx);
+
+ val = act.getHandler(keyidx);
+ if (0L != val) {
+ PersonFactory.restore(act, val, true);
+ }
+
+ person = PersonFactory.create(act);
+ person.setAge((short) rand.nextInt(50));
+ person.setName(String.format("Name: [%s]", UUID.randomUUID().toString()), true);
+ person.setName(String.format("Name: [%s]", UUID.randomUUID().toString()), true);
+ person.setName(String.format("Name: [%s]", UUID.randomUUID().toString()), true);
+ person.setName(String.format("Name: [%s]", UUID.randomUUID().toString()), true);
+
+ act.setHandler(keyidx, person.getHandler());
+
+ for (int deep = 0; deep < rand.nextInt(100); ++deep) {
+
+ mother = PersonFactory.create(act);
+ mother.setAge((short) (50 + rand.nextInt(50)));
+ mother.setName(String.format("Name: [%s]", UUID.randomUUID().toString()), true);
+
+ person.setMother(mother, true);
+
+ person = mother;
+
+ }
+ ++keyidx;
+ }
+ } finally {
+ act.close();
+ }
+ }
+
+ @Test(dependsOnMethods = { "testGenPeople" })
+ public void testCheckPeople() throws RetrieveDurableEntityError {
+ NonVolatileMemAllocator act = new NonVolatileMemAllocator(Utils.getNonVolatileMemoryAllocatorService("pmalloc"),
+ 1024 * 1024 * 8, "./pobj_person.dat", true);
+ act.setBufferReclaimer(new Reclaim<ByteBuffer>() {
+ @Override
+ public boolean reclaim(ByteBuffer mres, Long sz) {
+ System.out.println(String.format("Reclaim Memory Buffer: %X Size: %s", System.identityHashCode(mres),
+ null == sz ? "NULL" : sz.toString()));
+ return false;
+ }
+ });
+ act.setChunkReclaimer(new Reclaim<Long>() {
+ @Override
+ public boolean reclaim(Long mres, Long sz) {
+ System.out.println(String.format("Reclaim Memory Chunk: %X Size: %s", System.identityHashCode(mres),
+ null == sz ? "NULL" : sz.toString()));
+ return false;
+ }
+ });
+
+ long val;
+ for (long i = 0; i < cKEYCAPACITY; ++i) {
+ System.out.printf("----------Key %d--------------\n", i);
+ val = act.getHandler(i);
+ if (0L == val) {
+ break;
+ }
+ Person<Integer> person = PersonFactory.restore(act, val, true);
+ while (null != person) {
+ person.testOutput();
+ person = person.getMother();
+ }
+ }
+
+ act.close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/679bcdc1/collections/src/test/java/org/apache/mnemonic/collections/NonVolatileNodeValueNGTest.java
----------------------------------------------------------------------
diff --git a/collections/src/test/java/org/apache/mnemonic/collections/NonVolatileNodeValueNGTest.java b/collections/src/test/java/org/apache/mnemonic/collections/NonVolatileNodeValueNGTest.java
deleted file mode 100644
index ae122f7..0000000
--- a/collections/src/test/java/org/apache/mnemonic/collections/NonVolatileNodeValueNGTest.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.mnemonic.collections;
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Random;
-
-import org.apache.mnemonic.BigDataPMemAllocator;
-import org.apache.mnemonic.CommonPersistAllocator;
-import org.apache.mnemonic.Durable;
-import org.apache.mnemonic.EntityFactoryProxy;
-import org.apache.mnemonic.GenericField;
-import org.apache.mnemonic.Reclaim;
-import org.apache.mnemonic.Utils;
-import org.testng.AssertJUnit;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- *
- *
- */
-
-public class NonVolatileNodeValueNGTest {
- private long cKEYCAPACITY;
- private Random m_rand;
- private BigDataPMemAllocator m_act;
-
- @BeforeClass
- public void setUp() {
- m_rand = Utils.createRandom();
- m_act = new BigDataPMemAllocator(Utils.getNonVolatileMemoryAllocatorService("pmalloc"), 1024 * 1024 * 1024,
- "./pobj_NodeValue.dat", true);
- cKEYCAPACITY = m_act.handlerCapacity();
- m_act.setBufferReclaimer(new Reclaim<ByteBuffer>() {
- @Override
- public boolean reclaim(ByteBuffer mres, Long sz) {
- System.out.println(String.format("Reclaim Memory Buffer: %X Size: %s", System.identityHashCode(mres),
- null == sz ? "NULL" : sz.toString()));
- return false;
- }
- });
- m_act.setChunkReclaimer(new Reclaim<Long>() {
- @Override
- public boolean reclaim(Long mres, Long sz) {
- System.out.println(String.format("Reclaim Memory Chunk: %X Size: %s", System.identityHashCode(mres),
- null == sz ? "NULL" : sz.toString()));
- return false;
- }
- });
-
- for (long i = 0; i < cKEYCAPACITY; ++i) {
- m_act.setHandler(i, 0L);
- }
- }
-
- @AfterClass
- public void tearDown() {
- m_act.close();
- }
-
- @Test(enabled = false)
- public void testSingleNodeValueWithInteger() {
- int val = m_rand.nextInt();
- GenericField.GType gtypes[] = {GenericField.GType.INTEGER};
- NonVolatileNodeValue<Integer> plln = NonVolatileNodeValueFactory.create(m_act, null, gtypes, false);
- plln.setItem(val, false);
- Long handler = plln.getNonVolatileHandler();
- System.err.println("-------------Start to Restore Integer -----------");
- NonVolatileNodeValue<Integer> plln2 = NonVolatileNodeValueFactory.restore(m_act, null, gtypes, handler, false);
- AssertJUnit.assertEquals(val, (int) plln2.getItem());
- }
-
- @Test(enabled = false)
- public void testNodeValueWithString() {
- String val = Utils.genRandomString();
- GenericField.GType gtypes[] = {GenericField.GType.STRING};
- NonVolatileNodeValue<String> plln = NonVolatileNodeValueFactory.create(m_act, null, gtypes, false);
- plln.setItem(val, false);
- Long handler = plln.getNonVolatileHandler();
- System.err.println("-------------Start to Restore String-----------");
- NonVolatileNodeValue<String> plln2 = NonVolatileNodeValueFactory.restore(m_act, null, gtypes, handler, false);
- AssertJUnit.assertEquals(val, plln2.getItem());
- }
-
- @Test(enabled = false)
- public void testNodeValueWithPerson() {
-
- Person<Long> person = PersonFactory.create(m_act);
- person.setAge((short) 31);
-
- GenericField.GType gtypes[] = {GenericField.GType.DURABLE};
- EntityFactoryProxy efproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends CommonPersistAllocator<A>> Durable restore(A allocator, EntityFactoryProxy[] factoryproxys,
- GenericField.GType[] gfields, long phandler, boolean autoreclaim) {
- return PersonFactory.restore(allocator, factoryproxys, gfields, phandler, autoreclaim);
- }
- } };
-
- NonVolatileNodeValue<Person<Long>> plln = NonVolatileNodeValueFactory.create(m_act, efproxies, gtypes, false);
- plln.setItem(person, false);
- Long handler = plln.getNonVolatileHandler();
-
- NonVolatileNodeValue<Person<Long>> plln2 = NonVolatileNodeValueFactory.restore(m_act, efproxies, gtypes, handler,
- false);
- AssertJUnit.assertEquals(31, (int) plln2.getItem().getAge());
-
- }
-
- @Test(enabled = false)
- public void testLinkedNodeValueWithPerson() {
-
- int elem_count = 10;
- List<Long> referlist = new ArrayList();
-
- GenericField.GType listgftypes[] = {GenericField.GType.DURABLE};
- EntityFactoryProxy listefproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends CommonPersistAllocator<A>> Durable restore(A allocator, EntityFactoryProxy[] factoryproxys,
- GenericField.GType[] gfields, long phandler, boolean autoreclaim) {
- return PersonFactory.restore(allocator, factoryproxys, gfields, phandler, autoreclaim);
- }
- } };
-
- NonVolatileNodeValue<Person<Long>> firstnv = NonVolatileNodeValueFactory.create(m_act, listefproxies, listgftypes,
- false);
-
- NonVolatileNodeValue<Person<Long>> nextnv = firstnv;
-
- Person<Long> person;
- long val;
- NonVolatileNodeValue<Person<Long>> newnv;
- for (int i = 0; i < elem_count; ++i) {
- person = PersonFactory.create(m_act);
- person.setAge((short) m_rand.nextInt(50));
- person.setName(String.format("Name: [%s]", Utils.genRandomString()), true);
- nextnv.setItem(person, false);
- newnv = NonVolatileNodeValueFactory.create(m_act, listefproxies, listgftypes, false);
- nextnv.setNext(newnv, false);
- nextnv = newnv;
- }
-
- Person<Long> eval;
- NonVolatileNodeValue<Person<Long>> iternv = firstnv;
- while (null != iternv) {
- System.out.printf(" Stage 1 --->\n");
- eval = iternv.getItem();
- if (null != eval) {
- eval.testOutput();
- }
- iternv = iternv.getNext();
- }
-
- long handler = firstnv.getNonVolatileHandler();
-
- NonVolatileNodeValue<Person<Long>> firstnv2 = NonVolatileNodeValueFactory.restore(m_act, listefproxies, listgftypes,
- handler, false);
-
- for (Person<Long> eval2 : firstnv2) {
- System.out.printf(" Stage 2 ---> \n");
- if (null != eval2) {
- eval2.testOutput();
- }
- }
-
- // Assert.assert, expected);(plist, plist2);
-
- }
-
- @Test(enabled = true)
- public void testLinkedNodeValueWithLinkedNodeValue() {
-
- int elem_count = 10;
- long slotKeyId = 10;
-
- GenericField.GType[] elem_gftypes = {GenericField.GType.DOUBLE};
- EntityFactoryProxy[] elem_efproxies = null;
-
- GenericField.GType linkedgftypes[] = {GenericField.GType.DURABLE, GenericField.GType.DOUBLE};
- EntityFactoryProxy linkedefproxies[] = {new EntityFactoryProxy() {
- @Override
- public <A extends CommonPersistAllocator<A>> Durable restore(A allocator, EntityFactoryProxy[] factoryproxys,
- GenericField.GType[] gfields, long phandler, boolean autoreclaim) {
- EntityFactoryProxy[] val_efproxies = null;
- GenericField.GType[] val_gftypes = null;
- if (null != factoryproxys && factoryproxys.length >= 2) {
- val_efproxies = Arrays.copyOfRange(factoryproxys, 1, factoryproxys.length);
- }
- if (null != gfields && gfields.length >= 2) {
- val_gftypes = Arrays.copyOfRange(gfields, 1, gfields.length);
- }
- return NonVolatileNodeValueFactory.restore(allocator, val_efproxies, val_gftypes, phandler, autoreclaim);
- }
- } };
-
- NonVolatileNodeValue<NonVolatileNodeValue<Double>> nextnv = null, pre_nextnv = null;
- NonVolatileNodeValue<Double> elem = null, pre_elem = null, first_elem = null;
-
- Long linkhandler = 0L;
-
- System.out.printf(" Stage 1 -testLinkedNodeValueWithLinkedNodeValue--> \n");
-
- pre_nextnv = null;
- Double val;
- for (int i = 0; i < elem_count; ++i) {
- first_elem = null;
- pre_elem = null;
- for (int v = 0; v < 3; ++v) {
- elem = NonVolatileNodeValueFactory.create(m_act, elem_efproxies, elem_gftypes, false);
- val = m_rand.nextDouble();
- elem.setItem(val, false);
- if (null == pre_elem) {
- first_elem = elem;
- } else {
- pre_elem.setNext(elem, false);
- }
- pre_elem = elem;
- System.out.printf("%f ", val);
- }
-
- nextnv = NonVolatileNodeValueFactory.create(m_act, linkedefproxies, linkedgftypes, false);
- nextnv.setItem(first_elem, false);
- if (null == pre_nextnv) {
- linkhandler = nextnv.getNonVolatileHandler();
- } else {
- pre_nextnv.setNext(nextnv, false);
- }
- pre_nextnv = nextnv;
- System.out.printf(" generated an item... \n");
- }
- m_act.setHandler(slotKeyId, linkhandler);
-
- long handler = m_act.getHandler(slotKeyId);
-
- NonVolatileNodeValue<NonVolatileNodeValue<Double>> linkedvals = NonVolatileNodeValueFactory.restore(m_act,
- linkedefproxies, linkedgftypes, handler, false);
- Iterator<NonVolatileNodeValue<Double>> iter = linkedvals.iterator();
- Iterator<Double> elemiter = null;
-
- System.out.printf(" Stage 2 -testLinkedNodeValueWithLinkedNodeValue--> \n");
- while (iter.hasNext()) {
- elemiter = iter.next().iterator();
- while (elemiter.hasNext()) {
- System.out.printf("%f ", elemiter.next());
- }
- System.out.printf(" Fetched an item... \n");
- }
-
- // Assert.assert, expected);(plist, plist2);
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/679bcdc1/collections/src/test/java/org/apache/mnemonic/collections/NonVolatilePersonNGTest.java
----------------------------------------------------------------------
diff --git a/collections/src/test/java/org/apache/mnemonic/collections/NonVolatilePersonNGTest.java b/collections/src/test/java/org/apache/mnemonic/collections/NonVolatilePersonNGTest.java
deleted file mode 100644
index 42cfc16..0000000
--- a/collections/src/test/java/org/apache/mnemonic/collections/NonVolatilePersonNGTest.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.mnemonic.collections;
-
-import org.apache.mnemonic.BigDataPMemAllocator;
-import org.apache.mnemonic.OutOfPersistentMemory;
-import org.apache.mnemonic.Reclaim;
-import org.apache.mnemonic.RetrieveNonVolatileEntityError;
-import org.apache.mnemonic.Utils;
-import org.testng.annotations.Test;
-import java.nio.ByteBuffer;
-import java.util.Random;
-import java.util.UUID;
-
-/**
- *
- *
- */
-
-public class NonVolatilePersonNGTest {
- private long cKEYCAPACITY;
-
- @Test(expectedExceptions = { OutOfPersistentMemory.class })
- public void testGenPeople() throws OutOfPersistentMemory, RetrieveNonVolatileEntityError {
- Random rand = Utils.createRandom();
- BigDataPMemAllocator act = new BigDataPMemAllocator(Utils.getNonVolatileMemoryAllocatorService("pmalloc"),
- 1024 * 1024 * 8, "./pobj_person.dat", true);
- cKEYCAPACITY = act.handlerCapacity();
- act.setBufferReclaimer(new Reclaim<ByteBuffer>() {
- @Override
- public boolean reclaim(ByteBuffer mres, Long sz) {
- System.out.println(String.format("Reclaim Memory Buffer: %X Size: %s", System.identityHashCode(mres),
- null == sz ? "NULL" : sz.toString()));
- return false;
- }
- });
- act.setChunkReclaimer(new Reclaim<Long>() {
- @Override
- public boolean reclaim(Long mres, Long sz) {
- System.out.println(String.format("Reclaim Memory Chunk: %X Size: %s", System.identityHashCode(mres),
- null == sz ? "NULL" : sz.toString()));
- return false;
- }
- });
-
- for (long i = 0; i < cKEYCAPACITY; ++i) {
- act.setHandler(i, 0L);
- }
-
- Person<Integer> mother;
- Person<Integer> person;
-
- long keyidx = 0;
- long val;
-
- try {
- while (true) {
- // if (keyidx >= KEYCAPACITY) break;
-
- keyidx %= cKEYCAPACITY;
-
- System.out.printf("************ Generating People on Key %d ***********\n", keyidx);
-
- val = act.getHandler(keyidx);
- if (0L != val) {
- PersonFactory.restore(act, val, true);
- }
-
- person = PersonFactory.create(act);
- person.setAge((short) rand.nextInt(50));
- person.setName(String.format("Name: [%s]", UUID.randomUUID().toString()), true);
- person.setName(String.format("Name: [%s]", UUID.randomUUID().toString()), true);
- person.setName(String.format("Name: [%s]", UUID.randomUUID().toString()), true);
- person.setName(String.format("Name: [%s]", UUID.randomUUID().toString()), true);
-
- act.setHandler(keyidx, person.getNonVolatileHandler());
-
- for (int deep = 0; deep < rand.nextInt(100); ++deep) {
-
- mother = PersonFactory.create(act);
- mother.setAge((short) (50 + rand.nextInt(50)));
- mother.setName(String.format("Name: [%s]", UUID.randomUUID().toString()), true);
-
- person.setMother(mother, true);
-
- person = mother;
-
- }
- ++keyidx;
- }
- } finally {
- act.close();
- }
- }
-
- @Test(dependsOnMethods = { "testGenPeople" })
- public void testCheckPeople() throws RetrieveNonVolatileEntityError {
- BigDataPMemAllocator act = new BigDataPMemAllocator(Utils.getNonVolatileMemoryAllocatorService("pmalloc"),
- 1024 * 1024 * 8, "./pobj_person.dat", true);
- act.setBufferReclaimer(new Reclaim<ByteBuffer>() {
- @Override
- public boolean reclaim(ByteBuffer mres, Long sz) {
- System.out.println(String.format("Reclaim Memory Buffer: %X Size: %s", System.identityHashCode(mres),
- null == sz ? "NULL" : sz.toString()));
- return false;
- }
- });
- act.setChunkReclaimer(new Reclaim<Long>() {
- @Override
- public boolean reclaim(Long mres, Long sz) {
- System.out.println(String.format("Reclaim Memory Chunk: %X Size: %s", System.identityHashCode(mres),
- null == sz ? "NULL" : sz.toString()));
- return false;
- }
- });
-
- long val;
- for (long i = 0; i < cKEYCAPACITY; ++i) {
- System.out.printf("----------Key %d--------------\n", i);
- val = act.getHandler(i);
- if (0L == val) {
- break;
- }
- Person<Integer> person = PersonFactory.restore(act, val, true);
- while (null != person) {
- person.testOutput();
- person = person.getMother();
- }
- }
-
- act.close();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/679bcdc1/collections/src/test/java/org/apache/mnemonic/collections/Person.java
----------------------------------------------------------------------
diff --git a/collections/src/test/java/org/apache/mnemonic/collections/Person.java b/collections/src/test/java/org/apache/mnemonic/collections/Person.java
index 259bee9..5210847 100644
--- a/collections/src/test/java/org/apache/mnemonic/collections/Person.java
+++ b/collections/src/test/java/org/apache/mnemonic/collections/Person.java
@@ -20,11 +20,11 @@ package org.apache.mnemonic.collections;
import org.apache.mnemonic.Durable;
import org.apache.mnemonic.EntityFactoryProxy;
import org.apache.mnemonic.GenericField;
-import org.apache.mnemonic.NonVolatileEntity;
-import org.apache.mnemonic.NonVolatileGetter;
-import org.apache.mnemonic.NonVolatileSetter;
-import org.apache.mnemonic.OutOfPersistentMemory;
-import org.apache.mnemonic.RetrieveNonVolatileEntityError;
+import org.apache.mnemonic.DurableEntity;
+import org.apache.mnemonic.DurableGetter;
+import org.apache.mnemonic.DurableSetter;
+import org.apache.mnemonic.OutOfHybridMemory;
+import org.apache.mnemonic.RetrieveDurableEntityError;
import org.testng.annotations.Test;
/**
@@ -32,7 +32,7 @@ import org.testng.annotations.Test;
*
*/
-@NonVolatileEntity
+@DurableEntity
public abstract class Person<E> implements Durable, Comparable<Person<E>> {
E element;
@@ -52,7 +52,7 @@ public abstract class Person<E> implements Durable, Comparable<Person<E>> {
}
@Test
- public void testOutput() throws RetrieveNonVolatileEntityError {
+ public void testOutput() throws RetrieveDurableEntityError {
System.out.printf("Person %s, Age: %d ( %s ) \n", getName(), getAge(),
null == getMother() ? "No Recorded Mother" : "Has Recorded Mother");
}
@@ -68,28 +68,28 @@ public abstract class Person<E> implements Durable, Comparable<Person<E>> {
return ret;
}
- @NonVolatileGetter(Id = 1L)
+ @DurableGetter(Id = 1L)
public abstract Short getAge();
- @NonVolatileSetter
+ @DurableSetter
public abstract void setAge(Short age);
- @NonVolatileGetter(Id = 2L)
- public abstract String getName() throws RetrieveNonVolatileEntityError;
+ @DurableGetter(Id = 2L)
+ public abstract String getName() throws RetrieveDurableEntityError;
- @NonVolatileSetter
+ @DurableSetter
public abstract void setName(String name, boolean destroy)
- throws OutOfPersistentMemory, RetrieveNonVolatileEntityError;
+ throws OutOfHybridMemory, RetrieveDurableEntityError;
- @NonVolatileGetter(Id = 3L)
- public abstract Person<E> getMother() throws RetrieveNonVolatileEntityError;
+ @DurableGetter(Id = 3L)
+ public abstract Person<E> getMother() throws RetrieveDurableEntityError;
- @NonVolatileSetter
- public abstract void setMother(Person<E> mother, boolean destroy) throws RetrieveNonVolatileEntityError;
+ @DurableSetter
+ public abstract void setMother(Person<E> mother, boolean destroy) throws RetrieveDurableEntityError;
- @NonVolatileGetter(Id = 4L)
- public abstract Person<E> getFather() throws RetrieveNonVolatileEntityError;
+ @DurableGetter(Id = 4L)
+ public abstract Person<E> getFather() throws RetrieveDurableEntityError;
- @NonVolatileSetter
- public abstract void setFather(Person<E> mother, boolean destroy) throws RetrieveNonVolatileEntityError;
+ @DurableSetter
+ public abstract void setFather(Person<E> mother, boolean destroy) throws RetrieveDurableEntityError;
}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/679bcdc1/collections/src/test/resources/testng.xml
----------------------------------------------------------------------
diff --git a/collections/src/test/resources/testng.xml b/collections/src/test/resources/testng.xml
index eeacf58..eb82560 100644
--- a/collections/src/test/resources/testng.xml
+++ b/collections/src/test/resources/testng.xml
@@ -3,7 +3,7 @@
<suite name="Suite" verbose="1" parallel="tests" thread-count="1">
<test name="Test">
<classes>
- <class name="org.apache.mnemonic.collections.NonVolatileNodeValueNGTest"/>
+ <class name="org.apache.mnemonic.collections.DurableNodeValueNGTest"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
@@ -11,7 +11,7 @@
<!--
<class name="org.apache.mnemonic.collections.Person"/>
- <class name="org.apache.mnemonic.collections.NonVolatilePersonNGTest"/>
- <class name="org.apache.mnemonic.collections.NonVolatileListNGTest"/>
- <class name="org.apache.mnemonic.collections.NonVolatileNodeValueNGTest"/>
+ <class name="org.apache.mnemonic.collections.DurablePersonNGTest"/>
+ <class name="org.apache.mnemonic.collections.DurableListNGTest"/>
+ <class name="org.apache.mnemonic.collections.DurableNodeValueNGTest"/>
-->
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/679bcdc1/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index 91751f7..00b2855 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -62,7 +62,7 @@
<configuration>
<compilerArguments>-XDenableSunApiLintControl</compilerArguments>
<processors>
- <processor>${project.groupId}.NonVolatileEntityProcessor</processor>
+ <processor>${project.groupId}.DurableEntityProcessor</processor>
</processors>
</configuration>
</execution>