Commit 89c8365f authored by tomas@poseidon.(none)'s avatar tomas@poseidon.(none)

removed different CFG_ defined for connection host names

added support for setting up multiple interfaces
correct connect address for mgmt server
bug, -l flag would be interpreted as connectstring
added flag to remove all node id checks
changed automatic allocation of ports somewhat
parent 9df91321
...@@ -104,9 +104,9 @@ ...@@ -104,9 +104,9 @@
#define CFG_CONNECTION_NODE_1_SYSTEM 404 #define CFG_CONNECTION_NODE_1_SYSTEM 404
#define CFG_CONNECTION_NODE_2_SYSTEM 405 #define CFG_CONNECTION_NODE_2_SYSTEM 405
#define CFG_CONNECTION_SERVER_PORT 406 #define CFG_CONNECTION_SERVER_PORT 406
#define CFG_CONNECTION_HOSTNAME_1 407
#define CFG_CONNECTION_HOSTNAME_2 408
#define CFG_TCP_HOSTNAME_1 450
#define CFG_TCP_HOSTNAME_2 451
#define CFG_TCP_SERVER 452 #define CFG_TCP_SERVER 452
#define CFG_TCP_SEND_BUFFER_SIZE 454 #define CFG_TCP_SEND_BUFFER_SIZE 454
#define CFG_TCP_RECEIVE_BUFFER_SIZE 455 #define CFG_TCP_RECEIVE_BUFFER_SIZE 455
...@@ -128,8 +128,6 @@ ...@@ -128,8 +128,6 @@
#define CFG_SCI_NODE2_ADAPTER0 555 #define CFG_SCI_NODE2_ADAPTER0 555
#define CFG_SCI_NODE2_ADAPTER1 556 #define CFG_SCI_NODE2_ADAPTER1 556
#define CFG_OSE_HOSTNAME_1 600
#define CFG_OSE_HOSTNAME_2 601
#define CFG_OSE_PRIO_A_SIZE 602 #define CFG_OSE_PRIO_A_SIZE 602
#define CFG_OSE_PRIO_B_SIZE 603 #define CFG_OSE_PRIO_B_SIZE 603
#define CFG_OSE_RECEIVE_ARRAY_SIZE 604 #define CFG_OSE_RECEIVE_ARRAY_SIZE 604
......
...@@ -218,15 +218,18 @@ public: ...@@ -218,15 +218,18 @@ public:
void printState(); void printState();
#endif #endif
unsigned short m_service_port; class Transporter_interface {
public:
unsigned short m_service_port;
const char *m_interface;
};
Vector<Transporter_interface> m_transporter_interface;
void add_transporter_interface(const char *interface, unsigned short port);
protected: protected:
private: private:
void * callbackObj; void * callbackObj;
TransporterService *m_transporter_service;
char *m_interface_name;
struct NdbThread *m_start_clients_thread; struct NdbThread *m_start_clients_thread;
bool m_run_start_clients_thread; bool m_run_start_clients_thread;
......
...@@ -344,7 +344,7 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf, Uint32 ...@@ -344,7 +344,7 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf, Uint32
const char * name; const char * name;
struct in_addr addr; struct in_addr addr;
BaseString tmp; BaseString tmp;
if(!iter.get(CFG_TCP_HOSTNAME_1, &name) && strlen(name)){ if(!iter.get(CFG_CONNECTION_HOSTNAME_1, &name) && strlen(name)){
if(Ndb_getInAddr(&addr, name) != 0){ if(Ndb_getInAddr(&addr, name) != 0){
tmp.assfmt("Unable to lookup/illegal hostname %s, " tmp.assfmt("Unable to lookup/illegal hostname %s, "
"connection from node %d to node %d", "connection from node %d to node %d",
...@@ -354,7 +354,7 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf, Uint32 ...@@ -354,7 +354,7 @@ ConfigRetriever::verifyConfig(const struct ndb_mgm_configuration * conf, Uint32
} }
} }
if(!iter.get(CFG_TCP_HOSTNAME_2, &name) && strlen(name)){ if(!iter.get(CFG_CONNECTION_HOSTNAME_2, &name) && strlen(name)){
if(Ndb_getInAddr(&addr, name) != 0){ if(Ndb_getInAddr(&addr, name) != 0){
tmp.assfmt("Unable to lookup/illegal hostname %s, " tmp.assfmt("Unable to lookup/illegal hostname %s, "
"connection from node %d to node %d", "connection from node %d to node %d",
......
...@@ -345,18 +345,27 @@ IPCConfig::configureTransporters(Uint32 nodeId, ...@@ -345,18 +345,27 @@ IPCConfig::configureTransporters(Uint32 nodeId,
const class ndb_mgm_configuration & config, const class ndb_mgm_configuration & config,
class TransporterRegistry & tr){ class TransporterRegistry & tr){
Uint32 noOfTransportersCreated= 0, server_port= 0; Uint32 noOfTransportersCreated= 0;
ndb_mgm_configuration_iterator iter(config, CFG_SECTION_CONNECTION); ndb_mgm_configuration_iterator iter(config, CFG_SECTION_CONNECTION);
for(iter.first(); iter.valid(); iter.next()){ for(iter.first(); iter.valid(); iter.next()){
Uint32 nodeId1, nodeId2, remoteNodeId; Uint32 nodeId1, nodeId2, remoteNodeId;
const char * remoteHostName= 0, * localHostName= 0;
if(iter.get(CFG_CONNECTION_NODE_1, &nodeId1)) continue; if(iter.get(CFG_CONNECTION_NODE_1, &nodeId1)) continue;
if(iter.get(CFG_CONNECTION_NODE_2, &nodeId2)) continue; if(iter.get(CFG_CONNECTION_NODE_2, &nodeId2)) continue;
if(nodeId1 != nodeId && nodeId2 != nodeId) continue; if(nodeId1 != nodeId && nodeId2 != nodeId) continue;
remoteNodeId = (nodeId == nodeId1 ? nodeId2 : nodeId1); remoteNodeId = (nodeId == nodeId1 ? nodeId2 : nodeId1);
{
const char * host1= 0, * host2= 0;
iter.get(CFG_CONNECTION_HOSTNAME_1, &host1);
iter.get(CFG_CONNECTION_HOSTNAME_2, &host2);
localHostName = (nodeId == nodeId1 ? host1 : host2);
remoteHostName = (nodeId == nodeId1 ? host2 : host1);
}
Uint32 sendSignalId = 1; Uint32 sendSignalId = 1;
Uint32 checksum = 1; Uint32 checksum = 1;
if(iter.get(CFG_CONNECTION_SEND_SIGNAL_ID, &sendSignalId)) continue; if(iter.get(CFG_CONNECTION_SEND_SIGNAL_ID, &sendSignalId)) continue;
...@@ -365,14 +374,10 @@ IPCConfig::configureTransporters(Uint32 nodeId, ...@@ -365,14 +374,10 @@ IPCConfig::configureTransporters(Uint32 nodeId,
Uint32 type = ~0; Uint32 type = ~0;
if(iter.get(CFG_TYPE_OF_SECTION, &type)) continue; if(iter.get(CFG_TYPE_OF_SECTION, &type)) continue;
Uint32 tmp_server_port= 0; Uint32 server_port= 0;
if(iter.get(CFG_CONNECTION_SERVER_PORT, &tmp_server_port)) break; if(iter.get(CFG_CONNECTION_SERVER_PORT, &server_port)) break;
if (nodeId <= nodeId1 && nodeId <= nodeId2) { if (nodeId <= nodeId1 && nodeId <= nodeId2) {
if (server_port && server_port != tmp_server_port) { tr.add_transporter_interface(localHostName, server_port);
ndbout << "internal error in config setup of server ports line= " << __LINE__ << endl;
exit(-1);
}
server_port= tmp_server_port;
} }
switch(type){ switch(type){
...@@ -388,7 +393,7 @@ IPCConfig::configureTransporters(Uint32 nodeId, ...@@ -388,7 +393,7 @@ IPCConfig::configureTransporters(Uint32 nodeId,
if(iter.get(CFG_SHM_KEY, &conf.shmKey)) break; if(iter.get(CFG_SHM_KEY, &conf.shmKey)) break;
if(iter.get(CFG_SHM_BUFFER_MEM, &conf.shmSize)) break; if(iter.get(CFG_SHM_BUFFER_MEM, &conf.shmSize)) break;
conf.port= tmp_server_port; conf.port= server_port;
if(!tr.createTransporter(&conf)){ if(!tr.createTransporter(&conf)){
ndbout << "Failed to create SHM Transporter from: " ndbout << "Failed to create SHM Transporter from: "
...@@ -437,14 +442,10 @@ IPCConfig::configureTransporters(Uint32 nodeId, ...@@ -437,14 +442,10 @@ IPCConfig::configureTransporters(Uint32 nodeId,
case CONNECTION_TYPE_TCP:{ case CONNECTION_TYPE_TCP:{
TCP_TransporterConfiguration conf; TCP_TransporterConfiguration conf;
const char * host1, * host2;
if(iter.get(CFG_TCP_HOSTNAME_1, &host1)) break;
if(iter.get(CFG_TCP_HOSTNAME_2, &host2)) break;
if(iter.get(CFG_TCP_SEND_BUFFER_SIZE, &conf.sendBufferSize)) break; if(iter.get(CFG_TCP_SEND_BUFFER_SIZE, &conf.sendBufferSize)) break;
if(iter.get(CFG_TCP_RECEIVE_BUFFER_SIZE, &conf.maxReceiveSize)) break; if(iter.get(CFG_TCP_RECEIVE_BUFFER_SIZE, &conf.maxReceiveSize)) break;
conf.port= tmp_server_port; conf.port= server_port;
const char * proxy; const char * proxy;
if (!iter.get(CFG_TCP_PROXY, &proxy)) { if (!iter.get(CFG_TCP_PROXY, &proxy)) {
if (strlen(proxy) > 0 && nodeId2 == nodeId) { if (strlen(proxy) > 0 && nodeId2 == nodeId) {
...@@ -455,8 +456,8 @@ IPCConfig::configureTransporters(Uint32 nodeId, ...@@ -455,8 +456,8 @@ IPCConfig::configureTransporters(Uint32 nodeId,
conf.localNodeId = nodeId; conf.localNodeId = nodeId;
conf.remoteNodeId = remoteNodeId; conf.remoteNodeId = remoteNodeId;
conf.localHostName = (nodeId == nodeId1 ? host1 : host2); conf.localHostName = localHostName;
conf.remoteHostName = (nodeId == nodeId1 ? host2 : host1); conf.remoteHostName = remoteHostName;
conf.byteOrder = 0; conf.byteOrder = 0;
conf.compression = 0; conf.compression = 0;
conf.checksum = checksum; conf.checksum = checksum;
...@@ -470,19 +471,15 @@ IPCConfig::configureTransporters(Uint32 nodeId, ...@@ -470,19 +471,15 @@ IPCConfig::configureTransporters(Uint32 nodeId,
} }
case CONNECTION_TYPE_OSE:{ case CONNECTION_TYPE_OSE:{
OSE_TransporterConfiguration conf; OSE_TransporterConfiguration conf;
const char * host1, * host2;
if(iter.get(CFG_OSE_HOSTNAME_1, &host1)) break;
if(iter.get(CFG_OSE_HOSTNAME_2, &host2)) break;
if(iter.get(CFG_OSE_PRIO_A_SIZE, &conf.prioASignalSize)) break; if(iter.get(CFG_OSE_PRIO_A_SIZE, &conf.prioASignalSize)) break;
if(iter.get(CFG_OSE_PRIO_B_SIZE, &conf.prioBSignalSize)) break; if(iter.get(CFG_OSE_PRIO_B_SIZE, &conf.prioBSignalSize)) break;
if(iter.get(CFG_OSE_RECEIVE_ARRAY_SIZE, &conf.receiveBufferSize)) break; if(iter.get(CFG_OSE_RECEIVE_ARRAY_SIZE, &conf.receiveBufferSize)) break;
conf.localNodeId = nodeId; conf.localNodeId = nodeId;
conf.remoteNodeId = remoteNodeId; conf.remoteNodeId = remoteNodeId;
conf.localHostName = (nodeId == nodeId1 ? host1 : host2); conf.localHostName = localHostName;
conf.remoteHostName = (nodeId == nodeId1 ? host2 : host1); conf.remoteHostName = remoteHostName;
conf.byteOrder = 0; conf.byteOrder = 0;
conf.compression = 0; conf.compression = 0;
conf.checksum = checksum; conf.checksum = checksum;
...@@ -502,9 +499,6 @@ IPCConfig::configureTransporters(Uint32 nodeId, ...@@ -502,9 +499,6 @@ IPCConfig::configureTransporters(Uint32 nodeId,
} }
} }
} }
tr.m_service_port= server_port;
return noOfTransportersCreated; return noOfTransportersCreated;
} }
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <ndb_global.h>
#include <NdbMutex.h> #include <NdbMutex.h>
#include <NdbTCP.h> #include <NdbTCP.h>
...@@ -27,22 +28,25 @@ static NdbMutex LOCK_gethostbyname = NDB_MUTEX_INITIALIZER; ...@@ -27,22 +28,25 @@ static NdbMutex LOCK_gethostbyname = NDB_MUTEX_INITIALIZER;
extern "C" extern "C"
int int
Ndb_getInAddr(struct in_addr * dst, const char *address) { Ndb_getInAddr(struct in_addr * dst, const char *address) {
DBUG_ENTER("Ndb_getInAddr");
struct hostent * hostPtr; struct hostent * hostPtr;
NdbMutex_Lock(&LOCK_gethostbyname); NdbMutex_Lock(&LOCK_gethostbyname);
hostPtr = gethostbyname(address); hostPtr = gethostbyname(address);
if (hostPtr != NULL) { if (hostPtr != NULL) {
dst->s_addr = ((struct in_addr *) *hostPtr->h_addr_list)->s_addr; dst->s_addr = ((struct in_addr *) *hostPtr->h_addr_list)->s_addr;
NdbMutex_Unlock(&LOCK_gethostbyname); NdbMutex_Unlock(&LOCK_gethostbyname);
return 0; DBUG_RETURN(0);
} }
NdbMutex_Unlock(&LOCK_gethostbyname); NdbMutex_Unlock(&LOCK_gethostbyname);
/* Try it as aaa.bbb.ccc.ddd. */ /* Try it as aaa.bbb.ccc.ddd. */
dst->s_addr = inet_addr(address); dst->s_addr = inet_addr(address);
if (dst->s_addr != INADDR_NONE) { if (dst->s_addr != INADDR_NONE) {
return 0; DBUG_RETURN(0);
} }
return -1; DBUG_PRINT("error",("inet_addr(%s) - %d - %s",
address, errno, strerror(errno)));
DBUG_RETURN(-1);
} }
#if 0 #if 0
......
...@@ -98,9 +98,8 @@ SocketServer::Session * TransporterService::newSession(NDB_SOCKET_TYPE sockfd) ...@@ -98,9 +98,8 @@ SocketServer::Session * TransporterService::newSession(NDB_SOCKET_TYPE sockfd)
TransporterRegistry::TransporterRegistry(void * callback, TransporterRegistry::TransporterRegistry(void * callback,
unsigned _maxTransporters, unsigned _maxTransporters,
unsigned sizeOfLongSignalMemory) { unsigned sizeOfLongSignalMemory)
{
m_transporter_service= 0;
nodeIdSpecified = false; nodeIdSpecified = false;
maxTransporters = _maxTransporters; maxTransporters = _maxTransporters;
sendCounter = 1; sendCounter = 1;
...@@ -150,7 +149,6 @@ TransporterRegistry::~TransporterRegistry() { ...@@ -150,7 +149,6 @@ TransporterRegistry::~TransporterRegistry() {
delete[] theTransporters; delete[] theTransporters;
delete[] performStates; delete[] performStates;
delete[] ioStates; delete[] ioStates;
#ifdef NDB_OSE_TRANSPORTER #ifdef NDB_OSE_TRANSPORTER
if(theOSEReceiver != NULL){ if(theOSEReceiver != NULL){
theOSEReceiver->destroyPhantom(); theOSEReceiver->destroyPhantom();
...@@ -1159,55 +1157,67 @@ TransporterRegistry::stop_clients() ...@@ -1159,55 +1157,67 @@ TransporterRegistry::stop_clients()
return true; return true;
} }
bool void
TransporterRegistry::start_service(SocketServer& socket_server) TransporterRegistry::add_transporter_interface(const char *interface, unsigned short port)
{ {
#if 0 DBUG_ENTER("TransporterRegistry::add_transporter_interface");
for (int i= 0, n= 0; n < nTransporters; i++){ DBUG_PRINT("enter",("interface=%s, port= %d", interface, port));
Transporter * t = theTransporters[i]; if (interface && strlen(interface) == 0)
if (!t) interface= 0;
for (unsigned i= 0; i < m_transporter_interface.size(); i++)
{
Transporter_interface &tmp= m_transporter_interface[i];
if (port != tmp.m_service_port)
continue; continue;
n++; if (interface != 0 && tmp.m_interface != 0 &&
if (t->isServer) { strcmp(interface, tmp.m_interface) == 0)
t->m_service = new TransporterService(new SocketAuthSimple("ndbd passwd")); {
if(!socket_server.setup(t->m_service, t->m_r_port, 0)) DBUG_VOID_RETURN; // found match, no need to insert
{ }
ndbout_c("Unable to setup transporter service port: %d!\n" if (interface == 0 && tmp.m_interface == 0)
"Please check if the port is already used,\n" {
"(perhaps a mgmt server is already running)", DBUG_VOID_RETURN; // found match, no need to insert
m_service_port);
delete t->m_service;
return false;
}
} }
} }
#endif Transporter_interface t;
t.m_service_port= port;
if (m_service_port != 0) { t.m_interface= interface;
m_transporter_interface.push_back(t);
DBUG_PRINT("exit",("interface and port added"));
DBUG_VOID_RETURN;
}
m_transporter_service = new TransporterService(new SocketAuthSimple("ndbd", "ndbd passwd")); bool
TransporterRegistry::start_service(SocketServer& socket_server)
{
if (m_transporter_interface.size() > 0 && nodeIdSpecified != true)
{
ndbout_c("TransporterRegistry::startReceiving: localNodeId not specified");
return false;
}
if (nodeIdSpecified != true) { for (unsigned i= 0; i < m_transporter_interface.size(); i++)
ndbout_c("TransporterRegistry::startReceiving: localNodeId not specified"); {
Transporter_interface &t= m_transporter_interface[i];
if (t.m_service_port == 0)
{
continue;
}
TransporterService *transporter_service =
new TransporterService(new SocketAuthSimple("ndbd", "ndbd passwd"));
if(!socket_server.setup(transporter_service,
t.m_service_port, t.m_interface))
{
ndbout_c("Unable to setup transporter service port: %s:%d!\n"
"Please check if the port is already used,\n"
"(perhaps the node is already running)",
t.m_interface ? t.m_interface : "*", t.m_service_port);
delete transporter_service;
return false; return false;
} }
transporter_service->setTransporterRegistry(this);
//m_interface_name = "ndbd"; }
m_interface_name = 0;
if(!socket_server.setup(m_transporter_service, m_service_port, m_interface_name))
{
ndbout_c("Unable to setup transporter service port: %d!\n"
"Please check if the port is already used,\n"
"(perhaps a mgmt server is already running)",
m_service_port);
delete m_transporter_service;
return false;
}
m_transporter_service->setTransporterRegistry(this);
} else
m_transporter_service= 0;
return true; return true;
} }
...@@ -1281,3 +1291,5 @@ NdbOut & operator <<(NdbOut & out, SignalHeader & sh){ ...@@ -1281,3 +1291,5 @@ NdbOut & operator <<(NdbOut & out, SignalHeader & sh){
out << "trace: " << (int)sh.theTrace << endl; out << "trace: " << (int)sh.theTrace << endl;
return out; return out;
} }
template class Vector<TransporterRegistry::Transporter_interface>;
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <ndb_global.h> #include <ndb_global.h>
#include <my_pthread.h>
#include <SocketServer.hpp> #include <SocketServer.hpp>
...@@ -83,7 +84,8 @@ bool ...@@ -83,7 +84,8 @@ bool
SocketServer::setup(SocketServer::Service * service, SocketServer::setup(SocketServer::Service * service,
unsigned short port, unsigned short port,
const char * intface){ const char * intface){
DBUG_ENTER("SocketServer::setup");
DBUG_PRINT("enter",("interface=%s, port=%d", intface, port));
struct sockaddr_in servaddr; struct sockaddr_in servaddr;
memset(&servaddr, 0, sizeof(servaddr)); memset(&servaddr, 0, sizeof(servaddr));
servaddr.sin_family = AF_INET; servaddr.sin_family = AF_INET;
...@@ -92,36 +94,44 @@ SocketServer::setup(SocketServer::Service * service, ...@@ -92,36 +94,44 @@ SocketServer::setup(SocketServer::Service * service,
if(intface != 0){ if(intface != 0){
if(Ndb_getInAddr(&servaddr.sin_addr, intface)) if(Ndb_getInAddr(&servaddr.sin_addr, intface))
return false; DBUG_RETURN(false);
} }
const NDB_SOCKET_TYPE sock = socket(AF_INET, SOCK_STREAM, 0); const NDB_SOCKET_TYPE sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock == NDB_INVALID_SOCKET) { if (sock == NDB_INVALID_SOCKET) {
return false; DBUG_PRINT("error",("socket() - %d - %s",
errno, strerror(errno)));
DBUG_RETURN(false);
} }
const int on = 1; const int on = 1;
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
(const char*)&on, sizeof(on)) == -1) { (const char*)&on, sizeof(on)) == -1) {
DBUG_PRINT("error",("getsockopt() - %d - %s",
errno, strerror(errno)));
NDB_CLOSE_SOCKET(sock); NDB_CLOSE_SOCKET(sock);
return false; DBUG_RETURN(false);
} }
if (bind(sock, (struct sockaddr*) &servaddr, sizeof(servaddr)) == -1) { if (bind(sock, (struct sockaddr*) &servaddr, sizeof(servaddr)) == -1) {
DBUG_PRINT("error",("bind() - %d - %s",
errno, strerror(errno)));
NDB_CLOSE_SOCKET(sock); NDB_CLOSE_SOCKET(sock);
return false; DBUG_RETURN(false);
} }
if (listen(sock, m_maxSessions) == -1){ if (listen(sock, m_maxSessions) == -1){
DBUG_PRINT("error",("listen() - %d - %s",
errno, strerror(errno)));
NDB_CLOSE_SOCKET(sock); NDB_CLOSE_SOCKET(sock);
return false; DBUG_RETURN(false);
} }
ServiceInstance i; ServiceInstance i;
i.m_socket = sock; i.m_socket = sock;
i.m_service = service; i.m_service = service;
m_services.push_back(i); m_services.push_back(i);
return true; DBUG_RETURN(true);
} }
void void
...@@ -177,8 +187,9 @@ void* ...@@ -177,8 +187,9 @@ void*
socketServerThread_C(void* _ss){ socketServerThread_C(void* _ss){
SocketServer * ss = (SocketServer *)_ss; SocketServer * ss = (SocketServer *)_ss;
my_thread_init();
ss->doRun(); ss->doRun();
my_thread_end();
NdbThread_Exit(0); NdbThread_Exit(0);
return 0; return 0;
} }
...@@ -287,8 +298,10 @@ void* ...@@ -287,8 +298,10 @@ void*
sessionThread_C(void* _sc){ sessionThread_C(void* _sc){
SocketServer::Session * si = (SocketServer::Session *)_sc; SocketServer::Session * si = (SocketServer::Session *)_sc;
my_thread_init();
if(!transfer(si->m_socket)){ if(!transfer(si->m_socket)){
si->m_stopped = true; si->m_stopped = true;
my_thread_end();
NdbThread_Exit(0); NdbThread_Exit(0);
return 0; return 0;
} }
...@@ -301,6 +314,7 @@ sessionThread_C(void* _sc){ ...@@ -301,6 +314,7 @@ sessionThread_C(void* _sc){
} }
si->m_stopped = true; si->m_stopped = true;
my_thread_end();
NdbThread_Exit(0); NdbThread_Exit(0);
return 0; return 0;
} }
......
...@@ -673,8 +673,10 @@ CommandInterpreter::executeShutdown(char* parameters) ...@@ -673,8 +673,10 @@ CommandInterpreter::executeShutdown(char* parameters)
if (mgm_id == 0) if (mgm_id == 0)
mgm_id= state->node_states[i].node_id; mgm_id= state->node_states[i].node_id;
else { else {
ndbout << "Unable to locate management server, shutdown manually with #STOP" ndbout << "Unable to locate management server, "
<< "shutdown manually with <id> STOP"
<< endl; << endl;
return;
} }
} }
} }
...@@ -721,11 +723,13 @@ const char *status_string(ndb_mgm_node_status status) ...@@ -721,11 +723,13 @@ const char *status_string(ndb_mgm_node_status status)
static void static void
print_nodes(ndb_mgm_cluster_state *state, ndb_mgm_configuration_iterator *it, print_nodes(ndb_mgm_cluster_state *state, ndb_mgm_configuration_iterator *it,
const char *proc_name, int no_proc, ndb_mgm_node_type type, int master_id) const char *proc_name, int no_proc, ndb_mgm_node_type type,
int master_id)
{ {
int i; int i;
ndbout << "[" << proc_name ndbout << "[" << proc_name
<< "(" << ndb_mgm_get_node_type_string(type) << ")]\t" << no_proc << " node(s)" << endl; << "(" << ndb_mgm_get_node_type_string(type) << ")]\t"
<< no_proc << " node(s)" << endl;
for(i=0; i < state->no_of_nodes; i++) { for(i=0; i < state->no_of_nodes; i++) {
struct ndb_mgm_node_state *node_state= &(state->node_states[i]); struct ndb_mgm_node_state *node_state= &(state->node_states[i]);
if(node_state->node_type == type) { if(node_state->node_type == type) {
...@@ -733,7 +737,9 @@ print_nodes(ndb_mgm_cluster_state *state, ndb_mgm_configuration_iterator *it, ...@@ -733,7 +737,9 @@ print_nodes(ndb_mgm_cluster_state *state, ndb_mgm_configuration_iterator *it,
ndbout << "id=" << node_id; ndbout << "id=" << node_id;
if(node_state->version != 0) { if(node_state->version != 0) {
const char *hostname= node_state->connect_address; const char *hostname= node_state->connect_address;
if (hostname == 0 || strlen(hostname) == 0 || strcmp(hostname,"0.0.0.0") == 0) if (hostname == 0
|| strlen(hostname) == 0
|| strcmp(hostname,"0.0.0.0") == 0)
ndbout << " "; ndbout << " ";
else else
ndbout << "\t@" << hostname; ndbout << "\t@" << hostname;
...@@ -761,7 +767,8 @@ print_nodes(ndb_mgm_cluster_state *state, ndb_mgm_configuration_iterator *it, ...@@ -761,7 +767,8 @@ print_nodes(ndb_mgm_cluster_state *state, ndb_mgm_configuration_iterator *it,
ndb_mgm_get_string_parameter(it, CFG_NODE_HOST, &config_hostname); ndb_mgm_get_string_parameter(it, CFG_NODE_HOST, &config_hostname);
if (config_hostname == 0 || config_hostname[0] == 0) if (config_hostname == 0 || config_hostname[0] == 0)
config_hostname= "any host"; config_hostname= "any host";
ndbout << " (not connected, accepting connect from " << config_hostname << ")" << endl; ndbout << " (not connected, accepting connect from "
<< config_hostname << ")" << endl;
} }
} }
} }
......
...@@ -1529,7 +1529,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ...@@ -1529,7 +1529,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
}, },
{ {
CFG_TCP_HOSTNAME_1, CFG_CONNECTION_HOSTNAME_1,
"HostName1", "HostName1",
"TCP", "TCP",
"Name/IP of computer on one side of the connection", "Name/IP of computer on one side of the connection",
...@@ -1540,7 +1540,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ...@@ -1540,7 +1540,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
0, 0 }, 0, 0 },
{ {
CFG_TCP_HOSTNAME_2, CFG_CONNECTION_HOSTNAME_2,
"HostName2", "HostName2",
"TCP", "TCP",
"Name/IP of computer on one side of the connection", "Name/IP of computer on one side of the connection",
...@@ -1935,7 +1935,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ...@@ -1935,7 +1935,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
}, },
{ {
CFG_OSE_HOSTNAME_1, CFG_CONNECTION_HOSTNAME_1,
"HostName1", "HostName1",
"OSE", "OSE",
"Name of computer on one side of the connection", "Name of computer on one side of the connection",
...@@ -1946,7 +1946,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ...@@ -1946,7 +1946,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = {
0, 0 }, 0, 0 },
{ {
CFG_OSE_HOSTNAME_2, CFG_CONNECTION_HOSTNAME_2,
"HostName2", "HostName2",
"OSE", "OSE",
"Name of computer on one side of the connection", "Name of computer on one side of the connection",
...@@ -2902,26 +2902,38 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){ ...@@ -2902,26 +2902,38 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){
DBUG_ENTER("fixPortNumber"); DBUG_ENTER("fixPortNumber");
Uint32 id1= 0, id2= 0; Uint32 id1= 0, id2= 0;
const char *hostName1;
const char *hostName2;
require(ctx.m_currentSection->get("NodeId1", &id1)); require(ctx.m_currentSection->get("NodeId1", &id1));
require(ctx.m_currentSection->get("NodeId2", &id2)); require(ctx.m_currentSection->get("NodeId2", &id2));
require(ctx.m_currentSection->get("HostName1", &hostName1));
require(ctx.m_currentSection->get("HostName2", &hostName2));
DBUG_PRINT("info",("NodeId1=%d HostName1=\"%s\"",id1,hostName1));
DBUG_PRINT("info",("NodeId2=%d HostName2=\"%s\"",id2,hostName2));
if (id1 > id2) { if (id1 > id2) {
Uint32 tmp= id1; Uint32 tmp= id1;
const char *tmp_name= hostName1;
hostName1= hostName2;
id1= id2; id1= id2;
hostName2= tmp_name;
id2= tmp; id2= tmp;
} }
const Properties * node; const Properties * node;
require(ctx.m_config->get("Node", id1, &node)); require(ctx.m_config->get("Node", id1, &node));
BaseString hostname; BaseString hostname(hostName1);
require(node->get("HostName", hostname)); // require(node->get("HostName", hostname));
if (hostname.c_str()[0] == 0) { if (hostname.c_str()[0] == 0) {
ctx.reportError("Hostname required on nodeid %d since it will act as server.", id1); ctx.reportError("Hostname required on nodeid %d since it will "
"act as server.", id1);
DBUG_RETURN(false); DBUG_RETURN(false);
} }
Uint32 port= 0; Uint32 port= 0;
if (!node->get("ServerPort", &port) && !ctx.m_userProperties.get("ServerPort_", id1, &port)) { if (!node->get("ServerPort", &port) &&
!ctx.m_userProperties.get("ServerPort_", id1, &port)) {
Uint32 adder= 0; Uint32 adder= 0;
{ {
BaseString server_port_adder(hostname); BaseString server_port_adder(hostname);
...@@ -2932,7 +2944,8 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){ ...@@ -2932,7 +2944,8 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){
Uint32 base= 0; Uint32 base= 0;
if (!ctx.m_userProperties.get("ServerPortBase", &base)){ if (!ctx.m_userProperties.get("ServerPortBase", &base)){
if(!(ctx.m_userDefaults && ctx.m_userDefaults->get("PortNumber", &base)) && if(!(ctx.m_userDefaults &&
ctx.m_userDefaults->get("PortNumber", &base)) &&
!ctx.m_systemDefaults->get("PortNumber", &base)) { !ctx.m_systemDefaults->get("PortNumber", &base)) {
base= strtoll(NDB_BASE_PORT,0,0)+2; base= strtoll(NDB_BASE_PORT,0,0)+2;
// ctx.reportError("Cannot retrieve base port number"); // ctx.reportError("Cannot retrieve base port number");
...@@ -2945,12 +2958,15 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){ ...@@ -2945,12 +2958,15 @@ fixPortNumber(InitConfigFileParser::Context & ctx, const char * data){
} }
if(ctx.m_currentSection->contains("PortNumber")) { if(ctx.m_currentSection->contains("PortNumber")) {
ndbout << "PortNumber should no longer be specificied per connection, please remove from config. Will be changed to " << port << endl; ndbout << "PortNumber should no longer be specificied "
<< "per connection, please remove from config. "
<< "Will be changed to " << port << endl;
ctx.m_currentSection->put("PortNumber", port, true); ctx.m_currentSection->put("PortNumber", port, true);
} else } else
ctx.m_currentSection->put("PortNumber", port); ctx.m_currentSection->put("PortNumber", port);
DBUG_PRINT("info", ("connection %d-%d port %d host %s", id1, id2, port, hostname.c_str())); DBUG_PRINT("info", ("connection %d-%d port %d host %s",
id1, id2, port, hostname.c_str()));
DBUG_RETURN(true); DBUG_RETURN(true);
} }
......
This diff is collapsed.
...@@ -418,7 +418,8 @@ MgmApiSession::get_nodeid(Parser_t::Context &, ...@@ -418,7 +418,8 @@ MgmApiSession::get_nodeid(Parser_t::Context &,
&addr, &addrlen, error_string)){ &addr, &addrlen, error_string)){
const char *alias; const char *alias;
const char *str; const char *str;
alias= ndb_mgm_get_node_type_alias_string((enum ndb_mgm_node_type)nodetype, &str); alias= ndb_mgm_get_node_type_alias_string((enum ndb_mgm_node_type)
nodetype, &str);
m_output->println(cmd); m_output->println(cmd);
m_output->println("result: %s", error_string.c_str()); m_output->println("result: %s", error_string.c_str());
m_output->println(""); m_output->println("");
......
...@@ -82,6 +82,7 @@ struct MgmGlobals { ...@@ -82,6 +82,7 @@ struct MgmGlobals {
SocketServer * socketServer; SocketServer * socketServer;
}; };
int g_no_nodeid_checks= 0;
static MgmGlobals glob; static MgmGlobals glob;
...@@ -118,7 +119,9 @@ struct getargs args[] = { ...@@ -118,7 +119,9 @@ struct getargs args[] = {
"Specify configuration file connect string (will default use Ndb.cfg if available)", "Specify configuration file connect string (will default use Ndb.cfg if available)",
"filename" }, "filename" },
{ "interactive", 0, arg_flag, &glob.interactive, { "interactive", 0, arg_flag, &glob.interactive,
"Run interactive. Not supported but provided for testing purposes", "" }, "Run interactive. Not supported but provided for testing purposes", "" },
{ "no-nodeid-checks", 0, arg_flag, &g_no_nodeid_checks,
"Do not provide any node id checks", "" },
{ "nodaemon", 0, arg_flag, &glob.non_interactive, { "nodaemon", 0, arg_flag, &glob.non_interactive,
"Don't run as daemon, but don't read from stdin", "non-interactive" } "Don't run as daemon, but don't read from stdin", "non-interactive" }
}; };
...@@ -336,17 +339,12 @@ MgmGlobals::~MgmGlobals(){ ...@@ -336,17 +339,12 @@ MgmGlobals::~MgmGlobals(){
* @fn readLocalConfig * @fn readLocalConfig
* @param glob : Global variables * @param glob : Global variables
* @return true if success, false otherwise. * @return true if success, false otherwise.
*
* How to get LOCAL CONFIGURATION FILE:
* 1. Use local config file name (-l)
* 2. Use environment NDB_HOME + Ndb.cfg
* If NDB_HOME is not set this results in reading from local dir
*/ */
static bool static bool
readLocalConfig(){ readLocalConfig(){
// Read local config file // Read local config file
LocalConfig lc; LocalConfig lc;
if(!lc.init(glob.local_config_filename)){ if(!lc.init(0,glob.local_config_filename)){
lc.printError(); lc.printError();
return false; return false;
} }
...@@ -360,10 +358,6 @@ readLocalConfig(){ ...@@ -360,10 +358,6 @@ readLocalConfig(){
* @fn readGlobalConfig * @fn readGlobalConfig
* @param glob : Global variables * @param glob : Global variables
* @return true if success, false otherwise. * @return true if success, false otherwise.
*
* How to get the GLOBAL CONFIGURATION:
* 1. Use config file name (this is a text file)(-c)
* 2. Use name from line 2 of local config file, ex: file:///c/ndb/Ndb_cfg.bin
*/ */
static bool static bool
readGlobalConfig() { readGlobalConfig() {
......
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