예제 #1
0
    def __init__(self, name, ec_segment_size, ec_type, ec_nb_data,
                 ec_nb_parity):
        super(ECStorageMethod, self).__init__(name=name, ec=True)

        try:
            self._ec_nb_data = int(ec_nb_data)
        except (TypeError, ValueError):
            raise exceptions.InvalidStorageMethod('Invalid %r ec_nb_data' %
                                                  ec_nb_data)

        try:
            self._ec_nb_parity = int(ec_nb_parity)
        except (TypeError, ValueError):
            raise exceptions.InvalidStorageMethod('Invalid %r ec_nb_parity' %
                                                  ec_nb_parity)

        self._ec_segment_size = ec_segment_size
        self._ec_type = ec_type

        from pyeclib.ec_iface import ECDriver
        self.driver = ECDriver(k=ec_nb_data,
                               m=ec_nb_parity,
                               ec_type=ec_type_to_pyeclib_type[ec_type])
        self._ec_quorum_size = \
            self._ec_nb_data + self.driver.min_parity_fragments_needed()
예제 #2
0
    def __init__(self, name, ec_segment_size, ec_type, ec_nb_data,
                 ec_nb_parity):
        super(ECStorageMethod, self).__init__(name=name, ec=True)

        try:
            self._ec_nb_data = int(ec_nb_data)
        except (TypeError, ValueError):
            raise exceptions.InvalidStorageMethod('Invalid %r ec_nb_data' %
                                                  ec_nb_data)

        try:
            self._ec_nb_parity = int(ec_nb_parity)
        except (TypeError, ValueError):
            raise exceptions.InvalidStorageMethod('Invalid %r ec_nb_parity' %
                                                  ec_nb_parity)

        self._ec_segment_size = ec_segment_size
        self._ec_type = ec_type

        try:
            self.driver = ECDriver(k=ec_nb_data,
                                   m=ec_nb_parity,
                                   ec_type=ec_type)
        except ECDriverError as exc:
            msg = "'%s' (%s: %s) Check erasure code packages." % (
                ec_type, exc.__class__.__name__, exc)
            reraise(exceptions.InvalidStorageMethod,
                    exceptions.InvalidStorageMethod(msg),
                    sys.exc_info()[2])
        self._ec_quorum_size = \
            self._ec_nb_data + self.driver.min_parity_fragments_needed()
예제 #3
0
    def __init__(self, name, nb_copy):
        super(ReplicatedStorageMethod, self).__init__(name=name)

        try:
            self._nb_copy = int(nb_copy)
        except (TypeError, ValueError):
            raise exc.InvalidStorageMethod('Invalid %r nb_copy' % nb_copy)
        self._quorum = (self._nb_copy + 1) // 2
예제 #4
0
 def load(self, chunk_method):
     method = self.cache.get(chunk_method)
     if method:
         return method
     try:
         chunk_method, params = parse_chunk_method(chunk_method)
         cls = self.index[chunk_method]
     except Exception as e:
         raise exc.InvalidStorageMethod(str(e))
     return cls.build(params)
예제 #5
0
 def load(self, chunk_method, **kwargs):
     method = self.cache.get(chunk_method)
     if method:
         return method
     try:
         storage_method, params = parse_chunk_method(chunk_method)
         cls = self.index[storage_method]
     except Exception as exc:
         raise exceptions.InvalidStorageMethod(str(exc)), \
             None, sys.exc_info()[2]
     params.update(kwargs)
     self.cache[chunk_method] = cls.build(params)
     self.cache[chunk_method].type = storage_method
     return self.cache[chunk_method]