[Checkins] SVN: gocept.zeoraid/trunk/src/gocept/zeoraid/storage.py extract consistency check into separate method

Christian Theune ct at gocept.com
Wed Oct 6 04:16:07 EDT 2010


Log message for revision 117273:
  extract consistency check into separate method
  

Changed:
  U   gocept.zeoraid/trunk/src/gocept/zeoraid/storage.py

-=-
Modified: gocept.zeoraid/trunk/src/gocept/zeoraid/storage.py
===================================================================
--- gocept.zeoraid/trunk/src/gocept/zeoraid/storage.py	2010-10-06 07:50:35 UTC (rev 117272)
+++ gocept.zeoraid/trunk/src/gocept/zeoraid/storage.py	2010-10-06 08:16:06 UTC (rev 117273)
@@ -945,10 +945,7 @@
         # Try to find a storage that we can talk to. Stop after we found a
         # reliable result.
         storages = self.raid.storages_optimal[:]
-        reliable = False
-        while not reliable:
-            if not storages:
-                break
+        while storages:
             name = random.choice(storages)
             storages.remove(name)
             reliable, result = self.raid._apply_storage(
@@ -1037,17 +1034,7 @@
             # must be consistent anyway.
             pass
         elif results:
-            filtered_results = [
-                self.filter_results(result, self.raid.storages[storage])
-                for storage, result in results.items()]
-            ref = filtered_results[0]
-            for test in filtered_results[1:]:
-                if test != ref:
-                    logger.debug(
-                        'Got inconsistent results for method %s: %r' %
-                        (method_name, results))
-                    consistent = False
-                    break
+            consistent = self._check_result_consistency(results)
         if not consistent:
             self.raid.close()
             raise gocept.zeoraid.interfaces.RAIDError(
@@ -1065,7 +1052,20 @@
             return
         raise gocept.zeoraid.interfaces.RAIDError("RAID storage is failed.")
 
+    def _check_result_consistency(self, results):
+        filtered_results = [
+            self.filter_results(result, self.raid.storages[storage])
+            for storage, result in results.items()]
+        ref = filtered_results[0]
+        for test in filtered_results[1:]:
+            if test != ref:
+                logger.debug(
+                    'Got inconsistent results for method %s: %r' %
+                    (method_name, results))
+                return False
+        return True
 
+
 def optimistic_copy(source, target):
     """Try creating a hard link to source at target. Fall back to copying the
     file.



More information about the checkins mailing list