in graph/utils/heron.py [0:0]
def graph_check(graph_client: GremlinClient, zk_config: Dict[str, Any],
tracker_url: str, cluster: str, environ: str,
topology_id: str) -> str:
""" Checks to see if the specified topology has an entry in the graph
database and if so whether that entry was created since the latest change
to the physical plan object stored in the ZooKeeper cluster (defined in the
supplied config object)
Arguments:
graph_client (GremlinClient): The client instance for the graph
database.
zk_config (dict): A dictionary containing ZK config information.
"heron.statemgr.connection.string" and
"heron.statemgr.root.path" should be present.
tracker_url (str): The URL for the Heron Tracker API.
cluster (str): The name of the cluster the topology is running on.
environ (str): The environment the topology is running in.
topology_id (str): The topology ID string.
Returns:
The topology reference for the physical graph that was either found or
created in the graph database.
"""
most_recent_graph: Optional[Tuple[str, dt.datetime]] = \
most_recent_graph_ref(graph_client, topology_id)
zookeeper_url = zk_config["heron.statemgr.connection.string"]
parts = zookeeper_url.split(".")
parts[1] = cluster
zookeeper_url = ".".join(parts)
LOG.info("Zookeeper URL: %s", zookeeper_url)
if not most_recent_graph:
LOG.info("There are currently no physical graphs in the database "
"for topology %s", topology_id)
topology_ref: str = _build_graph(graph_client, tracker_url, cluster,
environ, topology_id)
elif not _physical_plan_still_current(
topology_id, most_recent_graph[1],
zookeeper_url,
zk_config["heron.statemgr.root.path"],
zk_config["zk.time.offset"]):
LOG.info("The physical plan for topology %s has changed since "
"the last physical graph (reference: %s) was built",
topology_id, most_recent_graph[0])
topology_ref = _build_graph(graph_client, tracker_url, cluster,
environ, topology_id)
else:
topology_ref = most_recent_graph[0]
LOG.info("The current physical plan for topology %s is already "
"represented in the graph database with reference %s",
topology_id, topology_ref)
return topology_ref