Exemple #1
0
    def restore(self):
        """
        Called when the handler recovers after a Server reload. Called
        by the Server process as part of the reload upstart. Here we
        overload the tickerhandler's restore method completely to make
        sure we correctly re-apply and re-initialize the correct
        monitor and repeater objecth on all saved objects.

        """
        # load the oob monitors and initialize them
        oob_storage = ServerConfig.objects.conf(key=self.oob_save_name)
        if oob_storage:
            self.oob_storage = dbunserialize(oob_storage)
            for store_key, (args, kwargs) in self.oob_storage.items():
                # re-create the monitors
                obj, sessid, fieldname, oobfuncname = store_key
                obj = unpack_dbobj(obj)
                self._add_monitor(obj, sessid, fieldname, oobfuncname, *args, **kwargs)
        # handle the tickers (same as in TickerHandler except we  call
        # the add_repeater method which makes sure to add the hooks before
        # starting the tickerpool)
        ticker_storage = ServerConfig.objects.conf(key=self.save_name)
        if ticker_storage:
            self.ticker_storage = dbunserialize(ticker_storage)
            for store_key, (args, kwargs) in self.ticker_storage.items():
                obj, interval, idstring = store_key
                obj = unpack_dbobj(obj)
                # we saved these in add_repeater before, can now retrieve them
                sessid = kwargs["_sessid"]
                oobfuncname = kwargs["_oobfuncname"]
                self.add_repeater(obj, sessid, oobfuncname, interval, *args, **kwargs)
Exemple #2
0
 def restore(self):
     """
     Called when the handler recovers after a Server reload. Called
     by the Server process as part of the reload upstart. Here we
     overload the tickerhandler's restore method completely to make
     sure we correctly re-apply and re-initialize the correct
     monitor and repeater objecth on all saved objects.
     """
     # load the oob monitors and initialize them
     oob_storage = ServerConfig.objects.conf(key=self.oob_save_name)
     if oob_storage:
         self.oob_storage = dbunserialize(oob_storage)
         for store_key, (args, kwargs) in self.oob_storage.items():
             # re-create the monitors
             obj, sessid, fieldname, oobfuncname = store_key
             obj = unpack_dbobj(obj)
             self._add_monitor(obj, sessid, fieldname, oobfuncname, *args, **kwargs)
     # handle the tickers (same as in TickerHandler except we  call
     # the add_repeater method which makes sure to add the hooks before
     # starting the tickerpool)
     ticker_storage = ServerConfig.objects.conf(key=self.save_name)
     if ticker_storage:
         self.ticker_storage = dbunserialize(ticker_storage)
         for store_key, (args, kwargs) in self.ticker_storage.items():
             obj, interval, idstring = store_key
             obj = unpack_dbobj(obj)
             # we saved these in add_repeater before, can now retrieve them
             sessid = kwargs["_sessid"]
             oobfuncname = kwargs["_oobfuncname"]
             self.add_repeater(obj, sessid, oobfuncname, interval, *args, **kwargs)
Exemple #3
0
 def restore(self):
     """
     Restore ticker_storage from database and re-initialize the handler from storage. This is triggered by the server at restart.
     """
     # load stored command instructions and use them to re-initialize handler
     ticker_storage = ServerConfig.objects.conf(key=self.save_name)
     if ticker_storage:
         self.ticker_storage = dbunserialize(ticker_storage)
         #print "restore:", self.ticker_storage
         for store_key, (args, kwargs) in self.ticker_storage.items():
             obj, interval, idstring = store_key
             obj = unpack_dbobj(obj)
             _, store_key = self._store_key(obj, interval, idstring)
             self.ticker_pool.add(store_key, obj, interval, *args, **kwargs)
 def restore(self):
     """
     Restore ticker_storage from database and re-initialize the handler from storage. This is triggered by the server at restart.
     """
     # load stored command instructions and use them to re-initialize handler
     ticker_storage = ServerConfig.objects.conf(key=self.save_name)
     if ticker_storage:
         self.ticker_storage = dbunserialize(ticker_storage)
         #print "restore:", self.ticker_storage
         for store_key, (args, kwargs) in self.ticker_storage.items():
             obj, interval, idstring = store_key
             obj = unpack_dbobj(obj)
             _, store_key = self._store_key(obj, interval, idstring)
             self.ticker_pool.add(store_key, obj, interval, *args, **kwargs)
Exemple #5
0
    def get_all_monitors(self, session):
        """
        Get the names of all variables this session is tracking.

        Args:
            session (Session): Session monitoring.
        Returns:
            stored monitors (tuple): A list of tuples
                `(obj, fieldname, args, kwargs)` representing all
                the monitoring the Session with the given sessid is doing.

        """
        sessid = session.sessid
        # [(obj, fieldname, args, kwargs), ...]
        return [(unpack_dbobj(key[0]), key[2], stored[0], stored[1])
                for key, stored in self.oob_monitor_storage.items() if key[1] == sessid]
Exemple #6
0
    def get_all_monitors(self, sessid):
        """
        Get the names of all variables this session is tracking.

        Args:
            sessid (id): Session id of monitoring Session
        Returns:
            stored monitors (tuple): A list of tuples
            `(obj, fieldname, args, kwargs)` representing all
            the monitoring the Session with the given sessid is doing.
        """
        # check so we didn't get a session instead of a sessid
        if not isinstance(sessid, int):
            sessid = sessid.sessid
        # [(obj, fieldname, args, kwargs), ...]
        return [(unpack_dbobj(key[0]), key[2], stored[0], stored[1])
                for key, stored in self.oob_monitor_storage.items() if key[1] == sessid]
Exemple #7
0
    def get_all_monitors(self, session):
        """
        Get the names of all variables this session is tracking.

        Args:
            session (Session): Session monitoring.
        Returns:
            stored monitors (tuple): A list of tuples
                `(obj, fieldname, args, kwargs)` representing all
                the monitoring the Session with the given sessid is doing.

        """
        sessid = session.sessid
        # [(obj, fieldname, args, kwargs), ...]
        return [(unpack_dbobj(key[0]), key[2], stored[0], stored[1])
                for key, stored in self.oob_monitor_storage.items()
                if key[1] == sessid]