The database directory was empty before running the restore with the
tdbloader.bat.
The restore was done without any problem but when i wanted to retrieve the
data with the Jena API (in java) i could'nt because of the NodeReadOnly
exception.
But when i comment the line ds.begin(ReadWrite.READ) i could retrieve the
data.

Here is the code i used to initialize the TDB before querying it in my
application :

TDB.getContext().set(SystemTDB.symFileMode, FileMode.direct);

ARQ.setExecutionLogging(InfoLevel.NONE);
 ARQ.setStrictMode();

// Direct way: Make a TDB-back Jena model in the named directory.
 ds = TDBFactory.createDataset(databasePath);
 ds.begin(ReadWrite.READ); // Comment this line solve the problem but i
need it to use transactions

model = ds.getDefaultModel();

Here the command i use to restore the DB :

SET JENA_HOME=C:\apache-jena-2.10.0
C:\apache-jena-2.10.0\bat\tdbloader.bat -loc C:\TEST_RESTORE C:\BACKUP.rdf


Here how i backup the database (generating the BACKUP.rdf)

 // Check if the specified triplestore directory exists. If not create it.
File directory = new File(databasePath);
 if (!directory.exists()) {
directory.mkdir();
}

TDB.getContext().set(SystemTDB.symFileMode, FileMode.direct);

ARQ.setExecutionLogging(InfoLevel.NONE);
 ARQ.setStrictMode();

// Direct way: Make a TDB-back Jena model in the named directory.
 ds = TDBFactory.createDataset(databasePath);
 ds.begin(ReadWrite.READ);

model = ds.getDefaultModel();
 // Set prefix namespace
 model.setNsPrefix(Measure.PREFIX, Measure.getURI()+"#");

                model.write(new FileOutputStream(new File(fileName)));


By the way i tried to restore the TDB using the API : TDBLoader like this

TDB.getContext().set(SystemTDB.symFileMode, FileMode.direct);

ARQ.setExecutionLogging(InfoLevel.NONE);
ARQ.setStrictMode();

// Direct way: Make a TDB-back Jena model in the named directory.
 Dataset ds = TDBFactory.createDataset("C:/TEST3");
 // Begin write transaction
 ds.begin(ReadWrite.WRITE);

Model model = ds.getDefaultModel();
 TDBLoader.loadModel(model, "C:/BACKUP.rdf");


but i have the following error :

java.lang.AssertionError: <C:/BACKUP.rdf> Code: 11/LOWERCASE_PREFERRED in
SCHEME: lowercase is preferred in this component
at org.junit.Assert.fail(Assert.java:93)
 at com.telemis.core.measure.RdfTest.backupTest(RdfTest.java:183)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
 at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
 at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
 at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
 at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
 at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
 at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
 at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)





2013/7/1 Rob Walpole <robkwalp...@gmail.com>

> Was the database empty before you attempted the restore? If there was old
> data then this should be deleted or moved elsewhere (all .dat, .idn. .opt
> and jrnl files). Also it is important that nothing in the JVM is attempting
> to access the database while the load script is running - or this could
> cause problems.
>
> Are you accessing TDB via Fuseki? If so then this gives you your JVM
> container and backups should be done using the management console - you
> shouldn't do backups from another JVM (like using the Java API) or likewise
> you could have problems.
>
>
> On Mon, Jul 1, 2013 at 3:38 PM, Frederic Toublanc <
> frederic.toubl...@telemis.com> wrote:
>
> > Ok i can restore the export rdf file. But is there a way to specify the
> > tdbloader script to set the TDB as transactional ?
> >
> > Cause when i want to read the data after the restore i have a
> nodeReadOnly
> > error. I'm using transaction to read and write so i guess when i restored
> > it back the TDB wasn't set to support transactions.
> >
> > Any clue ?
> >
> >
> > 2013/7/1 Frederic Toublanc <frederic.toubl...@telemis.com>
> >
> > > Ok i will try that thanks a lot.
> > >
> > >
> > > 2013/7/1 Rob Walpole <robkwalp...@gmail.com>
> > >
> > >> You can use the tdbloader or tdbloader2 script (depending on your OS)
> > >> which
> > >> is found in the /bin directory of your Apache Jena install.
> > >>
> > >> The command you need is something like ./tdbloader2 -loc
> > >> /path-to-tdb-data-dir /path-to-rdf-file
> > >>
> > >>
> > >> On Mon, Jul 1, 2013 at 12:31 PM, Frederic Toublanc <
> > >> frederic.toubl...@telemis.com> wrote:
> > >>
> > >> > Hello everyone,
> > >> >
> > >> > I'm using this code to backup a Jena TDB :
> > >> >
> > >> > FileOutputStream fos = new FileOutputStream(new
> File(backupFilePath));
> > >> >  TDBBackup.backup(new Location(tdbLocation), fos);
> > >> >
> > >> > This generate a backup.rdf file
> > >> >
> > >> > But i really dunno how to restore this backup in a new jena TDB.
> > >> >
> > >>
> > >>
> > >>
> > >> --
> > >>
> > >> Rob Walpole
> > >> Email robkwalp...@gmail.com
> > >> Tel. +44 (0)7969 869881
> > >> Skype: RobertWalpolehttp://www.linkedin.com/in/robwalpole
> > >>
> > >
> > >
> >
>
>
>
> --
>
> Rob Walpole
> Email robkwalp...@gmail.com
> Tel. +44 (0)7969 869881
> Skype: RobertWalpolehttp://www.linkedin.com/in/robwalpole
>

Reply via email to