Esempio n. 1
0
 def test_10_bits_length(self):
     builder = HashedContainerBuilder(bits=10)
     self.assertTrue(builder.verify("FF0"))
     self.assertTrue(builder.verify("FF8"))
     self.assertTrue(builder.verify("FF4"))
     self.assertFalse(builder.verify("1FF0"))
     self.assertFalse(builder.verify("1FF8"))
     self.assertFalse(builder.verify("1FF4"))
     self.assertFalse(builder.verify("FF9"))
     self.assertFalse(builder.verify("FF1"))
     self.assertFalse(builder.verify("FF2"))
     self.assertFalse(builder.verify("FFF"))
Esempio n. 2
0
 def get_flatns_manager(self):
     # TODO(jfs): this is also needed in oio-swift, need to factorize in
     #            oiopy
     self.info()
     options = self._nsinfo['options']
     bitlength, offset, size = None, 0, 0
     try:
         bitlength = int(options['flat_bitlength'])
     except:
         raise ConfigurationException(
             "Namespace not configured for autocontainers")
     try:
         if 'flat_hash_offset' in options:
             offset = int(options['flat_hash_offset'])
         if 'flat_hash_size' in options:
             size = int(options['flat_hash_size'])
     except:
         raise Exception("Invalid autocontainer config: offset/size")
     return HashedContainerBuilder(offset=offset, size=size, bits=bitlength)
Esempio n. 3
0
 def flatns_manager(self):
     if self._flatns_manager is not None:
         return self._flatns_manager
     from oio.common.autocontainer import HashedContainerBuilder
     options = self.nsinfo['options']
     bitlength, offset, size = None, 0, None
     try:
         bitlength = int(self._flatns_bits or options['flat_bitlength'])
     except Exception:
         from oio.common.exceptions import ConfigurationException
         raise ConfigurationException(
                 "Namespace not configured for autocontainers")
     try:
         if 'flat_hash_offset' in options:
             offset = int(options['flat_hash_offset'])
         if 'flat_hash_size' in options:
             size = int(options['flat_hash_size'])
     except Exception:
         raise Exception("Invalid autocontainer config: offset/size")
     self._flatns_manager = HashedContainerBuilder(
         offset=offset, size=size, bits=bitlength)
     return self._flatns_manager
Esempio n. 4
0
 def get_flatns_manager(self):
     if self._flatns_manager:
         return self._flatns_manager
     self.info()
     options = self._nsinfo['options']
     bitlength, offset, size = None, 0, 0
     try:
         bitlength = int(options['flat_bitlength'])
     except:
         raise ConfigurationException(
             "Namespace not configured for autocontainers")
     try:
         if 'flat_hash_offset' in options:
             offset = int(options['flat_hash_offset'])
         if 'flat_hash_size' in options:
             size = int(options['flat_hash_size'])
     except:
         raise Exception("Invalid autocontainer config: offset/size")
     self._flatns_manager = HashedContainerBuilder(offset=offset,
                                                   size=size,
                                                   bits=bitlength)
     return self._flatns_manager
Esempio n. 5
0
 def test_8_bits_length(self):
     builder = HashedContainerBuilder(bits=8)
     self.assertTrue(builder.verify("F0"))
     self.assertTrue(builder.verify("0F"))
     self.assertFalse(builder.verify("1F0"))
     self.assertFalse(builder.verify("FF0"))