Exemple #1
0
    def _maybe_repair(self, cr, monitor):
        crr = CheckAndRepairResults(self._verifycap.storage_index)
        crr.pre_repair_results = cr
        if cr.is_healthy():
            crr.post_repair_results = cr
            return defer.succeed(crr)

        crr.repair_attempted = True
        crr.repair_successful = False  # until proven successful

        def _repair_error(f):
            # as with mutable repair, I'm not sure if I want to pass
            # through a failure or not. TODO
            crr.repair_successful = False
            crr.repair_failure = f
            return f

        r = Repairer(self,
                     storage_broker=self._storage_broker,
                     secret_holder=self._secret_holder,
                     monitor=monitor)
        d = r.start()
        d.addCallbacks(self._gather_repair_results,
                       _repair_error,
                       callbackArgs=(
                           cr,
                           crr,
                       ))
        return d
Exemple #2
0
        def _maybe_repair(cr):
            crr = CheckAndRepairResults(storage_index)
            crr.pre_repair_results = cr
            if cr.is_healthy():
                crr.post_repair_results = cr
                return defer.succeed(crr)
            else:
                crr.repair_attempted = True
                crr.repair_successful = False  # until proven successful

                def _gather_repair_results(ur):
                    assert IUploadResults.providedBy(ur), ur
                    # clone the cr (check results) to form the basis of the
                    # prr (post-repair results)
                    prr = CheckResults(cr.uri, cr.storage_index)
                    prr.data = copy.deepcopy(cr.data)

                    sm = prr.data['sharemap']
                    assert isinstance(sm, DictOfSets), sm
                    sm.update(ur.sharemap)
                    servers_responding = set(prr.data['servers-responding'])
                    servers_responding.union(ur.sharemap.iterkeys())
                    prr.data['servers-responding'] = list(servers_responding)
                    prr.data['count-shares-good'] = len(sm)
                    prr.data['count-good-share-hosts'] = len(sm)
                    is_healthy = bool(len(sm) >= verifycap.total_shares)
                    is_recoverable = bool(len(sm) >= verifycap.needed_shares)
                    prr.set_healthy(is_healthy)
                    prr.set_recoverable(is_recoverable)
                    crr.repair_successful = is_healthy
                    prr.set_needs_rebalancing(
                        len(sm) >= verifycap.total_shares)

                    crr.post_repair_results = prr
                    return crr

                def _repair_error(f):
                    # as with mutable repair, I'm not sure if I want to pass
                    # through a failure or not. TODO
                    crr.repair_successful = False
                    crr.repair_failure = f
                    return f

                r = Repairer(self,
                             storage_broker=sb,
                             secret_holder=sh,
                             monitor=monitor)
                d = r.start()
                d.addCallbacks(_gather_repair_results, _repair_error)
                return d
Exemple #3
0
        def _maybe_repair(cr):
            crr = CheckAndRepairResults(storage_index)
            crr.pre_repair_results = cr
            if cr.is_healthy():
                crr.post_repair_results = cr
                return defer.succeed(crr)
            else:
                crr.repair_attempted = True
                crr.repair_successful = False # until proven successful
                def _gather_repair_results(ur):
                    assert IUploadResults.providedBy(ur), ur
                    # clone the cr (check results) to form the basis of the
                    # prr (post-repair results)
                    prr = CheckResults(cr.uri, cr.storage_index)
                    prr.data = copy.deepcopy(cr.data)

                    sm = prr.data['sharemap']
                    assert isinstance(sm, DictOfSets), sm
                    sm.update(ur.sharemap)
                    servers_responding = set(prr.data['servers-responding'])
                    servers_responding.union(ur.sharemap.iterkeys())
                    prr.data['servers-responding'] = list(servers_responding)
                    prr.data['count-shares-good'] = len(sm)
                    good_hosts = len(reduce(set.union, sm.itervalues(), set()))
                    prr.data['count-good-share-hosts'] = good_hosts
                    is_healthy = bool(len(sm) >= verifycap.total_shares)
                    is_recoverable = bool(len(sm) >= verifycap.needed_shares)
                    prr.set_healthy(is_healthy)
                    prr.set_recoverable(is_recoverable)
                    crr.repair_successful = is_healthy
                    prr.set_needs_rebalancing(len(sm) >= verifycap.total_shares)

                    crr.post_repair_results = prr
                    return crr
                def _repair_error(f):
                    # as with mutable repair, I'm not sure if I want to pass
                    # through a failure or not. TODO
                    crr.repair_successful = False
                    crr.repair_failure = f
                    return f
                r = Repairer(self, storage_broker=sb, secret_holder=sh,
                             monitor=monitor)
                d = r.start()
                d.addCallbacks(_gather_repair_results, _repair_error)
                return d
Exemple #4
0
    def _maybe_repair(self, cr, monitor):
        crr = CheckAndRepairResults(self._verifycap.storage_index)
        crr.pre_repair_results = cr
        if cr.is_healthy():
            crr.post_repair_results = cr
            return defer.succeed(crr)

        crr.repair_attempted = True
        crr.repair_successful = False # until proven successful
        def _repair_error(f):
            # as with mutable repair, I'm not sure if I want to pass
            # through a failure or not. TODO
            crr.repair_successful = False
            crr.repair_failure = f
            return f
        r = Repairer(self, storage_broker=self._storage_broker,
                     secret_holder=self._secret_holder,
                     monitor=monitor)
        d = r.start()
        d.addCallbacks(self._gather_repair_results, _repair_error,
                       callbackArgs=(cr, crr,))
        return d