List:Commits« Previous MessageNext Message »
From:jon.stephens Date:April 13 2010 10:48pm
Subject:svn commit - mysqldoc@docsrva: r20001 - trunk/ndbapi
View as plain text  
Author: jstephens
Date: 2010-04-14 00:48:41 +0200 (Wed, 14 Apr 2010)
New Revision: 20001

Log:

Followup #1 of 2:

	Started MGM API Examples section
	Moved ndb-examples-event-logging-dual to mgm-examples-event-logging-dual (within new section)
	Updated renamed-nodes.txt file



Modified:
   trunk/ndbapi/mgm-api.xml
   trunk/ndbapi/ndb-examples.xml
   trunk/ndbapi/renamed-nodes.txt


Modified: trunk/ndbapi/mgm-api.xml
===================================================================
--- trunk/ndbapi/mgm-api.xml	2010-04-13 22:35:59 UTC (rev 20000)
+++ trunk/ndbapi/mgm-api.xml	2010-04-13 22:48:41 UTC (rev 20001)
Changed blocks: 1, Lines Added: 270, Lines Deleted: 0; 8219 bytes

@@ -6832,4 +6832,274 @@
 
   </section>
 
+  <section id="mgm-examples">
+
+    <title>MGM API Examples</title>
+
+    <indexterm>
+      <primary>coding examples</primary>
+      <secondary>MGM API</secondary>
+    </indexterm>
+
+    <indexterm>
+      <primary>MGM API</primary>
+      <secondary>coding examples</secondary>
+    </indexterm>
+
+    <para>
+      This section contains MGM API coding examples.
+    </para>
+
+    <section id="mgm-examples-event-logging-dual">
+
+      <title>Event Handling with Multiple Clusters</title>
+
+      <indexterm>
+        <primary>events</primary>
+        <secondary>example</secondary>
+      </indexterm>
+
+      <indexterm>
+        <primary>connecting to multiple clusters</primary>
+        <secondary>example</secondary>
+      </indexterm>
+
+      <indexterm>
+        <primary>multiple clusters, connecting to</primary>
+        <secondary>example</secondary>
+      </indexterm>
+
+      <abstract>
+
+        <para>
+          This example shown in this section illustrates the handling of
+          log events using the MGM API on multiple clusters in a single
+          application.
+        </para>
+
+        <para>
+          The source code for this program may be found in the MySQL
+          Cluster source tree, in the file
+          <filename>storage/ndb/ndbapi-examples/mgmapi_logevent2/mgmapi_logevent2.cpp</filename>.
+        </para>
+
+      </abstract>
+
+<programlisting>
+#include &lt;mysql.h&gt;
+#include &lt;ndbapi/NdbApi.hpp&gt;
+#include &lt;mgmapi.h&gt;
+#include &lt;stdio.h&gt;
+#include &lt;stdlib.h&gt;
+
+/*
+ * export LD_LIBRARY_PATH=../../../libmysql_r/.libs:../../../ndb/src/.libs
+ */
+
+#define MGMERROR(h) \
+{ \
+  fprintf(stderr, "code: %d msg: %s\n", \
+          ndb_mgm_get_latest_error(h), \
+          ndb_mgm_get_latest_error_msg(h)); \
+  exit(-1); \
+}
+
+#define LOGEVENTERROR(h) \
+{ \
+  fprintf(stderr, "code: %d msg: %s\n", \
+          ndb_logevent_get_latest_error(h), \
+          ndb_logevent_get_latest_error_msg(h)); \
+  exit(-1); \
+}
+
+int main(int argc, char** argv)
+{
+  NdbMgmHandle h1,h2;
+  NdbLogEventHandle le1,le2;
+  int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP,
+		   15, NDB_MGM_EVENT_CATEGORY_CONNECTION,
+		   15, NDB_MGM_EVENT_CATEGORY_NODE_RESTART,
+		   15, NDB_MGM_EVENT_CATEGORY_STARTUP,
+		   15, NDB_MGM_EVENT_CATEGORY_ERROR,
+		   0 };
+  struct ndb_logevent event1, event2;
+
+  if (argc &lt; 3)
+  {
+    printf("Arguments are &lt;connect_string cluster 1&gt; &lt;connect_string cluster 2&gt; [&lt;iterations&gt;].\n");
+    exit(-1);
+  }
+  const char *connectstring1 = argv[1];
+  const char *connectstring2 = argv[2];
+  int iterations = -1; 
+  if (argc &gt; 3)
+    iterations = atoi(argv[3]);
+  ndb_init();
+  
+  h1= ndb_mgm_create_handle();
+  h2= ndb_mgm_create_handle();
+  if ( h1 == 0 || h2 == 0 )
+  {
+    printf("Unable to create handle\n");
+    exit(-1);
+  }
+  if (ndb_mgm_set_connectstring(h1, connectstring1) == -1 ||
+      ndb_mgm_set_connectstring(h2, connectstring1))
+  {
+    printf("Unable to set connectstring\n");
+    exit(-1);
+  }
+  if (ndb_mgm_connect(h1,0,0,0)) MGMERROR(h1);
+  if (ndb_mgm_connect(h2,0,0,0)) MGMERROR(h2);
+
+  if ((le1= ndb_mgm_create_logevent_handle(h1, filter)) == 0) MGMERROR(h1);
+  if ((le2= ndb_mgm_create_logevent_handle(h1, filter)) == 0) MGMERROR(h2);
+
+  while (iterations-- != 0)
+  {
+    int timeout= 1000;
+    int r1= ndb_logevent_get_next(le1,&amp;event1,timeout);
+    if (r1 == 0)
+      printf("No event within %d milliseconds\n", timeout);
+    else if (r1 &lt; 0)
+      LOGEVENTERROR(le1)
+    else
+    {
+      switch (event1.type) {
+      case NDB_LE_BackupStarted:
+	printf("Node %d: BackupStarted\n", event1.source_nodeid);
+	printf("  Starting node ID: %d\n", event1.BackupStarted.starting_node);
+	printf("  Backup ID: %d\n", event1.BackupStarted.backup_id);
+	break;
+      case NDB_LE_BackupCompleted:
+	printf("Node %d: BackupCompleted\n", event1.source_nodeid);
+	printf("  Backup ID: %d\n", event1.BackupStarted.backup_id);
+	break;
+      case NDB_LE_BackupAborted:
+	printf("Node %d: BackupAborted\n", event1.source_nodeid);
+	break;
+      case NDB_LE_BackupFailedToStart:
+	printf("Node %d: BackupFailedToStart\n", event1.source_nodeid);
+	break;
+
+      case NDB_LE_NodeFailCompleted:
+	printf("Node %d: NodeFailCompleted\n", event1.source_nodeid);
+	break;
+      case NDB_LE_ArbitResult:
+	printf("Node %d: ArbitResult\n", event1.source_nodeid);
+	printf("  code %d, arbit_node %d\n",
+	       event1.ArbitResult.code &amp; 0xffff,
+	       event1.ArbitResult.arbit_node);
+	break;
+      case NDB_LE_DeadDueToHeartbeat:
+	printf("Node %d: DeadDueToHeartbeat\n", event1.source_nodeid);
+	printf("  node %d\n", event1.DeadDueToHeartbeat.node);
+	break;
+
+      case NDB_LE_Connected:
+	printf("Node %d: Connected\n", event1.source_nodeid);
+	printf("  node %d\n", event1.Connected.node);
+	break;
+      case NDB_LE_Disconnected:
+	printf("Node %d: Disconnected\n", event1.source_nodeid);
+	printf("  node %d\n", event1.Disconnected.node);
+	break;
+      case NDB_LE_NDBStartCompleted:
+	printf("Node %d: StartCompleted\n", event1.source_nodeid);
+	printf("  version %d.%d.%d\n",
+	       event1.NDBStartCompleted.version &gt;&gt; 16 &amp; 0xff,
+	       event1.NDBStartCompleted.version &gt;&gt; 8 &amp; 0xff,
+	       event1.NDBStartCompleted.version &gt;&gt; 0 &amp; 0xff);
+	break;
+      case NDB_LE_ArbitState:
+	printf("Node %d: ArbitState\n", event1.source_nodeid);
+	printf("  code %d, arbit_node %d\n",
+	       event1.ArbitState.code &amp; 0xffff,
+	       event1.ArbitResult.arbit_node);
+	break;
+
+      default:
+	break;
+      }
+    }
+
+    int r2= ndb_logevent_get_next(le1,&amp;event2,timeout);
+    if (r2 == 0)
+      printf("No event within %d milliseconds\n", timeout);
+    else if (r2 &lt; 0)
+      LOGEVENTERROR(le2)
+    else
+    {
+      switch (event2.type) {
+      case NDB_LE_BackupStarted:
+	printf("Node %d: BackupStarted\n", event2.source_nodeid);
+	printf("  Starting node ID: %d\n", event2.BackupStarted.starting_node);
+	printf("  Backup ID: %d\n", event2.BackupStarted.backup_id);
+	break;
+      case NDB_LE_BackupCompleted:
+	printf("Node %d: BackupCompleted\n", event2.source_nodeid);
+	printf("  Backup ID: %d\n", event2.BackupStarted.backup_id);
+	break;
+      case NDB_LE_BackupAborted:
+	printf("Node %d: BackupAborted\n", event2.source_nodeid);
+	break;
+      case NDB_LE_BackupFailedToStart:
+	printf("Node %d: BackupFailedToStart\n", event2.source_nodeid);
+	break;
+
+      case NDB_LE_NodeFailCompleted:
+	printf("Node %d: NodeFailCompleted\n", event2.source_nodeid);
+	break;
+      case NDB_LE_ArbitResult:
+	printf("Node %d: ArbitResult\n", event2.source_nodeid);
+	printf("  code %d, arbit_node %d\n",
+	       event2.ArbitResult.code &amp; 0xffff,
+	       event2.ArbitResult.arbit_node);
+	break;
+      case NDB_LE_DeadDueToHeartbeat:
+	printf("Node %d: DeadDueToHeartbeat\n", event2.source_nodeid);
+	printf("  node %d\n", event2.DeadDueToHeartbeat.node);
+	break;
+
+      case NDB_LE_Connected:
+	printf("Node %d: Connected\n", event2.source_nodeid);
+	printf("  node %d\n", event2.Connected.node);
+	break;
+      case NDB_LE_Disconnected:
+	printf("Node %d: Disconnected\n", event2.source_nodeid);
+	printf("  node %d\n", event2.Disconnected.node);
+	break;
+      case NDB_LE_NDBStartCompleted:
+	printf("Node %d: StartCompleted\n", event2.source_nodeid);
+	printf("  version %d.%d.%d\n",
+	       event2.NDBStartCompleted.version &gt;&gt; 16 &amp; 0xff,
+	       event2.NDBStartCompleted.version &gt;&gt; 8 &amp; 0xff,
+	       event2.NDBStartCompleted.version &gt;&gt; 0 &amp; 0xff);
+	break;
+      case NDB_LE_ArbitState:
+	printf("Node %d: ArbitState\n", event2.source_nodeid);
+	printf("  code %d, arbit_node %d\n",
+	       event2.ArbitState.code &amp; 0xffff,
+	       event2.ArbitResult.arbit_node);
+	break;
+
+      default:
+	break;
+      }
+    }
+  }
+      
+  ndb_mgm_destroy_logevent_handle(&amp;le1);
+  ndb_mgm_destroy_logevent_handle(&amp;le2);
+  ndb_mgm_destroy_handle(&amp;h1);
+  ndb_mgm_destroy_handle(&amp;h2);
+  ndb_end(0);
+  return 0;
+}
+</programlisting>
+
+    </section>
+
+  </section>
+
 </chapter>


Modified: trunk/ndbapi/ndb-examples.xml
===================================================================
--- trunk/ndbapi/ndb-examples.xml	2010-04-13 22:35:59 UTC (rev 20000)
+++ trunk/ndbapi/ndb-examples.xml	2010-04-13 22:48:41 UTC (rev 20001)
Changed blocks: 1, Lines Added: 1, Lines Deleted: 247; 7918 bytes

@@ -3223,254 +3223,8 @@
 
   </section>
 
-  <section id="ndb-examples-event-logging-dual">
+  
 
-    <title>Event Handling with Multiple Clusters</title>
-
-    <indexterm>
-      <primary>events</primary>
-      <secondary>example</secondary>
-    </indexterm>
-
-    <indexterm>
-      <primary>connecting to multiple clusters</primary>
-      <secondary>example</secondary>
-    </indexterm>
-
-    <indexterm>
-      <primary>multiple clusters, connecting to</primary>
-      <secondary>example</secondary>
-    </indexterm>
-
-    <abstract>
-
-      <para>
-        This example illustrates the handling log events using the MGM
-        API on multiple clusters in a single application.
-      </para>
-
-      <para>
-        The source code for this program may be found in the MySQL
-        Cluster source tree, in the file
-        <filename>storage/ndb/ndbapi-examples/mgmapi_logevent2/mgmapi_logevent2.cpp</filename>.
-      </para>
-
-    </abstract>
-
-<programlisting>
-#include &lt;mysql.h&gt;
-#include &lt;ndbapi/NdbApi.hpp&gt;
-#include &lt;mgmapi.h&gt;
-#include &lt;stdio.h&gt;
-
-/*
- * export LD_LIBRARY_PATH=../../../libmysql_r/.libs:../../../ndb/src/.libs
- */
-
-#define MGMERROR(h) \
-{ \
-  fprintf(stderr, "code: %d msg: %s\n", \
-          ndb_mgm_get_latest_error(h), \
-          ndb_mgm_get_latest_error_msg(h)); \
-  exit(-1); \
-}
-
-#define LOGEVENTERROR(h) \
-{ \
-  fprintf(stderr, "code: %d msg: %s\n", \
-          ndb_logevent_get_latest_error(h), \
-          ndb_logevent_get_latest_error_msg(h)); \
-  exit(-1); \
-}
-
-int main(int argc, char** argv)
-{
-  NdbMgmHandle h1,h2;
-  NdbLogEventHandle le1,le2;
-  int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_BACKUP,
-       15, NDB_MGM_EVENT_CATEGORY_CONNECTION,
-       15, NDB_MGM_EVENT_CATEGORY_NODE_RESTART,
-       15, NDB_MGM_EVENT_CATEGORY_STARTUP,
-       15, NDB_MGM_EVENT_CATEGORY_ERROR,
-       0 };
-  struct ndb_logevent event1, event2;
-
-  if (argc &lt; 3)
-  {
-    printf("Arguments are &lt;connect_string cluster 1&gt; &lt;connect_string cluster 2&gt; [&lt;iterations&gt;].\n");
-    exit(-1);
-  }
-  const char *connectstring1 = argv[1];
-  const char *connectstring2 = argv[2];
-  int iterations = -1;
-  if (argc &gt; 3)
-    iterations = atoi(argv[3]);
-  ndb_init();
-
-  h1= ndb_mgm_create_handle();
-  h2= ndb_mgm_create_handle();
-  if ( h1 == 0 || h2 == 0 )
-  {
-    printf("Unable to create handle\n");
-    exit(-1);
-  }
-  if (ndb_mgm_set_connectstring(h1, connectstring1) == -1 ||
-      ndb_mgm_set_connectstring(h2, connectstring1))
-  {
-    printf("Unable to set connectstring\n");
-    exit(-1);
-  }
-  if (ndb_mgm_connect(h1,0,0,0)) MGMERROR(h1);
-  if (ndb_mgm_connect(h2,0,0,0)) MGMERROR(h2);
-
-  if ((le1= ndb_mgm_create_logevent_handle(h1, filter)) == 0) MGMERROR(h1);
-  if ((le2= ndb_mgm_create_logevent_handle(h1, filter)) == 0) MGMERROR(h2);
-
-  while (iterations-- != 0)
-  {
-    int timeout= 1000;
-    int r1= ndb_logevent_get_next(le1,&amp;event1,timeout);
-    if (r1 == 0)
-      printf("No event within %d milliseconds\n", timeout);
-    else if (r1 &lt; 0)
-      LOGEVENTERROR(le1)
-    else
-    {
-      switch (event1.type) {
-      case NDB_LE_BackupStarted:
-  printf("Node %d: BackupStarted\n", event1.source_nodeid);
-  printf("  Starting node ID: %d\n", event1.BackupStarted.starting_node);
-  printf("  Backup ID: %d\n", event1.BackupStarted.backup_id);
-  break;
-      case NDB_LE_BackupCompleted:
-  printf("Node %d: BackupCompleted\n", event1.source_nodeid);
-  printf("  Backup ID: %d\n", event1.BackupStarted.backup_id);
-  break;
-      case NDB_LE_BackupAborted:
-  printf("Node %d: BackupAborted\n", event1.source_nodeid);
-  break;
-      case NDB_LE_BackupFailedToStart:
-  printf("Node %d: BackupFailedToStart\n", event1.source_nodeid);
-  break;
-
-      case NDB_LE_NodeFailCompleted:
-  printf("Node %d: NodeFailCompleted\n", event1.source_nodeid);
-  break;
-      case NDB_LE_ArbitResult:
-  printf("Node %d: ArbitResult\n", event1.source_nodeid);
-  printf("  code %d, arbit_node %d\n",
-         event1.ArbitResult.code &amp; 0xffff,
-         event1.ArbitResult.arbit_node);
-  break;
-      case NDB_LE_DeadDueToHeartbeat:
-  printf("Node %d: DeadDueToHeartbeat\n", event1.source_nodeid);
-  printf("  node %d\n", event1.DeadDueToHeartbeat.node);
-  break;
-
-      case NDB_LE_Connected:
-  printf("Node %d: Connected\n", event1.source_nodeid);
-  printf("  node %d\n", event1.Connected.node);
-  break;
-      case NDB_LE_Disconnected:
-  printf("Node %d: Disconnected\n", event1.source_nodeid);
-  printf("  node %d\n", event1.Disconnected.node);
-  break;
-      case NDB_LE_NDBStartCompleted:
-  printf("Node %d: StartCompleted\n", event1.source_nodeid);
-  printf("  version %d.%d.%d\n",
-         event1.NDBStartCompleted.version &gt;&gt; 16 &amp; 0xff,
-         event1.NDBStartCompleted.version &gt;&gt; 8 &amp; 0xff,
-         event1.NDBStartCompleted.version &gt;&gt; 0 &amp; 0xff);
-  break;
-      case NDB_LE_ArbitState:
-  printf("Node %d: ArbitState\n", event1.source_nodeid);
-  printf("  code %d, arbit_node %d\n",
-         event1.ArbitState.code &amp; 0xffff,
-         event1.ArbitResult.arbit_node);
-  break;
-
-      default:
-  break;
-      }
-    }
-
-    int r2= ndb_logevent_get_next(le1,&amp;event2,timeout);
-    if (r2 == 0)
-      printf("No event within %d milliseconds\n", timeout);
-    else if (r2 &lt; 0)
-      LOGEVENTERROR(le2)
-    else
-    {
-      switch (event2.type) {
-      case NDB_LE_BackupStarted:
-  printf("Node %d: BackupStarted\n", event2.source_nodeid);
-  printf("  Starting node ID: %d\n", event2.BackupStarted.starting_node);
-  printf("  Backup ID: %d\n", event2.BackupStarted.backup_id);
-  break;
-      case NDB_LE_BackupCompleted:
-  printf("Node %d: BackupCompleted\n", event2.source_nodeid);
-  printf("  Backup ID: %d\n", event2.BackupStarted.backup_id);
-  break;
-      case NDB_LE_BackupAborted:
-  printf("Node %d: BackupAborted\n", event2.source_nodeid);
-  break;
-      case NDB_LE_BackupFailedToStart:
-  printf("Node %d: BackupFailedToStart\n", event2.source_nodeid);
-  break;
-
-      case NDB_LE_NodeFailCompleted:
-  printf("Node %d: NodeFailCompleted\n", event2.source_nodeid);
-  break;
-      case NDB_LE_ArbitResult:
-  printf("Node %d: ArbitResult\n", event2.source_nodeid);
-  printf("  code %d, arbit_node %d\n",
-         event2.ArbitResult.code &amp; 0xffff,
-         event2.ArbitResult.arbit_node);
-  break;
-      case NDB_LE_DeadDueToHeartbeat:
-  printf("Node %d: DeadDueToHeartbeat\n", event2.source_nodeid);
-  printf("  node %d\n", event2.DeadDueToHeartbeat.node);
-  break;
-
-      case NDB_LE_Connected:
-  printf("Node %d: Connected\n", event2.source_nodeid);
-  printf("  node %d\n", event2.Connected.node);
-  break;
-      case NDB_LE_Disconnected:
-  printf("Node %d: Disconnected\n", event2.source_nodeid);
-  printf("  node %d\n", event2.Disconnected.node);
-  break;
-      case NDB_LE_NDBStartCompleted:
-  printf("Node %d: StartCompleted\n", event2.source_nodeid);
-  printf("  version %d.%d.%d\n",
-         event2.NDBStartCompleted.version &gt;&gt; 16 &amp; 0xff,
-         event2.NDBStartCompleted.version &gt;&gt; 8 &amp; 0xff,
-         event2.NDBStartCompleted.version &gt;&gt; 0 &amp; 0xff);
-  break;
-      case NDB_LE_ArbitState:
-  printf("Node %d: ArbitState\n", event2.source_nodeid);
-  printf("  code %d, arbit_node %d\n",
-         event2.ArbitState.code &amp; 0xffff,
-         event2.ArbitResult.arbit_node);
-  break;
-
-      default:
-  break;
-      }
-    }
-  }
-
-  ndb_mgm_destroy_logevent_handle(&amp;le1);
-  ndb_mgm_destroy_logevent_handle(&amp;le2);
-  ndb_mgm_destroy_handle(&amp;h1);
-  ndb_mgm_destroy_handle(&amp;h2);
-  ndb_end(0);
-  return 0;
-}
-</programlisting>
-
-  </section>
-
   <section id="ndb-examples-blobs-basic">
 
     <title>Basic <literal>BLOB</literal> Handling Example</title>


Modified: trunk/ndbapi/renamed-nodes.txt
===================================================================
--- trunk/ndbapi/renamed-nodes.txt	2010-04-13 22:35:59 UTC (rev 20000)
+++ trunk/ndbapi/renamed-nodes.txt	2010-04-13 22:48:41 UTC (rev 20001)
Changed blocks: 1, Lines Added: 1, Lines Deleted: 0; 795 bytes

@@ -592,6 +592,7 @@
 ndb-error-codes-schema ndb-error-codes-schema-error  2009-09-15
 ndb-error-codes-temporary-resource ndb-error-codes-temporary-resource-error  2009-09-15
 ndb-error-codes-unknown-result ndb-error-codes-unknown-result-error  2009-09-15
+ndb-examples-event-logging-dual mgm-examples-event-logging-dual 2011-04-14
 ndb-internals-start-phases-read-config ndb-internals-start-phases-initialization 2009-06-01
 ndb-logevent-get-fd mgm-ndb-logevent-get-fd 2011-01-21
 ndb-logevent-get-latest-error mgm-ndb-logevent-get-latest-error 2011-01-21


Thread
svn commit - mysqldoc@docsrva: r20001 - trunk/ndbapijon.stephens14 Apr