Пример #1
0
    def __init__(self,
                 indicator_name,
                 kafka_topic,
                 processor,
                 domains=None,
                 doc_type=None):
        self.kafka_topic = kafka_topic
        self.domains = domains or processor.domains
        self.doc_type = doc_type or processor.doc_type

        change_feed = KafkaChangeFeed(topics=[self.kafka_topic],
                                      group_id=indicator_name)

        name = '{}Pillow'.format(indicator_name)
        checkpoint = PillowCheckpoint(
            'fluff.{}.{}'.format(name, get_machine_id()),
            change_feed.sequence_format)

        super(FluffPillow, self).__init__(
            name=name,
            checkpoint=checkpoint,
            change_feed=change_feed,
            processor=processor,
            change_processed_event_handler=KafkaCheckpointEventHandler(
                checkpoint=checkpoint,
                checkpoint_frequency=1000,
                change_feed=change_feed))
Пример #2
0
    def __init__(self, indicator_class, processor):
        self.indicator_class = indicator_class
        self.kafka_topic = indicator_class().kafka_topic
        self.domains = processor.domains
        self.doc_type = processor.doc_type

        name = '{}Pillow'.format(indicator_class.__name__)
        checkpoint = PillowCheckpoint('fluff.{}.{}'.format(name, get_machine_id()))

        super(FluffPillow, self).__init__(
            name=name,
            checkpoint=checkpoint,
            change_feed=KafkaChangeFeed(topics=[self.kafka_topic], group_id=indicator_class.__name__),
            processor=processor,
            change_processed_event_handler=PillowCheckpointEventHandler(
                checkpoint=checkpoint, checkpoint_frequency=1000,
            )
        )
Пример #3
0
def _get_mvp_indicator_pillow(pillow_id, processor):
    checkpoint = PillowCheckpoint(
        'mvp_docs.pillows.{}.{}'.format(pillow_id, get_machine_id()), )
    feed = CouchChangeFeed(XFormInstance.get_db(),
                           include_docs=True,
                           couch_filter='hqadmin/domains_and_doc_types',
                           extra_couch_view_params={
                               'domains': ' '.join(processor.domains),
                               'doc_types': ' '.join(processor.doc_types),
                           })
    return ConstructedPillow(
        name=pillow_id,
        checkpoint=checkpoint,
        change_feed=feed,
        processor=processor,
        change_processed_event_handler=PillowCheckpointEventHandler(
            checkpoint=checkpoint, checkpoint_frequency=100),
    )
Пример #4
0
    def __init__(self, indicator_name, kafka_topic, processor, domains=None, doc_type=None):
        self.kafka_topic = kafka_topic
        self.domains = domains or processor.domains
        self.doc_type = doc_type or processor.doc_type

        change_feed = KafkaChangeFeed(topics=[self.kafka_topic], client_id=indicator_name)

        name = '{}Pillow'.format(indicator_name)
        checkpoint = PillowCheckpoint('fluff.{}.{}'.format(name, get_machine_id()), change_feed.sequence_format)

        super(FluffPillow, self).__init__(
            name=name,
            checkpoint=checkpoint,
            change_feed=change_feed,
            processor=processor,
            change_processed_event_handler=KafkaCheckpointEventHandler(
                checkpoint=checkpoint, checkpoint_frequency=1000, change_feed=change_feed
            )
        )
Пример #5
0
def _get_mvp_indicator_pillow(pillow_id, processor):
    feed = CouchChangeFeed(
        XFormInstance.get_db(),
        couch_filter='hqadmin/domains_and_doc_types',
        extra_couch_view_params={
            'domains': ' '.join(processor.domains),
            'doc_types': ' '.join(processor.doc_types),
        }
    )
    checkpoint = PillowCheckpoint(
        'mvp_docs.pillows.{}.{}'.format(pillow_id, get_machine_id()), feed.sequence_format
    )
    return ConstructedPillow(
        name=pillow_id,
        checkpoint=checkpoint,
        change_feed=feed,
        processor=processor,
        change_processed_event_handler=PillowCheckpointEventHandler(
            checkpoint=checkpoint, checkpoint_frequency=100
        ),
    )
 def test_get_machine_id_settings(self):
     self.assertEqual('test-ptop', get_machine_id())
 def test_get_machine_id(self):
     # since this is machine dependent just ensure that this returns something
     # and doesn't crash
     self.assertTrue(bool(get_machine_id()))
Пример #8
0
 def test_get_machine_id_settings(self):
     self.assertEqual('test-ptop', get_machine_id())
Пример #9
0
 def test_get_machine_id(self):
     # since this is machine dependent just ensure that this returns something
     # and doesn't crash
     self.assertTrue(bool(get_machine_id()))
Пример #10
0
 def get_legacy_name(cls):
     return "%s.%s.%s.%s" % (
         cls.__module__, cls.__name__, cls.get_unique_id(), get_machine_id())
Пример #11
0
 def get_legacy_name(cls):
     return "%s.%s.%s" % (cls._get_base_name(), cls.__name__, get_machine_id())