Ejemplo n.º 1
0
        void run() {
            // Insert enough documents that counting them will exceed the iteration threshold
            // to trigger a yield.
            for( int i = 0; i < 1000; ++i ) {
                insert( BSON( "a" << 1 ) );
            }
            
            // Call runCount() under a read lock.
            dbtemprelease release;
            Client::ReadContext ctx( ns() );

            int numYieldsBeforeCount = numYields();
            
            string err;
            int errCode;
            ASSERT_EQUALS( 1000, runCount( ns(), countCommand( BSON( "a" << 1 ) ), err, errCode ) );
            ASSERT_EQUALS( "", err );

            int numYieldsAfterCount = numYields();
            int numYieldsDuringCount = numYieldsAfterCount - numYieldsBeforeCount;

            // The runCount() function yieled.
            ASSERT_NOT_EQUALS( 0, numYieldsDuringCount );
            ASSERT( 0 < numYieldsDuringCount );
        }
Ejemplo n.º 2
0
void AsdkCommandReactor::commandWillStart(const char* cmdStr)
{
    countCommand(cmdStr);
}
Ejemplo n.º 3
0
extern "C" void StartCountingCmd(const char* cmdStr)
{
    countCommand(cmdStr);
}
bool NexusLogParser::parseLog(ClvDataAccessor *writer, QString logFilePath, int startProgress, int endProgress){
    // progress
    int numOfCommands = countCommand(logFilePath);
    int diffOfProgress = endProgress - startProgress;
    int progressAfterCounting = startProgress + diffOfProgress * PROGRESS_COMMAND_COUNT_RATIO;
    double stepValue = diffOfProgress * (1 - PROGRESS_COMMAND_COUNT_RATIO);
    setValueOnProgressDialog(progressAfterCounting);

    // setup
    QFileInfo info(logFilePath);
    QString fileName = info.fileName();
    QFile file(logFilePath);
    file.open(QIODevice::ReadOnly);
    QRegExp regex("`(.*)`");
    QString line;
    QString command = "";
    QByteArray buffer;
    int counter = 0;

    // parse each line
    while(!file.atEnd()){
        line = file.readLine();

        // command
        if(regex.indexIn(line) > -1){
            if(command != ""){ // not first command
                QByteArray compressed = qCompress(buffer, 5);
                writer->writeCommand(command, command, "root", "", fileName, compressed);
                if(false){
                    qDebug() << command;
                    qDebug() << "row       : " << buffer.length();
                    qDebug() << "compressed: " << compressed.length();
                }
            }

            // clears old command's buffer for buffering next command.
            command = regex.cap(1).trimmed();
            buffer.clear();

            // progress
            counter++;
            if(counter % 10 == 0){
                int value = progressAfterCounting + (stepValue * counter / numOfCommands);
                setValueOnProgressDialog(value);
            }
        }

        // buffer both command and contents line
        buffer.append(line);
    }

    // write last command
    if(command != ""){
        QByteArray compressed = qCompress(buffer, 5);
        writer->writeCommand(command, command, "root", "", fileName, compressed);
        if(false){
            qDebug() << command;
            qDebug() << "row       : " << buffer.length();
            qDebug() << "compressed: " << compressed.length();
        }
        buffer.clear();
        compressed.clear();
    }

    return true;
}