0
votes

I am saving data to OrientDB to specific clusters. Like This

CREATE VERTEX <Class> CLUSTER <Cluster> SET ect...

I then query specific clusters via REST calls to get data. This works fine in standalone mode, but in distributed mode it doesn't because I may be trying to save data to a node that isn't the owner of that cluster. Is there a way to automatically send REST call to the correct node?

If not, how do I query the database to see which nodes own individual clusters so that I can write some logic to send request to the correct node?

I am using OrientDB 2.2.0

1
hello, could you post some examples? tnx - Ivan Mainetti
I have a server side function that saves to a specific cluster like this: Create VERTEX Class1 CLUSTER USA... I execute it using a POST REST call: <IP>/database/functions/functions1... Is there a way to have the call sent to the owner of the cluster USA? - manjam

1 Answers

0
votes

On a distributed 2.2.13 with 2 nodes I've changed the cluster selection strategy for a class to default; then you can create vertex

    orientdb {db=GratefulDeadConcerts}> alter class written_by CLUSTERSELECTION default
    orientdb {db=GratefulDeadConcerts}> select name,defaultClusterId,clusterIds,clusterSelection from ( select expand(classes) from metadata:schema ) where clusterSelection="default"
    +----+----------+----------------+-------------------------+----------------+
    |#   |name      |defaultClusterId|clusterIds               |clusterSelection|
    +----+----------+----------------+-------------------------+----------------+
    |0   |written_by|33              |[33,34,35,36,37,38,39,40]|default         |
    +----+----------+----------------+-------------------------+----------------+
    localhost:2480/command/GratefulDeadConcerts/sql/select name,defaultClusterId,clusterIds,clusterSelection from ( select expand(classes) from metadata:schema ) where clusterSelection="default" 
    localhost:2481/command/GratefulDeadConcerts/sql/select name,defaultClusterId,clusterIds,clusterSelection from ( select expand(classes) from metadata:schema ) where clusterSelection="default" 

Please take a look at documentation about cluster strategy for classes
http://orientdb.com/docs/2.2/SQL-Create-Class.html
http://orientdb.com/docs/2.2/SQL-Alter-Class.html
http://orientdb.com/docs/2.2/SQL-Create-Vertex.html

An example:

    orientdb {db=GratefulDeadConcerts}> CREATE CLASS V1 EXTENDS V 
    Class created successfully. Total classes in database now: 14.

    orientdb {db=GratefulDeadConcerts}> select name,defaultClusterId,clusterIds,clusterSelection from ( select expand(classes) from metadata:schema ) where name="V1"
    +----+----+----------------+-------------------------+----------------+
    |#   |name|defaultClusterId|clusterIds               |clusterSelection|
    +----+----+----------------+-------------------------+----------------+
    |0   |V1  |54              |[54,55,56,57,58,59,60,61]|round-robin     |
    +----+----+----------------+-------------------------+----------------+

    orientdb {db=GratefulDeadConcerts}> alter class V1 CLUSTERSELECTION default        
    Class updated successfully.

    orientdb {db=GratefulDeadConcerts}> info class V1
    CLASS 'V1'
    Records..............: 0
    Super classes........: [V]
    Default cluster......: v1 (id=54)
    Supported clusters...: v1(54), v1_1(55), v1_2(56), v1_3(57), v1_4(58), v1_5(59), v1_6(60), v1_7(61)
    Cluster selection....: default
    Oversize.............: 0.0

    orientdb {db=GratefulDeadConcerts}> CREATE VERTEX V1 CLUSTER V1  set name="me" , type="artist"
    Created vertex 'V1#54:0{name:me,type:artist} v1' in 0.017000 sec(s).

    orientdb {db=GratefulDeadConcerts}> select * from V1
    +----+-----+------+----+------+
    |#   |@RID |@CLASS|name|type  |
    +----+-----+------+----+------+
    |0   |#54:0|V1    |me  |artist|
    +----+-----+------+----+------+