Example #1
0
        found_stale_content = \
            _check_stale_file_content(existing_content, args.file,
                                      zk_data, mode)

    log.info("Generating file %s with the data from zookeeper..." %
             (args.file))

    tmp_dir = tempfile.gettempprefix()
    tmp_filename = os.path.join('/', tmp_dir, args.file.replace("/", "_"))

    try:
        with open(tmp_filename, 'w') as f:
            f.write(zk_data)
    except:
        log.exception("Failed to generate file %s from config in zookeeper. "
                      "Data to write: %s" % (tmp_filename, zk_data))
        exit(_UNHANDLED_EXCPETION)

    shutil.copy2(tmp_filename, args.file)
    log.info("File is generated.")

    # Report the file modification time.
    report_file_modification(mode, args.path, time.time())

    if found_stale_content:
        exit(_STALE_LOCAL_FILE_CODE)


if __name__ == "__main__":
    initialize_logger(logger_filename="zk_download_data.log")
    main()
Example #2
0
@app.route("/admin/query_skip_check_flappy_serversets")
def query_skip_check_flappy_serversets():
    return json.dumps(list(_SKIP_FLAPPY_CHECK_SERVERSETS))


@app.route("/admin/watched_metaconfigs")
def query_watched_metaconfigs():
    return json.dumps(list(_WATCHED_METACONFIGS))


@app.route("/admin/watched_dependencies")
def query_watched_dependencies():
    return json.dumps(list(_WATCHED_DEPENDENCIES))


# The following variables and apis are only used for unit testing.
test_notification_count = 0


@app.route("/admin/report_unittest_notification")
def report_unittest_notification():
    global test_notification_count
    test_notification_count += 1
    return ""


if __name__ == "__main__":
    initialize_logger(logger_filename="zk_update_monitor.log")
    main()
Example #3
0
        found_stale_content = \
            _check_stale_file_content(existing_content, args.file,
                                      zk_data, mode)

    log.info("Generating file %s with the data from zookeeper..."
             % (args.file))

    tmp_dir = tempfile.gettempprefix()
    tmp_filename = os.path.join('/', tmp_dir, args.file.replace("/", "_"))

    try:
        with open(tmp_filename, 'w') as f:
            f.write(zk_data)
    except:
        log.exception("Failed to generate file %s from config in zookeeper. "
                      "Data to write: %s" % (tmp_filename, zk_data))
        exit(_UNHANDLED_EXCPETION)

    shutil.copy2(tmp_filename, args.file)
    log.info("File is generated.")

    # Report the file modification time.
    report_file_modification(mode, args.path, time.time())

    if found_stale_content:
        exit(_STALE_LOCAL_FILE_CODE)


if __name__ == "__main__":
    initialize_logger(logger_filename="zk_download_data.log")
    main()
Example #4
0
@app.route("/admin/query_skip_check_flappy_serversets")
def query_skip_check_flappy_serversets():
    return json.dumps(list(_SKIP_FLAPPY_CHECK_SERVERSETS))


@app.route("/admin/watched_metaconfigs")
def query_watched_metaconfigs():
    return json.dumps(list(_WATCHED_METACONFIGS))


@app.route("/admin/watched_dependencies")
def query_watched_dependencies():
    return json.dumps(list(_WATCHED_DEPENDENCIES))


# The following variables and apis are only used for unit testing.
test_notification_count = 0


@app.route("/admin/report_unittest_notification")
def report_unittest_notification():
    global test_notification_count
    test_notification_count += 1
    return ""


if __name__ == "__main__":
    initialize_logger(logger_filename="zk_update_monitor.log")
    main()