2828
2929from gscoordinator .flex .core .config import CLUSTER_TYPE
3030from gscoordinator .flex .core .config import CREATION_TIME
31+ from gscoordinator .flex .core .config import GROOT_CYPHER_PORT
3132from gscoordinator .flex .core .config import GROOT_GREMLIN_PORT
3233from gscoordinator .flex .core .config import GROOT_GRPC_PORT
3334from gscoordinator .flex .core .config import GROOT_PASSWORD
3435from gscoordinator .flex .core .config import GROOT_USERNAME
3536from gscoordinator .flex .core .config import INSTANCE_NAME
3637from gscoordinator .flex .core .config import NAMESPACE
38+ from gscoordinator .flex .core .insight .utils import test_cypher_endpoint
3739from gscoordinator .flex .core .scheduler import schedule
3840from gscoordinator .flex .core .utils import data_type_to_groot
3941from gscoordinator .flex .core .utils import get_internal_ip
4648class GrootGraph (object ):
4749 """Graph class for GraphScope store"""
4850
49- def __init__ (self , name , creation_time , gremlin_endpoint , grpc_endpoint ):
51+ def __init__ (self , name , creation_time , gremlin_endpoint , grpc_endpoint , cypher_endpoint = None ):
5052 self ._id = "1"
5153 self ._name = name
5254
@@ -60,12 +62,14 @@ def __init__(self, name, creation_time, gremlin_endpoint, grpc_endpoint):
6062 )
6163 self ._g = self ._conn .g ()
6264 self ._schema = self ._g .schema ().to_dict ()
63- self ._gremlin_interface = {
65+ self ._endpoints = {
6466 "gremlin_endpoint" : gremlin_endpoint ,
6567 "grpc_endpoint" : grpc_endpoint ,
6668 "username" : GROOT_USERNAME ,
6769 "password" : GROOT_PASSWORD ,
6870 }
71+ self ._endpoints ["cypher_endpoint" ] = cypher_endpoint
72+
6973 # kubernetes
7074 if CLUSTER_TYPE == "KUBERNETES" :
7175 self ._api_client = resolve_api_client ()
@@ -97,22 +101,27 @@ def _fetch_endpoints_impl(self):
97101 grpc_endpoint , gremlin_endpoint , GROOT_USERNAME , GROOT_PASSWORD
98102 )
99103 g = conn .g ()
104+ cypher_endpoint = test_cypher_endpoint (pod .status .pod_ip , GROOT_CYPHER_PORT )
105+
100106 except Exception as e :
101107 logger .warn (f"Failed to fetch frontend endpoints: { str (e )} " )
102108 else :
103109 if (
104- gremlin_endpoint != self ._gremlin_interface ["gremlin_endpoint" ]
105- or grpc_endpoint != self ._gremlin_interface ["grpc_endpoint" ]
110+ gremlin_endpoint != self ._endpoints ["gremlin_endpoint" ]
111+ or grpc_endpoint != self ._endpoints ["grpc_endpoint" ]
112+ or cypher_endpoint != self ._endpoints .get ("cypher_endpoint" )
106113 ):
107114 self ._conn = conn
108115 self ._g = g
109116 self ._schema = self ._g .schema ().to_dict ()
110- self ._gremlin_interface = {
117+ self ._endpoints = {
111118 "gremlin_endpoint" : gremlin_endpoint ,
112119 "grpc_endpoint" : grpc_endpoint ,
113120 "username" : GROOT_USERNAME ,
114121 "password" : GROOT_PASSWORD ,
115122 }
123+ if cypher_endpoint :
124+ self ._endpoints ["cypher_endpoint" ] = cypher_endpoint
116125 logger .info (f"Update frontend endpoints: { str (endpoints )} " )
117126
118127 def __del__ (self ):
@@ -131,8 +140,8 @@ def name(self):
131140 return self ._name
132141
133142 @property
134- def gremlin_interface (self ):
135- return self ._gremlin_interface
143+ def groot_endpoints (self ):
144+ return self ._endpoints
136145
137146 @property
138147 def schema (self ):
@@ -284,12 +293,16 @@ def get_groot_graph_from_local():
284293 client .close ()
285294 break
286295 time .sleep (5 )
296+ # test whether cypher endpoint is ready
297+ cypher_endpoint = test_cypher_endpoint (host , GROOT_CYPHER_PORT )
298+
287299 # groot graph
288300 return GrootGraph (
289301 name = INSTANCE_NAME ,
290302 creation_time = CREATION_TIME ,
291303 gremlin_endpoint = gremlin_endpoint ,
292304 grpc_endpoint = grpc_endpoint ,
305+ cypher_endpoint = cypher_endpoint ,
293306 )
294307
295308
0 commit comments