New cluster wont save class

157 views
Skip to first unread message

Zaraka

unread,
Apr 16, 2015, 5:34:52 PM4/16/15
to orient-...@googlegroups.com
Hello,

I'm using orientdb-community-2.0.6 graph mode

My problem:
1) At one place in code a create a new cluster by command
ALTER CLASS X ADDCLUSTER X_CLUSTER
2) I see new cluster in OrientDB Studio
3) Then I try to create a vertex in that cluster (in completely different thread)
 OrientVertex vertex = graph.addVertex(X,X_CLUSTER);
But I got
SEVERE: java.lang.IllegalArgumentException: Cluster name 'X_CLUSTER' (id=26) is not configured to store the class 'X', valid are [11, 20]
    at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.save(ODatabaseDocumentTx.java:2266)
    at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.save(ODatabaseDocumentTx.java:118)
    at com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:1706)
    at com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:1702)
    at com.tinkerpop.blueprints.impls.orient.OrientElement.save(OrientElement.java:303)
    at com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.addVertex(OrientBaseGraph.java:617)

When I restart my program and try it second time it works.

Kindly please, what did I messed up?

Colin

unread,
Apr 16, 2015, 5:50:51 PM4/16/15
to orient-...@googlegroups.com
Hi Zaraka,

When you create the vertex in the completely different thread do you do this immediately after you create the new cluster?  You had mentioned seeing it in OrientDB Studio, so it appears that the different thread executes much later.

How do you synchronize the threads so that the create vertex thread knows when the cluster has been created?

How are you obtaining the OrientGraph object in each thread?

Thanks,

-Colin

Orient Technologies

The Company behind OrientDB

Zaraka

unread,
Apr 17, 2015, 5:16:47 AM4/17/15
to orient-...@googlegroups.com
So I have two threads that works with Database.
Both threads have opened database in OrientGraphFactory (database is opened once at program start in both threads)
new OrientGraphFactory(host, user, password).setupPool(1, 10);

In first thread I create clusters by code like this
 OrientGraph graph = factory.getTx();
        try {
            project.vertexTransaction(graph);

            //Vertices clusters
            new OCommandSQL(
                    "ALTER CLASS Resource ADDCLUSTER " + DatabaseClasses.RESOURCE.getName() + project.getCluster()
            ).execute();
            //... more code like this

        } finally {
            graph.shutdown();
        }
The second thread is actually a Java Service and executes its code seconds/minutes/hours later after this command is finished I pass cluster names to this thread so it knows which clusters it should use.


Dne čtvrtek 16. dubna 2015 23:50:51 UTC+2 Colin napsal(a):

Colin

unread,
Apr 17, 2015, 12:29:45 PM4/17/15
to orient-...@googlegroups.com
I assume in your second thread that you call factory.getTx() before calling graph.addVertex() and graph isn't cached beforehand.

Is that accurate?

You said that if you restart the application it works.  Do you mean if you restart the application and just execute the second thread's task (in other words you're not calling alter class again)?

Just trying to clarify the situation.

Thanks,

-Colin

Zaraka

unread,
Apr 22, 2015, 6:08:55 PM4/22/15
to orient-...@googlegroups.com
Yes, exactly.

Yes again.


Dne pátek 17. dubna 2015 18:29:45 UTC+2 Colin napsal(a):

Zaraka

unread,
Apr 29, 2015, 4:15:29 PM4/29/15
to orient-...@googlegroups.com
So, is this bug, or should I try to reopen database after I change database schema?

Dne čtvrtek 23. dubna 2015 0:08:55 UTC+2 Zaraka napsal(a):

Zaraka

unread,
May 12, 2015, 3:21:55 AM5/12/15
to orient-...@googlegroups.com
If anyone else run into this problem. You can fix it by creating a new GraphFactory for each thread every time you change clusters, probably also when you create classes.

Dne středa 29. dubna 2015 22:15:29 UTC+2 Zaraka napsal(a):

camilo casadiego

unread,
Sep 18, 2015, 12:22:14 AM9/18/15
to OrientDB
Hi, in case its worth, I was having the same problem, and the new object solution wasn't working, at the end, the solution was to add graphFactory.getDatabase().reload(); betwen the cluster creation and the object insertion
Reply all
Reply to author
Forward
0 new messages