コード例 #1
0
ファイル: st_flex.py プロジェクト: ffilz/pynfs
def _LayoutStats(t, env, stats):
    '''Loop over the provided layoutstats, sending them on in time
    '''
    sess = env.c1.new_pnfs_client_session(env.testname(t))

    # Create the file
    res = create_file(sess, env.testname(t))
    check(res)
    fh = res.resarray[-1].object
    open_stateid = res.resarray[-2].stateid
    lo_stateid = open_stateid

    ops = [op.putfh(fh),
           op.layoutget(False, LAYOUT4_FLEX_FILES,
                        LAYOUTIOMODE4_RW,
                        0, 0xffffffffffffffff, 8192, lo_stateid, 0xffff)]
    res = sess.compound(ops)
    check(res)
    lo_stateid = res.resarray[-1].logr_stateid
    check_seqid(lo_stateid, 1)

    layout = res.resarray[-1].logr_layout[-1]
    p = FlexUnpacker(layout.loc_body)
    opaque = p.unpack_ff_layout4()
    p.done()

    stats_hint = opaque.ffl_stats_collect_hint

    # Assume one mirror/storage device
    ds = opaque.ffl_mirrors[-1].ffm_data_servers[-1]

    deviceid = ds.ffds_deviceid

    ops = [op.putfh(fh),
           op.getdeviceinfo(deviceid, LAYOUT4_FLEX_FILES, 0xffffffff, 0)]
    res = sess.compound(ops)
    check(res)

    gda = res.resarray[-1].gdir_device_addr

    p = FlexUnpacker(gda.da_addr_body)
    da = p.unpack_ff_device_addr4()
    p.done()

    rd_io = io_info4()
    wr_io = io_info4()

    rd_lat = ff_io_latency4()
    wr_lat = ff_io_latency4()

    for s in stats:
        dur = get_nfstime(s[1])

        # Did not capture these in the gathered traces
        offset = 0
        file_length = 0xffffffffffffffff
        rd_io.ii_count = 0
        rd_io.ii_bytes = 0
        wr_io.ii_count = 0
        wr_io.ii_bytes = 0

        rd_lat.ffil_ops_requested = s[5]
        rd_lat.ffil_bytes_requested = s[4]
        rd_lat.ffil_ops_completed = s[6]
        rd_lat.ffil_bytes_completed = s[2]
        rd_lat.ffil_bytes_not_delivered = s[3]
        rd_lat.ffil_total_busy_time = get_nfstime(s[7])
        rd_lat.ffil_aggregate_completion_time = get_nfstime(s[8])
        wr_lat.ffil_ops_requested = s[12]
        wr_lat.ffil_bytes_requested = s[11]
        wr_lat.ffil_ops_completed = s[13]
        wr_lat.ffil_bytes_completed = s[9]
        wr_lat.ffil_bytes_not_delivered = s[10]
        wr_lat.ffil_total_busy_time = get_nfstime(s[14])
        wr_lat.ffil_aggregate_completion_time = get_nfstime(s[15])

        sleeper = s[0]
        env.sleep(sleeper)
        fflu = ff_layoutupdate4(da.ffda_netaddrs[-1], ds.ffds_fh_vers[-1],
                                rd_lat, wr_lat, dur, True)
        p = FlexPacker()
        p.pack_ff_layoutupdate4(fflu)
        lu4 = layoutupdate4(LAYOUT4_FLEX_FILES, p.get_buffer())

        ops = [op.putfh(fh),
               op.layoutstats(offset, file_length, lo_stateid, rd_io, wr_io, deviceid, lu4)]
        res = sess.compound(ops)
        check(res)

    ops = [op.putfh(fh),
           op.layoutreturn(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
                           layoutreturn4(LAYOUTRETURN4_FILE,
                                         layoutreturn_file4(0, 0xffffffffffffffff, lo_stateid, "")))]
    res = sess.compound(ops)
    check(res)
    res = close_file(sess, fh, stateid=open_stateid)
    check(res)
コード例 #2
0
def _LayoutStats(t, env, stats):
    '''Loop over the provided layoutstats, sending them on in time
    '''
    sess = env.c1.new_pnfs_client_session(env.testname(t))

    # Create the file
    res = create_file(sess, env.testname(t))
    check(res)
    fh = res.resarray[-1].object
    open_stateid = res.resarray[-2].stateid
    lo_stateid = open_stateid

    ops = [
        op.putfh(fh),
        op.layoutget(False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_RW, 0,
                     0xffffffffffffffff, 8192, lo_stateid, 0xffff)
    ]
    res = sess.compound(ops)
    check(res)
    lo_stateid = res.resarray[-1].logr_stateid
    check_seqid(lo_stateid, 1)

    layout = res.resarray[-1].logr_layout[-1]
    p = FlexUnpacker(layout.loc_body)
    opaque = p.unpack_ff_layout4()
    p.done()

    stats_hint = opaque.ffl_stats_collect_hint

    # Assume one mirror/storage device
    ds = opaque.ffl_mirrors[-1].ffm_data_servers[-1]

    deviceid = ds.ffds_deviceid

    ops = [
        op.putfh(fh),
        op.getdeviceinfo(deviceid, LAYOUT4_FLEX_FILES, 0xffffffff, 0)
    ]
    res = sess.compound(ops)
    check(res)

    gda = res.resarray[-1].gdir_device_addr

    p = FlexUnpacker(gda.da_addr_body)
    da = p.unpack_ff_device_addr4()
    p.done()

    rd_io = io_info4()
    wr_io = io_info4()

    rd_lat = ff_io_latency4()
    wr_lat = ff_io_latency4()

    for s in stats:
        dur = get_nfstime(s[1])

        # Did not capture these in the gathered traces
        offset = 0
        file_length = 0xffffffffffffffff
        rd_io.ii_count = 0
        rd_io.ii_bytes = 0
        wr_io.ii_count = 0
        wr_io.ii_bytes = 0

        rd_lat.ffil_ops_requested = s[5]
        rd_lat.ffil_bytes_requested = s[4]
        rd_lat.ffil_ops_completed = s[6]
        rd_lat.ffil_bytes_completed = s[2]
        rd_lat.ffil_bytes_not_delivered = s[3]
        rd_lat.ffil_total_busy_time = get_nfstime(s[7])
        rd_lat.ffil_aggregate_completion_time = get_nfstime(s[8])
        wr_lat.ffil_ops_requested = s[12]
        wr_lat.ffil_bytes_requested = s[11]
        wr_lat.ffil_ops_completed = s[13]
        wr_lat.ffil_bytes_completed = s[9]
        wr_lat.ffil_bytes_not_delivered = s[10]
        wr_lat.ffil_total_busy_time = get_nfstime(s[14])
        wr_lat.ffil_aggregate_completion_time = get_nfstime(s[15])

        sleeper = s[0]
        env.sleep(sleeper)
        fflu = ff_layoutupdate4(da.ffda_netaddrs[-1], ds.ffds_fh_vers[-1],
                                rd_lat, wr_lat, dur, True)
        p = FlexPacker()
        p.pack_ff_layoutupdate4(fflu)
        lu4 = layoutupdate4(LAYOUT4_FLEX_FILES, p.get_buffer())

        ops = [
            op.putfh(fh),
            op.layoutstats(offset, file_length, lo_stateid, rd_io, wr_io,
                           deviceid, lu4)
        ]
        res = sess.compound(ops)
        check(res)

    ops = [
        op.putfh(fh),
        op.layoutreturn(
            False, LAYOUT4_FLEX_FILES, LAYOUTIOMODE4_ANY,
            layoutreturn4(
                LAYOUTRETURN4_FILE,
                layoutreturn_file4(0, 0xffffffffffffffff, lo_stateid, "")))
    ]
    res = sess.compound(ops)
    check(res)
    res = close_file(sess, fh, stateid=open_stateid)
    check(res)