joafip-svn Mailing List for java data object persistence in file (Page 18)
Brought to you by:
luc_peuvrier
You can subscribe to this list here.
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(4) |
Oct
(102) |
Nov
(52) |
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2012 |
Jan
(4) |
Feb
|
Mar
(14) |
Apr
(116) |
May
(100) |
Jun
(14) |
Jul
|
Aug
|
Sep
(30) |
Oct
|
Nov
(108) |
Dec
(2) |
|
From: <luc...@us...> - 2011-11-12 16:56:58
|
Revision: 2967
http://joafip.svn.sourceforge.net/joafip/?rev=2967&view=rev
Author: luc_peuvrier
Date: 2011-11-12 16:56:52 +0000 (Sat, 12 Nov 2011)
Log Message:
-----------
todo update. doc for debug added
Modified Paths:
--------------
trunk/joafip/doc/_todo.txt
Added Paths:
-----------
trunk/joafip/doc/_bug_tree.txt
trunk/joafip/doc/missing.txt
Added: trunk/joafip/doc/_bug_tree.txt
===================================================================
--- trunk/joafip/doc/_bug_tree.txt (rev 0)
+++ trunk/joafip/doc/_bug_tree.txt 2011-11-12 16:56:52 UTC (rev 2967)
@@ -0,0 +1,12 @@
+in memory : ok
+auto save:
+----------
+block file heap manager no cache --- ok?
+block file heap manager cache ------ ok?
+multi file ------------------------- ok?
+heap file data manager no cache ---- ko
+heap file data manager cache ------- ko
+dual bloxk/heapfile heap manager --- ko
+- no cache
+no auto save:
+-------------
\ No newline at end of file
Modified: trunk/joafip/doc/_todo.txt
===================================================================
--- trunk/joafip/doc/_todo.txt 2011-11-12 16:55:23 UTC (rev 2966)
+++ trunk/joafip/doc/_todo.txt 2011-11-12 16:56:52 UTC (rev 2967)
@@ -21,7 +21,9 @@
- project divided on sub project
- export speed up
- kept in memory for object referenced by static field
-- check field access constraints, direct field access disallow to force use of getter and/or setter
+- persisted class byte code checked for persistence constraints
+-- check field access constraints, direct field access disallow to force use of getter and/or setter
+-- check private method invocation of other instance
- static field persistence feature removed because a non sense
minor changes:
@@ -77,22 +79,22 @@
currently:
-------------------------------------------------------------------------------------
-persistence constraint check at enhancement for proxy creation
-==> update http://joafip.sourceforge.net/presentation/ppojo.html#prules
-- check done at enhancement -> exception
--- check direct field access
--- check private method invocation
+auto save problems with jhupedom:
+- HeapFileDataManager problem ?
-upgrade Maven plugins :
-maven-jar-plugin ..................................... 2.3.1 -> 2.3.2
-[INFO] maven-javadoc-plugin ..................................... 2.7 -> 2.8
-[INFO] maven-release-plugin ................................... 2.1 -> 2.2.1
-[INFO] org.codehaus.mojo:build-helper-maven-plugin .............. 1.5 -> 1.7
-[INFO] org.codehaus.mojo:buildnumber-maven-plugin ........ 1.0-beta-4 -> 1.0
-[INFO] org.codehaus.mojo:exec-maven-plugin .................... 1.2 -> 1.2.1
+export/import problem.
+- test with BlockDataManger
+- no more static field management
+xml file for export:
+ bad namespace xmlns="http://joafip.sourceforge.net/schema"
+ should be xmlns="http://joafip.sourceforge.net"
+ may be /joafip/src/main/java/net/sf/joafip/store/service/export_import/joafip.xsd to update
-export/import problem.
+BlockDataManger
+- test performance with cache, if ok it is a good alternative but:
+ - big file, do not reuse free space
+ - fixed max data record length
garbage management error with jhupedom
Added: trunk/joafip/doc/missing.txt
===================================================================
--- trunk/joafip/doc/missing.txt (rev 0)
+++ trunk/joafip/doc/missing.txt 2011-11-12 16:56:52 UTC (rev 2967)
@@ -0,0 +1,6 @@
+
+using BKM:
+missing list=[108738, 118200, 132948, 142808, 165872]
+
+using HeapFileDataManager:
+missing list=[108738, 118200, 132948, 142808, 165872]
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-12 16:55:30
|
Revision: 2966
http://joafip.svn.sourceforge.net/joafip/?rev=2966&view=rev
Author: luc_peuvrier
Date: 2011-11-12 16:55:23 +0000 (Sat, 12 Nov 2011)
Log Message:
-----------
added tests for export/import
Modified Paths:
--------------
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/entity/Item.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractInserter.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractPerfService.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractSearcher.java
Added Paths:
-----------
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/AbstractBugTree.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainCountMmf.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeBlockFile.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeDual.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeHeapFile.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeHeapFileNoAutoSave.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeHeapFileNoCache.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeMem.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeMultiFile.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/Tree.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/TreeMem.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/ExporterBKM.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBKM.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/SearcherBKM.java
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/AbstractBugTree.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/AbstractBugTree.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/AbstractBugTree.java 2011-11-12 16:55:23 UTC (rev 2966)
@@ -0,0 +1,38 @@
+package net.sf.joafip.bugtree;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.StorableAccess;
+import net.sf.joafip.redblacktree.service.RBTException;
+
+@NotStorableClass
+@StorableAccess
+public abstract class AbstractBugTree {
+
+ protected void appendLoop(Tree<String> tree) throws RBTException {// NOPMD
+ for (int count = 0; count < 1000000; count++) {
+ if (count % 1000 == 1) {
+ System.out.println("#" + count);// NOPMD
+ }
+ final String element = "elt #" + reverse(count);
+ tree = treeAppend(tree, count, element);
+ }
+ }
+
+ protected Tree<String> treeAppend(final Tree<String> tree, final int count,
+ final String element) throws RBTException {
+ try {
+ tree.append(element);
+ } catch (RBTException e) {
+ System.err.println("count=" + count); // NOPMD
+ throw e;
+ }
+ return tree;
+ }
+
+ private int reverse(final int value) {
+ return ((value >> 24) & 0xff) |
+ /**/(((value >> 16) & 0xff) << 8) |
+ /**/(((value >> 8) & 0xff) << 16) |
+ /**/(value << 24);
+ }
+}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainCountMmf.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainCountMmf.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainCountMmf.java 2011-11-12 16:55:23 UTC (rev 2966)
@@ -0,0 +1,46 @@
+package net.sf.joafip.bugtree;
+
+import java.io.File;
+
+public final class MainCountMmf {
+
+ private MainCountMmf() {
+ super();
+ }
+
+ public static void main(final String[] args) {
+ try {
+ final File root = new File("runtime/mmf");
+ while (true) {
+ File current = root;
+ current = lastDir(current, true);
+ current = lastDir(current, true);
+ current = lastDir(current, true);
+ current = lastDir(current, true);
+ current = lastDir(current, false);
+ System.out.println(current.getName()); // NOPMD
+ Thread.sleep(5000);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();// NOPMD
+ }
+ }
+
+ private static File lastDir(final File current, final boolean ofDirectory)
+ throws Exception {// NOPMD
+ if (!current.isDirectory()) {
+ throw new Exception(current + " is not a directory");// NOPMD
+ }
+ final File[] files = current.listFiles();
+ File result = null;
+ String name = "";
+ for (File file : files) {
+ if ((!ofDirectory || file.isDirectory())
+ && file.getName().compareTo(name) > 0) {
+ result = file;
+ name = file.getName();
+ }
+ }
+ return result;
+ }
+}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeBlockFile.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeBlockFile.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeBlockFile.java 2011-11-12 16:55:23 UTC (rev 2966)
@@ -0,0 +1,82 @@
+package net.sf.joafip.bugtree;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.StorableAccess;
+import net.sf.joafip.heapfile.service.BlockDataManager;
+import net.sf.joafip.heapfile.service.HeapException;
+import net.sf.joafip.heapfile.service.IHeapDataManager;
+import net.sf.joafip.redblacktree.service.RBTException;
+import net.sf.joafip.service.FilePersistenceBuilder;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.service.IAutoSaveEventListener;
+import net.sf.joafip.service.IExclusiveDataAccessSession;
+import net.sf.joafip.service.IFilePersistence;
+import net.sf.joafip.store.service.proxy.IInstanceFactory;
+
+@NotStorableClass
+@StorableAccess
+public final class MainTreeBlockFile extends AbstractBugTree implements
+ IAutoSaveEventListener {
+
+ private MainTreeBlockFile() {
+ super();
+ }
+
+ public static void main(final String[] args) {
+ try {
+ final MainTreeBlockFile main = new MainTreeBlockFile();
+ main.run();
+ } catch (Exception e) {
+ e.printStackTrace();// NOPMD
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void run() throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceTooBigForSerializationException, RBTException,
+ HeapException {
+ final FilePersistenceBuilder builder = new FilePersistenceBuilder();
+ final IHeapDataManager dataManager = new BlockDataManager(10 * 1024, 10 * 1024,1024);
+ builder.setDataManager(dataManager);
+ builder.setProxyMode(true);
+ builder.setRemoveFiles(true);
+ builder.setCrashSafeMode(false);
+ builder.setGarbageManagement(false);
+ builder.setAutoSaveEnabled(true);
+ builder.setMaxInMemoryThreshold(1000);
+ builder.setMaintenedInMemory(false);
+ // builder.setMaintenedInMemoryQuota(100);
+ final IFilePersistence filePersistence = builder.build();
+ filePersistence.setAutoSaveEventListener(this);
+ final IExclusiveDataAccessSession session = filePersistence
+ .createExclusiveDataAccessSession();
+ final IInstanceFactory instanceFactory = session.getInstanceFactory();
+
+ session.open();
+ final Tree<String> tree = Tree.newInstance(instanceFactory);
+ appendLoop(tree);
+ session.close();
+ filePersistence.close();
+ }
+
+ @Override
+ public boolean doSave() {
+ return true;
+ }
+
+ @Override
+ public void saveDone(final int numberOfObjectState,
+ final int numberOfWeakreference, final long msDuration) {
+ System.out.println("n=" + numberOfObjectState + " w="// NOPMD
+ + numberOfWeakreference + " t=" + msDuration + " mS");
+ }
+}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeDual.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeDual.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeDual.java 2011-11-12 16:55:23 UTC (rev 2966)
@@ -0,0 +1,98 @@
+package net.sf.joafip.bugtree;
+
+import java.io.File;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.StorableAccess;
+import net.sf.joafip.TestException;
+import net.sf.joafip.heapfile.entity.HeapFileSetup;
+import net.sf.joafip.heapfile.service.BlockDataManager;
+import net.sf.joafip.heapfile.service.DualWrapDataManager;
+import net.sf.joafip.heapfile.service.HeapException;
+import net.sf.joafip.heapfile.service.HeapFileDataManager;
+import net.sf.joafip.heapfile.service.IHeapDataManager;
+import net.sf.joafip.redblacktree.service.RBTException;
+import net.sf.joafip.service.FilePersistenceBuilder;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.service.IAutoSaveEventListener;
+import net.sf.joafip.service.IExclusiveDataAccessSession;
+import net.sf.joafip.service.IFilePersistence;
+import net.sf.joafip.store.service.proxy.IInstanceFactory;
+
+@NotStorableClass
+@StorableAccess
+public final class MainTreeDual extends AbstractBugTree implements
+ IAutoSaveEventListener {
+
+ private MainTreeDual() {
+ super();
+ }
+
+ public static void main(final String[] args) {
+ try {
+ final MainTreeDual main = new MainTreeDual();
+ main.run();
+ } catch (Exception e) {
+ e.printStackTrace();// NOPMD
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void run() throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceTooBigForSerializationException, RBTException,
+ HeapException, TestException {
+ final FilePersistenceBuilder builder = new FilePersistenceBuilder();
+ final String dir = "runtime";//TestConstant.getWinRamDiskRuntimeDir();
+ final IHeapDataManager blockDataManager = new BlockDataManager(dir+"/data",1024);
+// 10 * 1024, 10 * 1024);
+ final HeapFileSetup setup = new HeapFileSetup(new File(dir+"/store.data"), false/*crashSafeMode*/,
+ false/*useCacheMode*/,false/*deleteRenaming*/, false/*clearResizeFile*/,
+ 0/*maxFileOperationRetry*/,0/*fileOperationRetryMsDelay*/,
+ new File("runtime/openFileTraceFile.txt"));
+ final IHeapDataManager fileDataManager = new HeapFileDataManager(setup);
+
+ builder.setDataManager(new DualWrapDataManager(fileDataManager,
+ blockDataManager));
+
+ builder.setProxyMode(true);
+ builder.setRemoveFiles(true);
+ builder.setCrashSafeMode(false);
+ builder.setGarbageManagement(false);
+ builder.setAutoSaveEnabled(true);
+ builder.setMaxInMemoryThreshold(1000);
+ builder.setMaintenedInMemory(false);
+ // builder.setMaintenedInMemoryQuota(100);
+ final IFilePersistence filePersistence = builder.build();
+ filePersistence.setAutoSaveEventListener(this);
+ final IExclusiveDataAccessSession session = filePersistence
+ .createExclusiveDataAccessSession();
+ final IInstanceFactory instanceFactory = session.getInstanceFactory();
+
+ session.open();
+ final Tree<String> tree = Tree.newInstance(instanceFactory);
+ appendLoop(tree);
+ session.close();
+ filePersistence.close();
+ }
+
+ @Override
+ public boolean doSave() {
+ return true;
+ }
+
+ @Override
+ public void saveDone(final int numberOfObjectState,
+ final int numberOfWeakreference, final long msDuration) {
+ System.out.println("n=" + numberOfObjectState + " w="// NOPMD
+ + numberOfWeakreference + " t=" + msDuration + " mS");
+ }
+}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeHeapFile.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeHeapFile.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeHeapFile.java 2011-11-12 16:55:23 UTC (rev 2966)
@@ -0,0 +1,63 @@
+package net.sf.joafip.bugtree;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.StorableAccess;
+import net.sf.joafip.redblacktree.service.RBTException;
+import net.sf.joafip.service.FilePersistenceBuilder;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.service.IExclusiveDataAccessSession;
+import net.sf.joafip.service.IFilePersistence;
+import net.sf.joafip.store.service.proxy.IInstanceFactory;
+
+@NotStorableClass
+@StorableAccess
+public final class MainTreeHeapFile extends AbstractBugTree {
+
+ private MainTreeHeapFile() {
+ super();
+ }
+
+ public static void main(final String[] args) {
+ try {
+ final MainTreeHeapFile main = new MainTreeHeapFile();
+ main.run();
+ } catch (Exception e) {
+ e.printStackTrace();// NOPMD
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void run() throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceTooBigForSerializationException, RBTException {
+ final FilePersistenceBuilder builder = new FilePersistenceBuilder();
+ builder.setPathName("runtime");
+ builder.setFileCache(10 * 1024, 10 * 1024);
+ builder.setProxyMode(true);
+ builder.setRemoveFiles(true);
+ builder.setCrashSafeMode(false);
+ builder.setGarbageManagement(false);
+ builder.setAutoSaveEnabled(true);
+ builder.setMaxInMemoryThreshold(1000);
+ builder.setMaintenedInMemory(false);
+ // builder.setMaintenedInMemoryQuota(100);
+ final IFilePersistence filePersistence = builder.build();
+ final IExclusiveDataAccessSession session = filePersistence
+ .createExclusiveDataAccessSession();
+ final IInstanceFactory instanceFactory = session.getInstanceFactory();
+
+ session.open();
+ final Tree<String> tree = Tree.newInstance(instanceFactory);
+ appendLoop(tree);
+ session.close();
+ filePersistence.close();
+ }
+}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeHeapFileNoAutoSave.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeHeapFileNoAutoSave.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeHeapFileNoAutoSave.java 2011-11-12 16:55:23 UTC (rev 2966)
@@ -0,0 +1,86 @@
+package net.sf.joafip.bugtree;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.StorableAccess;
+import net.sf.joafip.entity.EnumFilePersistenceCloseAction;
+import net.sf.joafip.redblacktree.service.RBTException;
+import net.sf.joafip.service.FilePersistenceBuilder;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.service.IDataAccessSession;
+import net.sf.joafip.service.IFilePersistence;
+
+@NotStorableClass
+@StorableAccess
+public final class MainTreeHeapFileNoAutoSave extends AbstractBugTree {
+
+ private IDataAccessSession session;
+
+ private MainTreeHeapFileNoAutoSave() {
+ super();
+ }
+
+ public static void main(final String[] args) {
+ try {
+ final MainTreeHeapFileNoAutoSave main = new MainTreeHeapFileNoAutoSave();
+ main.run();
+ } catch (Exception e) {
+ e.printStackTrace();// NOPMD
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void run() throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceTooBigForSerializationException, RBTException {
+ final FilePersistenceBuilder builder = new FilePersistenceBuilder();
+ builder.setPathName("runtime");
+ builder.setFileCache(10 * 1024, 10 * 1024);
+ builder.setProxyMode(true);
+ builder.setRemoveFiles(true);
+ builder.setCrashSafeMode(false);
+ builder.setGarbageManagement(false);
+ // builder.setAutoSaveEnabled(true);
+ // builder.setMaxInMemoryThreshold(1000);
+ // builder.setMaintenedInMemory(false);
+ // // builder.setMaintenedInMemoryQuota(100);
+ final IFilePersistence filePersistence = builder.build();
+ session = filePersistence.createDataAccessSession();
+
+ session.open();
+ Tree<String> tree = new Tree<String>();
+ session.setObject("key", tree);
+ session.close(EnumFilePersistenceCloseAction.SAVE);
+
+ session.open();
+ tree = (Tree<String>) session.getObject("key");
+ appendLoop(tree);
+ session.close(EnumFilePersistenceCloseAction.SAVE);
+ filePersistence.close();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected Tree<String> treeAppend(final Tree<String> tree, final int count,
+ final String element) throws RBTException {
+ Tree<String> newTree = super.treeAppend(tree, count, element);
+ if (count % 1000 == 1) {
+ try {
+ session.close(EnumFilePersistenceCloseAction.SAVE);
+ session.open();
+ newTree = (Tree<String>) session.getObject("key");
+ } catch (Exception exception) {
+ throw new RBTException(exception);
+ }
+ }
+ return newTree;
+ }
+
+}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeHeapFileNoCache.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeHeapFileNoCache.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeHeapFileNoCache.java 2011-11-12 16:55:23 UTC (rev 2966)
@@ -0,0 +1,62 @@
+package net.sf.joafip.bugtree;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.StorableAccess;
+import net.sf.joafip.redblacktree.service.RBTException;
+import net.sf.joafip.service.FilePersistenceBuilder;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.service.IExclusiveDataAccessSession;
+import net.sf.joafip.service.IFilePersistence;
+import net.sf.joafip.store.service.proxy.IInstanceFactory;
+
+@NotStorableClass
+@StorableAccess
+public final class MainTreeHeapFileNoCache extends AbstractBugTree {
+
+ private MainTreeHeapFileNoCache() {
+ super();
+ }
+
+ public static void main(final String[] args) {
+ try {
+ final MainTreeHeapFileNoCache main = new MainTreeHeapFileNoCache();
+ main.run();
+ } catch (Exception e) {
+ e.printStackTrace();// NOPMD
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void run() throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceTooBigForSerializationException, RBTException {
+ final FilePersistenceBuilder builder = new FilePersistenceBuilder();
+ builder.setPathName("runtime");
+ builder.setProxyMode(true);
+ builder.setRemoveFiles(true);
+ builder.setCrashSafeMode(false);
+ builder.setGarbageManagement(false);
+ builder.setAutoSaveEnabled(true);
+ builder.setMaxInMemoryThreshold(1000);
+ builder.setMaintenedInMemory(false);
+ // builder.setMaintenedInMemoryQuota(100);
+ final IFilePersistence filePersistence = builder.build();
+ final IExclusiveDataAccessSession session = filePersistence
+ .createExclusiveDataAccessSession();
+ final IInstanceFactory instanceFactory = session.getInstanceFactory();
+
+ session.open();
+ final Tree<String> tree = Tree.newInstance(instanceFactory);
+ appendLoop(tree);
+ session.close();
+ filePersistence.close();
+ }
+}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeMem.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeMem.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeMem.java 2011-11-12 16:55:23 UTC (rev 2966)
@@ -0,0 +1,28 @@
+package net.sf.joafip.bugtree;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.StorableAccess;
+import net.sf.joafip.redblacktree.service.RBTException;
+
+@NotStorableClass
+@StorableAccess
+public final class MainTreeMem extends AbstractBugTree {
+
+ private MainTreeMem() {
+ super();
+ }
+
+ public static void main(final String[] args) {
+ try {
+ final MainTreeMem main = new MainTreeMem();
+ main.run();
+ } catch (Exception e) {
+ e.printStackTrace();// NOPMD
+ }
+ }
+
+ private void run() throws RBTException {
+ final TreeMem<String> tree = new TreeMem<String>();
+ appendLoop(tree);
+ }
+}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeMultiFile.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeMultiFile.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeMultiFile.java 2011-11-12 16:55:23 UTC (rev 2966)
@@ -0,0 +1,83 @@
+package net.sf.joafip.bugtree;
+
+import java.io.File;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.StorableAccess;
+import net.sf.joafip.heapfile.service.HeapMultiFileDataManager;
+import net.sf.joafip.heapfile.service.IHeapDataManager;
+import net.sf.joafip.redblacktree.service.RBTException;
+import net.sf.joafip.service.FilePersistenceBuilder;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.service.IAutoSaveEventListener;
+import net.sf.joafip.service.IExclusiveDataAccessSession;
+import net.sf.joafip.service.IFilePersistence;
+import net.sf.joafip.store.service.proxy.IInstanceFactory;
+
+@NotStorableClass
+@StorableAccess
+public final class MainTreeMultiFile extends AbstractBugTree implements
+ IAutoSaveEventListener {
+
+ private MainTreeMultiFile() {
+ super();
+ }
+
+ public static void main(final String[] args) {
+ try {
+ final MainTreeMultiFile main = new MainTreeMultiFile();
+ main.run();
+ } catch (Exception e) {
+ e.printStackTrace();// NOPMD
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void run() throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceTooBigForSerializationException, RBTException {
+ final FilePersistenceBuilder builder = new FilePersistenceBuilder();
+ final IHeapDataManager dataManager = new HeapMultiFileDataManager(
+ new File("runtime/mmf"));
+ builder.setDataManager(dataManager);
+ builder.setProxyMode(true);
+ builder.setRemoveFiles(true);
+ builder.setCrashSafeMode(false);
+ builder.setGarbageManagement(false);
+ builder.setAutoSaveEnabled(true);
+ builder.setMaxInMemoryThreshold(1000);
+ builder.setMaintenedInMemory(false);
+ // builder.setMaintenedInMemoryQuota(100);
+ final IFilePersistence filePersistence = builder.build();
+ filePersistence.setAutoSaveEventListener(this);
+ final IExclusiveDataAccessSession session = filePersistence
+ .createExclusiveDataAccessSession();
+ final IInstanceFactory instanceFactory = session.getInstanceFactory();
+
+ session.open();
+ final Tree<String> tree = Tree.newInstance(instanceFactory);
+ appendLoop(tree);
+ session.close();
+ filePersistence.close();
+ }
+
+ @Override
+ public boolean doSave() {
+ return true;
+ }
+
+ @Override
+ public void saveDone(final int numberOfObjectState,
+ final int numberOfWeakreference, final long msDuration) {
+ System.out.println("n=" + numberOfObjectState + " w="//NOPMD
+ + numberOfWeakreference + " t=" + msDuration + " mS");
+ }
+}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/Tree.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/Tree.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/Tree.java 2011-11-12 16:55:23 UTC (rev 2966)
@@ -0,0 +1,54 @@
+package net.sf.joafip.bugtree;
+
+import net.sf.joafip.AssertNotNull;
+import net.sf.joafip.StorableClass;
+import net.sf.joafip.redblacktree.entity.IRBTNode;
+import net.sf.joafip.redblacktree.impl.memory.entity.RBTNode;
+import net.sf.joafip.redblacktree.impl.memory.service.RBTNodeManager;
+import net.sf.joafip.redblacktree.service.RBTException;
+import net.sf.joafip.redblacktree.service.RedBlackTree;
+import net.sf.joafip.store.service.proxy.IInstanceFactory;
+
+@StorableClass
+public class Tree<E> {
+
+ @AssertNotNull
+ protected final RedBlackTree<E> redBlackTree;
+
+ protected final transient IInstanceFactory instanceFactory;
+
+ @SuppressWarnings("unchecked")
+ public Tree(final IInstanceFactory instanceFactory) {
+ super();
+ this.instanceFactory = instanceFactory;
+ final RBTNodeManager<E> nodeManager = RBTNodeManager
+ .newInstance(instanceFactory);
+ redBlackTree = RedBlackTree.newInstance(instanceFactory, nodeManager,
+ true/* manageNodeIndex */, true/* unique value */);
+
+ }
+
+ public Tree() {
+ this(null);
+ }
+
+ @SuppressWarnings("rawtypes")
+ public static Tree newInstance(final IInstanceFactory instanceFactory) {
+ final Tree newInstance;
+ if (instanceFactory == null) {
+ newInstance = new Tree(instanceFactory);
+ } else {
+ newInstance = (Tree) instanceFactory.newInstance(Tree.class,
+ new Class<?>[] { IInstanceFactory.class },
+ new Object[] { instanceFactory });
+ }
+ return newInstance;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void append(final E element) throws RBTException {
+ final IRBTNode<E> nodeToAppend = RBTNode.newInstance(instanceFactory,
+ element);
+ redBlackTree.append(nodeToAppend);
+ }
+}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/TreeMem.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/TreeMem.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/TreeMem.java 2011-11-12 16:55:23 UTC (rev 2966)
@@ -0,0 +1,29 @@
+package net.sf.joafip.bugtree;
+
+import net.sf.joafip.AssertNotNull;
+import net.sf.joafip.StorableClass;
+import net.sf.joafip.redblacktree.entity.IRBTNode;
+import net.sf.joafip.redblacktree.impl.memory.entity.RBTNode;
+import net.sf.joafip.redblacktree.impl.memory.service.RBTNodeManager;
+import net.sf.joafip.redblacktree.service.RBTException;
+import net.sf.joafip.redblacktree.service.RedBlackTree;
+
+@StorableClass
+public class TreeMem<E> extends Tree<E>{
+
+ @AssertNotNull
+ protected final RedBlackTree<E> redBlackTree;
+
+ public TreeMem() {
+ super(null);
+ final RBTNodeManager<E> nodeManager = new RBTNodeManager<E>();
+ redBlackTree = new RedBlackTree<E>(nodeManager,
+ true/* manageNodeIndex */, true/* unique value */);
+
+ }
+
+ public void append(final E element) throws RBTException {
+ final IRBTNode<E> nodeToAppend = new RBTNode<E>(element);
+ redBlackTree.append(nodeToAppend);
+ }
+}
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/entity/Item.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/entity/Item.java 2011-11-12 16:54:06 UTC (rev 2965)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/entity/Item.java 2011-11-12 16:55:23 UTC (rev 2966)
@@ -74,7 +74,7 @@
} else {
value = "" + valueFromItem;
}
- itemState = item.itemState;
+ itemState = item.getItemState();
}
public String getValue() {
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractInserter.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractInserter.java 2011-11-12 16:54:06 UTC (rev 2965)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractInserter.java 2011-11-12 16:55:23 UTC (rev 2966)
@@ -39,6 +39,7 @@
import net.sf.joafip.entity.EnumFilePersistenceCloseAction;
import net.sf.joafip.file.entity.PageNode;
import net.sf.joafip.file.service.RandomAccessFileReadWriteCache;
+import net.sf.joafip.heapfile.service.IHeapDataManager;
import net.sf.joafip.java.util.PLinkedTreeSet;
import net.sf.joafip.meminspector.service.MemInspectorException;
import net.sf.joafip.meminspector.service.inspect.MemInspector;
@@ -104,6 +105,15 @@
super(pathName);
}
+ public AbstractInserter(final IHeapDataManager dataManager)
+ throws FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException, FilePersistenceException,
+ FilePersistenceTooBigForSerializationException {
+ super(dataManager);
+ }
+
protected void run(final int numberOfItem) throws FilePersistenceException,
StoreException, FilePersistenceClassNotFoundException,
FilePersistenceInvalidClassException,
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractPerfService.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractPerfService.java 2011-11-12 16:54:06 UTC (rev 2965)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractPerfService.java 2011-11-12 16:55:23 UTC (rev 2966)
@@ -22,6 +22,7 @@
import net.sf.joafip.StorableAccess;
import net.sf.joafip.entity.EnumFilePersistenceCloseAction;
import net.sf.joafip.heapfile.entity.EnumFileState;
+import net.sf.joafip.heapfile.service.IHeapDataManager;
import net.sf.joafip.logger.JoafipLogger;
import net.sf.joafip.performance.items.entity.ItemList;
import net.sf.joafip.performance.items.entity.ItemTemplateList;
@@ -77,6 +78,10 @@
protected int byItemIndex;
+ private final String pathName;
+
+ private final IHeapDataManager dataManager;
+
public AbstractPerfService(final String pathName)
throws FilePersistenceException,
FilePersistenceInvalidClassException,
@@ -85,9 +90,35 @@
FilePersistenceDataCorruptedException, StoreClassNotFoundException,
FilePersistenceTooBigForSerializationException {
super();
+ this.pathName = pathName;
+ this.dataManager = null;// NOPMD
+ initialize();
+ }
+
+ public AbstractPerfService(final IHeapDataManager dataManager)
+ throws FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException, FilePersistenceException,
+ FilePersistenceTooBigForSerializationException {
+ super();
+ this.dataManager = dataManager;
+ this.pathName = null;// NOPMD
+ initialize();
+ }
+
+ private void initialize() throws FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException, FilePersistenceException,
+ FilePersistenceTooBigForSerializationException {
final FilePersistenceBuilder builder = new FilePersistenceBuilder();
try {
- builder.setPathName(pathName);
+ if (dataManager == null) {
+ builder.setPathName(pathName);
+ } else {
+ builder.setDataManager(dataManager);
+ }
builder.setRemoveFiles(false);
builder.setProxyMode(true);
builder.setCrashSafeMode(CRASH_SAFE_MODE);
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractSearcher.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractSearcher.java 2011-11-12 16:54:06 UTC (rev 2965)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractSearcher.java 2011-11-12 16:55:23 UTC (rev 2966)
@@ -30,6 +30,7 @@
import java.util.List;
import net.sf.joafip.entity.EnumFilePersistenceCloseAction;
+import net.sf.joafip.heapfile.service.IHeapDataManager;
import net.sf.joafip.logger.JoafipLogger;
import net.sf.joafip.performance.items.entity.ItemList;
import net.sf.joafip.service.FilePersistenceClassNotFoundException;
@@ -60,6 +61,15 @@
super(pathName);
}
+ public AbstractSearcher(final IHeapDataManager dataManager)
+ throws FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException, FilePersistenceException,
+ FilePersistenceTooBigForSerializationException {
+ super(dataManager);
+ }
+
protected void run() throws FilePersistenceException,
FilePersistenceClassNotFoundException,
FilePersistenceInvalidClassException,
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/ExporterBKM.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/ExporterBKM.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/ExporterBKM.java 2011-11-12 16:55:23 UTC (rev 2966)
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2010 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (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.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * 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 net.sf.joafip.performance.items.service;
+
+import net.sf.joafip.heapfile.service.BlockDataManager;
+import net.sf.joafip.heapfile.service.HeapException;
+import net.sf.joafip.heapfile.service.IHeapDataManager;
+import net.sf.joafip.logger.JoafipLogger;
+import net.sf.joafip.service.FilePersistenceBuilder;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.service.IFilePersistence;
+import net.sf.joafip.store.service.export_import.out.IExporterListener;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public final class ExporterBKM implements IExporterListener {
+
+ private final static JoafipLogger LOGGER = JoafipLogger
+ .getLogger(ExporterBKM.class);
+
+ private static final String RUNTIME_DIR = "runtime_perf";
+
+ public static void main(final String[] args) {
+ try {
+ final ExporterBKM exporter = new ExporterBKM();
+ exporter.run();
+ } catch (final Throwable throwable) {// NOPMD catch all
+ LOGGER.fatal("error", throwable);
+ }
+ }
+
+ private long startTime;
+
+ private ExporterBKM() {
+ super();
+ }
+
+ private void run() throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException,
+ FilePersistenceTooBigForSerializationException, HeapException {
+ final FilePersistenceBuilder builder = new FilePersistenceBuilder();
+ final String dataFile = RUNTIME_DIR + "/block.data";
+ final IHeapDataManager dataManager =
+ /**/new BlockDataManager(dataFile, 1024);
+ builder.setDataManager(dataManager);
+ builder.setProxyMode(true);
+ builder.setRemoveFiles(false);
+ builder.setGarbageManagement(false);
+ builder.setCrashSafeMode(false);
+ final IFilePersistence filePersistence = builder.build();
+ filePersistence.setExportListener(this);
+ final int numberOfDataRecord = filePersistence.getNumberOfDataRecord();
+ System.out.println("numberOfDataRecord=" + numberOfDataRecord); // NOPMD
+ startTime = System.currentTimeMillis();
+ filePersistence.xmlExport("runtime_perf/export", "runtime_perf/tmp",
+ false/* exportPersistedClassByteCode */);
+ System.out.println("duration " // NOPMD
+ + (System.currentTimeMillis() - startTime) + " mS");
+ filePersistence.close();
+ }
+
+ @Override
+ public int getBatchSize() {
+ return 100;
+ }
+
+ @Override
+ public void numberOfExported(final int number) {
+ final long totalDuration = System.currentTimeMillis() - startTime;
+ final float durationPerRecord = (float) totalDuration / (float) number;
+ System.out.println("exported=" + number + ", per record "// NOPMD
+ + durationPerRecord + " mS, total " + totalDuration + " mS");
+ }
+}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBKM.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBKM.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBKM.java 2011-11-12 16:55:23 UTC (rev 2966)
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (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.gnu.org/licenses/lgpl.html
+ *
+ * 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 net.sf.joafip.performance.items.service;//NOPMD
+
+import java.io.File;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.StorableAccess;
+import net.sf.joafip.heapfile.service.BlockDataManager;
+import net.sf.joafip.heapfile.service.IHeapDataManager;
+import net.sf.joafip.logger.JoafipLogger;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.store.service.StoreClassNotFoundException;
+
+@SuppressWarnings("PMD")
+@NotStorableClass
+@StorableAccess
+public final class InserterBKM extends AbstractInserter {
+
+ private static final JoafipLogger LOGGER = JoafipLogger
+ .getLogger(InserterBKM.class);
+
+ private InserterBKM(final String pathName) throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException, StoreClassNotFoundException,
+ FilePersistenceTooBigForSerializationException {
+ super(pathName);
+ }
+
+ private InserterBKM(final IHeapDataManager dataManager)
+ throws FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException, FilePersistenceException,
+ FilePersistenceTooBigForSerializationException {
+ super(dataManager);
+ }
+
+ public static void main(final String[] args) {
+ final String dataFile = RUNTIME_DIR + "/block.data";
+ /* remove existing data */
+ new File(dataFile).delete();
+ new File(RUNTIME_DIR).mkdirs();
+ InserterBKM inserter;
+ try {
+ final IHeapDataManager dataManager =
+ /**/new BlockDataManager(dataFile, 1024);
+ inserter = new InserterBKM(dataManager);
+ inserter.run(NUMBER_OF_ITEM);
+ inserter.close();
+ } catch (final Throwable throwable) {// NOPMD catch all
+ LOGGER.fatal("error", throwable);
+ }
+ }
+}
Added: trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/SearcherBKM.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/SearcherBKM.java (rev 0)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/SearcherBKM.java 2011-11-12 16:55:23 UTC (rev 2966)
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2007 Luc Peuvrier
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (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.gnu.org/licenses/lgpl.html
+ *
+ * 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 net.sf.joafip.performance.items.service;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.StorableAccess;
+import net.sf.joafip.heapfile.service.BlockDataManager;
+import net.sf.joafip.heapfile.service.IHeapDataManager;
+import net.sf.joafip.logger.JoafipLogger;
+import net.sf.joafip.service.FilePersistenceClassNotFoundException;
+import net.sf.joafip.service.FilePersistenceDataCorruptedException;
+import net.sf.joafip.service.FilePersistenceException;
+import net.sf.joafip.service.FilePersistenceInvalidClassException;
+import net.sf.joafip.service.FilePersistenceNotSerializableException;
+import net.sf.joafip.service.FilePersistenceTooBigForSerializationException;
+import net.sf.joafip.store.service.StoreClassNotFoundException;
+
+@NotStorableClass
+@StorableAccess
+public class SearcherBKM extends AbstractSearcher {
+
+ private static final JoafipLogger LOGGER = JoafipLogger
+ .getLogger(SearcherBKM.class);
+
+ public SearcherBKM(final String pathName) throws FilePersistenceException,
+ FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException, StoreClassNotFoundException,
+ FilePersistenceTooBigForSerializationException {
+ super(pathName);
+ }
+
+ public SearcherBKM(final IHeapDataManager dataManager)
+ throws FilePersistenceInvalidClassException,
+ FilePersistenceNotSerializableException,
+ FilePersistenceClassNotFoundException,
+ FilePersistenceDataCorruptedException, FilePersistenceException,
+ FilePersistenceTooBigForSerializationException {
+ super(dataManager);
+ }
+
+ public static void main(final String[] args) {
+ final String dataFile = RUNTIME_DIR + "/block.data";
+ SearcherBKM searcher;
+ try {
+ final IHeapDataManager dataManager =
+ /**/new BlockDataManager(dataFile, 1024);
+ searcher = new SearcherBKM(dataManager);
+ searcher.run();
+ } catch (final Throwable throwable) {// NOPMD catch all
+ LOGGER.fatal("error", throwable);
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-12 16:55:29
|
Revision: 2966
http://joafip.svn.sourceforge.net/joafip/?rev=2966&view=rev
Author: luc_peuvrier
Date: 2011-11-12 16:55:23 +0000 (Sat, 12 Nov 2011)
Log Message:
-----------
added tests for export/import
Modified Paths:
--------------
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/entity/Item.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractInserter.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractPerfService.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/AbstractSearcher.java
Added Paths:
-----------
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/AbstractBugTree.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainCountMmf.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeBlockFile.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeDual.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeHeapFile.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeHeapFileNoAutoSave.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeHeapFileNoCache.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeMem.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/MainTreeMultiFile.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/Tree.java
trunk/joafip-4test/src/main/java/net/sf/joafip/bugtree/TreeMem.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/ExporterBKM.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/InserterBKM.java
trunk/joafip-4test/src/main/java/net/sf/joafip/performance/items/service/SearcherBKM.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-12 16:54:12
|
Revision: 2965
http://joafip.svn.sourceforge.net/joafip/?rev=2965&view=rev
Author: luc_peuvrier
Date: 2011-11-12 16:54:06 +0000 (Sat, 12 Nov 2011)
Log Message:
-----------
added comments
Modified Paths:
--------------
trunk/joafip-parent/pom.xml
Modified: trunk/joafip-parent/pom.xml
===================================================================
--- trunk/joafip-parent/pom.xml 2011-11-12 16:53:35 UTC (rev 2964)
+++ trunk/joafip-parent/pom.xml 2011-11-12 16:54:06 UTC (rev 2965)
@@ -105,8 +105,11 @@
</distributionManagement>
<build>
+ <!-- target directory -->
<directory>${basedir}/target</directory>
+ <!-- sources directory -->
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
+ <!-- test sources directory -->
<testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
<outputDirectory>${basedir}/target/classes</outputDirectory>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-12 16:54:12
|
Revision: 2965
http://joafip.svn.sourceforge.net/joafip/?rev=2965&view=rev
Author: luc_peuvrier
Date: 2011-11-12 16:54:06 +0000 (Sat, 12 Nov 2011)
Log Message:
-----------
added comments
Modified Paths:
--------------
trunk/joafip-parent/pom.xml
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-12 16:53:44
|
Revision: 2964
http://joafip.svn.sourceforge.net/joafip/?rev=2964&view=rev
Author: luc_peuvrier
Date: 2011-11-12 16:53:35 +0000 (Sat, 12 Nov 2011)
Log Message:
-----------
refactoring. Added block data manager for tests
Modified Paths:
--------------
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/DataRecordIdentifier.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/IHeapDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileCheckerDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapMemoryDataManagerMock.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapMultiFileDataManager.java
Added Paths:
-----------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/BlockDataManagerHeader.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/DataBlock.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerImpl.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/BlockDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/DualWrapDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestBlockDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerBackup.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerFreeing.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrMemoryLeak.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithScenario.java
Removed Paths:
-------------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapDataManagerBackup.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapDataManagerFreeing.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapDataMgrMemoryLeak.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapDataMgrWithScenario.java
Property Changed:
----------------
trunk/joafip-heapfile/
Property changes on: trunk/joafip-heapfile
___________________________________________________________________
Modified: svn:ignore
- target
.settings
.classpath
.project
.pmd
logs
+ target
.settings
.classpath
.project
.pmd
logs
runtime
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/DataRecordIdentifier.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/DataRecordIdentifier.java 2011-11-12 16:49:48 UTC (rev 2963)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/DataRecordIdentifier.java 2011-11-12 16:53:35 UTC (rev 2964)
@@ -45,7 +45,7 @@
* create the first data record identifier: #0
*
*/
- private DataRecordIdentifier() {
+ public DataRecordIdentifier() {
super();
this.value = 0;
}
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java 2011-11-12 16:49:48 UTC (rev 2963)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java 2011-11-12 16:53:35 UTC (rev 2964)
@@ -1113,6 +1113,7 @@
* @throws HeapException
*/
@Fortest
+ @Override
public long getLastRecordPositionInFile() throws HeapException {
final long lastRecordPositionInFile = heapElementManager
.getLastRecordPositionInFile();
@@ -1120,6 +1121,7 @@
}
@Fortest
+ @Override
public long getRecordPositionInfile(final DataRecordIdentifier identifier)
throws HeapException {
final HeapIdNode heapIdNode = idNodeSearchMayBeNotExist(identifier);
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/IHeapDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/IHeapDataManager.java 2011-11-12 16:49:48 UTC (rev 2963)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/IHeapDataManager.java 2011-11-12 16:53:35 UTC (rev 2964)
@@ -162,6 +162,7 @@
*
* @param dataRecordIdentifier
* data record to delete identifier
+ * @return true if record existed and then deleted
* @throws HeapException
*/
boolean deleteDataRecord(DataRecordIdentifier dataRecordIdentifier)
@@ -175,6 +176,7 @@
* @return data record identifier of first data record removed
* @throws HeapException
*/
+ //FIXMELUC _____________________to test or remove or add more
DataRecordIdentifier removeFirstDataRecord() throws HeapException;
/**
@@ -283,4 +285,11 @@
*/
@Fortest
Iterator<DataRecordIdentifier> dataRecordIterator() throws HeapException;
+
+ @Fortest
+ long getRecordPositionInfile(DataRecordIdentifier identifier)
+ throws HeapException;
+
+ @Fortest
+ long getLastRecordPositionInFile() throws HeapException;
}
Added: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/BlockDataManagerHeader.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/BlockDataManagerHeader.java (rev 0)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/BlockDataManagerHeader.java 2011-11-12 16:53:35 UTC (rev 2964)
@@ -0,0 +1,151 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (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.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * 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 net.sf.joafip.heapfile.entity;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+import net.sf.joafip.DoNotTransform;
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.heapfile.record.entity.DataRecordIdentifier;
+import net.sf.joafip.heapfile.service.HeapException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+@DoNotTransform
+public class BlockDataManagerHeader implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8579792598621073099L;
+
+ private int blockLength;
+
+ private DataRecordIdentifier nextIdentifier;
+
+ private long dataLength;
+
+ private int numberOfDataRecord;
+
+ public int getBlockLength() {
+ return blockLength;
+ }
+
+ public void setBlockLength(final int blockLength) {
+ this.blockLength = blockLength;
+ }
+
+ public DataRecordIdentifier getNextIdentifier() {
+ return nextIdentifier;
+ }
+
+ public void setNextIdentifier(final DataRecordIdentifier nextIdentifier) {
+ this.nextIdentifier = nextIdentifier;
+ }
+
+ public long getDataLength() {
+ return dataLength;
+ }
+
+ public void setDataLength(final long dataLength) {
+ this.dataLength = dataLength;
+ }
+
+ public int getNumberOfDataRecord() {
+ return numberOfDataRecord;
+ }
+
+ public void setNumberOfDataRecord(final int numberOfDataRecord) {
+ this.numberOfDataRecord = numberOfDataRecord;
+ }
+
+ public void decrementNumberOfDataRecord() {
+ numberOfDataRecord--;
+ }
+
+ public void incrementNumberOfDataRecord() {
+ numberOfDataRecord++;
+ }
+
+ public void set(final byte[] data) throws HeapException {
+ try {
+ final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
+ data);
+ final ObjectInputStream objectInputStream = new ObjectInputStream(
+ byteArrayInputStream);
+ final BlockDataManagerHeader header = (BlockDataManagerHeader) objectInputStream
+ .readObject();
+ objectInputStream.close();
+ set(header);
+ } catch (IOException exception) {
+ throw new HeapException(exception);
+ } catch (ClassNotFoundException exception) {
+ throw new HeapException(exception);
+ }
+ }
+
+ private void set(final BlockDataManagerHeader header) {
+ this.dataLength = header.dataLength;
+ this.nextIdentifier = header.nextIdentifier;
+ this.blockLength=header.blockLength;
+ this.numberOfDataRecord=header.numberOfDataRecord;
+ }
+
+ public byte[] get() throws HeapException {
+ try {
+ final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ final ObjectOutputStream objectOutputStream = new ObjectOutputStream(
+ byteArrayOutputStream);
+ objectOutputStream.writeObject(this);
+ objectOutputStream.close();
+ return byteArrayOutputStream.toByteArray();
+ } catch (IOException exception) {
+ throw new HeapException(exception);
+ }
+ }
+
+ private void writeObject(final ObjectOutputStream out) throws IOException {
+ out.writeInt(blockLength);
+ out.writeLong(dataLength);
+ out.writeLong(nextIdentifier.value);
+ out.writeInt(numberOfDataRecord);
+ }
+
+ private void readObject(final ObjectInputStream input) throws IOException,
+ ClassNotFoundException {
+ blockLength=input.readInt();
+ dataLength = input.readLong();
+ final long value = input.readLong();
+ nextIdentifier = new DataRecordIdentifier(value);
+ numberOfDataRecord=input.readInt();
+ }
+}
Added: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/DataBlock.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/DataBlock.java (rev 0)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/DataBlock.java 2011-11-12 16:53:35 UTC (rev 2964)
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (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.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * 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 net.sf.joafip.heapfile.entity;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class DataBlock {
+
+ private final long positionInFile;
+
+ private boolean toWrite;
+
+ private final byte[] data;
+
+ public DataBlock(final long positionInFile,final boolean toWrite,final byte[] data) { //NOPMD
+ super();
+ this.positionInFile = positionInFile;
+ this.toWrite = toWrite;
+ this.data = data;
+ }
+
+ public boolean isToWrite() {
+ return toWrite;
+ }
+
+ public void setToWrite(final boolean toWrite) {
+ this.toWrite = toWrite;
+ }
+
+ public long getPositionInFile() {
+ return positionInFile;
+ }
+
+ public byte[] getData() {
+ return data; //NOPMD
+ }
+}
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManager.java 2011-11-12 16:49:48 UTC (rev 2963)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManager.java 2011-11-12 16:53:35 UTC (rev 2964)
@@ -46,7 +46,7 @@
protected String tempFilePath;
- protected HeapFileDataManager heapDataManager; // NOPMD
+ protected IHeapDataManager heapDataManager; // NOPMD
protected File dataFile; // NOPMD
@@ -116,7 +116,7 @@
* @throws HeapException
*
*/
- protected void createHeap(final boolean removeFile) throws HeapException {
+ protected void createHeapFileDataManager(final boolean removeFile) throws HeapException {
final HeapFileSetup setup = new HeapFileSetup(dataFile,
true/* crashSafeMode */, false/* useCacheMode */,
false/* deleteRenaming */, false/* clearResizeFile */, 1, 0,
@@ -127,6 +127,15 @@
heapDataManager.startService(removeFile);
}
+ protected void createBlockDataManager(final boolean removeFile) throws HeapException {
+ heapDataManager = new BlockDataManager(dataFilePath,20000);
+ heapDataManager.startService(removeFile);
+ }
+
+ protected abstract void createHeap(final boolean removeFile) throws HeapException;
+
+ protected abstract boolean manageFreeRecord();
+
/**
* @throws HeapException
*
Added: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerImpl.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerImpl.java (rev 0)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerImpl.java 2011-11-12 16:53:35 UTC (rev 2964)
@@ -0,0 +1,624 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (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.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * 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 net.sf.joafip.heapfile.service;
+
+import net.sf.joafip.DoNotTransform;
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.TestException;
+import net.sf.joafip.heapfile.record.entity.DataRecordIdentifier;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+@DoNotTransform
+public abstract class AbstractTestHeapDataManagerImpl extends
+ AbstractTestHeapDataManagerRecord {
+
+ private static final String MUST_DELETE_1 = "must delete #1";
+
+ private static final String MUST_NOT_HAVE_DATA_RECORD = "must not have data record";
+
+ private static final String MUST_DELETE_0 = "must delete #0";
+
+ private static final String _0_FREE_RECORD_EXPECTED = "0 free record expected";
+
+ private static final String LAST_RECORD_MISMATCH = "last record mismatch";
+
+ private static final String MUST_HAVE_1_FREE_RECORD = "must have 1 free record";
+
+ private static final String MUST_NOT_HAVE_FREE_RECORD = "must not have free record";
+
+ private static final String MUST_HAVE_1_DATA_RECORD = "must have 1 data record";
+
+ private static final String MUST_HAVE_3_DATA_RECORD = "must have 3 data record";
+
+ public AbstractTestHeapDataManagerImpl() throws TestException {
+ super();
+ }
+
+ public AbstractTestHeapDataManagerImpl(final String name)
+ throws TestException {
+ super(name);
+ }
+
+ public void testEmpty() throws HeapException {
+ createHeap(true);
+ assertNull("reading must failed",
+ heapDataManager.readDataRecord(DataRecordIdentifier.ZERO));
+ checkIntegrity();
+ }
+
+ public void testFirstCreateClose() throws HeapException {// NOPMD
+ createHeap(true);
+ final int dataSize = 100;
+ createRecord(dataSize, 0);
+ closeHeap();
+ createHeap(false/* remove file */);
+ checkIntegrity();
+ firstCreatedReadAndCheck(dataSize);
+ }
+
+ public void testFirstCreateNoClose() throws HeapException {// NOPMD
+ createHeap(true);
+ final int dataSize = 100;
+ createRecord(dataSize, 0);
+ firstCreatedReadAndCheck(dataSize);
+ }
+
+ public void testDeleteClose() throws HeapException {// NOPMD
+ createHeap(true);
+ final int dataSize = 100;
+ createRecord(dataSize, 0);
+ checkIntegrity();
+ closeHeap();
+ createHeap(false/* remove file */);
+ final DataRecordIdentifier identifier = new DataRecordIdentifier(0);
+ assertTrue(MUST_DELETE_0, heapDataManager.deleteDataRecord(identifier));
+ closeHeap();
+ createHeap(false/* remove file */);
+ checkIntegrity();
+ }
+
+ public void testDeleteNoClose() throws HeapException {// NOPMD
+ createHeap(true);
+ final int dataSize = 100;
+ createRecord(dataSize, 0);
+ final DataRecordIdentifier identifier = new DataRecordIdentifier(0);
+ assertTrue(MUST_DELETE_0, heapDataManager.deleteDataRecord(identifier));
+ checkIntegrity();
+ }
+
+ /**
+ * @param dataSize
+ * @throws HeapException
+ *
+ */
+ private void firstCreatedReadAndCheck(final int dataSize)
+ throws HeapException {
+ final DataRecordIdentifier identifier = new DataRecordIdentifier(0);
+ checkDataRecord(dataSize, identifier);
+ checkIntegrity();
+ }
+
+ public void testAlloc() throws HeapException {
+ createHeap(true);
+ for (int index = 0; index < 10; index++) {
+ final DataRecordIdentifier identifier = heapDataManager
+ .getNewDataRecordIdentifier();
+ final byte[] data = new byte[1000]; // NOPMD
+ for (int dataIndex = 0; dataIndex < 1000; dataIndex++) {
+ data[dataIndex] = (byte) index;
+ }
+ heapDataManager.writeDataRecord(identifier, data);
+ logger.info("add #id=" + identifier);
+ logger.info("--------");
+ }
+ checkIntegrity();
+ closeHeap();
+ createHeap(false/* remove file */);
+ for (int identifier = 0; identifier < 10; identifier++) {
+ final DataRecordIdentifier dataRecordIdentifier = newDataRecordIdentifier(identifier);
+ final byte[] data = heapDataManager
+ .readDataRecord(dataRecordIdentifier);
+ assertNotNull("must exist data for identifier " + identifier, data);
+ for (int dataIndex = 0; dataIndex < 1000; dataIndex++) {
+ assertEquals("bad data value at " + dataIndex, data[dataIndex],
+ (byte) identifier);
+ }
+ }
+ }
+
+ /**
+ * realloc from only one free record keeping one free record
+ *
+ * @throws HeapException
+ */
+ public void testFreeReAlloc1() throws HeapException {
+ /*
+ * create record #0 of 10000 bytes, check data record and free record
+ */
+ createHeap(true);
+ int dataSize = 10000;
+ createRecord(dataSize, 0);
+ closeHeap();
+
+ createHeap(false/* remove file */);
+ assertEquals(MUST_HAVE_1_DATA_RECORD, 1,
+ heapDataManager.getNumberOfDataRecord());
+ if (manageFreeRecord()) {
+ assertEquals(MUST_NOT_HAVE_FREE_RECORD, 0,
+ heapDataManager.getNumberOfFreeRecord());
+ }
+ checkIntegrity();
+
+ /*
+ * delete record #0, check data record and free record
+ */
+ final DataRecordIdentifier identifier = new DataRecordIdentifier(0);
+ assertTrue(MUST_DELETE_0, heapDataManager.deleteDataRecord(identifier));
+ closeHeap();
+
+ createHeap(false/* remove file */);
+ assertEquals(MUST_NOT_HAVE_DATA_RECORD, 0,
+ heapDataManager.getNumberOfDataRecord());
+ if (manageFreeRecord()) {
+ assertEquals(MUST_HAVE_1_FREE_RECORD, 1,
+ heapDataManager.getNumberOfFreeRecord());
+ }
+ checkIntegrity();
+
+ /*
+ * create record #1 of 5000 byte, check 1 data record and 1 free record
+ */
+ dataSize = 5000;
+ createRecord(dataSize, 1);
+ closeHeap();
+
+ createHeap(false/* remove file */);
+ checkIntegrity();
+ assertEquals(MUST_HAVE_1_DATA_RECORD, 1,
+ heapDataManager.getNumberOfDataRecord());
+ if (manageFreeRecord()) {
+ assertEquals(MUST_HAVE_1_FREE_RECORD, 1,
+ heapDataManager.getNumberOfFreeRecord());
+ }
+ closeHeap();
+ }
+
+ /**
+ * realloc from only one free record keeping no more free record
+ *
+ * @throws HeapException
+ */
+ public void testFreeReAlloc2() throws HeapException {
+ createHeap(true);
+ int dataSize = 10000;
+ createRecord(dataSize, 0);
+ closeHeap();
+ createHeap(false/* remove file */);
+ assertEquals(MUST_HAVE_1_DATA_RECORD, 1,
+ heapDataManager.getNumberOfDataRecord());
+ if (manageFreeRecord()) {
+ assertEquals(MUST_NOT_HAVE_FREE_RECORD, 0,
+ heapDataManager.getNumberOfFreeRecord());
+ }
+ checkIntegrity();
+ final DataRecordIdentifier identifier = new DataRecordIdentifier(0);
+ assertTrue(MUST_DELETE_0, heapDataManager.deleteDataRecord(identifier));
+ closeHeap();
+ createHeap(false/* remove file */);
+ assertEquals(MUST_NOT_HAVE_DATA_RECORD, 0,
+ heapDataManager.getNumberOfDataRecord());
+ if (manageFreeRecord()) {
+ assertEquals(MUST_HAVE_1_FREE_RECORD, 1,
+ heapDataManager.getNumberOfFreeRecord());
+ }
+ checkIntegrity();
+
+ dataSize = 9999;
+ createRecord(dataSize, 1);
+ closeHeap();
+ createHeap(false/* remove file */);
+ checkIntegrity();
+ assertEquals(MUST_HAVE_1_DATA_RECORD, 1,
+ heapDataManager.getNumberOfDataRecord());
+ if (manageFreeRecord()) {
+ assertEquals(MUST_NOT_HAVE_FREE_RECORD, 0,
+ heapDataManager.getNumberOfFreeRecord());
+ }
+ closeHeap();
+ }
+
+ /**
+ * realloc from only one free record keeping one free record
+ *
+ * @throws HeapException
+ */
+ public void testFreeReAlloc3() throws HeapException {
+ createHeap(true);
+ int dataSize = 10000;
+ createRecord(dataSize, 0);
+ createRecord(dataSize, 1);
+ createRecord(dataSize, 2);
+ closeHeap();
+ createHeap(false/* remove file */);
+ assertEquals(MUST_HAVE_3_DATA_RECORD, 3,
+ heapDataManager.getNumberOfDataRecord());
+ if (manageFreeRecord()) {
+ assertEquals(MUST_NOT_HAVE_FREE_RECORD, 0,
+ heapDataManager.getNumberOfFreeRecord());
+ }
+ checkIntegrity();
+ final DataRecordIdentifier identifier = new DataRecordIdentifier(1);
+ assertTrue(MUST_DELETE_1, heapDataManager.deleteDataRecord(identifier));
+ closeHeap();
+ createHeap(false/* remove file */);
+ assertEquals("must have 2 data record", 2,
+ heapDataManager.getNumberOfDataRecord());
+ if (manageFreeRecord()) {
+ assertEquals(MUST_HAVE_1_FREE_RECORD, 1,
+ heapDataManager.getNumberOfFreeRecord());
+ }
+ checkIntegrity();
+
+ dataSize = 5000;
+ createRecord(dataSize, 3);
+ closeHeap();
+ createHeap(false/* remove file */);
+ checkIntegrity();
+ assertEquals(MUST_HAVE_3_DATA_RECORD, 3,
+ heapDataManager.getNumberOfDataRecord());
+ if (manageFreeRecord()) {
+ assertEquals(MUST_HAVE_1_FREE_RECORD, 1,
+ heapDataManager.getNumberOfFreeRecord());
+ }
+ closeHeap();
+ }
+
+ /**
+ * realloc from only one free record keeping no more free record
+ *
+ * @throws HeapException
+ */
+ public void testFreeReAlloc4() throws HeapException {
+ createHeap(true);
+ int dataSize = 10000;
+ createRecord(dataSize, 0);
+ assertEquals("1 data record expected", 1,
+ heapDataManager.getNumberOfDataRecord());
+ if (manageFreeRecord()) {
+ assertEquals(_0_FREE_RECORD_EXPECTED, 0,
+ heapDataManager.getNumberOfFreeRecord());
+ }
+ createRecord(dataSize, 1);
+ assertEquals("2 data record expected", 2,
+ heapDataManager.getNumberOfDataRecord());
+ if (manageFreeRecord()) {
+ assertEquals(_0_FREE_RECORD_EXPECTED, 0,
+ heapDataManager.getNumberOfFreeRecord());
+ }
+ createRecord(dataSize, 2);
+ assertEquals("3 data record expected", 3,
+ heapDataManager.getNumberOfDataRecord());
+ if (manageFreeRecord()) {
+ assertEquals(_0_FREE_RECORD_EXPECTED, 0,
+ heapDataManager.getNumberOfFreeRecord());
+ }
+ closeHeap();
+ createHeap(false/* remove file */);
+ assertEquals(MUST_HAVE_3_DATA_RECORD, 3,
+ heapDataManager.getNumberOfDataRecord());
+ if (manageFreeRecord()) {
+ assertEquals(MUST_NOT_HAVE_FREE_RECORD, 0,
+ heapDataManager.getNumberOfFreeRecord());
+ }
+ checkIntegrity();
+ final DataRecordIdentifier identifier = new DataRecordIdentifier(1);
+ assertTrue(MUST_DELETE_1, heapDataManager.deleteDataRecord(identifier));
+ closeHeap();
+ createHeap(false/* remove file */);
+ assertEquals("must have 2 data record", 2,
+ heapDataManager.getNumberOfDataRecord());
+ if (manageFreeRecord()) {
+ assertEquals(MUST_HAVE_1_FREE_RECORD, 1,
+ heapDataManager.getNumberOfFreeRecord());
+ }
+ checkIntegrity();
+
+ dataSize = 9999;
+ createRecord(dataSize, 3);
+ assertEquals("3 data record expected", 3,
+ heapDataManager.getNumberOfDataRecord());
+ if (manageFreeRecord()) {
+ assertEquals(_0_FREE_RECORD_EXPECTED, 0,
+ heapDataManager.getNumberOfFreeRecord());
+ }
+
+ closeHeap();
+ createHeap(false/* remove file */);
+ checkIntegrity();
+ assertEquals(MUST_HAVE_3_DATA_RECORD, 3,
+ heapDataManager.getNumberOfDataRecord());
+ if (manageFreeRecord()) {
+ assertEquals(MUST_NOT_HAVE_FREE_RECORD, 0,
+ heapDataManager.getNumberOfFreeRecord());
+ }
+ closeHeap();
+ }
+
+ public void testModification() throws HeapException {
+ createHeap(true);
+ byte[] data = createRecord(20, 0);
+ assertNotNull(DATA_MUST_BE_DEFINED, data);
+ for (int index = 0; index < 20; index++) {
+ data[index] = (byte) index;
+ }
+ checkIntegrity();
+ closeHeap();
+ createHeap(false/* remove file */);
+ final DataRecordIdentifier identifier = new DataRecordIdentifier(0);
+ data = heapDataManager.readDataRecord(identifier);
+ for (int index = 0; index < 20; index++) {
+ assertEquals("bad value", data[index], index);
+ }
+ for (int index = 0; index < 20; index++) {
+ data[index] = (byte) (10 + index);
+ }
+ heapDataManager.writeDataRecord(identifier, data);
+ closeHeap();
+ createHeap(false/* remove file */);
+ data = heapDataManager.readDataRecord(identifier);
+ for (int index = 0; index < 20; index++) {
+ assertEquals("bad value", data[index], 10 + index);
+ }
+ }
+
+ public void testNoDataWrite() throws HeapException {
+ createHeap(true);
+ final DataRecordIdentifier identifier = heapDataManager
+ .getNewDataRecordIdentifier();
+ byte[] data = new byte[100];
+ heapDataManager.writeDataRecord(identifier, data);
+ final DataRecordIdentifier identifier0 = new DataRecordIdentifier(0);
+ assertEquals("not expected identifier", identifier0, identifier);
+ closeHeap();
+ createHeap(true/* remove file */);
+ data = heapDataManager.readDataRecord(identifier0);
+ assertNull("must failed since no data wrote", data);
+ }
+
+ public void testCreateDeleteReCreate() throws HeapException {
+ createHeap(true);
+ DataRecordIdentifier identifier = heapDataManager
+ .getNewDataRecordIdentifier();
+ byte[] data = new byte[10];
+ heapDataManager.writeDataRecord(identifier, data);
+
+ DataRecordIdentifier expectedIdentifier = new DataRecordIdentifier(0);
+ assertEquals("identifier must be 0", expectedIdentifier, identifier);
+ assertTrue("must have data record #0",
+ heapDataManager.hasDataRecord(identifier));
+
+ assertTrue(MUST_DELETE_0, heapDataManager.deleteDataRecord(identifier));
+ assertFalse("must not have data record #0",
+ heapDataManager.hasDataRecord(identifier));
+
+ identifier = heapDataManager.getNewDataRecordIdentifier();
+ data = new byte[10];
+ heapDataManager.writeDataRecord(identifier, data);
+
+ expectedIdentifier = new DataRecordIdentifier(1);
+ assertEquals("identifier must be 1", expectedIdentifier, identifier);
+ assertTrue("must have data record #0",
+ heapDataManager.hasDataRecord(identifier));
+ heapDataManager.flush();
+ }
+
+ public void testRecordFreeing1() throws HeapException {
+ createHeap(true);
+ /*
+ * create record #0
+ */
+ DataRecordIdentifier identifier = heapDataManager
+ .getNewDataRecordIdentifier();
+ byte[] data = new byte[100];
+ heapDataManager.writeDataRecord(identifier, data);
+
+ final DataRecordIdentifier expectedIdentifier0 = new DataRecordIdentifier(
+ 0);
+ assertEquals("must create record #0", expectedIdentifier0, identifier);
+
+ /*
+ * create record #1
+ */
+ identifier = heapDataManager.getNewDataRecordIdentifier();
+ data = new byte[100];
+ heapDataManager.writeDataRecord(identifier, data);
+
+ final DataRecordIdentifier expectedIdentifier1 = new DataRecordIdentifier(
+ 1);
+ assertEquals("must create record #1", expectedIdentifier1, identifier);
+
+ /*
+ * create record #2
+ */
+ identifier = heapDataManager.getNewDataRecordIdentifier();
+ data = new byte[100];
+ heapDataManager.writeDataRecord(identifier, data);
+
+ final DataRecordIdentifier expectedIdentifier2 = new DataRecordIdentifier(
+ 2);
+ assertEquals("must create record #2", expectedIdentifier2, identifier);
+
+ /*
+ * delete #0
+ */
+ identifier = new DataRecordIdentifier(0);
+ assertTrue(MUST_DELETE_0, heapDataManager.deleteDataRecord(identifier));
+ heapDataManager.flush();
+ final long record2PositionInFile = heapDataManager
+ .getRecordPositionInfile(expectedIdentifier2);
+
+ long lastRecordPositionInFile = heapDataManager
+ .getLastRecordPositionInFile();
+ assertEquals(LAST_RECORD_MISMATCH, record2PositionInFile,
+ lastRecordPositionInFile);
+
+ /*
+ * delete #1
+ */
+ identifier = new DataRecordIdentifier(1);
+ assertTrue(MUST_DELETE_1, heapDataManager.deleteDataRecord(identifier));
+ heapDataManager.flush();
+ lastRecordPositionInFile = heapDataManager
+ .getLastRecordPositionInFile();
+ assertEquals(LAST_RECORD_MISMATCH, lastRecordPositionInFile,
+ record2PositionInFile);
+ }
+
+ public void testRecordFreeing2() throws HeapException {
+ createHeap(true);
+ /*
+ * create record #0
+ */
+ DataRecordIdentifier identifier = heapDataManager
+ .getNewDataRecordIdentifier();
+ byte[] data = new byte[100];
+ heapDataManager.writeDataRecord(identifier, data);
+
+ final DataRecordIdentifier expectedIdentifier = new DataRecordIdentifier(
+ 0);
+ assertEquals("must create record #0", expectedIdentifier, identifier);
+
+ /*
+ * create record #1
+ */
+ identifier = heapDataManager.getNewDataRecordIdentifier();
+ data = new byte[100];
+ heapDataManager.writeDataRecord(identifier, data);
+
+ final DataRecordIdentifier expectedIdentifier1 = new DataRecordIdentifier(
+ 1);
+ assertEquals("must create record #1", expectedIdentifier1, identifier);
+ heapDataManager.flush();
+ final long record1PositionInFile = heapDataManager
+ .getRecordPositionInfile(expectedIdentifier1);
+
+ /*
+ * create record #2
+ */
+ identifier = heapDataManager.getNewDataRecordIdentifier();
+ data = new byte[100];
+ heapDataManager.writeDataRecord(identifier, data);
+
+ final DataRecordIdentifier expectedIdentifier2 = new DataRecordIdentifier(
+ 2);
+ assertEquals("must create record #2", expectedIdentifier2, identifier);
+ heapDataManager.flush();
+ final long record2PositionInFile = heapDataManager
+ .getRecordPositionInfile(expectedIdentifier2);
+
+ /*
+ * delete #2
+ */
+ identifier = new DataRecordIdentifier(2);
+ assertTrue("must delete #2",
+ heapDataManager.deleteDataRecord(identifier));
+ heapDataManager.flush();
+ long lastRecordPositionInFile = heapDataManager
+ .getLastRecordPositionInFile();
+ assertEquals(LAST_RECORD_MISMATCH, record2PositionInFile,
+ lastRecordPositionInFile);
+
+ /*
+ * delete #1
+ */
+ identifier = new DataRecordIdentifier(1);
+ assertTrue(MUST_DELETE_1, heapDataManager.deleteDataRecord(identifier));
+ heapDataManager.flush();
+ lastRecordPositionInFile = heapDataManager
+ .getLastRecordPositionInFile();
+ if (manageFreeRecord()) {
+ assertEquals(LAST_RECORD_MISMATCH, record1PositionInFile,
+ lastRecordPositionInFile);
+ }
+ }
+
+ public void testRecordFreeing3() throws HeapException {
+ createHeap(true);
+ DataRecordIdentifier identifier = heapDataManager
+ .getNewDataRecordIdentifier();
+ byte[] data = new byte[100];
+ heapDataManager.writeDataRecord(identifier, data);
+
+ DataRecordIdentifier expectedIdentifier = new DataRecordIdentifier(0);
+ assertEquals("must create record #0", expectedIdentifier, identifier);
+
+ identifier = heapDataManager.getNewDataRecordIdentifier();
+ data = new byte[100];
+ heapDataManager.writeDataRecord(identifier, data);
+
+ expectedIdentifier = new DataRecordIdentifier(1);
+ assertEquals("must create record #1", expectedIdentifier, identifier);
+
+ identifier = heapDataManager.getNewDataRecordIdentifier();
+ data = new byte[100];
+ heapDataManager.writeDataRecord(identifier, data);
+
+ expectedIdentifier = new DataRecordIdentifier(2);
+ assertEquals("must create record #2", expectedIdentifier, identifier);
+
+ identifier = new DataRecordIdentifier(0);
+ assertTrue(MUST_DELETE_0, heapDataManager.deleteDataRecord(identifier));
+ identifier = new DataRecordIdentifier(2);
+ assertTrue("must delete #2",
+ heapDataManager.deleteDataRecord(identifier));
+ heapDataManager.flush();
+ identifier = new DataRecordIdentifier(1);
+ assertTrue(MUST_DELETE_1, heapDataManager.deleteDataRecord(identifier));
+ }
+
+ public void testRemoveFirst() throws HeapException {
+ createHeap(true);
+ assertNull(MUST_NOT_HAVE_DATA_RECORD,
+ heapDataManager.removeFirstDataRecord());
+ DataRecordIdentifier identifier = heapDataManager
+ .getNewDataRecordIdentifier();
+ final byte[] data = new byte[100];
+ heapDataManager.writeDataRecord(identifier, data);
+ identifier = heapDataManager.getNewDataRecordIdentifier();
+ heapDataManager.writeDataRecord(identifier, data);
+ heapDataManager.flush();
+ identifier = heapDataManager.removeFirstDataRecord();
+ assertNotNull("must deleted first data record", identifier);
+ assertEquals(0L, identifier.value);
+ identifier = heapDataManager.removeFirstDataRecord();
+ assertNotNull("must deleted first data record", identifier);
+ assertEquals(1L, identifier.value);
+ assertNull(MUST_NOT_HAVE_DATA_RECORD,
+ heapDataManager.removeFirstDataRecord());
+ }
+}
Added: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/BlockDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/BlockDataManager.java (rev 0)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/BlockDataManager.java 2011-11-12 16:53:35 UTC (rev 2964)
@@ -0,0 +1,493 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (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.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * 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 net.sf.joafip.heapfile.service;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.file.service.FileIOException;
+import net.sf.joafip.file.service.IRandomAccessFile;
+import net.sf.joafip.file.service.RandomAccessFileDirectNio;
+import net.sf.joafip.file.service.RandomAccessFileReadWriteCache;
+import net.sf.joafip.heapfile.entity.BlockDataManagerHeader;
+import net.sf.joafip.heapfile.entity.DataBlock;
+import net.sf.joafip.heapfile.record.entity.DataRecordIdentifier;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public class BlockDataManager extends AbstractHeapDataManager {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -7880032946404411395L;
+
+ private static final int FIRST_BLOCK_LENGTH = 1024;
+
+ private final IRandomAccessFile randomAccessFile;
+
+ private final BlockDataManagerHeader header = new BlockDataManagerHeader();
+
+ private final Map<Long, DataBlock> cacheMap = new TreeMap<Long, DataBlock>();
+
+ public BlockDataManager(final String filePath, final int blockLength)
+ throws HeapException {
+ super();
+ final File file = new File(filePath);
+ randomAccessFile = new RandomAccessFileDirectNio(file, 0, 0);
+ // randomAccessFile = new RandomAccessFileDirect(file, 0, 0);
+ header.setBlockLength(blockLength);
+ }
+
+ public BlockDataManager(final int pageSize, final int maxPage,
+ final int blockLength) throws HeapException {
+ super();
+ final File file = new File("runtime/data");
+ final IRandomAccessFile drandomAccessFile = new RandomAccessFileDirectNio(
+ file, 0, 0);
+ randomAccessFile = new RandomAccessFileReadWriteCache(
+ drandomAccessFile, pageSize, maxPage, true);
+ header.setBlockLength(blockLength);
+ }
+
+ @Override
+ protected void removeFiles() throws HeapException {
+ try {
+ randomAccessFile.deleteIfExists();
+ } catch (FileIOException exception) {
+ throw new HeapException(exception);
+ }
+ }
+
+ @Override
+ protected void startServiceImpl(final boolean removeFiles)
+ throws HeapException {
+ try {
+ randomAccessFile.open();
+ randomAccessFile.seek(0);
+ final byte[] block = new byte[FIRST_BLOCK_LENGTH];
+ if (removeFiles) {
+ randomAccessFile.write(block);
+ header.setNextIdentifier(new DataRecordIdentifier());
+ header.setNumberOfDataRecord(0);
+ } else {
+ if (randomAccessFile.read(block) == FIRST_BLOCK_LENGTH) {
+ final int length = (((int) block[0]) & 0xff) << 8
+ | (((int) block[1]) & 0xff);
+ final byte[] data = new byte[length];
+ System.arraycopy(block, 2, data, 0, length);
+ header.set(data);
+ } else {
+ randomAccessFile.write(block);
+ header.setNextIdentifier(new DataRecordIdentifier());
+ header.setNumberOfDataRecord(0);
+ }
+ }
+ } catch (FileIOException exception) {
+ throw new HeapException(exception);
+ }
+ }
+
+ @Override
+ protected void stopServiceImpl() throws HeapException {
+ try {
+ writeHeader();
+ randomAccessFile.close();
+ } catch (FileIOException exception) {
+ throw new HeapException(exception);
+ }
+ }
+
+ private void writeHeader() throws HeapException, FileIOException {
+ final byte[] data = header.get();
+ final int length = data.length;
+ final byte[] block = new byte[(int) FIRST_BLOCK_LENGTH];
+ block[0] = (byte) (length >> 8);
+ block[1] = (byte) length;
+ System.arraycopy(data, 0, block, 2, length);
+ randomAccessFile.seek(0);
+ randomAccessFile.write(block);
+ }
+
+ @Override
+ protected void clearImpl() throws HeapException {
+ removeFiles();
+ }
+
+ @Override
+ protected void flushImp() throws HeapException {
+ try {
+ for (Map.Entry<Long, DataBlock> entry : cacheMap.entrySet()) {
+ final long position = entry.getKey();
+ final DataBlock dataBlock = entry.getValue();
+ if (dataBlock.isToWrite()) {
+ randomAccessFile.seek(position);
+ randomAccessFile.write(dataBlock.getData());
+ }
+ }
+ writeHeader();
+ randomAccessFile.flush();
+ cacheMap.clear();
+ } catch (FileIOException exception) {
+ throw new HeapException(exception);
+ }
+ }
+
+ @Override
+ protected void clearStandbyModificationImpl() throws HeapException {
+ cacheMap.clear();
+ }
+
+ @Override
+ protected DataRecordIdentifier getNextFreeDataRecordIdentifierImpl()
+ throws HeapException {
+ return header.getNextIdentifier();
+ }
+
+ @Override
+ protected void setNextFreeDataRecordIdentifierImpl(
+ final DataRecordIdentifier dataRecordIdentifier)
+ throws HeapException {
+ header.setNextIdentifier(dataRecordIdentifier);
+ }
+
+ @Override
+ protected DataRecordIdentifier getNewDataRecordIdentifierImpl()
+ throws HeapException {
+ final DataRecordIdentifier result = header.getNextIdentifier();
+ header.setNextIdentifier(new DataRecordIdentifier(result));
+ return result;
+ }
+
+ @Override
+ protected boolean deleteDataRecordImpl(
+ final DataRecordIdentifier dataRecordIdentifier)
+ throws HeapException {
+ try {
+ final long position = getRecordPositionInfile(dataRecordIdentifier);
+ final boolean deleted;
+ final byte[] lengthData = new byte[2];
+ final int read = read(position, 0, lengthData,true);
+ if (read == 2) {
+ final int length = (((int) lengthData[0]) & 0xff) << 8
+ | (((int) lengthData[1]) & 0xff);
+ if (length == 0) {
+ deleted = false;
+ } else {
+ header.decrementNumberOfDataRecord();
+ deleted = true;
+ lengthData[0] = (byte) 0;
+ lengthData[1] = (byte) 0;
+ write(position, 0, lengthData);
+ }
+ } else {
+ deleted = false;
+ }
+ return deleted;
+ } catch (FileIOException exception) {
+ throw new HeapException(exception);
+ }
+ }
+
+ @Override
+ protected byte[] readDataRecordImpl(
+ final DataRecordIdentifier dataRecordIdentifier)
+ throws HeapException {
+ try {
+ final long position = getRecordPositionInfile(dataRecordIdentifier);
+ byte[] data = new byte[2];
+ final int read = read(position, 0, data,true);
+ if (read == 2) {
+ final int length = (((int) data[0]) & 0xff) << 8
+ | (((int) data[1]) & 0xff);
+
+ if (length == 0) {
+ data = null;// NOPMD
+ } else {
+ data = new byte[length];
+ read(position, 2, data,true);
+ }
+ } else {
+ data = null;// NOPMD
+ }
+ return data;
+ } catch (FileIOException exception) {
+ throw new HeapException(exception);
+ }
+ }
+
+ @Override
+ protected boolean writeDataRecordImpl(
+ final DataRecordIdentifier dataRecordIdentifier, final byte[] data)
+ throws HeapException {
+ if (data.length == 0) {
+ throw new HeapException("no data");
+ }
+ if (data.length > header.getBlockLength() - 2) {
+ throw new HeapException("too big data: " + data.length
+ + " for block of " + header.getBlockLength());
+ }
+ try {
+ final long position = getRecordPositionInfile(dataRecordIdentifier);
+ final boolean created;
+ final byte[] lengthData = new byte[2];
+ int previousLength = -1;
+ final int read = read(position, 0, lengthData,true);
+ if (read == 2) {
+ previousLength = (((int) lengthData[0]) & 0xff) << 8
+ | (((int) lengthData[1]) & 0xff);
+ created = previousLength == 0;
+ } else {
+ created = true;
+ }
+ if (created) {
+ header.incrementNumberOfDataRecord();
+ }
+ final int length = data.length;
+ lengthData[0] = (byte) (length >> 8);
+ lengthData[1] = (byte) length;
+ write(position, 0, lengthData);
+ write(position, 2, data);
+ return created;
+ } catch (FileIOException exception) {
+ throw new HeapException("for data record #" + dataRecordIdentifier,
+ exception);
+ }
+ }
+
+ @Override
+ protected boolean hasDataRecordImpl(
+ final DataRecordIdentifier dataRecordIdentifier)
+ throws HeapException {
+ try {
+ final long position = getRecordPositionInfile(dataRecordIdentifier);
+ final boolean hasDatarecord;
+ final byte[] lengthData = new byte[2];
+ final int read = read(position, 0, lengthData,true);
+ if (read == 2) {
+ final int length = (((int) lengthData[0]) & 0xff) << 8
+ | (((int) lengthData[1]) & 0xff);
+ hasDatarecord = length != 0;
+ } else {
+ hasDatarecord = false;
+ }
+ return hasDatarecord;
+ } catch (FileIOException exception) {
+ throw new HeapException(exception);
+ }
+ }
+
+ @Override
+ public long getRecordPositionInfile(
+ final DataRecordIdentifier dataRecordIdentifier)
+ throws HeapException {
+ final long value = dataRecordIdentifier.value;
+ return getRecordPositionInfile(value);
+ }
+
+ private long getRecordPositionInfile(final long value) {
+ return value * header.getBlockLength() + FIRST_BLOCK_LENGTH;
+ }
+
+ @Override
+ public long getLastRecordPositionInFile() throws HeapException {
+ return getRecordPositionInfile((header.getDataLength() - 1 - FIRST_BLOCK_LENGTH)
+ / header.getBlockLength());
+ }
+
+ @Override
+ protected int getNumberOfDataRecordImpl() throws HeapException {
+ return header.getNumberOfDataRecord();
+ }
+
+ @Override
+ protected DataRecordIdentifier removeFirstDataRecordImpl()
+ throws HeapException {
+ try {
+ boolean found = false;
+ final long firstRecordPositionInfile = getRecordPositionInfile(0);
+ long position = firstRecordPositionInfile;
+ final byte[] lengthData = new byte[2];
+ do {
+ final int read = read(position, 0, lengthData,false);
+ if (read == 2) {
+ final int length = (((int) lengthData[0]) & 0xff) << 8
+ | (((int) lengthData[1]) & 0xff);
+ if (length == 0) {
+ position += header.getBlockLength();
+ } else {
+ found = true;
+ }
+ } else {
+ position = Long.MAX_VALUE;
+ }
+ } while (!found && position < header.getDataLength());
+ DataRecordIdentifier result;
+ if (found) {
+ lengthData[0] = 0;
+ lengthData[1] = 0;
+ write(position, 0, lengthData);
+ result = new DataRecordIdentifier(
+ (position - firstRecordPositionInfile)
+ / header.getBlockLength());
+ } else {
+ result = null;// NOPMD
+ }
+ return result;
+ } catch (FileIOException exception) {
+ throw new HeapException(exception);
+ }
+ }
+
+ @Override
+ protected int getNumberOfFreeRecordImpl() throws HeapException {
+ // no implementation
+ return 0;
+ }
+
+ @Override
+ protected long heapSizeImpl() throws HeapException {
+ // no implementation
+ return 0;
+ }
+
+ @Override
+ protected long freeSizeImpl() throws HeapException {
+ // no implementation
+ return 0;
+ }
+
+ @Override
+ protected long usedSizeImpl() throws HeapException {
+ // no implementation
+ return 0;
+ }
+
+ @Override
+ protected Set<DataRecordIdentifier> getDataRecordIdentifierSetImpl()
+ throws HeapException {
+ // no implementation
+ return null;
+ }
+
+ @Override
+ protected Iterator<DataRecordIdentifier> dataRecordIteratorImpl() {
+ // no implementation
+ return null;
+ }
+
+ @Override
+ protected void closeHeapManagerAfterException() {
+ // no implementation
+ }
+
+ @Override
+ public boolean isDataLost() {
+ return false;
+ }
+
+ @Override
+ public String getStorageFileName() throws HeapException {
+ return randomAccessFile.getFile().getAbsolutePath();
+ }
+
+ @Override
+ public void backup(final long identifier, final int maxBackup)
+ throws HeapException {
+ throw new HeapException("not implemented");
+ }
+
+ @Override
+ public String getBackupFileName() throws HeapException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getChangeFileName() throws HeapException {
+ return null;
+ }
+
+ private int read(final long position, final int offset, final byte[] data,
+ final boolean addToCache) throws FileIOException {
+ DataBlock dataBlock = cacheMap.get(position);
+ if (dataBlock == null) {
+ dataBlock = readInFile(position, addToCache);
+ }
+ final int result;
+ if (dataBlock == null) {
+ result = 0;
+ } else {
+ result = data.length;
+ final byte[] recordData = dataBlock.getData();
+ System.arraycopy(recordData, offset, data, 0, result);
+ }
+ return result;
+ }
+
+ private DataBlock readInFile(final long position, final boolean addToCache)
+ throws FileIOException {
+ final DataBlock dataBlock;
+ randomAccessFile.seek(position);
+ final int blockLength = header.getBlockLength();
+ final byte[] recordData = new byte[blockLength];
+ final int read = randomAccessFile.read(recordData);
+ if (read == blockLength) {
+ dataBlock = new DataBlock(position, false, recordData);
+ if (addToCache) {
+ cacheMap.put(position, dataBlock);
+ }
+ } else {
+ dataBlock = null;
+ }
+ return dataBlock;
+ }
+
+ private void write(final long position, final int offset, final byte[] data)
+ throws FileIOException {
+ DataBlock dataBlock = cacheMap.get(position);
+ if (dataBlock == null) {
+ dataBlock = readInFile(position,true);
+ if (dataBlock == null) {
+ final byte[] recordData = new byte[header.getBlockLength()];
+ dataBlock = new DataBlock(position, true, recordData);
+ cacheMap.put(position, dataBlock);
+ }
+ } else {
+ dataBlock.setToWrite(true);
+ }
+ System.arraycopy(data, 0, dataBlock.getData(), offset, data.length);
+ final long length = position + header.getBlockLength();
+ if (length > header.getDataLength()) {
+ header.setDataLength(length);
+ }
+ }
+}
Added: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/DualWrapDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/DualWrapDataManager.java (rev 0)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/DualWrapDataManager.java 2011-11-12 16:53:35 UTC (rev 2964)
@@ -0,0 +1,280 @@
+/*
+ * Copyright 2011 Luc Peuvrier
+ *
+ * This file is a part of JOAFIP.
+ *
+ * JOAFIP is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License.
+ *
+ * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
+ * Licensed under the LGPL License, Version 3, 29 June 2007 (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.gnu.org/licenses/lgpl.html
+ *
+ * JOAFIP is distributed in the hope that it will be useful, but
+ * 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 net.sf.joafip.heapfile.service;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Set;
+
+import net.sf.joafip.heapfile.record.entity.DataRecordIdentifier;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+public class DualWrapDataManager implements IHeapDataManager {
+
+ private final IHeapDataManager firstDataManager;
+
+ private final IHeapDataManager secondDataManager;
+
+ public DualWrapDataManager(final IHeapDataManager firstDataManager,
+ final IHeapDataManager secondDataManager) {
+ super();
+ this.firstDataManager = firstDataManager;
+ this.secondDataManager = secondDataManager;
+ }
+
+ @Override
+ public boolean isDataLost() {
+ // no implementation
+ return false;
+ }
+
+ @Override
+ public void startService(final boolean removeFiles) throws HeapException {
+ firstDataManager.startService(removeFiles);
+ secondDataManager.startService(removeFiles);
+ }
+
+ @Override
+ public void stopService() throws HeapException {
+ firstDataManager.stopService();
+ secondDataManager.stopService();
+ }
+
+ @Override
+ public boolean isServiceStarted() {
+ final boolean started1 = firstDataManager.isServiceStarted();
+ final boolean started2 = secondDataManager.isServiceStarted();
+ if (started1 != started2) {
+ throw new HeapRuntimeException("started stated missmatch "
+ + started1 + " " + started2);
+ }
+ return started1;
+ }
+
+ @Override
+ public void clear() throws HeapException {
+ firstDataManager.clear();
+ secondDataManager.clear();
+ }
+
+ @Override
+ public DataRecordIdentifier getNextFreeDataRecordIdentifier()
+ throws HeapException {
+ final DataRecordIdentifier next1 = firstDataManager
+ .getNextFreeDataRecordIdentifier();
+ final DataRecordIdentifier next2 = secondDataManager
+ .getNextFreeDataRecordIdentifier();
+ if (next1.value != next2.value) {
+ throw new HeapException("new data record identifier missmatch "
+ + next1.value + " " + next2.value);
+ }
+ return next1;
+ }
+
+ @Override
+ public void setNextFreeDataRecordIdentifier(
+ final DataRecordIdentifier dataRecordIdentifier)
+ throws HeapException {
+ firstDataManager.setNextFreeDataRecordIdentifier(dataRecordIdentifier);
+ secondDataManager.setNextFreeDataRecordIdentifier(dataRecordIdentifier);
+ }
+
+ @Override
+ public DataRecordIdentifier getNewDataRecordIdentifier()
+ throws HeapException {
+ final DataRecordIdentifier new1 = firstDataManager
+ .getNewDataRecordIdentifier();
+ final DataRecordIdentifier new2 = secondDataManager
+ .getNewDataRecordIdentifier();
+ if (new1.value != new2.value) {
+ throw new HeapException("new data record identifier missmatch "
+ + new1.value + " " + new2.value);
+ }
+ return new1;
+ }
+
+ @Override
+ public boolean hasDataRecord(final DataRecordIdentifier dataRecordIdentifier)
+ throws HeapException {
+ final boolean has1 = firstDataManager
+ .hasDataRecord(dataRecordIdentifier);
+ final boolean has2 = secondDataManager
+ .hasDataRecord(dataRecordIdentifier);
+ if (has1 != has2) {
+ throw new HeapException("has data record missmatch " + has1 + " "
+ + has2);
+ }
+ return has1;
+ }
+
+ @Override
+ public byte[] readDataRecord(final DataRecordIdentifier dataRecordIdentifier)
+ throws HeapException {
+ final byte[] data1 = firstDataManager
+ .readDataRecord(dataRecordIdentifier);
+ final byte[] data2 = secondDataManager
+ .readDataRecord(dataRecordIdentifier);
+ if (!Arrays.equals(data1, data2)) {
+ throw new HeapException("data differs");
+ }
+ return data1;
+ }
+
+ @Override
+ public boolean writeDataRecord(
+ final DataRecordIdentifier dataRecordIdentifier, final byte[] data)
+ throws HeapException {
+ final boolean created1 = firstDataManager.writeDataRecord(
+ dataRecordIdentifier, data);
+ final boolean created2 = secondDataManager.writeDataRecord(
+ dataRecordIdentifier, data);
+ if (created1 != created2) {
+ throw new HeapException("created state missmatch " + created1 + " "
+ + created2 + " for " + dataRecordIdentifier);
+ }
+ return created1;
+ }
+
+ @Override
+ public boolean deleteDataRecord(
+ final DataRecordIdentifier dataRecordIdentifier)
+ throws HeapException {
+ final boolean deleted1 = firstDataManager
+ .deleteDataRecord(dataRecordIdentifier);
+ final boolean deleted2 = secondDataManager
+ .deleteDataRecord(dataRecordIdentifier);
+ if (deleted1 != deleted2) {
+ throw new HeapException("deleted state missmatch " + deleted1 + " "
+ + deleted2);
+ }
+ return deleted1;
+ }
+
+ @Override
+ public DataRecordIdentifier removeFirstDataRecord() throws HeapException {
+ final DataRecordIdentifier dr1 = firstDataManager
+ .removeFirstDataRecord();
+ final DataRecordIdentifier dr2 = secondDataManager
+ .removeFirstDataRecord();
+ if (dr1.value != dr2.value) {
+ throw new HeapException("data record mismatch " + dr1.value + " "
+ + dr2.value);
+ }
+ return dr1;
+ }
+
+ @Override
+ public void flush() throws HeapException {
+ firstDataManager.flush();
+ secondDataManager.flush();
+ }
+
+ @Override
+ public void clearStandbyModification() throws HeapException {
+ firstDataManager.clearStandbyModification();
+ secondDataManager.clearStandbyModification();
+ }
+
+ @Override
+ public int getNumberOfDataRecord() throws HeapException {
+ // no implementation
+ return 0;
+ }
+
+ @Override
+ public int getNumberOfFreeRecord() throws HeapException {
+ // no implementation
+ return 0;
+ }
+
+ @Override
+ public long heapSize() throws HeapException {
+ // no implementation
+ return 0;
+ }
+
+ @Override
+ public long freeSize() throws HeapException {
+ // no implementation
+ return 0;
+ }
+
+ @Override
+ public long usedSize() throws HeapException {
+ // no implementation
+ return 0;
+ }
+
+ @Override
+ public void backup(final long identifier, final int maxBackup)
+ throws HeapException {
+ // no implementation
+ }
+
+ @Override
+ public String getStorageFileName() throws HeapException {
+ // no implementation
+ return null;
+ }
+
+ @Override
+ public String getBackupFileName() throws HeapException {
+ // no implementation
+ return null;
+ }
+
+ @Override
+ public String getChangeFileName() throws HeapException {
+ // no implementation
+ return null;
+ }
+
+ @Override
+ public Set<DataRecordIdentifier> getDataRecordIdentifierSet()
+ throws HeapException {
+ // no implementation
+ return null;
+ }
+
+ @Override
+ public Iterator<DataRecordIdentifier> dataRecordIterator()
+ throws HeapException {
+ // no implementation
+ return null;
+ }
+
+ @Override
+ public long getRecordPositionInfile(final DataRecordIdentifier identifier)
+ throws HeapException {
+ throw new HeapException("unsupported");
+ }
+
+ @Override
+ public long getLastRecordPositionInFile() throws HeapException {
+ throw new HeapException("unsupported");
+ }
+}
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileCheckerDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileCheckerDataManager.java 2011-11-12 16:49:48 UTC (rev 2963)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileCheckerDataManager.java 2011-11-12 16:53:35 UTC (rev 2964)
@@ -248,4 +248,15 @@
throws HeapException {
return heapFileDataManager.dataRecordIterator();
}
+
+ @Override
+ public long getRecordPositionInfile(final DataRecordIdentifier identifier)
+ throws HeapException {
+ throw new HeapException("unsupported");
+ }
+
+ @Override
+ public long getLastRecordPositionInFile() throws HeapException {
+ throw new HeapException("unsupported");
+ }
}
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapMemoryDataManagerMock.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapMemoryDataManagerMock.java 2011-11-12 16:49:48 UTC (rev 2963)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapMemoryDataManagerMock.java 2011-11-12 16:53:35 UTC (rev 2964)
@@ -291,4 +291,15 @@
public Iterator<DataRecordIdentifier> dataRecordIteratorImpl() {
return getDataRecordIdentifierSetImpl().iterator();
}
+
+ @Override
+ public long getRecordPositionInfile(final DataRecordIdentifier identifier)
+ throws HeapException {
+ throw new HeapException(UNSUPPORTED);
+ }
+
+ @Override
+ public long getLastRecordPositionInFile() throws HeapException {
+ throw new HeapException(UNSUPPORTED);
+ }
}
\ No newline at end of file
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapMultiFileDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapMultiFileDataManager.java 2011-11-12 16:49:48 UTC (rev 2963)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapMultiFileDataManager.java 2011-11-12 16:53:35 UTC (rev 2964)
@@ -462,4 +462,15 @@
public Iterator<DataRecordIdentifier> dataRecordIteratorImpl() {
throw new UnsupportedOperationException();
}
+
+ @Override
+ public long getR...
[truncated message content] |
|
From: <luc...@us...> - 2011-11-12 16:53:42
|
Revision: 2964
http://joafip.svn.sourceforge.net/joafip/?rev=2964&view=rev
Author: luc_peuvrier
Date: 2011-11-12 16:53:35 +0000 (Sat, 12 Nov 2011)
Log Message:
-----------
refactoring. Added block data manager for tests
Modified Paths:
--------------
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/DataRecordIdentifier.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/IHeapDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileCheckerDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapMemoryDataManagerMock.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapMultiFileDataManager.java
Added Paths:
-----------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/BlockDataManagerHeader.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/entity/DataBlock.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerImpl.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/BlockDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/DualWrapDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestBlockDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerBackup.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataManagerFreeing.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrMemoryLeak.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithScenario.java
Removed Paths:
-------------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapDataManagerBackup.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapDataManagerFreeing.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapDataMgrMemoryLeak.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapDataMgrWithScenario.java
Property Changed:
----------------
trunk/joafip-heapfile/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-12 16:49:54
|
Revision: 2963
http://joafip.svn.sourceforge.net/joafip/?rev=2963&view=rev
Author: luc_peuvrier
Date: 2011-11-12 16:49:48 +0000 (Sat, 12 Nov 2011)
Log Message:
-----------
for tests
Modified Paths:
--------------
trunk/joafip-file/src/test/java/net/sf/joafip/file/entity/FileAccessRecord.java
trunk/joafip-file/src/test/java/net/sf/joafip/file/service/ParallelRandomAccessFileForTest.java
trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileProbeForTest.java
Modified: trunk/joafip-file/src/test/java/net/sf/joafip/file/entity/FileAccessRecord.java
===================================================================
--- trunk/joafip-file/src/test/java/net/sf/joafip/file/entity/FileAccessRecord.java 2011-11-12 16:47:42 UTC (rev 2962)
+++ trunk/joafip-file/src/test/java/net/sf/joafip/file/entity/FileAccessRecord.java 2011-11-12 16:49:48 UTC (rev 2963)
@@ -35,17 +35,11 @@
private final byte[] data;
- public FileAccessRecord(final long positionInFile, final byte[] data) {
- super();
- this.positionInFile = positionInFile;
- this.data = data.clone();
- }
-
- public FileAccessRecord(final long positionInFile, final byte[] data,
+ public FileAccessRecord(final long positionInFile, final byte[] data,final int offset,
final int length) {
super();
this.positionInFile = positionInFile;
- this.data = Arrays.copyOf(data, length);
+ this.data = Arrays.copyOfRange(data, offset, offset+length);
}
public long getPositionInFile() {
Modified: trunk/joafip-file/src/test/java/net/sf/joafip/file/service/ParallelRandomAccessFileForTest.java
===================================================================
--- trunk/joafip-file/src/test/java/net/sf/joafip/file/service/ParallelRandomAccessFileForTest.java 2011-11-12 16:47:42 UTC (rev 2962)
+++ trunk/joafip-file/src/test/java/net/sf/joafip/file/service/ParallelRandomAccessFileForTest.java 2011-11-12 16:49:48 UTC (rev 2963)
@@ -181,6 +181,14 @@
}
@Override
+ public void write(final byte[] data, final int offset, final int length)
+ throws FileIOException {
+ randomFileDirect.write(data, offset, length);
+ randomFileDirectNio.write(data, offset, length);
+ randomFileReadWriteCache.write(data, offset, length);
+ }
+
+ @Override
public boolean isClose() throws FileIOException {
final boolean close1 = randomFileDirect.isClose();
final boolean close2 = randomFileDirectNio.isClose();
Modified: trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileProbeForTest.java
===================================================================
--- trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileProbeForTest.java 2011-11-12 16:47:42 UTC (rev 2962)
+++ trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileProbeForTest.java 2011-11-12 16:49:48 UTC (rev 2963)
@@ -59,7 +59,7 @@
final int read = delegate.read(data);
if (read > 0) {
final FileAccessRecord fileAccessRecord = new FileAccessRecord(
- positionInFile, data);
+ positionInFile, data, 0, data.length);
readLog.add(fileAccessRecord);
}
return read;
@@ -69,7 +69,7 @@
public void write(final byte[] data) throws FileIOException {
final long positionInFile = delegate.currentPositionInFile();
final FileAccessRecord fileAccessRecord = new FileAccessRecord(
- positionInFile, data);
+ positionInFile, data, 0, data.length);
delegate.write(data);
writeLog.add(fileAccessRecord);
}
@@ -79,11 +79,21 @@
throws FileIOException {
final long positionInFile = delegate.currentPositionInFile();
final FileAccessRecord fileAccessRecord = new FileAccessRecord(
- positionInFile, data, length);
+ positionInFile, data, 0, length);
delegate.write(data);
writeLog.add(fileAccessRecord);
}
+ @Override
+ public void write(final byte[] data, final int offset, final int length)
+ throws FileIOException {
+ final long positionInFile = delegate.currentPositionInFile();
+ final FileAccessRecord fileAccessRecord = new FileAccessRecord(
+ positionInFile, data, offset, length);
+ delegate.write(data);
+ writeLog.add(fileAccessRecord);
+ }
+
public void clearLog() {
readLog.clear();
writeLog.clear();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-12 16:49:54
|
Revision: 2963
http://joafip.svn.sourceforge.net/joafip/?rev=2963&view=rev
Author: luc_peuvrier
Date: 2011-11-12 16:49:48 +0000 (Sat, 12 Nov 2011)
Log Message:
-----------
for tests
Modified Paths:
--------------
trunk/joafip-file/src/test/java/net/sf/joafip/file/entity/FileAccessRecord.java
trunk/joafip-file/src/test/java/net/sf/joafip/file/service/ParallelRandomAccessFileForTest.java
trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileProbeForTest.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-12 16:47:48
|
Revision: 2962
http://joafip.svn.sourceforge.net/joafip/?rev=2962&view=rev
Author: luc_peuvrier
Date: 2011-11-12 16:47:42 +0000 (Sat, 12 Nov 2011)
Log Message:
-----------
added write method (data offset length)
Modified Paths:
--------------
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/AbstractRandomAccessFile.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/IRandomAccessFile.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirect.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirectNio.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-12 16:47:48
|
Revision: 2962
http://joafip.svn.sourceforge.net/joafip/?rev=2962&view=rev
Author: luc_peuvrier
Date: 2011-11-12 16:47:42 +0000 (Sat, 12 Nov 2011)
Log Message:
-----------
added write method (data offset length)
Modified Paths:
--------------
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/AbstractRandomAccessFile.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/IRandomAccessFile.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirect.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirectNio.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java
Modified: trunk/joafip-file/src/main/java/net/sf/joafip/file/service/AbstractRandomAccessFile.java
===================================================================
--- trunk/joafip-file/src/main/java/net/sf/joafip/file/service/AbstractRandomAccessFile.java 2011-11-12 16:42:00 UTC (rev 2961)
+++ trunk/joafip-file/src/main/java/net/sf/joafip/file/service/AbstractRandomAccessFile.java 2011-11-12 16:47:42 UTC (rev 2962)
@@ -145,6 +145,16 @@
throws FileIOException;
@Override
+ public void write(final byte[] data, final int offset, final int length)
+ throws FileIOException {
+ checkOpened();
+ writeImpl(data, offset, length);
+ }
+
+ protected abstract void writeImpl(byte[] data, int offset, int length)
+ throws FileIOException;
+
+ @Override
public long length() throws FileIOException {
checkOpened();
return lengthImpl();
Modified: trunk/joafip-file/src/main/java/net/sf/joafip/file/service/IRandomAccessFile.java
===================================================================
--- trunk/joafip-file/src/main/java/net/sf/joafip/file/service/IRandomAccessFile.java 2011-11-12 16:42:00 UTC (rev 2961)
+++ trunk/joafip-file/src/main/java/net/sf/joafip/file/service/IRandomAccessFile.java 2011-11-12 16:47:42 UTC (rev 2962)
@@ -75,6 +75,8 @@
void write(byte[] data, int length) throws FileIOException;
+ void write(byte[] data, int offset, int length) throws FileIOException;
+
long currentPositionInFile() throws FileIOException;
long length() throws FileIOException;
Modified: trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirect.java
===================================================================
--- trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirect.java 2011-11-12 16:42:00 UTC (rev 2961)
+++ trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirect.java 2011-11-12 16:47:42 UTC (rev 2962)
@@ -241,6 +241,18 @@
}
@Override
+ protected void writeImpl(final byte[] data,final int offset,final int length)
+ throws FileIOException {
+ try {
+ randomAccessFile.write(data, offset, length);
+ } catch (IOException exception) {
+ throw HELPER_FILE_UTIL.fileIOException("failed write in " + file,
+ file, exception);
+ }
+ currentPositionInFile += length;
+ }
+
+ @Override
public void clearCache() {
// nothing to do
}
Modified: trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirectNio.java
===================================================================
--- trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirectNio.java 2011-11-12 16:42:00 UTC (rev 2961)
+++ trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileDirectNio.java 2011-11-12 16:47:42 UTC (rev 2962)
@@ -290,6 +290,22 @@
}
@Override
+ protected void writeImpl(final byte[] data, final int offset,
+ final int length) throws FileIOException {
+ try {
+ final ByteBuffer byteBuffer = ByteBuffer.wrap(data, offset, length);
+ if (fileChannel.write(byteBuffer) != length) {
+ throw HELPER_FILE_UTIL.fileIOException("failed write " + length
+ + " bytes in " + file, file, null);
+ }
+ currentPositionInFile += length;
+ } catch (IOException exception) {
+ throw HELPER_FILE_UTIL.fileIOException("failed write in " + file,
+ file, exception);
+ }
+ }
+
+ @Override
public void clearCache() {
// nothing to do
}
Modified: trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java
===================================================================
--- trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java 2011-11-12 16:42:00 UTC (rev 2961)
+++ trunk/joafip-file/src/main/java/net/sf/joafip/file/service/RandomAccessFileReadWriteCache.java 2011-11-12 16:47:42 UTC (rev 2962)
@@ -269,12 +269,18 @@
@Override
public void writeImpl(final byte[] data) throws FileIOException {
- writeImpl(data, data.length);
+ writeImpl(data,0, data.length);
}
@Override
public void writeImpl(final byte[] data, final int length)
throws FileIOException {
+ writeImpl(data,0, length);
+ }
+
+ @Override
+ protected void writeImpl(final byte[] data,final int offset,final int length)
+ throws FileIOException {
int wrote = 0;
byte[] page;
do {
@@ -288,7 +294,7 @@
} else {
lengthToCopy = inPage;
}
- System.arraycopy(data, wrote, page, positionInPage, lengthToCopy);
+ System.arraycopy(data, offset+wrote, page, positionInPage, lengthToCopy);
wrote += lengthToCopy;
positionInFile += lengthToCopy;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-12 16:42:06
|
Revision: 2961
http://joafip.svn.sourceforge.net/joafip/?rev=2961&view=rev
Author: luc_peuvrier
Date: 2011-11-12 16:42:00 +0000 (Sat, 12 Nov 2011)
Log Message:
-----------
do not stop if failed delete file
Modified Paths:
--------------
trunk/joafip-common/src/test/java/net/sf/joafip/AbstractCommonDeleteFileTestCase.java
trunk/joafip-common/src/test/java/net/sf/joafip/HelperDeleteJoafipFileForTest.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-12 16:42:06
|
Revision: 2961
http://joafip.svn.sourceforge.net/joafip/?rev=2961&view=rev
Author: luc_peuvrier
Date: 2011-11-12 16:42:00 +0000 (Sat, 12 Nov 2011)
Log Message:
-----------
do not stop if failed delete file
Modified Paths:
--------------
trunk/joafip-common/src/test/java/net/sf/joafip/AbstractCommonDeleteFileTestCase.java
trunk/joafip-common/src/test/java/net/sf/joafip/HelperDeleteJoafipFileForTest.java
Modified: trunk/joafip-common/src/test/java/net/sf/joafip/AbstractCommonDeleteFileTestCase.java
===================================================================
--- trunk/joafip-common/src/test/java/net/sf/joafip/AbstractCommonDeleteFileTestCase.java 2011-11-01 01:45:31 UTC (rev 2960)
+++ trunk/joafip-common/src/test/java/net/sf/joafip/AbstractCommonDeleteFileTestCase.java 2011-11-12 16:42:00 UTC (rev 2961)
@@ -55,7 +55,11 @@
@Override
protected void tearDown() throws Exception {
super.tearDown();
- HelperDeleteJoafipFileForTest.deleteFiles(path);
+ try {
+ HelperDeleteJoafipFileForTest.deleteFiles(path);
+ } catch (Exception e) {// NOPMD
+ // ignore error
+ }
Thread.yield();
Thread.sleep(50);
Thread.yield(); // without have sometime file creation error on my PC
Modified: trunk/joafip-common/src/test/java/net/sf/joafip/HelperDeleteJoafipFileForTest.java
===================================================================
--- trunk/joafip-common/src/test/java/net/sf/joafip/HelperDeleteJoafipFileForTest.java 2011-11-01 01:45:31 UTC (rev 2960)
+++ trunk/joafip-common/src/test/java/net/sf/joafip/HelperDeleteJoafipFileForTest.java 2011-11-12 16:42:00 UTC (rev 2961)
@@ -50,9 +50,9 @@
&& file.isFile() && !file.delete()) {
LOGGER.fatal("failed delete file " + file, new Exception(// NOPMD
"trace"));
- System.err.println("failed delete file " + file);// NOPMD
- System.exit(1);// NOPMD
- // throw new Exception("failed delete " + file); // NOPMD
+ // System.err.println("failed delete file " + file);// NOPMD
+ // System.exit(1);// NOPMD
+ throw new Exception("failed delete " + file); // NOPMD
}
// } catch (Throwable throwable) {// NOPMD
// }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-01 01:45:38
|
Revision: 2960
http://joafip.svn.sourceforge.net/joafip/?rev=2960&view=rev
Author: luc_peuvrier
Date: 2011-11-01 01:45:31 +0000 (Tue, 01 Nov 2011)
Log Message:
-----------
plugin version update
Modified Paths:
--------------
trunk/joafip-parent/pom.xml
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-11-01 01:45:38
|
Revision: 2960
http://joafip.svn.sourceforge.net/joafip/?rev=2960&view=rev
Author: luc_peuvrier
Date: 2011-11-01 01:45:31 +0000 (Tue, 01 Nov 2011)
Log Message:
-----------
plugin version update
Modified Paths:
--------------
trunk/joafip-parent/pom.xml
Modified: trunk/joafip-parent/pom.xml
===================================================================
--- trunk/joafip-parent/pom.xml 2011-10-31 03:41:43 UTC (rev 2959)
+++ trunk/joafip-parent/pom.xml 2011-11-01 01:45:31 UTC (rev 2960)
@@ -172,7 +172,7 @@
<!-- add source directory -->
<!-- <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId>
- <version>1.5</version> <executions> <execution> <id>add-source</id> <phase>generate-sources</phase>
+ <version>1.7</version> <executions> <execution> <id>add-source</id> <phase>generate-sources</phase>
<goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>src/mtest/java</source>
<source>src/testsuite/java</source> <source>src/tool/java</source> </sources>
</configuration> </execution> <execution> <id>add-resource</id> <phase>generate-resources</phase>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-31 03:41:49
|
Revision: 2959
http://joafip.svn.sourceforge.net/joafip/?rev=2959&view=rev
Author: luc_peuvrier
Date: 2011-10-31 03:41:43 +0000 (Mon, 31 Oct 2011)
Log Message:
-----------
added close and open consistency on parallel random access file
Modified Paths:
--------------
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/FileOutputStreamNIO.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/IRandomAccessFile.java
trunk/joafip-file/src/test/java/net/sf/joafip/file/service/ParallelRandomAccessFileForTest.java
trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileProbeForTest.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-31 03:41:49
|
Revision: 2959
http://joafip.svn.sourceforge.net/joafip/?rev=2959&view=rev
Author: luc_peuvrier
Date: 2011-10-31 03:41:43 +0000 (Mon, 31 Oct 2011)
Log Message:
-----------
added close and open consistency on parallel random access file
Modified Paths:
--------------
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/FileOutputStreamNIO.java
trunk/joafip-file/src/main/java/net/sf/joafip/file/service/IRandomAccessFile.java
trunk/joafip-file/src/test/java/net/sf/joafip/file/service/ParallelRandomAccessFileForTest.java
trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileProbeForTest.java
Modified: trunk/joafip-file/src/main/java/net/sf/joafip/file/service/FileOutputStreamNIO.java
===================================================================
--- trunk/joafip-file/src/main/java/net/sf/joafip/file/service/FileOutputStreamNIO.java 2011-10-31 03:40:12 UTC (rev 2958)
+++ trunk/joafip-file/src/main/java/net/sf/joafip/file/service/FileOutputStreamNIO.java 2011-10-31 03:41:43 UTC (rev 2959)
@@ -70,12 +70,12 @@
@Override
public void close() throws IOException {
writeBuffer();
- if (randomAccessFile.isOpen()) {
- try {
+ try {
+ if (randomAccessFile.isOpen()) {
randomAccessFile.close();
- } catch (FileIOException exception) {
- throw new IOException(exception);
}
+ } catch (FileIOException exception) {
+ throw new IOException(exception);
}
}
Modified: trunk/joafip-file/src/main/java/net/sf/joafip/file/service/IRandomAccessFile.java
===================================================================
--- trunk/joafip-file/src/main/java/net/sf/joafip/file/service/IRandomAccessFile.java 2011-10-31 03:40:12 UTC (rev 2958)
+++ trunk/joafip-file/src/main/java/net/sf/joafip/file/service/IRandomAccessFile.java 2011-10-31 03:41:43 UTC (rev 2959)
@@ -46,9 +46,9 @@
*/
void close() throws FileIOException;
- boolean isOpen();
+ boolean isOpen() throws FileIOException;
- boolean isClose();
+ boolean isClose() throws FileIOException;
/**
* flush all modification on disk
Modified: trunk/joafip-file/src/test/java/net/sf/joafip/file/service/ParallelRandomAccessFileForTest.java
===================================================================
--- trunk/joafip-file/src/test/java/net/sf/joafip/file/service/ParallelRandomAccessFileForTest.java 2011-10-31 03:40:12 UTC (rev 2958)
+++ trunk/joafip-file/src/test/java/net/sf/joafip/file/service/ParallelRandomAccessFileForTest.java 2011-10-31 03:41:43 UTC (rev 2959)
@@ -181,13 +181,30 @@
}
@Override
- public boolean isClose() {
- return randomFileDirect.isClose();
+ public boolean isClose() throws FileIOException {
+ final boolean close1 = randomFileDirect.isClose();
+ final boolean close2 = randomFileDirectNio.isClose();
+ final boolean close3 = randomFileReadWriteCache.isClose();
+ if (close1 != close2 || close1 != close3 || close2 != close3) {
+ throw HelperFileUtil.getInstance()
+ .fileIOException(
+ "close state error " + close1 + "," + close2 + ","
+ + close3, null, null);
+ }
+ return close1;
}
@Override
- public boolean isOpen() {
- return randomFileDirect.isOpen();
+ public boolean isOpen() throws FileIOException {
+ final boolean open1 = randomFileDirect.isOpen();
+ final boolean open2 = randomFileDirectNio.isOpen();
+ final boolean open3 = randomFileReadWriteCache.isOpen();
+ if (open1 != open2 || open1 != open3 || open2 != open3) {
+ throw HelperFileUtil.getInstance().fileIOException(
+ "close state error " + open1 + "," + open2 + "," + open3,
+ null, null);
+ }
+ return open1;
}
@Override
Modified: trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileProbeForTest.java
===================================================================
--- trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileProbeForTest.java 2011-10-31 03:40:12 UTC (rev 2958)
+++ trunk/joafip-file/src/test/java/net/sf/joafip/file/service/RandomAccessFileProbeForTest.java 2011-10-31 03:41:43 UTC (rev 2959)
@@ -152,12 +152,12 @@
}
@Override
- public boolean isClose() {
+ public boolean isClose() throws FileIOException {
return delegate.isClose();
}
@Override
- public boolean isOpen() {
+ public boolean isOpen() throws FileIOException {
return delegate.isOpen();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-31 03:40:19
|
Revision: 2958
http://joafip.svn.sourceforge.net/joafip/?rev=2958&view=rev
Author: luc_peuvrier
Date: 2011-10-31 03:40:12 +0000 (Mon, 31 Oct 2011)
Log Message:
-----------
cache was not activated when crash safe mode enabled
Modified Paths:
--------------
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-31 03:40:18
|
Revision: 2958
http://joafip.svn.sourceforge.net/joafip/?rev=2958&view=rev
Author: luc_peuvrier
Date: 2011-10-31 03:40:12 +0000 (Mon, 31 Oct 2011)
Log Message:
-----------
cache was not activated when crash safe mode enabled
Modified Paths:
--------------
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java 2011-10-31 03:08:14 UTC (rev 2957)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java 2011-10-31 03:40:12 UTC (rev 2958)
@@ -137,7 +137,8 @@
crashSafeMode = true;
if (setup.isUseCacheMode()) {
fileForStorable = new FileForStorable(setup.getDataFile(),
- setup.getPageSize(), setup.getMaxPage());
+ setup.getPageSize(), setup.getMaxPage(),
+ maxFileOperationRetry, fileOperationRetryMsDelay);
/* no read cache on backup copy, not used for read */
fileForStorableBackup = new FileForStorable(
setup.getBackupDataFile(), setup.getPageSize(),
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-31 03:08:21
|
Revision: 2957
http://joafip.svn.sourceforge.net/joafip/?rev=2957&view=rev
Author: luc_peuvrier
Date: 2011-10-31 03:08:14 +0000 (Mon, 31 Oct 2011)
Log Message:
-----------
missing hashcode() added
Modified Paths:
--------------
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/AbstractHeapRBTNode.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/HeapRecord.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-31 03:08:21
|
Revision: 2957
http://joafip.svn.sourceforge.net/joafip/?rev=2957&view=rev
Author: luc_peuvrier
Date: 2011-10-31 03:08:14 +0000 (Mon, 31 Oct 2011)
Log Message:
-----------
missing hashcode() added
Modified Paths:
--------------
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/AbstractHeapRBTNode.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/HeapRecord.java
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/AbstractHeapRBTNode.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/AbstractHeapRBTNode.java 2011-10-31 03:07:11 UTC (rev 2956)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/AbstractHeapRBTNode.java 2011-10-31 03:08:14 UTC (rev 2957)
@@ -521,6 +521,11 @@
+ " parent=" + parentPositionInFile;
}
+ @Override
+ public int hashCode() {
+ return 31 + (int) (positionInFile ^ (positionInFile >>> 32));
+ }
+
@SuppressWarnings("unchecked")
@Override
public boolean equals(final Object obj) {// NOPMD hashcode not needed
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/HeapRecord.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/HeapRecord.java 2011-10-31 03:07:11 UTC (rev 2956)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/HeapRecord.java 2011-10-31 03:08:14 UTC (rev 2957)
@@ -799,6 +799,11 @@
}
@Override
+ public int hashCode() {
+ return 31 + (int) (positionInFile ^ (positionInFile >>> 32));
+ }
+
+ @Override
public boolean equals(final Object obj) {// NOPMD no hashcode needed
final boolean equals;
if (obj == this) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-31 03:07:18
|
Revision: 2956
http://joafip.svn.sourceforge.net/joafip/?rev=2956&view=rev
Author: luc_peuvrier
Date: 2011-10-31 03:07:11 +0000 (Mon, 31 Oct 2011)
Log Message:
-----------
fix update
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/reflect/HelperReflect.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/ClassInfo.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/FieldInfo.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/FieldInfoForSerialization.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/conversion/ValuedFieldList.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/classinfo/ClassInfoFactory.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/classinfo/IClassInfoFactory.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/conversion/def/AbstractConversionDefinitionReader.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/AbstractFieldOwnerHandler.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/InObjectHandler.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/XmlImporter.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerDelegatingToStateMap.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/ObjectIOManager.java
trunk/joafip/src/test/java/net/sf/joafip/service/sync/TestSynchronizedCollection.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-31 03:07:18
|
Revision: 2956
http://joafip.svn.sourceforge.net/joafip/?rev=2956&view=rev
Author: luc_peuvrier
Date: 2011-10-31 03:07:11 +0000 (Mon, 31 Oct 2011)
Log Message:
-----------
fix update
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/reflect/HelperReflect.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/ClassInfo.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/FieldInfo.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/FieldInfoForSerialization.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/conversion/ValuedFieldList.java
trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/classinfo/ClassInfoFactory.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/classinfo/IClassInfoFactory.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/conversion/def/AbstractConversionDefinitionReader.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/AbstractFieldOwnerHandler.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/InObjectHandler.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/XmlImporter.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerDelegatingToStateMap.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/ObjectIOManager.java
trunk/joafip/src/test/java/net/sf/joafip/service/sync/TestSynchronizedCollection.java
Modified: trunk/joafip/src/main/java/net/sf/joafip/reflect/HelperReflect.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/reflect/HelperReflect.java 2011-10-30 03:34:28 UTC (rev 2955)
+++ trunk/joafip/src/main/java/net/sf/joafip/reflect/HelperReflect.java 2011-10-31 03:07:11 UTC (rev 2956)
@@ -244,7 +244,7 @@
/**
* @param object
- * @param field
+ * @param fieldInfo
* @param fieldValue
* @throws ReflectException
* @throws ReflectFailedSetException
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/ClassInfo.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/ClassInfo.java 2011-10-30 03:34:28 UTC (rev 2955)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/ClassInfo.java 2011-10-31 03:07:11 UTC (rev 2956)
@@ -821,6 +821,24 @@
return allDeclaredTransientOrNotFields; // NOPMD
}
+ public FieldInfo getFieldInfo(final String declaringClassName,
+ final String fieldName) throws ClassInfoException {
+ if (!fieldInfoInitialized) {
+ initializeFieldInfo();
+ }
+ FieldInfo fieldInfo = null;
+ final int length = allDeclaredTransientOrNotFields.length;
+ for (int index = 0; fieldInfo == null && index < length; index++) {
+ final FieldInfo candidate = allDeclaredTransientOrNotFields[index];
+ if (fieldName.equals(candidate.getFieldName())
+ && declaringClassName.equals(candidate
+ .getDeclaringClassName())) {
+ fieldInfo = candidate;
+ }
+ }
+ return fieldInfo;
+ }
+
public FieldInfo[] getSerialPersistentFieldsInfo()
throws ClassInfoException {
if (!fieldInfoInitialized) {
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/FieldInfo.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/FieldInfo.java 2011-10-30 03:34:28 UTC (rev 2955)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/FieldInfo.java 2011-10-31 03:07:11 UTC (rev 2956)
@@ -77,6 +77,9 @@
private boolean persisted = true;
+ /**
+ * null field information
+ */
private FieldInfo() {
super();
this.field = null;// NOPMD
@@ -122,6 +125,7 @@
assertNotNull = field.isAnnotationPresent(AssertNotNull.class);
}
+ // FIXMELUC ______known field: called ?
public FieldInfo(final ClassInfo declaringClass, final String fieldName,
final ClassInfo fieldType, final Boolean staticField,
final Boolean transientField) throws ClassInfoException {
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/FieldInfoForSerialization.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/FieldInfoForSerialization.java 2011-10-30 03:34:28 UTC (rev 2955)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/classinfo/FieldInfoForSerialization.java 2011-10-31 03:07:11 UTC (rev 2956)
@@ -51,6 +51,7 @@
final String fieldName, final ClassInfo fieldType,
final Boolean staticField, final Boolean transientField)
throws ClassInfoException {
+ // FIXMELUC ______known field
super(declaringClass, fieldName, fieldType, staticField, transientField);
unshared = false;
securityException = null;
@@ -61,6 +62,7 @@
final String fieldName, final ClassInfo fieldType,
final NoSuchFieldException noSuchFieldException)
throws ClassInfoException {
+ // FIXMELUC ______known field
super(declaringClass, fieldName, fieldType, null, null);
unshared = false;
this.noSuchFieldException = noSuchFieldException;
@@ -71,6 +73,7 @@
final String fieldName, final ClassInfo fieldType,
final SecurityException securityException)
throws ClassInfoException {
+ // FIXMELUC ______known field
super(declaringClass, fieldName, fieldType, null, null);
unshared = false;
this.securityException = securityException;
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/conversion/ValuedFieldList.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/conversion/ValuedFieldList.java 2011-10-30 03:34:28 UTC (rev 2955)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/conversion/ValuedFieldList.java 2011-10-31 03:07:11 UTC (rev 2956)
@@ -101,6 +101,7 @@
// ASSERTX
assert fieldValue != null : "field value must be set";
try {
+ // FIXMELUC ______known field
final FieldInfo fieldInfo = new FieldInfo(declaringClass,
fieldName, fieldType, Boolean.valueOf(staticField),
Boolean.valueOf(transientField));
@@ -164,6 +165,7 @@
final boolean transientField, final int index)
throws ConversionException {
try {
+ // FIXMELUC ______known field
final FieldInfo fieldInfo = new FieldInfo(declaringClass,
fieldName, fieldType, Boolean.valueOf(staticField),
Boolean.valueOf(transientField));
@@ -205,6 +207,7 @@
final ClassInfo fieldType, final boolean staticField,
final boolean transientField) throws ConversionException {
try {
+ // FIXMELUC ______known field
final FieldInfo originalFieldInfo = new FieldInfo(
originalDeclaringClass, originalFieldName,
originalFieldType, null, null);
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java 2011-10-30 03:34:28 UTC (rev 2955)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectStateMap.java 2011-10-31 03:07:11 UTC (rev 2956)
@@ -582,7 +582,7 @@
private void removeWeaked(final ObjectAndPersistInfo toRemove) {
stateMap.remove(toRemove);
stateMapByIdentifier.remove(toRemove.dataRecordIdentifier);
- // FIXMELUC ___assert failure, why ?
+ // FIXMELUC ?___assert failure, why ?
// assert x == toRemove : x + "\n" + toRemove;
toRemove.clearSubstitution();
removeFromQueue(toRemove);
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/classinfo/ClassInfoFactory.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/classinfo/ClassInfoFactory.java 2011-10-30 03:34:28 UTC (rev 2955)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/classinfo/ClassInfoFactory.java 2011-10-31 03:07:11 UTC (rev 2956)
@@ -201,6 +201,19 @@
}
@Override
+ public ClassInfo getClassInfo(final Class<?> clazz)
+ throws ClassInfoException {
+ final String className = clazz.getName();
+ assert className.indexOf(ClassEnhancer.JOAFIP_SUFIX) == -1;
+ ClassInfo classInfo = classInfoMap.get(className);
+ if (classInfo == null) {
+ classInfo = createClassInfoOfExistingClass(clazz, className);
+ }
+ setAttributes(classInfo, className);
+ return classInfo;
+ }
+
+ @Override
public ClassInfo getNoProxyClassInfo(final Class<?> clazz)
throws ClassInfoException {
String className = clazz.getName();
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/classinfo/IClassInfoFactory.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/classinfo/IClassInfoFactory.java 2011-10-30 03:34:28 UTC (rev 2955)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/classinfo/IClassInfoFactory.java 2011-10-31 03:07:11 UTC (rev 2956)
@@ -60,6 +60,9 @@
ClassInfo knownAsNotExisting(String className)
throws ClassNotFoundException, ClassInfoException;
+ ClassInfo getClassInfo(Class<?> clazz) throws ClassInfoException;
+
+ // FIXMELUC __(rename) call only if can be a proxy
ClassInfo getNoProxyClassInfo(Class<?> clazz) throws ClassInfoException;
Class<?> getNoProxyClass(Class<?> clazz) throws ClassInfoException;
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/conversion/def/AbstractConversionDefinitionReader.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/conversion/def/AbstractConversionDefinitionReader.java 2011-10-30 03:34:28 UTC (rev 2955)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/conversion/def/AbstractConversionDefinitionReader.java 2011-10-31 03:07:11 UTC (rev 2956)
@@ -180,6 +180,7 @@
final ClassInfo declaringClass = classForName(declaringClassName);
FieldInfo fieldInfo;
try {
+ // FIXMELUC ______known field
fieldInfo = new FieldInfo(declaringClass, fieldName,// NOPMD
fieldClass, staticField, transientField);
} catch (ClassInfoException exception) {
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/AbstractFieldOwnerHandler.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/AbstractFieldOwnerHandler.java 2011-10-30 03:34:28 UTC (rev 2955)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/AbstractFieldOwnerHandler.java 2011-10-31 03:07:11 UTC (rev 2956)
@@ -79,6 +79,7 @@
final Boolean staticField, final Boolean transientField)
throws ImportException, ImportClassNotFoundException {
try {
+ // FIXMELUC ______known field
return new FieldInfo(fieldDeclaringClass, originalFieldName,
fieldType, staticField, transientField);
} catch (ClassInfoException exception) {
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/InObjectHandler.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/InObjectHandler.java 2011-10-30 03:34:28 UTC (rev 2955)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/InObjectHandler.java 2011-10-31 03:07:11 UTC (rev 2956)
@@ -97,10 +97,14 @@
FieldInfo fieldInfo;
- fieldInfo = new FieldInfo(currentObject.getClassInfo(),
- "dataModelIdentifier",
- classInfoFactory.getNoProxyClassInfo(int.class),
- false, false);
+ final ClassInfo currentObjectClassInfo = currentObject
+ .getClassInfo();
+ fieldInfo = currentObjectClassInfo.getFieldInfo(
+ StoreRoot4.class.getName(), "dataModelIdentifier");
+ // fieldInfo = new FieldInfo(currentObjectClassInfo,
+ // "dataModelIdentifier",
+ // classInfoFactory.getClassInfo(int.class),
+ // false, false);
currentObject.setValue(
2,
fieldInfo,
@@ -109,10 +113,13 @@
classInfoFactory
.getNoProxyClassInfo(int.class)));
- fieldInfo = new FieldInfo(currentObject.getClassInfo(),
- "dataRecordIdOfpersistedStaticSet",
- classInfoFactory.getNoProxyClassInfo(Set.class),
- false, false);
+ fieldInfo = currentObjectClassInfo.getFieldInfo(
+ StoreRoot4.class.getName(),
+ "dataRecordIdOfpersistedStaticSet");
+ // fieldInfo = new FieldInfo(currentObjectClassInfo,
+ // "dataRecordIdOfpersistedStaticSet",
+ // classInfoFactory.getClassInfo(Set.class),
+ // false, false);
Set<Long> dataRecordIdOfpersistedStaticSet = storeRoot
.getDataRecordIdOfpersistedStaticSet();
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/XmlImporter.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/XmlImporter.java 2011-10-30 03:34:28 UTC (rev 2955)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/export_import/in/XmlImporter.java 2011-10-31 03:07:11 UTC (rev 2956)
@@ -68,7 +68,7 @@
throw new ImportException(exportFile + " does not exists");
}
final SAXParserFactory factory = SAXParserFactory.newInstance();
- // FIXMELUC ____why not validating
+ // FIXMELUC ?____why not validating ?
factory.setValidating(false);
factory.setNamespaceAware(true);
final SchemaFactory schemaFactory = SchemaFactory
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerDelegatingToStateMap.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerDelegatingToStateMap.java 2011-10-30 03:34:28 UTC (rev 2955)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/AbstractObjectIOManagerDelegatingToStateMap.java 2011-10-31 03:07:11 UTC (rev 2956)
@@ -150,7 +150,7 @@
final DataRecordIdentifier dataRecordIdentifier) {
objectStateMgr
.clearObjectAndPersistInfoByDataRecordIdentifier(dataRecordIdentifier);
- // FIXMELUC ___clear statemap ?
+ // FIXMELUC ?___clear statemap ?
}
@Override
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/ObjectIOManager.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/ObjectIOManager.java 2011-10-30 03:34:28 UTC (rev 2955)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/objectio/manager/ObjectIOManager.java 2011-10-31 03:07:11 UTC (rev 2956)
@@ -121,7 +121,7 @@
private FileOutputStream changeFileOutputStream;
/** true if proxy notify object access */
- // FIXMELUC ___no more needed ?
+ // FIXMELUC ?___no more needed ?
private boolean maintainInMemoryEnabled;// NOPMD
private IFilePersistenceAutoSaver saver;
Modified: trunk/joafip/src/test/java/net/sf/joafip/service/sync/TestSynchronizedCollection.java
===================================================================
--- trunk/joafip/src/test/java/net/sf/joafip/service/sync/TestSynchronizedCollection.java 2011-10-30 03:34:28 UTC (rev 2955)
+++ trunk/joafip/src/test/java/net/sf/joafip/service/sync/TestSynchronizedCollection.java 2011-10-31 03:07:11 UTC (rev 2956)
@@ -66,7 +66,7 @@
FilePersistenceDataCorruptedException,
FilePersistenceNotSerializableException,
FilePersistenceTooBigForSerializationException {
- // FIXMELUC ______known problem to solve
+ // FIXMELUC __known problem to solve
if (buildMode) {
warnSkipped();
return;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-30 03:34:35
|
Revision: 2955
http://joafip.svn.sourceforge.net/joafip/?rev=2955&view=rev
Author: luc_peuvrier
Date: 2011-10-30 03:34:28 +0000 (Sun, 30 Oct 2011)
Log Message:
-----------
fix done, no more NullProxyCallBack
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectAndPersistInfo.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyManager2.java
trunk/joafip-4test/src/main/java/net/sf/joafip/store/service/bytecode/SuperExternalizableExtend.java
trunk/joafip-4test/src/main/java/net/sf/joafip/store/service/bytecode/SuperSerializableExtend.java
trunk/joafip-4test/src/main/java/net/sf/joafip/store/service/bytecode/UsingNullProxyCallBack.java
Removed Paths:
-------------
trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/NullProxyCallBack.java
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectAndPersistInfo.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectAndPersistInfo.java 2011-10-30 03:09:09 UTC (rev 2954)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectAndPersistInfo.java 2011-10-30 03:34:28 UTC (rev 2955)
@@ -41,7 +41,6 @@
import net.sf.joafip.store.service.objectio.ObjectIOInvalidClassException;
import net.sf.joafip.store.service.proxy.IProxyCallBackProxyDelegation;
import net.sf.joafip.store.service.proxy.IProxyCallBackToImplement;
-import net.sf.joafip.store.service.proxy.NullProxyCallBack;
import net.sf.joafip.store.service.proxy.ProxyManager2;
/**
@@ -52,9 +51,6 @@
@NotStorableClass
public class ObjectAndPersistInfo extends ObjectAndItsClassInfo {
- private static final NullProxyCallBack NULL_PROXY_CALL_BACK_INSTANCE = NullProxyCallBack
- .getInstance();
-
private static final ObjectClassInfoAndDeclared[] NO_WROTE_OBJECTS =
/**/new ObjectClassInfoAndDeclared[0];
@@ -125,7 +121,7 @@
public FieldInfo[] fieldToSetInfo;
- private IProxyCallBackToImplement proxyCallBack = NULL_PROXY_CALL_BACK_INSTANCE;
+ private IProxyCallBackToImplement proxyCallBack;
private final boolean proxyIntanceOrEnhanced;
Deleted: trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/NullProxyCallBack.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/NullProxyCallBack.java 2011-10-30 03:09:09 UTC (rev 2954)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/NullProxyCallBack.java 2011-10-30 03:34:28 UTC (rev 2955)
@@ -1,201 +0,0 @@
-/*
- * Copyright 2009 Luc Peuvrier
- *
- * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE
- * Licensed under the LGPL License, Version 3, 29 June 2007 (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.gnu.org/licenses/lgpl.html
- *
- * 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 net.sf.joafip.store.service.proxy;
-
-import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.store.entity.objectio.ObjectAndPersistInfo;
-import net.sf.joafip.store.service.classinfo.ClassInfoFactory;
-import net.sf.joafip.store.service.objectio.ObjectIOClassNotFoundException;
-import net.sf.joafip.store.service.objectio.ObjectIODataCorruptedException;
-import net.sf.joafip.store.service.objectio.ObjectIODataRecordNotFoundException;
-import net.sf.joafip.store.service.objectio.ObjectIOException;
-import net.sf.joafip.store.service.objectio.ObjectIOInvalidClassException;
-import net.sf.joafip.store.service.objectio.ObjectIONotSerializableException;
-import net.sf.joafip.store.service.objectio.manager.IObjectIOManagerForProxyObjectIO;
-
-/**
- *
- * @author luc peuvrier
- *
- */
-@NotStorableClass
-public final class NullProxyCallBack implements IProxyCallBack,
- IProxyCallBackToImplement {
-
- public static final NullProxyCallBack INSTANCE =
- /**/new NullProxyCallBack();
-
- private NullProxyCallBack() {
- super();
- }
-
- public static NullProxyCallBack getInstance() {
- return INSTANCE;
- }
-
- @Override
- @SuppressWarnings("PMD")
- public void initialize$JOAFIP$(IProxyCallBackToImplement proxyCallBack)
- throws ProxyException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void initializeFileAccessSessionIdentifier(
- final IObjectIOManagerForProxyObjectIO objectIOManager) {
- throw new UnsupportedOperationException();
- // do nothing
- }
-
- @Override
- @SuppressWarnings("PMD")
- public void intercept$JOAFIP$() {
- // FIXMELUC ___call when proxied construct, construct not need
- // interception
- // throw new UnsupportedOperationException();
- // do nothing
- }
-
- @SuppressWarnings("PMD")
- @Override
- public void constructorEnd$JOAFIP$() {
- // no implementation
- }
-
- @Override
- @SuppressWarnings("PMD")
- public void methodEnd$JOAFIP$() {
- // FIXMELUC ___call when proxied construct, construct not need
- // interception
- // throw new UnsupportedOperationException();
- // do nothing
- }
-
- @Override
- @SuppressWarnings("PMD")
- public boolean isLoaded$JOAFIP$() {
- throw new UnsupportedOperationException();
- // not loaded also means not construct
- // return false;
- }
-
- @Override
- @SuppressWarnings("PMD")
- public void forceLoad$JOAFIP$() throws ObjectIOException,
- ObjectIODataRecordNotFoundException, ObjectIOInvalidClassException,
- ObjectIOClassNotFoundException, ObjectIODataCorruptedException,
- ObjectIONotSerializableException {
- // do nothing
- throw new UnsupportedOperationException();
- }
-
- @Override
- @SuppressWarnings("PMD")
- public void unload$JOAFIP$() {
- // do nothing
- throw new UnsupportedOperationException();
- }
-
- @Override
- @SuppressWarnings("PMD")
- public long getMyFileAccessSessionIdentifier$JOAFIP$() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- @SuppressWarnings("PMD")
- public void setIsLoaded$JOAFIP$() throws ObjectIOException {
- throw new UnsupportedOperationException();
- }
-
- @SuppressWarnings("PMD")
- @Override
- public void setIsLoadedNoSave$JOAFIP$() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- @SuppressWarnings("PMD")
- public void setLoading$JOAFIP$(final boolean loading) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- @SuppressWarnings("PMD")
- public IObjectIOManagerForProxyObjectIO getObjectIOManager$JOAFIP$() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- @SuppressWarnings("PMD")
- public ClassInfoFactory getClassInfoFactory$JOAFIP$() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- @SuppressWarnings("PMD")
- public void setInstance$JOAFIP$(
- final ObjectAndPersistInfo objectAndPersistInfo) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- @SuppressWarnings("PMD")
- public ObjectAndPersistInfo getInstance$JOAFIP$() {
- throw new UnsupportedOperationException();
- // return null;
- }
-
- @Override
- public IProxyCallBackToImplement getProxyCallBack$JOAFIP$() {// NOPMD
- return this;
- }
-
- @Override
- @SuppressWarnings("PMD")
- public void setProxyCallBack$JOAFIP$(
- final IProxyCallBackToImplement proxyCallBack) {
- // no implementation
- throw new UnsupportedOperationException();
- }
-
- // @Override
- // @SuppressWarnings("PMD")
- // public Exception getLoadTrace$JOAFIP$() {
- // // no implementation
- // return null;
- // }
-
- // @Override
- // @SuppressWarnings("PMD")
- // public Exception getUnloadTrace$JOAFIP$() {
- // // no implementation
- // return null;
- // }
-
- @Override
- @SuppressWarnings("PMD")
- public int getInObjectCount$JOAFIP$() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- @SuppressWarnings("PMD")
- public boolean isAutoSaveEnabled$JOAFIP$() {
- throw new UnsupportedOperationException();
- }
-}
Modified: trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyManager2.java
===================================================================
--- trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyManager2.java 2011-10-30 03:09:09 UTC (rev 2954)
+++ trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyManager2.java 2011-10-30 03:34:28 UTC (rev 2955)
@@ -48,9 +48,6 @@
@NotStorableClass
public final class ProxyManager2 implements IProxyManagerForObjectIO {
- private static final NullProxyCallBack NULL_PROXY_CALL_BACK_INSTANCE = NullProxyCallBack
- .getInstance();
-
private static final String NO_OBJECT_CLASS =
/**/"object class information is not defined: error proxy call back is not setted for ";
@@ -279,7 +276,6 @@
objectAndPersistInfo.setStorageInfo(storageInfo);
if (constructed) {
- assert getProxyCallBack(instanceCreated) != NULL_PROXY_CALL_BACK_INSTANCE;
assert objectAndPersistInfo.isNotWeak();
objectAndPersistInfo.setIsLoaded();
}
@@ -592,8 +588,7 @@
final Object object) {
final IProxyCallBackToImplement proxyCallBack = getProxyCallBack(object);
final ObjectAndPersistInfo objectAndPersistInfo;
- if (proxyCallBack == null
- || proxyCallBack == NULL_PROXY_CALL_BACK_INSTANCE) {// NOPMD
+ if (proxyCallBack == null) {
objectAndPersistInfo = null;
} else {
objectAndPersistInfo = proxyCallBack.getInstance$JOAFIP$();
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/store/service/bytecode/SuperExternalizableExtend.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/store/service/bytecode/SuperExternalizableExtend.java 2011-10-30 03:09:09 UTC (rev 2954)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/store/service/bytecode/SuperExternalizableExtend.java 2011-10-30 03:34:28 UTC (rev 2955)
@@ -4,19 +4,16 @@
import java.io.ObjectInput;
import net.sf.joafip.store.service.proxy.IProxyCallBackProxyDelegation;
-import net.sf.joafip.store.service.proxy.NullProxyCallBack;
@SuppressWarnings("PMD")
public class SuperExternalizableExtend extends SuperExternalizable {
+ @SuppressWarnings("unused")
private IProxyCallBackProxyDelegation $proxyCallBack$;// NOPMD
@Override
public void readExternal(final ObjectInput in) throws IOException,
ClassNotFoundException {
- if ($proxyCallBack$ == null) {
- $proxyCallBack$ = NullProxyCallBack.INSTANCE;
- }
super.readExternal(in);
}
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/store/service/bytecode/SuperSerializableExtend.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/store/service/bytecode/SuperSerializableExtend.java 2011-10-30 03:09:09 UTC (rev 2954)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/store/service/bytecode/SuperSerializableExtend.java 2011-10-30 03:34:28 UTC (rev 2955)
@@ -4,7 +4,6 @@
import java.io.ObjectInputStream;
import net.sf.joafip.store.service.proxy.IProxyCallBackProxyDelegation;
-import net.sf.joafip.store.service.proxy.NullProxyCallBack;
@SuppressWarnings("PMD")
public class SuperSerializableExtend extends SuperSerializable {
@@ -14,14 +13,12 @@
*/
private static final long serialVersionUID = -5560800790933799145L;
+ @SuppressWarnings("unused")
private IProxyCallBackProxyDelegation $proxyCallBack$;// NOPMD
@Override
protected void readObject(final ObjectInputStream in) throws IOException,
ClassNotFoundException {
- if ($proxyCallBack$ == null) {
- $proxyCallBack$ = NullProxyCallBack.INSTANCE;
- }
super.readObject(in);
}
Modified: trunk/joafip-4test/src/main/java/net/sf/joafip/store/service/bytecode/UsingNullProxyCallBack.java
===================================================================
--- trunk/joafip-4test/src/main/java/net/sf/joafip/store/service/bytecode/UsingNullProxyCallBack.java 2011-10-30 03:09:09 UTC (rev 2954)
+++ trunk/joafip-4test/src/main/java/net/sf/joafip/store/service/bytecode/UsingNullProxyCallBack.java 2011-10-30 03:34:28 UTC (rev 2955)
@@ -1,12 +1,11 @@
package net.sf.joafip.store.service.bytecode;
import net.sf.joafip.store.service.proxy.IProxyCallBack;
-import net.sf.joafip.store.service.proxy.NullProxyCallBack;
@SuppressWarnings("PMD")
public class UsingNullProxyCallBack {
- IProxyCallBack proxyCallBack = NullProxyCallBack.INSTANCE;
+ IProxyCallBack proxyCallBack;
public UsingNullProxyCallBack() {// NOPMD
super();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2011-10-30 03:34:35
|
Revision: 2955
http://joafip.svn.sourceforge.net/joafip/?rev=2955&view=rev
Author: luc_peuvrier
Date: 2011-10-30 03:34:28 +0000 (Sun, 30 Oct 2011)
Log Message:
-----------
fix done, no more NullProxyCallBack
Modified Paths:
--------------
trunk/joafip/src/main/java/net/sf/joafip/store/entity/objectio/ObjectAndPersistInfo.java
trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/ProxyManager2.java
trunk/joafip-4test/src/main/java/net/sf/joafip/store/service/bytecode/SuperExternalizableExtend.java
trunk/joafip-4test/src/main/java/net/sf/joafip/store/service/bytecode/SuperSerializableExtend.java
trunk/joafip-4test/src/main/java/net/sf/joafip/store/service/bytecode/UsingNullProxyCallBack.java
Removed Paths:
-------------
trunk/joafip/src/main/java/net/sf/joafip/store/service/proxy/NullProxyCallBack.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|