I think I've tracked down the problem. I've been using the following 
directory structure for my databases:

/Users/me/projects/<uuid>/db

where the <uuid> is different for each database. Orientdb seems to take the 
last part of the path (db) as the unique identifier for the database. So, 
even though I have 4 distinct directories with 4 different databases, 
orient only sees and uses the last one.

If I run this first test program:

import java.util.LinkedList;
import java.util.List;

import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.orient.OrientBaseGraph;
import com.tinkerpop.blueprints.impls.orient.OrientGraph;
import com.tinkerpop.blueprints.impls.orient.OrientGraphFactory;
import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx;

public class OrientTest {
  static class Writer implements Runnable {
    Writer(String url, OrientGraphFactory oGF) {
      this.url = url;
      this.oGF = oGF;
    }
    public void run() {
      OrientGraphNoTx oG = oGF.getNoTx();
      oG.setThreadMode(OrientBaseGraph.THREAD_MODE.ALWAYS_AUTOSET);
      oG.addVertex(null, "url", url);
      oG.shutdown();
    }
    private final String url;
    private final OrientGraphFactory oGF;
  }
  static class Reader implements Runnable {
    Reader(String url, OrientGraphFactory oGF) {
      this.url = url;
      this.oGF = oGF;
    }
    public void run() {
      OrientGraph oG = oGF.getTx();
      oG.setThreadMode(OrientBaseGraph.THREAD_MODE.ALWAYS_AUTOSET);
      Iterable<Vertex> vertices = 
oG.query().has("url",oG.getRawGraph().getURL()).vertices();
      assert(vertices.iterator().hasNext());
      for (Vertex next : vertices) {
        System.out.format("vertex : %s url:%s%n", next, 
next.getProperty("url"));
      }
      oG.shutdown();
    }
    private final String url;
    private final OrientGraphFactory oGF;
  }
  public static void main(String[] args) throws InterruptedException {
    List<OrientGraphNoTx> oGS = new LinkedList<>();
    Thread[] writers = new Thread[10];
    for (int i = 0; i<4; i++) {
      String url = "plocal:/Users/curtis/orientdb/" + uuids[i] + "/db";
      OrientGraphFactory oGF = new OrientGraphFactory(url);
      writers[i] = new Thread(new Writer(url, oGF));
      writers[i].start();
    }
    for (int i=0; i<4; i++) writers[i].join();
    for (int i = 0; i<4; i++) {
      String url = "plocal:/Users/curtis/orientdb/" + uuids[i] + "/db";
      OrientGraphFactory oGF = new OrientGraphFactory(url);
      new Thread(new Reader(url, oGF)).start();
    }
  }
  private static String[] uuids = {
    "91c032a0-5b36-4ebf-bd0f-f0b1fd14cd56",
    "258d6da8-a3cc-4e17-91ec-48449876b78a",
    "2873e704-588b-4e05-bac9-4bdded9f2bfa",
    "bd1b381a-69ff-4dfa-86fe-70212594a1a2"
  };
//   private static String[] uuids = {
//     "dir0",
//     "dir1",
//     "dir2",
//     "dir3"
//   };
}


I get these errors:

Exception in thread "Thread-2" Exception in thread "Thread-1" Exception in 
thread "Thread-0" 
com.orientechnologies.orient.core.exception.ODatabaseException: Cannot 
create database
at 
com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.create(ODatabaseRecordAbstract.java:396)
at 
com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract.create(ODatabaseWrapperAbstract.java:55)
at 
com.orientechnologies.orient.core.db.ODatabaseRecordWrapperAbstract.create(ODatabaseRecordWrapperAbstract.java:64)
at 
com.tinkerpop.blueprints.impls.orient.OrientGraphFactory.getDatabase(OrientGraphFactory.java:137)
at 
com.tinkerpop.blueprints.impls.orient.OrientGraphFactory.getDatabase(OrientGraphFactory.java:118)
at 
com.tinkerpop.blueprints.impls.orient.OrientGraphFactory.getNoTx(OrientGraphFactory.java:101)
at OrientTest$Writer.run(OrientTest.java:23)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.orientechnologies.orient.core.exception.ODatabaseException: 
Cannot create database
at 
com.orientechnologies.orient.core.db.raw.ODatabaseRaw.create(ODatabaseRaw.java:143)
at 
com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract.create(ODatabaseWrapperAbstract.java:55)
at 
com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.create(ODatabaseRecordAbstract.java:350)
... 7 more
Caused by: com.orientechnologies.orient.core.exception.OStorageException: 
Cannot create new storage 'db' because it is not closed
at 
com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage.create(OLocalPaginatedStorage.java:282)
at 
com.orientechnologies.orient.core.db.raw.ODatabaseRaw.create(ODatabaseRaw.java:139)
... 9 more
com.orientechnologies.orient.core.exception.ODatabaseException: Cannot 
create database
at 
com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.create(ODatabaseRecordAbstract.java:396)
at 
com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract.create(ODatabaseWrapperAbstract.java:55)
at 
com.orientechnologies.orient.core.db.ODatabaseRecordWrapperAbstract.create(ODatabaseRecordWrapperAbstract.java:64)
at 
com.tinkerpop.blueprints.impls.orient.OrientGraphFactory.getDatabase(OrientGraphFactory.java:137)
at 
com.tinkerpop.blueprints.impls.orient.OrientGraphFactory.getDatabase(OrientGraphFactory.java:118)
at 
com.tinkerpop.blueprints.impls.orient.OrientGraphFactory.getNoTx(OrientGraphFactory.java:101)
at OrientTest$Writer.run(OrientTest.java:23)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.orientechnologies.orient.core.exception.ODatabaseException: 
Cannot create database
at 
com.orientechnologies.orient.core.db.raw.ODatabaseRaw.create(ODatabaseRaw.java:143)
at 
com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract.create(ODatabaseWrapperAbstract.java:55)
at 
com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.create(ODatabaseRecordAbstract.java:350)
... 7 more
Caused by: com.orientechnologies.orient.core.exception.OStorageException: 
Cannot create new storage 'db' because it is not closed
at 
com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage.create(OLocalPaginatedStorage.java:282)
at 
com.orientechnologies.orient.core.db.raw.ODatabaseRaw.create(ODatabaseRaw.java:139)
... 9 more
com.orientechnologies.orient.core.exception.ODatabaseException: Cannot 
create database
at 
com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.create(ODatabaseRecordAbstract.java:396)
at 
com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract.create(ODatabaseWrapperAbstract.java:55)
at 
com.orientechnologies.orient.core.db.ODatabaseRecordWrapperAbstract.create(ODatabaseRecordWrapperAbstract.java:64)
at 
com.tinkerpop.blueprints.impls.orient.OrientGraphFactory.getDatabase(OrientGraphFactory.java:137)
at 
com.tinkerpop.blueprints.impls.orient.OrientGraphFactory.getDatabase(OrientGraphFactory.java:118)
at 
com.tinkerpop.blueprints.impls.orient.OrientGraphFactory.getNoTx(OrientGraphFactory.java:101)
at OrientTest$Writer.run(OrientTest.java:23)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.orientechnologies.orient.core.exception.ODatabaseException: 
Cannot create database
at 
com.orientechnologies.orient.core.db.raw.ODatabaseRaw.create(ODatabaseRaw.java:143)
at 
com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract.create(ODatabaseWrapperAbstract.java:55)
at 
com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.create(ODatabaseRecordAbstract.java:350)
... 7 more
Caused by: com.orientechnologies.orient.core.exception.OStorageException: 
Cannot create new storage 'db' because it is not closed
at 
com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage.create(OLocalPaginatedStorage.java:282)
at 
com.orientechnologies.orient.core.db.raw.ODatabaseRaw.create(ODatabaseRaw.java:139)
... 9 more
vertex : v[#9:0] 
url:plocal:/Users/curtis/orientdb/bd1b381a-69ff-4dfa-86fe-70212594a1a2/db
Disconnected from the target VM, address: '127.0.0.1:56993', transport: 
'socket'

However, if I remove the + "/db"; from the url lines, it works and I get:

Connected to the target VM, address: '127.0.0.1:57066', transport: 'socket'
vertex : v[#9:0] 
url:plocal:/Users/curtis/orientdb/258d6da8-a3cc-4e17-91ec-48449876b78a
vertex : v[#9:0] 
url:plocal:/Users/curtis/orientdb/bd1b381a-69ff-4dfa-86fe-70212594a1a2
vertex : v[#9:0] 
url:plocal:/Users/curtis/orientdb/91c032a0-5b36-4ebf-bd0f-f0b1fd14cd56
vertex : v[#9:0] 
url:plocal:/Users/curtis/orientdb/2873e704-588b-4e05-bac9-4bdded9f2bfa
Disconnected from the target VM, address: '127.0.0.1:57066', transport: 
'socket'

Seems like a bug to me...

Curtis

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to