示例#1
0
文件: cloud.py 项目: piyush76/EMS
def checkSearchStatus(mc,msgSize,msgs,custId,userId,sleepSecs):
    if msgs is not None:
        msgIds = []
        for msg in msgs:    
            msgIds.append(Long(msg.getMessageId()))
    
        if msgSize != len(msgIds):
            print "msgSize != msg array size"
            return None

    isc = IndexSearchConstraint(custId,userId)
    if msgs is not None:
        isc.constrainByStorageIds(msgIds)
    sm = mc.getIndexSearchManager()
    retries = 20
    done = False
    sr = None
    while not done and retries > 0:
        sleep(sleepSecs)
        retries = retries - 1
        
        sr = sm.search('',isc,None,CallerApp.TESTING)
        done = (sr is not None) and (sr.getDocCount() == msgSize)
        if sr is not None:            
            print 'Search found messages: ' + str(sr.getDocCount())

    if not done:
        lastCount = 0
        if sr is not None:
            lastCount = sr.getDocCount()
        print 'Search failed to find messages',lastCount

    return done
示例#2
0
文件: testUtils.py 项目: piyush76/EMS
def checkSearchStatus3(mc,msgs,custid,shouldExist,query):
    print 'checkSearchStatus(',query,')'
    done = False
    msgIds = []
    count = 0
    for msg in msgs:
        print 'Message Id No',count,' ', msg.getMessageId()
        msgIds.append(Long(msg.getMessageId()))
        count = count + 1

    found = 0

    cs = 0
    ce = cs + 200
    if ce > len(msgIds):
        ce = len(msgIds)
    chunk = msgIds[cs:ce]
    cs = ce

    sr = None
    while len(chunk) > 0:
        isc = IndexSearchConstraint(custid,None)
        isc.constrainByStorageIds(chunk)
        sm = mc.getIndexSearchManager()
        retries = 180
        done = False
        while not done and retries > 0:
            sr = sm.search(query,isc,None,CallerApp.TESTING)
            # print 'checkSearchStatus() found',sr.getDocCount()
            if shouldExist:
                done = (sr is not None) and (sr.getDocCount() == len(chunk))
            else:
                done = (sr is not None) and (sr.getDocCount() == 0)
            if not done:
                time.sleep(5)
            retries = retries - 1
            if not done and retries % 12 == 0:
                print 'checkSearchStatus() Chunk',sr.getDocCount(),'of',len(chunk),'Total',found,'of',count

        if sr is not None:
            found = found + sr.getDocCount()
        print 'checkSearchStatus() found',found,'of',count

        if not done:
            return done

        # next chunk
        ce = cs + 200
        if ce > len(msgIds):
            ce = len(msgIds)
        chunk = msgIds[cs:ce]
        cs = ce

    return done
示例#3
0
def getDocuments(ism, isle, storageId, locationId):
    iss = IndexSearchConstraint(None,None)
    iss.constrainByIsland(isle)
    iss.constrainByStorageIds([Long(storageId)])
    iss.setShardConstraint(locationId)
    iss.setOutputFields(['*'])
    qr = ism.search('',iss, None, CallerApp.INTERNAL)
    results = []
    for doc in qr:
        results.append(doc)
    return results