Example #1
0
 def do_persist(self):
     """Immediately write persistence data to storage."""
     persistency_data = []
     for dict_record in self.known_values_dict.items():
         persistency_data.append(dict_record)
     PersistencyUtil.store_json(self.persistence_file_name,
                                persistency_data)
     self.next_persist_time = None
Example #2
0
 def do_timer(self, trigger_time):
     """Check current ruleset should be persisted"""
     if self.next_persist_time is None:
         return 600
     delta = self.next_persist_time - trigger_time
     if delta < 0:
         PersistencyUtil.store_json(self.persistence_file_name,
                                    self.expected_values_dict)
         self.next_persist_time = None
         delta = 600
     return delta
    def do_timer(self, trigger_time):
        """Check current ruleset should be persisted"""
        if self.next_persist_time is None:
            return 600

        delta = self.next_persist_time - trigger_time
        if delta < 0:
            PersistencyUtil.store_json(self.persistence_file_name,
                                       list(self.known_path_set))
            self.next_persist_time = None
            delta = 600
        return delta
 def do_timer(self, trigger_time):
     """This method is called to perform trigger actions and to determine the time for next invocation. The caller may decide
     to invoke this method earlier than requested during the previous call. Classes implementing this method have to handle such
     cases. Each class should try to limit the time spent in this method as it might delay trigger signals to other components.
     For extensive compuational work or IO, a separate thread should be used.
     @param trigger_time the time this trigger is invoked. This might be the current real time when invoked from real time
     timers or the forensic log timescale time value.
     @return the number of seconds when next invocation of this trigger is required."""
     delta = self.next_persist_time - trigger_time
     if delta <= 0:
         self.repositioning_data_dict = {}
         for log_stream_name, log_stream in self.log_streams_by_name.items(
         ):
             repositioning_data = log_stream.get_repositioning_data()
             if repositioning_data is not None:
                 self.repositioning_data_dict[
                     log_stream_name] = repositioning_data
         PersistencyUtil.store_json(self.persistence_file_name,
                                    self.repositioning_data_dict)
         delta = 600
         self.next_persist_time = trigger_time + delta
     return delta
Example #5
0
 def do_persist(self):
     """Immediately write persistence data to storage."""
     PersistencyUtil.store_json(self.persistence_file_name,
                                self.known_values)
     self.next_persist_time = None