orientdb clusterselection,如何平均分配每个节点中的记录

orientdb clusterselection,如何平均分配每个节点中的记录,orientdb,Orientdb,Orientdb verson 2.1.11 我有3个节点,我想在每个节点平均分发我的记录,我的代码是: ODatabase database = new DatabaseDocumentTx("remote:node1;node2;node3/mydb").open("root", "1234"); System.out.println("selection:" + database.get(ODatabase.ATTRIBUTES.CLUSTERSELECTION)); database

Orientdb verson 2.1.11

我有3个节点,我想在每个节点平均分发我的记录,我的代码是:

ODatabase database = new DatabaseDocumentTx("remote:node1;node2;node3/mydb").open("root", "1234");

System.out.println("selection:" + database.get(ODatabase.ATTRIBUTES.CLUSTERSELECTION));

database.command(new OCommandSQL("alter class Person clusterSelection round-robin"));

System.out.println("selection:" + database.get(ODatabase.ATTRIBUTES.CLUSTERSELECTION));

for (int i = 0; i < 100; ++i) {
    ODocument document = new ODocument("Person");
    document.field("name", "pengtao.geng" + i);
    document.field("age", 28 + i);

    document.save();
    System.out.println("save " + i);
}
database.close();
ODatabase database=newdatabasedocumenttx(“远程:node1;node2;node3/mydb”)。打开(“根”,“1234”);
System.out.println(“选择:“+database.get(ODatabase.ATTRIBUTES.CLUSTERSELECTION));
命令(新的OCommandSQL(“alterclaspersonclusterselection循环”);
System.out.println(“选择:“+database.get(ODatabase.ATTRIBUTES.CLUSTERSELECTION));
对于(int i=0;i<100;++i){
气味文件=新气味文件(“人员”);
文件字段(“名称”、“彭涛.耿”+i);
文件.字段(“年龄”,28+i);
document.save();
System.out.println(“保存”+i);
}
close()数据库;
但是,它不起作用。我试图通过studio修改类clusterselection,但它也不起作用


如何做到这一点,您能给我举个例子吗?非常感谢您在v2.2中使用OrientDB支持负载平衡:。您可以在此代码中使用
ROUND\u ROBIN\u REQUEST
策略(服务器必须在集群中):

ODatabase database=newdatabasedocumenttx(“远程:node1;node2;node3/mydb”)。打开(“根”,“1234”);
db.setProperty(ostrageremote.PARAM_CONNECTION_STRATEGY、ostrageremote.CONNECTION_STRATEGY、ROUND_ROBIN_REQUEST);
对于(int i=0;i<100;++i){
气味文件=新气味文件(“人员”);
文件字段(“名称”、“彭涛.耿”+i);
文件.字段(“年龄”,28+i);
document.save();
System.out.println(“保存”+i);
}
close()数据库;

在v2.2 OrientDB中支持负载平衡:。您可以在此代码中使用
ROUND\u ROBIN\u REQUEST
策略(服务器必须在集群中):

ODatabase database=newdatabasedocumenttx(“远程:node1;node2;node3/mydb”)。打开(“根”,“1234”);
db.setProperty(ostrageremote.PARAM_CONNECTION_STRATEGY、ostrageremote.CONNECTION_STRATEGY、ROUND_ROBIN_REQUEST);
对于(int i=0;i<100;++i){
气味文件=新气味文件(“人员”);
文件字段(“名称”、“彭涛.耿”+i);
文件.字段(“年龄”,28+i);
document.save();
System.out.println(“保存”+i);
}
close()数据库;
ODatabase database = new DatabaseDocumentTx("remote:node1;node2;node3/mydb").open("root", "1234");

db.setProperty(OStorageRemote.PARAM_CONNECTION_STRATEGY, OStorageRemote.CONNECTION_STRATEGY.ROUND_ROBIN_REQUEST);

for (int i = 0; i < 100; ++i) {
    ODocument document = new ODocument("Person");
    document.field("name", "pengtao.geng" + i);
    document.field("age", 28 + i);

    document.save();
    System.out.println("save " + i);
}
database.close();