Esempio n. 1
0
def get_topic(name):
    if has_kafka_api():
        pass
    else:
        manager = ManagerApi()
        broker_host = manager.get_kafka_brokers().split(',')[0].split(':')[0]
        return manager.get_kafka_topics(broker_host)[name]
Esempio n. 2
0
def get_topics(user):
    if has_kafka_api():
        return KafkaApi().topics()
    else:
        data = {'snippet': {}, 'database': 'topics'}

        return [
            topic['name']
            for topic in _get_notebook_api(user, connector_id=56).autocomplete(
                **data)['tables_meta'] if not topic['name'].startswith('__')
        ]
Esempio n. 3
0
def get_topics(user):
    if has_kafka_api():
        return KafkaApi().topics()
    else:
        data = {'snippet': {}, 'database': 'topics'}

        interpreter = _get_interpreter_from_dialect('ksql', user)
        api = _get_notebook_api(user, connector_id=interpreter['type'])

        return [
            topic['name'] for topic in api.autocomplete(**data)['tables_meta']
            if not topic['name'].startswith('__')
        ]
Esempio n. 4
0
def get_topics():
    if has_kafka_api():
        return KafkaApi().topics()
    else:
        try:
            manager = ManagerApi()
            broker_host = manager.get_kafka_brokers().split(',')[0].split(
                ':')[0]
            return [
                name
                for name in list(manager.get_kafka_topics(broker_host).keys())
                if not name.startswith('__')
            ]
        except Exception as e:
            return ['user_behavior']
Esempio n. 5
0
def get_topics():
    if has_kafka_api():
        return KafkaApi().topics()
    else:
        try:
            manager = ManagerApi()
            broker_host = manager.get_kafka_brokers().split(',')[0].split(
                ':')[0]
            return [
                name for name in manager.get_kafka_topics(broker_host).keys()
                if not name.startswith('__')
            ]
        except Exception, e:
            print e
            return ["traffic", "hueAccessLogs"]
Esempio n. 6
0
def get_topic_data(user, name):
    if has_kafka_api():
        print(SchemaRegistryApi().subjects())
        print(SchemaRegistryApi().subject(name='Kafka-value'))
        data = {
            'full_headers': [{
                'name': 'message',
                'type': 'string'
            }],
            'rows': [['This is rider 894 and I am at 38.1952, -123.1723'],
                     ['This is rider 98 and I am at 39.2531, -121.9547'],
                     ['This is rider 564 and I am at 22.3431, -111.7670']]
        }
    else:
        from desktop.api_public import _get_interpreter_from_dialect  # Avoid circular import
        interpreter = _get_interpreter_from_dialect('ksql', user)
        api = _get_notebook_api(user, connector_id=interpreter['type'])

        data = api.get_sample_data(snippet={})

    print(data)

    return data