Exemplo n.º 1
0
def RunOneTypeNodeSetup(conn, svrAddr, svrPortBegin, isMaster, ycsbHome,
                        bindingName, procPriority, outDir, attemptNum,
                        numOfNode, workload, dist, recCount, maxOp, maxTime,
                        threadCountList, opPerSessList, targetThrpList):

    UpdateClientConfig(numOfNode, svrAddr, svrPortBegin)

    #----- Setup server nodes
    if isMaster:
        #Tell server we have test to perform
        st.SocketSendPack(conn, 'Test')

        #Tell server how many node we need
        print('INFO:', 'Telling server how many node we need...')
        SendNumOfNode(conn, numOfNode)

    #----- Wait for server to complete the setup process
    print('INFO:', 'Waiting for server to complete the setup process...')
    clientSignal = st.SocketRecvPack(conn)
    if clientSignal != 'R':
        raise RuntimeError('Server error during setup process.')

    #----- Load database:
    print('INFO:', 'Loading database...')
    if isMaster:
        CreateDirs(os.path.join(outDir, 'load'))
        loadThreadCount = threadCountList[len(threadCountList) - 1]
        loadMaxOpPerTicket = opPerSessList[len(opPerSessList) - 1]

        outPathBase = 'Attempt_' + '{0:02d}'.format(
            attemptNum) + '_' + '{0:02d}'.format(
                numOfNode) + '_' + '{0:02d}'.format(
                    loadThreadCount) + '_' + str(loadMaxOpPerTicket) + '_-1'
        loadOutPathBase = os.path.join(outDir, 'load', outPathBase)
        LoadDatabase(conn, ycsbHome, bindingName, procPriority,
                     loadOutPathBase, workload, dist, recCount, numOfNode,
                     loadThreadCount, loadMaxOpPerTicket)
    else:
        st.SocketSendPack(conn, 'Start')
        if st.SocketRecvPack(conn) != 'Proceed':
            raise RuntimeError('Server respond error.')
        st.SocketSendPack(conn, 'End')
        st.SocketRecvPack(conn)

    #----- Run transactions:
    print('INFO:', 'Begin testing...')
    for threadCount in threadCountList:
        for maxOpPerTicket in opPerSessList:
            for targetThrp in targetThrpList:
                outPathBase = 'Attempt_' + '{0:02d}'.format(attemptNum) + '_' + '{0:02d}'.format(numOfNode) + '_' + '{0:02d}'.format(threadCount) \
                   + '_' + str(maxOpPerTicket) + '_' + str(targetThrp)
                outPathBase = os.path.join(outDir, outPathBase)
                RunTest(conn, ycsbHome, bindingName, procPriority, outPathBase,
                        workload, dist, recCount, numOfNode, maxOp, maxTime,
                        threadCount, maxOpPerTicket, targetThrp)

    if isMaster:
        st.SocketSendPack(conn, 'Finished')

    print('INFO:', 'Finished test with', numOfNode, 'nodes.')
Exemplo n.º 2
0
def RunTest(conn, ycsbHome, bindingName, procPriority, outPathBase, workload,
            dist, recCount, numOfNode, maxOp, maxTime, threadCount,
            maxOpPerTicket, targetThrp):

    print('INFO:', 'Running the test...')

    #output report path
    outRepPath = outPathBase + '.txt'
    if os.path.exists(outRepPath):
        raise FileExistsError('The output report file, with path ' +
                              outRepPath + ', already exist!')

    #output raw data path
    outRawPath = outPathBase + '.ycsb.csv'
    if os.path.exists(outRawPath):
        raise FileExistsError('The output report file, with path ' +
                              outRawPath + ', already exist!')

    #output server sys status data path
    outSvrStatPath = outPathBase + '.SvrStat.csv'
    if os.path.exists(outSvrStatPath):
        raise FileExistsError('The output report file, with path ' +
                              outSvrStatPath + ', already exist!')

    #Construct command
    options = []
    options += ['-P', GetYcsbWorkloadPath(ycsbHome, workload)]
    options += ['-threads', str(threadCount)]
    options += ['-target', str(targetThrp)] if targetThrp >= 0 else []

    options += ['-p', ('recordcount=' + str(recCount * numOfNode))]
    options += ['-p', ('requestdistribution=' + dist)]
    options += ['-p', ('operationcount=' + str(maxOp))]
    options += ['-p', ('maxexecutiontime=' + str(maxTime))]
    options += ['-p', ('measurementtype=' + 'raw')]
    options += ['-p', ('measurement.raw.output_file=' + outRawPath)]

    command = [
        'cmd.exe', '/c',
        os.path.join(ycsbHome, 'bin', 'ycsb'), 'run', bindingName
    ]
    command += options
    command += ['>', outRepPath]

    print('INFO:', 'Running test with maxOpPerTicket =', maxOpPerTicket)
    SetJavaSysProperty(maxOpPerTicket)

    st.SocketSendPack(conn, 'Start')
    if st.SocketRecvPack(conn) != 'Proceed':
        raise RuntimeError('Server respond error.')
    ExecuteYcsbTestCommand(command, procPriority)
    st.SocketSendPack(conn, 'End')

    WriteStrToFile(outSvrStatPath, st.SocketRecvPack(conn))

    WaitFor(5)
Exemplo n.º 3
0
def ListenToClients(connArr, targetBin, targetAffFullList, targetPriority,
                    targetPortStart, svcBinNameList, svcAffFullList,
                    svcAffMode, svcPriority):

    clientSignal = st.SocketRecvPack(connArr[0])

    while clientSignal == 'Test':
        RunOneTestCase(connArr, targetBin, targetAffFullList, targetPriority,
                       targetPortStart, svcBinNameList, svcAffFullList,
                       svcAffMode, svcPriority)
        clientSignal = st.SocketRecvPack(connArr[0])
Exemplo n.º 4
0
def SendNumOfNode(conn, numOfNode):

    st.SocketSend_uint64(conn, numOfNode)

    if st.SocketRecvPack(conn) != 'OK':
        raise RuntimeError('Server doesn\'t accept the numOfNode=' +
                           numOfNode + ' !')
Exemplo n.º 5
0
def GetClientsStartEndRound(connArr, pList, targetAffList, svcAffList):

    for conn in connArr:
        clientSignal = st.SocketRecvPack(conn)
        # Any non-"Start" reply will terminate the test
        if clientSignal != 'Start':
            return False

    sysStatRecorder = pct.SysStatusRecorderThread(pList,
                                                  sum(targetAffList, []),
                                                  svcAffList, 0.1)  # Start
    sysStatRecorder.start()

    for conn in connArr:
        st.SocketSendPack(conn, 'Proceed')

    #----- Master client:
    clientSignal = st.SocketRecvPack(connArr[0])
    #Any signal will be treated as end.
    rec = sysStatRecorder.StopAndGetResult()  # End

    #----- sub-clients:
    for i in range(1, len(connArr)):
        clientSignal = st.SocketRecvPack(connArr[i])
        #Any signal will be treated as end.

    #----- Master client:
    recCsvStr = pct.ConvertRecord2CsvStr(rec, pList)
    #Send CSV string
    st.SocketSendPack(connArr[0], recCsvStr)

    #----- sub-clients:
    for i in range(1, len(connArr)):
        st.SocketSendPack(connArr[i], '')

    return True