List:Commits« Previous MessageNext Message »
From:Jonas Oreland Date:October 4 2010 2:44pm
Subject:bzr commit into mysql-5.1-telco-7.0-spj branch (jonas:3221)
View as plain text  
#At file:///home/jonas/src/70-spj/ based on revid:jonas@stripped

 3221 Jonas Oreland	2010-10-04 [merge]
      ndb - merge 70-main into 70-spj

    added:
      storage/ndb/src/ndbapi/ndb_internal.cpp
      storage/ndb/src/ndbapi/trp_client.hpp
    modified:
      mysql-test/suite/ndb/r/ndb_partition_range.result
      mysql-test/suite/ndb/t/ndb_partition_range.test
      storage/ndb/include/kernel/BlockNumbers.h
      storage/ndb/include/kernel/signaldata/ScanFrag.hpp
      storage/ndb/include/kernel/signaldata/WaitGCP.hpp
      storage/ndb/include/ndb_version.h.in
      storage/ndb/include/ndbapi/Ndb.hpp
      storage/ndb/include/ndbapi/NdbDictionary.hpp
      storage/ndb/include/ndbapi/NdbReceiver.hpp
      storage/ndb/include/ndbapi/NdbTransaction.hpp
      storage/ndb/src/common/debugger/signaldata/ScanTab.cpp
      storage/ndb/src/kernel/blocks/backup/Backup.cpp
      storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
      storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp
      storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp
      storage/ndb/src/kernel/blocks/dbspj/DbspjMain.cpp
      storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
      storage/ndb/src/kernel/blocks/suma/Suma.cpp
      storage/ndb/src/mgmsrv/ConfigManager.cpp
      storage/ndb/src/mgmsrv/MgmtSrvr.cpp
      storage/ndb/src/mgmsrv/MgmtSrvr.hpp
      storage/ndb/src/mgmsrv/main.cpp
      storage/ndb/src/ndbapi/API.hpp
      storage/ndb/src/ndbapi/CMakeLists.txt
      storage/ndb/src/ndbapi/ClusterMgr.cpp
      storage/ndb/src/ndbapi/ClusterMgr.hpp
      storage/ndb/src/ndbapi/Makefile.am
      storage/ndb/src/ndbapi/Ndb.cpp
      storage/ndb/src/ndbapi/NdbApiSignal.cpp
      storage/ndb/src/ndbapi/NdbApiSignal.hpp
      storage/ndb/src/ndbapi/NdbBlob.cpp
      storage/ndb/src/ndbapi/NdbDictionary.cpp
      storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp
      storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp
      storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp
      storage/ndb/src/ndbapi/NdbImpl.hpp
      storage/ndb/src/ndbapi/NdbInfoScanOperation.cpp
      storage/ndb/src/ndbapi/NdbOperation.cpp
      storage/ndb/src/ndbapi/NdbOperationExec.cpp
      storage/ndb/src/ndbapi/NdbOperationSearch.cpp
      storage/ndb/src/ndbapi/NdbQueryOperation.cpp
      storage/ndb/src/ndbapi/NdbReceiver.cpp
      storage/ndb/src/ndbapi/NdbScanFilter.cpp
      storage/ndb/src/ndbapi/NdbScanOperation.cpp
      storage/ndb/src/ndbapi/NdbTransaction.cpp
      storage/ndb/src/ndbapi/NdbTransactionScan.cpp
      storage/ndb/src/ndbapi/NdbWaiter.hpp
      storage/ndb/src/ndbapi/Ndberr.cpp
      storage/ndb/src/ndbapi/Ndbif.cpp
      storage/ndb/src/ndbapi/Ndbinit.cpp
      storage/ndb/src/ndbapi/Ndblist.cpp
      storage/ndb/src/ndbapi/SignalSender.cpp
      storage/ndb/src/ndbapi/SignalSender.hpp
      storage/ndb/src/ndbapi/TransporterFacade.cpp
      storage/ndb/src/ndbapi/TransporterFacade.hpp
      storage/ndb/src/ndbapi/ndb_cluster_connection.cpp
      storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp
      storage/ndb/src/ndbapi/ndb_internal.hpp
      storage/ndb/test/ndbapi/testDict.cpp
      storage/ndb/test/ndbapi/testRestartGci.cpp
      storage/ndb/test/src/NDBT_Test.cpp
=== modified file 'mysql-test/suite/ndb/r/ndb_partition_range.result'
--- a/mysql-test/suite/ndb/r/ndb_partition_range.result	2010-09-16 10:53:40 +0000
+++ b/mysql-test/suite/ndb/r/ndb_partition_range.result	2010-10-01 10:08:29 +0000
@@ -177,7 +177,8 @@ ENGINE=NDB;
 CREATE TABLESPACE ts1
 ADD DATAFILE 'datafile.dat'
   USE LOGFILE GROUP lg1
-INITIAL_SIZE 16M
+INITIAL_SIZE 12M
+EXTENT_SIZE 256k
 ENGINE NDB;
 CREATE TABLE test.t1 (
 a1 INT,

=== modified file 'mysql-test/suite/ndb/t/ndb_partition_range.test'
--- a/mysql-test/suite/ndb/t/ndb_partition_range.test	2010-09-22 12:12:14 +0000
+++ b/mysql-test/suite/ndb/t/ndb_partition_range.test	2010-10-01 10:08:29 +0000
@@ -147,7 +147,8 @@ CREATE LOGFILE GROUP lg1
 CREATE TABLESPACE ts1
   ADD DATAFILE 'datafile.dat'
   USE LOGFILE GROUP lg1
-  INITIAL_SIZE 16M
+  INITIAL_SIZE 12M
+  EXTENT_SIZE 256k
   ENGINE NDB;
 
 CREATE TABLE test.t1 (

=== modified file 'storage/ndb/include/kernel/BlockNumbers.h'
--- a/storage/ndb/include/kernel/BlockNumbers.h	2010-08-26 16:01:10 +0000
+++ b/storage/ndb/include/kernel/BlockNumbers.h	2010-10-04 14:44:27 +0000
@@ -28,14 +28,14 @@
 /* 2047 */
 #define API_PACKED     0x07ff
 
+/* Fixed block numbers in API */
+#define NO_API_FIXED_BLOCKS    2
+
 /* 4002 */
 #define API_CLUSTERMGR 0x0FA2
+#define MGM_CONFIG_MAN 0x0FA3
 
-/* Fixed block numbers in API */
-#define NO_API_FIXED_BLOCKS    1
-#define MIN_API_FIXED_BLOCK_NO (API_CLUSTERMGR+1)
-#define MGM_CONFIG_MAN MIN_API_FIXED_BLOCK_NO
-
+#define MIN_API_FIXED_BLOCK_NO (API_CLUSTERMGR)
 #define MAX_API_FIXED_BLOCK_NO (MIN_API_FIXED_BLOCK_NO + NO_API_FIXED_BLOCKS)
 
 

=== modified file 'storage/ndb/include/kernel/signaldata/ScanFrag.hpp'
--- a/storage/ndb/include/kernel/signaldata/ScanFrag.hpp	2010-05-20 11:18:08 +0000
+++ b/storage/ndb/include/kernel/signaldata/ScanFrag.hpp	2010-10-04 14:44:27 +0000
@@ -239,11 +239,16 @@ public:
   
 public:
   Uint32 senderData;
-  Uint32 closeFlag;
+  Uint32 requestInfo; // 1 == close
   Uint32 transId1;
   Uint32 transId2;
   Uint32 batch_size_rows;
   Uint32 batch_size_bytes;
+
+  STATIC_CONST( ZCLOSE = 1 );
+
+  Uint32 getCloseFlag(const Uint32&);
+  void setCloseFlag(Uint32&, Uint32);
 };
 
 /**

=== modified file 'storage/ndb/include/kernel/signaldata/WaitGCP.hpp'
--- a/storage/ndb/include/kernel/signaldata/WaitGCP.hpp	2009-05-27 15:21:45 +0000
+++ b/storage/ndb/include/kernel/signaldata/WaitGCP.hpp	2010-09-30 14:27:18 +0000
@@ -51,7 +51,8 @@ public:
     CurrentGCI        = 8,  ///< Immediately return current GCI
     BlockStartGcp     = 9,
     UnblockStartGcp   = 10,
-    WaitEpoch         = 11  // If GCP is blocked, wait for epoch to not start
+    WaitEpoch         = 11, // If GCP is blocked, wait for epoch to not start
+    RestartGCI        = 12  // Return restart GCI
   };
 
   Uint32 senderRef;
@@ -98,6 +99,7 @@ class WaitGCPRef {
   friend class Dbdict;
   friend class Backup;
   friend class Trix;
+  friend class NdbDictInterface;
 
 public:
   STATIC_CONST( SignalLength = 2 );

=== modified file 'storage/ndb/include/ndb_version.h.in'
--- a/storage/ndb/include/ndb_version.h.in	2010-09-29 08:45:11 +0000
+++ b/storage/ndb/include/ndb_version.h.in	2010-10-04 11:07:50 +0000
@@ -500,4 +500,11 @@ ndbd_suma_stop_me(Uint32 x)
   }
 }
 
+/**
+ * After this version, TC/BACKUP/SUMA does not use ScanFragReq::setAttrLen
+ *   when sending long SCAN_FRAGREQ
+ */
+#define NDBD_LONG_SCAN_FRAGREQ_70 NDB_MAKE_VERSION(7,0,20)
+#define NDBD_LONG_SCAN_FRAGREQ_71 NDB_MAKE_VERSION(7,1,9)
+
 #endif

=== modified file 'storage/ndb/include/ndbapi/Ndb.hpp'
--- a/storage/ndb/include/ndbapi/Ndb.hpp	2010-09-29 13:49:49 +0000
+++ b/storage/ndb/include/ndbapi/Ndb.hpp	2010-10-04 14:44:27 +0000
@@ -1666,23 +1666,6 @@ public:
   };
 
   /**
-   * For testing purposes it is possible to tamper with the NDB Cluster
-   * (i.e. send a special signal to DBDIH, the NDB distribution handler).
-   * <b>This feature should only used for debugging purposes.</b>
-   * In a release versions of NDB Cluster,
-   * this call always return -1 and does nothing.
-   * 
-   * @param aAction Action to be taken according to TamperType above
-   *
-   * @param aNode  Which node the action will be taken
-   *              -1:   Master DIH.
-   *            0-16:   Nodnumber.
-   * @return -1 indicates error, other values have meaning dependent 
-   *          on type of tampering.
-   */
-  int NdbTamper(TamperType aAction, int aNode);  
-
-  /**
    * Return a unique tuple id for a table.  The id sequence is
    * ascending but may contain gaps.  Methods which have no
    * TupleIdRange argument use NDB API dict cache.  They may
@@ -1848,9 +1831,6 @@ private:
                                       Uint32 nodeSequence,
                                       Uint32 *ret_conn_seq= 0);
   
-  // Sets Restart GCI in Ndb object
-  void			RestartGCI(int aRestartGCI);
-
   // Get block number of this NDBAPI object
   int			getBlockNumber();
   
@@ -2002,9 +1982,6 @@ private:
   int creleaseSignals;
 #endif
 
-  static void executeMessage(void*, const NdbApiSignal *,
-			     const struct LinearSectionPtr ptr[3]);
-  static void statusMessage(void*, Uint32, bool, bool);
 #ifdef VM_TRACE
 #include <my_attribute.h>
   void printState(const char* fmt, ...)

=== modified file 'storage/ndb/include/ndbapi/NdbDictionary.hpp'
--- a/storage/ndb/include/ndbapi/NdbDictionary.hpp	2010-09-23 11:55:42 +0000
+++ b/storage/ndb/include/ndbapi/NdbDictionary.hpp	2010-10-04 14:44:27 +0000
@@ -2328,6 +2328,11 @@ public:
      */
     int forceGCPWait();
     int forceGCPWait(int type);
+
+    /**
+     * Get restart gci
+     */
+    int getRestartGCI(Uint32 * gci);
 #endif
 
     /** @} *******************************************************************/

=== modified file 'storage/ndb/include/ndbapi/NdbReceiver.hpp'
--- a/storage/ndb/include/ndbapi/NdbReceiver.hpp	2010-03-22 08:23:10 +0000
+++ b/storage/ndb/include/ndbapi/NdbReceiver.hpp	2010-10-04 14:44:27 +0000
@@ -25,6 +25,7 @@
 
 
 class Ndb;
+class NdbImpl;
 class NdbTransaction;
 class NdbRecord;
 class TransporterFacade;
@@ -101,7 +102,7 @@ private:
   void prepareSend();
 
   static
-  void calculate_batch_size(const TransporterFacade *tp,
+  void calculate_batch_size(const NdbImpl&,
                             const NdbRecord *,
                             const NdbRecAttr *first_rec_attr,
                             Uint32, Uint32, Uint32&, Uint32&, Uint32&);

=== modified file 'storage/ndb/include/ndbapi/NdbTransaction.hpp'
--- a/storage/ndb/include/ndbapi/NdbTransaction.hpp	2010-09-29 13:49:49 +0000
+++ b/storage/ndb/include/ndbapi/NdbTransaction.hpp	2010-10-04 14:44:27 +0000
@@ -962,7 +962,6 @@ private:						
   Uint32        get_send_size();                  // Get size to send
   void          set_send_size(Uint32);            // Set size to send;
   
-  int  receiveDIHNDBTAMPER(const NdbApiSignal* anApiSignal);
   int  receiveTCSEIZECONF(const NdbApiSignal* anApiSignal);
   int  receiveTCSEIZEREF(const NdbApiSignal* anApiSignal);
   int  receiveTCRELEASECONF(const NdbApiSignal* anApiSignal);

=== modified file 'storage/ndb/src/common/debugger/signaldata/ScanTab.cpp'
--- a/storage/ndb/src/common/debugger/signaldata/ScanTab.cpp	2009-06-12 12:01:12 +0000
+++ b/storage/ndb/src/common/debugger/signaldata/ScanTab.cpp	2010-10-04 14:44:27 +0000
@@ -126,7 +126,7 @@ printSCANFRAGNEXTREQ(FILE * output, cons
   fprintf(output, " transId(1, 2): (H\'%.8x, H\'%.8x)\n",
 	  sig->transId1, sig->transId2);
   
-  fprintf(output, " Close scan: %u\n", sig->closeFlag);
+  fprintf(output, " requestInfo: 0x%.8x\n", sig->requestInfo);
 
   return false;
 }

=== modified file 'storage/ndb/src/kernel/blocks/backup/Backup.cpp'
--- a/storage/ndb/src/kernel/blocks/backup/Backup.cpp	2010-08-17 11:47:55 +0000
+++ b/storage/ndb/src/kernel/blocks/backup/Backup.cpp	2010-10-04 11:13:22 +0000
@@ -4092,7 +4092,6 @@ Backup::execBACKUP_FRAGMENT_REQ(Signal* 
     ScanFragReq::setLockMode(req->requestInfo, 0);
     ScanFragReq::setHoldLockFlag(req->requestInfo, 0);
     ScanFragReq::setKeyinfoFlag(req->requestInfo, 0);
-    ScanFragReq::setAttrLen(req->requestInfo, attrLen);
     ScanFragReq::setTupScanFlag(req->requestInfo, 1);
     if (ptr.p->is_lcp())
     {
@@ -4113,25 +4112,19 @@ Backup::execBACKUP_FRAGMENT_REQ(Signal* 
       ndbrequire(instanceKey != 0);
       lqhRef = numberToRef(DBLQH, instanceKey, getOwnNodeId());
     }
+
+    Uint32 attrInfo[25];
+    attrInfo[0] = table.attrInfoLen;
+    attrInfo[1] = 0;
+    attrInfo[2] = 0;
+    attrInfo[3] = 0;
+    attrInfo[4] = 0;
+    memcpy(attrInfo + 5, table.attrInfo, 4*table.attrInfoLen);
+    LinearSectionPtr ptr[3];
+    ptr[0].p = attrInfo;
+    ptr[0].sz = 5 + table.attrInfoLen;
     sendSignal(lqhRef, GSN_SCAN_FRAGREQ, signal,
-               ScanFragReq::SignalLength, JBB);
-    
-    signal->theData[0] = filePtr.i;
-    signal->theData[1] = 0;
-    signal->theData[2] = (BACKUP << 20) + (getOwnNodeId() << 8);
-    
-    // Return all
-    signal->theData[3] = table.attrInfoLen;
-    signal->theData[4] = 0;
-    signal->theData[5] = 0;
-    signal->theData[6] = 0;
-    signal->theData[7] = 0;
-    
-    Uint32 dataPos = 8;
-    memcpy(signal->theData + dataPos, table.attrInfo, 4*table.attrInfoLen);
-    dataPos += table.attrInfoLen;
-    ndbassert(dataPos < 25);
-    sendSignal(lqhRef, GSN_ATTRINFO, signal, dataPos, JBB);
+               ScanFragReq::SignalLength, JBB, ptr, 1);
   }
 }
 
@@ -4465,7 +4458,7 @@ Backup::checkScan(Signal* signal, Backup
     op.closeScan();
     ScanFragNextReq * req = (ScanFragNextReq *)signal->getDataPtrSend();
     req->senderData = filePtr.i;
-    req->closeFlag = 1;
+    req->requestInfo = ScanFragNextReq::ZCLOSE;
     req->transId1 = 0;
     req->transId2 = (BACKUP << 20) + (getOwnNodeId() << 8);
     sendSignal(lqhRef, GSN_SCAN_NEXTREQ, signal, 
@@ -4478,7 +4471,7 @@ Backup::checkScan(Signal* signal, Backup
     
     ScanFragNextReq * req = (ScanFragNextReq *)signal->getDataPtrSend();
     req->senderData = filePtr.i;
-    req->closeFlag = 0;
+    req->requestInfo = 0;
     req->transId1 = 0;
     req->transId2 = (BACKUP << 20) + (getOwnNodeId() << 8);
     req->batch_size_rows= 16;

=== modified file 'storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2010-09-23 11:55:42 +0000
+++ b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp	2010-10-04 14:44:27 +0000
@@ -17994,6 +17994,18 @@ void Dbdih::execWAIT_GCP_REQ(Signal* sig
     return;
   }//if
 
+  if(requestType == WaitGCPReq::RestartGCI)
+  {
+    jam();
+    conf->senderData = senderData;
+    conf->gci_hi = Uint32(crestartGci);
+    conf->gci_lo = 0;
+    conf->blockStatus = cgcpOrderBlocked;
+    sendSignal(senderRef, GSN_WAIT_GCP_CONF, signal,
+	       WaitGCPConf::SignalLength, JBB);
+    return;
+  }//if
+
   if (requestType == WaitGCPReq::BlockStartGcp)
   {
     jam();

=== modified file 'storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp'
--- a/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp	2010-09-23 11:55:42 +0000
+++ b/storage/ndb/src/kernel/blocks/dblqh/Dblqh.hpp	2010-10-04 14:44:27 +0000
@@ -2243,7 +2243,7 @@ private:
   // Statement blocks
 
   void init_acc_ptr_list(ScanRecord*);
-  bool seize_acc_ptr_list(ScanRecord*, Uint32);
+  bool seize_acc_ptr_list(ScanRecord*, Uint32, Uint32);
   void release_acc_ptr_list(ScanRecord*);
   Uint32 get_acc_ptr_from_scan_record(ScanRecord*, Uint32, bool);
   void set_acc_ptr_in_scan_record(ScanRecord*, Uint32, Uint32);

=== modified file 'storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp	2010-09-29 13:49:49 +0000
+++ b/storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp	2010-10-04 14:44:27 +0000
@@ -9291,7 +9291,7 @@ void Dblqh::execSCAN_NEXTREQ(Signal* sig
     jam();
     DEBUG(senderData << 
 	  " Received SCAN_NEXTREQ in LQH with close flag when closed");
-    ndbrequire(nextReq->closeFlag == ZTRUE);
+    ndbrequire(nextReq->requestInfo == ScanFragNextReq::ZCLOSE);
     return;
   }
 
@@ -9345,7 +9345,8 @@ void Dblqh::execSCAN_NEXTREQ(Signal* sig
    * continue execution else set flags and wait until the scan 
    * completes itself
    * ------------------------------------------------------------------ */
-  if (nextReq->closeFlag == ZTRUE){
+  if (nextReq->requestInfo == ScanFragNextReq::ZCLOSE)
+  {
     jam();
     if(ERROR_INSERTED(5034)){
       CLEAR_ERROR_INSERT_VALUE;
@@ -9367,9 +9368,32 @@ void Dblqh::execSCAN_NEXTREQ(Signal* sig
    */
   const Uint32 max_rows = nextReq->batch_size_rows;
   const Uint32 max_bytes = nextReq->batch_size_bytes;
-  ndbrequire(scanptr.p->m_max_batch_size_rows == max_rows);
-  ndbrequire(scanptr.p->m_max_batch_size_bytes == max_bytes);  
+  scanptr.p->m_max_batch_size_bytes = max_bytes;
 
+  if (max_rows > scanptr.p->m_max_batch_size_rows)
+  {
+    jam();
+    /**
+     * Extend list...
+     */
+    if (!seize_acc_ptr_list(scanptr.p, 
+                            scanptr.p->m_max_batch_size_rows, max_rows))
+    {
+      jam();
+      tcConnectptr.p->errorCode = ScanFragRef::ZTOO_MANY_ACTIVE_SCAN_ERROR;
+      closeScanRequestLab(signal);
+      return;
+    }
+    cbookedAccOps += (max_rows - scanptr.p->m_max_batch_size_rows);
+    scanptr.p->m_max_batch_size_rows = max_rows;
+  }
+  else if (unlikely(max_rows < scanptr.p->m_max_batch_size_rows))
+  {
+    jam();
+    cbookedAccOps -= (scanptr.p->m_max_batch_size_rows - max_rows);
+    scanptr.p->m_max_batch_size_rows = max_rows;
+  }
+  
   /* --------------------------------------------------------------------
    * If scanLockHold = TRUE we need to unlock previous round of 
    * scanned records.
@@ -9640,17 +9664,22 @@ void Dblqh::scanLockReleasedLab(Signal* 
 }//Dblqh::scanLockReleasedLab()
 
 bool
-Dblqh::seize_acc_ptr_list(ScanRecord* scanP, Uint32 batch_size)
+Dblqh::seize_acc_ptr_list(ScanRecord* scanP, 
+                          Uint32 curr_batch_size, 
+                          Uint32 new_batch_size)
 {
-  Uint32 i;
   /*  1 maps to 0 segments
    * >1 maps to enough segments to store
    */
-  Uint32 segments= (batch_size + (SectionSegment::DataLength -2 )) / 
+  Uint32 segments= (new_batch_size + (SectionSegment::DataLength -2 )) / 
     SectionSegment::DataLength;
 
-  if (batch_size > 1) {
-    for (i= 1; i <= segments; i++) {
+  ndbassert(segments >= scanP->scan_acc_segments);
+
+  if (new_batch_size > 1)
+  {
+    for (Uint32 i = 1 + scanP->scan_acc_segments; i <= segments; i++)
+    {
       Uint32 seg= seizeSegment();
       if (unlikely(seg == RNIL))
       {
@@ -9664,7 +9693,6 @@ Dblqh::seize_acc_ptr_list(ScanRecord* sc
     }
   }
   scanP->scan_acc_segments= segments;
-  scanP->scan_acc_index = 0;
   return true;
 }
 
@@ -11051,10 +11079,13 @@ Uint32 Dblqh::initScanrec(const ScanFrag
     return ScanFragRef::ZTOO_MANY_ACTIVE_SCAN_ERROR;
   }
 
-  if (!seize_acc_ptr_list(scanptr.p, max_rows)){
+  scanptr.p->scan_acc_segments = 0;
+  if (!seize_acc_ptr_list(scanptr.p, 0, max_rows)){
     jam();
     return ScanFragRef::ZTOO_MANY_ACTIVE_SCAN_ERROR;
   }
+  init_acc_ptr_list(scanptr.p);
+
   /**
    * Used for scan take over
    */
@@ -11127,7 +11158,6 @@ Uint32 Dblqh::initScanrec(const ScanFrag
 #endif
     c_scanTakeOverHash.add(scanptr);
   }
-  init_acc_ptr_list(scanptr.p);
   return ZOK;
 }
 

=== modified file 'storage/ndb/src/kernel/blocks/dbspj/DbspjMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dbspj/DbspjMain.cpp	2010-09-03 08:16:37 +0000
+++ b/storage/ndb/src/kernel/blocks/dbspj/DbspjMain.cpp	2010-10-04 14:44:27 +0000
@@ -1754,11 +1754,11 @@ Dbspj::execSCAN_NEXTREQ(Signal* signal)
   if (unlikely(!m_scan_request_hash.find(requestPtr, key)))
   {
     jam();
-    ndbrequire(req->closeFlag == ZTRUE);
+    ndbrequire(req->requestInfo == ScanFragNextReq::ZCLOSE);
     return;
   }
 
-  if (req->closeFlag == ZTRUE)  // Requested close scan
+  if (req->requestInfo == ScanFragNextReq::ZCLOSE)  // Requested close scan
   {
     jam();
     abort(signal, requestPtr, 0);
@@ -3779,7 +3779,7 @@ Dbspj::scanFrag_execSCAN_NEXTREQ(Signal*
   ScanFragNextReq* req = 
     reinterpret_cast<ScanFragNextReq*>(signal->getDataPtrSend());
   req->senderData = treeNodePtr.i;
-  req->closeFlag = 0;
+  req->requestInfo = 0;
   req->transId1 = requestPtr.p->m_transId[0];
   req->transId2 = requestPtr.p->m_transId[1];
   req->batch_size_rows = org->batch_size_rows;
@@ -3813,7 +3813,7 @@ Dbspj::scanFrag_abort(Signal* signal, 
     ScanFragNextReq* req = 
       reinterpret_cast<ScanFragNextReq*>(signal->getDataPtrSend());
     req->senderData = treeNodePtr.i;
-    req->closeFlag = ZTRUE;
+    req->requestInfo = ScanFragNextReq::ZCLOSE;
     req->transId1 = requestPtr.p->m_transId[0];
     req->transId2 = requestPtr.p->m_transId[1];
     req->batch_size_rows = 0;
@@ -4790,7 +4790,7 @@ Dbspj::scanIndex_execSCAN_NEXTREQ(Signal
   ScanFragNextReq* req = 
     reinterpret_cast<ScanFragNextReq*>(signal->getDataPtrSend());
   req->senderData = treeNodePtr.i;
-  req->closeFlag = 0;
+  req->requestInfo = 0;
   req->transId1 = requestPtr.p->m_transId[0];
   req->transId2 = requestPtr.p->m_transId[1];
   req->batch_size_rows = org->batch_size_rows;

=== modified file 'storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp'
--- a/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2010-09-03 08:59:02 +0000
+++ b/storage/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2010-10-04 14:44:27 +0000
@@ -10228,7 +10228,6 @@ Dbtc::initScanrec(ScanRecordPtr scanptr,
   ScanFragReq::setRangeScanFlag(tmp, ScanTabReq::getRangeScanFlag(ri));
   ScanFragReq::setDescendingFlag(tmp, ScanTabReq::getDescendingFlag(ri));
   ScanFragReq::setTupScanFlag(tmp, ScanTabReq::getTupScanFlag(ri));
-  ScanFragReq::setAttrLen(tmp, aiLength);
   ScanFragReq::setNoDiskFlag(tmp, ScanTabReq::getNoDiskFlag(ri));
   if (ScanTabReq::getViaSPJFlag(ri))
   {
@@ -11132,7 +11131,7 @@ void Dbtc::execSCAN_NEXTREQ(Signal* sign
   }
 
   ScanFragNextReq tmp;
-  tmp.closeFlag = ZFALSE;
+  tmp.requestInfo = 0;
   tmp.transId1 = apiConnectptr.p->transid[0];
   tmp.transId2 = apiConnectptr.p->transid[1];
   tmp.batch_size_rows = scanP->batch_size_rows;
@@ -11218,7 +11217,7 @@ Dbtc::close_scan_req(Signal* signal, Sca
    */
   
   ScanFragNextReq * nextReq = (ScanFragNextReq*)&signal->theData[0];
-  nextReq->closeFlag = ZTRUE;
+  nextReq->requestInfo = ScanFragNextReq::ZCLOSE;
   nextReq->transId1 = apiConnectptr.p->transid[0];
   nextReq->transId2 = apiConnectptr.p->transid[1];
   
@@ -11403,7 +11402,6 @@ void Dbtc::sendScanFragReq(Signal* signa
   ScanFragReq * const req = (ScanFragReq *)&signal->theData[0];
   Uint32 requestInfo = scanP->scanRequestInfo;
   ScanFragReq::setScanPrio(requestInfo, 1);
-  ScanFragReq::setAttrLen(requestInfo, reqAttrLen);
   apiConnectptr.i = scanP->scanApiRec;
   req->tableId = scanP->scanTableref;
   req->schemaVersion = scanP->scanSchemaVersion;
@@ -11493,6 +11491,7 @@ void Dbtc::sendScanFragReq(Signal* signa
     /* Short SCANFRAGREQ with separate KeyInfo and AttrInfo trains 
      * Sent to older NDBD nodes during upgrade
      */
+    ScanFragReq::setAttrLen(requestInfo, reqAttrLen);
     sendSignal(scanFragP->lqhBlockref, GSN_SCAN_FRAGREQ, signal,
                ScanFragReq::SignalLength, JBB);
     if(scanP->scanKeyLen > 0)

=== modified file 'storage/ndb/src/kernel/blocks/suma/Suma.cpp'
--- a/storage/ndb/src/kernel/blocks/suma/Suma.cpp	2010-09-29 07:39:42 +0000
+++ b/storage/ndb/src/kernel/blocks/suma/Suma.cpp	2010-10-04 11:13:22 +0000
@@ -2512,7 +2512,6 @@ Suma::SyncRecord::nextScan(Signal* signa
   ScanFragReq::setLockMode(req->requestInfo, 0);
   ScanFragReq::setHoldLockFlag(req->requestInfo, 1);
   ScanFragReq::setKeyinfoFlag(req->requestInfo, 0);
-  ScanFragReq::setAttrLen(req->requestInfo, attrLen);
   if (m_requestInfo & SubSyncReq::LM_Exclusive)
   {
     ScanFragReq::setLockMode(req->requestInfo, 1);
@@ -2533,32 +2532,25 @@ Suma::SyncRecord::nextScan(Signal* signa
   req->batch_size_rows= parallelism;
 
   req->batch_size_bytes= 0;
-  suma.sendSignal(lqhRef, GSN_SCAN_FRAGREQ, signal, 
-		  ScanFragReq::SignalLength, JBB);
-  
-  signal->theData[0] = ptrI;
-  signal->theData[1] = 0;
-  signal->theData[2] = (SUMA << 20) + (suma.getOwnNodeId() << 8);
-  
-  // Return all
-  signal->theData[3] = attrBuf.getSize();
-  signal->theData[4] = 0;
-  signal->theData[5] = 0;
-  signal->theData[6] = 0;
-  signal->theData[7] = 0;
+
+  Uint32 * attrInfo = signal->theData + 25;
+  attrInfo[0] = attrBuf.getSize();
+  attrInfo[1] = 0;
+  attrInfo[2] = 0;
+  attrInfo[3] = 0;
+  attrInfo[4] = 0;
   
-  Uint32 dataPos = 8;
+  Uint32 pos = 5;
   DataBuffer<15>::DataBufferIterator it;
-  for(attrBuf.first(it); !it.curr.isNull(); attrBuf.next(it)){
-    AttributeHeader::init(&signal->theData[dataPos++], * it.data, 0);
-    if(dataPos == 25){
-      suma.sendSignal(lqhRef, GSN_ATTRINFO, signal, 25, JBB);
-      dataPos = 3;
-    }
-  }
-  if(dataPos != 3){
-    suma.sendSignal(lqhRef, GSN_ATTRINFO, signal, dataPos, JBB);
+  for(attrBuf.first(it); !it.curr.isNull(); attrBuf.next(it))
+  {
+    AttributeHeader::init(&attrInfo[pos++], * it.data, 0);
   }
+  LinearSectionPtr ptr[3];
+  ptr[0].p = attrInfo;
+  ptr[0].sz = pos;
+  suma.sendSignal(lqhRef, GSN_SCAN_FRAGREQ, signal, 
+		  ScanFragReq::SignalLength, JBB, ptr, 1);
   
   m_currentNoOfAttributes = attrBuf.getSize();        
 
@@ -2651,7 +2643,7 @@ Suma::execSUB_SYNC_CONTINUE_CONF(Signal*
 
   ScanFragNextReq * req = (ScanFragNextReq *)signal->getDataPtrSend();
   req->senderData = syncPtrI;
-  req->closeFlag = 0;
+  req->requestInfo = 0;
   req->transId1 = 0;
   req->transId2 = (SUMA << 20) + (getOwnNodeId() << 8);
   req->batch_size_rows = 16;

=== modified file 'storage/ndb/src/mgmsrv/ConfigManager.cpp'
--- a/storage/ndb/src/mgmsrv/ConfigManager.cpp	2010-09-21 12:02:05 +0000
+++ b/storage/ndb/src/mgmsrv/ConfigManager.cpp	2010-09-30 09:32:28 +0000
@@ -20,6 +20,7 @@
 
 #include <NdbConfig.h>
 #include <NdbSleep.h>
+#include <kernel/GlobalSignalNumbers.h>
 #include <SignalSender.hpp>
 #include <NdbApiSignal.hpp>
 #include <signaldata/NFCompleteRep.hpp>
@@ -27,6 +28,8 @@
 #include <signaldata/ApiRegSignalData.hpp>
 #include <ndb_version.h>
 
+#include <EventLogger.hpp>
+extern EventLogger * g_eventLogger;
 
 extern "C" const char* opt_ndb_connectstring;
 extern "C" int opt_ndb_nodeid;

=== modified file 'storage/ndb/src/mgmsrv/MgmtSrvr.cpp'
--- a/storage/ndb/src/mgmsrv/MgmtSrvr.cpp	2010-09-29 13:25:19 +0000
+++ b/storage/ndb/src/mgmsrv/MgmtSrvr.cpp	2010-10-01 10:08:29 +0000
@@ -408,9 +408,7 @@ MgmtSrvr::start_transporter(const Config
     Register ourself at TransporterFacade to be able to receive signals
     and to be notified when a database process has died.
   */
-  if ((_blockNumber= theFacade->open(this,
-                                     signalReceivedNotification,
-                                     nodeStatusNotification)) == -1)
+  if ((_blockNumber= theFacade->open(this)) == -1)
   {
     g_eventLogger->error("Failed to open block in TransporterFacade");
     theFacade->stop_instance();
@@ -2457,7 +2455,8 @@ const char* MgmtSrvr::getErrorText(int e
 
 
 void
-MgmtSrvr::handleReceivedSignal(const NdbApiSignal* signal)
+MgmtSrvr::trp_deliver_signal(const NdbApiSignal* signal,
+                             const LinearSectionPtr ptr[3])
 {
   int gsn = signal->readSignalNumber();
 
@@ -2492,55 +2491,40 @@ MgmtSrvr::handleReceivedSignal(const Ndb
 
 
 void
-MgmtSrvr::signalReceivedNotification(void* mgmtSrvr,
-                                     const NdbApiSignal* signal,
-				     const LinearSectionPtr ptr[3])
-{
-  ((MgmtSrvr*)mgmtSrvr)->handleReceivedSignal(signal);
-}
-
-
-void
-MgmtSrvr::handleStatus(NodeId nodeId, bool alive, bool nfComplete)
+MgmtSrvr::trp_node_status(Uint32 nodeId, Uint32 _event)
 {
   DBUG_ENTER("MgmtSrvr::handleStatus");
-  DBUG_PRINT("enter",("nodeid: %d, alive: %d, nfComplete: %d",
-                      nodeId, alive, nfComplete));
+  DBUG_PRINT("enter",("nodeid: %d, event: %u", nodeId, _event));
 
   union {
     Uint32 theData[25];
     EventReport repData;
   };
   EventReport * rep = &repData;
+  NS_Event event = (NS_Event)_event;
 
   theData[1] = nodeId;
-  if (alive) {
+  switch(event){
+  case NS_CONNECTED:
+    DBUG_VOID_RETURN;
+  case NS_NODE_ALIVE:
     if (nodeTypes[nodeId] == NODE_TYPE_DB)
     {
       m_started_nodes.push_back(nodeId);
     }
     rep->setEventType(NDB_LE_Connected);
-  } else {
+    break;
+  case NS_NODE_FAILED:
     rep->setEventType(NDB_LE_Disconnected);
-    if(nfComplete)
-    {
-      DBUG_VOID_RETURN;
-    }
+    break;
+  case NS_NODE_NF_COMPLETE:
+    DBUG_VOID_RETURN;
   }
   rep->setNodeId(_ownNodeId);
   eventReport(theData, 1);
   DBUG_VOID_RETURN;
 }
 
-
-void
-MgmtSrvr::nodeStatusNotification(void* mgmSrv, Uint32 nodeId,
-				 bool alive, bool nfComplete)
-{
-  ((MgmtSrvr*)mgmSrv)->handleStatus(nodeId, alive, nfComplete);
-}
-
-
 enum ndb_mgm_node_type 
 MgmtSrvr::getNodeType(NodeId nodeId) const 
 {

=== modified file 'storage/ndb/src/mgmsrv/MgmtSrvr.hpp'
--- a/storage/ndb/src/mgmsrv/MgmtSrvr.hpp	2010-09-29 13:25:19 +0000
+++ b/storage/ndb/src/mgmsrv/MgmtSrvr.hpp	2010-10-01 10:08:29 +0000
@@ -73,7 +73,7 @@ public:
   @class MgmtSrvr
   @brief Main class for the management server.
  */
-class MgmtSrvr : private ConfigSubscriber {
+class MgmtSrvr : private ConfigSubscriber, public trp_client {
 
 public:
   // some compilers need all of this
@@ -469,30 +469,12 @@ private:
   NodeBitmask m_reserved_nodes;
   struct in_addr m_connect_address[MAX_NODES];
 
-  void handleReceivedSignal(const NdbApiSignal* signal);
-  void handleStatus(NodeId nodeId, bool alive, bool nfComplete);
-
   /**
-     Callback function installed into TransporterFacade, will be called
-     once for each new signal received to the MgmtSrvr.
-     @param  mgmtSrvr: The MgmtSrvr object which shall recieve the signal.
-     @param  signal: The received signal.
-     @param  ptr: The long part(s) of the signal
-   */
-  static void signalReceivedNotification(void* mgmtSrvr, 
-					 const NdbApiSignal* signal,
-					 const struct LinearSectionPtr ptr[3]);
-
-  /**
-     Callback function installed into TransporterFacade, will be called
-     when status of a node changes.
-     @param  mgmtSrvr: The MgmtSrvr object which shall receive
-     the notification.
-     @param  processId: Id of the node whose status changed.
-     @param alive: true if the other node is alive
+   * trp_client interface
    */
-  static void nodeStatusNotification(void* mgmSrv, Uint32 nodeId, 
-				     bool alive, bool nfCompleted);
+  virtual void trp_deliver_signal(const NdbApiSignal* signal,
+                                  const struct LinearSectionPtr ptr[3]);
+  virtual void trp_node_status(Uint32 nodeId, Uint32 event);
   
   /**
    * An event from <i>nodeId</i> has arrived

=== modified file 'storage/ndb/src/mgmsrv/main.cpp'
--- a/storage/ndb/src/mgmsrv/main.cpp	2010-09-23 07:31:51 +0000
+++ b/storage/ndb/src/mgmsrv/main.cpp	2010-09-30 09:32:28 +0000
@@ -34,6 +34,10 @@
 #include <NdbAutoPtr.hpp>
 #include <ndb_mgmclient.hpp>
 
+#include <EventLogger.hpp>
+extern EventLogger * g_eventLogger;
+
+
 const char *load_default_groups[]= { "mysql_cluster","ndb_mgmd",0 };
 
 // copied from mysql.cc to get readline

=== modified file 'storage/ndb/src/ndbapi/API.hpp'
--- a/storage/ndb/src/ndbapi/API.hpp	2010-09-30 07:19:22 +0000
+++ b/storage/ndb/src/ndbapi/API.hpp	2010-10-04 14:44:27 +0000
@@ -26,8 +26,6 @@
 #include <NdbOut.hpp>
 
 #include "NdbApiSignal.hpp"
-
-#include "NdbImpl.hpp"
 #include "NdbDictionaryImpl.hpp"
 #include "NdbRecord.hpp"
 #include "NdbUtil.hpp"
@@ -41,9 +39,17 @@
 #include <NdbRecAttr.hpp>
 #include <NdbReceiver.hpp>
 #include <NdbBlob.hpp>
+#include <NdbBlobImpl.hpp>
 #include <NdbInterpretedCode.hpp>
 
 #include <NdbEventOperation.hpp>
 #include "NdbEventOperationImpl.hpp"
 
+#include "NdbQueryOperationImpl.hpp"
+
+#include <NdbReceiver.hpp>
+#include "NdbImpl.hpp"
+
+#include "TransporterFacade.hpp"
+
 #endif

=== modified file 'storage/ndb/src/ndbapi/CMakeLists.txt'
--- a/storage/ndb/src/ndbapi/CMakeLists.txt	2009-11-10 09:50:28 +0000
+++ b/storage/ndb/src/ndbapi/CMakeLists.txt	2010-10-04 14:44:27 +0000
@@ -58,5 +58,6 @@ ADD_LIBRARY(ndbapi STATIC
             SignalSender.cpp
             ObjectMap.cpp
             NdbInfo.cpp
-            NdbInfoScanOperation.cpp)
+            NdbInfoScanOperation.cpp
+            ndb_internal.cpp)
 

=== modified file 'storage/ndb/src/ndbapi/ClusterMgr.cpp'
--- a/storage/ndb/src/ndbapi/ClusterMgr.cpp	2010-08-03 07:25:36 +0000
+++ b/storage/ndb/src/ndbapi/ClusterMgr.cpp	2010-10-04 08:31:18 +0000
@@ -21,10 +21,11 @@
 #include <util/version.h>
 
 #include "TransporterFacade.hpp"
+#include <kernel/GlobalSignalNumbers.h>
+
 #include "ClusterMgr.hpp"
 #include <IPCConfig.hpp>
 #include "NdbApiSignal.hpp"
-#include "API.hpp"
 #include <NdbSleep.h>
 #include <NdbOut.hpp>
 #include <NdbTick.h>
@@ -33,6 +34,8 @@
 #include <signaldata/NodeFailRep.hpp>
 #include <signaldata/NFCompleteRep.hpp>
 #include <signaldata/ApiRegSignalData.hpp>
+#include <signaldata/AlterTable.hpp>
+#include <signaldata/SumaImpl.hpp>
 
 #include <mgmapi.h>
 #include <mgmapi_configuration.hpp>
@@ -55,6 +58,7 @@ runClusterMgr_C(void * me)
 ClusterMgr::ClusterMgr(TransporterFacade & _facade):
   theStop(0),
   theFacade(_facade),
+  theArbitMgr(NULL),
   m_connect_count(0),
   m_max_api_reg_req_interval(~0),
   noOfAliveNodes(0),
@@ -68,6 +72,13 @@ ClusterMgr::ClusterMgr(TransporterFacade
   clusterMgrThreadMutex = NdbMutex_Create();
   waitForHBCond= NdbCondition_Create();
   m_auto_reconnect = -1;
+
+  int ret = theFacade.open(this, API_CLUSTERMGR);
+  if (unlikely(ret < 0))
+  {
+    ndbout_c("Failed to register ClusterMgr! ret: %d", ret);
+    abort();
+  }
   DBUG_VOID_RETURN;
 }
 
@@ -75,13 +86,20 @@ ClusterMgr::~ClusterMgr()
 {
   DBUG_ENTER("ClusterMgr::~ClusterMgr");
   doStop();
+  if (theArbitMgr != 0)
+  {
+    delete theArbitMgr;
+    theArbitMgr = 0;
+  }
   NdbCondition_Destroy(waitForHBCond);
   NdbMutex_Destroy(clusterMgrThreadMutex);
   DBUG_VOID_RETURN;
 }
 
 void
-ClusterMgr::configure(const ndb_mgm_configuration* config){
+ClusterMgr::configure(Uint32 nodeId,
+                      const ndb_mgm_configuration* config)
+{
   ndb_mgm_configuration_iterator iter(* config, CFG_SECTION_NODE);
   for(iter.first(); iter.valid(); iter.next()){
     Uint32 nodeId = 0;
@@ -131,6 +149,30 @@ ClusterMgr::configure(const ndb_mgm_conf
   print_nodes("init");
 #endif
 
+  // Configure arbitrator
+  Uint32 rank = 0;
+  iter.first();
+  iter.find(CFG_NODE_ID, nodeId); // let not found in config mean rank=0
+  iter.get(CFG_NODE_ARBIT_RANK, &rank);
+
+  if (rank > 0)
+  {
+    // The arbitrator should be active
+    if (!theArbitMgr)
+      theArbitMgr = new ArbitMgr(theFacade);
+    theArbitMgr->setRank(rank);
+
+    Uint32 delay = 0;
+    iter.get(CFG_NODE_ARBIT_DELAY, &delay);
+    theArbitMgr->setDelay(delay);
+  }
+  else if (theArbitMgr)
+  {
+    // No arbitrator should be started
+    theArbitMgr->doStop(NULL);
+    delete theArbitMgr;
+    theArbitMgr= NULL;
+  }
 }
 
 void
@@ -160,6 +202,11 @@ ClusterMgr::doStop( ){
     NdbThread_Destroy(&theClusterMgrThread);
   }
 
+  if (theArbitMgr != NULL)
+  {
+    theArbitMgr->doStop(NULL);
+  }
+
   DBUG_VOID_RETURN;
 }
 
@@ -322,6 +369,112 @@ ClusterMgr::threadMain( ){
   }
 }
 
+void
+ClusterMgr::trp_deliver_signal(const NdbApiSignal* sig,
+                               const LinearSectionPtr ptr[3])
+{
+  const Uint32 gsn = sig->theVerId_signalNumber;
+  const Uint32 * theData = sig->getDataPtr();
+
+  switch (gsn){
+  case GSN_API_REGREQ:
+    execAPI_REGREQ(theData);
+    break;
+
+  case GSN_API_REGCONF:
+  {
+    execAPI_REGCONF(theData);
+
+    // Distribute signal to all threads/blocks
+    theFacade.for_each(this, sig, ptr);
+    break;
+  }
+
+  case GSN_API_REGREF:
+    execAPI_REGREF(theData);
+    break;
+
+  case GSN_NODE_FAILREP:
+    execNODE_FAILREP(theData);
+    break;
+
+  case GSN_NF_COMPLETEREP:
+    execNF_COMPLETEREP(theData);
+    break;
+
+  case GSN_ARBIT_STARTREQ:
+    if (theArbitMgr != NULL)
+      theArbitMgr->doStart(theData);
+    break;
+
+  case GSN_ARBIT_CHOOSEREQ:
+    if (theArbitMgr != NULL)
+      theArbitMgr->doChoose(theData);
+    break;
+
+  case GSN_ARBIT_STOPORD:
+    if(theArbitMgr != NULL)
+      theArbitMgr->doStop(theData);
+    break;
+
+  case GSN_ALTER_TABLE_REP:
+  {
+    if (theFacade.m_globalDictCache == NULL)
+      break;
+    const AlterTableRep* rep = (const AlterTableRep*)theData;
+    theFacade.m_globalDictCache->lock();
+    theFacade.m_globalDictCache->
+      alter_table_rep((const char*)ptr[0].p,
+                      rep->tableId,
+                      rep->tableVersion,
+                      rep->changeType == AlterTableRep::CT_ALTERED);
+    theFacade.m_globalDictCache->unlock();
+    break;
+  }
+  case GSN_SUB_GCP_COMPLETE_REP:
+  {
+    /**
+     * Report
+     */
+    theFacade.for_each(this, sig, ptr);
+
+    /**
+     * Reply
+     */
+    {
+      BlockReference ownRef = numberToRef(API_CLUSTERMGR, theFacade.ownId());
+      NdbApiSignal tSignal(* sig);
+      Uint32* send= tSignal.getDataPtrSend();
+      memcpy(send, theData, tSignal.getLength() << 2);
+      ((SubGcpCompleteAck*)send)->rep.senderRef = ownRef;
+      Uint32 ref= sig->theSendersBlockRef;
+      Uint32 aNodeId= refToNode(ref);
+      tSignal.theReceiversBlockNumber= refToBlock(ref);
+      tSignal.theVerId_signalNumber= GSN_SUB_GCP_COMPLETE_ACK;
+      tSignal.theSendersBlockRef = API_CLUSTERMGR;
+      theFacade.sendSignalUnCond(&tSignal, aNodeId);
+    }
+    break;
+  }
+  case GSN_TAKE_OVERTCCONF:
+  {
+    /**
+     * Report
+     */
+    theFacade.for_each(this, sig, ptr);
+    return;
+  }
+  default:
+    break;
+
+  }
+  return;
+}
+
+void
+ClusterMgr::trp_node_status(Uint32 nodeId, Uint32 event)
+{
+}
 
 ClusterMgr::Node::Node()
   : m_state(NodeState::SL_NOTHING),
@@ -581,7 +734,7 @@ ClusterMgr::execNF_COMPLETEREP(const Uin
   Node & node = theNodes[nodeId];
   if (node.nfCompleteRep == false)
   {
-    theFacade.ReportNodeFailureComplete(nodeId);
+    theFacade.trp_node_status(nodeId, NS_NODE_NF_COMPLETE);
     node.nfCompleteRep = true;
   }
 }
@@ -617,7 +770,7 @@ ClusterMgr::reportConnected(NodeId nodeI
 
   theNode.minDbVersion = 0;
   
-  theFacade.ReportNodeAlive(nodeId);
+  theFacade.trp_node_status(nodeId, NS_NODE_ALIVE);
   DBUG_VOID_RETURN;
 }
 
@@ -657,7 +810,7 @@ ClusterMgr::reportNodeFailed(NodeId node
   
   if(disconnect || report)
   {
-    theFacade.ReportNodeDead(nodeId);
+    theFacade.trp_node_status(nodeId, NS_NODE_FAILED);
   }
   
   if (noOfConnectedNodes == 0)

=== modified file 'storage/ndb/src/ndbapi/ClusterMgr.hpp'
--- a/storage/ndb/src/ndbapi/ClusterMgr.hpp	2010-01-28 15:16:46 +0000
+++ b/storage/ndb/src/ndbapi/ClusterMgr.hpp	2010-10-01 11:43:32 +0000
@@ -19,7 +19,6 @@
 #ifndef ClusterMgr_H
 #define ClusterMgr_H
 
-#include "API.hpp"
 #include <ndb_limits.h>
 #include <NdbThread.h>
 #include <NdbMutex.h>
@@ -28,6 +27,7 @@
 #include <signaldata/NodeStateSignalData.hpp>
 #include <NodeInfo.hpp>
 #include <NodeState.hpp>
+#include "trp_client.hpp"
 
 extern "C" void* runClusterMgr_C(void * me);
 
@@ -35,13 +35,14 @@ extern "C" void* runClusterMgr_C(void * 
 /**
  * @class ClusterMgr
  */
-class ClusterMgr {
+class ClusterMgr : public trp_client
+{
   friend class TransporterFacade;
   friend void* runClusterMgr_C(void * me);
 public:
   ClusterMgr(class TransporterFacade &);
-  ~ClusterMgr();
-  void configure(const ndb_mgm_configuration* config);
+  virtual ~ClusterMgr();
+  void configure(Uint32 nodeId, const ndb_mgm_configuration* config);
   
   void reportConnected(NodeId nodeId);
   void reportDisconnected(NodeId nodeId);
@@ -61,7 +62,8 @@ private:
   
   int  theStop;
   class TransporterFacade & theFacade;
-  
+  class ArbitMgr * theArbitMgr;
+
 public:
   enum Cluster_state {
     CS_waiting_for_clean_cache = 0,
@@ -173,6 +175,14 @@ private:
 
   void print_nodes(const char* where, NdbOut& out = ndbout);
   void recalcMinDbVersion();
+
+public:
+  /**
+   * trp_client interface
+   */
+  virtual void trp_deliver_signal(const NdbApiSignal*,
+                                  const LinearSectionPtr p[3]);
+  virtual void trp_node_status(Uint32, Uint32);
 };
 
 inline

=== modified file 'storage/ndb/src/ndbapi/Makefile.am'
--- a/storage/ndb/src/ndbapi/Makefile.am	2009-11-10 09:50:28 +0000
+++ b/storage/ndb/src/ndbapi/Makefile.am	2010-10-04 14:44:27 +0000
@@ -63,7 +63,8 @@ libndbapi_la_SOURCES = \
         ObjectMap.cpp \
 	NdbInterpretedCode.cpp \
 	NdbInfo.cpp \
-	NdbInfoScanOperation.cpp
+	NdbInfoScanOperation.cpp \
+        ndb_internal.cpp
 
 INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/src/mgmapi
 

=== modified file 'storage/ndb/src/ndbapi/Ndb.cpp'
--- a/storage/ndb/src/ndbapi/Ndb.cpp	2010-08-26 12:33:33 +0000
+++ b/storage/ndb/src/ndbapi/Ndb.cpp	2010-09-30 14:27:18 +0000
@@ -25,19 +25,11 @@ Name:          Ndb.cpp
 
 #include <ndb_global.h>
 
-
-#include "NdbApiSignal.hpp"
-#include "NdbImpl.hpp"
-#include <NdbOperation.hpp>
-#include <NdbTransaction.hpp>
-#include <NdbEventOperation.hpp>
-#include <NdbEventOperationImpl.hpp>
-#include <NdbRecAttr.hpp>
+#include "API.hpp"
 #include <md5_hash.hpp>
 #include <NdbSleep.h>
 #include <NdbOut.hpp>
 #include <ndb_limits.h>
-#include "API.hpp"
 #include <NdbEnv.h>
 #include <BaseString.hpp>
 #include <NdbSqlUtil.hpp>
@@ -998,171 +990,6 @@ Ndb::closeTransaction(NdbTransaction* aC
   DBUG_VOID_RETURN;
 }//Ndb::closeTransaction()
 
-/*****************************************************************************
-int* NdbTamper(int aAction, int aNode);
-
-Parameters: aAction     Specifies what action to be taken
-            1: Lock global checkpointing    Can only be sent to master DIH, Parameter aNode ignored.
-            2: UnLock global checkpointing    Can only be sent to master DIH, Parameter aNode ignored.
-	    3: Crash node
-
-           aNode        Specifies which node the action will be taken
-     	  -1: Master DIH 
-       	0-16: Nodnumber
-
-Return Value: -1 Error  .
-                
-Remark:         Sends a signal to DIH.
-*****************************************************************************/ 
-int 
-Ndb::NdbTamper(TamperType aAction, int aNode)
-{
-  NdbTransaction*	tNdbConn;
-  NdbApiSignal		tSignal(theMyRef);
-  int			tNode;
-  int                   tAction;
-  int			ret_code;
-
-#ifdef CUSTOMER_RELEASE
-  return -1;
-#else
-  DBUG_ENTER("Ndb::NdbTamper");
-  CHECK_STATUS_MACRO;
-  checkFailedNode();
-
-  theRestartGCI = 0;
-  switch (aAction) {
-// Translate enum to integer. This is done because the SCI layer
-// expects integers. 
-     case LockGlbChp:
-        tAction = 1;
-        break;
-     case UnlockGlbChp:
-        tAction = 2;
-	break;
-     case CrashNode:
-        tAction = 3;
-        break;
-     case ReadRestartGCI:
-	tAction = 4;
-	break;
-     default:
-        theError.code = 4102;
-        DBUG_RETURN(-1);
-  }
-
-  tNdbConn = getNdbCon();	// Get free connection object
-  if (tNdbConn == NULL) {
-    theError.code = 4000;
-    DBUG_RETURN(-1);
-  }
-  tSignal.setSignal(GSN_DIHNDBTAMPER);
-  tSignal.setData (tAction, 1);
-  tSignal.setData(tNdbConn->ptr2int(),2);
-  tSignal.setData(theMyRef,3);		// Set return block reference
-  tNdbConn->Status(NdbTransaction::Connecting); // Set status to connecting
-  TransporterFacade *tp = theImpl->m_transporter_facade;
-  if (tAction == 3) {
-    tp->lock_mutex();
-    tp->sendSignal(&tSignal, aNode);
-    tp->unlock_mutex();
-    releaseNdbCon(tNdbConn);
-  } else if ( (tAction == 2) || (tAction == 1) ) {
-    tp->lock_mutex();
-    tNode = tp->get_an_alive_node();
-    if (tNode == 0) {
-      theError.code = 4002;
-      releaseNdbCon(tNdbConn);
-      DBUG_RETURN(-1);
-    }//if
-    ret_code = tp->sendSignal(&tSignal,aNode);
-    tp->unlock_mutex();
-    releaseNdbCon(tNdbConn);
-    DBUG_RETURN(ret_code);
-  } else {
-    do {
-      tp->lock_mutex();
-      // Start protected area
-      tNode = tp->get_an_alive_node();
-      tp->unlock_mutex();
-      // End protected area
-      if (tNode == 0) {
-        theError.code = 4009;
-        releaseNdbCon(tNdbConn);
-        DBUG_RETURN(-1);
-      }//if
-      ret_code = sendRecSignal(tNode, WAIT_NDB_TAMPER, &tSignal, 0);
-      if (ret_code == 0) {  
-        if (tNdbConn->Status() != NdbTransaction::Connected) {
-          theRestartGCI = 0;
-        }//if
-        releaseNdbCon(tNdbConn);
-        DBUG_RETURN(theRestartGCI);
-      } else if ((ret_code == -5) || (ret_code == -2)) {
-        TRACE_DEBUG("Continue DIHNDBTAMPER when node failed/stopping");
-      } else {
-        DBUG_RETURN(-1);
-      }//if
-    } while (1);
-  }
-  DBUG_RETURN(0);
-#endif
-}
-#if 0
-/****************************************************************************
-NdbSchemaCon* startSchemaTransaction();
-
-Return Value:   Returns a pointer to a schema connection object.
-                Return NULL otherwise.
-Remark:         Start schema transaction. Synchronous.
-****************************************************************************/ 
-NdbSchemaCon* 
-Ndb::startSchemaTransaction()
-{
-  NdbSchemaCon* tSchemaCon;
-  if (theSchemaConToNdbList != NULL) {
-    theError.code = 4321;
-    return NULL;
-  }//if
-  tSchemaCon = new NdbSchemaCon(this);
-  if (tSchemaCon == NULL) {
-    theError.code = 4000;
-    return NULL;
-  }//if 
-  theSchemaConToNdbList = tSchemaCon;
-  return tSchemaCon;  
-}
-/*****************************************************************************
-void closeSchemaTransaction(NdbSchemaCon* aSchemaCon);
-
-Parameters:     aSchemaCon: the schemacon used in the transaction.
-Remark:         Close transaction by releasing the schemacon and all schemaop.
-*****************************************************************************/
-void
-Ndb::closeSchemaTransaction(NdbSchemaCon* aSchemaCon)
-{
-  if (theSchemaConToNdbList != aSchemaCon) {
-    abort();
-    return;
-  }//if
-  aSchemaCon->release();
-  delete aSchemaCon;
-  theSchemaConToNdbList = NULL;
-  return;
-}//Ndb::closeSchemaTransaction()
-#endif
-
-/*****************************************************************************
-void RestartGCI(int aRestartGCI);
-
-Remark:		Set theRestartGCI on the NDB object
-*****************************************************************************/
-void
-Ndb::RestartGCI(int aRestartGCI)
-{
-  theRestartGCI = aRestartGCI;
-}
-
 /****************************************************************************
 int getBlockNumber(void);
 

=== modified file 'storage/ndb/src/ndbapi/NdbApiSignal.cpp'
--- a/storage/ndb/src/ndbapi/NdbApiSignal.cpp	2010-09-29 13:25:19 +0000
+++ b/storage/ndb/src/ndbapi/NdbApiSignal.cpp	2010-10-01 18:49:35 +0000
@@ -278,6 +278,7 @@ NdbApiSignal::set(Uint8  trace,
 
 void
 NdbApiSignal::copyFrom(const NdbApiSignal * src){
+  theSignalId             = src->theSignalId;
   theVerId_signalNumber   = src->theVerId_signalNumber;
   theReceiversBlockNumber = src->theReceiversBlockNumber;
   theSendersBlockRef      = src->theSendersBlockRef;
@@ -292,11 +293,4 @@ NdbApiSignal::copyFrom(const NdbApiSigna
     dstData[i] = srcData[i];
 
   setDataPtr(dstData);
-  
-  /**
-   * NOTE that theSignalId is used as data ptr
-   *   and should not be copied
-   * NOTE that theSendersSignalId is used as next pointer
-   *   and should not be copied
-   */
 }

=== modified file 'storage/ndb/src/ndbapi/NdbApiSignal.hpp'
--- a/storage/ndb/src/ndbapi/NdbApiSignal.hpp	2010-09-29 13:25:19 +0000
+++ b/storage/ndb/src/ndbapi/NdbApiSignal.hpp	2010-09-30 09:32:28 +0000
@@ -33,27 +33,10 @@
 #define NdbApiSignal_H
 
 #include <kernel_types.h>
-#include "TransporterFacade.hpp"
+#include <RefConvert.hpp>
 #include <TransporterDefinitions.hpp>
-#include "Ndb.hpp"
 
-#include <signaldata/GetTabInfo.hpp>
-#include <signaldata/DictTabInfo.hpp>
-#include <signaldata/CreateTable.hpp>
-#include <signaldata/CreateIndx.hpp>
-#include <signaldata/CreateEvnt.hpp>
-#include <signaldata/SumaImpl.hpp>
-#include <signaldata/DropTable.hpp>
-#include <signaldata/AlterTable.hpp>
-#include <signaldata/DropIndx.hpp>
-#include <signaldata/ListTables.hpp>
-#include <signaldata/DropFilegroup.hpp>
-#include <signaldata/CreateFilegroup.hpp>
-#include <signaldata/WaitGCP.hpp>
-#include <signaldata/SchemaTrans.hpp>
-#include <signaldata/CreateHashMap.hpp>
-#include <signaldata/ApiRegSignalData.hpp>
-#include <signaldata/ArbitSignalData.hpp>
+class Ndb;
 
 /**
  * A NdbApiSignal : public SignalHeader

=== modified file 'storage/ndb/src/ndbapi/NdbBlob.cpp'
--- a/storage/ndb/src/ndbapi/NdbBlob.cpp	2010-02-26 12:44:34 +0000
+++ b/storage/ndb/src/ndbapi/NdbBlob.cpp	2010-09-30 09:32:28 +0000
@@ -16,20 +16,9 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 */
 
-#include <Ndb.hpp>
-#include <NdbDictionaryImpl.hpp>
-#include <NdbTransaction.hpp>
-#include <NdbOperation.hpp>
-#include <NdbIndexOperation.hpp>
-#include <NdbRecAttr.hpp>
-#include <NdbBlob.hpp>
-#include "NdbBlobImpl.hpp"
-#include <NdbScanOperation.hpp>
+#include "API.hpp"
 #include <signaldata/TcKeyReq.hpp>
-#include <NdbEventOperationImpl.hpp>
 #include <NdbEnv.h>
-#include "NdbRecord.hpp"
-#include "NdbUtil.hpp"
 #include <ndb_version.h>
 
 /*

=== modified file 'storage/ndb/src/ndbapi/NdbDictionary.cpp'
--- a/storage/ndb/src/ndbapi/NdbDictionary.cpp	2010-09-23 11:55:42 +0000
+++ b/storage/ndb/src/ndbapi/NdbDictionary.cpp	2010-10-04 14:44:27 +0000
@@ -2570,6 +2570,12 @@ NdbDictionary::Dictionary::forceGCPWait(
   return m_impl.forceGCPWait(type);
 }
 
+int
+NdbDictionary::Dictionary::getRestartGCI(Uint32 * gci)
+{
+  return m_impl.getRestartGCI(gci);
+}
+
 void
 NdbDictionary::Dictionary::removeCachedIndex(const Index *index){
   DBUG_ENTER("NdbDictionary::Dictionary::removeCachedIndex");

=== modified file 'storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp'
--- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2010-09-30 07:19:22 +0000
+++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2010-10-01 10:08:29 +0000
@@ -16,19 +16,11 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 */
 
-#include "NdbDictionaryImpl.hpp"
 #include "API.hpp"
 #include <NdbOut.hpp>
-#include "NdbApiSignal.hpp"
-#include "TransporterFacade.hpp"
 #include <SimpleProperties.hpp>
 #include <Bitmask.hpp>
 #include <AttributeList.hpp>
-#include <NdbEventOperation.hpp>
-#include "NdbEventOperationImpl.hpp"
-#include <NdbBlob.hpp>
-#include "NdbBlobImpl.hpp"
-#include <NdbInterpretedCode.hpp>
 #include <AttributeHeader.hpp>
 #include <my_sys.h>
 #include <NdbEnv.h>
@@ -36,6 +28,23 @@
 #include <util/version.h>
 #include <NdbSleep.h>
 
+#include <signaldata/GetTabInfo.hpp>
+#include <signaldata/DictTabInfo.hpp>
+#include <signaldata/CreateTable.hpp>
+#include <signaldata/CreateIndx.hpp>
+#include <signaldata/CreateEvnt.hpp>
+#include <signaldata/SumaImpl.hpp>
+#include <signaldata/DropTable.hpp>
+#include <signaldata/AlterTable.hpp>
+#include <signaldata/DropIndx.hpp>
+#include <signaldata/ListTables.hpp>
+#include <signaldata/DropFilegroup.hpp>
+#include <signaldata/CreateFilegroup.hpp>
+#include <signaldata/WaitGCP.hpp>
+#include <signaldata/SchemaTrans.hpp>
+#include <signaldata/CreateHashMap.hpp>
+#include <signaldata/ApiRegSignalData.hpp>
+
 #define DEBUG_PRINT 0
 #define INCOMPATIBLE_VERSION -2
 
@@ -2196,17 +2205,17 @@ NdbDictInterface::execSignal(void* dictI
 }
 
 void
-NdbDictInterface::execNodeStatus(void* dictImpl, Uint32 aNode,
-				 bool alive, bool nfCompleted)
+NdbDictInterface::execNodeStatus(void* dictImpl, Uint32 aNode, Uint32 ns_event)
 {
   NdbDictInterface * tmp = (NdbDictInterface*)dictImpl;
+  NS_Event event = (NS_Event)ns_event;
   
-  if(!alive && !nfCompleted){
-    return;
-  }
-  
-  if (!alive && nfCompleted){
+  switch(event){
+  case NS_NODE_FAILED:
     tmp->m_waiter.nodeFail(aNode);
+    break;
+  default:
+    break;
   }
 }
 
@@ -4597,7 +4606,7 @@ NdbDictInterface::executeSubscribeEvent(
                        errCodes, -1);
   if (ret == 0)
   {
-    buckets =m_sub_start_conf.m_buckets;
+    buckets = m_data.m_sub_start_conf.m_buckets;
   }
 
   DBUG_RETURN(ret);
@@ -4912,7 +4921,7 @@ NdbDictInterface::execSUB_START_CONF(con
 
   if (signal->getLength() == SubStartConf::SignalLength)
   {
-    m_sub_start_conf.m_buckets = subStartConf->bucketCount;
+    m_data.m_sub_start_conf.m_buckets = subStartConf->bucketCount;
   }
   else
   {
@@ -4920,7 +4929,7 @@ NdbDictInterface::execSUB_START_CONF(con
      * 6.3 doesn't send required bucketCount.  
      * ~0 indicates no bucketCount received
      */
-    m_sub_start_conf.m_buckets = ~0;
+    m_data.m_sub_start_conf.m_buckets = ~0;
   }
   DBUG_PRINT("info",("subscriptionId=%d,subscriptionKey=%d,subscriberData=%d",
 		     subscriptionId,subscriptionKey,subscriberData));
@@ -5095,7 +5104,6 @@ NdbDictInterface::execDROP_EVNT_REF(cons
   DBUG_VOID_RETURN;
 }
 
-#include <NdbScanOperation.hpp>
 static int scanEventTable(Ndb* pNdb, 
                           const NdbDictionary::Table* pTab,
                           NdbDictionary::Dictionary::List &list)
@@ -5770,12 +5778,15 @@ int
 NdbDictInterface::forceGCPWait(int type)
 {
   NdbApiSignal tSignal(m_reference);
-  if (type == 0)
+  if (type == 0 || type == 2)
   {
     WaitGCPReq* const req = CAST_PTR(WaitGCPReq, tSignal.getDataPtrSend());
     req->senderRef = m_reference;
     req->senderData = 0;
-    req->requestType = WaitGCPReq::CompleteForceStart;
+    req->requestType = 
+      type == 0 ? 
+      WaitGCPReq::CompleteForceStart : WaitGCPReq::RestartGCI;
+      
     tSignal.theReceiversBlockNumber = DBDIH;
     tSignal.theVerId_signalNumber = GSN_WAIT_GCP_REQ;
     tSignal.theLength = WaitGCPReq::SignalLength;
@@ -5800,7 +5811,7 @@ NdbDictInterface::forceGCPWait(int type)
       m_waiter.m_state = WAIT_LIST_TABLES_CONF;
       m_waiter.wait(DICT_WAITFOR_TIMEOUT);
       m_transporter->unlock_mutex();
-      return 0;
+      return m_error.code == 0 ? 0 : -1;
     }
     return -1;
   }
@@ -5829,15 +5840,34 @@ NdbDictInterface::forceGCPWait(int type)
       m_transporter->forceSend(refToBlock(m_reference));
       m_transporter->unlock_mutex();
     }
-    return 0;
+    return m_error.code == 0 ? 0 : -1;
+  }
+  else
+  {
+    m_error.code = 4003;
   }
   return -1;
 }
 
+int
+NdbDictionaryImpl::getRestartGCI(Uint32 * gci)
+{
+  int res = m_receiver.forceGCPWait(2);
+  if (res == 0 && gci != 0)
+  {
+    * gci = m_receiver.m_data.m_wait_gcp_conf.gci_hi;
+  }
+  return res;
+}
+
 void
 NdbDictInterface::execWAIT_GCP_CONF(const NdbApiSignal* signal,
 				    const LinearSectionPtr ptr[3])
 {
+  const WaitGCPConf* conf = CAST_CONSTPTR(WaitGCPConf, signal->getDataPtr());
+
+  m_data.m_wait_gcp_conf.gci_lo = conf->gci_lo;
+  m_data.m_wait_gcp_conf.gci_hi = conf->gci_hi;
   m_waiter.signal(NO_WAIT);
 }
 
@@ -5845,6 +5875,9 @@ void
 NdbDictInterface::execWAIT_GCP_REF(const NdbApiSignal* signal,
                                    const LinearSectionPtr ptr[3])
 {
+  const WaitGCPRef* ref = CAST_CONSTPTR(WaitGCPRef, signal->getDataPtr());
+  m_error.code = ref->errorCode;
+
   m_waiter.signal(NO_WAIT);
 }
 

=== modified file 'storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp'
--- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp	2010-09-29 13:25:19 +0000
+++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp	2010-10-01 10:08:29 +0000
@@ -661,6 +661,7 @@ public:
 			  Uint32 noOfSections, bool fullyQualifiedNames);
 
   int forceGCPWait(int type);
+  int getRestartGCI(Uint32 *);
 
   static int parseTableInfo(NdbTableImpl ** dst, 
 			    const Uint32 * data, Uint32 len,
@@ -712,13 +713,13 @@ private:
   class TransporterFacade * m_transporter;
   
   friend class Ndb;
+  friend class NdbImpl;
   friend class NdbDictionaryImpl;
   static void execSignal(void* dictImpl, 
 			 const class NdbApiSignal* signal,
 			 const struct LinearSectionPtr ptr[3]);
   
-  static void execNodeStatus(void* dictImpl, Uint32, 
-			     bool alive, bool nfCompleted);  
+  static void execNodeStatus(void* dictImpl, Uint32, Uint32);
   
   void execGET_TABINFO_REF(const NdbApiSignal *, const LinearSectionPtr p[3]);
   void execGET_TABINFO_CONF(const NdbApiSignal *, const LinearSectionPtr p[3]);
@@ -787,9 +788,15 @@ private:
   UtilBuffer m_tableData;
   UtilBuffer m_tableNames;
 
-  struct {
-    Uint32 m_buckets;
-  } m_sub_start_conf;
+  union {
+    struct SubStartConfData {
+      Uint32 m_buckets;
+    } m_sub_start_conf;
+    struct WaitGcpData {
+      Uint32 gci_hi;
+      Uint32 gci_lo;
+    } m_wait_gcp_conf;
+  } m_data;
 };
 
 class NdbDictionaryImpl;
@@ -846,6 +853,7 @@ public:
   int stopSubscribeEvent(NdbEventOperationImpl &);
 
   int forceGCPWait(int type);
+  int getRestartGCI(Uint32*);
 
   int listObjects(List& list, NdbDictionary::Object::Type type, 
                   bool fullyQualified);

=== modified file 'storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp'
--- a/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp	2010-09-29 13:25:19 +0000
+++ b/storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp	2010-10-04 11:13:48 +0000
@@ -20,11 +20,9 @@
 #include <ndb_global.h>
 #include <kernel_types.h>
 
-#include "NdbDictionaryImpl.hpp"
 #include "API.hpp"
 #include <NdbOut.hpp>
-#include "NdbApiSignal.hpp"
-#include "TransporterFacade.hpp"
+
 #include <signaldata/CreateEvnt.hpp>
 #include <signaldata/SumaImpl.hpp>
 #include <SimpleProperties.hpp>
@@ -34,21 +32,14 @@
 #include <NdbError.hpp>
 #include <BaseString.hpp>
 #include <UtilBuffer.hpp>
-#include <NdbDictionary.hpp>
-#include <Ndb.hpp>
-#include "NdbImpl.hpp"
-#include "DictCache.hpp"
 #include <portlib/NdbMem.h>
-#include <NdbRecAttr.hpp>
-#include <NdbBlob.hpp>
-#include <NdbEventOperation.hpp>
-#include "NdbEventOperationImpl.hpp"
 #include <signaldata/AlterTable.hpp>
 #include "ndb_internal.hpp"
 
 #include <EventLogger.hpp>
 extern EventLogger * g_eventLogger;
 
+#define TOTAL_BUCKETS_INIT (1 << 15)
 static Gci_container_pod g_empty_gci_container;
 
 #if defined(VM_TRACE) && defined(NOT_USED)
@@ -598,6 +589,18 @@ NdbEventOperationImpl::execute_nolock()
     DBUG_RETURN(-1);
   }
 
+  bool schemaTrans = false;
+  if (m_ndb->theEventBuffer->m_total_buckets == TOTAL_BUCKETS_INIT)
+  {
+    int res = myDict->beginSchemaTrans();
+    if (res != 0)
+    {
+      m_error.code= myDict->getNdbError().code;
+      DBUG_RETURN(-1);
+    }
+    schemaTrans = true;
+  }
+
   if (theFirstPkAttrs[0] == NULL && 
       theFirstDataAttrs[0] == NULL) { // defaults to get all
   }
@@ -623,6 +626,11 @@ NdbEventOperationImpl::execute_nolock()
       buckets = m_ndb->theImpl->theNoOfDBnodes;
 
     m_ndb->theEventBuffer->set_total_buckets(buckets);
+    if (schemaTrans)
+    {
+      schemaTrans = false;
+      myDict->endSchemaTrans(1);
+    }
 
     if (theMainOp == NULL) {
       DBUG_PRINT("info", ("execute blob ops"));
@@ -656,6 +664,13 @@ NdbEventOperationImpl::execute_nolock()
   m_magic_number= 0;
   m_error.code= myDict->getNdbError().code;
   m_ndb->theEventBuffer->remove_op();
+
+  if (schemaTrans)
+  {
+    schemaTrans = false;
+    myDict->endSchemaTrans(1);
+  }
+
   DBUG_RETURN(r);
 }
 
@@ -1066,8 +1081,6 @@ NdbEventOperationImpl::printAll()
  * Class NdbEventBuffer
  * Each Ndb object has a Object.
  */
-#define TOTAL_BUCKETS_INIT (1 << 15)
-
 NdbEventBuffer::NdbEventBuffer(Ndb *ndb) :
   m_total_buckets(TOTAL_BUCKETS_INIT), 
   m_min_gci_index(0),
@@ -2235,8 +2248,10 @@ NdbEventBuffer::handle_change_nodegroup(
       Gci_container* tmp = find_bucket(array[pos]);
       assert((tmp->m_state & Gci_container::GC_CHANGE_CNT) == 0);
       tmp->m_gcp_complete_rep_count -= cnt;
-      ndbout_c(" - decreasing cnt on %u/%u by %u",
-               Uint32(tmp->m_gci >> 32), Uint32(tmp->m_gci), cnt);
+      ndbout_c(" - decreasing cnt on %u/%u by %u to: %u",
+               Uint32(tmp->m_gci >> 32), Uint32(tmp->m_gci), 
+               cnt,
+               tmp->m_gcp_complete_rep_count);
     }
   }
 }

=== modified file 'storage/ndb/src/ndbapi/NdbImpl.hpp'
--- a/storage/ndb/src/ndbapi/NdbImpl.hpp	2010-02-03 15:14:07 +0000
+++ b/storage/ndb/src/ndbapi/NdbImpl.hpp	2010-10-04 14:44:27 +0000
@@ -20,12 +20,8 @@
 #define NDB_IMPL_HPP
 
 #include <ndb_global.h>
-#include <Ndb.hpp>
+#include "API.hpp"
 #include <NdbOut.hpp>
-#include <NdbError.hpp>
-#include <NdbCondition.h>
-#include <NdbReceiver.hpp>
-#include <NdbOperation.hpp>
 #include <kernel/ndb_limits.h>
 #include <NdbTick.h>
 
@@ -33,6 +29,7 @@
 #include "ndb_cluster_connection_impl.hpp"
 #include "NdbDictionaryImpl.hpp"
 #include "ObjectMap.hpp"
+#include "trp_client.hpp"
 
 template <class T>
 struct Ndb_free_list_t 
@@ -53,7 +50,8 @@ struct Ndb_free_list_t 
 /**
  * Private parts of the Ndb object (corresponding to Ndb.hpp in public API)
  */
-class NdbImpl {
+class NdbImpl : public trp_client
+{
 public:
   NdbImpl(Ndb_cluster_connection *, Ndb&);
   ~NdbImpl();
@@ -117,6 +115,13 @@ public:
     ndb->theImpl->forceShortRequests = val;
   }
 
+  Uint32 get_waitfor_timeout() const {
+    return m_ndb_cluster_connection.m_config.m_waitfor_timeout;
+  }
+  const NdbApiConfig& get_ndbapi_config_parameters() const {
+    return m_ndb_cluster_connection.m_config;
+  }
+
 
   BaseString m_systemPrefix; // Buffer for preformatted for <sys>/<def>/
 
@@ -139,6 +144,13 @@ public:
   Ndb_free_list_t<NdbOperation>  theOpIdleList;  
   Ndb_free_list_t<NdbIndexOperation> theIndexOpIdleList;
   Ndb_free_list_t<NdbTransaction> theConIdleList; 
+
+  /**
+   * trp_client interface
+   */
+  virtual void trp_deliver_signal(const NdbApiSignal*,
+                                  const LinearSectionPtr p[3]);
+  virtual void trp_node_status(Uint32, Uint32);
 };
 
 #ifdef VM_TRACE

=== modified file 'storage/ndb/src/ndbapi/NdbInfoScanOperation.cpp'
--- a/storage/ndb/src/ndbapi/NdbInfoScanOperation.cpp	2010-08-17 09:54:53 +0000
+++ b/storage/ndb/src/ndbapi/NdbInfoScanOperation.cpp	2010-09-30 09:32:28 +0000
@@ -18,7 +18,7 @@
 
 #include "NdbInfo.hpp"
 #include "SignalSender.hpp"
-
+#include <kernel/GlobalSignalNumbers.h>
 #include <AttributeHeader.hpp>
 #include <signaldata/DbinfoScan.hpp>
 #include <signaldata/TransIdAI.hpp>

=== modified file 'storage/ndb/src/ndbapi/NdbOperation.cpp'
--- a/storage/ndb/src/ndbapi/NdbOperation.cpp	2010-02-03 15:14:07 +0000
+++ b/storage/ndb/src/ndbapi/NdbOperation.cpp	2010-10-04 14:44:27 +0000
@@ -16,19 +16,8 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 */
 
-#include <ndb_global.h>
-#include <NdbTransaction.hpp>
-#include <NdbOperation.hpp>
-#include "NdbApiSignal.hpp"
-#include "NdbRecAttr.hpp"
-#include "NdbUtil.hpp"
-#include "NdbBlob.hpp"
-#include "ndbapi_limits.h"
-#include <signaldata/TcKeyReq.hpp>
-#include "NdbDictionaryImpl.hpp"
-
 #include "API.hpp"
-#include <NdbOut.hpp>
+#include <signaldata/TcKeyReq.hpp>
 
 
 /******************************************************************************

=== modified file 'storage/ndb/src/ndbapi/NdbOperationExec.cpp'
--- a/storage/ndb/src/ndbapi/NdbOperationExec.cpp	2010-09-29 13:49:49 +0000
+++ b/storage/ndb/src/ndbapi/NdbOperationExec.cpp	2010-10-04 14:44:27 +0000
@@ -17,14 +17,7 @@
 */
 
 #include <ndb_global.h>
-#include <NdbOperation.hpp>
-#include <NdbTransaction.hpp>
-#include <NdbBlob.hpp>
-#include "NdbApiSignal.hpp"
-#include <Ndb.hpp>
-#include <NdbRecAttr.hpp>
-#include "NdbUtil.hpp"
-#include "NdbInterpretedCode.hpp"
+#include "API.hpp"
 
 #include "Interpreter.hpp"
 #include <AttributeHeader.hpp>

=== modified file 'storage/ndb/src/ndbapi/NdbOperationSearch.cpp'
--- a/storage/ndb/src/ndbapi/NdbOperationSearch.cpp	2009-11-27 14:47:24 +0000
+++ b/storage/ndb/src/ndbapi/NdbOperationSearch.cpp	2010-09-30 09:32:28 +0000
@@ -31,18 +31,10 @@ Adjust:  971022  UABMNST   First version
  *****************************************************************************/
 #include "API.hpp"
 
-#include <NdbOperation.hpp>
-#include "NdbApiSignal.hpp"
-#include <NdbTransaction.hpp>
-#include <Ndb.hpp>
-#include "NdbImpl.hpp"
-#include <NdbOut.hpp>
-#include "NdbBlob.hpp"
 
 #include <AttributeHeader.hpp>
 #include <signaldata/TcKeyReq.hpp>
 #include <signaldata/KeyInfo.hpp>
-#include "NdbDictionaryImpl.hpp"
 #include <md5_hash.hpp>
 
 /******************************************************************************

=== modified file 'storage/ndb/src/ndbapi/NdbQueryOperation.cpp'
--- a/storage/ndb/src/ndbapi/NdbQueryOperation.cpp	2010-09-29 13:49:49 +0000
+++ b/storage/ndb/src/ndbapi/NdbQueryOperation.cpp	2010-10-04 14:44:27 +0000
@@ -18,9 +18,9 @@
 
 
 #include <ndb_global.h>
+#include "API.hpp"
 #include <NdbQueryBuilder.hpp>
 #include "NdbQueryBuilderImpl.hpp"
-
 #include "NdbQueryOperationImpl.hpp"
 
 #include <signaldata/TcKeyReq.hpp>
@@ -30,13 +30,6 @@
 #include <signaldata/DbspjErr.hpp>
 
 #include "AttributeHeader.hpp"
-#include "NdbRecord.hpp"
-#include "NdbRecAttr.hpp"
-#include "TransporterFacade.hpp"
-#include "NdbApiSignal.hpp"
-#include "NdbTransaction.hpp"
-#include "NdbInterpretedCode.hpp"
-#include "NdbScanFilter.hpp"
 
 #include <Bitmask.hpp>
 
@@ -1385,6 +1378,7 @@ NdbQueryImpl::fetchMoreResults(bool forc
     assert (m_scanTransaction);
 
     Ndb* const ndb = m_transaction.getNdb();
+    Uint32 timeout = ndb->theImpl->get_waitfor_timeout();
     TransporterFacade* const facade = ndb->theImpl->m_transporter_facade;
 
     /* This part needs to be done under mutex due to synchronization with 
@@ -1413,7 +1407,7 @@ NdbQueryImpl::fetchMoreResults(bool forc
 
         /* More results are on the way, so we wait for them.*/
         const FetchResult waitResult = static_cast<FetchResult>
-          (poll_guard.wait_scan(3*facade->m_waitfor_timeout, 
+          (poll_guard.wait_scan(3*timeout, 
                                 m_transaction.getConnectedNodeId(), 
                                 forceSend));
         if(waitResult != FetchResult_ok){
@@ -1678,7 +1672,7 @@ NdbQueryImpl::prepareSend()
     // when building signal after max-batchRows has been determined.
     for (Uint32 i = 0; i < m_countOperations; i++) {
       Uint32 batchByteSize, firstBatchRows;
-      NdbReceiver::calculate_batch_size(tp,
+      NdbReceiver::calculate_batch_size(* ndb->theImpl,
                                     m_operations[i].m_ndbRecord,
                                     m_operations[i].m_firstRecAttr,
                                     0, // Key size.
@@ -1938,7 +1932,7 @@ NdbQueryImpl::doSend(int nodeId, bool la
 
     Uint32 batchRows = m_maxBatchRows;
     Uint32 batchByteSize, firstBatchRows;
-    NdbReceiver::calculate_batch_size(tp,
+    NdbReceiver::calculate_batch_size(* ndb.theImpl,
                                       root.m_ndbRecord,
                                       root.m_firstRecAttr,
                                       0, // Key size.
@@ -2303,6 +2297,7 @@ NdbQueryImpl::closeTcCursor(bool forceSe
   assert (m_queryDef.isScanQuery());
 
   Ndb* const ndb = m_transaction.getNdb();
+  Uint32 timeout = ndb->theImpl->get_waitfor_timeout();
   TransporterFacade* const facade = ndb->theImpl->m_transporter_facade;
 
   /* This part needs to be done under mutex due to synchronization with 
@@ -2316,7 +2311,7 @@ NdbQueryImpl::closeTcCursor(bool forceSe
   while (m_error.code==0 && !isBatchComplete())
   {
     const FetchResult waitResult = static_cast<FetchResult>
-          (poll_guard.wait_scan(3*facade->m_waitfor_timeout, 
+          (poll_guard.wait_scan(3*timeout, 
                                 m_transaction.getConnectedNodeId(), 
                                 forceSend));
     switch (waitResult) {
@@ -2350,7 +2345,7 @@ NdbQueryImpl::closeTcCursor(bool forceSe
     while (m_pendingFrags > 0)
     {
       const FetchResult waitResult = static_cast<FetchResult>
-            (poll_guard.wait_scan(3*facade->m_waitfor_timeout, 
+            (poll_guard.wait_scan(3*timeout, 
                                   m_transaction.getConnectedNodeId(), 
                                   forceSend));
       switch (waitResult) {

=== modified file 'storage/ndb/src/ndbapi/NdbReceiver.cpp'
--- a/storage/ndb/src/ndbapi/NdbReceiver.cpp	2010-09-29 13:49:49 +0000
+++ b/storage/ndb/src/ndbapi/NdbReceiver.cpp	2010-10-04 14:44:27 +0000
@@ -140,7 +140,7 @@ NdbReceiver::getValues(const NdbRecord* 
 */
 //static
 void
-NdbReceiver::calculate_batch_size(const TransporterFacade *tp,
+NdbReceiver::calculate_batch_size(const NdbImpl& theImpl,
                                   const NdbRecord *record,
                                   const NdbRecAttr *first_rec_attr,
                                   Uint32 key_size,
@@ -149,9 +149,10 @@ NdbReceiver::calculate_batch_size(const 
                                   Uint32& batch_byte_size,
                                   Uint32& first_batch_size)
 {
-  const Uint32 max_scan_batch_size= tp->get_scan_batch_size();
-  const Uint32 max_batch_byte_size= tp->get_batch_byte_size();
-  const Uint32 max_batch_size= tp->get_batch_size();
+  const NdbApiConfig & cfg = theImpl.get_ndbapi_config_parameters();
+  const Uint32 max_scan_batch_size= cfg.m_scan_batch_size;
+  const Uint32 max_batch_byte_size= cfg.m_batch_byte_size;
+  const Uint32 max_batch_size= cfg.m_batch_size;
 
   Uint32 tot_size= (key_size ? (key_size + 32) : 0); //key + signal overhead
   if (record)
@@ -209,7 +210,7 @@ NdbReceiver::calculate_batch_size(Uint32
                                   Uint32& first_batch_size,
                                   const NdbRecord *record) const
 {
-  calculate_batch_size(m_ndb->theImpl->m_transporter_facade,
+  calculate_batch_size(* m_ndb->theImpl,
                        record,
                        theFirstRecAttr,
                        key_size, parallelism, batch_size, batch_byte_size,

=== modified file 'storage/ndb/src/ndbapi/NdbScanFilter.cpp'
--- a/storage/ndb/src/ndbapi/NdbScanFilter.cpp	2009-05-27 15:21:45 +0000
+++ b/storage/ndb/src/ndbapi/NdbScanFilter.cpp	2010-09-30 09:32:28 +0000
@@ -16,18 +16,12 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 */
 
+#include "API.hpp"
 #include <NdbScanFilter.hpp>
-#include <Ndb.hpp>
-#include <NdbOperation.hpp>
-#include <NdbScanOperation.hpp>
-#include "NdbDictionaryImpl.hpp"
 #include <Vector.hpp>
 #include <NdbOut.hpp>
 #include <Interpreter.hpp>
 #include <signaldata/AttrInfo.hpp>
-#include "NdbApiSignal.hpp"
-#include "NdbUtil.hpp"
-#include <NdbInterpretedCode.hpp>
 
 #ifdef VM_TRACE
 #include <NdbEnv.h>

=== modified file 'storage/ndb/src/ndbapi/NdbScanOperation.cpp'
--- a/storage/ndb/src/ndbapi/NdbScanOperation.cpp	2010-09-29 13:49:49 +0000
+++ b/storage/ndb/src/ndbapi/NdbScanOperation.cpp	2010-10-04 14:44:27 +0000
@@ -1829,6 +1829,7 @@ NdbScanOperation::nextResultNdbRecord(co
 
   /* Now we have to wait for more rows (or end-of-file on all receivers). */
   Uint32 nodeId = theNdbCon->theDBnode;
+  Uint32 timeout= theNdb->theImpl->get_waitfor_timeout();
   TransporterFacade* tp = theNdb->theImpl->m_transporter_facade;
   int retVal= 2;
   Uint32 idx, last;
@@ -1851,7 +1852,6 @@ NdbScanOperation::nextResultNdbRecord(co
   {
     idx= m_current_api_receiver;
     last= m_api_receivers_count;
-    Uint32 timeout= tp->m_waitfor_timeout;
 
     do {
       if (theError.code){
@@ -3690,6 +3690,7 @@ NdbIndexScanOperation::ordered_insert_re
 int
 NdbIndexScanOperation::ordered_send_scan_wait_for_all(bool forceSend)
 {
+  Uint32 timeout= theNdb->theImpl->get_waitfor_timeout();
   TransporterFacade* tp= theNdb->theImpl->m_transporter_facade;
 
   PollGuard poll_guard(tp, &theNdb->theImpl->theWaiter,
@@ -3699,7 +3700,6 @@ NdbIndexScanOperation::ordered_send_scan
 
   Uint32 seq= theNdbCon->theNodeSequence;
   Uint32 nodeId= theNdbCon->theDBnode;
-  Uint32 timeout= tp->m_waitfor_timeout;
   if (seq == tp->getNodeSequence(nodeId) &&
       !send_next_scan_ordered(m_current_api_receiver))
   {
@@ -3789,6 +3789,7 @@ int
 NdbScanOperation::close_impl(TransporterFacade* tp, bool forceSend,
                              PollGuard *poll_guard)
 {
+  Uint32 timeout= theNdb->theImpl->get_waitfor_timeout();
   Uint32 seq = theNdbCon->theNodeSequence;
   Uint32 nodeId = theNdbCon->theDBnode;
   
@@ -3798,7 +3799,6 @@ NdbScanOperation::close_impl(Transporter
     return -1;
   }
   
-  Uint32 timeout = tp->m_waitfor_timeout;
   /**
    * Wait for outstanding
    */

=== modified file 'storage/ndb/src/ndbapi/NdbTransaction.cpp'
--- a/storage/ndb/src/ndbapi/NdbTransaction.cpp	2010-09-29 13:49:49 +0000
+++ b/storage/ndb/src/ndbapi/NdbTransaction.cpp	2010-10-04 14:44:27 +0000
@@ -18,19 +18,7 @@
 
 #include <ndb_global.h>
 #include <NdbOut.hpp>
-#include <NdbTransaction.hpp>
-#include <NdbOperation.hpp>
-#include <NdbScanOperation.hpp>
-#include <NdbIndexScanOperation.hpp>
-#include <NdbIndexOperation.hpp>
-#include <NdbDictionaryImpl.hpp>
-#include <NdbQueryOperationImpl.hpp>
-#include <NdbQueryBuilder.hpp>
-#include "NdbApiSignal.hpp"
-#include "TransporterFacade.hpp"
 #include "API.hpp"
-#include "NdbBlob.hpp"
-#include "NdbUtil.hpp"
 
 #include <AttributeHeader.hpp>
 #include <signaldata/TcKeyConf.hpp>
@@ -551,7 +539,7 @@ NdbTransaction::executeNoBlobs(NdbTransa
 //------------------------------------------------------------------------
   Ndb* tNdb = theNdb;
 
-  Uint32 timeout = theNdb->theImpl->m_transporter_facade->m_waitfor_timeout;
+  Uint32 timeout = theNdb->theImpl->get_waitfor_timeout();
   m_waitForReply = false;
   executeAsynchPrepare(aTypeOfExec, NULL, NULL, abortOption);
   if (m_waitForReply){
@@ -1822,26 +1810,6 @@ NdbTransaction::getNdbIndexOperation(con
 
 
 /*******************************************************************************
-int  receiveDIHNDBTAMPER(NdbApiSignal* aSignal)
-
-Return Value:  Return 0 : receiveDIHNDBTAMPER was successful.
-               Return -1: In all other case.
-Parameters:    aSignal: The signal object pointer.
-Remark:        Sets theRestartGCI in the NDB object. 
-*******************************************************************************/
-int			
-NdbTransaction::receiveDIHNDBTAMPER(const NdbApiSignal* aSignal)
-{
-  if (theStatus != Connecting) {
-    return -1;
-  } else {
-    theNdb->RestartGCI((Uint32)aSignal->readData(2));
-    theStatus = Connected;
-  }//if
-  return 0;  
-}//NdbTransaction::receiveDIHNDBTAMPER()
-
-/*******************************************************************************
 int  receiveTCSEIZECONF(NdbApiSignal* aSignal);
 
 Return Value:  Return 0 : receiveTCSEIZECONF was successful.

=== modified file 'storage/ndb/src/ndbapi/NdbTransactionScan.cpp'
--- a/storage/ndb/src/ndbapi/NdbTransactionScan.cpp	2010-09-29 13:49:49 +0000
+++ b/storage/ndb/src/ndbapi/NdbTransactionScan.cpp	2010-10-04 14:44:27 +0000
@@ -19,15 +19,7 @@
 
 #include <ndb_global.h>
 
-#include <Ndb.hpp>
-#include <NdbTransaction.hpp>
-#include <NdbOperation.hpp>
-#include <NdbScanOperation.hpp>
-#include "NdbApiSignal.hpp"
-#include "TransporterFacade.hpp"
-#include "NdbUtil.hpp"
 #include "API.hpp"
-#include "NdbImpl.hpp"
 
 #include <signaldata/ScanTab.hpp>
 

=== modified file 'storage/ndb/src/ndbapi/NdbWaiter.hpp'
--- a/storage/ndb/src/ndbapi/NdbWaiter.hpp	2009-05-27 15:21:45 +0000
+++ b/storage/ndb/src/ndbapi/NdbWaiter.hpp	2010-09-30 09:32:28 +0000
@@ -20,14 +20,9 @@
 #define NDB_WAITER_HPP
 
 #include <ndb_global.h>
-#include <NdbOut.hpp>
-#include <NdbError.hpp>
-#include <NdbCondition.h>
-#include <NdbReceiver.hpp>
-#include <NdbOperation.hpp>
-#include <kernel/ndb_limits.h>
-
 #include <NdbTick.h>
+#include <NdbCondition.h>
+#include <NdbOut.hpp>
 
 enum WaitSignalType { 
   NO_WAIT           = 0,

=== modified file 'storage/ndb/src/ndbapi/Ndberr.cpp'
--- a/storage/ndb/src/ndbapi/Ndberr.cpp	2009-06-25 13:38:11 +0000
+++ b/storage/ndb/src/ndbapi/Ndberr.cpp	2010-10-04 14:44:27 +0000
@@ -16,16 +16,7 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 */
 
-
-#include <NdbError.hpp>
-#include "NdbImpl.hpp"
-#include "NdbDictionaryImpl.hpp"
-#include <NdbOperation.hpp>
-#include <NdbTransaction.hpp>
-#include "NdbQueryBuilderImpl.hpp"
-#include "NdbQueryOperationImpl.hpp"
-#include <NdbBlob.hpp>
-#include "NdbEventOperationImpl.hpp"
+#include "API.hpp"
 
 static void
 update(const NdbError & _err){

=== modified file 'storage/ndb/src/ndbapi/Ndbif.cpp'
--- a/storage/ndb/src/ndbapi/Ndbif.cpp	2010-09-29 13:49:49 +0000
+++ b/storage/ndb/src/ndbapi/Ndbif.cpp	2010-10-04 14:44:27 +0000
@@ -19,17 +19,7 @@
 
 #include <ndb_global.h>
 
-#include "NdbApiSignal.hpp"
-#include "NdbImpl.hpp"
-#include <NdbTransaction.hpp>
-#include <NdbOperation.hpp>
-#include <NdbIndexOperation.hpp>
-#include <NdbScanOperation.hpp>
-#include <NdbRecAttr.hpp>
-#include <NdbReceiver.hpp>
-#include <NdbQueryOperationImpl.hpp>
 #include "API.hpp"
-#include "NdbEventOperationImpl.hpp"
 
 #include <signaldata/TcCommit.hpp>
 #include <signaldata/TcKeyFailConf.hpp>
@@ -83,9 +73,8 @@ Ndb::init(int aMaxNoOfTransactions)
   TransporterFacade * theFacade =  theImpl->m_transporter_facade;
   theFacade->lock_mutex();
   
-  const int tBlockNo = theFacade->open(this,
-                                       executeMessage, 
-                                       statusMessage);  
+  const int tBlockNo = theFacade->open(theImpl);
+
   if ( tBlockNo == -1 ) {
     theError.code = 4105;
     theFacade->unlock_mutex();
@@ -151,7 +140,7 @@ error_handler:
   ndbout << "error_handler" << endl;
   releaseTransactionArrays();
   delete theDictionary;
-  theImpl->m_transporter_facade->close(theNdbBlockNumber, 0);
+  theImpl->m_transporter_facade->close(theNdbBlockNumber);
   DBUG_RETURN(-1);
 }
 
@@ -172,12 +161,10 @@ Ndb::releaseTransactionArrays()
 }//Ndb::releaseTransactionArrays()
 
 void
-Ndb::executeMessage(void* NdbObject,
-                    const NdbApiSignal * aSignal,
-                    const LinearSectionPtr ptr[3])
+NdbImpl::trp_deliver_signal(const NdbApiSignal * aSignal,
+                            const LinearSectionPtr ptr[3])
 {
-  Ndb* tNdb = (Ndb*)NdbObject;
-  tNdb->handleReceivedSignal(aSignal, ptr);
+  m_ndb.handleReceivedSignal(aSignal, ptr);
 }
 
 void Ndb::connected(Uint32 ref)
@@ -200,9 +187,8 @@ void Ndb::connected(Uint32 ref)
   }
   theImpl->theNoOfDBnodes = n;
   
-  theFirstTransId = ((Uint64)tBlockNo << 52)+
+  theFirstTransId += ((Uint64)tBlockNo << 52)+
     ((Uint64)tmpTheNode << 40);
-  theFirstTransId += theFacade->m_max_trans_id;
   //      assert(0);
   DBUG_PRINT("info",("connected with ref=%x, id=%d, no_db_nodes=%d, first_trans_id: 0x%lx",
 		     theMyRef,
@@ -226,28 +212,30 @@ void Ndb::report_node_connected(Uint32 n
 }
 
 void
-Ndb::statusMessage(void* NdbObject, Uint32 a_node, bool alive, bool nfComplete)
+NdbImpl::trp_node_status(Uint32 a_node, Uint32 _event)
 {
   DBUG_ENTER("Ndb::statusMessage");
-  DBUG_PRINT("info", ("a_node: %u  alive: %u  nfComplete: %u",
-                      a_node, alive, nfComplete));
-  Ndb* tNdb = (Ndb*)NdbObject;
-  if (alive) {
-    if (nfComplete) {
-      // cluster connect, a_node == own reference
-      tNdb->connected(a_node);
-      DBUG_VOID_RETURN;
-    }//if
+  NS_Event event = (NS_Event)_event;
+  DBUG_PRINT("info", ("a_node: %u  event: %u",
+                      a_node, _event));
+  Ndb* tNdb = (Ndb*)&m_ndb;
+  switch(event){
+  case NS_CONNECTED:
+    // cluster connect, a_node == own reference
+    tNdb->connected(a_node);
+    break;
+  case NS_NODE_ALIVE:
     tNdb->report_node_connected(a_node);
-  } else {
-    if (nfComplete) {
-      tNdb->report_node_failure_completed(a_node);
-    } else {
-      tNdb->report_node_failure(a_node);
-    }//if
+    break;
+  case NS_NODE_FAILED:
+    tNdb->report_node_failure(a_node);
+    break;
+  case NS_NODE_NF_COMPLETE:
+    tNdb->report_node_failure_completed(a_node);
+    break;
   }//if
   NdbDictInterface::execNodeStatus(&tNdb->theDictionary->m_receiver,
-				   a_node, alive, nfComplete);
+				   a_node, event);
   DBUG_VOID_RETURN;
 }
 
@@ -828,21 +816,6 @@ Ndb::handleReceivedSignal(const NdbApiSi
     theEventBuffer->insertDataL(op, sdata, tLen, copy);
     return;
   }
-  case GSN_DIHNDBTAMPER:
-    {
-      tFirstDataPtr = int2void(tFirstData);
-      if (tFirstDataPtr == 0) goto InvalidSignal;
-      
-      if (tWaitState != WAIT_NDB_TAMPER)
-	return;
-      tCon = void2con(tFirstDataPtr);
-      if (tCon->checkMagicNumber() != 0)
-	return;
-      tReturnCode = tCon->receiveDIHNDBTAMPER(aSignal);
-      if (tReturnCode != -1)
-	theImpl->theWaiter.m_state = NO_WAIT;
-      break;
-    }
   case GSN_SCAN_TABCONF:
     {
       tFirstDataPtr = int2void(tFirstData);
@@ -1139,7 +1112,7 @@ Ndb::pollCompleted(NdbTransaction** aCop
 void
 Ndb::check_send_timeout()
 {
-  Uint32 timeout = theImpl->m_transporter_facade->m_waitfor_timeout;
+  Uint32 timeout = theImpl->get_ndbapi_config_parameters().m_waitfor_timeout;
   NDB_TICKS current_time = NdbTick_CurrentMillisecond();
   assert(current_time >= the_last_check_time);
   if (current_time - the_last_check_time > 1000) {

=== modified file 'storage/ndb/src/ndbapi/Ndbinit.cpp'
--- a/storage/ndb/src/ndbapi/Ndbinit.cpp	2010-01-28 15:16:46 +0000
+++ b/storage/ndb/src/ndbapi/Ndbinit.cpp	2010-09-30 11:52:49 +0000
@@ -19,23 +19,15 @@
 
 #include <ndb_global.h>
 
+#include "API.hpp"
 #include "NdbApiSignal.hpp"
 #include "NdbImpl.hpp"
-#include <NdbOperation.hpp>
-#include <NdbTransaction.hpp>
-#include <NdbRecAttr.hpp>
-#include <IPCConfig.hpp>
-#include "TransporterFacade.hpp"
 #include <ConfigRetriever.hpp>
 #include <ndb_limits.h>
 #include <NdbOut.hpp>
 #include <NdbSleep.h>
 #include "ObjectMap.hpp"
-#include <NdbIndexScanOperation.hpp>
-#include <NdbIndexOperation.hpp>
 #include "NdbUtil.hpp"
-#include <NdbBlob.hpp>
-#include "NdbEventOperationImpl.hpp"
 
 #include <EventLogger.hpp>
 extern EventLogger * g_eventLogger;
@@ -153,7 +145,7 @@ Ndb::~Ndb()
 
   /* Disconnect from transporter to stop signals from coming in */
   if (theImpl->m_transporter_facade != NULL && theNdbBlockNumber > 0){
-    theImpl->m_transporter_facade->close(theNdbBlockNumber, theFirstTransId);
+    theImpl->m_transporter_facade->close(theNdbBlockNumber);
   }
 
   delete theEventBuffer;

=== modified file 'storage/ndb/src/ndbapi/Ndblist.cpp'
--- a/storage/ndb/src/ndbapi/Ndblist.cpp	2010-01-28 15:16:46 +0000
+++ b/storage/ndb/src/ndbapi/Ndblist.cpp	2010-09-30 09:32:28 +0000
@@ -16,16 +16,7 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 */
 
-#include <NdbOut.hpp>
-#include <Ndb.hpp>
-#include <NdbOperation.hpp>
-#include <NdbIndexOperation.hpp>
-#include <NdbIndexScanOperation.hpp>
-#include "NdbApiSignal.hpp"
-#include <NdbRecAttr.hpp>
-#include "NdbUtil.hpp"
 #include "API.hpp"
-#include "NdbBlob.hpp"
 
 void
 Ndb::checkFailedNode()

=== modified file 'storage/ndb/src/ndbapi/SignalSender.cpp'
--- a/storage/ndb/src/ndbapi/SignalSender.cpp	2010-09-29 13:25:19 +0000
+++ b/storage/ndb/src/ndbapi/SignalSender.cpp	2010-10-01 10:08:29 +0000
@@ -17,6 +17,7 @@
 */
 
 #include "SignalSender.hpp"
+#include <kernel/GlobalSignalNumbers.h>
 #include <NdbSleep.h>
 #include <SignalLoggerManager.hpp>
 #include <signaldata/NFCompleteRep.hpp>
@@ -80,7 +81,7 @@ SignalSender::SignalSender(TransporterFa
   m_cond = NdbCondition_Create();
   theFacade = facade;
   lock();
-  m_blockNo = theFacade->open(this, execSignal, execNodeStatus, blockNo);
+  m_blockNo = theFacade->open(this, blockNo);
   unlock();
   assert(m_blockNo > 0);
 }
@@ -90,7 +91,7 @@ SignalSender::SignalSender(Ndb_cluster_c
   m_cond = NdbCondition_Create();
   theFacade = connection->m_impl.m_transporter_facade;
   lock();
-  m_blockNo = theFacade->open(this, execSignal, execNodeStatus, -1);
+  m_blockNo = theFacade->open(this, -1);
   unlock();
   assert(m_blockNo > 0);
 }
@@ -99,7 +100,7 @@ SignalSender::~SignalSender(){
   int i;
   if (m_lock)
     unlock();
-  theFacade->close(m_blockNo,0);
+  theFacade->close(m_blockNo);
   // free these _after_ closing theFacade to ensure that
   // we delete all signals
   for (i= m_jobBuffer.size()-1; i>= 0; i--)
@@ -256,9 +257,9 @@ SignalSender::waitFor(Uint32 timeOutMill
 #include <NdbApiSignal.hpp>
 
 void
-SignalSender::execSignal(void* signalSender, 
-			 const NdbApiSignal* signal,
-			 const struct LinearSectionPtr ptr[3]){
+SignalSender::trp_deliver_signal(const NdbApiSignal* signal,
+                                 const struct LinearSectionPtr ptr[3])
+{
   SimpleSignal * s = new SimpleSignal(true);
   s->header = * signal;
   memcpy(&s->theData[0], signal->getDataPtr(), 4 * s->header.theLength);
@@ -267,26 +268,29 @@ SignalSender::execSignal(void* signalSen
     s->ptr[i].sz = ptr[i].sz;
     memcpy(s->ptr[i].p, ptr[i].p, 4 * ptr[i].sz);
   }
-  SignalSender * ss = (SignalSender*)signalSender;
-  ss->m_jobBuffer.push_back(s);
-  NdbCondition_Signal(ss->m_cond);
+  m_jobBuffer.push_back(s);
+  NdbCondition_Signal(m_cond);
 }
   
 void 
-SignalSender::execNodeStatus(void* signalSender, 
-			     Uint32 nodeId, 
-			     bool alive, 
-			     bool nfCompleted){
-  if (alive) {
-    // node connected
+SignalSender::trp_node_status(Uint32 nodeId, Uint32 _event)
+{
+  NS_Event event = (NS_Event)_event;
+  switch(event){
+  case NS_CONNECTED:
+  case NS_NODE_ALIVE:
     return;
+  case NS_NODE_FAILED:
+  case NS_NODE_NF_COMPLETE:
+    goto ok;
   }
+  return;
 
+ok:
   SimpleSignal * s = new SimpleSignal(true);
-  SignalSender * ss = (SignalSender*)signalSender;
 
   // node disconnected
-  if(nfCompleted)
+  if (event == NS_NODE_NF_COMPLETE)
   {
     // node shutdown complete
     s->header.theVerId_signalNumber = GSN_NF_COMPLETEREP;
@@ -308,13 +312,13 @@ SignalSender::execNodeStatus(void* signa
     NdbNodeBitmask::clear(rep->theNodes);
 
     // Mark ndb nodes as failed in bitmask
-    const ClusterMgr::Node node= ss->getNodeInfo(nodeId);
+    const ClusterMgr::Node node= getNodeInfo(nodeId);
     if (node.m_info.getType() ==  NodeInfo::DB)
       NdbNodeBitmask::set(rep->theNodes, nodeId);
   }
 
-  ss->m_jobBuffer.push_back(s);
-  NdbCondition_Signal(ss->m_cond);
+  m_jobBuffer.push_back(s);
+  NdbCondition_Signal(m_cond);
 }
 
 

=== modified file 'storage/ndb/src/ndbapi/SignalSender.hpp'
--- a/storage/ndb/src/ndbapi/SignalSender.hpp	2010-09-29 13:25:19 +0000
+++ b/storage/ndb/src/ndbapi/SignalSender.hpp	2010-10-01 10:08:29 +0000
@@ -21,6 +21,7 @@
 
 #include <ndb_global.h>
 #include "TransporterFacade.hpp"
+#include "trp_client.hpp"
 #include <Vector.hpp>
 
 #include <signaldata/TestOrd.hpp>
@@ -84,7 +85,7 @@ private:
   bool deallocSections;
 };
 
-class SignalSender {
+class SignalSender  : public trp_client {
 public:
   SignalSender(TransporterFacade *facade, int blockNo = -1);
   SignalSender(Ndb_cluster_connection* connection);
@@ -119,13 +120,15 @@ private:
   int m_blockNo;
   TransporterFacade * theFacade;
   
-  static void execSignal(void* signalSender, 
-			 const NdbApiSignal* signal,
-			 const struct LinearSectionPtr ptr[3]);
-  
-  static void execNodeStatus(void* signalSender, Uint32 nodeId, 
-			     bool alive, bool nfCompleted);
+public:
+  /**
+   * trp_client interface
+   */
+  virtual void trp_deliver_signal(const NdbApiSignal* signal,
+                                  const struct LinearSectionPtr ptr[3]);
   
+  virtual void trp_node_status(Uint32 nodeId, Uint32 _event);
+
   int m_lock;
   struct NdbCondition * m_cond;
   Vector<SimpleSignal *> m_jobBuffer;

=== modified file 'storage/ndb/src/ndbapi/TransporterFacade.cpp'
--- a/storage/ndb/src/ndbapi/TransporterFacade.cpp	2010-08-26 16:01:10 +0000
+++ b/storage/ndb/src/ndbapi/TransporterFacade.cpp	2010-10-04 14:44:27 +0000
@@ -17,19 +17,20 @@
 */
 
 #include <ndb_global.h>
-#include <my_pthread.h>
 #include <ndb_limits.h>
+#include "trp_client.hpp"
 #include "TransporterFacade.hpp"
 #include "ClusterMgr.hpp"
 #include <IPCConfig.hpp>
 #include <TransporterCallback.hpp>
 #include <TransporterRegistry.hpp>
 #include "NdbApiSignal.hpp"
+#include "NdbWaiter.hpp"
 #include <NdbOut.hpp>
 #include <NdbEnv.h>
 #include <NdbSleep.h>
 
-#include "API.hpp"
+#include <kernel/GlobalSignalNumbers.h>
 #include <mgmapi_config_parameters.h>
 #include <mgmapi_configuration.hpp>
 #include <NdbConfig.h>
@@ -210,24 +211,24 @@ TransporterFacade::deliver_signal(Signal
                                   Uint8 prio, Uint32 * const theData,
                                   LinearSectionPtr ptr[3])
 {
-
-  TransporterFacade::ThreadData::Object_Execute oe; 
   Uint32 tRecBlockNo = header->theReceiversBlockNumber;
   
 #ifdef API_TRACE
   if(setSignalLog() && TRACE_GSN(header->theVerId_signalNumber)){
     signalLogger.executeSignal(* header, 
-			       prio,
+                               prio,
                                theData,
-			       ownId(),
+                               ownId(),
                                ptr, header->m_noOfSections);
     signalLogger.flushSignalLog();
   }
 #endif  
 
-  if (tRecBlockNo >= MIN_API_BLOCK_NO) {
-    oe = m_threads.get(tRecBlockNo);
-    if (oe.m_object != 0 && oe.m_executeFunction != 0) {
+  if (tRecBlockNo >= MIN_API_BLOCK_NO)
+  {
+    trp_client * clnt = m_threads.get(tRecBlockNo);
+    if (clnt != 0)
+    {
       /**
        * Handle received signal immediately to avoid any unnecessary
        * copying of data, allocation of memory and other things. Copying
@@ -242,9 +243,11 @@ TransporterFacade::deliver_signal(Signal
       NdbApiSignal tmpSignal(*header);
       NdbApiSignal * tSignal = &tmpSignal;
       tSignal->setDataPtr(theData);
-      (* oe.m_executeFunction) (oe.m_object, tSignal, ptr);
+      clnt->trp_deliver_signal(tSignal, ptr);
     }//if
-  } else if (tRecBlockNo == API_PACKED) {
+  }
+  else if (tRecBlockNo == API_PACKED)
+  {
     /**
      * Block number == 2047 is used to signal a signal that consists of
      * multiple instances of the same signal. This is an effort to
@@ -262,150 +265,55 @@ TransporterFacade::deliver_signal(Signal
       Tsent++;
       Uint32 TpacketLen = (Theader & 0x1F) + 3;
       tRecBlockNo = Theader >> 16;
-      if (TpacketLen <= 25) {
-	if ((TpacketLen + Tsent) <= Tlength) {
-	  /**
-	   * Set the data length of the signal and the receivers block
-	   * reference and then call the API.
-	   */
-	  header->theLength = TpacketLen;
-	  header->theReceiversBlockNumber = tRecBlockNo;
-	  Uint32* tDataPtr = &theData[Tsent];
-	  Tsent += TpacketLen;
-	  if (tRecBlockNo >= MIN_API_BLOCK_NO) {
-	    oe = m_threads.get(tRecBlockNo);
-	    if(oe.m_object != 0 && oe.m_executeFunction != 0){
-	      NdbApiSignal tmpSignal(*header);
-	      NdbApiSignal * tSignal = &tmpSignal;
-	      tSignal->setDataPtr(tDataPtr);
-	      (*oe.m_executeFunction)(oe.m_object, tSignal, 0);
-	    }
-	  }
-	}
+      if (TpacketLen <= 25)
+      {
+        if ((TpacketLen + Tsent) <= Tlength)
+        {
+          /**
+           * Set the data length of the signal and the receivers block
+           * reference and then call the API.
+           */
+          header->theLength = TpacketLen;
+          header->theReceiversBlockNumber = tRecBlockNo;
+          Uint32* tDataPtr = &theData[Tsent];
+          Tsent += TpacketLen;
+          if (tRecBlockNo >= MIN_API_BLOCK_NO)
+          {
+            trp_client * clnt = m_threads.get(tRecBlockNo);
+            if(clnt != 0)
+            {
+              NdbApiSignal tmpSignal(*header);
+              NdbApiSignal * tSignal = &tmpSignal;
+              tSignal->setDataPtr(tDataPtr);
+              clnt->trp_deliver_signal(tSignal, 0);
+            }
+          }
+        }
       }
     }
     return;
-  } else if (tRecBlockNo == API_CLUSTERMGR) {
-     /**
-      * The signal was aimed for the Cluster Manager. 
-      * We handle it immediately here.
-      */     
-     ClusterMgr * clusterMgr = theClusterMgr;
-     const Uint32 gsn = header->theVerId_signalNumber;
-
-     switch (gsn){
-     case GSN_API_REGREQ:
-       clusterMgr->execAPI_REGREQ(theData);
-       break;
-
-     case GSN_API_REGCONF:
-     {
-       clusterMgr->execAPI_REGCONF(theData);
-
-       // Distribute signal to all threads/blocks
-       NdbApiSignal tSignal(* header);
-       tSignal.setDataPtr(theData);
-       for_each(&tSignal, ptr);
-       break;
-     }
-
-     case GSN_API_REGREF:
-       clusterMgr->execAPI_REGREF(theData);
-       break;
-
-     case GSN_NODE_FAILREP:
-       clusterMgr->execNODE_FAILREP(theData);
-       break;
-       
-     case GSN_NF_COMPLETEREP:
-       clusterMgr->execNF_COMPLETEREP(theData);
-       break;
-
-     case GSN_ARBIT_STARTREQ:
-       if (theArbitMgr != NULL)
-	 theArbitMgr->doStart(theData);
-       break;
-       
-     case GSN_ARBIT_CHOOSEREQ:
-       if (theArbitMgr != NULL)
-	 theArbitMgr->doChoose(theData);
-       break;
-       
-     case GSN_ARBIT_STOPORD:
-       if(theArbitMgr != NULL)
-	 theArbitMgr->doStop(theData);
-       break;
-
-     case GSN_ALTER_TABLE_REP:
-     {
-       if (m_globalDictCache == NULL)
-         break;
-       const AlterTableRep* rep = (const AlterTableRep*)theData;
-       m_globalDictCache->lock();
-       m_globalDictCache->
-	 alter_table_rep((const char*)ptr[0].p, 
-			 rep->tableId,
-			 rep->tableVersion,
-			 rep->changeType == AlterTableRep::CT_ALTERED);
-       m_globalDictCache->unlock();
-       break;
-     }
-     case GSN_SUB_GCP_COMPLETE_REP:
-     {
-       /**
-	* Report
-	*/
-       NdbApiSignal tSignal(* header);
-       tSignal.setDataPtr(theData);
-       for_each(&tSignal, ptr);
-
-       /**
-	* Reply
-	*/
-       {
-	 Uint32* send= tSignal.getDataPtrSend();
-	 memcpy(send, theData, tSignal.getLength() << 2);
-	 CAST_PTR(SubGcpCompleteAck, send)->rep.senderRef = 
-	   numberToRef(API_CLUSTERMGR, theOwnId);
-	 Uint32 ref= header->theSendersBlockRef;
-	 Uint32 aNodeId= refToNode(ref);
-	 tSignal.theReceiversBlockNumber= refToBlock(ref);
-	 tSignal.theVerId_signalNumber= GSN_SUB_GCP_COMPLETE_ACK;
-	 sendSignalUnCond(&tSignal, aNodeId);
-       }
-       break;
-     }
-     case GSN_TAKE_OVERTCCONF:
-     {
-       /**
-	* Report
-	*/
-       NdbApiSignal tSignal(* header);
-       tSignal.setDataPtr(theData);
-       for_each(&tSignal, ptr);
-       return;
-     }
-     default:
-       break;
-       
-     }
-     return;
-  } else if (tRecBlockNo >= MIN_API_FIXED_BLOCK_NO &&
-             tRecBlockNo <= MAX_API_FIXED_BLOCK_NO) {
+  }
+  else if (tRecBlockNo >= MIN_API_FIXED_BLOCK_NO &&
+           tRecBlockNo <= MAX_API_FIXED_BLOCK_NO) 
+  {
     Uint32 dynamic= m_fixed2dynamic[tRecBlockNo - MIN_API_FIXED_BLOCK_NO];
-    oe = m_threads.get(dynamic);
-    if (oe.m_object != 0 && oe.m_executeFunction != 0) {
+    trp_client * clnt = m_threads.get(dynamic);
+    if (clnt != 0)
+    {
       NdbApiSignal tmpSignal(*header);
       NdbApiSignal * tSignal = &tmpSignal;
       tSignal->setDataPtr(theData);
-      (* oe.m_executeFunction) (oe.m_object, tSignal, ptr);
+      clnt->trp_deliver_signal(tSignal, ptr);
     }//if   
-  } else {
-    ; // Ignore all other block numbers.
-    if(header->theVerId_signalNumber != GSN_API_REGREQ) {
+  }
+  else
+  {
+    // Ignore all other block numbers.
+    if(header->theVerId_signalNumber != GSN_API_REGREQ)
+    {
       TRP_DEBUG( "TransporterFacade received signal to unknown block no." );
       ndbout << "BLOCK NO: "  << tRecBlockNo << " sig " 
-	     << header->theVerId_signalNumber  << endl;
+             << header->theVerId_signalNumber  << endl;
       abort();
     }
   }
@@ -500,7 +408,6 @@ TransporterFacade::doStop(){
    * and also uses theFacadeInstance to lock/unlock theMutexPtr
    */
   if (theClusterMgr != NULL) theClusterMgr->doStop();
-  if (theArbitMgr != NULL) theArbitMgr->doStop(NULL);
   
   /**
    * Now stop the send and receive threads
@@ -721,16 +628,11 @@ TransporterFacade::TransporterFacade(Glo
   theOwnId(0),
   theStartNodeId(1),
   theClusterMgr(NULL),
-  theArbitMgr(NULL),
   checkCounter(4),
   currentSendLimit(1),
-  m_scan_batch_size(MAX_SCAN_BATCH_SIZE),
-  m_batch_byte_size(SCAN_BATCH_SIZE),
-  m_batch_size(DEF_BATCH_SIZE),
   theStopReceive(0),
   theSendThread(NULL),
   theReceiveThread(NULL),
-  m_max_trans_id(0),
   m_fragmented_signal_id(0),
   m_globalDictCache(cache)
 {
@@ -815,7 +717,7 @@ TransporterFacade::configure(NodeId node
     DBUG_RETURN(false);
 
   // Configure cluster manager
-  theClusterMgr->configure(conf);
+  theClusterMgr->configure(nodeId, conf);
 
   ndb_mgm_configuration_iterator iter(* conf, CFG_SECTION_NODE);
   if(iter.find(CFG_NODE_ID, nodeId))
@@ -826,42 +728,6 @@ TransporterFacade::configure(NodeId node
   iter.get(CFG_TOTAL_SEND_BUFFER_MEMORY, &total_send_buffer);
   theTransporterRegistry->allocate_send_buffers(total_send_buffer);
 
-  // Configure arbitrator
-  Uint32 rank = 0;
-  iter.get(CFG_NODE_ARBIT_RANK, &rank);
-  if (rank > 0)
-  {
-    // The arbitrator should be active
-    if (!theArbitMgr)
-      theArbitMgr = new ArbitMgr(* this);
-    theArbitMgr->setRank(rank);
-
-    Uint32 delay = 0;
-    iter.get(CFG_NODE_ARBIT_DELAY, &delay);
-    theArbitMgr->setDelay(delay);
-  }
-  else if (theArbitMgr)
-  {
-    // No arbitrator should be started
-    theArbitMgr->doStop(NULL);
-    delete theArbitMgr;
-    theArbitMgr= NULL;
-  }
-
-  // Configure scan settings
-  Uint32 scan_batch_size= 0;
-  if (!iter.get(CFG_MAX_SCAN_BATCH_SIZE, &scan_batch_size)) {
-    m_scan_batch_size= scan_batch_size;
-  }
-  Uint32 batch_byte_size= 0;
-  if (!iter.get(CFG_BATCH_BYTE_SIZE, &batch_byte_size)) {
-    m_batch_byte_size= batch_byte_size;
-  }
-  Uint32 batch_size= 0;
-  if (!iter.get(CFG_BATCH_SIZE, &batch_size)) {
-    m_batch_size= batch_size;
-  }
-
   Uint32 auto_reconnect=1;
   iter.get(CFG_AUTO_RECONNECT, &auto_reconnect);
 
@@ -879,19 +745,6 @@ TransporterFacade::configure(NodeId node
     theClusterMgr->m_auto_reconnect = auto_reconnect;
   }
   
-  // Configure timeouts
-  Uint32 timeout = 120000;
-  for (iter.first(); iter.valid(); iter.next())
-  {
-    Uint32 tmp1 = 0, tmp2 = 0;
-    iter.get(CFG_DB_TRANSACTION_CHECK_INTERVAL, &tmp1);
-    iter.get(CFG_DB_TRANSACTION_DEADLOCK_TIMEOUT, &tmp2);
-    tmp1 += tmp2;
-    if (tmp1 > timeout)
-      timeout = tmp1;
-  }
-  m_waitfor_timeout = timeout;
-
 #ifdef API_TRACE
   signalLogger.logOn(true, 0, SignalLoggerManager::LogInOut);
 #endif
@@ -904,16 +757,17 @@ TransporterFacade::configure(NodeId node
 }
 
 void
-TransporterFacade::for_each(NdbApiSignal* aSignal, LinearSectionPtr ptr[3])
+TransporterFacade::for_each(trp_client* sender,
+                            const NdbApiSignal* aSignal, 
+                            const LinearSectionPtr ptr[3])
 {
   Uint32 sz = m_threads.m_statusNext.size();
-  TransporterFacade::ThreadData::Object_Execute oe; 
   for (Uint32 i = 0; i < sz ; i ++) 
   {
-    oe = m_threads.m_objectExecute[i];
-    if (m_threads.getInUse(i))
+    trp_client * clnt = m_threads.m_objectExecute[i];
+    if (clnt != 0 && clnt != sender)
     {
-      (* oe.m_executeFunction) (oe.m_object, aSignal, ptr);
+      clnt->trp_deliver_signal(aSignal, ptr);
     }
   }
 }
@@ -923,18 +777,19 @@ TransporterFacade::connected()
 {
   DBUG_ENTER("TransporterFacade::connected");
   Uint32 sz = m_threads.m_statusNext.size();
-  for (Uint32 i = 0; i < sz ; i ++) {
-    if (m_threads.getInUse(i)){
-      void * obj = m_threads.m_objectExecute[i].m_object;
-      NodeStatusFunction RegPC = m_threads.m_statusFunction[i];
-      (*RegPC) (obj, numberToRef(indexToNumber(i), theOwnId), true, true);
+  for (Uint32 i = 0; i < sz ; i ++)
+  {
+    trp_client * clnt = m_threads.m_objectExecute[i];
+    if (clnt != 0)
+    {
+      clnt->trp_node_status(numberToRef(indexToNumber(i), theOwnId), NS_CONNECTED);
     }
   }
   DBUG_VOID_RETURN;
 }
 
 void
-TransporterFacade::ReportNodeDead(NodeId tNodeId)
+TransporterFacade::trp_node_status(NodeId tNodeId, Uint32 event)
 {
   DBUG_ENTER("TransporterFacade::ReportNodeDead");
   DBUG_PRINT("enter",("nodeid= %d", tNodeId));
@@ -947,69 +802,21 @@ TransporterFacade::ReportNodeDead(NodeId
    * might not have noticed the failure.
    */
   Uint32 sz = m_threads.m_statusNext.size();
-  for (Uint32 i = 0; i < sz ; i ++) {
-    if (m_threads.getInUse(i)){
-      void * obj = m_threads.m_objectExecute[i].m_object;
-      NodeStatusFunction RegPC = m_threads.m_statusFunction[i];
-      (*RegPC) (obj, tNodeId, false, false);
-    }
-  }
-  DBUG_VOID_RETURN;
-}
-
-void
-TransporterFacade::ReportNodeFailureComplete(NodeId tNodeId)
-{
-  /**
-   * When a node fails we must report this to each Ndb object. 
-   * The function that is used for communicating node failures is called.
-   * This is to ensure that the Ndb objects do not think their connections 
-   * are correct after a failure followed by a restart. 
-   * After the restart the node is up again and the Ndb object 
-   * might not have noticed the failure.
-   */
-
-  DBUG_ENTER("TransporterFacade::ReportNodeFailureComplete");
-  DBUG_PRINT("enter",("nodeid= %d", tNodeId));
-  Uint32 sz = m_threads.m_statusNext.size();
-  for (Uint32 i = 0; i < sz ; i ++) {
-    if (m_threads.getInUse(i)){
-      void * obj = m_threads.m_objectExecute[i].m_object;
-      NodeStatusFunction RegPC = m_threads.m_statusFunction[i];
-      (*RegPC) (obj, tNodeId, false, true);
+  for (Uint32 i = 0; i < sz ; i ++)
+  {
+    trp_client * clnt = m_threads.m_objectExecute[i];
+    if (clnt != 0)
+    {
+      clnt->trp_node_status(tNodeId, event);
     }
   }
   DBUG_VOID_RETURN;
 }
 
-void
-TransporterFacade::ReportNodeAlive(NodeId tNodeId)
-{
-  /**
-   * When a node fails we must report this to each Ndb object. 
-   * The function that is used for communicating node failures is called.
-   * This is to ensure that the Ndb objects do not think there connections 
-   * are correct after a failure
-   * followed by a restart. 
-   * After the restart the node is up again and the Ndb object 
-   * might not have noticed the failure.
-   */
-  Uint32 sz = m_threads.m_statusNext.size();
-  for (Uint32 i = 0; i < sz ; i ++) {
-    if (m_threads.getInUse(i)){
-      void * obj = m_threads.m_objectExecute[i].m_object;
-      NodeStatusFunction RegPC = m_threads.m_statusFunction[i];
-      (*RegPC) (obj, tNodeId, true, false);
-    }
-  }
-}
-
 int 
-TransporterFacade::close(BlockNumber blockNumber, Uint64 trans_id)
+TransporterFacade::close(BlockNumber blockNumber)
 {
   NdbMutex_Lock(theMutexPtr);
-  Uint32 low_bits = (Uint32)trans_id;
-  m_max_trans_id = m_max_trans_id > low_bits ? m_max_trans_id : low_bits;
   close_local(blockNumber);
   NdbMutex_Unlock(theMutexPtr);
   return 0;
@@ -1022,29 +829,30 @@ TransporterFacade::close_local(BlockNumb
 }
 
 int
-TransporterFacade::open(void* objRef, 
-                        ExecuteFunction fun, 
-                        NodeStatusFunction statusFun,
-                        int blockNo)
+TransporterFacade::open(trp_client * clnt, int blockNo)
 {
   DBUG_ENTER("TransporterFacade::open");
-  int r= m_threads.open(objRef, fun, statusFun);
+  int r= m_threads.open(clnt);
   if (r < 0)
+  {
     DBUG_RETURN(r);
+  }
 
-  if (unlikely(blockNo != -1)){
+  if (unlikely(blockNo != -1))
+  {
     // Using fixed block number, add fixed->dymamic mapping
-    Uint32 fixed_index= blockNo - MIN_API_FIXED_BLOCK_NO;
-
+    Uint32 fixed_index = blockNo - MIN_API_FIXED_BLOCK_NO;
+    
     assert(blockNo >= MIN_API_FIXED_BLOCK_NO &&
            fixed_index <= NO_API_FIXED_BLOCKS);
-
+    
     m_fixed2dynamic[fixed_index]= r;
   }
 
 #if 1
-  if (theOwnId > 0) {
-    (*statusFun)(objRef, numberToRef(r, theOwnId), true, true);
+  if (theOwnId > 0)
+  {
+    clnt->trp_node_status(numberToRef(r, theOwnId), NS_CONNECTED);
   }
 #endif
   DBUG_RETURN(r);
@@ -1056,7 +864,6 @@ TransporterFacade::~TransporterFacade()
 
   NdbMutex_Lock(theMutexPtr);
   delete theClusterMgr;  
-  delete theArbitMgr;
   delete theTransporterRegistry;
   NdbMutex_Unlock(theMutexPtr);
   NdbMutex_Destroy(theMutexPtr);
@@ -1778,12 +1585,10 @@ TransporterFacade::ThreadData::ThreadDat
 
 void
 TransporterFacade::ThreadData::expand(Uint32 size){
-  Object_Execute oe = { 0 ,0 };
-  NodeStatusFunction fun = 0;
+  trp_client * oe = 0;
 
   const Uint32 sz = m_statusNext.size();
   m_objectExecute.fill(sz + size, oe);
-  m_statusFunction.fill(sz + size, fun);
   for(Uint32 i = 0; i<size; i++){
     m_statusNext.push_back(sz + i + 1);
   }
@@ -1794,9 +1599,7 @@ TransporterFacade::ThreadData::expand(Ui
 
 
 int
-TransporterFacade::ThreadData::open(void* objRef, 
-				    ExecuteFunction fun, 
-				    NodeStatusFunction fun2)
+TransporterFacade::ThreadData::open(trp_client * clnt)
 {
   Uint32 nextFree = m_firstFree;
 
@@ -1812,11 +1615,8 @@ TransporterFacade::ThreadData::open(void
   m_use_cnt++;
   m_firstFree = m_statusNext[nextFree];
 
-  Object_Execute oe = { objRef , fun };
-
   m_statusNext[nextFree] = INACTIVE;
-  m_objectExecute[nextFree] = oe;
-  m_statusFunction[nextFree] = fun2;
+  m_objectExecute[nextFree] = clnt;
 
   return indexToNumber(nextFree);
 }
@@ -1824,14 +1624,12 @@ TransporterFacade::ThreadData::open(void
 int
 TransporterFacade::ThreadData::close(int number){
   number= numberToIndex(number);
-  assert(getInUse(number));
+  assert(m_objectExecute[number] != 0);
   m_statusNext[number] = m_firstFree;
   assert(m_use_cnt);
   m_use_cnt--;
   m_firstFree = number;
-  Object_Execute oe = { 0, 0 };
-  m_objectExecute[number] = oe;
-  m_statusFunction[number] = 0;
+  m_objectExecute[number] = 0;
   return 0;
 }
 
@@ -2014,8 +1812,7 @@ void PollGuard::unlock_and_signal()
   m_locked=false;
 }
 
-template class Vector<NodeStatusFunction>;
-template class Vector<TransporterFacade::ThreadData::Object_Execute>;
+template class Vector<trp_client*>;
 
 #include "SignalSender.hpp"
 

=== modified file 'storage/ndb/src/ndbapi/TransporterFacade.hpp'
--- a/storage/ndb/src/ndbapi/TransporterFacade.hpp	2010-09-29 13:49:49 +0000
+++ b/storage/ndb/src/ndbapi/TransporterFacade.hpp	2010-10-04 14:44:27 +0000
@@ -35,14 +35,19 @@ struct ndb_mgm_configuration;
 class Ndb;
 class NdbApiSignal;
 class NdbWaiter;
+class trp_client;
 
-typedef void (* ExecuteFunction)(void *, const NdbApiSignal *, const LinearSectionPtr ptr[3]);
-typedef void (* NodeStatusFunction)(void *, Uint32, bool nodeAlive, bool nfComplete);
+enum NS_Event
+{
+  NS_CONNECTED,   // *we* are connected and have nodeId (report as NodeId)
+  NS_NODE_ALIVE,  // *nodeId* is alive (connected and API_REGCONF)
+  NS_NODE_FAILED, // *nodeId* has failed
+  NS_NODE_NF_COMPLETE
+};
 
 extern "C" {
   void* runSendRequest_C(void*);
   void* runReceiveResponse_C(void*);
-  void atexit_stop_instance();
 }
 
 class TransporterFacade : public TransporterCallback
@@ -70,11 +75,10 @@ public:
    * @blockNo block number to use, -1 => any blockNumber
    * @return BlockNumber or -1 for failure
    */
-  int open(void* objRef, ExecuteFunction, NodeStatusFunction,
-           int blockNo = -1);
+  int open(trp_client*, int blockNo = -1);
   
   // Close this block number
-  int close(BlockNumber blockNumber, Uint64 trans_id);
+  int close(BlockNumber blockNumber);
   Uint32 get_active_ndb_objects() const;
 
   // Only sends to nodes which are alive
@@ -112,14 +116,13 @@ public:
   void reportDisconnected(int NodeId);
 
   NodeId get_an_alive_node();
-  void ReportNodeAlive(NodeId nodeId);
-  void ReportNodeDead(NodeId nodeId);
-  void ReportNodeFailureComplete(NodeId nodeId);
+  void trp_node_status(NodeId, Uint32 event);
 
   /**
    * Send signal to each registered object
    */
-  void for_each(NdbApiSignal* aSignal, LinearSectionPtr ptr[3]);
+  void for_each(trp_client* clnt,
+                const NdbApiSignal* aSignal, const LinearSectionPtr ptr[3]);
   
   void lock_mutex();
   void unlock_mutex();
@@ -131,12 +134,6 @@ public:
   // Close this block number
   int close_local(BlockNumber blockNumber);
 
-  // Scan batch configuration parameters
-  Uint32 get_scan_batch_size() const;
-  Uint32 get_batch_byte_size() const;
-  Uint32 get_batch_size() const;
-  Uint32 m_waitfor_timeout; // in milli seconds...
-
   TransporterRegistry* get_registry() { return theTransporterRegistry;};
 
 /*
@@ -236,7 +233,6 @@ private:
   NodeId theStartNodeId;
 
   ClusterMgr* theClusterMgr;
-  ArbitMgr* theArbitMgr;
   
   // Improving the API response time
   int checkCounter;
@@ -244,11 +240,6 @@ private:
   
   void calculateSendLimit();
 
-  // Scan batch configuration parameters
-  Uint32 m_scan_batch_size;
-  Uint32 m_batch_byte_size;
-  Uint32 m_batch_size;
-
   // Declarations for the receive and send thread
   int  theStopReceive;
 
@@ -259,7 +250,6 @@ private:
 
   friend void* runSendRequest_C(void*);
   friend void* runReceiveResponse_C(void*);
-  friend void atexit_stop_instance();
 
   bool do_connect_mgm(NodeId, const ndb_mgm_configuration*);
 
@@ -275,48 +265,26 @@ private:
     
     ThreadData(Uint32 initialSize = 32);
     
-    /**
-     * Split "object" into 3 list
-     *   This to improve locality
-     *   when iterating over lists
-     */
-    struct Object_Execute {
-      void * m_object;
-      ExecuteFunction m_executeFunction;
-    };
-    struct NodeStatus_NextFree {
-      NodeStatusFunction m_statusFunction;
-    };
-
     Uint32 m_use_cnt;
     Uint32 m_firstFree;
     Vector<Uint32> m_statusNext;
-    Vector<Object_Execute> m_objectExecute;
-    Vector<NodeStatusFunction> m_statusFunction;
+    Vector<trp_client*> m_objectExecute;
     
-    int open(void* objRef, ExecuteFunction, NodeStatusFunction);
+    int open(trp_client*);
     int close(int number);
     void expand(Uint32 size);
 
-    inline Object_Execute get(Uint16 blockNo) const {
+    inline trp_client* get(Uint16 blockNo) const {
       blockNo -= MIN_API_BLOCK_NO;
-      if(likely (blockNo < m_objectExecute.size())){
-	return m_objectExecute[blockNo];
+      if(likely (blockNo < m_objectExecute.size()))
+      {
+        return m_objectExecute.getBase()[blockNo];
       }
-      Object_Execute oe = { 0, 0 };
-      return oe;
-    }
-
-    /**
-     * Is the block number used currently
-     */
-    inline bool getInUse(Uint16 index) const {
-      return (m_statusNext[index] & (1 << 16)) != 0;
+      return 0;
     }
   } m_threads;
 
   Uint32 m_fixed2dynamic[NO_API_FIXED_BLOCKS];
-  Uint32 m_max_trans_id;
   Uint32 m_fragmented_signal_id;
 
 public:
@@ -456,24 +424,6 @@ TransporterFacade::getMinDbNodeVersion()
     return 0;
 }
 
-inline
-Uint32
-TransporterFacade::get_scan_batch_size() const {
-  return m_scan_batch_size;
-}
-
-inline
-Uint32
-TransporterFacade::get_batch_byte_size() const {
-  return m_batch_byte_size;
-}
-
-inline
-Uint32
-TransporterFacade::get_batch_size() const {
-  return m_batch_size;
-}
-
 /** 
  * LinearSectionIterator
  *

=== modified file 'storage/ndb/src/ndbapi/ndb_cluster_connection.cpp'
--- a/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp	2010-05-04 14:34:54 +0000
+++ b/storage/ndb/src/ndbapi/ndb_cluster_connection.cpp	2010-09-30 11:52:49 +0000
@@ -23,7 +23,7 @@
 #include "ndb_cluster_connection_impl.hpp"
 #include <mgmapi_configuration.hpp>
 #include <mgmapi_config_parameters.h>
-#include <TransporterFacade.hpp>
+#include "TransporterFacade.hpp"
 #include <NdbOut.hpp>
 #include <NdbSleep.h>
 #include <NdbThread.h>
@@ -33,6 +33,8 @@
 #include <mgmapi_debug.h>
 #include <mgmapi_internal.h>
 #include <md5_hash.hpp>
+#include "NdbImpl.hpp"
+#include "NdbDictionaryImpl.hpp"
 
 #include <NdbMutex.h>
 #ifdef VM_TRACE
@@ -302,7 +304,8 @@ Ndb_cluster_connection_impl(const char *
     m_latest_trans_gci(0),
     m_first_ndb_object(0),
     m_latest_error_msg(),
-    m_latest_error(0)
+    m_latest_error(0),
+    m_max_trans_id(0)
 {
   DBUG_ENTER("Ndb_cluster_connection");
   DBUG_PRINT("enter",("Ndb_cluster_connection this=0x%lx", (long) this));
@@ -453,6 +456,7 @@ Ndb_cluster_connection_impl::link_ndb_ob
   p->theImpl->m_next_ndb_object = m_first_ndb_object;
   m_first_ndb_object = p;
   
+  p->theFirstTransId += m_max_trans_id;
   unlock_ndb_objects();
 }
 
@@ -481,6 +485,12 @@ Ndb_cluster_connection_impl::unlink_ndb_
   p->theImpl->m_prev_ndb_object = 0;
   p->theImpl->m_next_ndb_object = 0;
 
+  Uint32 transId = (Uint32)p->theFirstTransId;
+  if (transId > m_max_trans_id)
+  {
+    m_max_trans_id = transId;
+  }
+
   unlock_ndb_objects();  
 }
 
@@ -590,6 +600,46 @@ Ndb_cluster_connection_impl::init_nodes_
   DBUG_RETURN(0);
 }
 
+int
+Ndb_cluster_connection_impl::configure(Uint32 nodeId,
+                                       const ndb_mgm_configuration &config)
+{
+  DBUG_ENTER("Ndb_cluster_connection_impl::configure");
+  {
+    ndb_mgm_configuration_iterator iter(config, CFG_SECTION_NODE);
+    if(iter.find(CFG_NODE_ID, nodeId))
+      DBUG_RETURN(-1);
+
+    // Configure scan settings
+    Uint32 scan_batch_size= 0;
+    if (!iter.get(CFG_MAX_SCAN_BATCH_SIZE, &scan_batch_size)) {
+      m_config.m_scan_batch_size= scan_batch_size;
+    }
+    Uint32 batch_byte_size= 0;
+    if (!iter.get(CFG_BATCH_BYTE_SIZE, &batch_byte_size)) {
+      m_config.m_batch_byte_size= batch_byte_size;
+    }
+    Uint32 batch_size= 0;
+    if (!iter.get(CFG_BATCH_SIZE, &batch_size)) {
+      m_config.m_batch_size= batch_size;
+    }
+
+    // Configure timeouts
+    Uint32 timeout = 120000;
+    for (iter.first(); iter.valid(); iter.next())
+    {
+      Uint32 tmp1 = 0, tmp2 = 0;
+      iter.get(CFG_DB_TRANSACTION_CHECK_INTERVAL, &tmp1);
+      iter.get(CFG_DB_TRANSACTION_DEADLOCK_TIMEOUT, &tmp2);
+      tmp1 += tmp2;
+      if (tmp1 > timeout)
+        timeout = tmp1;
+    }
+    m_config.m_waitfor_timeout = timeout;
+  }
+  DBUG_RETURN(init_nodes_vector(nodeId, config));
+}
+
 void
 Ndb_cluster_connection_impl::do_test()
 {
@@ -684,16 +734,16 @@ int Ndb_cluster_connection_impl::connect
     if(props == 0)
       break;
 
-    if (m_transporter_facade->start_instance(nodeId, props) < 0)
+    if (configure(nodeId, *props))
     {
       ndb_mgm_destroy_configuration(props);
+      DBUG_PRINT("exit", ("malloc failure, ret: -1"));
       DBUG_RETURN(-1);
     }
 
-    if (init_nodes_vector(nodeId, *props))
+    if (m_transporter_facade->start_instance(nodeId, props) < 0)
     {
       ndb_mgm_destroy_configuration(props);
-      DBUG_PRINT("exit", ("malloc failure, ret: -1"));
       DBUG_RETURN(-1);
     }
 

=== modified file 'storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp'
--- a/storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp	2010-05-04 14:34:54 +0000
+++ b/storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp	2010-09-30 11:52:49 +0000
@@ -37,6 +37,21 @@ extern "C" {
   void* run_ndb_cluster_connection_connect_thread(void*);
 }
 
+struct NdbApiConfig
+{
+  NdbApiConfig() :
+    m_scan_batch_size(MAX_SCAN_BATCH_SIZE),
+    m_batch_byte_size(SCAN_BATCH_SIZE),
+    m_batch_size(DEF_BATCH_SIZE),
+    m_waitfor_timeout(120000)
+    {}
+
+  Uint32 m_scan_batch_size;
+  Uint32 m_batch_byte_size;
+  Uint32 m_batch_size;
+  Uint32 m_waitfor_timeout; // in milli seconds...
+};
+
 class Ndb_cluster_connection_impl : public Ndb_cluster_connection
 {
   Ndb_cluster_connection_impl(const char *connectstring,
@@ -75,6 +90,7 @@ private:
 
   Vector<Node> m_all_nodes;
   int init_nodes_vector(Uint32 nodeid, const ndb_mgm_configuration &config);
+  int configure(Uint32 nodeid, const ndb_mgm_configuration &config);
   void connect_thread();
   void set_name(const char *name);
 
@@ -101,6 +117,12 @@ private:
 
   BaseString m_latest_error_msg;
   unsigned m_latest_error;
+
+  // Scan batch configuration parameters
+  NdbApiConfig m_config;
+  
+  // keep initial transId's increasing...
+  Uint32 m_max_trans_id;
 };
 
 #endif

=== added file 'storage/ndb/src/ndbapi/ndb_internal.cpp'
--- a/storage/ndb/src/ndbapi/ndb_internal.cpp	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/src/ndbapi/ndb_internal.cpp	2010-09-30 09:32:28 +0000
@@ -0,0 +1,34 @@
+/*
+   Copyright (C) 2007 MySQL AB
+    All rights reserved. Use is subject to license terms.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+*/
+
+#include "API.hpp"
+#include "ndb_internal.hpp"
+
+int
+Ndb_internal::send_event_report(bool has_lock, 
+                                Ndb *ndb, Uint32 *data, Uint32 length)
+{
+  return ndb->theImpl->send_event_report(has_lock, data, length);
+}
+
+void
+Ndb_internal::setForceShortRequests(Ndb* ndb, bool val)
+{
+  ndb->theImpl->forceShortRequests = val;
+}
+                                    

=== modified file 'storage/ndb/src/ndbapi/ndb_internal.hpp'
--- a/storage/ndb/src/ndbapi/ndb_internal.hpp	2009-06-22 08:23:35 +0000
+++ b/storage/ndb/src/ndbapi/ndb_internal.hpp	2010-09-30 12:52:55 +0000
@@ -16,15 +16,20 @@
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 */
 
-#include "NdbImpl.hpp"
+#ifndef NDB_INTERNAL_HPP
+#define NDB_INTERNAL_HPP
 
+/**
+ * This class exposes non-public funcionality to various test/utility programs
+ */
 class Ndb_internal
 {
-private:
-  friend class NdbEventBuffer;
-  friend class BackupRestore;
+public:
   Ndb_internal() {}
   virtual ~Ndb_internal() {}
-  static int send_event_report(bool has_lock, Ndb *ndb, Uint32 *data, Uint32 length)
-    { return ndb->theImpl->send_event_report(has_lock, data, length); }
+
+  static int send_event_report(bool has_lock, Ndb *ndb, Uint32*data,Uint32 len);
+  static void setForceShortRequests(Ndb*, bool val);
 };
+
+#endif

=== added file 'storage/ndb/src/ndbapi/trp_client.hpp'
--- a/storage/ndb/src/ndbapi/trp_client.hpp	1970-01-01 00:00:00 +0000
+++ b/storage/ndb/src/ndbapi/trp_client.hpp	2010-10-01 10:08:29 +0000
@@ -0,0 +1,36 @@
+/*
+   Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+*/
+
+#ifndef trp_client_hpp
+#define trp_client_hpp
+
+#include <ndb_global.h>
+
+class NdbApiSignal;
+struct LinearSectionPtr;
+
+class trp_client
+{
+public:
+  virtual ~trp_client() {}
+
+  virtual void trp_deliver_signal(const NdbApiSignal *,
+                                  const LinearSectionPtr ptr[3]) = 0;
+  virtual void trp_node_status(Uint32, Uint32 event) = 0;
+};
+
+#endif

=== modified file 'storage/ndb/test/ndbapi/testDict.cpp'
--- a/storage/ndb/test/ndbapi/testDict.cpp	2010-08-26 12:33:33 +0000
+++ b/storage/ndb/test/ndbapi/testDict.cpp	2010-09-30 14:27:18 +0000
@@ -7749,8 +7749,10 @@ runBug46585(NDBT_Context* ctx, NDBT_Step
     CHECK2(res.waitClusterStarted() == 0,
            "wait cluster started failed");
 
-    int restartGCI = pNdb->NdbTamper(Ndb::ReadRestartGCI, 0);
-    ndbout_c("restartGCI: %d", restartGCI);
+    Uint32 restartGCI = 0;
+    CHECK2(pDic->getRestartGCI(&restartGCI) == 0,
+           "getRestartGCI failed");
+    ndbout_c("restartGCI: %u", restartGCI);
 
     pDic->invalidateTable(tab.getName());
     {

=== modified file 'storage/ndb/test/ndbapi/testRestartGci.cpp'
--- a/storage/ndb/test/ndbapi/testRestartGci.cpp	2010-09-15 09:43:39 +0000
+++ b/storage/ndb/test/ndbapi/testRestartGci.cpp	2010-09-30 15:26:18 +0000
@@ -132,7 +132,14 @@ int runVerifyInserts(NDBT_Context* ctx, 
   HugoOperations hugoOps(*ctx->getTab());
   NdbRestarter restarter;
 
-  int restartGCI = pNdb->NdbTamper(Ndb::ReadRestartGCI, 0);    
+  Uint32 restartGCI;
+  int res = pNdb->getDictionary()->getRestartGCI(&restartGCI);
+  if (res != 0)
+  {
+    ndbout << "Failed to retreive restart gci" << endl;
+    ndbout << pNdb->getDictionary()->getNdbError() << endl;
+    return NDBT_FAILED;
+  }
 
   ndbout << "restartGCI = " << restartGCI << endl;
   int count = 0;
@@ -145,7 +152,7 @@ int runVerifyInserts(NDBT_Context* ctx, 
   int recordsWithLowerOrSameGci = 0;
   unsigned i; 
   for (i = 0; i < savedRecords.size(); i++){
-    if (savedRecords[i].m_gci <= restartGCI)
+    if (savedRecords[i].m_gci <= (int)restartGCI)
       recordsWithLowerOrSameGci++;
   }
   if (recordsWithLowerOrSameGci != count){
@@ -173,7 +180,7 @@ int runVerifyInserts(NDBT_Context* ctx, 
       // Record was not found in db'
 
       // Check record gci
-      if (savedRecords[i].m_gci <= restartGCI){
+      if (savedRecords[i].m_gci <= (int)restartGCI){
 	ndbout << "ERR: Record "<<i<<" should have existed" << endl;
 	result = NDBT_FAILED;
       }
@@ -194,7 +201,7 @@ int runVerifyInserts(NDBT_Context* ctx, 
 	result = NDBT_FAILED;
       }
       // Check record gci in range
-      if (savedRecords[i].m_gci > restartGCI){
+      if (savedRecords[i].m_gci > (int)restartGCI){
 	ndbout << "ERR: Record "<<i<<" should not have existed" << endl;
 	result = NDBT_FAILED;
       }

=== modified file 'storage/ndb/test/src/NDBT_Test.cpp'
--- a/storage/ndb/test/src/NDBT_Test.cpp	2010-09-23 11:55:42 +0000
+++ b/storage/ndb/test/src/NDBT_Test.cpp	2010-10-04 14:44:27 +0000
@@ -275,7 +275,7 @@ NDBT_Step::NDBT_Step(NDBT_TestCase* ptes
 {
 }
 
-#include <../../src/ndbapi/NdbImpl.hpp>
+#include "../../src/ndbapi/ndb_internal.hpp"
 
 int
 NDBT_Step::setUp(Ndb_cluster_connection& con){
@@ -290,8 +290,8 @@ NDBT_Step::setUp(Ndb_cluster_connection&
     m_ndb = new Ndb(&con, "TEST_DB" );
     m_ndb->init(1024);
 
-    NdbImpl::setForceShortRequests(m_ndb, 
-                                   m_ctx->suite->getForceShort());
+    Ndb_internal::setForceShortRequests(m_ndb, 
+                                        m_ctx->suite->getForceShort());
 
     int result = m_ndb->waitUntilReady(300); // 5 minutes
     if (result != 0){
@@ -946,7 +946,7 @@ NDBT_TestSuite::executeOneCtx(Ndb_cluste
     Ndb ndb(&con, "TEST_DB");
     ndb.init(1024);
 
-    NdbImpl::setForceShortRequests(&ndb, m_forceShort);
+    Ndb_internal::setForceShortRequests(&ndb, m_forceShort);
 
     int result = ndb.waitUntilReady(300); // 5 minutes
     if (result != 0){


Attachment: [text/bzr-bundle] bzr/jonas@mysql.com-20101004144427-so0zgv71exnklzeg.bundle
Thread
bzr commit into mysql-5.1-telco-7.0-spj branch (jonas:3221) Jonas Oreland4 Oct