|
From: <mar...@us...> - 2010-09-01 14:27:53
|
Revision: 3479
http://bigdata.svn.sourceforge.net/bigdata/?rev=3479&view=rev
Author: martyncutcher
Date: 2010-09-01 14:27:44 +0000 (Wed, 01 Sep 2010)
Log Message:
-----------
Support RootBlock reference from CommitRecords
Added Paths:
-----------
branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/RootBlockCommitter.java
Added: branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/RootBlockCommitter.java
===================================================================
--- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/RootBlockCommitter.java (rev 0)
+++ branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/RootBlockCommitter.java 2010-09-01 14:27:44 UTC (rev 3479)
@@ -0,0 +1,61 @@
+/**
+
+Copyright (C) SYSTAP, LLC 2006-2010. All rights reserved.
+
+Contact:
+ SYSTAP, LLC
+ 4501 Tower Road
+ Greensboro, NC 27410
+ lic...@bi...
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; version 2 of the License.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+package com.bigdata.journal;
+
+import java.nio.ByteBuffer;
+
+/**
+ * Provides the callback to save the previous root block and store the address
+ * with the current CommitRecord. This enables access to historical root blocks
+ * since the next CommitRecord is accessible from the CommitRecordIndex. This
+ * is effective if slightly circuitious.
+ *
+ * @author Martyn Cutcher
+ *
+ */
+public class RootBlockCommitter implements ICommitter {
+ final AbstractJournal journal;
+
+ public RootBlockCommitter(AbstractJournal journal) {
+ this.journal = journal;
+ }
+
+ /**
+ * Write the current root block to the Journal and return its address
+ * to be stored in the CommitRecord.
+ */
+ public long handleCommit(long commitTime) {
+ ByteBuffer rbv = journal.getRootBlockView().asReadOnlyBuffer();
+
+ ByteBuffer bb = ByteBuffer.allocate(rbv.capacity());
+ for (int i = 0; i < rbv.capacity(); i++) {
+ bb.put(rbv.get());
+ }
+ bb.flip();
+
+ return journal.write(bb);
+ }
+
+}
Property changes on: branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/RootBlockCommitter.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Id Date Revision Author HeadURL
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|