Commit cd2e3aca authored by unknown's avatar unknown
Browse files

moved some Ndb member variables to NdbImpl class

removed theCurrentConnectCounter
optimized the_release_ind by using pos[0] to indicate that there is something there
smaller storage of theDBNodes array by using Uint8
set the_relase_ind array to Uint32 to avoid possible parallell thread usage errors

parent 4630d406
Loading
Loading
Loading
Loading
+1 −10
Original line number Diff line number Diff line
@@ -1586,7 +1586,6 @@ private:
/******************************************************************************
 *	These are the private variables in this class.	
 *****************************************************************************/
  NdbObjectIdMap*       theNdbObjectIdMap;
  Ndb_cluster_connection   *m_ndb_cluster_connection;

  NdbConnection**       thePreparedTransactionsArray;
@@ -1637,10 +1636,6 @@ private:
  Uint32   theMyRef;        // My block reference  
  Uint32   theNode;         // The node number of our node
  
  Uint32   theNoOfDBnodes;  // The number of DB nodes  
  Uint32 * theDBnodes;      // The node number of the DB nodes
  Uint8    *the_release_ind;// 1 indicates to release all connections to node 
  
  Uint64               the_last_check_time;
  Uint64               theFirstTransId;
  
@@ -1663,10 +1658,6 @@ private:
    InitConfigError
  } theInitState;

  // Ensure good distribution of connects
  Uint32		theCurrentConnectIndex;
  Uint32		theCurrentConnectCounter;
  
  /**
   * Computes fragement id for primary key
   *
@@ -1692,7 +1683,7 @@ private:
    Uint32 noOfFragments;
    Uint32 * fragment2PrimaryNodeMap;
    
    void init(Uint32 noOfNodes, Uint32 nodeIds[]);
    void init(Uint32 noOfNodes, Uint8 nodeIds[]);
    void release();
  } startTransactionNodeSelectionData;
  
+13 −24
Original line number Diff line number Diff line
@@ -65,37 +65,25 @@ NdbConnection* Ndb::doConnect(Uint32 tConNode)
// We will connect to any node. Make sure that we have connections to all
// nodes.
//****************************************************************************
  Uint32 tNoOfDbNodes = theNoOfDBnodes;
  i = theCurrentConnectIndex;
  Uint32 tNoOfDbNodes= theImpl->theNoOfDBnodes;
  Uint32 &theCurrentConnectIndex= theImpl->theCurrentConnectIndex;
  UintR Tcount = 0;
  do {
    if (i >= tNoOfDbNodes) {
      i = 0;
    theCurrentConnectIndex++;
    if (theCurrentConnectIndex >= tNoOfDbNodes) {
      theCurrentConnectIndex = 0;
    }//if
    Tcount++;
    tNode = theDBnodes[i];
    tNode = theImpl->theDBnodes[theCurrentConnectIndex];
    TretCode = NDB_connect(tNode);
    if ((TretCode == 1) || (TretCode == 2)) {
//****************************************************************************
// We have connections now to the desired node. Return
//****************************************************************************
      if (theCurrentConnectIndex == i) {
        theCurrentConnectCounter++;
        if (theCurrentConnectCounter == 8) {
	  theCurrentConnectCounter = 1;
	  theCurrentConnectIndex++;
	}//if
      } else {
	// Set to 2 because we have already connected to a node 
	// when we get here.
        theCurrentConnectCounter = 2;
        theCurrentConnectIndex = i;
      }//if
      return getConnectedNdbConnection(tNode);
    } else if (TretCode != 0) {
      tAnyAlive = 1;
    }//if
    i++;
  } while (Tcount < tNoOfDbNodes);
//****************************************************************************
// We were unable to find a free connection. If no node alive we will report
@@ -211,8 +199,9 @@ Ndb::doDisconnect()
  NdbConnection* tNdbCon;
  CHECK_STATUS_MACRO_VOID;

  DBUG_PRINT("info", ("theNoOfDBnodes=%d", theNoOfDBnodes));
  Uint32 tNoOfDbNodes = theNoOfDBnodes;
  Uint32 tNoOfDbNodes = theImpl->theNoOfDBnodes;
  Uint8 *theDBnodes= theImpl->theDBnodes;
  DBUG_PRINT("info", ("theNoOfDBnodes=%d", tNoOfDbNodes));
  UintR i;
  for (i = 0; i < tNoOfDbNodes; i++) {
    Uint32 tNode = theDBnodes[i];
@@ -259,8 +248,8 @@ Ndb::waitUntilReady(int timeout)
      unsigned int foundAliveNode = 0;
      TransporterFacade *tp = TransporterFacade::instance();
      tp->lock_mutex();
      for (unsigned int i = 0; i < theNoOfDBnodes; i++) {
	const NodeId nodeId = theDBnodes[i];
      for (unsigned int i = 0; i < theImpl->theNoOfDBnodes; i++) {
	const NodeId nodeId = theImpl->theDBnodes[i];
	//************************************************
	// If any node is answering, ndb is answering
	//************************************************
@@ -270,7 +259,7 @@ Ndb::waitUntilReady(int timeout)
      }//for
      
      tp->unlock_mutex();
      if (foundAliveNode == theNoOfDBnodes) {
      if (foundAliveNode == theImpl->theNoOfDBnodes) {
	DBUG_RETURN(0);
      }//if
      if (foundAliveNode > 0) {
@@ -1077,7 +1066,7 @@ Ndb::guessPrimaryNode(Uint32 fragmentId){

void
Ndb::StartTransactionNodeSelectionData::init(Uint32 noOfNodes,
                                             Uint32 nodeIds[]) {
                                             Uint8 nodeIds[]) {
  kValue           = 6;
  noOfFragments    = 2 * noOfNodes;

+2 −2
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ NdbConnection::NdbConnection( Ndb* aNdb ) :
{
  theListState = NotInList;
  theError.code = 0;
  theId = theNdb->theNdbObjectIdMap->map(this);
  theId = theNdb->theImpl->theNdbObjectIdMap.map(this);

#define CHECK_SZ(mask, sz) assert((sizeof(mask)/sizeof(mask[0])) == sz)

@@ -99,7 +99,7 @@ Remark: Deletes the connection object.
NdbConnection::~NdbConnection()
{
  DBUG_ENTER("NdbConnection::~NdbConnection");
  theNdb->theNdbObjectIdMap->unmap(theId, this);
  theNdb->theImpl->theNdbObjectIdMap.unmap(theId, this);
  DBUG_VOID_RETURN;
}//NdbConnection::~NdbConnection()

+21 −12
Original line number Diff line number Diff line
@@ -17,7 +17,15 @@
#ifndef NDB_IMPL_HPP
#define NDB_IMPL_HPP

#include <Vector.hpp>
#include <Ndb.hpp>
#include <NdbError.hpp>
#include <NdbCondition.h>
#include <NdbReceiver.hpp>
#include <NdbOperation.hpp>
#include <kernel/ndb_limits.h>

#include <NdbTick.h>

#include "ObjectMap.hpp"

/**
@@ -25,19 +33,20 @@
 */
class NdbImpl {
public:
  Vector<class NdbTableImpl *> m_invalidTables;
  NdbImpl();
  ~NdbImpl();

  void checkErrorCode(Uint32 i);
  void checkInvalidTable(class NdbDictionaryImpl * dict);
};
  // Ensure good distribution of connects
  Uint32 theCurrentConnectIndex;

#include <Ndb.hpp>
#include <NdbError.hpp>
#include <NdbCondition.h>
#include <NdbReceiver.hpp>
#include <NdbOperation.hpp>
  NdbObjectIdMap theNdbObjectIdMap;

#include <NdbTick.h>
  Uint32 theNoOfDBnodes; // The number of DB nodes  
  Uint8 theDBnodes[MAX_NDB_NODES]; // The node number of the DB nodes

 // 1 indicates to release all connections to node 
  Uint32 the_release_ind[MAX_NDB_NODES];
};

#ifdef VM_TRACE
#define TRACE_DEBUG(x) ndbout << x << endl;
@@ -57,7 +66,7 @@ public:
inline
void *
Ndb::int2void(Uint32 val){
  return theNdbObjectIdMap->getObject(val);
  return theImpl->theNdbObjectIdMap.getObject(val);
}

inline
+2 −2
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ NdbReceiver::~NdbReceiver()
{
  DBUG_ENTER("NdbReceiver::~NdbReceiver");
  if (m_id != NdbObjectIdMap::InvalidId) {
    m_ndb->theNdbObjectIdMap->unmap(m_id, this);
    m_ndb->theImpl->theNdbObjectIdMap.unmap(m_id, this);
  }
  delete[] m_rows;
  DBUG_VOID_RETURN;
@@ -54,7 +54,7 @@ NdbReceiver::init(ReceiverType type, void* owner)
  m_owner = owner;
  if (m_id == NdbObjectIdMap::InvalidId) {
    if (m_ndb)
      m_id = m_ndb->theNdbObjectIdMap->map(this);
      m_id = m_ndb->theImpl->theNdbObjectIdMap.map(this);
  }

  theFirstRecAttr = NULL;
Loading