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 533b5dcc
...@@ -1586,7 +1586,6 @@ private: ...@@ -1586,7 +1586,6 @@ private:
/****************************************************************************** /******************************************************************************
* These are the private variables in this class. * These are the private variables in this class.
*****************************************************************************/ *****************************************************************************/
NdbObjectIdMap* theNdbObjectIdMap;
Ndb_cluster_connection *m_ndb_cluster_connection; Ndb_cluster_connection *m_ndb_cluster_connection;
NdbConnection** thePreparedTransactionsArray; NdbConnection** thePreparedTransactionsArray;
...@@ -1637,10 +1636,6 @@ private: ...@@ -1637,10 +1636,6 @@ private:
Uint32 theMyRef; // My block reference Uint32 theMyRef; // My block reference
Uint32 theNode; // The node number of our node 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 the_last_check_time;
Uint64 theFirstTransId; Uint64 theFirstTransId;
...@@ -1663,10 +1658,6 @@ private: ...@@ -1663,10 +1658,6 @@ private:
InitConfigError InitConfigError
} theInitState; } theInitState;
// Ensure good distribution of connects
Uint32 theCurrentConnectIndex;
Uint32 theCurrentConnectCounter;
/** /**
* Computes fragement id for primary key * Computes fragement id for primary key
* *
...@@ -1692,7 +1683,7 @@ private: ...@@ -1692,7 +1683,7 @@ private:
Uint32 noOfFragments; Uint32 noOfFragments;
Uint32 * fragment2PrimaryNodeMap; Uint32 * fragment2PrimaryNodeMap;
void init(Uint32 noOfNodes, Uint32 nodeIds[]); void init(Uint32 noOfNodes, Uint8 nodeIds[]);
void release(); void release();
} startTransactionNodeSelectionData; } startTransactionNodeSelectionData;
......
...@@ -65,37 +65,25 @@ NdbConnection* Ndb::doConnect(Uint32 tConNode) ...@@ -65,37 +65,25 @@ NdbConnection* Ndb::doConnect(Uint32 tConNode)
// We will connect to any node. Make sure that we have connections to all // We will connect to any node. Make sure that we have connections to all
// nodes. // nodes.
//**************************************************************************** //****************************************************************************
Uint32 tNoOfDbNodes = theNoOfDBnodes; Uint32 tNoOfDbNodes= theImpl->theNoOfDBnodes;
i = theCurrentConnectIndex; Uint32 &theCurrentConnectIndex= theImpl->theCurrentConnectIndex;
UintR Tcount = 0; UintR Tcount = 0;
do { do {
if (i >= tNoOfDbNodes) { theCurrentConnectIndex++;
i = 0; if (theCurrentConnectIndex >= tNoOfDbNodes) {
theCurrentConnectIndex = 0;
}//if }//if
Tcount++; Tcount++;
tNode = theDBnodes[i]; tNode = theImpl->theDBnodes[theCurrentConnectIndex];
TretCode = NDB_connect(tNode); TretCode = NDB_connect(tNode);
if ((TretCode == 1) || (TretCode == 2)) { if ((TretCode == 1) || (TretCode == 2)) {
//**************************************************************************** //****************************************************************************
// We have connections now to the desired node. Return // 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); return getConnectedNdbConnection(tNode);
} else if (TretCode != 0) { } else if (TretCode != 0) {
tAnyAlive = 1; tAnyAlive = 1;
}//if }//if
i++;
} while (Tcount < tNoOfDbNodes); } while (Tcount < tNoOfDbNodes);
//**************************************************************************** //****************************************************************************
// We were unable to find a free connection. If no node alive we will report // We were unable to find a free connection. If no node alive we will report
...@@ -211,8 +199,9 @@ Ndb::doDisconnect() ...@@ -211,8 +199,9 @@ Ndb::doDisconnect()
NdbConnection* tNdbCon; NdbConnection* tNdbCon;
CHECK_STATUS_MACRO_VOID; CHECK_STATUS_MACRO_VOID;
DBUG_PRINT("info", ("theNoOfDBnodes=%d", theNoOfDBnodes)); Uint32 tNoOfDbNodes = theImpl->theNoOfDBnodes;
Uint32 tNoOfDbNodes = theNoOfDBnodes; Uint8 *theDBnodes= theImpl->theDBnodes;
DBUG_PRINT("info", ("theNoOfDBnodes=%d", tNoOfDbNodes));
UintR i; UintR i;
for (i = 0; i < tNoOfDbNodes; i++) { for (i = 0; i < tNoOfDbNodes; i++) {
Uint32 tNode = theDBnodes[i]; Uint32 tNode = theDBnodes[i];
...@@ -259,8 +248,8 @@ Ndb::waitUntilReady(int timeout) ...@@ -259,8 +248,8 @@ Ndb::waitUntilReady(int timeout)
unsigned int foundAliveNode = 0; unsigned int foundAliveNode = 0;
TransporterFacade *tp = TransporterFacade::instance(); TransporterFacade *tp = TransporterFacade::instance();
tp->lock_mutex(); tp->lock_mutex();
for (unsigned int i = 0; i < theNoOfDBnodes; i++) { for (unsigned int i = 0; i < theImpl->theNoOfDBnodes; i++) {
const NodeId nodeId = theDBnodes[i]; const NodeId nodeId = theImpl->theDBnodes[i];
//************************************************ //************************************************
// If any node is answering, ndb is answering // If any node is answering, ndb is answering
//************************************************ //************************************************
...@@ -270,7 +259,7 @@ Ndb::waitUntilReady(int timeout) ...@@ -270,7 +259,7 @@ Ndb::waitUntilReady(int timeout)
}//for }//for
tp->unlock_mutex(); tp->unlock_mutex();
if (foundAliveNode == theNoOfDBnodes) { if (foundAliveNode == theImpl->theNoOfDBnodes) {
DBUG_RETURN(0); DBUG_RETURN(0);
}//if }//if
if (foundAliveNode > 0) { if (foundAliveNode > 0) {
...@@ -1077,7 +1066,7 @@ Ndb::guessPrimaryNode(Uint32 fragmentId){ ...@@ -1077,7 +1066,7 @@ Ndb::guessPrimaryNode(Uint32 fragmentId){
void void
Ndb::StartTransactionNodeSelectionData::init(Uint32 noOfNodes, Ndb::StartTransactionNodeSelectionData::init(Uint32 noOfNodes,
Uint32 nodeIds[]) { Uint8 nodeIds[]) {
kValue = 6; kValue = 6;
noOfFragments = 2 * noOfNodes; noOfFragments = 2 * noOfNodes;
......
...@@ -83,7 +83,7 @@ NdbConnection::NdbConnection( Ndb* aNdb ) : ...@@ -83,7 +83,7 @@ NdbConnection::NdbConnection( Ndb* aNdb ) :
{ {
theListState = NotInList; theListState = NotInList;
theError.code = 0; 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) #define CHECK_SZ(mask, sz) assert((sizeof(mask)/sizeof(mask[0])) == sz)
...@@ -99,7 +99,7 @@ Remark: Deletes the connection object. ...@@ -99,7 +99,7 @@ Remark: Deletes the connection object.
NdbConnection::~NdbConnection() NdbConnection::~NdbConnection()
{ {
DBUG_ENTER("NdbConnection::~NdbConnection"); DBUG_ENTER("NdbConnection::~NdbConnection");
theNdb->theNdbObjectIdMap->unmap(theId, this); theNdb->theImpl->theNdbObjectIdMap.unmap(theId, this);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
}//NdbConnection::~NdbConnection() }//NdbConnection::~NdbConnection()
......
...@@ -17,7 +17,15 @@ ...@@ -17,7 +17,15 @@
#ifndef NDB_IMPL_HPP #ifndef NDB_IMPL_HPP
#define 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" #include "ObjectMap.hpp"
/** /**
...@@ -25,19 +33,20 @@ ...@@ -25,19 +33,20 @@
*/ */
class NdbImpl { class NdbImpl {
public: public:
Vector<class NdbTableImpl *> m_invalidTables; NdbImpl();
~NdbImpl();
void checkErrorCode(Uint32 i); // Ensure good distribution of connects
void checkInvalidTable(class NdbDictionaryImpl * dict); Uint32 theCurrentConnectIndex;
};
#include <Ndb.hpp> NdbObjectIdMap theNdbObjectIdMap;
#include <NdbError.hpp>
#include <NdbCondition.h>
#include <NdbReceiver.hpp>
#include <NdbOperation.hpp>
#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 #ifdef VM_TRACE
#define TRACE_DEBUG(x) ndbout << x << endl; #define TRACE_DEBUG(x) ndbout << x << endl;
...@@ -57,7 +66,7 @@ public: ...@@ -57,7 +66,7 @@ public:
inline inline
void * void *
Ndb::int2void(Uint32 val){ Ndb::int2void(Uint32 val){
return theNdbObjectIdMap->getObject(val); return theImpl->theNdbObjectIdMap.getObject(val);
} }
inline inline
......
...@@ -40,7 +40,7 @@ NdbReceiver::~NdbReceiver() ...@@ -40,7 +40,7 @@ NdbReceiver::~NdbReceiver()
{ {
DBUG_ENTER("NdbReceiver::~NdbReceiver"); DBUG_ENTER("NdbReceiver::~NdbReceiver");
if (m_id != NdbObjectIdMap::InvalidId) { if (m_id != NdbObjectIdMap::InvalidId) {
m_ndb->theNdbObjectIdMap->unmap(m_id, this); m_ndb->theImpl->theNdbObjectIdMap.unmap(m_id, this);
} }
delete[] m_rows; delete[] m_rows;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
...@@ -54,7 +54,7 @@ NdbReceiver::init(ReceiverType type, void* owner) ...@@ -54,7 +54,7 @@ NdbReceiver::init(ReceiverType type, void* owner)
m_owner = owner; m_owner = owner;
if (m_id == NdbObjectIdMap::InvalidId) { if (m_id == NdbObjectIdMap::InvalidId) {
if (m_ndb) if (m_ndb)
m_id = m_ndb->theNdbObjectIdMap->map(this); m_id = m_ndb->theImpl->theNdbObjectIdMap.map(this);
} }
theFirstRecAttr = NULL; theFirstRecAttr = NULL;
......
...@@ -92,8 +92,8 @@ Ndb::init(int aMaxNoOfTransactions) ...@@ -92,8 +92,8 @@ Ndb::init(int aMaxNoOfTransactions)
theDictionary->setTransporter(this, theFacade); theDictionary->setTransporter(this, theFacade);
aNrOfCon = theNoOfDBnodes; aNrOfCon = theImpl->theNoOfDBnodes;
aNrOfOp = 2*theNoOfDBnodes; aNrOfOp = 2*theImpl->theNoOfDBnodes;
// Create connection object in a linked list // Create connection object in a linked list
if((createConIdleList(aNrOfCon)) == -1){ if((createConIdleList(aNrOfCon)) == -1){
...@@ -192,14 +192,14 @@ void Ndb::connected(Uint32 ref) ...@@ -192,14 +192,14 @@ void Ndb::connected(Uint32 ref)
} }
TransporterFacade * theFacade = TransporterFacade::instance(); TransporterFacade * theFacade = TransporterFacade::instance();
int i; int i, n= 0;
theNoOfDBnodes= 0;
for (i = 1; i < MAX_NDB_NODES; i++){ for (i = 1; i < MAX_NDB_NODES; i++){
if (theFacade->getIsDbNode(i)){ if (theFacade->getIsDbNode(i)){
theDBnodes[theNoOfDBnodes] = i; theImpl->theDBnodes[n] = i;
theNoOfDBnodes++; n++;
} }
} }
theImpl->theNoOfDBnodes= n;
theFirstTransId = ((Uint64)tBlockNo << 52)+ theFirstTransId = ((Uint64)tBlockNo << 52)+
((Uint64)tmpTheNode << 40); ((Uint64)tmpTheNode << 40);
theFirstTransId += theFacade->m_max_trans_id; theFirstTransId += theFacade->m_max_trans_id;
...@@ -207,9 +207,10 @@ void Ndb::connected(Uint32 ref) ...@@ -207,9 +207,10 @@ void Ndb::connected(Uint32 ref)
DBUG_PRINT("info",("connected with ref=%x, id=%d, no_db_nodes=%d, first_trans_id=%lx", DBUG_PRINT("info",("connected with ref=%x, id=%d, no_db_nodes=%d, first_trans_id=%lx",
theMyRef, theMyRef,
tmpTheNode, tmpTheNode,
theNoOfDBnodes, theImpl->theNoOfDBnodes,
theFirstTransId)); theFirstTransId));
startTransactionNodeSelectionData.init(theNoOfDBnodes, theDBnodes); startTransactionNodeSelectionData.init(theImpl->theNoOfDBnodes,
theImpl->theDBnodes);
theCommitAckSignal = new NdbApiSignal(theMyRef); theCommitAckSignal = new NdbApiSignal(theMyRef);
theDictionary->m_receiver.m_reference= theMyRef; theDictionary->m_receiver.m_reference= theMyRef;
...@@ -247,7 +248,9 @@ Ndb::report_node_failure(Uint32 node_id) ...@@ -247,7 +248,9 @@ Ndb::report_node_failure(Uint32 node_id)
* *
* This method is only called by ClusterMgr (via lots of methods) * This method is only called by ClusterMgr (via lots of methods)
*/ */
the_release_ind[node_id] = 1; theImpl->the_release_ind[node_id] = 1;
// must come after
theImpl->the_release_ind[0] = 1;
theWaiter.nodeFail(node_id); theWaiter.nodeFail(node_id);
return; return;
}//Ndb::report_node_failure() }//Ndb::report_node_failure()
......
...@@ -82,7 +82,6 @@ void Ndb::setup(Ndb_cluster_connection *ndb_cluster_connection, ...@@ -82,7 +82,6 @@ void Ndb::setup(Ndb_cluster_connection *ndb_cluster_connection,
{ {
DBUG_ENTER("Ndb::setup"); DBUG_ENTER("Ndb::setup");
theNdbObjectIdMap= 0;
m_ndb_cluster_connection= ndb_cluster_connection; m_ndb_cluster_connection= ndb_cluster_connection;
thePreparedTransactionsArray= NULL; thePreparedTransactionsArray= NULL;
theSentTransactionsArray= NULL; theSentTransactionsArray= NULL;
...@@ -110,9 +109,6 @@ void Ndb::setup(Ndb_cluster_connection *ndb_cluster_connection, ...@@ -110,9 +109,6 @@ void Ndb::setup(Ndb_cluster_connection *ndb_cluster_connection,
theCallList= NULL; theCallList= NULL;
theScanList= NULL; theScanList= NULL;
theNdbBlobIdleList= NULL; theNdbBlobIdleList= NULL;
theNoOfDBnodes= 0;
theDBnodes= NULL;
the_release_ind= NULL;
the_last_check_time= 0; the_last_check_time= 0;
theFirstTransId= 0; theFirstTransId= 0;
theRestartGCI= 0; theRestartGCI= 0;
...@@ -134,19 +130,12 @@ void Ndb::setup(Ndb_cluster_connection *ndb_cluster_connection, ...@@ -134,19 +130,12 @@ void Ndb::setup(Ndb_cluster_connection *ndb_cluster_connection,
theError.code = 0; theError.code = 0;
theNdbObjectIdMap = new NdbObjectIdMap(1024,1024);
theConnectionArray = new NdbConnection * [MAX_NDB_NODES]; theConnectionArray = new NdbConnection * [MAX_NDB_NODES];
theDBnodes = new Uint32[MAX_NDB_NODES];
the_release_ind = new Uint8[MAX_NDB_NODES];
theCommitAckSignal = NULL; theCommitAckSignal = NULL;
theCurrentConnectCounter = 1;
theCurrentConnectIndex = 0;
int i; int i;
for (i = 0; i < MAX_NDB_NODES ; i++) { for (i = 0; i < MAX_NDB_NODES ; i++) {
theConnectionArray[i] = NULL; theConnectionArray[i] = NULL;
the_release_ind[i] = 0;
theDBnodes[i] = 0;
}//forg }//forg
for (i = 0; i < 2048 ; i++) { for (i = 0; i < 2048 ; i++) {
theFirstTupleId[i] = 0; theFirstTupleId[i] = 0;
...@@ -213,7 +202,6 @@ Ndb::~Ndb() ...@@ -213,7 +202,6 @@ Ndb::~Ndb()
doDisconnect(); doDisconnect();
delete theDictionary; delete theDictionary;
delete theImpl;
NdbGlobalEventBuffer_drop(theGlobalEventBufferHandle); NdbGlobalEventBuffer_drop(theGlobalEventBufferHandle);
...@@ -260,15 +248,12 @@ Ndb::~Ndb() ...@@ -260,15 +248,12 @@ Ndb::~Ndb()
startTransactionNodeSelectionData.release(); startTransactionNodeSelectionData.release();
delete []theConnectionArray; delete []theConnectionArray;
delete []theDBnodes;
delete []the_release_ind;
if(theCommitAckSignal != NULL){ if(theCommitAckSignal != NULL){
delete theCommitAckSignal; delete theCommitAckSignal;
theCommitAckSignal = NULL; theCommitAckSignal = NULL;
} }
if(theNdbObjectIdMap != 0) delete theImpl;
delete theNdbObjectIdMap;
/** /**
* This sleep is to make sure that the transporter * This sleep is to make sure that the transporter
...@@ -307,4 +292,17 @@ NdbWaiter::~NdbWaiter(){ ...@@ -307,4 +292,17 @@ NdbWaiter::~NdbWaiter(){
NdbCondition_Destroy(m_condition); NdbCondition_Destroy(m_condition);
} }
NdbImpl::NdbImpl() : theNdbObjectIdMap(1024,1024),
theCurrentConnectIndex(0),
theNoOfDBnodes(0)
{
int i;
for (i = 0; i < MAX_NDB_NODES; i++) {
the_release_ind[i] = 0;
}
}
NdbImpl::~NdbImpl()
{
}
...@@ -30,10 +30,18 @@ void ...@@ -30,10 +30,18 @@ void
Ndb::checkFailedNode() Ndb::checkFailedNode()
{ {
DBUG_ENTER("Ndb::checkFailedNode"); DBUG_ENTER("Ndb::checkFailedNode");
DBUG_PRINT("enter", ("theNoOfDBnodes: %d", theNoOfDBnodes)); Uint32 *the_release_ind= theImpl->the_release_ind;
if (the_release_ind[0] == 0)
{
DBUG_VOID_RETURN;
}
Uint32 tNoOfDbNodes = theImpl->theNoOfDBnodes;
Uint8 *theDBnodes= theImpl->theDBnodes;
DBUG_PRINT("enter", ("theNoOfDBnodes: %d", tNoOfDbNodes));
DBUG_ASSERT(theNoOfDBnodes < MAX_NDB_NODES); DBUG_ASSERT(tNoOfDbNodes < MAX_NDB_NODES);
for (Uint32 i = 0; i < theNoOfDBnodes; i++){ for (Uint32 i = 0; i < tNoOfDbNodes; i++){
const NodeId node_id = theDBnodes[i]; const NodeId node_id = theDBnodes[i];
DBUG_PRINT("info", ("i: %d, node_id: %d", i, node_id)); DBUG_PRINT("info", ("i: %d, node_id: %d", i, node_id));
...@@ -56,31 +64,6 @@ Ndb::checkFailedNode() ...@@ -56,31 +64,6 @@ Ndb::checkFailedNode()
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
#if 0
void
NdbImpl::checkInvalidTable(NdbDictionaryImpl * dict){
Uint32 sz = m_invalidTables.size();
for(Int32 i = sz - 1; i >= 0; i--){
NdbTableImpl * tab = m_invalidTables[i];
m_invalidTables.erase(i);
dict->tableDropped(* tab);
}
}
void
NdbImpl::checkErrorCode(Uint32 i, NdbTableImpl * tab){
switch(i){
case 241:
case 283:
case 284:
case 285:
case 1225:
case 1226:
}
}
#endif
/*************************************************************************** /***************************************************************************
* int createConIdleList(int aNrOfCon); * int createConIdleList(int aNrOfCon);
* *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment