Ejemplo n.º 1
0
 def waitLoaded(self):
     if not self.isLoaded_:
         self.ensureSubscribed()
         SharedStateSynchronizer.getSynchronizer().waitForKeyspaceAndPrefix(
                                                             self.keyspaceName,
                                                             NativeJson.Json(())
                                                             )
Ejemplo n.º 2
0
    def setValueSlot(self, newValue):
        logging.info("Setting %s %s", str(self), newValue)
        if not self.keyspace.loaded:
            if SynchronousPropertyAccess.SynchronousPropertyAccess.getCurrent() is not None:
                self.keyspace.waitLoaded()
            else:
                logging.info("raising NotLoadedException for %s", self)
                raise NotLoadedException(self.keyspace)

        if newValue is None:
            SharedStateSynchronizer.getSynchronizer().writeValue(
                self.keyspace.keyspaceName,
                self.keyName,
                None
                )
        else:
            assert isinstance(newValue, tuple)
            assert len(newValue) == 1

            try:
                SharedStateSynchronizer.getSynchronizer().writeValue(
                    self.keyspace.keyspaceName,
                    self.keyName,
                    JsonPickle.toJson(newValue[0])
                    )
            except Exception as e:
                logging.error("%s", traceback.format_exc())
                raise

        self.value_ = newValue
Ejemplo n.º 3
0
    def setValueSlot(self, newValue):
        logging.info("Setting %s %s", str(self), newValue)
        if not self.keyspace.loaded:
            if SynchronousPropertyAccess.SynchronousPropertyAccess.getCurrent(
            ) is not None:
                self.keyspace.waitLoaded()
            else:
                logging.info("raising NotLoadedException for %s", self)
                raise NotLoadedException(self.keyspace)

        if newValue is None:
            SharedStateSynchronizer.getSynchronizer().writeValue(
                self.keyspace.keyspaceName, self.keyName, None)
        else:
            assert isinstance(newValue, tuple)
            assert len(newValue) == 1

            try:
                SharedStateSynchronizer.getSynchronizer().writeValue(
                    self.keyspace.keyspaceName, self.keyName,
                    JsonPickle.toJson(newValue[0]))
            except Exception as e:
                logging.error("%s", traceback.format_exc())
                raise

        self.value_ = newValue
Ejemplo n.º 4
0
    def ensureSubscribed(self):
        assert SharedStateSynchronizer.isConnected()
        if not self.isSubscribed_:
            logging.info("ComputedGraphSharedState subscribing to: %s", self)

            SharedStateSynchronizer.getSynchronizer().addKeyspaceListener(
                self.keyspaceName, KeyspaceUpdater(self), NativeJson.Json(()))
            self.isSubscribed_ = True
Ejemplo n.º 5
0
    def ensureSubscribed(self):
        assert SharedStateSynchronizer.isConnected()
        if not self.isSubscribed_:
            logging.info("ComputedGraphSharedState subscribing to: %s", self)

            SharedStateSynchronizer.getSynchronizer().addKeyspaceListener(
                self.keyspaceName,
                KeyspaceUpdater(self),
                NativeJson.Json(())
                )
            self.isSubscribed_ = True
Ejemplo n.º 6
0
    def populateKey(self):
        keyspace, key = self.createKey()

        keyspace.waitLoaded()

        key.value = (self.keyValue,)

        SharedStateSynchronizer.getSynchronizer().update()
        SharedStateSynchronizer.getSynchronizer().commitPendingWrites()

        return key
Ejemplo n.º 7
0
 def waitLoaded(self):
     if not self.isLoaded_:
         self.ensureSubscribed()
         SharedStateSynchronizer.getSynchronizer().waitForKeyspaceAndPrefix(
             self.keyspaceName, NativeJson.Json(()))