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):
>
> 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):
>>
>> Yes, exactly.
>>
>> Yes again.
>>
>>
>> Dne pátek 17. dubna 2015 18:29:45 UTC+2 Colin napsal(a):
>>>
>>> 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
>>>
>>> On Friday, April 17, 2015 at 4:16:47 AM UTC-5, Zaraka wrote:
>>>>
>>>> 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):
>>>>>
>>>>> 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
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Thursday, April 16, 2015 at 4:34:52 PM UTC-5, Zaraka wrote:
>>>>>>
>>>>>> 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?
>>>>>>
>>>>>

-- 

--- 
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