class Store: def __init__(self, store_node): self.name = _child_text(store_node, "name") self.persistence = _child_text(store_node, "persistence") self.routing = _child_text(store_node, "routing") self.routing_strategy = _child_text(store_node, "routing-strategy", default="consistent-routing") self.replication_factor = int(_child_text(store_node, "replication-factor")) self.required_reads = int(_child_text(store_node, "required-reads")) self.preferred_reads = _int_or_none(_child_text(store_node, "preferred-reads", required=False)) self.required_writes = int(_child_text(store_node, "required-writes")) self.preferred_writes = _int_or_none(_child_text(store_node, "preferred-writes", required=False)) key_serializer_node = _child(store_node, "key-serializer") try: self.key_serializer_type = _child_text(key_serializer_node, "type") self.key_serializer = self._create_serializer(self.key_serializer_type, key_serializer_node) except serialization.SerializationException, e: logging.warn("Error while creating key serializer for store [%s]: %s" % (self.name, e)) self.key_serializer_type = "invalid" self.key_serializer = serialization.UnimplementedSerializer("invalid") value_serializer_node = _child(store_node, "value-serializer") try: self.value_serializer_type = _child_text(value_serializer_node, "type") self.value_serializer = self._create_serializer(self.value_serializer_type, value_serializer_node) except serialization.SerializationException, e: logging.warn("Error while creating value serializer for store [%s]: %s" % (self.name, e)) self.value_serializer_type = "invalid" self.value_serializer = serialization.UnimplementedSerializer("invalid")
def _create_serializer(self, serializer_type, serializer_node): if serializer_type not in serialization.SERIALIZER_CLASSES: return serialization.UnimplementedSerializer(serializer_type) return serialization.SERIALIZER_CLASSES[serializer_type].create_from_xml(serializer_node)