18 #include <ndb_global.h>
19 #include <IPCConfig.hpp>
21 #include <TransporterRegistry.hpp>
24 #include <mgmapi_configuration.hpp>
28 static bool is_mgmd(Uint32 nodeId,
32 if (iter.find(CFG_NODE_ID, nodeId))
35 if(iter.get(CFG_TYPE_OF_SECTION, &type))
38 return (type == NODE_TYPE_MGM);
46 bool transporter_to_self)
50 DBUG_ENTER(
"IPCConfig::configureTransporters");
53 if (!is_mgmd(nodeId, config))
61 const char *separator=
"";
64 for(iter.first(); iter.valid(); iter.next())
67 if(iter.get(CFG_TYPE_OF_SECTION, &type))
continue;
68 if(type != NODE_TYPE_MGM)
continue;
71 if(iter.get(CFG_NODE_HOST, &hostname))
continue;
72 if( strlen(hostname) == 0 )
continue;
73 if(iter.get(CFG_MGM_PORT, &port))
continue;
74 connect_string.
appfmt(
"%s%s:%u",separator,hostname,port);
78 if ( h && connect_string.
length() > 0 )
87 for (
int i= 1;
i < MAX_NODES;
i++)
90 if (tr.get_transporter(
i) && iter.find(CFG_NODE_ID,
i))
94 ndbout_c(
"The connection to node %d could not "
95 "be removed at this time",
i);
103 for(iter.first(); iter.valid(); iter.next()){
105 bzero(&conf,
sizeof(conf));
106 Uint32 nodeId1, nodeId2, remoteNodeId;
107 const char * remoteHostName= 0, * localHostName= 0;
108 if(iter.get(CFG_CONNECTION_NODE_1, &nodeId1))
continue;
109 if(iter.get(CFG_CONNECTION_NODE_2, &nodeId2))
continue;
111 if(nodeId1 != nodeId && nodeId2 != nodeId)
continue;
112 remoteNodeId = (nodeId == nodeId1 ? nodeId2 : nodeId1);
114 if (nodeId1 == nodeId && nodeId2 == nodeId)
116 transporter_to_self =
false;
120 const char * host1= 0, * host2= 0;
121 iter.get(CFG_CONNECTION_HOSTNAME_1, &host1);
122 iter.get(CFG_CONNECTION_HOSTNAME_2, &host2);
123 localHostName = (nodeId == nodeId1 ? host1 : host2);
124 remoteHostName = (nodeId == nodeId1 ? host2 : host1);
127 Uint32 sendSignalId = 1;
129 if(iter.get(CFG_CONNECTION_SEND_SIGNAL_ID, &sendSignalId))
continue;
130 if(iter.get(CFG_CONNECTION_CHECKSUM, &checksum))
continue;
133 if(iter.get(CFG_TYPE_OF_SECTION, &type))
continue;
135 Uint32 server_port= 0;
136 if(iter.get(CFG_CONNECTION_SERVER_PORT, &server_port))
break;
138 Uint32 nodeIdServer= 0;
139 if(iter.get(CFG_CONNECTION_NODE_ID_SERVER, &nodeIdServer))
break;
141 if(is_mgmd(nodeId1, config) || is_mgmd(nodeId2, config))
144 conf.isMgmConnection=
true;
147 conf.isMgmConnection=
false;
149 Uint32 bindInAddrAny = 0;
150 iter.get(CFG_TCP_BIND_INADDR_ANY, &bindInAddrAny);
152 if (nodeId == nodeIdServer && !conf.isMgmConnection) {
153 tr.add_transporter_interface(remoteNodeId,
154 !bindInAddrAny ? localHostName :
"",
158 DBUG_PRINT(
"info", (
"Transporter between this node %d and node %d using port %d, signalId %d, checksum %d",
159 nodeId, remoteNodeId, server_port, sendSignalId, checksum));
171 conf.localNodeId = nodeId;
172 conf.remoteNodeId = remoteNodeId;
173 conf.checksum = checksum;
174 conf.signalId = sendSignalId;
175 conf.s_port = server_port;
176 conf.localHostName = localHostName;
177 conf.remoteHostName = remoteHostName;
178 conf.serverNodeId = nodeIdServer;
181 case CONNECTION_TYPE_SHM:
182 if(iter.get(CFG_SHM_KEY, &conf.shm.shmKey))
break;
183 if(iter.get(CFG_SHM_BUFFER_MEM, &conf.shm.shmSize))
break;
186 if(iter.get(CFG_SHM_SIGNUM, &signum))
break;
187 conf.shm.signum= signum;
189 conf.type = tt_SHM_TRANSPORTER;
192 DBUG_PRINT(
"error", (
"Failed to configure SHM Transporter "
194 conf.localNodeId, conf.remoteNodeId));
195 ndbout_c(
"Failed to configure SHM Transporter to node %d",
199 DBUG_PRINT(
"info", (
"Configured SHM Transporter using shmkey %d, "
200 "buf size = %d", conf.shm.shmKey, conf.shm.shmSize));
203 case CONNECTION_TYPE_SCI:
204 if(iter.get(CFG_SCI_SEND_LIMIT, &conf.sci.sendLimit))
break;
205 if(iter.get(CFG_SCI_BUFFER_MEM, &conf.sci.bufferSize))
break;
206 if (nodeId == nodeId1) {
207 if(iter.get(CFG_SCI_HOST2_ID_0, &conf.sci.remoteSciNodeId0))
break;
208 if(iter.get(CFG_SCI_HOST2_ID_1, &conf.sci.remoteSciNodeId1))
break;
210 if(iter.get(CFG_SCI_HOST1_ID_0, &conf.sci.remoteSciNodeId0))
break;
211 if(iter.get(CFG_SCI_HOST1_ID_1, &conf.sci.remoteSciNodeId1))
break;
213 if (conf.sci.remoteSciNodeId1 == 0) {
214 conf.sci.nLocalAdapters = 1;
216 conf.sci.nLocalAdapters = 2;
218 conf.type = tt_SCI_TRANSPORTER;
220 DBUG_PRINT(
"error", (
"Failed to configure SCI Transporter "
222 conf.localNodeId, conf.remoteNodeId));
223 ndbout_c(
"Failed to configure SCI Transporter to node %d",
227 DBUG_PRINT(
"info", (
"Configured SCI Transporter: Adapters = %d, "
228 "remote SCI node id %d",
229 conf.sci.nLocalAdapters, conf.sci.remoteSciNodeId0));
230 DBUG_PRINT(
"info", (
"Host 1 = %s, Host 2 = %s, sendLimit = %d, "
231 "buf size = %d", conf.localHostName,
232 conf.remoteHostName, conf.sci.sendLimit,
233 conf.sci.bufferSize));
234 if (conf.sci.nLocalAdapters > 1) {
235 DBUG_PRINT(
"info", (
"Fault-tolerant with 2 Remote Adapters, "
236 "second remote SCI node id = %d",
237 conf.sci.remoteSciNodeId1));
242 case CONNECTION_TYPE_TCP:
243 if(iter.get(CFG_TCP_SEND_BUFFER_SIZE, &conf.tcp.sendBufferSize))
break;
244 if(iter.get(CFG_TCP_RECEIVE_BUFFER_SIZE, &conf.tcp.maxReceiveSize))
break;
247 if (!iter.get(CFG_TCP_PROXY, &proxy)) {
248 if (strlen(proxy) > 0 && nodeId2 == nodeId) {
250 conf.s_port = atoi(proxy);
254 iter.get(CFG_TCP_SND_BUF_SIZE, &conf.tcp.tcpSndBufSize);
255 iter.get(CFG_TCP_RCV_BUF_SIZE, &conf.tcp.tcpRcvBufSize);
256 iter.get(CFG_TCP_MAXSEG_SIZE, &conf.tcp.tcpMaxsegSize);
257 iter.get(CFG_CONNECTION_OVERLOAD, &conf.tcp.tcpOverloadLimit);
259 conf.type = tt_TCP_TRANSPORTER;
262 ndbout_c(
"Failed to configure TCP Transporter to node %d",
266 DBUG_PRINT(
"info", (
"Configured TCP Transporter: sendBufferSize = %d, "
267 "maxReceiveSize = %d", conf.tcp.sendBufferSize,
268 conf.tcp.maxReceiveSize));
269 loopback_conf = conf;
272 ndbout <<
"Unknown transporter type from: " << nodeId <<
273 " to: " << remoteNodeId << endl;
278 if (transporter_to_self)
280 loopback_conf.remoteNodeId = nodeId;
281 loopback_conf.localNodeId = nodeId;
282 loopback_conf.serverNodeId = 0;
283 loopback_conf.remoteHostName =
"localhost";
284 loopback_conf.localHostName =
"localhost";
285 loopback_conf.s_port = 1;
288 ndbout_c(
"Failed to configure Loopback Transporter");