def collapse(ip, port, clusterId, n):
    """
    tell the node listening on (ip, port) to collapse, and keep n tlog files
    @type ip: string
    @type port: int
    @type n: int > 0
    @type clusterId:string
    @param clusterId: must match cluster id of the node
    """
    if n < 1:
        raise ValueError("%i is not acceptable" % n)
    s = RCP.make_socket(ip, port)

    try:
        RCP._prologue(clusterId, s)
        cmd  = RCP._int_to(RCP._COLLAPSE_TLOGS | RCP._MAGIC)
        cmd += RCP._int_to(n)
        s.send(cmd)
        RCP.check_error_code(s)
        collapse_count = RCP._receive_int(s)
        logging.debug("collapse_count = %i", collapse_count)
        for i in range(collapse_count):
            logging.debug("i=%i", i)
            RCP.check_error_code(s)
            took = RCP._receive_int64(s)
            logging.info("took %i", took)
    finally:
        s.close()
def collapse(ip, port, clusterId, n):
    """
    tell the node listening on (ip, port) to collapse, and keep n tlog files
    @type ip: string
    @type port: int
    @type n: int > 0
    @type clusterId:string
    @param clusterId: must match cluster id of the node
    """
    if n < 1:
        raise ValueError("%i is not acceptable" % n)
    s = RCP.make_socket(ip, port)

    try:
        RCP._prologue(clusterId, s)
        cmd = RCP._int_to(RCP._COLLAPSE_TLOGS | RCP._MAGIC)
        cmd += RCP._int_to(n)
        s.send(cmd)
        RCP.check_error_code(s)
        collapse_count = RCP._receive_int(s)
        logging.debug("collapse_count = %i", collapse_count)
        for i in range(collapse_count):
            logging.debug("i=%i", i)
            RCP.check_error_code(s)
            took = RCP._receive_int64(s)
            logging.info("took %i", took)
    finally:
        s.close()