[Mulgara-svn] r710 - in trunk: jxdata/iTQL/backup_restore src/jar/content-mbox/java/org/mulgara/content/mbox src/jar/content-mp3/java/org/mulgara/content/mp3 src/jar/content-n3/java/org/mulgara/content/n3 src/jar/content-rdfxml/java/org/mulgara/content/rdfxml src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/writer src/jar/content-rio/java/org/mulgara/content/rio src/jar/resolver/java/org/mulgara/resolver src/jar/resolver-filesystem/java/org/mulgara/resolver/filesystem src/jar/resolver-memory/java/org/mulgara/resolver/memory src/jar/resolver-spi/java/org/mulgara/resolver/spi src/jar/resolver-store/java/org/mulgara/resolver/store src/jar/resolver-xsd/java/org/mulgara/resolver/xsd src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory

andrae at mulgara.org andrae at mulgara.org
Tue Mar 25 09:40:23 UTC 2008


Author: andrae
Date: 2008-03-25 02:40:22 -0700 (Tue, 25 Mar 2008)
New Revision: 710

Added:
   trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/BackupRestoreSession.java
Modified:
   trunk/jxdata/iTQL/backup_restore/test.jxu
   trunk/src/jar/content-mbox/java/org/mulgara/content/mbox/TestResolverSession.java
   trunk/src/jar/content-mp3/java/org/mulgara/content/mp3/TestResolverSession.java
   trunk/src/jar/content-n3/java/org/mulgara/content/n3/TestResolverSession.java
   trunk/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/TestResolverSession.java
   trunk/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/writer/TestResolverSession.java
   trunk/src/jar/content-rio/java/org/mulgara/content/rio/TestResolverSession.java
   trunk/src/jar/resolver-filesystem/java/org/mulgara/resolver/filesystem/TestResolverSession.java
   trunk/src/jar/resolver-memory/java/org/mulgara/resolver/memory/MemoryResolver.java
   trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ResolverSession.java
   trunk/src/jar/resolver-store/java/org/mulgara/resolver/store/StatementStoreResolver.java
   trunk/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/TestResolverSession.java
   trunk/src/jar/resolver/java/org/mulgara/resolver/BackupOperation.java
   trunk/src/jar/resolver/java/org/mulgara/resolver/PersistentResolverSession.java
   trunk/src/jar/resolver/java/org/mulgara/resolver/StringPoolSession.java
   trunk/src/jar/resolver/java/org/mulgara/resolver/TestResolverSession.java
   trunk/src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory/MemoryStringPoolImpl.java
Log:
refs #89

merge -r 699:709 ../../branches/mgr-89-backup

This merge fixes the problem with backup obtaining the wrong phase.

The core of the fix is in BackupOperation, BackupRestoreSession, and
StringPoolSession.

As discussed on the wiki - this bug was related to a failure by BackupOperation
to use the phase provided it by the enclosing transaction, instead bypassing the
transaction and obtaining its own reference to the current-phase.  This is
clearly in error as this is a read-only operation and so should not require
access to this phase - and moreover this bypass also bypassed the write-lock,
meaning the phase was not stable, leading to errors.



Modified: trunk/jxdata/iTQL/backup_restore/test.jxu
===================================================================
--- trunk/jxdata/iTQL/backup_restore/test.jxu	2008-03-25 08:47:54 UTC (rev 709)
+++ trunk/jxdata/iTQL/backup_restore/test.jxu	2008-03-25 09:40:22 UTC (rev 710)
@@ -238,8 +238,6 @@
 <!--  BACKUP 3 - backup and restore the server locally  -->
 <!-- ================================================== -->
 
-<!--
-
   <set name="query" value="backup &lt;@server@&gt; to local &lt;@baseuri@/tmp/server.gz&gt;;"/>
 
   <eval stepClass="org.mulgara.store.jxunit.QueryJX" />
@@ -248,6 +246,7 @@
     <fail>Output failed.  Check badQuery6Result.xml for output.</fail>
   </ifEqual>
 
+<!--
   <set name="query" value="restore &lt;@server@&gt; from local &lt;@baseuri@/tmp/server.gz&gt;;"/>
 
   <eval stepClass="org.mulgara.store.jxunit.QueryJX" />

Modified: trunk/src/jar/content-mbox/java/org/mulgara/content/mbox/TestResolverSession.java
===================================================================
--- trunk/src/jar/content-mbox/java/org/mulgara/content/mbox/TestResolverSession.java	2008-03-25 08:47:54 UTC (rev 709)
+++ trunk/src/jar/content-mbox/java/org/mulgara/content/mbox/TestResolverSession.java	2008-03-25 09:40:22 UTC (rev 710)
@@ -160,8 +160,10 @@
    * @return The factory to allow for creation of SPObjects
    */
   public SPObjectFactory getSPObjectFactory() {
+    throw new UnsupportedOperationException("Not Implemented on test class");
+  }
 
+  public SPObject findSPObject(long gNode) {
     throw new UnsupportedOperationException("Not Implemented on test class");
   }
-
 }

Modified: trunk/src/jar/content-mp3/java/org/mulgara/content/mp3/TestResolverSession.java
===================================================================
--- trunk/src/jar/content-mp3/java/org/mulgara/content/mp3/TestResolverSession.java	2008-03-25 08:47:54 UTC (rev 709)
+++ trunk/src/jar/content-mp3/java/org/mulgara/content/mp3/TestResolverSession.java	2008-03-25 09:40:22 UTC (rev 710)
@@ -160,7 +160,10 @@
    * @return The factory to allow for creation of SPObjects
    */
   public SPObjectFactory getSPObjectFactory() {
+    throw new UnsupportedOperationException("Not Implemented on test class");
+  }
 
+  public SPObject findSPObject(long gNode) {
     throw new UnsupportedOperationException("Not Implemented on test class");
   }
 }

Modified: trunk/src/jar/content-n3/java/org/mulgara/content/n3/TestResolverSession.java
===================================================================
--- trunk/src/jar/content-n3/java/org/mulgara/content/n3/TestResolverSession.java	2008-03-25 08:47:54 UTC (rev 709)
+++ trunk/src/jar/content-n3/java/org/mulgara/content/n3/TestResolverSession.java	2008-03-25 09:40:22 UTC (rev 710)
@@ -144,7 +144,10 @@
    * @return The factory to allow for creation of SPObjects
    */
   public SPObjectFactory getSPObjectFactory() {
+    throw new UnsupportedOperationException("Not Implemented on test class");
+  }
 
+  public SPObject findSPObject(long gNode) {
     throw new UnsupportedOperationException("Not Implemented on test class");
   }
 }

Modified: trunk/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/TestResolverSession.java
===================================================================
--- trunk/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/TestResolverSession.java	2008-03-25 08:47:54 UTC (rev 709)
+++ trunk/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/TestResolverSession.java	2008-03-25 09:40:22 UTC (rev 710)
@@ -144,7 +144,10 @@
    * @return The factory to allow for creation of SPObjects
    */
   public SPObjectFactory getSPObjectFactory() {
+    throw new UnsupportedOperationException("Not Implemented on test class");
+  }
 
+  public SPObject findSPObject(long gNode) {
     throw new UnsupportedOperationException("Not Implemented on test class");
   }
 }

Modified: trunk/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/writer/TestResolverSession.java
===================================================================
--- trunk/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/writer/TestResolverSession.java	2008-03-25 08:47:54 UTC (rev 709)
+++ trunk/src/jar/content-rdfxml/java/org/mulgara/content/rdfxml/writer/TestResolverSession.java	2008-03-25 09:40:22 UTC (rev 710)
@@ -172,7 +172,10 @@
    * @return The factory to allow for creation of SPObjects
    */
   public SPObjectFactory getSPObjectFactory() {
+    throw new UnsupportedOperationException("Not Implemented on test class");
+  }
 
+  public SPObject findSPObject(long gNode) {
     throw new UnsupportedOperationException("Not Implemented on test class");
   }
 }

Modified: trunk/src/jar/content-rio/java/org/mulgara/content/rio/TestResolverSession.java
===================================================================
--- trunk/src/jar/content-rio/java/org/mulgara/content/rio/TestResolverSession.java	2008-03-25 08:47:54 UTC (rev 709)
+++ trunk/src/jar/content-rio/java/org/mulgara/content/rio/TestResolverSession.java	2008-03-25 09:40:22 UTC (rev 710)
@@ -144,7 +144,10 @@
    * @return The factory to allow for creation of SPObjects
    */
   public SPObjectFactory getSPObjectFactory() {
+    throw new UnsupportedOperationException("Not Implemented on test class");
+  }
 
+  public SPObject findSPObject(long gNode) {
     throw new UnsupportedOperationException("Not Implemented on test class");
   }
 }

Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/BackupOperation.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/BackupOperation.java	2008-03-25 08:47:54 UTC (rev 709)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/BackupOperation.java	2008-03-25 09:40:22 UTC (rev 710)
@@ -140,9 +140,7 @@
             new GZIPOutputStream(os), "UTF-8"
         ));
 
-        StringPool stringPool =
-            resolverSessionFactory.getPersistentStringPool();
-        backupDatabase(stringPool, systemResolver, metadata, writer);
+        backupDatabase(systemResolver, metadata, writer);
       }
     } finally {
       // Clean up.
@@ -167,10 +165,8 @@
    * @param writer Writer
    * @throws Exception
    */
-  private void backupDatabase(
-      StringPool stringPool, Resolver resolver,
-      DatabaseMetadata metadata, Writer writer
-  ) throws Exception {
+  private void backupDatabase(SystemResolver systemResolver, DatabaseMetadata metadata, Writer writer)
+      throws Exception {
     // Write the backup
     writer.write(BACKUP_FILE_HEADER + BACKUP_VERSION + '\n');
     writer.write(new Date().toString());
@@ -179,7 +175,7 @@
     // Dump the strings.
     writer.write("RDFNODES\n");
 
-    Tuples t = stringPool.findGNodes(null, null);
+    Tuples t = systemResolver.findStringPoolType(null, null);
     assert t != null;
     try {
       t.beforeFirst();
@@ -188,7 +184,7 @@
         writer.write(Long.toString(localNode));
         writer.write(' ');
 
-        SPObject spObject = stringPool.findSPObject(localNode);
+        SPObject spObject = systemResolver.findSPObject(localNode);
         writer.write(spObject.getEncodedString());
         writer.write('\n');
       }
@@ -197,7 +193,7 @@
     }
 
     // Dump the triples.
-    Tuples tuples = resolver.resolve(new ConstraintImpl(
+    Tuples tuples = systemResolver.resolve(new ConstraintImpl(
         StatementStore.VARIABLES[0],
         StatementStore.VARIABLES[1],
         StatementStore.VARIABLES[2],

Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/PersistentResolverSession.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/PersistentResolverSession.java	2008-03-25 08:47:54 UTC (rev 709)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/PersistentResolverSession.java	2008-03-25 09:40:22 UTC (rev 710)
@@ -144,7 +144,10 @@
    * @return The factory to allow for creation of SPObjects
    */
   public SPObjectFactory getSPObjectFactory() {
-
     return resolverSession.getSPObjectFactory();
   }
+
+  public SPObject findSPObject(long gNode) {
+    throw new UnsupportedOperationException("Not Implemented on test class");
+  }
 }

Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/StringPoolSession.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/StringPoolSession.java	2008-03-25 08:47:54 UTC (rev 709)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/StringPoolSession.java	2008-03-25 09:40:22 UTC (rev 710)
@@ -67,7 +67,7 @@
  *   Technology, Inc</a>
  * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
  */
-public class StringPoolSession implements XAResolverSession
+public class StringPoolSession implements XAResolverSession, BackupRestoreSession
 {
   /** Logger.  */
   private static final Logger logger =
@@ -707,4 +707,17 @@
     return result;
   }
 
+  /**
+   * {@inheritDoc}
+   *
+   * NB: This method does not perform any absolute/relative URI mapping.
+   */
+  public SPObject findSPObject(long gNode) throws StringPoolException {
+    if (gNode < NodePool.MIN_NODE) {
+      throw new IllegalArgumentException("Attempt to resolve temporary gNode in BackupRestoreSession");
+    }
+
+    return persistentStringPool.findSPObject(gNode);
+  }
+
 }

Modified: trunk/src/jar/resolver/java/org/mulgara/resolver/TestResolverSession.java
===================================================================
--- trunk/src/jar/resolver/java/org/mulgara/resolver/TestResolverSession.java	2008-03-25 08:47:54 UTC (rev 709)
+++ trunk/src/jar/resolver/java/org/mulgara/resolver/TestResolverSession.java	2008-03-25 09:40:22 UTC (rev 710)
@@ -167,8 +167,10 @@
    * @return The factory to allow for creation of SPObjects
    */
   public SPObjectFactory getSPObjectFactory() {
+    throw new UnsupportedOperationException("Not Implemented on test class");
+  }
 
+  public SPObject findSPObject(long gNode) {
     throw new UnsupportedOperationException("Not Implemented on test class");
   }
-
 }

Modified: trunk/src/jar/resolver-filesystem/java/org/mulgara/resolver/filesystem/TestResolverSession.java
===================================================================
--- trunk/src/jar/resolver-filesystem/java/org/mulgara/resolver/filesystem/TestResolverSession.java	2008-03-25 08:47:54 UTC (rev 709)
+++ trunk/src/jar/resolver-filesystem/java/org/mulgara/resolver/filesystem/TestResolverSession.java	2008-03-25 09:40:22 UTC (rev 710)
@@ -165,7 +165,10 @@
    * @return The factory to allow for creation of SPObjects
    */
   public SPObjectFactory getSPObjectFactory() {
+    throw new UnsupportedOperationException("Not Implemented on test class");
+  }
 
+  public SPObject findSPObject(long gNode) {
     throw new UnsupportedOperationException("Not Implemented on test class");
   }
 }

Modified: trunk/src/jar/resolver-memory/java/org/mulgara/resolver/memory/MemoryResolver.java
===================================================================
--- trunk/src/jar/resolver-memory/java/org/mulgara/resolver/memory/MemoryResolver.java	2008-03-25 08:47:54 UTC (rev 709)
+++ trunk/src/jar/resolver-memory/java/org/mulgara/resolver/memory/MemoryResolver.java	2008-03-25 09:40:22 UTC (rev 710)
@@ -330,10 +330,13 @@
    * @return The factory to allow for creation of SPObjects
    */
   public SPObjectFactory getSPObjectFactory() {
-
     return resolverSession.getSPObjectFactory();
   }
 
+  public SPObject findSPObject(long gNode) throws StringPoolException {
+    return resolverSession.findSPObject(gNode);
+  }
+
   //
   // Internal methods
   //

Copied: trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/BackupRestoreSession.java (from rev 709, branches/mgr-89-backup/src/jar/resolver-spi/java/org/mulgara/resolver/spi/BackupRestoreSession.java)
===================================================================
--- trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/BackupRestoreSession.java	                        (rev 0)
+++ trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/BackupRestoreSession.java	2008-03-25 09:40:22 UTC (rev 710)
@@ -0,0 +1,49 @@
+
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.rosenlaw.com/OSL3.0.htm
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * This file is an original work developed by Andrae Muys
+ * Copyright (c) 2008 Andrae Muys <andrae at muys.id.au>
+ * All Rights Reserved.
+ */
+package org.mulgara.resolver.spi;
+
+// Third party packages
+
+// Local packages
+import org.mulgara.store.stringpool.SPObject;
+import org.mulgara.store.stringpool.StringPoolException;
+
+/**
+ * An interface to the string-pool required by the Backup and Restore
+ * Operations.
+ *
+ *  Note: This interface is a temporary fix until the model-name deconflation
+ *  work is put in place - at which point this we will hopefully be able to
+ *  rely on the string-pool primitives in ResolverSession.
+ *
+ * @created 2008-03-25
+ * @copyright &copy;2008 <a href="mailto:andrae at muys.id.au">Andrae Muys</a>
+ * @licence Open Software Licence v3.0
+ */
+
+public interface BackupRestoreSession
+{
+  /**
+   * Find a single object in the persistent string pool.
+   *
+   * @param gNode The graph node to find.
+   * @return the SPObject corresponding to <var>gNode</var>, or
+   * <code>null</code> if the node is not in the pool.
+   * @throws StringPoolException if an internal error occurs.
+   */
+  public SPObject findSPObject(long gNode) throws StringPoolException;
+}

Modified: trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ResolverSession.java
===================================================================
--- trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ResolverSession.java	2008-03-25 08:47:54 UTC (rev 709)
+++ trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/ResolverSession.java	2008-03-25 09:40:22 UTC (rev 710)
@@ -61,7 +61,7 @@
  * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
  */
 
-public interface ResolverSession
+public interface ResolverSession extends BackupRestoreSession
 {
   /**
    * Convert session-local node numbers to globally valid RDF nodes.

Modified: trunk/src/jar/resolver-store/java/org/mulgara/resolver/store/StatementStoreResolver.java
===================================================================
--- trunk/src/jar/resolver-store/java/org/mulgara/resolver/store/StatementStoreResolver.java	2008-03-25 08:47:54 UTC (rev 709)
+++ trunk/src/jar/resolver-store/java/org/mulgara/resolver/store/StatementStoreResolver.java	2008-03-25 09:40:22 UTC (rev 710)
@@ -484,7 +484,7 @@
    * @throws StringPoolException
    */
   public SPObject findStringPoolObject(long gNode) throws StringPoolException {
-    return xaResolverSession.findStringPoolObject(gNode);
+    return resolverSession.findStringPoolObject(gNode);
   }
 
   /**
@@ -494,10 +494,13 @@
    * @return The factory to allow for creation of SPObjects
    */
   public SPObjectFactory getSPObjectFactory() {
-
     return resolverSession.getSPObjectFactory();
   }
 
+  public SPObject findSPObject(long gNode) throws StringPoolException {
+    return resolverSession.findSPObject(gNode);
+  }
+
   //
   // Internal methods
   //

Modified: trunk/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/TestResolverSession.java
===================================================================
--- trunk/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/TestResolverSession.java	2008-03-25 08:47:54 UTC (rev 709)
+++ trunk/src/jar/resolver-xsd/java/org/mulgara/resolver/xsd/TestResolverSession.java	2008-03-25 09:40:22 UTC (rev 710)
@@ -183,7 +183,10 @@
    * @return The factory to allow for creation of SPObjects
    */
   public SPObjectFactory getSPObjectFactory() {
-
     return spObjectFactory;
   }
+
+  public SPObject findSPObject(long gNode) {
+    throw new UnsupportedOperationException("Not Implemented on test class");
+  }
 }

Modified: trunk/src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory/MemoryStringPoolImpl.java
===================================================================
--- trunk/src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory/MemoryStringPoolImpl.java	2008-03-25 08:47:54 UTC (rev 709)
+++ trunk/src/jar/store-stringpool-memory/java/org/mulgara/store/stringpool/memory/MemoryStringPoolImpl.java	2008-03-25 09:40:22 UTC (rev 710)
@@ -135,7 +135,6 @@
       smallestSPObjects[s] = new SPLimit(s, true);
       largestSPObjects[s] = new SPLimit(s, false);
     }
-
   }
 
   //
@@ -355,7 +354,10 @@
           "Finding typed literal nodes on the in memory string pool is not supported"
       );
     }
-    SortedSet subset = stringIndex.subSet(smallestSPObjects[typeCategory.ID], largestSPObjects[typeCategory.ID]);
+
+    SortedSet subset = typeCategory != null ?
+        stringIndex.subSet(smallestSPObjects[typeCategory.ID], largestSPObjects[typeCategory.ID]) : stringIndex;
+
     return new SetWrapperTuples(subset);
   }
 




More information about the Mulgara-svn mailing list