예제 #1
0
파일: query.py 프로젝트: hgdeoro/daedalus
def query(pool):
    cf_logs = ColumnFamily(pool, CF_LOGS)
    row_key = ymd_from_epoch()
    try:
        cf_logs.get(row_key, column_count=0)
    except NotFoundException:
        # FIXME: this is extremely inefficient!
        row_key = cf_logs.get_range().next()[0]

    logging.info("-" * 120)  # ------------------------------
    logging.info("Querying for key %s", row_key)
    logging.info("-" * 120)  # ------------------------------
    count = 20
    for k, v in cf_logs.get(row_key, column_reversed=True).iteritems():  # @UnusedVariable
        logging.info(v)
        count -= 1
        if count == 0:
            break
    del cf_logs

    logging.info("-" * 120)  # ------------------------------
    cf_logs_by_app = ColumnFamily(pool, CF_LOGS_BY_APP)
    row_key = EXAMPLE_APPS[0]
    logging.info("Querying for key %s", row_key)
    logging.info("-" * 120)  # ------------------------------
    count = 20
    for k, v in cf_logs_by_app.get(row_key, column_reversed=True).iteritems():  # @UnusedVariable
        logging.info(v)
        count -= 1
        if count == 0:
            break
    del cf_logs_by_app

    logging.info("-" * 120)  # ------------------------------
    cf_logs_by_host = ColumnFamily(pool, CF_LOGS_BY_HOST)
    row_key = EXAMPLE_HOSTS[0]
    logging.info("Querying for key %s", row_key)
    logging.info("-" * 120)  # ------------------------------
    count = 20
    for k, v in cf_logs_by_host.get(row_key, column_reversed=True).iteritems():  # @UnusedVariable
        logging.info(v)
        count -= 1
        if count == 0:
            break
    del cf_logs_by_host

    logging.info("-" * 120)  # ------------------------------
    cf_logs_by_severity = ColumnFamily(pool, CF_LOGS_BY_SEVERITY)
    row_key = "WARN"
    logging.info("Querying for key %s", row_key)
    logging.info("-" * 120)  # ------------------------------
    count = 20
    for k, v in cf_logs_by_severity.get(row_key, column_reversed=True).iteritems():  # @UnusedVariable
        logging.info(v)
        count -= 1
        if count == 0:
            break
    del cf_logs_by_severity
예제 #2
0
def query(pool):
    cf_logs = ColumnFamily(pool, CF_LOGS)
    row_key = ymd_from_epoch()
    try:
        cf_logs.get(row_key, column_count=0)
    except NotFoundException:
        # FIXME: this is extremely inefficient!
        row_key = cf_logs.get_range().next()[0]

    logging.info("-" * 120) # ------------------------------
    logging.info("Querying for key %s", row_key)
    logging.info("-" * 120) # ------------------------------
    count = 20
    for k, v in cf_logs.get(row_key, column_reversed=True).iteritems(): #@UnusedVariable
        logging.info(v)
        count -= 1
        if count == 0:
            break
    del cf_logs

    logging.info("-" * 120) # ------------------------------
    cf_logs_by_app = ColumnFamily(pool, CF_LOGS_BY_APP)
    row_key = EXAMPLE_APPS[0]
    logging.info("Querying for key %s", row_key)
    logging.info("-" * 120) # ------------------------------
    count = 20
    for k, v in cf_logs_by_app.get(row_key, column_reversed=True).iteritems(): #@UnusedVariable
        logging.info(v)
        count -= 1
        if count == 0:
            break
    del cf_logs_by_app

    logging.info("-" * 120) # ------------------------------
    cf_logs_by_host = ColumnFamily(pool, CF_LOGS_BY_HOST)
    row_key = EXAMPLE_HOSTS[0]
    logging.info("Querying for key %s", row_key)
    logging.info("-" * 120) # ------------------------------
    count = 20
    for k, v in cf_logs_by_host.get(row_key, column_reversed=True).iteritems(): #@UnusedVariable
        logging.info(v)
        count -= 1
        if count == 0:
            break
    del cf_logs_by_host

    logging.info("-" * 120) # ------------------------------
    cf_logs_by_severity = ColumnFamily(pool, CF_LOGS_BY_SEVERITY)
    row_key = 'WARN'
    logging.info("Querying for key %s", row_key)
    logging.info("-" * 120) # ------------------------------
    count = 20
    for k, v in cf_logs_by_severity.get(row_key, column_reversed=True).iteritems(): #@UnusedVariable
        logging.info(v)
        count -= 1
        if count == 0:
            break
    del cf_logs_by_severity
예제 #3
0
        def _compute_count(a_range):
            column_start = convert_time_to_uuid(a_range[0], lowest_val=True)
            # start_datetime = utc_timestamp2datetime(a_range[0])
            column_finish = convert_time_to_uuid(a_range[1], lowest_val=False)
            # end_datetime = utc_timestamp2datetime(a_range[1])
            row_key = ymd_from_epoch(float(a_range[0]))
            count = self._get_cf_logs().get_count(row_key,
                                                  column_start=column_start,
                                                  column_finish=column_finish)

            return count  # to be used by `_json_cache()`
예제 #4
0
파일: storage.py 프로젝트: hgdeoro/daedalus
        def _compute_count(a_range):
            column_start = convert_time_to_uuid(a_range[0], lowest_val=True)
            # start_datetime = utc_timestamp2datetime(a_range[0])
            column_finish = convert_time_to_uuid(a_range[1], lowest_val=False)
            # end_datetime = utc_timestamp2datetime(a_range[1])
            row_key = ymd_from_epoch(float(a_range[0]))
            count = self._get_cf_logs().get_count(
                row_key,
                column_start=column_start,
                column_finish=column_finish)

            return count # to be used by `_json_cache()`