具有来自不同服务器的存储库的联合存储

Federated store with repositories from different server

我想在 AllegroGraph 中为联合存储创建一个抽象存储库。

我可以连接到存储在不同服务器上的存储库。但是当我尝试使用联合函数将它们组合起来时,它会抛出一个错误,即它无法在第二台服务器上找到存储库。

我在这个 link 中发现了同样的问题,但没有帮助。有什么提示吗?

这是我的代码:

AGServer server = new AGServer(SERVER_URL, USERNAME, PASSWORD);
AGServer server2 = new AGServer(SERVER_URL2, USERNAME2, PASSWORD2);
println("Available catalogs: " + server.listCatalogs());
AGRepositoryConnection custCon = server.createRepositoryConnection("repo1", CATALOG_ID, false);
AGRepositoryConnection supCon = server2.createRepositoryConnection("repo2", CATALOG_ID, false);
AGAbstractRepository rainbowRepo = server2.federate(custCon.getRepository(), supCon.getRepository());

rainbowRepo.initialize();
AGRepositoryConnection rainbowConn = rainbowRepo.getConnection();

SailRepository class 为联合上下文实现 FederatedServiceResolverClient,因此您可以使用 class SailRepository 添加具有不同存储库的联合存储:

AGServer server = new AGServer(SERVER_URL, USERNAME, PASSWORD);
AGServer server2 = new AGServer(SERVER_URL2, USERNAME2, PASSWORD2);

AGRepository repo1 = server.getCatalog(CATALOG_ID).openRepository("repo1");
AGRepository repo2 = server2.getCatalog(CATALOG_ID).openRepository("repo2");

Federation federation = new Federation();
federation.addMember(repo1);
federation.addMember(repo2);
federation.setReadOnly(true); 

SailRepository rainbowRepo  = new SailRepository(federation);
rainbowRepo .initialize();

SailRepositoryConnection rainbowConn  =  rainbowRepo .getConnection(); //for querying and updating the contents of the repository.