コード例 #1
0
def Run(tests, period=YEAR, verbosity="all"):
    """ run and report a set of specified simulations
        tests -- actual list of simulations to run
                (print a header line for each None test)
        period -- simulation period
        verbosity -- output options
    """

    # column headings
    heads = ("storage", "durability",
             "PL(site)", "PL(copies)", "PL(NRE)", "PL(rep)", "loss/PiB")

    # column descriptions
    legends = [
        "storage unit/configuration being modeled",
        "probability of object survival*",
        "probability of loss due to site failures*",
        "probability of loss due to drive failures*",
        "probability of loss due to NREs during recovery*",
        "probability of loss due to replication failure*",
        "expected data loss per Petabyte*"
    ]

    # use the headings to generate a format
    format = ColumnPrint(heads, maxdesc=20)

    # figure out what output he wants
    headings = True
    parms = True
    descr = True
    if verbosity == "parameters":
        descr = False
    elif verbosity == "headings":
        parms = False
        descr = False
    elif verbosity == "data only":
        parms = False
        descr = False
        headings = False

    # introspect the tests to find the disk/raid/rados parameters
    disk = None
    raid = None
    rados = None
    site = None
    multi = None
    for t in tests:
        c = t.__class__.__name__
        if disk is None and "Disk" in c:
            disk = t
        if raid is None and c.startswith("RAID"):
            raid = t
        if rados is None and c.startswith("RADOS"):
            rados = t
        if site is None and c.startswith("Site"):
            site = t
        if multi is None and c.startswith("MultiSite"):
            multi = t

    # find elements that only exist beneath others
    if site is None and multi is not None:
        site = multi.site
    if rados is None and multi is not None:
        rados = multi.rados
    if disk is None and rados is not None:
        disk = rados.disk
    if disk is None and raid is not None:
        disk = raid.disk

    if parms:
        printParms(format, disk, raid, rados, site, multi)

    if descr:
        print ""
        print "Column legends"
        s = format.printTime(period)
        i = 1
        while i <= len(legends):
            l = legends[i - 1]
            if l.endswith('*'):
                print "\t%d %s (per %s)" % (i, l, s)
            else:
                print "\t%d %s" % (i, l)
            i += 1

    if headings:
        format.printHeadings()

    # expected data loss after drive failures
    for t in tests:
        if t is None:
            format.printHeadings()
            continue

        # calculate the renderable reliabilities and durability
        s = list()
        t.compute(period=period)
        s.append(t.description)                 # description
        s.append(format.printDurability(t.dur))        # durability
        s.append(format.printProbability(t.P_site))    # P(site failure)
        s.append(format.printProbability(t.P_drive))   # P(drive failure)
        s.append(format.printProbability(t.P_nre))     # P(NRE on recovery)
        s.append(format.printProbability(t.P_rep))     # P(replication failure)
        l = (t.P_site * t.L_site) + (t.P_drive * t.L_drive) +\
            (t.P_nre * t.L_nre) + (t.P_rep * t.L_rep)
        s.append(format.printFloat(l * PiB / t.rawsize))   # expected loss/PiB
        format.printLine(s)
コード例 #2
0
ファイル: run.py プロジェクト: markkampe/KeepsOnTickin
def run(models, columns="", verbosity="default",
        capacity=1*PiB, period=1*YEAR):
    """ execute a single model and print out the results
        models -- list of models to be run
        columns -- what optional columns to include
        verbosity -- what kind of output we want
        capacity -- total system capacity (bytes)
        period -- modeled time period (hours)
    """

    # figure out what optional fields to include
    showTr = False     # FIX get from columns
    showBW = False     # FIX get from columns

    # define the column headings
    heads = [
        "configuration", "<p,s>/PiB", "durability", "Ploss"
    ]
    legends = [
        "configuration being modeled",
        "<primaries, secondaries> per petabyte",
        "probability of object survival*",
        "probability of loss*",
    ]

    # consider the optional fields
    if showBW:
        heads.append("BW(recov)")
        legends.append("peak recovery bandwidth")
    if showTr:
        heads.append("T(recov)")
        legends.append("max detect/recovery time")

    # figure out the longest description
    maxlen = len(heads[0])
    for m in models:
        l = len(m.descr)
        if l > maxlen:
            maxlen = l

    format = ColumnPrint(heads, maxdesc=maxlen)

    # figure out what output he wants
    parm1 = True        # basic parameters at front
    descr = True        # descriptions of columns
    headings = True     # column headings
    parms = True        # all parameters for every model
    debug = False       # diagnostic output
    if verbosity == "parameters":   # per-test parameters
        parm1 = False
        descr = False
    elif verbosity == "headings":   # output and headings
        parm1 = False
        parms = False
        descr = False
    elif verbosity == "data":   # minimal - just the output
        parm1 = False
        parms = False
        descr = False
        headings = False
    elif verbosity == "all":    # pretty much everyting
        debug = True
        parm1 = False
    elif verbosity == "debug":  # debug only
        debug = True
        headings = False
        parm1 = False
        parms = False
        descr = False
    else:
        parms = False

    # print out basic parameters (assumed not to change)
    if parm1:
        printParms(models[0], None, None)

    # print out column legends
    if descr:
        print ""
        print "Column legends:"
        s = printTime(period)
        i = 1
        while i <= len(legends):
            l = legends[i - 1]
            if l.endswith('*'):
                print "\t%d %s (per %s)" % (i, l, s)
            else:
                print "\t%d %s" % (i, l)
            i += 1

    # print out column headings
    if headings:
        format.printHeadings()

    for m in models:
        # compute sizes and rates
        sizes = Sizes(m, capacity, debug)
        rates = Rates(m, debug)

        # print out the model parameters
        if parms:
            printParms(m, sizes, rates)

        # compute and print the reliability
        results = Results(m, sizes, rates, period, debug)
        s = list()
        s.append(m.descr)
        if m.symmetric:
            s.append("<%d>" % (sizes.n_primary))
        else:
            s.append("<%d,%d>" % (sizes.n_primary, sizes.n_secondary))
        s.append(printDurability(results.durability))
        s.append(printProbability(results.p_loss))
        bw = max(results.bw_sfail, results.bw_pfail)

        if showBW:
            s.append("n/a" if bw == 0 else printSize(bw, 1000) + "/s")
        if showTr:
            s.append("n/a" if bw == 0 else printFloat(results.Trecov)+"s")
        format.printLine(s)