javasesameallegrograph

allegro graph - federate repositories located on different server


I'm trying to create an abstract repository for doing a federal search on Allegro Graph. I'm able to connect to the repositories stored on different server. However, when I tried to combined them using the federate, it throws an error that it cannot find the repo on the second server. Is there a way to combined two repositories stored on different server into an abstract repository where a federal search can be done?

    AGServer server = new AGServer(SERVER_URL1, USERNAME1, PASSWORD1);
    AGRepository repo1 = server.getRootCatalog().openRepository(REPO1);


    AGServer server2 = new AGServer(SERVER_URL2, USERNAME2, PASSWORD2);
    AGRepository repo2 = server2.getRootCatalog().openRepository(REPO2);

    System.out.println(repo1.getConnection().size());
    System.out.println(repo2.getConnection().size());

    AGAbstractRepository combinedRepo = server.federate(repo1, repo2);
    combinedRepo.initialize();

    combinedRepo.getConnection(); //this return an exception


    Exception in thread "main" org.openrdf.repository.RepositoryException: org.openrdf.repository.RepositoryException: Repository not found with ID: REPO2
        at com.franz.agraph.repository.AGCatalog.openRepository(AGCatalog.java:264)
...
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
    Caused by: org.openrdf.repository.RepositoryException: Repository not found with ID: REPO2
        at com.franz.agraph.repository.AGCatalog.openRepository(AGCatalog.java:260)
        ... 6 more

TIA


Solution

  • I was able to make a federated repository using the AGServer of Allegro Graph. Here's how I did it for those who might find it helpful:

    AGVirtualRepository s = server2.virtualRepository("<http://<ip address>:10035/repositories/repo1> + <http://<ip address>:10035/repositories/repo2>");
    AGRepositoryConnection combinedConn = s.getConnection();