MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
testMgmDisconnect.c
1 /*
2  Copyright 2008 Sun Microsystems, Inc.
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #include <stdlib.h>
20 #include <unistd.h>
21 
22 #include <mgmapi.h>
23 
24 int main()
25 {
27 
28  while(1==1){
29  if (ndb_mgm_connect(handle,0,0,0) == -1){
30  printf("connect failed, error: '%d: %s'\n",
33  sleep(1);
34  continue;
35  }
36 
37  while(ndb_mgm_is_connected(handle) != 0){
38  struct ndb_mgm_cluster_state *state= ndb_mgm_get_status(handle);
39 
40  if(state==NULL){
41  printf("ndb_mgm_get_status failed, error: '%d: %s', line: %d\n",
45  continue;
46  }
47 
48  int i= 0;
49  for(i=0; i < state->no_of_nodes; i++)
50  {
51  struct ndb_mgm_node_state *node_state= &state->node_states[i];
52  printf("node with ID=%d ", node_state->node_id);
53 
54  if(node_state->version != 0)
55  printf("connected\n");
56  else
57  printf("not connected\n");
58  }
59  free((void*)state);
60  }
61  }
62 
63  ndb_mgm_destroy_handle(&handle);
64  return 1;
65 }