Commit 9dac644f authored by joreland@mysql.com's avatar joreland@mysql.com

ndb - removed deprecated Ndb constructor

parent 228a63d3
...@@ -1038,9 +1038,6 @@ public: ...@@ -1038,9 +1038,6 @@ public:
Ndb(Ndb_cluster_connection *ndb_cluster_connection, Ndb(Ndb_cluster_connection *ndb_cluster_connection,
const char* aCatalogName = "", const char* aSchemaName = "def"); const char* aCatalogName = "", const char* aSchemaName = "def");
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
Ndb(const char* aCatalogName = "", const char* aSchemaName = "def");
#endif
~Ndb(); ~Ndb();
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
...@@ -1349,13 +1346,6 @@ public: ...@@ -1349,13 +1346,6 @@ public:
*/ */
int getNodeId(); int getNodeId();
/**
* setConnectString
*
* @param connectString - see MySQL ref manual for format
*/
static void setConnectString(const char * connectString);
bool usingFullyQualifiedNames(); bool usingFullyQualifiedNames();
/** /**
......
...@@ -21,14 +21,16 @@ ...@@ -21,14 +21,16 @@
static NdbPool* m_pool = 0; static NdbPool* m_pool = 0;
bool bool
create_instance(Uint32 max_ndb_objects, create_instance(Ndb_cluster_connection* cc,
Uint32 max_ndb_objects,
Uint32 no_conn_obj, Uint32 no_conn_obj,
Uint32 init_no_ndb_objects) Uint32 init_no_ndb_objects)
{ {
if (m_pool != NULL) { if (m_pool != NULL) {
return false; return false;
} }
m_pool = NdbPool::create_instance(max_ndb_objects, m_pool = NdbPool::create_instance(cc,
max_ndb_objects,
no_conn_obj, no_conn_obj,
init_no_ndb_objects); init_no_ndb_objects);
if (m_pool == NULL) { if (m_pool == NULL) {
......
...@@ -20,7 +20,8 @@ NdbMutex *NdbPool::pool_mutex = NULL; ...@@ -20,7 +20,8 @@ NdbMutex *NdbPool::pool_mutex = NULL;
NdbPool *the_pool = NULL; NdbPool *the_pool = NULL;
NdbPool* NdbPool*
NdbPool::create_instance(Uint32 max_ndb_obj, NdbPool::create_instance(Ndb_cluster_connection* cc,
Uint32 max_ndb_obj,
Uint32 no_conn_obj, Uint32 no_conn_obj,
Uint32 init_no_ndb_objects) Uint32 init_no_ndb_objects)
{ {
...@@ -32,7 +33,7 @@ NdbPool::create_instance(Uint32 max_ndb_obj, ...@@ -32,7 +33,7 @@ NdbPool::create_instance(Uint32 max_ndb_obj,
if (the_pool != NULL) { if (the_pool != NULL) {
a_pool = NULL; a_pool = NULL;
} else { } else {
the_pool = new NdbPool(max_ndb_obj, no_conn_obj); the_pool = new NdbPool(cc, max_ndb_obj, no_conn_obj);
if (!the_pool->init(init_no_ndb_objects)) { if (!the_pool->init(init_no_ndb_objects)) {
delete the_pool; delete the_pool;
the_pool = NULL; the_pool = NULL;
...@@ -76,7 +77,8 @@ NdbPool::initPoolMutex() ...@@ -76,7 +77,8 @@ NdbPool::initPoolMutex()
return ret_result; return ret_result;
} }
NdbPool::NdbPool(Uint32 max_no_objects, NdbPool::NdbPool(Ndb_cluster_connection* cc,
Uint32 max_no_objects,
Uint32 no_conn_objects) Uint32 no_conn_objects)
{ {
if (no_conn_objects > 1024) { if (no_conn_objects > 1024) {
...@@ -101,6 +103,7 @@ NdbPool::NdbPool(Uint32 max_no_objects, ...@@ -101,6 +103,7 @@ NdbPool::NdbPool(Uint32 max_no_objects,
m_output_queue = 0; m_output_queue = 0;
m_input_queue = 0; m_input_queue = 0;
m_signal_count = 0; m_signal_count = 0;
m_cluster_connection = cc;
} }
NdbPool::~NdbPool() NdbPool::~NdbPool()
...@@ -294,9 +297,9 @@ NdbPool::allocate_ndb(Uint32 &id, ...@@ -294,9 +297,9 @@ NdbPool::allocate_ndb(Uint32 &id,
return false; return false;
} }
if (a_schema_name) { if (a_schema_name) {
a_ndb = new Ndb(a_schema_name, a_catalog_name); a_ndb = new Ndb(m_cluster_connection, a_schema_name, a_catalog_name);
} else { } else {
a_ndb = new Ndb(""); a_ndb = new Ndb(m_cluster_connection, "");
} }
if (a_ndb == NULL) { if (a_ndb == NULL) {
return false; return false;
......
...@@ -92,7 +92,8 @@ class NdbPool { ...@@ -92,7 +92,8 @@ class NdbPool {
Uint16 prev_db_object; Uint16 prev_db_object;
}; };
public: public:
static NdbPool* create_instance(Uint32 max_ndb_objects = 240, static NdbPool* create_instance(Ndb_cluster_connection*,
Uint32 max_ndb_objects = 240,
Uint32 no_conn_obj = 4, Uint32 no_conn_obj = 4,
Uint32 init_no_ndb_objects = 8); Uint32 init_no_ndb_objects = 8);
static void drop_instance(); static void drop_instance();
...@@ -104,7 +105,8 @@ class NdbPool { ...@@ -104,7 +105,8 @@ class NdbPool {
bool init(Uint32 initial_no_of_ndb_objects = 8); bool init(Uint32 initial_no_of_ndb_objects = 8);
void release_all(); void release_all();
static bool initPoolMutex(); static bool initPoolMutex();
NdbPool(Uint32 max_no_of_ndb_objects, Uint32 no_conn_objects); NdbPool(Ndb_cluster_connection*,
Uint32 max_no_of_ndb_objects, Uint32 no_conn_objects);
~NdbPool(); ~NdbPool();
/* /*
We have three lists: We have three lists:
...@@ -158,5 +160,7 @@ class NdbPool { ...@@ -158,5 +160,7 @@ class NdbPool {
Uint16 m_input_queue; Uint16 m_input_queue;
Uint16 m_output_queue; Uint16 m_output_queue;
Uint16 m_signal_count; Uint16 m_signal_count;
Ndb_cluster_connection * m_cluster_connection;
}; };
#endif #endif
...@@ -34,48 +34,12 @@ class NdbGlobalEventBufferHandle; ...@@ -34,48 +34,12 @@ class NdbGlobalEventBufferHandle;
NdbGlobalEventBufferHandle *NdbGlobalEventBuffer_init(int); NdbGlobalEventBufferHandle *NdbGlobalEventBuffer_init(int);
void NdbGlobalEventBuffer_drop(NdbGlobalEventBufferHandle *); void NdbGlobalEventBuffer_drop(NdbGlobalEventBufferHandle *);
/**
* Static object for NDB
*/
// only needed for backwards compatability, before ndb_cluster_connection
static char *ndbConnectString = 0;
static int theNoOfNdbObjects = 0;
static Ndb_cluster_connection *global_ndb_cluster_connection= 0;
/***************************************************************************
Ndb(const char* aDataBase);
Parameters: aDataBase : Name of the database.
Remark: Connect to the database.
***************************************************************************/
Ndb::Ndb( const char* aDataBase , const char* aSchema)
: theImpl(NULL)
{
DBUG_ENTER("Ndb::Ndb()");
DBUG_PRINT("enter",("(old)Ndb::Ndb this=0x%x", this));
if (theNoOfNdbObjects < 0)
abort(); // old and new Ndb constructor used mixed
theNoOfNdbObjects++;
if (global_ndb_cluster_connection == 0) {
global_ndb_cluster_connection= new Ndb_cluster_connection(ndbConnectString);
global_ndb_cluster_connection->connect(12,5,1);
}
setup(global_ndb_cluster_connection, aDataBase, aSchema);
DBUG_VOID_RETURN;
}
Ndb::Ndb( Ndb_cluster_connection *ndb_cluster_connection, Ndb::Ndb( Ndb_cluster_connection *ndb_cluster_connection,
const char* aDataBase , const char* aSchema) const char* aDataBase , const char* aSchema)
: theImpl(NULL) : theImpl(NULL)
{ {
DBUG_ENTER("Ndb::Ndb()"); DBUG_ENTER("Ndb::Ndb()");
DBUG_PRINT("enter",("Ndb::Ndb this=0x%x", this)); DBUG_PRINT("enter",("Ndb::Ndb this=0x%x", this));
if (global_ndb_cluster_connection != 0 &&
global_ndb_cluster_connection != ndb_cluster_connection)
abort(); // old and new Ndb constructor used mixed
theNoOfNdbObjects= -1;
setup(ndb_cluster_connection, aDataBase, aSchema); setup(ndb_cluster_connection, aDataBase, aSchema);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -177,16 +141,6 @@ void Ndb::setup(Ndb_cluster_connection *ndb_cluster_connection, ...@@ -177,16 +141,6 @@ void Ndb::setup(Ndb_cluster_connection *ndb_cluster_connection,
} }
void Ndb::setConnectString(const char * connectString)
{
if (ndbConnectString != 0) {
free(ndbConnectString);
ndbConnectString = 0;
}
if (connectString)
ndbConnectString = strdup(connectString);
}
/***************************************************************************** /*****************************************************************************
* ~Ndb(); * ~Ndb();
* *
...@@ -241,19 +195,6 @@ Ndb::~Ndb() ...@@ -241,19 +195,6 @@ Ndb::~Ndb()
delete theImpl; delete theImpl;
/**
* This needs to be put after delete theImpl
* as TransporterFacade::instance is delete by global_ndb_cluster_connection
* and used by theImpl
*/
if (global_ndb_cluster_connection != 0) {
theNoOfNdbObjects--;
if(theNoOfNdbObjects == 0){
delete global_ndb_cluster_connection;
global_ndb_cluster_connection= 0;
}
}//if
/** /**
* This sleep is to make sure that the transporter * This sleep is to make sure that the transporter
* send thread will come in and send any * send thread will come in and send any
......
...@@ -77,9 +77,12 @@ int main(int argc, char** argv){ ...@@ -77,9 +77,12 @@ int main(int argc, char** argv){
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
return NDBT_ProgramExit(NDBT_WRONGARGS); return NDBT_ProgramExit(NDBT_WRONGARGS);
Ndb::setConnectString(opt_connect_str); Ndb_cluster_connection con(opt_connect_str);
// Connect to Ndb if(con.connect(12, 5, 1) != 0)
Ndb MyNdb(_dbname); {
return NDBT_ProgramExit(NDBT_FAILED);
}
Ndb MyNdb(&con, _dbname );
if(MyNdb.init() != 0){ if(MyNdb.init() != 0){
ERR(MyNdb.getNdbError()); ERR(MyNdb.getNdbError());
......
...@@ -77,10 +77,13 @@ int main(int argc, char** argv){ ...@@ -77,10 +77,13 @@ int main(int argc, char** argv){
if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option))) if ((ho_error=handle_options(&argc, &argv, my_long_options, get_one_option)))
return NDBT_ProgramExit(NDBT_WRONGARGS); return NDBT_ProgramExit(NDBT_WRONGARGS);
Ndb::setConnectString(opt_connect_str); Ndb_cluster_connection con(opt_connect_str);
if(con.connect(12, 5, 1) != 0)
{
return NDBT_ProgramExit(NDBT_FAILED);
}
Ndb* pMyNdb; Ndb* pMyNdb = new Ndb(&con, _dbname);
pMyNdb = new Ndb(_dbname);
pMyNdb->init(); pMyNdb->init();
ndbout << "Waiting..."; ndbout << "Waiting...";
......
...@@ -78,9 +78,13 @@ int main(int argc, char** argv){ ...@@ -78,9 +78,13 @@ int main(int argc, char** argv){
return NDBT_ProgramExit(NDBT_WRONGARGS); return NDBT_ProgramExit(NDBT_WRONGARGS);
} }
Ndb::setConnectString(opt_connect_str); Ndb_cluster_connection con(opt_connect_str);
// Connect to Ndb if(con.connect(12, 5, 1) != 0)
Ndb MyNdb(_dbname); {
return NDBT_ProgramExit(NDBT_FAILED);
}
Ndb MyNdb(&con, _dbname );
if(MyNdb.init() != 0){ if(MyNdb.init() != 0){
ERR(MyNdb.getNdbError()); ERR(MyNdb.getNdbError());
return NDBT_ProgramExit(NDBT_FAILED); return NDBT_ProgramExit(NDBT_FAILED);
......
...@@ -78,8 +78,13 @@ int main(int argc, char** argv){ ...@@ -78,8 +78,13 @@ int main(int argc, char** argv){
return NDBT_ProgramExit(NDBT_WRONGARGS); return NDBT_ProgramExit(NDBT_WRONGARGS);
} }
Ndb::setConnectString(opt_connect_str); Ndb_cluster_connection con(opt_connect_str);
Ndb MyNdb(_dbname); if(con.connect(12, 5, 1) != 0)
{
return NDBT_ProgramExit(NDBT_FAILED);
}
Ndb MyNdb(&con, _dbname );
if(MyNdb.init() != 0){ if(MyNdb.init() != 0){
ERR(MyNdb.getNdbError()); ERR(MyNdb.getNdbError());
return NDBT_ProgramExit(NDBT_FAILED); return NDBT_ProgramExit(NDBT_FAILED);
......
...@@ -23,6 +23,7 @@ extern FilteredNdbOut debug; ...@@ -23,6 +23,7 @@ extern FilteredNdbOut debug;
static void callback(int, NdbConnection*, void*); static void callback(int, NdbConnection*, void*);
extern const char * g_connect_string;
bool bool
BackupRestore::init() BackupRestore::init()
{ {
...@@ -31,7 +32,13 @@ BackupRestore::init() ...@@ -31,7 +32,13 @@ BackupRestore::init()
if (!m_restore && !m_restore_meta) if (!m_restore && !m_restore_meta)
return true; return true;
m_ndb = new Ndb(); m_cluster_connection = new Ndb_cluster_connection(g_connect_string);
if(m_cluster_connection->connect(12, 5, 1) != 0)
{
return -1;
}
m_ndb = new Ndb(m_cluster_connection);
if (m_ndb == NULL) if (m_ndb == NULL)
return false; return false;
...@@ -77,6 +84,12 @@ void BackupRestore::release() ...@@ -77,6 +84,12 @@ void BackupRestore::release()
delete [] m_callback; delete [] m_callback;
m_callback= 0; m_callback= 0;
} }
if (m_cluster_connection)
{
delete m_cluster_connection;
m_cluster_connection= 0;
}
} }
BackupRestore::~BackupRestore() BackupRestore::~BackupRestore()
......
...@@ -35,6 +35,7 @@ public: ...@@ -35,6 +35,7 @@ public:
BackupRestore(Uint32 parallelism=1) BackupRestore(Uint32 parallelism=1)
{ {
m_ndb = 0; m_ndb = 0;
m_cluster_connection = 0;
m_logCount = m_dataCount = 0; m_logCount = m_dataCount = 0;
m_restore = false; m_restore = false;
m_restore_meta = false; m_restore_meta = false;
...@@ -62,6 +63,7 @@ public: ...@@ -62,6 +63,7 @@ public:
virtual bool finalize_table(const TableS &); virtual bool finalize_table(const TableS &);
void connectToMysql(); void connectToMysql();
Ndb * m_ndb; Ndb * m_ndb;
Ndb_cluster_connection * m_cluster_connection;
bool m_restore; bool m_restore;
bool m_restore_meta; bool m_restore_meta;
Uint32 m_logCount; Uint32 m_logCount;
......
...@@ -240,6 +240,8 @@ free_data_callback() ...@@ -240,6 +240,8 @@ free_data_callback()
g_consumers[i]->tuple_free(); g_consumers[i]->tuple_free();
} }
const char * g_connect_string = 0;
int int
main(int argc, char** argv) main(int argc, char** argv)
{ {
...@@ -250,7 +252,7 @@ main(int argc, char** argv) ...@@ -250,7 +252,7 @@ main(int argc, char** argv)
return -1; return -1;
} }
Ndb::setConnectString(opt_connect_str); g_connect_string = opt_connect_str;
/** /**
* we must always load meta data, even if we will only print it to stdout * we must always load meta data, even if we will only print it to stdout
......
...@@ -124,9 +124,12 @@ int main(int argc, char** argv){ ...@@ -124,9 +124,12 @@ int main(int argc, char** argv){
return NDBT_ProgramExit(NDBT_WRONGARGS); return NDBT_ProgramExit(NDBT_WRONGARGS);
} }
Ndb::setConnectString(opt_connect_str); Ndb_cluster_connection con(opt_connect_str);
// Connect to Ndb if(con.connect(12, 5, 1) != 0)
Ndb MyNdb(_dbname); {
return NDBT_ProgramExit(NDBT_FAILED);
}
Ndb MyNdb(&con, _dbname );
if(MyNdb.init() != 0){ if(MyNdb.init() != 0){
ERR(MyNdb.getNdbError()); ERR(MyNdb.getNdbError());
......
...@@ -97,9 +97,12 @@ int main(int argc, char** argv){ ...@@ -97,9 +97,12 @@ int main(int argc, char** argv){
return NDBT_ProgramExit(NDBT_WRONGARGS); return NDBT_ProgramExit(NDBT_WRONGARGS);
} }
Ndb::setConnectString(opt_connect_str); Ndb_cluster_connection con(opt_connect_str);
// Connect to Ndb if(con.connect(12, 5, 1) != 0)
Ndb MyNdb(_dbname); {
return NDBT_ProgramExit(NDBT_FAILED);
}
Ndb MyNdb(&con, _dbname );
if(MyNdb.init() != 0){ if(MyNdb.init() != 0){
ERR(MyNdb.getNdbError()); ERR(MyNdb.getNdbError());
......
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