def _start_maintenance_thread(self):
     # start the maintenance thread and register all the maintenance
     # operations :
     # (1) JournalCleanup - Delete completed rows from journal
     # (2) CleanupProcessing - Mark orphaned processing rows to pending
     cleanup_obj = cleanup.JournalCleanup()
     self._maintenance_thread = maintenance.MaintenanceThread()
     self._maintenance_thread.register_operation(
         cleanup_obj.delete_completed_rows)
     self._maintenance_thread.register_operation(
         cleanup_obj.cleanup_processing_rows)
     self._maintenance_thread.start()
Beispiel #2
0
 def _start_maintenance_thread(self):
     # start the maintenance thread and register all the maintenance
     # operations :
     # (1) JournalCleanup - Delete completed rows from journal
     # (2) CleanupProcessing - Mark orphaned processing rows to pending
     # (3) Full sync - Re-sync when detecting an ODL "cold reboot"
     cleanup_obj = cleanup.JournalCleanup()
     self._maintenance_thread = maintenance.MaintenanceThread()
     self._maintenance_thread.register_operation(
         cleanup_obj.delete_completed_rows)
     self._maintenance_thread.register_operation(
         cleanup_obj.cleanup_processing_rows)
     self._maintenance_thread.register_operation(full_sync.full_sync)
     self._maintenance_thread.start()
    def _test_cleanup_processing_rows(self, last_retried, expected_state):
        # Create a dummy network (creates db row in pending state).
        self._call_operation_object(odl_const.ODL_CREATE,
                                    odl_const.ODL_NETWORK)

        # Get pending row and mark as processing and update
        # the last_retried time
        row = db.get_all_db_rows_by_state(self.db_session,
                                          odl_const.PENDING)[0]
        row.last_retried = last_retried
        db.update_db_row_state(self.db_session, row, odl_const.PROCESSING)

        # Test if the cleanup marks this in the desired state
        # based on the last_retried timestamp
        cleanup.JournalCleanup().cleanup_processing_rows(self.db_session)

        # Verify that the Db row is in the desired state
        rows = db.get_all_db_rows_by_state(self.db_session, expected_state)
        self.assertEqual(1, len(rows))