We are just starting to use Oak (version 1.6.1) backed by a file store. We have 
two concurrent processes trying to access the data in the file store, each 
process using its own Repository interface. As a simple test case we have the 
following. Process1 has this code (imports omitted to save space):


public class HoldSessionOpen {

    private static String workspace = "default";
    private static String repodir = "\\tmp\\oak-repo";

    public static void main(String[] args) throws Exception {
        FileStore filestore = FileStoreBuilder.fileStoreBuilder(new 
File(repodir)).build();
        try {
            SegmentNodeStore sns = 
SegmentNodeStoreBuilders.builder(filestore).build();
            Repository repository = new Jcr(new Oak(sns)).createRepository();
            SimpleCredentials creds = new SimpleCredentials("admin", 
"admin".toCharArray());
            Session session = repository.login(creds, workspace);
            try {
                System.out.println("Holding session: " + session);
                Node root = session.getRootNode();
                for (int i = 0; i < 100000; i++) {
                    if (root.hasNode("hold")) {
                        Node hold = root.getNode("hold");
                        long count = hold.getProperty("count").getLong();
                        hold.setProperty("count", count + 1);
                        System.out.println("found the hold node, count = " + 
count);
                    } else {
                        System.out.println("creating the hold node");
                        root.addNode("hold").setProperty("count", 1);
                    }
                }
                session.save();
            } finally {
                session.logout();
            }
        } finally {
            filestore.flush();
            filestore.close();
        }
    }
}


and process2 has this code:


public class AccessRepo {

    private static String workspace = "default";
    private static String repodir = "\\tmp\\oak-repo";

    public static void main(String[] args) throws Exception {
        FileStore filestore = FileStoreBuilder.fileStoreBuilder(new 
File(repodir)).build();
        try {
            SegmentNodeStore sns = 
SegmentNodeStoreBuilders.builder(filestore).build();
            Repository repository = new Jcr(new Oak(sns)).createRepository();
            SimpleCredentials creds = new SimpleCredentials("admin", 
"admin".toCharArray());
            Session session = repository.login(creds, workspace);
            try {
                Node root = session.getRootNode();
                if (root.hasNode("hello")) {
                    Node hello = root.getNode("hello");
                    long count = hello.getProperty("count").getLong();
                    hello.setProperty("count", count + 1);
                    System.out.println("found the hello node, count = " + 
count);
                } else {
                    System.out.println("creating the hello node");
                    root.addNode("hello").setProperty("count", 1);
                }
                session.save();
            } finally {
                session.logout();
            }
        } finally {
            filestore.flush();
            filestore.close();
        }
    }
}

If I open up two consoles and start process1 in one and then process2 in the 
other, process2 is blocked until process1 terminates.


The actual use case is that one process is responding to REST requests for data 
in the repository while another process is uploading content to the same 
repository, but we see the same behavior - the process that starts second is 
blocked until the process that starts first completes.


Is there any way to have concurrent access to the same data through two 
repositories?


DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the 
property of Persistent Systems Ltd. It is intended only for the use of the 
individual or entity to which it is addressed. If you are not the intended 
recipient, you are not authorized to read, retain, copy, print, distribute or 
use this message. If you have received this communication in error, please 
notify the sender and delete all copies of this message. Persistent Systems 
Ltd. does not accept any liability for virus infected mails.

Reply via email to