You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ch...@apache.org on 2010/04/22 12:44:28 UTC
svn commit: r936770 -
/camel/trunk/components/camel-hawtdb/src/main/java/org/apache/camel/component/hawtdb/HawtDBFile.java
Author: chirino
Date: Thu Apr 22 10:44:27 2010
New Revision: 936770
URL: http://svn.apache.org/viewvc?rev=936770&view=rev
Log:
- do a pageFile.flush() after every commit garantee that the data is persisted to disk on commit.
- better initialization logic to cope with the case were page file is created but process is killed before the root index is created.
Modified:
camel/trunk/components/camel-hawtdb/src/main/java/org/apache/camel/component/hawtdb/HawtDBFile.java
Modified: camel/trunk/components/camel-hawtdb/src/main/java/org/apache/camel/component/hawtdb/HawtDBFile.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hawtdb/src/main/java/org/apache/camel/component/hawtdb/HawtDBFile.java?rev=936770&r1=936769&r2=936770&view=diff
==============================================================================
--- camel/trunk/components/camel-hawtdb/src/main/java/org/apache/camel/component/hawtdb/HawtDBFile.java (original)
+++ camel/trunk/components/camel-hawtdb/src/main/java/org/apache/camel/component/hawtdb/HawtDBFile.java Thu Apr 22 10:44:27 2010
@@ -68,19 +68,19 @@ public class HawtDBFile extends TxPageFi
LOG.debug("Starting HawtDB using file: " + getFile());
}
- final boolean initialize = !getFile().exists();
open();
pageFile = getTxPageFile();
execute(new Work<Boolean>() {
public Boolean execute(Transaction tx) {
- if (initialize) {
- int page = tx.allocator().alloc(1);
+ int page = tx.allocator().alloc(1);
+ if (page==0) {
// if we just created the file, first allocated page should be 0
- assert page == 0;
ROOT_INDEXES_FACTORY.create(tx, 0);
LOG.info("Aggregation repository data store created using file: " + getFile());
} else {
+ // Was previously created.. so free up the test page
+ tx.allocator().free(page, 1);
Index<String, Integer> indexes = ROOT_INDEXES_FACTORY.open(tx, 0);
LOG.info("Aggregation repository data store loaded using file: " + getFile()
+ " containing " + indexes.size() + " repositories.");
@@ -109,6 +109,7 @@ public class HawtDBFile extends TxPageFi
try {
answer = work.execute(tx);
tx.commit();
+ pageFile.flush();
} catch (RuntimeException e) {
LOG.warn("Error executing work " + work + " will do rollback.", e);
tx.rollback();