def _create_stream_managers()

in graph/builder/heron/builder.py [0:0]


def _create_stream_managers(graph_client: GremlinClient, topology_id: str,
                            topology_ref: str, physical_plan: Dict[str, Any]
                            ) -> None:

    LOG.info("Creating stream managers and container vertices")

    counter: int = 0

    for stream_manager in physical_plan["stmgrs"].values():

        # Create the stream manager vertex
        LOG.debug("Creating vertex for stream manager: %s",
                  stream_manager["id"])

        strmg: Vertex = (graph_client.graph_traversal
                         .addV("stream_manager")
                         .property("id", stream_manager["id"])
                         .property("host", stream_manager["host"])
                         .property("port", stream_manager["port"])
                         .property("topology_id", topology_id)
                         .property("topology_ref", topology_ref)
                         .next())

        # Create the stream manager vertex
        container: int = int(stream_manager["id"].split("-")[1])

        LOG.debug("Creating vertex for container: %d", container)

        cont: Vertex = (graph_client.graph_traversal
                        .addV("container")
                        .property("id", container)
                        .property("topology_id", topology_id)
                        .property("topology_ref", topology_ref)
                        .next())

        # Connect the stream manager to the container
        LOG.debug("Connecting stream manager %s to be within container %d",
                  stream_manager["id"], container)
        (graph_client.graph_traversal.V(strmg).addE("is_within").to(cont)
         .next())

        counter += 1

    LOG.info("Created %d container and stream manager vertices", counter)