2014-02-18 14 views
1

알레그로 그래프에서 연방 검색을 수행하기 위해 추상 저장소를 만들려고합니다. 다른 서버에 저장된 리포지토리에 연결할 수 있습니다. 그러나 Federate를 사용하여 결합하려고 시도하면 두 번째 서버에서 Repo를 찾을 수 없다는 오류가 발생합니다. 다른 서버에 저장된 두 개의 저장소를 연방 검색을 수행 할 수있는 추상 저장소에 결합하는 방법이 있습니까?알레그로 그래프 - 다른 서버에 위치한 연합 저장소

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

답변

0

Allegro Graph의 AGServer를 사용하여 연합 리포지토리를 만들 수있었습니다. 도움이 될만한 사람들을 위해 내가 한 일은 다음과 같습니다.

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

참깨 프레임 워크는 하나 개의 가상 저장소에 (다른 서버/지역에 거주하는) 여러 참깨 저장소를 포장하는 데 사용할 수있는 Federation Sail 지원합니다. 당신이 시도하고 (단 하나의 서버에 여러 저장소에 기어드 것 같다) 인 AllegroGraph의 맞춤형 연합 코드를 사용하는 것을 대신 사용할 수 있습니다

// create your AG repositories the same way 
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); 

// Use a Sesame Federation to combine them 
org.openrdf.sail.federation.Federation federation = new Federation(); 
federation.addMember(repo1); 
federation.addMember(repo2); 
federation.setReadOnly(true); // assuming you only use it for query 

Repository combinedRepo = new SailRepository(federation); 
combinedRepo.initialize(); 

(ObDisclaimer이 : 내 머리의 상단에서 작성된 코드보다, 내가있을 수 있습니다

대안은 SERVICE 절을 통해 페더레이션에 대한 SPARQL 지원을 사용하는 것입니다. 이것은 질의하고자하는 각 저장소가 HTTP를 통해 SPARQL 엔드 포인트로 액세스 할 수 있어야합니다.