def _list(sharding_type): """The method returns all the shard mappings (names) of a particular sharding_type. For example if the method is called with 'range' it returns all the sharding specifications that exist of type range. :param sharding_type: The sharding type for which the sharding specification needs to be returned. :return: A list of dictionaries of shard mappings that are of the sharding type An empty list of the sharding type is valid but no shard mapping definition is found An error if the sharding type is invalid. :raises: Sharding Error if Sharding type is not found. """ if sharding_type not in Shards.VALID_SHARDING_TYPES: raise _errors.ShardingError(INVALID_SHARDING_TYPE % (sharding_type,)) ret_shard_mappings = [] shard_mappings = ShardMapping.list(sharding_type) for shard_mapping in shard_mappings: ret_shard_mappings.append({ "mapping_id":shard_mapping.shard_mapping_id, "table_name":shard_mapping.table_name, "column_name":shard_mapping.column_name, "type_name":shard_mapping.type_name, "global_group":shard_mapping.global_group}) return ret_shard_mappings
def _list(sharding_type): """The method returns all the shard mappings (names) of a particular sharding_type. For example if the method is called with 'range' it returns all the sharding specifications that exist of type range. :param sharding_type: The sharding type for which the sharding specification needs to be returned. :return: A list of dictionaries of shard mappings that are of the sharding type An empty list of the sharding type is valid but no shard mapping definition is found An error if the sharding type is invalid. :raises: Sharding Error if Sharding type is not found. """ if sharding_type not in Shards.VALID_SHARDING_TYPES: raise _errors.ShardingError(INVALID_SHARDING_TYPE % (sharding_type, )) ret_shard_mappings = [] shard_mappings = ShardMapping.list(sharding_type) for shard_mapping in shard_mappings: ret_shard_mappings.append({ "mapping_id": shard_mapping.shard_mapping_id, "table_name": shard_mapping.table_name, "column_name": shard_mapping.column_name, "type_name": shard_mapping.type_name, "global_group": shard_mapping.global_group }) return ret_shard_mappings
def test_shard_mapping_list_mappings(self): """Test the listing of all HASH shards in a shard mapping. """ shard_mappings = ShardMapping.list("HASH") self.assertTrue( ShardingUtils.compare_shard_mapping(self.__shard_mapping_1, shard_mappings[0]))
def test_shard_mapping_list_mappings(self): shard_mappings = ShardMapping.list("RANGE") self.assertTrue(ShardingUtils.compare_shard_mapping (self.__shard_mapping_1, shard_mappings[0])) self.assertTrue(ShardingUtils.compare_shard_mapping (self.__shard_mapping_2, shard_mappings[1])) self.assertTrue(ShardingUtils.compare_shard_mapping (self.__shard_mapping_3, shard_mappings[2])) self.assertTrue(ShardingUtils.compare_shard_mapping (self.__shard_mapping_4, shard_mappings[3]))
def test_shard_mapping_list_mappings(self): shard_mappings = ShardMapping.list("RANGE") self.assertTrue( ShardingUtils.compare_shard_mapping(self.__shard_mapping_1, shard_mappings[0])) self.assertTrue( ShardingUtils.compare_shard_mapping(self.__shard_mapping_2, shard_mappings[1])) self.assertTrue( ShardingUtils.compare_shard_mapping(self.__shard_mapping_3, shard_mappings[2])) self.assertTrue( ShardingUtils.compare_shard_mapping(self.__shard_mapping_4, shard_mappings[3]))
def test_shard_mapping_list_mappings(self): """Test the listing of all HASH shards in a shard mapping. """ shard_mappings = ShardMapping.list("HASH") self.assertTrue(ShardingUtils.compare_shard_mapping (self.__shard_mapping_1, shard_mappings[0]))