Skip to content

Commit ee331ba

Browse files
committed
wl#9819 patch #11: New method set_application_address() on Ndb_cluster_connection
1 parent 975f29e commit ee331ba

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

storage/ndb/include/ndbapi/ndb_cluster_connection.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,27 @@ class Ndb_cluster_connection {
9696

9797
/**
9898
* Set a name on the connection, which will be reported in cluster log
99+
* and in ndbinfo.processes.
100+
* For the name to be visible, this must be called prior to connect().
99101
*
100102
* @param name
101103
*
102104
*/
103105
void set_name(const char *name);
104106

107+
/**
108+
* Set an application host network address and port number on the connection,
109+
* which will be reported in ndbinfo.processes.
110+
* This must be called prior to connect() for the information to be visible.
111+
* If address_string is null, the network address used by the NDBAPI
112+
* connection will be reported.
113+
*
114+
* @param address_string
115+
* @param port
116+
*
117+
*/
118+
void set_application_address(const char * address_string, int port);
119+
105120
/**
106121
* Set timeout
107122
*

storage/ndb/src/ndbapi/ndb_cluster_connection.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,9 @@ Ndb_cluster_connection_impl(const char * connect_string,
437437
m_latest_error_msg(),
438438
m_latest_error(0),
439439
m_data_node_neighbour(0),
440-
m_multi_wait_group(0)
440+
m_multi_wait_group(0),
441+
m_application_addr(0),
442+
m_application_port(0)
441443
{
442444
DBUG_ENTER("Ndb_cluster_connection");
443445
DBUG_PRINT("enter",("Ndb_cluster_connection this=0x%lx", (long) this));
@@ -901,6 +903,13 @@ Ndb_cluster_connection_impl::set_name(const char *name)
901903
ndb_mgm_set_name(h, name);
902904
}
903905

906+
void
907+
Ndb_cluster_connection_impl::set_application_address(const char * addr, int port)
908+
{
909+
m_application_addr = addr;
910+
m_application_port = port;
911+
}
912+
904913
int
905914
Ndb_cluster_connection_impl::init_nodes_vector(Uint32 nodeid,
906915
const ndb_mgm_configuration
@@ -1210,6 +1219,11 @@ void Ndb_cluster_connection::set_name(const char *name)
12101219
m_impl.set_name(name);
12111220
}
12121221

1222+
void Ndb_cluster_connection::set_application_address(const char * addr, int port)
1223+
{
1224+
m_impl.set_application_address(addr, port);
1225+
}
1226+
12131227
int Ndb_cluster_connection_impl::connect(int no_retries,
12141228
int retry_delay_in_seconds,
12151229
int verbose)
@@ -1275,7 +1289,11 @@ int Ndb_cluster_connection_impl::connect(int no_retries,
12751289
ndb_mgm_destroy_configuration(props);
12761290
DBUG_RETURN(-1);
12771291
}
1278-
1292+
NdbMgmHandle mgm_handle = m_config_retriever->get_mgmHandle();
1293+
const char * name = ndb_mgm_get_name(mgm_handle);
1294+
m_transporter_facade->theClusterMgr->setProcessInfo(name,
1295+
m_application_addr,
1296+
m_application_port);
12791297
ndb_mgm_destroy_configuration(props);
12801298
m_transporter_facade->connected();
12811299
m_latest_error = 0;

storage/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ class Ndb_cluster_connection_impl : public Ndb_cluster_connection
117117
int configure(Uint32 nodeid, const ndb_mgm_configuration &config);
118118
void connect_thread();
119119
void set_name(const char *name);
120+
void set_application_address(const char *, int);
120121
void set_data_node_neighbour(Uint32 neighbour_node);
121122
void adjust_node_proximity(Uint32 node_id, Int32 adjustment);
122123
Uint32 get_db_nodes(Uint8 nodesarray[MAX_NDB_NODES]) const;
@@ -168,6 +169,10 @@ class Ndb_cluster_connection_impl : public Ndb_cluster_connection
168169
Uint64 globalApiStatsBaseline[ Ndb::NumClientStatistics ];
169170

170171
NdbWaitGroup *m_multi_wait_group;
172+
173+
// Data for ndbinfo.processes
174+
const char * m_application_addr;
175+
int m_application_port;
171176
};
172177

173178
#endif

0 commit comments

Comments
 (0)