コード例 #1
0
ファイル: __init__.py プロジェクト: YoanSallami/underworlds
 def reset(self):
     """ Hard reset of Underworlds: all the worlds are deleted.
     The existing mesh database is kept, however.
     This does not impact the list of known clients (ie, clients do not have to
     call 'helo' again).
     """
     self.rpc.reset(gRPC.Client(id=self.id), _TIMEOUT_SECONDS)
コード例 #2
0
 def __iter__(self):
     """To iterate over the existing worlds, first ask the server
     an up-to-date list of worlds, and yield worlds as much as needed.
     Doing so, worlds are lazily created.
     """
     topo = self._ctx.rpc.topology(gRPC.Client(id=self._ctx.id),
                                   _TIMEOUT_SECONDS)
     for world in topo.worlds:
         yield self.__getitem__(world)
コード例 #3
0
    def push_mesh(self, mesh):

        starttime = time.time()
        try:
            self.rpc.pushMesh(
                gRPC.MeshInContext(client=gRPC.Client(id=self.id),
                                   mesh=mesh.serialize(gRPC.Mesh)),
                _TIMEOUT_SECONDS_MESH_LOADING)
        except ExpirationError:
            logger.error("Timeout while trying to push a mesh to the server!")

        logger.info("Pushed mesh <%s> in %.2fsec" %
                    (mesh.id, time.time() - starttime))
コード例 #4
0
    def topology(self):
        """Returns the current topology to the underworlds environment.

        It returns an object with two members:
        - 'worlds': the list of all worlds' names known to the system
        - 'clients': the list of known clients. Each client is an object with
          the following members:
          - client.id
          - client.name
          - client.links: a list of the 'links' between this client and the
            worlds. Each link has the following members:
            - link.world
            - link.type: `READER`, `PROVIDER`, `FILTER`, `MONITOR`, see `types.py`
            - link.last_activity: the timestamp of the last time this link has been used
        """
        return self.rpc.topology(gRPC.Client(id=self.id), _TIMEOUT_SECONDS)
コード例 #5
0
    def __init__(self, name, host, port):
        self.id = str(uuid.uuid4())
        self.name = name

        # stores the links (cf clients' types) with the various worlds.
        self.links = {}

        self.channel = None
        self.invalidation_server = self._connect_invalidation_server(
            name, host, port)
        self.isactive = (self.invalidation_server is not None)

        self.active_invalidations = []

        self.grpc_client = gRPC.Client(id=self.id)

        if self.isactive:
            logger.debug("Client %s (id: %s) successfully created." %
                         (self.name, self.id))
        else:
            logger.warn("Client %s (id: %s) created but inactive." %
                        (self.name, self.id))
コード例 #6
0
 def mesh(self, id):
     mesh = self.rpc.getMesh(
         gRPC.MeshInContext(client=gRPC.Client(id=self.id),
                            mesh=gRPC.Mesh(id=id)),
         _TIMEOUT_SECONDS_MESH_LOADING)
     return Mesh.deserialize(mesh)
コード例 #7
0
 def has_mesh(self, id):
     ok = self.rpc.hasMesh(
         gRPC.MeshInContext(client=gRPC.Client(id=self.id),
                            mesh=gRPC.Mesh(id=id)), _TIMEOUT_SECONDS)
     return ok.value
コード例 #8
0
 def uptime(self):
     """Returns the server uptime in seconds.
     """
     return self.rpc.uptime(gRPC.Client(id=self.id), _TIMEOUT_SECONDS).time
コード例 #9
0
    def reset(self):
        """Resets all worlds.
		"""

        return self.rpc.reset(gRPC.Client(id=self.id), _TIMEOUT_SECONDS)
コード例 #10
0
ファイル: __init__.py プロジェクト: YoanSallami/underworlds
 def close(self):
     logger.info("Closing context [%s]..." % self.name)
     self.rpc.byebye(gRPC.Client(id=self.id), _TIMEOUT_SECONDS)
     self.invalidation_server.stop(1).wait()
     logger.info("The context [%s] is now closed." % self.name)