9. JanusGraph ConfiguredGraphFactory

ConfiguredGraphFactory는 JanusGraph 서버를 구성 할 수 있습니다. ConfiguredGraphFactory는 JanusGraphFactory 유사한 접근 방법의 도면이다. 이 수치 팩토리 클래스도의 서버에서 호스팅 동적 관리하는 방법을 제공한다.

1. 개요

JanusGraphFactory는 구성 객체를 구성하여 다이어그램에 액세스 할 때마다 그리는 방법에 대한 액세스를 제공하는 클래스입니다.

ConfiguredGraphFactory는 방식의 구성도를 작성하는 데 사용할 ConfigurationManagementGraph 액세스를 제공합니다. 또한 레이아웃 도면을 관리 할 수있는 방법을 제공합니다.

ConfigurationManagementGraph 당신이 구성도를 관리 할 수 ​​있습니다.

JanusGraphManager 당신이 당신의지도를 사용하도록 구성되어 있는지 제공 참조 맵을 추적 할 수 있습니다, 내부 서비스 구성 요소입니다.

2. ConfiguredGraphFactory 및 JanusGraphFactory

그러나이 두 가지도 팩토리 클래스 사이의 한 가지 중요한 차이점 :

  • 서비스가 당신이 당신의 서버를 구성하는 데 사용 ConfigurationManagementGraph의 API를 시작하는 경우에만, ConfiguredGraphFactory 사용할 수 있습니다.

ConfiguredGraphFactory 사용의 장점은 다음과 같습니다 :

  • 당신은 당신에게 당신이 사용하는 그래픽에 액세스 할 때지도가 백 엔드 정보를 지정해야 열 때마다 요청이 아니라 JanusGraphFactory-보다,지도에 액세스 할 문자열을 제공해야합니다.
  • 당신의 ConfigurationManagementGraph 스토리지 백엔드 구성, 클러스터 사용의 모든 노드에서 사용할 차트 JanusGraph의 구성을 배포합니다.

방법 3. ConfiguredGraphFactory 작업

그림 ConfiguredGraphFactory는 다음과 같은 두 가지 경우에 액세스 방법을 제공한다 :

  • 당신은 ConfigurationManagementGraph # createConfiguration 특정 다이어그램 객체를 생성하도록 구성 사용해야합니다. 이 시나리오에서의 사용은 이전에이 구성도 오픈 그래프를 위해 만들었습니다.
  • 당신은 ConfigurationManagementGraph # createTemplateConfiguration을 사용하도록 구성 템플릿을 만들었습니다. 이 경우, 우리는 템플릿 구성 저장소에있는 모든 속성을 통과하고 관련 graphName 추가 속성은 특정 구성에 따라지도를 만든지도하고 개방하도록 구성 생성하려면 복사합니다.

4.도 액세스

당신은 ConfiguredGraphFactory.create ( "graphName") 또는 ConfiguredGraphFactory.open ( "graphName")를 사용할 수 있습니다. 이 두 장소에 접근 사이에 많은 차이를 배울 수 ConfigurationManagementGraph에 다음 섹션을 읽어보십시오.

또한지도에 액세스 할 수 바인딩을 사용할 수 있습니다. 자세한 내용은 섹션 9.10 "그래프 및 순회 바인딩"절을 참조하십시오.

도 목록입니다.

ConfiguredGraphFactory.getGraphNames는 ()는 구성의 다이어그램을 만들 수 ConfigurationManagementGraph API를 사용하여 이름 집합을 반환합니다.

반면에, JanusGraphFactory.getGraphNames는 () 인스턴스화도 이름의 배열을 반환하고, 기준은 JanusGraphManager에 저장됩니다.

6. 삭제지도

ConfiguredGraphFactory.drop ( "graphName")는 모든 데이터 저장 및 인덱스를 삭제,지도 데이터베이스를 삭제합니다. 이 도면은 (일부로 폐쇄한다 결실)을 개폐 할 수있다. 또한,도 ConfigurationManagementGraph 기존 구성도 제거한다.

참고 :

  • 이것은 모든지도와 인덱스 데이터를 제거, 돌이킬 수없는 작업입니다.
  • 올바른 구성의 각 노드가 클러스터의 모든 수치는 모든 JanusGraph JanusGraphManager 그래픽이 동일에 캐시 대표 노드 수 있도록, JanusGraphManager를 사용한다고 가정하면,이 클러스터 다이어그램의 각 노드를 삭제합니다. 이 기능이 어떻게이 기능을 사용하도록 서비스를 구성하는 방법에 대해 자세히 알아보십시오.

7. 구성 JanusGraph 서비스 ConfiguredGraphFactory

ConfiguredGraphFactory를 사용하려면, 당신은 당신의 서비스를 구성 ConfigurationManagementGraph API를 사용해야합니다. 이렇게하려면, 당신은 당신의 YAML 파일 서비스의 그래프에서 "ConfigurationManagementGraph"라는 이름의 맵 변수를 구성해야합니다. 예를 들면 :

graphManager: org.janusgraph.graphdb.management.JanusGraphManager
graphs: {
  ConfigurationManagementGraph: conf/JanusGraph-configurationmanagement.properties
}

다음이 예에서는,도 프로퍼티 ConfigurationManagementGraph의 conf / JanusGraph-configurationmanagement.properties 저장 구성 예를 사용한다 :

gremlin.graph=org.janusgraph.core.JanusGraphFactory
storage.backend=cql
graph.graphname=ConfigurationManagementGraph
storage.hostname=127.0.0.1

성공적인 시작과 ConfigurationManagementGraph GremlinServer가 성공적으로 인스턴스화되면, 싱글에서 사용 가능한 모든도도의 작업을 수행합니다 ConfigurationManagementGraph의 API이다. 또한,이 도면은 ConfiguredGraphFactory도 1의 구성으로 생성 / 오픈 액세스 사용될 수있다.

참고 :

pom.xml 파일 JanusGraph은 선택 사항으로 이번 릴리즈 의존성에 포함되어 있지만, ConfiguredGraphFactory이 JanusGraphManager를 사용, 그것은 org.apache.tinkerpop 의존 : 놈아 서버. 당신이 오류 NoClassDefFoundError를 발생한다면, pom.xml 파일에 종속성을 추가하려면이 프롬프트 수 있도록해야합니다.

8. ConfigurationManagementGraph

ConfigurationManagementGraph는 싱글 당신이 ConfiguredGraphFactory이 업데이트 구성 / / 삭제도 만들어 사용할 수 있습니다. API를 사용하도록 서비스를 구성하는 방법에 위의 내용을 참조하십시오.

주 : ConfiguredGraphFactory 따라서 하나의 실시 예는 그 자체를 조작하는 대신에, 사용할 수 ConfiguredGraphFactory 정적 메소드를 대응 ConfigurationManagementGraph 통해도 1의 구성을 관리하는 방법을 제공한다. 예를 들어, 당신이 사용할 수있는 ConfiguredGraphFactory.removeTemplateConfiguration () 대신 ConfiguredGraphFactory.getInstance (). RemoveTemplateConfiguration ().

8.1 구성도.

ConfigurationManagementGraph 하나의 실시 예는 특정 특성도 graph.graphname하여 열린 구성을 생성 할 수있다. 예를 들면 :

map = new HashMap<String, Object>();
map.put("storage.backend", "cql");
map.put("storage.hostname", "127.0.0.1");
map.put("graph.graphname", "graph1");
ConfiguredGraphFactory.createConfiguration(new MapConfiguration(map));

그런 다음, 당신은 어떤 JanusGraph 노드에서이 차트에 액세스하려면 다음과 같은 방법을 사용할 수 있습니다 :

ConfiguredGraphFactory.open("graph1");
8.2. 템플릿 구성

ConfigurationManagementGraph은 또한 당신이 동일한 구성 템플릿을 사용하여 그림을 많이 만들 수 있습니다, 템플릿 구성을 만들 수 있습니다. 예를 들면 :

map = new HashMap<String, Object>();
map.put("storage.backend", "cql");
map.put("storage.hostname", "127.0.0.1");
ConfiguredGraphFactory.createTemplateConfiguration(new MapConfiguration(map));

이 작업이 완료되면, 당신은 템플릿 구성을 사용하여 차트를 만들 수 있습니다 :

ConfiguredGraphFactory.create("graph2");

이 방법은 첫 번째 구성 모든 속성을 복사하여 템플릿과 관련하여 "그래프 2"에 대한 새로운 구성을 만들려면이 특정 그림까지의 구성에 저장됩니다. 당신은 다음과 같은 방법으로 모든 노드에이 차트 JanusGraph에 액세스 할 수 있습니다이 방법 :

ConfiguredGraphFactory.open("graph2");
8.3 업데이트 구성

구성의 상호 작용 JanusGraphFactory 및 ConfiguredGraphFactory 주어진 JVM에서 JanusGraphManager 트랙에 의해 정의 된 모든 속성의 graph.graphname와의 모든 상호 작용이 인용 한 수치에 생성됩니다. 이것은 그래픽스 버퍼. 이러한 이유로 :

JanusGraph 관련 그래픽은 각 노드가 제대로 JanusGraphManager를 사용하도록 구성되어 있는지 가정, 각 노드에서 맵 캐시 클러스터에서 구성을 나타내는 모든 업데이트는 추방가 발생합니다. 이 기능이 어떻게이 기능을 사용하도록 서버를 구성하는 방법에 대해 자세히 알아보십시오.

그래픽 수단의 구성을 만드는 방법 제 복사본을 이용하여 생성 만든 템플릿을 사용하여 그래픽 구성으로서 :

만든 템플릿 구성을 사용하여 특정 차트에 모든 업데이트는 특정 차트까지 효력을 보장 할 수 있습니다 :

  1. 삭제 구성 : ConfiguredGraphFactory.removeConfiguration ( "그래프 2");
  2. 지도를 다시 템플릿 구성을 사용 ConfiguredGraphFactory.create ( "그래프 2를");
8.4. 예 업데이트
  1. 우리는 새로운 IP 주소를 새 서버로 데이터를 마이그레이션 카산드라 :

    map = new HashMap();
    map.put("storage.backend", "cql");
    map.put("storage.hostname", "127.0.0.1");
    map.put("graph.graphname", "graph1");
    ConfiguredGraphFactory.createConfiguration(new
    MapConfiguration(map));
    
    g1 = ConfiguredGraphFactory.open("graph1");
    
    // Update configuration
    map = new HashMap();
    map.put("storage.hostname", "10.0.0.1");
    ConfiguredGraphFactory.updateConfiguration("graph1",
    map);
    
    // We are now guaranteed to use the updated configuration
    g1 = ConfiguredGraphFactory.open("graph1");
    
  2. 우리는 설정에서 Elasticsearch 노드를 추가했습니다 :

    map = new HashMap();
    map.put("storage.backend", "cql");
    map.put("storage.hostname", "127.0.0.1");
    map.put("graph.graphname", "graph1");
    ConfiguredGraphFactory.createConfiguration(new
    MapConfiguration(map));
    
    g1 = ConfiguredGraphFactory.open("graph1");
    
    // Update configuration
    map = new HashMap();
    map.put("index.search.backend", "elasticsearch");
    map.put("index.search.hostname", "127.0.0.1");
    map.put("index.search.elasticsearch.transport-scheme", "http");
    ConfiguredGraphFactory.updateConfiguration("graph1",
    map);
    
    // We are now guaranteed to use the updated configuration
    g1 = ConfiguredGraphFactory.open("graph1");
    
  3. 그래픽 업데이트 된 템플릿 구성 생성 구성을 업데이트 :

    map = new HashMap();
    map.put("storage.backend", "cql");
    map.put("storage.hostname", "127.0.0.1");
    ConfiguredGraphFactory.createTemplateConfiguration(new
    MapConfiguration(map));
    
    g1 = ConfiguredGraphFactory.create("graph1");
    
    // Update template configuration
    map = new HashMap();
    map.put("index.search.backend", "elasticsearch");
    map.put("index.search.hostname", "127.0.0.1");
    map.put("index.search.elasticsearch.transport-scheme", "http");
    ConfiguredGraphFactory.updateTemplateConfiguration(new
    MapConfiguration(map));
    
    // Remove Configuration
    ConfiguredGraphFactory.removeConfiguration("graph1");
    
    // Recreate
    ConfiguredGraphFactory.create("graph1");
    // Now this graph's configuration is guaranteed to be updated
    

    9. JanusGraphManager

    JanusGraphManager은 다음과 TinkerPop graphManager 사양 싱글입니다.

    특히, JanusGraphManager는 다음과 같은 기능을 제공합니다

    • 코디기구는 도면의 특정 예 JanusGraph 노드 인용
    • 기준 패턴을 추적 (또는 캐시)

    Graph.graphname는 JanusGraphManager 합격 모든 그래픽 특성을 사용하여 생성 된 대응하는 방식으로 인스턴스화. 도 차트 참조도 JVM에 캐시에 저장된다.

    따라서, 어떤 중요한 JVM에서 열 특성 graph.graphname을 사용하여도가도 캐시로부터 검색 인스턴스화.

    업데이트 구성이 이유의 정확성을 보장하기 위해 몇 가지 단계가 필요 이유입니다.

    9.1. 어떻게 JanusGraphManager를 사용하는 방법

    이것은 정의하는 방법 그래픽에 액세스 할 수있는 구성 속성을 정의 할 때 사용할 수있는 새 구성 옵션입니다. 구성은이 속성이 (공정 위에서 설명 됨) 그래픽 JanusGraphManager 인스턴스화 달성 포함됩니다.

    호환성을 위해,이 파라미터는 어떤 지원하지 않고 그래픽 서버 객체 그래프 .yaml 파일의 시작에 가능한, JanusGraphManager 키 수치는 도면에 도시하는 결합에 의해 제공된다. 예를 들어, 다음과 같이 당신의 .yaml도 객체는 경우 :

    graphManager: org.janusgraph.graphdb.management.JanusGraphManager
    graphs {
      graph1: conf/graph1.properties,
      graph2: conf/graph2.properties
    }
    

    그러나 conf의 / graph1.properties 및 conf의 / graph2.properties 그래서 그래프 2는 각각 그래프 1, 속성 이들도 JanusGraphManager에 저장되어, graph.graphname 포함 및 스크립트 실행 등의 바인드 놈아 없습니다.

    9.2. 참고

    편의를 위해, 구성 파일 지정 graph.graphname 경우,하지만 백엔드 스토리지 디렉토리, TABLENAME 또는 keyspacename의 관련 매개 변수가 자동으로 graph.graphname의 값으로 설정되어 구성되지 않았습니다. 당신이 매개 변수 중 하나를 구성하는 경우 그러나, 그것은 우선 순위 값을 사용합니다. 구성하지 않으면 기본값은 기본값을 사용하여 구성됩니다.

    특별한 경우는 storage.root 구성 항목입니다. 이 새로운 구성입니다, 어떤 백엔드의 루트 디렉토리를 지정하는 데 사용되는 로컬 저장소 디렉토리 액세스를 필요로합니다. 이 매개 변수는, 당신은 또한 graph.graphname 속성을 제공해야하는 경우, 이것은 절대 저장소 디렉토리 경로 플러스 graph.graphname storage.root 경로 될 것입니다.

    다음은 사용 예이다 :

    • 위해 만든 내 카산드라 백엔드 템플릿 구성은 식물에 공급되는 문자열의 방법으로 얻은 각 그래픽 만들려면이 구성을 사용하는 <graphName>고유 키 공간의 동등한 :

      map = new HashMap();
      map.put("storage.backend", "cql");
      map.put("storage.hostname", "127.0.0.1");
      ConfiguredGraphFactory.createTemplateConfiguration(new
      MapConfiguration(map));
      
      g1 = ConfiguredGraphFactory.create("graph1"); //keyspace === graph1
      g2 = ConfiguredGraphFactory.create("graph2"); //keyspace === graph2
      g3 = ConfiguredGraphFactory.create("graph3"); //keyspace === graph3
      
    • 내 BerkeleyJE 템플릿 구성은 얻을 동일 각 그래픽을 작성할 때이 구성을 사용하기 위해 만든 백엔드 <storage.root> / <graph.graphname>고유의 저장 디렉토리를 :

      map = new HashMap();
      map.put("storage.backend", "berkeleyje");
      map.put("storage.root", "/data/graphs");
      ConfiguredGraphFactory.createTemplateConfiguration(new
      MapConfiguration(map));
      
      g1 = ConfiguredGraphFactory.create("graph1"); //storage directory === /data/graphs/graph1
      g2 = ConfiguredGraphFactory.create("graph2"); //storage directory === /data/graphs/graph2
      g3 = ConfiguredGraphFactory.create("graph3"); //storage directory === /data/graphs/graph3
      

    10. 그래프 및 순회 바인딩

    ConfiguredGraphFactory는 "graph.graphname"속성을 통해 그렘린 서버에 바인딩 그래픽 프로그램 실행 컨텍스트를 사용하여 만든 및 그래픽 순회하는에 의해 참조 <graphname> _traversal문맥에 바인드. (가) 처음 생성 한 후, / 열기가 서버에 이후 관련 도면이 방법을 수행 할 수 있습니다 <graphname><graphname> _traversal참조 속성 액세스 그래프 트래버스.

    이 기능이 어떻게이 기능을 사용하도록 서버를 구성하는 방법에 대해 자세히 알아보십시오.

    참고 :

    • 당신이 그렘린 및 원격 서버에 콘솔 세션 연결 그렘린 연결을 사용하는 경우에는 다시 연결해야 바인드 변수에 서버. 동일은 웹 소켓 연결의 세션에 대한 사실이다.
    • JanusGraphManager는 각 그래픽 ConfigurationManagementGraph에 20 초마다 저장 리 바인드 (또는 그래픽의 구성을 만들었습니다). 이 방법은 그래픽을 만들고 통과 ConfigredGraphFactory 20 초까지 지연 모든 JanusGraph 노드에서 사용할 수 바인딩. 또한 서버가 재시작 된 후, 노드에 결합이 여전히 사용될 수 있다는 것을 의미한다.
    10.1 실시 예 바인딩
    gremlin> :remote connect tinkerpop.server conf/remote.yaml
    ==>Configured localhost/127.0.0.1:8182
    gremlin> :remote console
    ==>All scripts will now be sent to Gremlin Server - [localhost/127.0.0.1:8182] - type ':remote console' to return to local mode
    gremlin> ConfiguredGraphFactory.open("graph1")
    ==>standardjanusgraph[cassandrathrift:[127.0.0.1]]
    gremlin> graph1
    ==>standardjanusgraph[cassandrathrift:[127.0.0.1]]
    gremlin> graph1_traversal
    ==>graphtraversalsource[standardjanusgraph[cassandrathrift:[127.0.0.1]], standard]
    

    11. 샘플

    세션 연결이 구성된 그래프 공장 템플릿을 만들 때 좋습니다. 세션 연결을 사용하지 않을 경우, 그래픽 템플릿 세미콜론 공장 구성을 생성 할 수있는 단일 라인으로 서버에 전송해야합니다. 세션에 대한 자세한 내용은 섹션 7.1.1.1 "는 그렘린 서버에 연결"을 참조하십시오.

    gremlin> :remote connect tinkerpop.server conf/remote.yaml session
    ==>Configured localhost/127.0.0.1:8182
    
    gremlin> :remote console
    ==>All scripts will now be sent to Gremlin Server - [localhost:8182]-[5206cdde-b231-41fa-9e6c-69feac0fe2b2] - type ':remote console' to return to local mode
    
    gremlin> ConfiguredGraphFactory.open("graph");
    Please create configuration for this graph using the
    ConfigurationManagementGraph API.
    
    gremlin> ConfiguredGraphFactory.create("graph");
    Please create a template Configuration using the
    ConfigurationManagementGraph API.
    
    gremlin> map = new HashMap();
    gremlin> map.put("storage.backend", "cql");
    gremlin> map.put("storage.hostname", "127.0.0.1");
    gremlin> map.put("GraphName", "graph1");
    gremlin> ConfiguredGraphFactory.createConfiguration(new MapConfiguration(map));
    Please include in your configuration the property "graph.graphname".
    
    gremlin> map = new HashMap();
    gremlin> map.put("storage.backend", "cql");
    gremlin> map.put("storage.hostname", "127.0.0.1");
    gremlin> map.put("graph.graphname", "graph1");
    gremlin> ConfiguredGraphFactory.createConfiguration(new MapConfiguration(map));
    ==>null
    
    gremlin> ConfiguredGraphFactory.open("graph1").vertices();
    
    gremlin> map = new HashMap(); map.put("storage.backend",
    "cql"); map.put("storage.hostname", "127.0.0.1");
    gremlin> map.put("graph.graphname", "graph1");
    gremlin> ConfiguredGraphFactory.createTemplateConfiguration(new MapConfiguration(map));
    Your template configuration may not contain the property
    "graph.graphname".
    
    gremlin> map = new HashMap();
    gremlin> map.put("storage.backend",
    "cql"); map.put("storage.hostname", "127.0.0.1");
    gremlin> ConfiguredGraphFactory.createTemplateConfiguration(new MapConfiguration(map));
    ==>null
    
    // Each graph is now acting in unique keyspaces equivalent to the
    graphnames.
    gremlin> g1 = ConfiguredGraphFactory.open("graph1");
    gremlin> g2 = ConfiguredGraphFactory.create("graph2");
    gremlin> g3 = ConfiguredGraphFactory.create("graph3");
    gremlin> g2.addVertex();
    gremlin> l = [];
    gremlin> l << g1.vertices().size();
    ==>0
    gremlin> l << g2.vertices().size();
    ==>1
    gremlin> l << g3.vertices().size();
    ==>0
    
    // After a graph is created, you must access it using .open()
    gremlin> g2 = ConfiguredGraphFactory.create("graph2"); g2.vertices().size();
    Configuration for graph "graph2" already exists.
    
    gremlin> g2 = ConfiguredGraphFactory.open("graph2"); g2.vertices().size();
    ==>1
    

대중의 관심의 코드 번호를 청소에 오신 것을 환영합니다, 더 나은 의사 소통
대중의 관심의 코드 번호를 청소에 오신 것을 환영합니다, 더 나은 의사 소통

게시 된 115 개 원래 기사 · 원 찬양 67 ·은 10 만 + 조회수

추천

출처blog.csdn.net/meifannao789456/article/details/92108306