Exemplo n.º 1
0
void
T3_Callback_1(int result, NdbConnection * pCON, void * threadData){
  ThreadData * td = (ThreadData *)threadData;
  DEBUG3("T3(%.*s, %.2d): - Callback 1", SUBSCRIBER_NUMBER_LENGTH, 
	 td->transactionData.number, 
	 td->transactionData.server_id);

  if (result == -1) {
    CHECK_ALLOWED_ERROR("T3-1: execute", td, pCON->getNdbError());
    td->pNDB->closeTransaction(pCON);
    start_T3(td->pNDB, td, stat_async);
    return;
  }//if

  NdbOperation * MyOp = pCON->getNdbOperation(GROUP_TABLE);
  CHECK_NULL(MyOp, "T3-2: getNdbOperation", td,
	     pCON->getNdbError());
    
  MyOp->readTuple();
  MyOp->equal(IND_GROUP_ID,
	      (char*)&td->transactionData.group_id);
  MyOp->getValue(IND_GROUP_ALLOW_READ, 
		 (char *)&td->transactionData.permission);
  if (stat_async == 1) {
    pCON->executeAsynchPrepare( NoCommit , T3_Callback_2, td);
  } else {
    int result = pCON->execute( NoCommit );
    T3_Callback_2(result, pCON, (void*)td);
    return;
  }//if
}
Exemplo n.º 2
0
static
void 
doTransaction_T3(Ndb * pNDB, ThreadData * td, int async)
{
  SessionElement  *se;
  
  /*----------------*/
  /* Init arguments */
  /*----------------*/
  se = getNextSession(&td->generator.activeSessions);
  if( se ) {
    strcpy(td->transactionData.number, se->subscriberNumber);
    td->transactionData.server_id = se->serverId;
    td->transactionData.sessionElement = 1;
  } else {
    getRandomSubscriberNumber(td->transactionData.number);
    getRandomServerId(&td->transactionData.server_id);
    td->transactionData.sessionElement = 0;
  }
  
  td->transactionData.server_bit = (1 << td->transactionData.server_id);

  /*-----------------*/
  /* Run transaction */
  /*-----------------*/
  td->runState = Running;
  td->generator.transactions[2].startLatency();
  start_T3(pNDB, td, async);
}
Exemplo n.º 3
0
void
T3_Callback_1(int result, NdbConnection * pCON, void * threadData) {
    ThreadData * td = (ThreadData *)threadData;
    DEBUG3("T3(%.*s, %.2d): - Callback 1", SUBSCRIBER_NUMBER_LENGTH,
           td->transactionData.number,
           td->transactionData.server_id);

    if (result == -1) {
        CHECK_ALLOWED_ERROR("T3-1: execute", td, pCON->getNdbError());
        td->pNDB->closeTransaction(pCON);
        start_T3(td->pNDB, td, stat_async);
        return;
    }//if

    const NdbOperation* op= NULL;

    if (td->ndbRecordSharedData)
    {
        char* rowPtr= (char*) &td->transactionData;
        const NdbRecord* record= td->ndbRecordSharedData->
                                 groupTableAllowReadNdbRecord;
        Uint32 m=0;
        unsigned char* mask= (unsigned char*) &m;

        SET_MASK(mask, IND_GROUP_ALLOW_READ);

        op= pCON->readTuple(record, rowPtr, record, rowPtr,
                            NdbOperation::LM_Read, mask);
    }
    else
    {
        NdbOperation * MyOp = pCON->getNdbOperation(GROUP_TABLE);
        op= MyOp;
        CHECK_NULL(MyOp, "T3-2: getNdbOperation", td,
                   pCON->getNdbError());

        MyOp->readTuple();
        MyOp->equal(IND_GROUP_ID,
                    (char*)&td->transactionData.group_id);
        MyOp->getValue(IND_GROUP_ALLOW_READ,
                       (char *)&td->transactionData.permission);
    }

    if (stat_async == 1) {
        pCON->executeAsynchPrepare( NoCommit , T3_Callback_2, td);
    } else {
        int result = pCON->execute( NoCommit );
        T3_Callback_2(result, pCON, (void*)td);
        return;
    }//if
}
Exemplo n.º 4
0
void
T3_Callback_3(int result, NdbConnection * pCON, void * threadData){
  ThreadData * td = (ThreadData *)threadData;  
  DEBUG3("T3(%.*s, %.2d): - Completing", SUBSCRIBER_NUMBER_LENGTH, 
	 td->transactionData.number, 
	 td->transactionData.server_id);
  
  if (result == -1) {
    CHECK_ALLOWED_ERROR("T3-3: Commit", td, pCON->getNdbError());
    td->pNDB->closeTransaction(pCON);
    start_T3(td->pNDB, td, stat_async);
    return;
  }//if
  td->pNDB->closeTransaction(pCON);
  complete_T3(td);
}
Exemplo n.º 5
0
void
T3_Callback_2(int result, NdbConnection * pCON, void * threadData){
  ThreadData * td = (ThreadData *)threadData;
  
  if (result == -1) {
    CHECK_ALLOWED_ERROR("T3-2: execute", td, pCON->getNdbError());
    td->pNDB->closeTransaction(pCON);
    start_T3(td->pNDB, td, stat_async);
    return;
  }//if
  
  Uint32 permission = td->transactionData.permission;
  Uint32 sessions   = td->transactionData.sessions;
  Uint32 server_bit = td->transactionData.server_bit;

  if(((permission & server_bit) == server_bit) &&
     ((sessions   & server_bit) == server_bit)){
    
    memcpy(td->transactionData.suffix,
	   &td->transactionData.number[SFX_START],
	   SUBSCRIBER_NUMBER_SUFFIX_LENGTH);
    DEBUG5("T3(%.*s, %.2d): - Callback 2 - reading(%.*s)", 
	   SUBSCRIBER_NUMBER_LENGTH, 
	   td->transactionData.number, 
	   td->transactionData.server_id,
	   SUBSCRIBER_NUMBER_SUFFIX_LENGTH, 
	   td->transactionData.suffix);
    
    /* Operation 3 */
    NdbOperation * MyOp = pCON->getNdbOperation(SESSION_TABLE);
    CHECK_NULL(MyOp, "T3-3: getNdbOperation", td,
	       pCON->getNdbError());
    
    MyOp->simpleRead();
    MyOp->equal(IND_SESSION_SUBSCRIBER,
		(char*)td->transactionData.number);
    MyOp->equal(IND_SESSION_SERVER,
		(char*)&td->transactionData.server_id);
    MyOp->getValue(IND_SESSION_DATA, 
		   (char *)td->transactionData.session_details);
    
    /* Operation 4 */
    MyOp = pCON->getNdbOperation(SERVER_TABLE);
    CHECK_NULL(MyOp, "T3-4: getNdbOperation", td,
	       pCON->getNdbError());
    
    MyOp->interpretedUpdateTuple();
    MyOp->equal(IND_SERVER_ID,
		(char*)&td->transactionData.server_id);
    MyOp->equal(IND_SERVER_SUBSCRIBER_SUFFIX,
		(char*)td->transactionData.suffix);
    MyOp->incValue(IND_SERVER_READS, (uint32)1);
    td->transactionData.branchExecuted = 1;
  } else {
    DEBUG3("T3(%.*s, %.2d): - Callback 2 - no read",
	   SUBSCRIBER_NUMBER_LENGTH, 
	   td->transactionData.number, 
	   td->transactionData.server_id);
    td->transactionData.branchExecuted = 0;
  }
  if (stat_async == 1) {
    pCON->executeAsynchPrepare( Commit , T3_Callback_3, td);
  } else {
    int result = pCON->execute( Commit );
    T3_Callback_3(result, pCON, (void*)td);
    return;
  }//if
}
Exemplo n.º 6
0
void
T3_Callback_2(int result, NdbConnection * pCON, void * threadData) {
    ThreadData * td = (ThreadData *)threadData;

    if (result == -1) {
        CHECK_ALLOWED_ERROR("T3-2: execute", td, pCON->getNdbError());
        td->pNDB->closeTransaction(pCON);
        start_T3(td->pNDB, td, stat_async);
        return;
    }//if

    Uint32 permission = td->transactionData.permission;
    Uint32 sessions   = td->transactionData.sessions;
    Uint32 server_bit = td->transactionData.server_bit;

    if(((permission & server_bit) == server_bit) &&
            ((sessions   & server_bit) == server_bit)) {

        memcpy(td->transactionData.suffix,
               &td->transactionData.number[SFX_START],
               SUBSCRIBER_NUMBER_SUFFIX_LENGTH);
        DEBUG5("T3(%.*s, %.2d): - Callback 2 - reading(%.*s)",
               SUBSCRIBER_NUMBER_LENGTH,
               td->transactionData.number,
               td->transactionData.server_id,
               SUBSCRIBER_NUMBER_SUFFIX_LENGTH,
               td->transactionData.suffix);

        /* Operations 3 + 4 */
        if (td->ndbRecordSharedData)
        {
            /* Op 3 */
            char* rowPtr= (char*) &td->transactionData;
            const NdbRecord* record= td->ndbRecordSharedData->
                                     sessionTableNdbRecord;
            Uint32 m=0;
            unsigned char* mask= (unsigned char*) &m;

            SET_MASK(mask, IND_SESSION_DATA);

            const NdbOperation* MyOp = pCON->readTuple(record, rowPtr, record, rowPtr,
                                       NdbOperation::LM_SimpleRead,
                                       mask);
            CHECK_NULL((void*) MyOp, "T3-3: readTuple", td,
                       pCON->getNdbError());

            /* Op 4 */
            record= td->ndbRecordSharedData->
                    serverTableNdbRecord;
            m= 0;

            /* Attach interpreted program */
            NdbOperation::OperationOptions opts;
            opts.optionsPresent= NdbOperation::OperationOptions::OO_INTERPRETED;
            opts.interpretedCode= td->ndbRecordSharedData->incrServerReadsProg;

            MyOp= pCON->updateTuple(record, rowPtr, record, rowPtr, mask,
                                    &opts,
                                    sizeof(opts));
            CHECK_NULL((void*) MyOp, "T3-3: updateTuple", td,
                       pCON->getNdbError());
        }
        else
        {
            NdbOperation * MyOp = pCON->getNdbOperation(SESSION_TABLE);
            CHECK_NULL(MyOp, "T3-3: getNdbOperation", td,
                       pCON->getNdbError());

            MyOp->simpleRead();
            MyOp->equal(IND_SESSION_SUBSCRIBER,
                        (char*)td->transactionData.number);
            MyOp->equal(IND_SESSION_SERVER,
                        (char*)&td->transactionData.server_id);
            MyOp->getValue(IND_SESSION_DATA,
                           (char *)td->transactionData.session_details);

            MyOp = pCON->getNdbOperation(SERVER_TABLE);
            CHECK_NULL(MyOp, "T3-4: getNdbOperation", td,
                       pCON->getNdbError());

            MyOp->interpretedUpdateTuple();
            MyOp->equal(IND_SERVER_ID,
                        (char*)&td->transactionData.server_id);
            MyOp->equal(IND_SERVER_SUBSCRIBER_SUFFIX,
                        (char*)td->transactionData.suffix);
            MyOp->incValue(IND_SERVER_READS, (uint32)1);
        }

        td->transactionData.branchExecuted = 1;
    } else {
        DEBUG3("T3(%.*s, %.2d): - Callback 2 - no read",
               SUBSCRIBER_NUMBER_LENGTH,
               td->transactionData.number,
               td->transactionData.server_id);
        td->transactionData.branchExecuted = 0;
    }
    if (stat_async == 1) {
        pCON->executeAsynchPrepare( Commit , T3_Callback_3, td);
    } else {
        int result = pCON->execute( Commit );
        T3_Callback_3(result, pCON, (void*)td);
        return;
    }//if
}