ObjectDB ObjectDB

Setting temp directory location in ObjectDB

#1

HI,

I am using ObjectDB and would to change the temp directory location wihtout using objectDB.conf file.

I am using JDO and setting the persistenceManager as follow

properties.setProperty("javax.jdo.PersistenceManagerFactoryClass","com.objectdb.jdo.PMF");

properties.setProperty("javax.jdo.option.ConnectionURL", fileName.odb);

pmf = JDOHelper.getPersistenceManagerFactory(properties), JDOHelper.class.getClassLoader());

I read in the ObjectDB website that we can change the temp directory using the following conf file

<general>
  <temp path="$temp/ObjectDB" threshold="64mb" />
  <network inactivity-timeout="0" />
  <log path="$objectdb/log/" max="8mb" stdout="false" stderr="false" />
  <log-archive path="$objectdb/log/archive/" retain="90" />
  <logger name="*" level="info" />
</general>

But can you please let me know, if i dont want to use the conf file, how can i set the temp directory using my java class  e.g setting through system property or ..... I m using fileName.odb file to store the objects and reading objects from the fileName.odb. When pm.currentTransaction().begin(); hits it creates a .$fileName.obd$ file in the same directory where fileName.odb is located. But i want to set the tempority folder location so that $fileName.obd$ will be created in some different folder. Please let me know the solution.

Thanks

edit
delete
#2

You didn't specify an ObjectDB version, but it seems that you are using an old ObjectDB 1.x version because the recovery file name has a different format in ObjectDB 2.x.

The configuration file in your post is relevant only for ObjectDB 2.x anyway.

In ObjectDB 1.x the recovery file path is calculated using:

    String dirPath = System.getProperty("com.objectdb.recovery.path");
    if (dirPath == null) {
        dirPath = m_dbFile.getParent();
    }
    m_recoveryFile = new File(dirPath, ".$" + m_dbFile.getName() + "$");

So you can change the path by setting the com.objectdb.recovery.path system property.

ObjectDB Support
edit
delete
#3

Thanks for the reply. I am using objectDb 1.x. i am able to set the temp folder path.

When i try to read the odb.file, I see that the parent folder OS timestamp changes, i just want to read the file. Ideally the OS timestamp should not change for the parent folder when the odb file open for read operation only i.e. Date Modified time in the microsoft explorer window

For example, parentfolder/fileName.odb
      Name                                    Date Modiefied
parentfolder                       03/08/2011  10:37

After executing following line the

properties.setProperty("javax.jdo.PersistenceManagerFactoryClass","com.objectdb.jdo.PMF");

properties.setProperty("javax.jdo.option.ConnectionURL", fileName.odb);

pmf = JDOHelper.getPersistenceManagerFactory(properties), JDOHelper.class.getClassLoader());
pmf.setMultithreaded(true);
pmf.setNontransactionalRead(true);
pmf.setNontransactionalWrite(false);

PersistenceManager pm = pmf.getPersistenceManager();

When pmf.getPersistanceManager() line gets executed, the see the OS timestamp of the fodler changes to the current time and a new temprory file is the created in the folder which I have specified through the com.objectdb.recovery.path. I have specified different folder not inside the parent folder.

 

Name                                    Date Modiefied
parentfolder                       03/08/2011  10:42

Please let me know why the OS timestamp is changing for the parent folder. How can i stop the timestamp change for the odb parent folder.

edit
delete
#4

This might be a side effect of the file locking method that is used by ObjectDB 1.x.

Try running ObjectDB in a process with no permission to write to the parent directory.

ObjectDB Support
edit
delete
#5

can you please elaborate what exactly "Try running ObjectDB in a process with no permission to write to the parent directory".

I did not undertand this. How can we achieve this as we specify the connectionURL while giving the fileName.odb path.

properties.setProperty("javax.jdo.option.ConnectionURL", fileName.odb);

In the above case, i dont have file handler so that i can do anything. Can you please let me know how to do this.

And if write permission permission is blocked for the parent folder, won't ObjectDB locking method throw exceptions if it does not get the write permission.

 

edit
delete
#6

> can you please elaborate what exactly "Try running ObjectDB in a process with no permission to write to the parent directory"

It is something to be done outside Java / ObjectDB and it depends on your operating system.

See file system permissions.

> And if write permission permission is blocked for the parent folder, won't ObjectDB locking method throw exceptions if it does not get the write permission.

No. ObjectDB 1.x silently ignores such condition.

ObjectDB Support
edit
delete
#7

Thanks for the reply. As mentioned by you that "This might be a side effect of the file locking method that is used by ObjectDB 1.x". Ideally, for reading the .odb files, the timestamp for the .odb parent file should not be changed. We have a problem in our software because of this. Can you fix this timestamp issue and provide the patch or release information.

Does this problem also exist in ObjectDb 2.x ?

edit
delete
#8

ObjectDB 2.x uses standard Java file locking and should not have this issue (ObjectDB 1.x was released many years ago when Java didn't provide a standard file locking).

ObjectDB 1.x is now towards its end of life and no future patches are planned, so you will have to find a workaround on your side (changing the file permission, additional parent directory level, etc.).

It is recommended to upgrade to ObjectDB 2.x when possible.

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.