Thread: [Joafip-svn] SF.net SVN: joafip:[2997] trunk/joafip-heapfile/src
Brought to you by:
luc_peuvrier
|
From: <luc...@us...> - 2012-04-08 06:48:26
|
Revision: 2997
http://joafip.svn.sourceforge.net/joafip/?rev=2997&view=rev
Author: luc_peuvrier
Date: 2012-04-08 06:48:19 +0000 (Sun, 08 Apr 2012)
Log Message:
-----------
warning correction
Modified Paths:
--------------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerImpl.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithKey.java
Removed Paths:
-------------
trunk/joafip-heapfile/src/main/java/net/sf/joafip/kvstore/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-08 06:48:25
|
Revision: 2997
http://joafip.svn.sourceforge.net/joafip/?rev=2997&view=rev
Author: luc_peuvrier
Date: 2012-04-08 06:48:19 +0000 (Sun, 08 Apr 2012)
Log Message:
-----------
warning correction
Modified Paths:
--------------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerImpl.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithKey.java
Removed Paths:
-------------
trunk/joafip-heapfile/src/main/java/net/sf/joafip/kvstore/
Modified: 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 2012-04-08 03:03:31 UTC (rev 2996)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerImpl.java 2012-04-08 06:48:19 UTC (rev 2997)
@@ -38,6 +38,8 @@
public abstract class AbstractTestHeapDataManagerImpl extends
AbstractTestHeapDataManagerRecord {
+ private static final String BAD_VALUE = "bad value";
+
private static final String MUST_DELETE_1 = "must delete #1";
private static final String MUST_NOT_HAVE_DATA_RECORD = "must not have data record";
@@ -383,7 +385,7 @@
final DataRecordIdentifier identifier = new DataRecordIdentifier(0);
data = heapDataManager.readDataRecord(identifier);
for (int index = 0; index < 20; index++) {
- assertEquals("bad value", data[index], index);
+ assertEquals(BAD_VALUE, data[index], index);
}
for (int index = 0; index < 20; index++) {
data[index] = (byte) (10 + index);
@@ -393,7 +395,7 @@
createHeap(false/* remove file */);
data = heapDataManager.readDataRecord(identifier);
for (int index = 0; index < 20; index++) {
- assertEquals("bad value", data[index], 10 + index);
+ assertEquals(BAD_VALUE, data[index], 10 + index);
}
}
@@ -615,10 +617,10 @@
heapDataManager.flush();
identifier = heapDataManager.removeFirstDataRecord();
assertNotNull("must deleted first data record", identifier);
- assertEquals(0L, identifier.value);
+ assertEquals(BAD_VALUE,0L, identifier.value);
identifier = heapDataManager.removeFirstDataRecord();
assertNotNull("must deleted first data record", identifier);
- assertEquals(1L, identifier.value);
+ assertEquals(BAD_VALUE,1L, identifier.value);
assertNull(MUST_NOT_HAVE_DATA_RECORD,
heapDataManager.removeFirstDataRecord());
}
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithKey.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithKey.java 2012-04-08 03:03:31 UTC (rev 2996)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithKey.java 2012-04-08 06:48:19 UTC (rev 2997)
@@ -58,7 +58,7 @@
assertTrue("must found 'A'", heapDataManager.hasDataRecord(keyA));
final byte[] readDataA = heapDataManager.readDataRecord(keyA);
assertNotNull("must read 'A' data", readDataA);
- assertEquals("valueA", new String(readDataA));
+ assertEquals("bad value","valueA", new String(readDataA));
}
@Override
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-17 04:52:10
|
Revision: 3010
http://joafip.svn.sourceforge.net/joafip/?rev=3010&view=rev
Author: luc_peuvrier
Date: 2012-04-17 04:52:03 +0000 (Tue, 17 Apr 2012)
Log Message:
-----------
useless abstract removed
Modified Paths:
--------------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerImpl.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/TestHeapFileDataMgrWithKey.java
Added Paths:
-----------
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/FileForStorable.java
Removed Paths:
-------------
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/AbstractFileFor.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/FileForStorable.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-17 04:52:13
|
Revision: 3010
http://joafip.svn.sourceforge.net/joafip/?rev=3010&view=rev
Author: luc_peuvrier
Date: 2012-04-17 04:52:03 +0000 (Tue, 17 Apr 2012)
Log Message:
-----------
useless abstract removed
Modified Paths:
--------------
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerImpl.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/TestHeapFileDataMgrWithKey.java
Added Paths:
-----------
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/FileForStorable.java
Removed Paths:
-------------
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/AbstractFileFor.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/FileForStorable.java
Deleted: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/AbstractFileFor.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/AbstractFileFor.java 2012-04-16 03:07:06 UTC (rev 3009)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/AbstractFileFor.java 2012-04-17 04:52:03 UTC (rev 3010)
@@ -1,358 +0,0 @@
-/*
- * 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.heapfile.service;
-
-import java.io.File;
-
-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.kvstore.service.HeapException;
-import net.sf.joafip.logger.JoafipLogger;
-
-/**
- * abstract file management
- *
- * @author luc peuvrier
- *
- */
-@NotStorableClass
-public abstract class AbstractFileFor implements IFileForStorable {// NOPMD
- // abstract
- // class
- // without
- // abstract
- // method
-
- private static final String FILE_IS_OPENED = "file is opened";
-
- protected final JoafipLogger logger = JoafipLogger.getLogger(getClass());// NOPMD
-
- protected static final String FILE_ALREADY_CLOSED = "file already closed";
-
- protected static final String FILE_NOT_OPENNED = "file not opened";
-
- private static final String FILE_ALREADY_OPENED = "file already opened";
-
- protected static final String FAILED_DELETE_FILE = "failed delete file ";
-
- /** the file object for file heap */
- private final File file;
-
- /** for random read write file access */
- protected IRandomAccessFile randomAccessFile;
-
- /** true if file opened */
- private boolean opened = false;
-
- private Exception opennerTrace;
-
- private Exception closerTrace = new Exception("closer trace");
-
- /**
- * setup file to manage at construction, do not use cache<br>
- *
- * @param fileName
- * the file to manage name
- * @param maxRetry
- * @param retryMsDelay
- * @throws HeapException
- */
- public AbstractFileFor(final String fileName, final int maxRetry,
- final int retryMsDelay) throws HeapException {
- this(fileName == null ? null : new File(fileName), maxRetry,
- retryMsDelay);
- }
-
- /**
- * setup file to manage at construction, do not use cache<br>
- *
- * @param file
- * the file to manage
- * @param maxRetry
- * @param retryMsDelay
- * @throws HeapException
- */
- public AbstractFileFor(final File file, final int maxRetry,
- final int retryMsDelay) throws HeapException {
- this.file = file;
- randomAccessFile = new RandomAccessFileDirectNio(file, maxRetry,
- retryMsDelay);
- }
-
- /**
- * setup file to manage and read/write cache at construction<br>
- *
- * @param fileName
- * the file to manage name
- * @param pageSize
- * page size ( number of byte ), must be greater or equals to
- * 1024
- * @param maxPage
- * maximum number of page for read cache
- * @param maxRetry
- * @param retryMsDelay
- * @throws HeapException
- */
- public AbstractFileFor(final String fileName, final int pageSize,
- final int maxPage, final int maxRetry, final int retryMsDelay)
- throws HeapException {
- this(fileName == null ? null : new File(fileName), pageSize, maxPage,
- maxRetry, retryMsDelay);
- }
-
- /**
- * setup file to manage and read/write cache at construction<br>
- *
- * @param file
- * the file to manage
- * @param pageSize
- * page size ( number of byte ), must be greater or equals to
- * 1024
- * @param maxPage
- * maximum number of page for read cache
- * @param maxRetry
- * @param retryMsDelay
- * @throws HeapException
- */
- public AbstractFileFor(final File file, final int pageSize,
- final int maxPage, final int maxRetry, final int retryMsDelay)
- throws HeapException {
- this.file = file;
- final RandomAccessFileDirectNio randomAccessFileDirect =
- /**/new RandomAccessFileDirectNio(file, maxRetry, retryMsDelay);
- randomAccessFile = new RandomAccessFileReadWriteCache(
- randomAccessFileDirect, pageSize, maxPage, maxRetry,
- retryMsDelay);
- }
-
- /**
- * setup file to manage and read/write cache at construction<br>
- *
- * @param file
- * the file to manage
- * @param pageSize
- * page size ( number of byte ), must be greater or equals to
- * 1024
- * @param maxPage
- * maximum number of page for read cache
- * @param haveReadCache
- * true if have read cache
- * @param maxRetry
- * @param retryMsDelay
- * @throws HeapException
- */
- public AbstractFileFor(final File file, final int pageSize,
- final int maxPage, final boolean haveReadCache, final int maxRetry,
- final int retryMsDelay) {
- this.file = file;
- final RandomAccessFileDirectNio randomAccessFileDirect =
- /**/new RandomAccessFileDirectNio(file, maxRetry, retryMsDelay);
- randomAccessFile = new RandomAccessFileReadWriteCache(
- randomAccessFileDirect, pageSize, maxPage, haveReadCache);
- }
-
- @Override
- public void open() throws HeapException {
- if (opened) {
- throw new HeapException(FILE_ALREADY_OPENED, opennerTrace);
- } else {
- try {
- randomAccessFile.open();
- } catch (FileIOException exception) {
- throw new HeapException(exception);
- }
- opened = true;
- opennerTrace = new Exception("openner trace");
- }
- }
-
- @Override
- public void close() throws HeapException {
- if (opened) {
- opened = false;
- closerTrace = new Exception("closer trace");
- try {
- randomAccessFile.close();
- } catch (FileIOException e) {
- throw new HeapException(e);
- }
- } else {
- throw new HeapException(FILE_ALREADY_CLOSED, closerTrace);
- }
- }
-
- @Override
- public void flush() throws HeapException {
- assertOpened();
- try {
- randomAccessFile.flush();
- } catch (FileIOException e) {
- throw new HeapException(e);
- }
- }
-
- @Override
- public void resetFileSize() throws HeapException {
- assertOpened();
- try {
- randomAccessFile.setLength(0);
- } catch (FileIOException e) {
- throw closeAfterIOException(e);
- }
- }
-
- @Override
- public void deleteFileIfExists() throws HeapException {
- if (opened) {
- throw new HeapException(FILE_IS_OPENED);
- }
- if (logger.debugEnabled) {
- logger.debug("delete " + file);
- }
- try {
- randomAccessFile.deleteIfExists();
- } catch (FileIOException exception) {
- throw new HeapException(FAILED_DELETE_FILE + file, exception);
- }
- }
-
- @Override
- public void deleteFileIfExistsRenaming() throws HeapException {
- if (opened) {
- throw new HeapException(FILE_IS_OPENED);
- }
- if (logger.debugEnabled) {
- logger.debug("delete " + file);
- }
- try {
- randomAccessFile.deleteIfExistsRenaming();
- } catch (FileIOException exception) {
- throw new HeapException(FAILED_DELETE_FILE + file, exception);
- }
- }
-
- /**
- * @throws HeapException
- *
- */
- private void assertOpened() throws HeapException {
- if (!opened) {
- throw new HeapException(FILE_NOT_OPENNED, closerTrace);
- }
- }
-
- public boolean isOpened() {
- return opened;
- }
-
- @Override
- public void seek(final long positionInFile) throws HeapException {
- assertOpened();
- try {
- randomAccessFile.seek(positionInFile);
- } catch (FileIOException e) {
- throw closeAfterIOException(e);
- }
- }
-
- @Override
- public int read(final byte[] data) throws HeapException {
- assertOpened();
- try {
- return randomAccessFile.read(data);// NOPMD
- } catch (FileIOException e) {
- throw closeAfterIOException(e);
- }
- }
-
- @Override
- public void write(final byte[] data) throws HeapException {
- assertOpened();
- try {
- randomAccessFile.write(data);
- } catch (FileIOException e) {
- throw closeAfterIOException(e);
- }
- }
-
- @Override
- public File getFile() {
- return file;
- }
-
- @Override
- public long getFileSize() throws HeapException {
- long size;
- assertOpened();
- try {
- size = randomAccessFile.length();
- } catch (FileIOException e) {
- throw closeAfterIOException(e);
- }
- return size;
- }
-
- /**
- * set the size of this file
- *
- * @param newSize
- * the file new size
- * @throws HeapException
- * if an I/O error occurs.
- */
- public void setFileSize(final long newSize) throws HeapException {
- assertOpened();
- try {
- randomAccessFile.setLength(newSize);
- } catch (FileIOException e) {
- throw closeAfterIOException(e);
- }
- }
-
- /**
- * close after io exception
- */
- protected HeapException closeAfterIOException(
- final FileIOException exception) throws HeapException {
- final HeapException fileForStorageException =
- /**/new HeapException(exception);
- try {
- close();
- } catch (HeapException exception2) {
- logger.warn("closing after exception", exception2);
- }
- return fileForStorageException;
- }
-
- public void copy(final String fileName) throws FileIOException {
- randomAccessFile.copy(fileName);
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("AbstractFileFor [file=");
- builder.append(file);
- builder.append(", opened=");
- builder.append(opened);
- builder.append("]");
- return builder.toString();
- }
-}
Deleted: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/FileForStorable.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/FileForStorable.java 2012-04-16 03:07:06 UTC (rev 3009)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/FileForStorable.java 2012-04-17 04:52:03 UTC (rev 3010)
@@ -1,158 +0,0 @@
-/*
- * 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.heapfile.service;
-
-import java.io.File;
-
-import net.sf.joafip.NotStorableClass;
-import net.sf.joafip.file.service.FileIOException;
-import net.sf.joafip.heapfile.entity.IFileStorable;
-import net.sf.joafip.heapfile.record.entity.ToBackupRecord;
-import net.sf.joafip.kvstore.service.HeapException;
-
-/**
- * to read/write class implementing {@link IFileStorable} to/from file.<br>
- * {@link #open()} and {@link #close()}<br>
- *
- * @author luc peuvrier
- *
- */
-@NotStorableClass
-public class FileForStorable extends AbstractFileFor {
-
- /**
- * create a file to read from and write to {@link IFileStorable} object.<br>
- * no cache used for file management<br>
- *
- * @param fileName
- * the file name of file to use for object storing
- * @param maxRetry
- * @param retryMsDelay
- * @throws HeapException
- * if an I/O error occurs while opening the file
- */
- public FileForStorable(final String fileName, final int maxRetry,
- final int retryMsDelay) throws HeapException {
- super(fileName, maxRetry, retryMsDelay);
- }
-
- /**
- * create a file to read from and write to {@link IFileStorable} object<br>
- * no cache used for file management<br>
- *
- * @param file
- * the file to use for object storing
- * @param maxRetry
- * @param retryMsDelay
- * @throws HeapException
- * if an I/O error occurs while opening the file
- */
- public FileForStorable(final File file, final int maxRetry,
- final int retryMsDelay) throws HeapException {
- super(file, maxRetry, retryMsDelay);
- }
-
- /**
- * create a file to read from and write to {@link IFileStorable} object<br>
- * file management use read/write cache<br>
- *
- * @param file
- * the file to use for object storing
- * @param pageSize
- * page size ( number of byte ), must be greater or equals to
- * 1024
- * @param maxPage
- * maximum number of page for read cache
- * @param maxRetry
- * @param retryMsDelay
- * @throws HeapException
- */
- public FileForStorable(final File file, final int pageSize,
- final int maxPage, final int maxRetry, final int retryMsDelay)
- throws HeapException {
- super(file, pageSize, maxPage, maxRetry, retryMsDelay);
- }
-
- /**
- * create a file to read from and write to {@link IFileStorable} object<br>
- * file management use read/write cache<br>
- *
- * @param file
- * the file to use for object storing
- * @param pageSize
- * page size ( number of byte ), must be greater or equals to
- * 1024
- * @param maxPage
- * maximum number of page for read cache
- * @param haveReadCache
- * true if have read cache
- * @param maxRetry
- * @param retryMsDelay
- * @throws HeapException
- */
- public FileForStorable(final File file, final int pageSize,
- final int maxPage, final boolean haveReadCache, final int maxRetry,
- final int retryMsDelay) {
- super(file, pageSize, maxPage, haveReadCache, maxRetry, retryMsDelay);
- }
-
- /**
- * create a file to read from and write to {@link IFileStorable} object<br>
- * file management use read/write cache<br>
- *
- * @param fileName
- * the file name of file to use for object storing
- * @param pageSize
- * page size ( number of byte ), must be greater or equals to
- * 1024
- * @param maxPage
- * maximum number of page for read cache
- * @param maxRetry
- * @param retryMsDelay
- * @throws HeapException
- */
- public FileForStorable(final String fileName, final int pageSize,
- final int maxPage, final int maxRetry, final int retryMsDelay)
- throws HeapException {
- super(fileName, pageSize, maxPage, maxRetry, retryMsDelay);
- }
-
- /**
- * copy this file to an other file
- *
- * @param fileForStorable
- * @throws HeapException
- */
- public void copy(final FileForStorable fileForStorable)
- throws HeapException {
- try {
- randomAccessFile.copy(fileForStorable.getFile().getAbsolutePath());
- } catch (FileIOException exception) {
- throw new HeapException(exception);
- }
- }
-
- @Override
- public void write(final ToBackupRecord toBackupRecord) throws HeapException {
- try {
- randomAccessFile.seek(toBackupRecord.getPositionInFile());
- randomAccessFile.write(toBackupRecord.getData());
- } catch (FileIOException exception) {
- throw new HeapException(exception);
- }
- }
-}
Copied: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/FileForStorable.java (from rev 2999, trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/AbstractFileFor.java)
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/FileForStorable.java (rev 0)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/FileForStorable.java 2012-04-17 04:52:03 UTC (rev 3010)
@@ -0,0 +1,387 @@
+/*
+ * 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.heapfile.service;
+
+import java.io.File;
+
+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.IFileStorable;
+import net.sf.joafip.heapfile.record.entity.ToBackupRecord;
+import net.sf.joafip.kvstore.service.HeapException;
+import net.sf.joafip.logger.JoafipLogger;
+
+/**
+ * to read/write class implementing {@link IFileStorable} to/from file.<br>
+ * {@link #open()} and {@link #close()}<br>
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public class FileForStorable implements IFileForStorable {
+
+ private static final String FILE_IS_OPENED = "file is opened";
+
+ protected final JoafipLogger logger = JoafipLogger.getLogger(getClass());// NOPMD
+
+ protected static final String FILE_ALREADY_CLOSED = "file already closed";
+
+ protected static final String FILE_NOT_OPENNED = "file not opened";
+
+ private static final String FILE_ALREADY_OPENED = "file already opened";
+
+ protected static final String FAILED_DELETE_FILE = "failed delete file ";
+
+ /** the file object for file heap */
+ private final File file;
+
+ /** for random read write file access */
+ protected IRandomAccessFile randomAccessFile;
+
+ /** true if file opened */
+ private boolean opened = false;
+
+ private Exception opennerTrace;
+
+ private Exception closerTrace = new Exception("closer trace");
+
+ /**
+ * create a file to read from and write to {@link IFileStorable} object.<br>
+ * no cache used for file management<br>
+ *
+ * @param fileName
+ * the file name of file to use for storing storable object
+ * @param maxRetry
+ * @param retryMsDelay
+ * @throws HeapException
+ * if an I/O error occurs while opening the file
+ */
+ public FileForStorable(final String fileName, final int maxRetry,
+ final int retryMsDelay) throws HeapException {
+ this(fileName == null ? null : new File(fileName), maxRetry,
+ retryMsDelay);
+ }
+
+ /**
+ * create a file to read from and write to {@link IFileStorable} object<br>
+ * no cache used for file management<br>
+ *
+ * @param file
+ * the file to use for storable object storing
+ * @param maxRetry
+ * @param retryMsDelay
+ * @throws HeapException
+ * if an I/O error occurs while opening the file
+ */
+ public FileForStorable(final File file, final int maxRetry,
+ final int retryMsDelay) throws HeapException {
+ this.file = file;
+ randomAccessFile = new RandomAccessFileDirectNio(file, maxRetry,
+ retryMsDelay);
+ }
+
+ /**
+ * create a file to read from and write to {@link IFileStorable} object<br>
+ * file management use read/write cache<br>
+ *
+ * @param fileName
+ * the file name of file to use for object storing
+ * @param pageSize
+ * page size ( number of byte ), must be greater or equals to
+ * 1024
+ * @param maxPage
+ * maximum number of page for read cache
+ * @param maxRetry
+ * @param retryMsDelay
+ * @throws HeapException
+ */
+ public FileForStorable(final String fileName, final int pageSize,
+ final int maxPage, final int maxRetry, final int retryMsDelay)
+ throws HeapException {
+ this(fileName == null ? null : new File(fileName), pageSize, maxPage,
+ maxRetry, retryMsDelay);
+ }
+
+ /**
+ * create a file to read from and write to {@link IFileStorable} object<br>
+ *
+ * @param file
+ * the file to use for storable object storing
+ * @param pageSize
+ * page size ( number of byte ), must be greater or equals to
+ * 1024
+ * @param maxPage
+ * maximum number of page for read cache
+ * @param maxRetry
+ * @param retryMsDelay
+ * @throws HeapException
+ */
+ public FileForStorable(final File file, final int pageSize,
+ final int maxPage, final int maxRetry, final int retryMsDelay)
+ throws HeapException {
+ this.file = file;
+ final RandomAccessFileDirectNio randomAccessFileDirect =
+ /**/new RandomAccessFileDirectNio(file, maxRetry, retryMsDelay);
+ randomAccessFile = new RandomAccessFileReadWriteCache(
+ randomAccessFileDirect, pageSize, maxPage, maxRetry,
+ retryMsDelay);
+ }
+
+ /**
+ * create a file to read from and write to {@link IFileStorable} object<br>
+ * file management use read/write cache<br>
+ *
+ * @param file
+ * the file to use for storable object storing
+ * @param pageSize
+ * page size ( number of byte ), must be greater or equals to
+ * 1024
+ * @param maxPage
+ * maximum number of page for read cache
+ * @param haveReadCache
+ * true if have read cache
+ * @param maxRetry
+ * @param retryMsDelay
+ * @throws HeapException
+ */
+ public FileForStorable(final File file, final int pageSize,
+ final int maxPage, final boolean haveReadCache, final int maxRetry,
+ final int retryMsDelay) {
+ this.file = file;
+ final RandomAccessFileDirectNio randomAccessFileDirect =
+ /**/new RandomAccessFileDirectNio(file, maxRetry, retryMsDelay);
+ randomAccessFile = new RandomAccessFileReadWriteCache(
+ randomAccessFileDirect, pageSize, maxPage, haveReadCache);
+ }
+
+ @Override
+ public void open() throws HeapException {
+ if (opened) {
+ throw new HeapException(FILE_ALREADY_OPENED, opennerTrace);
+ } else {
+ try {
+ randomAccessFile.open();
+ } catch (FileIOException exception) {
+ throw new HeapException(exception);
+ }
+ opened = true;
+ opennerTrace = new Exception("openner trace");
+ }
+ }
+
+ @Override
+ public void close() throws HeapException {
+ if (opened) {
+ opened = false;
+ closerTrace = new Exception("closer trace");
+ try {
+ randomAccessFile.close();
+ } catch (FileIOException e) {
+ throw new HeapException(e);
+ }
+ } else {
+ throw new HeapException(FILE_ALREADY_CLOSED, closerTrace);
+ }
+ }
+
+ @Override
+ public void flush() throws HeapException {
+ assertOpened();
+ try {
+ randomAccessFile.flush();
+ } catch (FileIOException e) {
+ throw new HeapException(e);
+ }
+ }
+
+ @Override
+ public void resetFileSize() throws HeapException {
+ assertOpened();
+ try {
+ randomAccessFile.setLength(0);
+ } catch (FileIOException e) {
+ throw closeAfterIOException(e);
+ }
+ }
+
+ @Override
+ public void deleteFileIfExists() throws HeapException {
+ if (opened) {
+ throw new HeapException(FILE_IS_OPENED);
+ }
+ if (logger.debugEnabled) {
+ logger.debug("delete " + file);
+ }
+ try {
+ randomAccessFile.deleteIfExists();
+ } catch (FileIOException exception) {
+ throw new HeapException(FAILED_DELETE_FILE + file, exception);
+ }
+ }
+
+ @Override
+ public void deleteFileIfExistsRenaming() throws HeapException {
+ if (opened) {
+ throw new HeapException(FILE_IS_OPENED);
+ }
+ if (logger.debugEnabled) {
+ logger.debug("delete " + file);
+ }
+ try {
+ randomAccessFile.deleteIfExistsRenaming();
+ } catch (FileIOException exception) {
+ throw new HeapException(FAILED_DELETE_FILE + file, exception);
+ }
+ }
+
+ /**
+ * @throws HeapException
+ *
+ */
+ private void assertOpened() throws HeapException {
+ if (!opened) {
+ throw new HeapException(FILE_NOT_OPENNED, closerTrace);
+ }
+ }
+
+ public boolean isOpened() {
+ return opened;
+ }
+
+ @Override
+ public void seek(final long positionInFile) throws HeapException {
+ assertOpened();
+ try {
+ randomAccessFile.seek(positionInFile);
+ } catch (FileIOException e) {
+ throw closeAfterIOException(e);
+ }
+ }
+
+ @Override
+ public int read(final byte[] data) throws HeapException {
+ assertOpened();
+ try {
+ return randomAccessFile.read(data);// NOPMD
+ } catch (FileIOException e) {
+ throw closeAfterIOException(e);
+ }
+ }
+
+ @Override
+ public void write(final byte[] data) throws HeapException {
+ assertOpened();
+ try {
+ randomAccessFile.write(data);
+ } catch (FileIOException e) {
+ throw closeAfterIOException(e);
+ }
+ }
+
+ @Override
+ public void write(final ToBackupRecord toBackupRecord) throws HeapException {
+ try {
+ randomAccessFile.seek(toBackupRecord.getPositionInFile());
+ randomAccessFile.write(toBackupRecord.getData());
+ } catch (FileIOException exception) {
+ throw new HeapException(exception);
+ }
+ }
+
+ @Override
+ public File getFile() {
+ return file;
+ }
+
+ @Override
+ public long getFileSize() throws HeapException {
+ long size;
+ assertOpened();
+ try {
+ size = randomAccessFile.length();
+ } catch (FileIOException e) {
+ throw closeAfterIOException(e);
+ }
+ return size;
+ }
+
+ /**
+ * set the size of this file
+ *
+ * @param newSize
+ * the file new size
+ * @throws HeapException
+ * if an I/O error occurs.
+ */
+ public void setFileSize(final long newSize) throws HeapException {
+ assertOpened();
+ try {
+ randomAccessFile.setLength(newSize);
+ } catch (FileIOException e) {
+ throw closeAfterIOException(e);
+ }
+ }
+
+ /**
+ * copy this file to an other file
+ *
+ * @param fileForStorable
+ * @throws HeapException
+ */
+ public void copy(final FileForStorable fileForStorable)
+ throws HeapException {
+ try {
+ randomAccessFile.copy(fileForStorable.getFile().getAbsolutePath());
+ } catch (FileIOException exception) {
+ throw new HeapException(exception);
+ }
+ }
+
+ /**
+ * close after io exception
+ */
+ protected HeapException closeAfterIOException(
+ final FileIOException exception) throws HeapException {
+ final HeapException fileForStorageException =
+ /**/new HeapException(exception);
+ try {
+ close();
+ } catch (HeapException exception2) {
+ logger.warn("closing after exception", exception2);
+ }
+ return fileForStorageException;
+ }
+
+ public void copy(final String fileName) throws FileIOException {
+ randomAccessFile.copy(fileName);
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder();
+ builder.append("AbstractFileFor [file=");
+ builder.append(file);
+ builder.append(", opened=");
+ builder.append(opened);
+ builder.append("]");
+ return builder.toString();
+ }
+}
Modified: 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 2012-04-16 03:07:06 UTC (rev 3009)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/AbstractTestHeapDataManagerImpl.java 2012-04-17 04:52:03 UTC (rev 3010)
@@ -617,10 +617,10 @@
heapDataManager.flush();
identifier = heapDataManager.removeFirstDataRecord();
assertNotNull("must deleted first data record", identifier);
- assertEquals(BAD_VALUE,0L, identifier.value);
+ assertEquals(BAD_VALUE, 0L, identifier.value);
identifier = heapDataManager.removeFirstDataRecord();
assertNotNull("must deleted first data record", identifier);
- assertEquals(BAD_VALUE,1L, identifier.value);
+ assertEquals(BAD_VALUE, 1L, identifier.value);
assertNull(MUST_NOT_HAVE_DATA_RECORD,
heapDataManager.removeFirstDataRecord());
}
Modified: 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 2012-04-16 03:07:06 UTC (rev 3009)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/DualWrapDataManager.java 2012-04-17 04:52:03 UTC (rev 3010)
@@ -373,7 +373,8 @@
@Override
public void setDataRecordKeyComparator(
- final IDataRecordKeyManager dataRecordKeyComparator) throws HeapException {
+ final IDataRecordKeyManager dataRecordKeyComparator)
+ throws HeapException {
firstDataManager.setDataRecordKeyComparator(dataRecordKeyComparator);
secondDataManager.setDataRecordKeyComparator(dataRecordKeyComparator);
}
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithKey.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/TestHeapFileDataMgrWithKey.java 2012-04-16 03:07:06 UTC (rev 3009)
+++...
[truncated message content] |
|
From: <luc...@us...> - 2012-04-17 19:01:44
|
Revision: 3014
http://joafip.svn.sourceforge.net/joafip/?rev=3014&view=rev
Author: luc_peuvrier
Date: 2012-04-17 19:01:37 +0000 (Tue, 17 Apr 2012)
Log Message:
-----------
dead code removed
Modified Paths:
--------------
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/service/HeapElementManager.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/IHeapElementManager.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapElementManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapRecordManage.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestStoreRestore.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/FileDataManagerIntegrityChecker.java
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 2012-04-17 06:44:59 UTC (rev 3013)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/HeapRecord.java 2012-04-17 19:01:37 UTC (rev 3014)
@@ -129,8 +129,6 @@
private HeapFreeNode freeNode;
- private int readSession = -1;
-
/** the area size in file ( record header size + data size ) */
private Integer areaSize;
@@ -620,13 +618,11 @@
// ASSERTX
assert !freeRecord : "is free record";
updateIdNodeData();
- final int currentReadSession = heapElementManager.getReadSession();
- if (idNode == null || readSession != currentReadSession) {
+ if (idNode == null) {
idNode = new HeapIdNode(heapElementManager, positionInFile,
parentPositionInFile, leftPositionInFile,
rightPositionInFile, colorSetted, color, numberOfChild,
nodeIdentifier);
- readSession = currentReadSession;
}
return idNode;
}
@@ -635,13 +631,11 @@
// ASSERTX
assert freeRecord : "is data record";
updateFreeNodeData();
- final int currentReadSession = heapElementManager.getReadSession();
- if (freeNode == null || readSession != currentReadSession) {
+ if (freeNode == null) {
freeNode = new HeapFreeNode(heapElementManager, positionInFile,
parentPositionInFile, leftPositionInFile,
rightPositionInFile, colorSetted, color, numberOfChild,
areaSize);
- readSession = currentReadSession;
}
return freeNode;
}
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/HeapElementManager.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/HeapElementManager.java 2012-04-17 06:44:59 UTC (rev 3013)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/HeapElementManager.java 2012-04-17 19:01:37 UTC (rev 3014)
@@ -210,8 +210,6 @@
private final boolean fileOpenedInTransaction;
- private int readSession;
-
private final boolean deleteRenamig;
private final boolean clearResizeFile;
@@ -573,7 +571,7 @@
stopperTrace = new Exception("stopper trace");
serviceStarted = false;
if (!fileOpenedInTransaction) {
- closeFile();
+ closeFiles();
}
}
@@ -628,7 +626,7 @@
header.writeToFile();
flushOnFile();
if (fileOpenedInTransaction) {
- closeFile();
+ closeFiles();
openFile();
}
} else {
@@ -691,25 +689,6 @@
}
@Override
- public void clearNotToWrite() throws HeapException {
- // was for debug assert
- // for (HeapRecord heapRecord : readHeapRecordMap.values()) {
- // // if (heapRecord.isValueChangedToSave()) {
- // // throw new HeapRuntimeException("must not be in read cache");
- // // }
- // }
-
- // FIXMELUC x this increase execution time
- // readHeapRecordMap.clear();
- // readSession++;
- }
-
- @Override
- public int getReadSession() {
- return readSession;
- }
-
- @Override
public void closeTransaction() throws HeapException {
// ASSERTX
assert assertTransactionOpened();
@@ -735,7 +714,7 @@
flushOnFile();
}
if (fileOpenedInTransaction) {
- closeFile();
+ closeFiles();
}
openedTransaction = false;
}
@@ -747,7 +726,7 @@
clearHeaprecordToWriteMap();
readHeapRecordMap.clear();
if (fileOpenedInTransaction) {
- closeFile();
+ closeFiles();
}
openedTransaction = false;
}
@@ -756,7 +735,7 @@
heapRecordToWriteMap.clear();
}
- private void closeFile() throws HeapException {
+ private void closeFiles() throws HeapException {
try {
if (openFileTraceFile != null && !openFileTraceFile.delete()) {
LOGGER.error("while deleting open file trace");
@@ -1151,6 +1130,17 @@
return readHeapRecordMap.size() + heapRecordToWriteMap.size();
}
+ @Override
+ public void setDataRecordKeyManager(
+ final IDataRecordKeyManager dataRecordKeyManager) {
+ this.dataRecordKeyManager = dataRecordKeyManager;
+ }
+
+ @Override
+ public IDataRecordKeyManager getDataRecordKeyManager() {
+ return dataRecordKeyManager;
+ }
+
/**
* FOR TEST ONLY<br>
*
@@ -1174,15 +1164,4 @@
public HeapRecord getHeapFileRecordInWriteCache(final long positionInFile) {
return heapRecordToWriteMap.get(positionInFile);
}
-
- @Override
- public void setDataRecordKeyManager(
- final IDataRecordKeyManager dataRecordKeyManager) {
- this.dataRecordKeyManager = dataRecordKeyManager;
- }
-
- @Override
- public IDataRecordKeyManager getDataRecordKeyManager() {
- return dataRecordKeyManager;
- }
}
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/IHeapElementManager.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/IHeapElementManager.java 2012-04-17 06:44:59 UTC (rev 3013)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/IHeapElementManager.java 2012-04-17 19:01:37 UTC (rev 3014)
@@ -105,15 +105,6 @@
void closeTransaction() throws HeapException;
/**
- * clear from memory not to write record (the read heap record cache)
- *
- * @throws HeapException
- */
- void clearNotToWrite() throws HeapException;
-
- int getReadSession();
-
- /**
* close the heap file transaction management without commit modification in
* file
*
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 2012-04-17 06:44:59 UTC (rev 3013)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java 2012-04-17 19:01:37 UTC (rev 3014)
@@ -268,7 +268,6 @@
logger.debug("create heap record #" + dataRecordIdentifier
+ FOR_DATA_SIZE + data.length);
}
- heapElementManager.clearNotToWrite();
return created;
}
@@ -348,7 +347,6 @@
deleteDataRecord(heapIdNode);
deleted = true;
}
- heapElementManager.clearNotToWrite();
return deleted;
}
@@ -677,7 +675,6 @@
} else {
dataAssociated = heapRecord.getDataAssociated();
}
- heapElementManager.clearNotToWrite();
return dataAssociated;
}
@@ -825,7 +822,6 @@
final DataRecordIdentifier dataRecordIdentifier)
throws HeapException {
final boolean haveDataRecord = idNodeSearchMayBeNotExist(dataRecordIdentifier) != null;
- heapElementManager.clearNotToWrite();
return haveDataRecord;
}
@@ -1020,11 +1016,6 @@
@Override
protected void closeHeapManagerAfterException() {
try {
- heapElementManager.clearNotToWrite();
- } catch (Exception exception) {
- logger.warn("closing after exception", exception);
- }
- try {
if (heapElementManager.isTransactionOpened()) {
heapElementManager.closeTransactionDiscardChange();
}
@@ -1067,7 +1058,6 @@
} catch (RBTException exception) {
throw new HeapException(exception);
}
- heapElementManager.clearNotToWrite();
return numberOfDataRecord;
}
@@ -1079,7 +1069,6 @@
} catch (RBTException exception) {
throw new HeapException(exception);
}
- heapElementManager.clearNotToWrite();
return numberOfFreeRecord;
}
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapElementManager.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapElementManager.java 2012-04-17 06:44:59 UTC (rev 3013)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapElementManager.java 2012-04-17 19:01:37 UTC (rev 3014)
@@ -128,7 +128,6 @@
heapElementManager.startService();
heapElementManager.openTransaction();
getHeapHeaderAndCheckPosition(heapHeader1);
- heapElementManager.clearNotToWrite();
heapElementManager.closeTransaction();
heapElementManager.stopService();
}
@@ -158,7 +157,6 @@
// heapElementManager, heapRecord).getPositionInFile());
heapHeader2.setIdRootNodeFilePosition(heapRecord.getPositionInFile());
/* write modifications */
- heapElementManager.clearNotToWrite();
heapElementManager.closeTransaction();
/* read the last modification */
@@ -174,7 +172,6 @@
+ HeapHeader.HEAP_HEADER_SIZE, HeapHeader.HEAP_HEADER_SIZE,
heapHeader3.getIdRootNodeFilePosition());
- heapElementManager.clearNotToWrite();
heapElementManager.closeTransaction();
heapElementManager.stopService();
}
@@ -221,7 +218,6 @@
assertEquals("read must be equals appened", heapRecordAppened2,
heapRecord2);
- heapElementManager.clearNotToWrite();
heapElementManager.closeTransaction();
heapElementManager.stopService();
}
@@ -238,7 +234,6 @@
data1[index] = (byte) (data1.length - index);
}
heapRecord1.setDataAssociated(data1);
- heapElementManager.clearNotToWrite();
heapElementManager.closeTransaction();
heapElementManager.openTransaction();
@@ -247,7 +242,6 @@
for (int index = 0; index < data1.length; index++) {
assertEquals("bad record data", data1.length - index, data1[index]);
}
- heapElementManager.clearNotToWrite();
heapElementManager.closeTransaction();
heapElementManager.stopService();
@@ -283,7 +277,6 @@
node.setColor(!color);
assertTrue("value must have changed",
heapRecord1.isValueChangedToSave());
- heapElementManager.clearNotToWrite();
heapElementManager.closeTransaction();
heapElementManager.openTransaction();
@@ -291,7 +284,6 @@
node = heapRecord1.getIdNode();
assertEquals("color must have changed", !color, node.getColor());
assertFalse("not modified record", heapRecord1.isValueChangedToSave());
- heapElementManager.clearNotToWrite();
heapElementManager.closeTransaction();
heapElementManager.openTransaction();
@@ -315,14 +307,12 @@
color = true;
}
node.setColor(!color);
- heapElementManager.clearNotToWrite();
heapElementManager.closeTransaction();
heapElementManager.openTransaction();
heapRecord1 = heapElementManager.readHeapFileDataRecord(pos);
node = heapRecord1.getFreeNode();
assertEquals("color must have changed", !color, node.getColor());
- heapElementManager.clearNotToWrite();
heapElementManager.closeTransaction();
heapElementManager.stopService();
}
@@ -353,7 +343,6 @@
// heapRecord1.createDataArea();
- heapElementManager.clearNotToWrite();
heapElementManager.closeTransaction();
heapElementManager.openTransaction();
@@ -370,7 +359,6 @@
assertNotNull("must be in cache",
heapElementManager.getHeapFileRecordInReadCache(pos));
- heapElementManager.clearNotToWrite();
heapElementManager.closeTransaction();
heapElementManager.stopService();
}
@@ -394,7 +382,6 @@
// .isValueChangedToSave());
assertFalse("created header must be saved",
heapHeader1.isValueChangedToSave());
- heapElementManager.clearNotToWrite();
heapElementManager.closeTransaction();
heapElementManager.stopService();
assertFalse("saving implies no more value changed",
@@ -439,7 +426,6 @@
}
heapRecordAppened1.setDataAssociated(testData);
- heapElementManager.clearNotToWrite();
heapElementManager.closeTransaction();
logger.debug("appened heap record1\n" + heapRecordAppened1.toString());
@@ -453,7 +439,6 @@
* crc32
*/);
heapRecordAppened2.setDataAssociated(testData);
- heapElementManager.clearNotToWrite();
heapElementManager.closeTransaction();
heapElementManager.stopService();
logger.debug("appened heap record2\n" + heapRecordAppened2.toString());
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapRecordManage.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapRecordManage.java 2012-04-17 06:44:59 UTC (rev 3013)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapRecordManage.java 2012-04-17 19:01:37 UTC (rev 3014)
@@ -164,7 +164,6 @@
previousPosition = position;
final HeapIdNode node = (HeapIdNode) heapRecord.getIdNode();
idNodeTree.append(node);
- heapElementManager.clearNotToWrite();
heapElementManager.closeTransaction();
heapElementManager.openTransaction();
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestStoreRestore.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestStoreRestore.java 2012-04-17 06:44:59 UTC (rev 3013)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestStoreRestore.java 2012-04-17 19:01:37 UTC (rev 3014)
@@ -232,16 +232,6 @@
}
@Override
- public void clearNotToWrite() {
- // do nothing
- }
-
- @Override
- public int getReadSession() {
- return 0;
- }
-
- @Override
public void closeTransaction() throws HeapException {// NOPMD do nothing
}
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/FileDataManagerIntegrityChecker.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/FileDataManagerIntegrityChecker.java 2012-04-17 06:44:59 UTC (rev 3013)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/FileDataManagerIntegrityChecker.java 2012-04-17 19:01:37 UTC (rev 3014)
@@ -125,7 +125,6 @@
checkTotalNumberOfRecord(freeRecordCount, dataRecordCount);
}
- heapElementManager.clearNotToWrite();
}
private void checkFreeNodeInTree(final HeapRecord heapRecord)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-04-17 19:01:44
|
Revision: 3014
http://joafip.svn.sourceforge.net/joafip/?rev=3014&view=rev
Author: luc_peuvrier
Date: 2012-04-17 19:01:37 +0000 (Tue, 17 Apr 2012)
Log Message:
-----------
dead code removed
Modified Paths:
--------------
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/service/HeapElementManager.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/service/IHeapElementManager.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapElementManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapRecordManage.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestStoreRestore.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/FileDataManagerIntegrityChecker.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-11-22 06:54:30
|
Revision: 3158
http://joafip.svn.sourceforge.net/joafip/?rev=3158&view=rev
Author: luc_peuvrier
Date: 2012-11-22 06:54:24 +0000 (Thu, 22 Nov 2012)
Log Message:
-----------
foreground garbage changed
Modified Paths:
--------------
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileCheckerDataManager.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 2012-11-22 06:54:14 UTC (rev 3157)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java 2012-11-22 06:54:24 UTC (rev 3158)
@@ -145,11 +145,14 @@
}
@Override
- protected void stopServiceImpl() throws HeapException {
+ protected void stopServiceImpl(final boolean removeFiles) throws HeapException {
if (heapElementManager.isTransactionOpened()) {
heapElementManager.closeTransactionDiscardChange();
}
heapElementManager.stopService();
+ if( removeFiles) {
+ heapElementManager.removeFiles();
+ }
}
@Override
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 2012-11-22 06:54:14 UTC (rev 3157)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileCheckerDataManager.java 2012-11-22 06:54:24 UTC (rev 3158)
@@ -61,6 +61,12 @@
}
@Override
+ public void stopService(final boolean removeFiles) throws HeapException {
+ heapFileDataManager.stopService(removeFiles);
+ heapMultiFileDataManager.stopService(removeFiles);
+ }
+
+ @Override
public void clear() throws HeapException {
heapFileDataManager.clear();
heapMultiFileDataManager.clear();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-11-22 06:54:30
|
Revision: 3158
http://joafip.svn.sourceforge.net/joafip/?rev=3158&view=rev
Author: luc_peuvrier
Date: 2012-11-22 06:54:24 +0000 (Thu, 22 Nov 2012)
Log Message:
-----------
foreground garbage changed
Modified Paths:
--------------
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileCheckerDataManager.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-11-28 12:15:53
|
Revision: 3165
http://joafip.svn.sourceforge.net/joafip/?rev=3165&view=rev
Author: luc_peuvrier
Date: 2012-11-28 12:15:42 +0000 (Wed, 28 Nov 2012)
Log Message:
-----------
red black tree management changed. foreground garbage sweep changed
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
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/AutoSaveHeapFileDataManager.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapElementManagerWithHeapRecord.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapRecordStoreRestore.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileCheckerDataManager.java
Added Paths:
-----------
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/DataRecordIterator.java
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <luc...@us...> - 2012-11-28 12:15:54
|
Revision: 3165
http://joafip.svn.sourceforge.net/joafip/?rev=3165&view=rev
Author: luc_peuvrier
Date: 2012-11-28 12:15:42 +0000 (Wed, 28 Nov 2012)
Log Message:
-----------
red black tree management changed. foreground garbage sweep changed
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
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/AutoSaveHeapFileDataManager.java
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapElementManagerWithHeapRecord.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapRecordStoreRestore.java
trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileCheckerDataManager.java
Added Paths:
-----------
trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/DataRecordIterator.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 2012-11-28 12:15:18 UTC (rev 3164)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/AbstractHeapRBTNode.java 2012-11-28 12:15:42 UTC (rev 3165)
@@ -404,7 +404,8 @@
private void checkColorSetted() throws RBTException {
if (!colorSetted) {
- throw new RBTException("color is not setted:\n" + this.toString());
+ throw new RBTException("color is not setted:\n" + getClass() + "\n"
+ + this.toString());
}
}
@@ -516,9 +517,10 @@
@Override
public String toString() {
- return "color=" + color + " pos in file=" + positionInFile + " left="
- + leftPositionInFile + " right=" + rightPositionInFile
- + " parent=" + parentPositionInFile;
+ return "attached " + isAttached() + ", color=" + color
+ + ", pos in file=" + positionInFile + ", left="
+ + leftPositionInFile + ", right=" + rightPositionInFile
+ + ", parent=" + parentPositionInFile;
}
@Override
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 2012-11-28 12:15:18 UTC (rev 3164)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/record/entity/HeapRecord.java 2012-11-28 12:15:42 UTC (rev 3165)
@@ -419,7 +419,7 @@
writeByte((byte) 0x02);
}
} else {
- writeByte((byte) 0x00);
+ throw new HeapException("data record color not set");
}
writeInteger(numberOfChild);
writeLong(nodeIdentifier.value);
@@ -470,7 +470,7 @@
writeByte((byte) 0x02);
}
} else {
- writeByte((byte) 0x00);
+ throw new HeapException("free record color not set");
}
// writeInteger(freeNode.getNumberOfChild());
writeInteger(numberOfChild);
@@ -539,7 +539,8 @@
colorSetted = true;
color = true;
} else {
- colorSetted = false;
+ // colorSetted = false;
+ throw new HeapException("data record color not set");
}
numberOfChild = readInteger();
final long long1 = readLong();
@@ -576,7 +577,8 @@
colorSetted = true;
color = true;
} else {
- colorSetted = false;
+ // colorSetted = false;
+ throw new HeapException("free record color not set");
}
// freeNode.setNumberOfChildUnmarshalling(readInteger());
numberOfChild = readInteger();
Modified: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/AutoSaveHeapFileDataManager.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/AutoSaveHeapFileDataManager.java 2012-11-28 12:15:18 UTC (rev 3164)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/AutoSaveHeapFileDataManager.java 2012-11-28 12:15:42 UTC (rev 3165)
@@ -22,6 +22,7 @@
*/
package net.sf.joafip.heapfile.service;
+import net.sf.joafip.Fortest;
import net.sf.joafip.NotStorableClass;
import net.sf.joafip.kvstore.entity.HeapFileSetup;
import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
@@ -95,6 +96,87 @@
return created;
}
+ @Override
+ public boolean deleteDataRecordImpl(
+ DataRecordIdentifier dataRecordIdentifier) throws HeapException {
+ final boolean result = super.deleteDataRecordImpl(dataRecordIdentifier);
+ checkForSave();
+ return result;
+ }
+
+ @Override
+ protected boolean hasDataRecordImpl(
+ DataRecordIdentifier dataRecordIdentifier) throws HeapException {
+ final boolean result = super.hasDataRecordImpl(dataRecordIdentifier);
+ checkForSave();
+ return result;
+ }
+
+ @Override
+ protected DataRecordIdentifier firstDataRecordIdentifierImpl()
+ throws HeapException {
+ final DataRecordIdentifier result = super.firstDataRecordIdentifierImpl();
+ checkForSave();
+ return result;
+ }
+
+ @Override
+ public DataRecordIdentifier nextDataRecordIdentifierImpl(
+ DataRecordIdentifier dataRecordIdentifier) throws HeapException {
+ final DataRecordIdentifier result = super.nextDataRecordIdentifier(dataRecordIdentifier);
+ checkForSave();
+ return result;
+ }
+
+ @Override
+ protected DataRecordIdentifier lastDataRecordIdentifierImpl()
+ throws HeapException {
+ final DataRecordIdentifier result = super.lastDataRecordIdentifierImpl();
+ checkForSave();
+ return result;
+ }
+
+ @Override
+ protected DataRecordIdentifier lowerDataRecordIdentifierImpl(
+ DataRecordIdentifier identifier) throws HeapException {
+ final DataRecordIdentifier result = super.lowerDataRecordIdentifierImpl(identifier);
+ checkForSave();
+ return result;
+ }
+
+ @Override
+ protected DataRecordIdentifier floorDataRecordIdentifierImpl(
+ DataRecordIdentifier identifier) throws HeapException {
+ final DataRecordIdentifier result = super.floorDataRecordIdentifierImpl(identifier);
+ checkForSave();
+ return result;
+ }
+
+ @Override
+ protected DataRecordIdentifier ceilingDataRecordIdentifierImpl(
+ DataRecordIdentifier identifier) throws HeapException {
+ final DataRecordIdentifier result = super.ceilingDataRecordIdentifierImpl(identifier);
+ checkForSave();
+ return result;
+ }
+
+ @Override
+ protected DataRecordIdentifier higherDataRecordIdentifierImpl(
+ DataRecordIdentifier identifier) throws HeapException {
+ final DataRecordIdentifier result = super.higherDataRecordIdentifierImpl(identifier);
+ checkForSave();
+ return result;
+ }
+
+ @Override
+ @Fortest
+ public long getRecordPositionInfile(DataRecordIdentifier identifier)
+ throws HeapException {
+ final long result = super.getRecordPositionInfile(identifier);
+ checkForSave();
+ return result;
+ }
+
private void checkForSave() throws HeapException {
if (heapElementManager.getNumberOfHeaprecordInMemory() >= maxRecord) {
flushImp();
Added: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/DataRecordIterator.java
===================================================================
--- trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/DataRecordIterator.java (rev 0)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/DataRecordIterator.java 2012-11-28 12:15:42 UTC (rev 3165)
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2012 Luc Peuvrier
+ * All rights reserved.
+ *
+ * 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.Iterator;
+import java.util.NoSuchElementException;
+
+import net.sf.joafip.NotStorableClass;
+import net.sf.joafip.kvstore.record.entity.DataRecordIdentifier;
+import net.sf.joafip.kvstore.service.HeapException;
+import net.sf.joafip.kvstore.service.HeapRuntimeException;
+
+/**
+ *
+ * @author luc peuvrier
+ *
+ */
+@NotStorableClass
+public class DataRecordIterator implements Iterator<DataRecordIdentifier> {
+
+ private final HeapFileDataManager heapFileDataManager;
+
+ private DataRecordIdentifier next;
+
+ private DataRecordIdentifier removable;
+
+ public DataRecordIterator(HeapFileDataManager heapFileDataManager) {
+ super();
+ this.heapFileDataManager=heapFileDataManager;
+ try {
+ next=heapFileDataManager.firstDataRecordIdentifier();
+ } catch (HeapException exception) {
+ throw new HeapRuntimeException(exception);
+ }
+ }
+
+ @Override
+ public boolean hasNext() {
+ return next!=null;
+ }
+
+ @Override
+ public DataRecordIdentifier next() {
+ if( next==null){
+ throw new NoSuchElementException();
+ }
+ final DataRecordIdentifier result = next;
+ try {
+ next=heapFileDataManager.nextDataRecordIdentifier(next);
+ } catch (HeapException exception) {
+ throw new HeapRuntimeException(exception);
+ }
+ removable=result;
+ return result;
+ }
+
+ @Override
+ public void remove() {
+ if( removable==null) {
+ throw new IllegalStateException();
+ }
+ try {
+ heapFileDataManager.deleteDataRecord(removable);
+ } catch (HeapException exception) {
+ throw new HeapRuntimeException(exception);
+ }
+ removable=null;
+ }
+}
Property changes on: trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/DataRecordIterator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
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 2012-11-28 12:15:18 UTC (rev 3164)
+++ trunk/joafip-heapfile/src/main/java/net/sf/joafip/heapfile/service/HeapFileDataManager.java 2012-11-28 12:15:42 UTC (rev 3165)
@@ -145,12 +145,13 @@
}
@Override
- protected void stopServiceImpl(final boolean removeFiles) throws HeapException {
+ protected void stopServiceImpl(final boolean removeFiles)
+ throws HeapException {
if (heapElementManager.isTransactionOpened()) {
heapElementManager.closeTransactionDiscardChange();
}
heapElementManager.stopService();
- if( removeFiles) {
+ if (removeFiles) {
heapElementManager.removeFiles();
}
}
@@ -789,6 +790,35 @@
}
@Override
+ public DataRecordIdentifier nextDataRecordIdentifier(
+ final DataRecordIdentifier dataRecordIdentifier)
+ throws HeapException {
+ final HeapIdNode currentHeapIdNode;
+ try {
+ currentHeapIdNode = (HeapIdNode) idNodeSearchMayBeNotExist(dataRecordIdentifier);
+ } catch (HeapException exception) {
+ final String message = "failed get current node";
+ logger.fatal(message);
+ throw new HeapException(message, exception);
+ }
+ final HeapIdNode nextHeapIdNode;
+ try {
+ nextHeapIdNode = (HeapIdNode) idNodeTree.next(currentHeapIdNode);
+ } catch (RBTException exception) {
+ final String message = "failed get next node";
+ logger.fatal(message);
+ throw new HeapException(message, exception);
+ }
+ final DataRecordIdentifier element;
+ if (nextHeapIdNode == null) {
+ element = null;
+ } else {
+ element = nextHeapIdNode.getElement();
+ }
+ return element;
+ }
+
+ @Override
protected DataRecordIdentifier lastDataRecordIdentifierImpl()
throws HeapException {
try {
@@ -1057,40 +1087,9 @@
return file.getAbsolutePath();
}
- @NotStorableClass
- private class DataRecordIterator implements Iterator<DataRecordIdentifier> {
-
- private final Iterator<IRBTNode<DataRecordIdentifier>> iterator;
-
- public DataRecordIterator() {
- super();
- iterator = idNodeTree.iterator();
- }
-
- @Override
- public boolean hasNext() {
- return iterator.hasNext();
- }
-
- @Override
- public DataRecordIdentifier next() {
- final IRBTNode<DataRecordIdentifier> nextRbtNode = iterator.next();
- try {
- return nextRbtNode.getElement();
- } catch (RBTException exception) {
- throw new RuntimeException(exception);// NOPMD
- }
- }
-
- @Override
- public void remove() {
- iterator.remove();
- }
- }
-
@Override
protected Iterator<DataRecordIdentifier> dataRecordIteratorImpl() {
- return new DataRecordIterator();
+ return new DataRecordIterator(this);
}
@Override
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapElementManagerWithHeapRecord.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapElementManagerWithHeapRecord.java 2012-11-28 12:15:18 UTC (rev 3164)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapElementManagerWithHeapRecord.java 2012-11-28 12:15:42 UTC (rev 3165)
@@ -28,6 +28,7 @@
import net.sf.joafip.kvstore.service.HeapException;
import net.sf.joafip.redblacktree.entity.IRBTNode;
import net.sf.joafip.redblacktree.service.RBTException;
+import net.sf.joafip.redblacktree.service.RedBlackTree;
@NotStorableClass
@DoNotTransform
@@ -136,9 +137,10 @@
* test append done correctly
*
* @throws HeapException
+ * @throws RBTException
*
*/
- public void testAppendRecord() throws HeapException {
+ public void testAppendRecord() throws HeapException, RBTException {
appendRecord();
heapElementManager.startService();
heapElementManager.openTransaction();
@@ -176,7 +178,7 @@
heapElementManager.stopService();
}
- public void testUpdateDataRecord() throws HeapException {
+ public void testUpdateDataRecord() throws HeapException, RBTException {
appendRecord();
final long pos = record1pos;
@@ -271,7 +273,7 @@
heapElementManager.stopService();
}
- public void testChangeManageDataMode() throws HeapException {
+ public void testChangeManageDataMode() throws HeapException, RBTException {
appendRecord();
final long pos = record1pos;
heapElementManager.startService();
@@ -346,8 +348,9 @@
* append two records
*
* @throws HeapException
+ * @throws RBTException
*/
- private void appendRecord() throws HeapException {
+ private void appendRecord() throws HeapException, RBTException {
appendHeaderInEmptyFile();
heapElementManager.startService();
heapElementManager.openTransaction();
@@ -361,6 +364,7 @@
* area size: +
* 4 for crc32
*/);
+
// heapRecordAppened1 = heapElementManager.newHeapFileRecord(record1pos,
// -1L/* prev pos */, dataRecordIdentifier/* id */,
// false/* free */, dataSize, dataSize
@@ -369,6 +373,10 @@
// * 4 for crc32
// */);
heapElementManager.appendHeapFileRecord(heapRecordAppened1);
+
+ IRBTNode<DataRecordIdentifier> idNode = heapRecordAppened1.getIdNode();
+ idNode.setColor(RedBlackTree.BLACK);
+
try {
assert false;
} catch (AssertionError error) {
@@ -405,6 +413,10 @@
// * crc32
// */);
heapElementManager.appendHeapFileRecord(heapRecordAppened2);
+
+ idNode = heapRecordAppened2.getIdNode();
+ idNode.setColor(RedBlackTree.BLACK);
+
heapRecordAppened2.setDataAssociated(testData);
heapElementManager.closeTransaction();
heapElementManager.stopService();
Modified: trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapRecordStoreRestore.java
===================================================================
--- trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapRecordStoreRestore.java 2012-11-28 12:15:18 UTC (rev 3164)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/record/service/TestHeapRecordStoreRestore.java 2012-11-28 12:15:42 UTC (rev 3165)
@@ -106,6 +106,11 @@
heapIdNode.setLeftPositionInFile(2);
heapIdNode.setRightPositionInFile(3);
heapIdNode.setParentPositionInFile(4);
+ try {
+ heapIdNode.setBlack();
+ } catch (Exception exception) {
+ // ignore error
+ }
// byte[] data = heapRecord.getDataAssociated();
final byte[] data = new byte[10];
heapRecord.setDataAssociated(data);
@@ -133,6 +138,11 @@
heapFreeNode.setLeftPositionInFile(91);
heapFreeNode.setRightPositionInFile(92);
heapFreeNode.setParentPositionInFile(93);
+ try {
+ heapFreeNode.setBlack();
+ } catch (Exception exception) {
+ // ignore error
+ }
// to force write
heapRecord.setValueIsChangedValueToSave();
heapRecord.writeToFile();
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 2012-11-28 12:15:18 UTC (rev 3164)
+++ trunk/joafip-heapfile/src/test/java/net/sf/joafip/heapfile/service/HeapFileCheckerDataManager.java 2012-11-28 12:15:42 UTC (rev 3165)
@@ -186,6 +186,19 @@
}
@Override
+ public DataRecordIdentifier nextDataRecordIdentifier(
+ final DataRecordIdentifier dataRecordIdentifier) throws HeapException {
+ final DataRecordIdentifier dr1 = heapFileDataManager
+ .nextDataRecordIdentifier(dataRecordIdentifier);
+ final DataRecordIdentifier dr2 = heapMultiFileDataManager
+ .nextDataRecordIdentifier(dataRecordIdentifier);
+ if (dr1.value != dr2.value) {
+ throw new HeapException(NOT_SAME_DATA_RECORD);
+ }
+ return dr1;
+ }
+
+ @Override
public DataRecordIdentifier lastDataRecordIdentifier() throws HeapException {
final DataRecordIdentifier dr1 = heapFileDataManager
.lastDataRecordIdentifier();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|