Esempio n. 1
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. 2
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. 3
0
def create_topic(request):
    name = request.POST.get('name')
    partitions = request.POST.get('partitions', 1)
    replication_factor = request.POST.get('replication_factor', 1)

    status = KafkaApi().create_topic(name, partitions, replication_factor)

    return JsonResponse({
        'status': status,
        'topic': {
            'name': name,
            'partitions': partitions,
            'replication_factor': replication_factor
        }
    })
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"]