From aeee580b322d07aec7ac8cebf250bd5017b5ad33 Mon Sep 17 00:00:00 2001 From: steve glass Date: Wed, 11 Nov 2015 20:05:37 -0500 Subject: [PATCH 01/26] removing draft of ump_src_failover --- c_index.html | 1 - index.html | 1 - ump_src_failover/README.txt | 5 ----- 3 files changed, 7 deletions(-) delete mode 100644 ump_src_failover/README.txt diff --git a/c_index.html b/c_index.html index 84c385e..d932bc9 100644 --- a/c_index.html +++ b/c_index.html @@ -38,7 +38,6 @@

Examples

sequential_modeC Java C#/.NETExample on how to run a LBM application in sequential mode with a separate context thread setting_attributesC Java C#/.NETExamples on setting UM attributes via the API ump_receiver_callbacksC Java C#/.NETA sample application that handles all UMP receiver callbacks and logs important data -ump_src_failoverC Java C#/.NETExample UMP source application that demonstrates how a persisted source can failover to a backup store diff --git a/index.html b/index.html index 92e37b4..251d5ac 100644 --- a/index.html +++ b/index.html @@ -48,7 +48,6 @@

Examples

sequential_modeC Java C#/.NETExample on how to run a LBM application in sequential mode with a separate context thread setting_attributesC Java C#/.NETExamples on setting UM attributes via the API ump_receiver_callbacksC Java C#/.NETA sample application that handles all UMP receiver callbacks and logs important data -ump_src_failoverC Java C#/.NETExample UMP source application that demonstrates how a persisted source can failover to a backup store diff --git a/ump_src_failover/README.txt b/ump_src_failover/README.txt deleted file mode 100644 index 6a17087..0000000 --- a/ump_src_failover/README.txt +++ /dev/null @@ -1,5 +0,0 @@ -# README.txt - this file must conform to a standard format. - -Summary=Example UMP source application that demonstrates how a persisted source can failover to a backup store - -Description= From b914163f4ccb769da8117982fdadbed3e81c0861 Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Fri, 24 Nov 2017 14:10:50 -0600 Subject: [PATCH 02/26] per-source state, etc Added per-source state to C source_notify_callbacks. Also changed all programs to have properly formed "main" with return. Also changed one program's tabs to spaces. --- bld.sh | 15 +- c_index.html | 1 + cancelling_timers/c/cancelling_timers.c | 3 +- cancelling_timers/c/cancelling_timers_c.slsrc | 3 +- .../c/cancelling_timers_c.slsrc.html | 4 +- .../c/check_flight_size_ewouldblock.c | 3 +- .../c/check_flight_size_ewouldblock.slsrc | 3 +- .../check_flight_size_ewouldblock.slsrc.html | 4 +- clean_shutdown/c/clean_shutdown.c | 3 +- clean_shutdown/c/clean_shutdown_c.slsrc | 3 +- clean_shutdown/c/clean_shutdown_c.slsrc.html | 4 +- context_create/c/context_create_c.slsrc | 3 +- dump_attributes/c/dump_attributes.c | 3 +- dump_attributes/c/dump_attributes_c.slsrc | 3 +- .../c/dump_attributes_c.slsrc.html | 4 +- event_q_rcv/c/event_q_rcv.c | 3 +- event_q_rcv/c/event_q_rcv_c.slsrc | 3 +- event_q_rcv/c/event_q_rcv_c.slsrc.html | 4 +- event_q_src/c/event_q_src.c | 3 +- event_q_src/c/event_q_src_c.slsrc | 3 +- event_q_src/c/event_q_src_c.slsrc.html | 4 +- handle_burst/c/handle_burst.c | 3 +- handle_burst/c/handle_burst_c.slsrc | 3 +- handle_burst/c/handle_burst_c.slsrc.html | 4 +- index.html | 1 + late_join/c/late_join.c | 3 +- late_join/c/late_join_c.slsrc | 3 +- late_join/c/late_join_c.slsrc.html | 4 +- load_config/c/load_config.c | 3 +- load_config/c/load_config_c.slsrc | 3 +- load_config/c/load_config_c.slsrc.html | 4 +- logging_callback/c/logging_callback.c | 3 +- logging_callback/c/logging_callback_c.slsrc | 3 +- .../c/logging_callback_c.slsrc.html | 4 +- minsrc/c/minsrc.c | 1 + minsrc/c/minsrc_c.slsrc | 1 + minsrc/c/minsrc_c.slsrc.html | 2 + multi_context/c/multi_context.c | 3 +- multi_context/c/multi_context_c.slsrc | 3 +- multi_context/c/multi_context_c.slsrc.html | 4 +- no_source_notify/c/no_source_notify.c | 3 +- no_source_notify/c/no_source_notify_c.slsrc | 3 +- .../c/no_source_notify_c.slsrc.html | 4 +- quorum_state/c/quorum_state.c | 3 +- quorum_state/c/quorum_state_c.slsrc | 3 +- quorum_state/c/quorum_state_c.slsrc.html | 4 +- request_response/c/request_response.c | 3 +- request_response/c/request_response_c.slsrc | 3 +- .../c/request_response_c.slsrc.html | 4 +- schedule_timers/c/schedule_timers.c | 3 +- schedule_timers/c/schedule_timers_c.slsrc | 3 +- .../c/schedule_timers_c.slsrc.html | 4 +- seq_number_callback/c/seq_number_callback.c | 3 +- .../c/seq_number_callback_c.slsrc | 3 +- .../c/seq_number_callback_c.slsrc.html | 4 +- sequential_mode/c/sequential_mode.c | 3 +- sequential_mode/c/sequential_mode_c.slsrc | 3 +- .../c/sequential_mode_c.slsrc.html | 4 +- setting_attributes/c/setting_attributes.c | 3 +- .../c/setting_attributes_c.slsrc | 3 +- .../c/setting_attributes_c.slsrc.html | 4 +- source_create/c/source_create_c.slsrc | 3 +- .../c/source_notify_callbacks.c | 21 +- .../c/source_notify_callbacks.sldoc | 11 +- .../c/source_notify_callbacks.sldoc.html | 122 +++++---- .../c/source_notify_callbacks_c.slsrc | 23 +- .../c/source_notify_callbacks_c.slsrc.html | 156 +++++++----- .../dotnet/source_notify_callbacks.sldoc.html | 6 +- source_notify_callbacks/intro.sldoc | 6 +- .../java/source_notify_callbacks.sldoc.html | 6 +- .../c/ump_receiver_callbacks.c | 3 +- .../c/ump_receiver_callbacks_c.slsrc | 3 +- .../c/ump_receiver_callbacks_c.slsrc.html | 4 +- ump_src_failover/c/ump_src_failover.c | 195 +++++++------- .../c/ump_src_failover.sldoc.html | 108 ++++---- ump_src_failover/c/ump_src_failover_c.slsrc | 239 +++++++++--------- .../c/ump_src_failover_c.slsrc.html | 186 +++++++------- 77 files changed, 743 insertions(+), 553 deletions(-) diff --git a/bld.sh b/bld.sh index 5034da8..7cdfd00 100755 --- a/bld.sh +++ b/bld.sh @@ -7,10 +7,18 @@ else : exit 1 fi -# Find all the examples -find * -name README.txt -print >bld.tmp +if [ -n "$1" ]; then : + if [ ! -d "$1" ]; then : + echo "$1 not found" >&2 + exit 1 + fi + find "$1" -name README.txt -print >bld.tmp +else : + # Find all the examples + find * -name README.txt -print >bld.tmp +fi -# Build all the semiliterate docs +# Build the semiliterate docs cat bld.tmp | while read F; do : # find each tool T=`dirname $F` cd $T @@ -28,6 +36,7 @@ cat bld.tmp | while read F; do : # find each tool done echo "bld.sh: Info: building html index files" +find * -name README.txt -print >bld.tmp perl bld.pl bld.tmp rm bld.tmp diff --git a/c_index.html b/c_index.html index 39556cf..ce21b0e 100644 --- a/c_index.html +++ b/c_index.html @@ -39,6 +39,7 @@

Examples

setting_attributesC Java C#/.NETExamples on setting UM attributes via the API source_notify_callbacksC Java C#/.NETA sample application that demonstrates how to configure and code the source_notification_callback feature for receivers ump_receiver_callbacksC Java C#/.NETA sample application that handles all UMP receiver callbacks and logs important data +ump_src_failoverC Java C#/.NETExample UMP source application that demonstrates how a persisted source can failover to a backup store diff --git a/cancelling_timers/c/cancelling_timers.c b/cancelling_timers/c/cancelling_timers.c index cbc5bc5..be08ea7 100644 --- a/cancelling_timers/c/cancelling_timers.c +++ b/cancelling_timers/c/cancelling_timers.c @@ -59,7 +59,7 @@ int cancel_timer_cb(lbm_context_t *ctx, const void *clientd) return 0; } -main() +int main(int argc, void **argv) { lbm_context_t *ctx; /* Context object */ lbm_context_attr_t * cattr; /* Context attribute object */ @@ -101,5 +101,6 @@ main() /* Windows-specific cleanup overhead */ WSACleanup(); #endif + return 0; } diff --git a/cancelling_timers/c/cancelling_timers_c.slsrc b/cancelling_timers/c/cancelling_timers_c.slsrc index 72a30dd..898b092 100644 --- a/cancelling_timers/c/cancelling_timers_c.slsrc +++ b/cancelling_timers/c/cancelling_timers_c.slsrc @@ -71,7 +71,7 @@ int cancel_timer_cb(lbm_context_t *ctx, const void *clientd) } /* =semlit,endblock,cancel_cb=*/ -main() +int main(int argc, void **argv) { lbm_context_t *ctx; /* Context object */ lbm_context_attr_t * cattr; /* Context attribute object */ @@ -121,5 +121,6 @@ main() /* Windows-specific cleanup overhead */ WSACleanup(); #endif + return 0; } diff --git a/cancelling_timers/c/cancelling_timers_c.slsrc.html b/cancelling_timers/c/cancelling_timers_c.slsrc.html index de0394a..436c61d 100644 --- a/cancelling_timers/c/cancelling_timers_c.slsrc.html +++ b/cancelling_timers/c/cancelling_timers_c.slsrc.html @@ -121,6 +121,7 @@ 00103 00104 00105 +00106 /* Code Disclaimer? */ #include <stdio.h> @@ -182,7 +183,7 @@ return 0; } - main() + int main(int argc, void **argv) { lbm_context_t *ctx; /* Context object */ lbm_context_attr_t * cattr; /* Context attribute object */ @@ -224,6 +225,7 @@ /* Windows-specific cleanup overhead */ WSACleanup(); #endif + return 0; } diff --git a/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.c b/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.c index 984f4bf..cf92ed0 100644 --- a/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.c +++ b/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.c @@ -17,7 +17,7 @@ #define DEFAULT_APP_FLIGHT_SIZE 500 /* Used for checking flight size */ -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ lbm_topic_t *topic; /* Topic object */ @@ -104,6 +104,7 @@ main() } } } + return 0; } diff --git a/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.slsrc b/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.slsrc index e8846cc..a01946c 100644 --- a/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.slsrc +++ b/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.slsrc @@ -21,7 +21,7 @@ #define DEFAULT_APP_FLIGHT_SIZE 500 /* Used for checking flight size */ /* =semlit,endblock,default_flight=*/ -main() +int main(int argc, char **argv) { /* =semlit,block,variables=*/ lbm_context_t *ctx; /* Context object */ @@ -122,6 +122,7 @@ main() } } } + return 0; } diff --git a/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.slsrc.html b/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.slsrc.html index 2954bcb..640edbd 100644 --- a/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.slsrc.html +++ b/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.slsrc.html @@ -125,6 +125,7 @@ 00107 00108 00109 +00110 /* Code Disclaimer? */ #include <stdio.h> @@ -144,7 +145,7 @@ #define DEFAULT_APP_FLIGHT_SIZE 500 /* Used for checking flight size */ - main() + int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ lbm_topic_t *topic; /* Topic object */ @@ -231,6 +232,7 @@ } } } + return 0; } diff --git a/clean_shutdown/c/clean_shutdown.c b/clean_shutdown/c/clean_shutdown.c index ca2ad80..00eaae6 100644 --- a/clean_shutdown/c/clean_shutdown.c +++ b/clean_shutdown/c/clean_shutdown.c @@ -61,7 +61,7 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) cleanup = 1; } -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_context_attr_t * cattr; /* pointer to context attribute object */ @@ -151,5 +151,6 @@ main() lbm_src_delete(src); lbm_context_delete(ctx); lbm_event_queue_delete(evq); + return 0; } diff --git a/clean_shutdown/c/clean_shutdown_c.slsrc b/clean_shutdown/c/clean_shutdown_c.slsrc index 58a6e44..7a65bd3 100644 --- a/clean_shutdown/c/clean_shutdown_c.slsrc +++ b/clean_shutdown/c/clean_shutdown_c.slsrc @@ -67,7 +67,7 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) cleanup = 1; } -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_context_attr_t * cattr; /* pointer to context attribute object */ @@ -171,5 +171,6 @@ main() lbm_context_delete(ctx); lbm_event_queue_delete(evq); /* =semlit,endblock,delete=*/ + return 0; } diff --git a/clean_shutdown/c/clean_shutdown_c.slsrc.html b/clean_shutdown/c/clean_shutdown_c.slsrc.html index 90d55f0..7fae85a 100644 --- a/clean_shutdown/c/clean_shutdown_c.slsrc.html +++ b/clean_shutdown/c/clean_shutdown_c.slsrc.html @@ -171,6 +171,7 @@ 00153 00154 00155 +00156 /* Code Disclaimer? */ #include <stdio.h> @@ -234,7 +235,7 @@ cleanup = 1; } - main() + int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_context_attr_t * cattr; /* pointer to context attribute object */ @@ -324,6 +325,7 @@ lbm_src_delete(src); lbm_context_delete(ctx); lbm_event_queue_delete(evq); + return 0; } diff --git a/context_create/c/context_create_c.slsrc b/context_create/c/context_create_c.slsrc index 5baaf30..3d6d5fc 100644 --- a/context_create/c/context_create_c.slsrc +++ b/context_create/c/context_create_c.slsrc @@ -18,7 +18,7 @@ /* =semlit,endblock,includes=*/ /* =semlit,block,main=*/ -main() +int main(int argc, char **argv) { /* =semlit,block,declare=*/ lbm_context_t *ctx; /* pointer to context object */ @@ -57,5 +57,6 @@ main() WSACleanup(); #endif /* =semlit,endblock,winclean=*/ + return 0; } /* =semlit,endblock,main= */ diff --git a/dump_attributes/c/dump_attributes.c b/dump_attributes/c/dump_attributes.c index 1cc9546..bf51ac0 100644 --- a/dump_attributes/c/dump_attributes.c +++ b/dump_attributes/c/dump_attributes.c @@ -15,7 +15,7 @@ #include -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_topic_t *topic_1; /* pointer to topic object */ @@ -209,5 +209,6 @@ main() #if defined(_MSC_VER) WSACleanup(); #endif + return 0; } diff --git a/dump_attributes/c/dump_attributes_c.slsrc b/dump_attributes/c/dump_attributes_c.slsrc index 7c5e4de..58d1f5c 100644 --- a/dump_attributes/c/dump_attributes_c.slsrc +++ b/dump_attributes/c/dump_attributes_c.slsrc @@ -15,7 +15,7 @@ #include -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_topic_t *topic_1; /* pointer to topic object */ @@ -219,5 +219,6 @@ main() #if defined(_MSC_VER) WSACleanup(); #endif + return 0; } diff --git a/dump_attributes/c/dump_attributes_c.slsrc.html b/dump_attributes/c/dump_attributes_c.slsrc.html index 0651c7f..4ee0394 100644 --- a/dump_attributes/c/dump_attributes_c.slsrc.html +++ b/dump_attributes/c/dump_attributes_c.slsrc.html @@ -229,6 +229,7 @@ 00211 00212 00213 +00214 /* Example on setting Ultra Messaging attributes */ #include <stdio.h> @@ -246,7 +247,7 @@ #include <lbm/lbm.h> - main() + int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_topic_t *topic_1; /* pointer to topic object */ @@ -440,6 +441,7 @@ #if defined(_MSC_VER) WSACleanup(); #endif + return 0; } diff --git a/event_q_rcv/c/event_q_rcv.c b/event_q_rcv/c/event_q_rcv.c index 2072cf1..c823709 100644 --- a/event_q_rcv/c/event_q_rcv.c +++ b/event_q_rcv/c/event_q_rcv.c @@ -30,7 +30,7 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) return 0; } -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_topic_t *topic_1; /* pointer to topic object */ @@ -103,5 +103,6 @@ main() #if defined(_MSC_VER) WSACleanup(); #endif + return 0; } diff --git a/event_q_rcv/c/event_q_rcv_c.slsrc b/event_q_rcv/c/event_q_rcv_c.slsrc index 85c78d3..63e1576 100644 --- a/event_q_rcv/c/event_q_rcv_c.slsrc +++ b/event_q_rcv/c/event_q_rcv_c.slsrc @@ -30,7 +30,7 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) return 0; } -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_topic_t *topic_1; /* pointer to topic object */ @@ -111,5 +111,6 @@ main() #if defined(_MSC_VER) WSACleanup(); #endif + return 0; } diff --git a/event_q_rcv/c/event_q_rcv_c.slsrc.html b/event_q_rcv/c/event_q_rcv_c.slsrc.html index 7d846ff..753eeda 100644 --- a/event_q_rcv/c/event_q_rcv_c.slsrc.html +++ b/event_q_rcv/c/event_q_rcv_c.slsrc.html @@ -123,6 +123,7 @@ 00105 00106 00107 +00108 /* Example on setting Ultra Messaging attributes */ #include <stdio.h> @@ -155,7 +156,7 @@ return 0; } - main() + int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_topic_t *topic_1; /* pointer to topic object */ @@ -228,6 +229,7 @@ #if defined(_MSC_VER) WSACleanup(); #endif + return 0; } diff --git a/event_q_src/c/event_q_src.c b/event_q_src/c/event_q_src.c index c65452c..90ee4cc 100644 --- a/event_q_src/c/event_q_src.c +++ b/event_q_src/c/event_q_src.c @@ -41,7 +41,7 @@ int handle_src_event(lbm_src_t *src, int event, void *ed, void *cd) return 0; } -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_topic_t *topic_1; /* pointer to topic object */ @@ -125,5 +125,6 @@ main() #if defined(_MSC_VER) WSACleanup(); #endif + return 0; } diff --git a/event_q_src/c/event_q_src_c.slsrc b/event_q_src/c/event_q_src_c.slsrc index 651078b..bb103d2 100644 --- a/event_q_src/c/event_q_src_c.slsrc +++ b/event_q_src/c/event_q_src_c.slsrc @@ -41,7 +41,7 @@ int handle_src_event(lbm_src_t *src, int event, void *ed, void *cd) return 0; } -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_topic_t *topic_1; /* pointer to topic object */ @@ -133,5 +133,6 @@ main() #if defined(_MSC_VER) WSACleanup(); #endif + return 0; } diff --git a/event_q_src/c/event_q_src_c.slsrc.html b/event_q_src/c/event_q_src_c.slsrc.html index b4ac65b..1ab893e 100644 --- a/event_q_src/c/event_q_src_c.slsrc.html +++ b/event_q_src/c/event_q_src_c.slsrc.html @@ -145,6 +145,7 @@ 00127 00128 00129 +00130 /* Example on setting Ultra Messaging attributes */ #include <stdio.h> @@ -188,7 +189,7 @@ return 0; } - main() + int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_topic_t *topic_1; /* pointer to topic object */ @@ -272,6 +273,7 @@ #if defined(_MSC_VER) WSACleanup(); #endif + return 0; } diff --git a/handle_burst/c/handle_burst.c b/handle_burst/c/handle_burst.c index 38567d6..5918fb4 100644 --- a/handle_burst/c/handle_burst.c +++ b/handle_burst/c/handle_burst.c @@ -53,7 +53,7 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) return 0; } -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ lbm_context_attr_t * cattr; /* Context attribute object */ @@ -95,4 +95,5 @@ main() /* Windows-specific cleanup overhead */ WSACleanup(); #endif + return 0; } /* main */ diff --git a/handle_burst/c/handle_burst_c.slsrc b/handle_burst/c/handle_burst_c.slsrc index a042f23..ae37eb1 100644 --- a/handle_burst/c/handle_burst_c.slsrc +++ b/handle_burst/c/handle_burst_c.slsrc @@ -63,7 +63,7 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) return 0; } -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ lbm_context_attr_t * cattr; /* Context attribute object */ @@ -109,4 +109,5 @@ main() /* Windows-specific cleanup overhead */ WSACleanup(); #endif + return 0; } /* main */ diff --git a/handle_burst/c/handle_burst_c.slsrc.html b/handle_burst/c/handle_burst_c.slsrc.html index 650d746..2561ff3 100644 --- a/handle_burst/c/handle_burst_c.slsrc.html +++ b/handle_burst/c/handle_burst_c.slsrc.html @@ -114,6 +114,7 @@ 00096 00097 00098 +00099 /* handle_burst.c - http://ultramessaging.github.io/UMExamples */ #include <stdio.h> @@ -169,7 +170,7 @@ return 0; } - main() + int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ lbm_context_attr_t * cattr; /* Context attribute object */ @@ -211,6 +212,7 @@ /* Windows-specific cleanup overhead */ WSACleanup(); #endif + return 0; } /* main */ diff --git a/index.html b/index.html index 8504a38..b26baf6 100644 --- a/index.html +++ b/index.html @@ -49,6 +49,7 @@

Examples

setting_attributesC Java C#/.NETExamples on setting UM attributes via the API source_notify_callbacksC Java C#/.NETA sample application that demonstrates how to configure and code the source_notification_callback feature for receivers ump_receiver_callbacksC Java C#/.NETA sample application that handles all UMP receiver callbacks and logs important data +ump_src_failoverC Java C#/.NETExample UMP source application that demonstrates how a persisted source can failover to a backup store diff --git a/late_join/c/late_join.c b/late_join/c/late_join.c index 2986fe2..e0fe668 100644 --- a/late_join/c/late_join.c +++ b/late_join/c/late_join.c @@ -42,7 +42,7 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) return 0; } -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_topic_t *topic_1; /* pointer to topic object */ @@ -150,5 +150,6 @@ main() #if defined(_MSC_VER) WSACleanup(); #endif + return 0; } diff --git a/late_join/c/late_join_c.slsrc b/late_join/c/late_join_c.slsrc index f67d708..e31c27c 100644 --- a/late_join/c/late_join_c.slsrc +++ b/late_join/c/late_join_c.slsrc @@ -44,7 +44,7 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) return 0; } -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_topic_t *topic_1; /* pointer to topic object */ @@ -162,5 +162,6 @@ main() #if defined(_MSC_VER) WSACleanup(); #endif + return 0; } diff --git a/late_join/c/late_join_c.slsrc.html b/late_join/c/late_join_c.slsrc.html index e878172..fd11f29 100644 --- a/late_join/c/late_join_c.slsrc.html +++ b/late_join/c/late_join_c.slsrc.html @@ -170,6 +170,7 @@ 00152 00153 00154 +00155 /* Example on setting Ultra Messaging attributes */ #include <stdio.h> @@ -214,7 +215,7 @@ return 0; } - main() + int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_topic_t *topic_1; /* pointer to topic object */ @@ -322,6 +323,7 @@ #if defined(_MSC_VER) WSACleanup(); #endif + return 0; } diff --git a/load_config/c/load_config.c b/load_config/c/load_config.c index 04da4fe..adddd67 100644 --- a/load_config/c/load_config.c +++ b/load_config/c/load_config.c @@ -26,7 +26,7 @@ #define LBM_CONFIG_XML_FILE "../xml_config.xml" #define LBM_APPLICATION_NAME "processA" -main() +int main(int argc, char **argv) { int err; /* Used for checking API return codes */ @@ -35,4 +35,5 @@ main() err = lbm_config_xml_file((const char *)LBM_CONFIG_XML_FILE, (const char *)LBM_APPLICATION_NAME); EX_LBM_CHK(err); + return 0; } diff --git a/load_config/c/load_config_c.slsrc b/load_config/c/load_config_c.slsrc index d010a11..468a3aa 100644 --- a/load_config/c/load_config_c.slsrc +++ b/load_config/c/load_config_c.slsrc @@ -32,7 +32,7 @@ #define LBM_APPLICATION_NAME "processA" /* =semlit,endblock,define_configs=*/ -main() +int main(int argc, char **argv) { /* =semlit,block,vars=*/ int err; /* Used for checking API return codes */ @@ -47,4 +47,5 @@ main() err = lbm_config_xml_file((const char *)LBM_CONFIG_XML_FILE, (const char *)LBM_APPLICATION_NAME); EX_LBM_CHK(err); /* =semlit,endblock,xml_file=*/ + return 0; } diff --git a/load_config/c/load_config_c.slsrc.html b/load_config/c/load_config_c.slsrc.html index f99bad7..7d6388d 100644 --- a/load_config/c/load_config_c.slsrc.html +++ b/load_config/c/load_config_c.slsrc.html @@ -54,6 +54,7 @@ 00036 00037 00038 +00039 /* load_config.c - http://ultramessaging.github.io/UMExamples */ #include <stdio.h> @@ -82,7 +83,7 @@ #define LBM_CONFIG_XML_FILE "../xml_config.xml" #define LBM_APPLICATION_NAME "processA" - main() + int main(int argc, char **argv) { int err; /* Used for checking API return codes */ @@ -91,6 +92,7 @@ err = lbm_config_xml_file((const char *)LBM_CONFIG_XML_FILE, (const char *)LBM_APPLICATION_NAME); EX_LBM_CHK(err); + return 0; } diff --git a/logging_callback/c/logging_callback.c b/logging_callback/c/logging_callback.c index 595cadf..ac76aea 100644 --- a/logging_callback/c/logging_callback.c +++ b/logging_callback/c/logging_callback.c @@ -22,7 +22,7 @@ int lbm_log_msg(int level, const char *message, void *clientd) return 0; } -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_context_attr_t * cattr; /* pointer to context attribute object */ @@ -91,5 +91,6 @@ main() /* Cleanup */ lbm_src_delete(src); lbm_context_delete(ctx); + return 0; } diff --git a/logging_callback/c/logging_callback_c.slsrc b/logging_callback/c/logging_callback_c.slsrc index bc9d38f..b6a41fe 100644 --- a/logging_callback/c/logging_callback_c.slsrc +++ b/logging_callback/c/logging_callback_c.slsrc @@ -26,7 +26,7 @@ int lbm_log_msg(int level, const char *message, void *clientd) } /* =semlit,endblock,logging_cb=*/ -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_context_attr_t * cattr; /* pointer to context attribute object */ @@ -103,5 +103,6 @@ main() /* Cleanup */ lbm_src_delete(src); lbm_context_delete(ctx); + return 0; } diff --git a/logging_callback/c/logging_callback_c.slsrc.html b/logging_callback/c/logging_callback_c.slsrc.html index 9e61975..549881c 100644 --- a/logging_callback/c/logging_callback_c.slsrc.html +++ b/logging_callback/c/logging_callback_c.slsrc.html @@ -111,6 +111,7 @@ 00093 00094 00095 +00096 /* Code Disclaimer? */ #include <stdio.h> @@ -135,7 +136,7 @@ return 0; } - main() + int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_context_attr_t * cattr; /* pointer to context attribute object */ @@ -204,6 +205,7 @@ /* Cleanup */ lbm_src_delete(src); lbm_context_delete(ctx); + return 0; } diff --git a/minsrc/c/minsrc.c b/minsrc/c/minsrc.c index b0f7a26..fd56c77 100644 --- a/minsrc/c/minsrc.c +++ b/minsrc/c/minsrc.c @@ -83,4 +83,5 @@ int main(int argc, char **argv) /* Windows-specific cleanup overhead */ WSACleanup(); #endif + return 0; } /* main */ diff --git a/minsrc/c/minsrc_c.slsrc b/minsrc/c/minsrc_c.slsrc index feaab60..78ec7b0 100644 --- a/minsrc/c/minsrc_c.slsrc +++ b/minsrc/c/minsrc_c.slsrc @@ -103,4 +103,5 @@ int main(int argc, char **argv) WSACleanup(); #endif /*=semlit,endblock,wsa_clean=*/ + return 0; } /* main */ diff --git a/minsrc/c/minsrc_c.slsrc.html b/minsrc/c/minsrc_c.slsrc.html index 27e98f7..0eee956 100644 --- a/minsrc/c/minsrc_c.slsrc.html +++ b/minsrc/c/minsrc_c.slsrc.html @@ -102,6 +102,7 @@ 00084 00085 00086 +00087 /* minsrc.c, see http://ultramessaging.github.io/UMExamples/minsrc/c/ */ #include <stdio.h> @@ -187,6 +188,7 @@ /* Windows-specific cleanup overhead */ WSACleanup(); #endif + return 0; } /* main */ diff --git a/multi_context/c/multi_context.c b/multi_context/c/multi_context.c index d17c5a3..df0a317 100644 --- a/multi_context/c/multi_context.c +++ b/multi_context/c/multi_context.c @@ -27,7 +27,7 @@ #define LBM_CONFIG_XML_FILE "multi_context_config.xml" #define LBM_APPLICATION_NAME "main" -main() +int main(int argc, char **argv) { lbm_context_t *ctx_1; /* Context object */ lbm_context_attr_t * cattr_1; /* pointer to context attribute object */ @@ -69,4 +69,5 @@ main() #if defined(_MSC_VER) WSACleanup(); #endif + return 0; } diff --git a/multi_context/c/multi_context_c.slsrc b/multi_context/c/multi_context_c.slsrc index 2587856..fccc439 100644 --- a/multi_context/c/multi_context_c.slsrc +++ b/multi_context/c/multi_context_c.slsrc @@ -33,7 +33,7 @@ #define LBM_APPLICATION_NAME "main" /* =semlit,endblock,define_configs=*/ -main() +int main(int argc, char **argv) { /* =semlit,block,vars=*/ lbm_context_t *ctx_1; /* Context object */ @@ -85,4 +85,5 @@ main() #if defined(_MSC_VER) WSACleanup(); #endif + return 0; } diff --git a/multi_context/c/multi_context_c.slsrc.html b/multi_context/c/multi_context_c.slsrc.html index b54ca7c..f1d5d1f 100644 --- a/multi_context/c/multi_context_c.slsrc.html +++ b/multi_context/c/multi_context_c.slsrc.html @@ -88,6 +88,7 @@ 00070 00071 00072 +00073 /* Code Disclaimer? */ #include <stdio.h> @@ -117,7 +118,7 @@ #define LBM_CONFIG_XML_FILE "multi_context_config.xml" #define LBM_APPLICATION_NAME "main" - main() + int main(int argc, char **argv) { lbm_context_t *ctx_1; /* Context object */ lbm_context_attr_t * cattr_1; /* pointer to context attribute object */ @@ -159,6 +160,7 @@ #if defined(_MSC_VER) WSACleanup(); #endif + return 0; } diff --git a/no_source_notify/c/no_source_notify.c b/no_source_notify/c/no_source_notify.c index 1ee9508..097414b 100644 --- a/no_source_notify/c/no_source_notify.c +++ b/no_source_notify/c/no_source_notify.c @@ -45,7 +45,7 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) return 0; } -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ lbm_context_attr_t * cattr; /* Context attribute object */ @@ -93,4 +93,5 @@ main() /* Windows-specific cleanup overhead */ WSACleanup(); #endif + return 0; } /* main */ diff --git a/no_source_notify/c/no_source_notify_c.slsrc b/no_source_notify/c/no_source_notify_c.slsrc index 4cbda8d..d99d22f 100644 --- a/no_source_notify/c/no_source_notify_c.slsrc +++ b/no_source_notify/c/no_source_notify_c.slsrc @@ -53,7 +53,7 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) return 0; } -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ lbm_context_attr_t * cattr; /* Context attribute object */ @@ -105,4 +105,5 @@ main() /* Windows-specific cleanup overhead */ WSACleanup(); #endif + return 0; } /* main */ diff --git a/no_source_notify/c/no_source_notify_c.slsrc.html b/no_source_notify/c/no_source_notify_c.slsrc.html index 151081d..f7f171c 100644 --- a/no_source_notify/c/no_source_notify_c.slsrc.html +++ b/no_source_notify/c/no_source_notify_c.slsrc.html @@ -112,6 +112,7 @@ 00094 00095 00096 +00097 /* no_source_notify.c - http://ultramessaging.github.io/UMExamples */ #include <stdio.h> @@ -159,7 +160,7 @@ return 0; } - main() + int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ lbm_context_attr_t * cattr; /* Context attribute object */ @@ -207,6 +208,7 @@ /* Windows-specific cleanup overhead */ WSACleanup(); #endif + return 0; } /* main */ diff --git a/quorum_state/c/quorum_state.c b/quorum_state/c/quorum_state.c index 6dcc3aa..77d8ed7 100644 --- a/quorum_state/c/quorum_state.c +++ b/quorum_state/c/quorum_state.c @@ -44,7 +44,7 @@ int handle_src_event(lbm_src_t *src, int event, void *ed, void *cd) return 0; } -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ lbm_topic_t *topic; /* Topic object */ @@ -128,4 +128,5 @@ main() SLEEP_SEC(1); } } + return 0; } diff --git a/quorum_state/c/quorum_state_c.slsrc b/quorum_state/c/quorum_state_c.slsrc index 67be15c..62b7c8c 100644 --- a/quorum_state/c/quorum_state_c.slsrc +++ b/quorum_state/c/quorum_state_c.slsrc @@ -54,7 +54,7 @@ int handle_src_event(lbm_src_t *src, int event, void *ed, void *cd) return 0; } -main() +int main(int argc, char **argv) { /* =semlit,block,variables=*/ lbm_context_t *ctx; /* Context object */ @@ -148,4 +148,5 @@ main() } /* =semlit,endblock,src_send=*/ } + return 0; } diff --git a/quorum_state/c/quorum_state_c.slsrc.html b/quorum_state/c/quorum_state_c.slsrc.html index 83ae8fe..62da0b6 100644 --- a/quorum_state/c/quorum_state_c.slsrc.html +++ b/quorum_state/c/quorum_state_c.slsrc.html @@ -147,6 +147,7 @@ 00129 00130 00131 +00132 /* Code Disclaimer? */ #include <stdio.h> @@ -193,7 +194,7 @@ return 0; } - main() + int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ lbm_topic_t *topic; /* Topic object */ @@ -277,6 +278,7 @@ SLEEP_SEC(1); } } + return 0; } diff --git a/request_response/c/request_response.c b/request_response/c/request_response.c index 2cef5d3..3b0bd43 100644 --- a/request_response/c/request_response.c +++ b/request_response/c/request_response.c @@ -52,7 +52,7 @@ int handle_response(lbm_request_t *req, lbm_msg_t *msg, void *clientd) } } -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ lbm_topic_t *stopic; /* Source Topic object */ @@ -126,4 +126,5 @@ main() /* Windows-specific cleanup overhead */ WSACleanup(); #endif + return 0; } /* main */ diff --git a/request_response/c/request_response_c.slsrc b/request_response/c/request_response_c.slsrc index 45bf245..82d236e 100644 --- a/request_response/c/request_response_c.slsrc +++ b/request_response/c/request_response_c.slsrc @@ -62,7 +62,7 @@ int handle_response(lbm_request_t *req, lbm_msg_t *msg, void *clientd) } /* =semlit,endblock,resp_cb=*/ -main() +int main(int argc, char **argv) { /* =semlit,block,vars=*/ lbm_context_t *ctx; /* Context object */ @@ -154,4 +154,5 @@ main() WSACleanup(); #endif /* =semlit,endblock,clean_win=*/ + return 0; } /* main */ diff --git a/request_response/c/request_response_c.slsrc.html b/request_response/c/request_response_c.slsrc.html index 6c49fb6..1db1ca1 100644 --- a/request_response/c/request_response_c.slsrc.html +++ b/request_response/c/request_response_c.slsrc.html @@ -145,6 +145,7 @@ 00127 00128 00129 +00130 /* request_response.c - http://ultramessaging.github.io/UMExamples */ #include <stdio.h> @@ -199,7 +200,7 @@ } } - main() + int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ lbm_topic_t *stopic; /* Source Topic object */ @@ -273,6 +274,7 @@ /* Windows-specific cleanup overhead */ WSACleanup(); #endif + return 0; } /* main */ diff --git a/schedule_timers/c/schedule_timers.c b/schedule_timers/c/schedule_timers.c index bd5d6db..ebec55f 100644 --- a/schedule_timers/c/schedule_timers.c +++ b/schedule_timers/c/schedule_timers.c @@ -33,7 +33,7 @@ int sample_timer_handler(lbm_context_t *ctx, const void *clientd) wait = 0; } -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ lbm_context_attr_t * cattr; /* Context attribute object */ @@ -64,5 +64,6 @@ main() /* Windows-specific cleanup overhead */ WSACleanup(); #endif + return 0; } diff --git a/schedule_timers/c/schedule_timers_c.slsrc b/schedule_timers/c/schedule_timers_c.slsrc index eb3e2f5..70014a2 100644 --- a/schedule_timers/c/schedule_timers_c.slsrc +++ b/schedule_timers/c/schedule_timers_c.slsrc @@ -41,7 +41,7 @@ int sample_timer_handler(lbm_context_t *ctx, const void *clientd) } /* =semlit,endblock,timer_cb=*/ -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ lbm_context_attr_t * cattr; /* Context attribute object */ @@ -78,5 +78,6 @@ main() /* Windows-specific cleanup overhead */ WSACleanup(); #endif + return 0; } diff --git a/schedule_timers/c/schedule_timers_c.slsrc.html b/schedule_timers/c/schedule_timers_c.slsrc.html index 71245cc..992227c 100644 --- a/schedule_timers/c/schedule_timers_c.slsrc.html +++ b/schedule_timers/c/schedule_timers_c.slsrc.html @@ -84,6 +84,7 @@ 00066 00067 00068 +00069 /* Code Disclaimer? */ #include <stdio.h> @@ -119,7 +120,7 @@ wait = 0; } - main() + int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ lbm_context_attr_t * cattr; /* Context attribute object */ @@ -150,6 +151,7 @@ /* Windows-specific cleanup overhead */ WSACleanup(); #endif + return 0; } diff --git a/seq_number_callback/c/seq_number_callback.c b/seq_number_callback/c/seq_number_callback.c index 89e54da..04ada0a 100644 --- a/seq_number_callback/c/seq_number_callback.c +++ b/seq_number_callback/c/seq_number_callback.c @@ -67,7 +67,7 @@ int ume_rcv_seqnum_ex(lbm_ume_rcv_recovery_info_ex_func_info_t *info, void *clie return 0; } -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ lbm_context_attr_t * cattr; /* Context attribute object */ @@ -119,4 +119,5 @@ main() /* Windows-specific cleanup overhead */ WSACleanup(); #endif + return 0; } /* main */ diff --git a/seq_number_callback/c/seq_number_callback_c.slsrc b/seq_number_callback/c/seq_number_callback_c.slsrc index 9d260bb..64c9a46 100644 --- a/seq_number_callback/c/seq_number_callback_c.slsrc +++ b/seq_number_callback/c/seq_number_callback_c.slsrc @@ -73,7 +73,7 @@ int ume_rcv_seqnum_ex(lbm_ume_rcv_recovery_info_ex_func_info_t *info, void *clie } /* =semlit,endblock,cb=*/ -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ lbm_context_attr_t * cattr; /* Context attribute object */ @@ -133,4 +133,5 @@ main() /* Windows-specific cleanup overhead */ WSACleanup(); #endif + return 0; } /* main */ diff --git a/seq_number_callback/c/seq_number_callback_c.slsrc.html b/seq_number_callback/c/seq_number_callback_c.slsrc.html index cac76ec..e508a72 100644 --- a/seq_number_callback/c/seq_number_callback_c.slsrc.html +++ b/seq_number_callback/c/seq_number_callback_c.slsrc.html @@ -138,6 +138,7 @@ 00120 00121 00122 +00123 /* seq_number_callback.c - http://ultramessaging.github.io/UMExamples */ #include <stdio.h> @@ -207,7 +208,7 @@ return 0; } - main() + int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ lbm_context_attr_t * cattr; /* Context attribute object */ @@ -259,6 +260,7 @@ /* Windows-specific cleanup overhead */ WSACleanup(); #endif + return 0; } /* main */ diff --git a/sequential_mode/c/sequential_mode.c b/sequential_mode/c/sequential_mode.c index 61c6d4a..3ba8de6 100644 --- a/sequential_mode/c/sequential_mode.c +++ b/sequential_mode/c/sequential_mode.c @@ -34,7 +34,7 @@ void *seq_thread(void *arg) } } -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_context_attr_t * cattr; /* pointer to context attribute object */ @@ -91,5 +91,6 @@ main() /* Wait forever */ while (1) { } + return 0; } diff --git a/sequential_mode/c/sequential_mode_c.slsrc b/sequential_mode/c/sequential_mode_c.slsrc index 1505185..c052279 100644 --- a/sequential_mode/c/sequential_mode_c.slsrc +++ b/sequential_mode/c/sequential_mode_c.slsrc @@ -38,7 +38,7 @@ void *seq_thread(void *arg) } /* =semlit,endblock,context_thread=*/ -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_context_attr_t * cattr; /* pointer to context attribute object */ @@ -101,5 +101,6 @@ main() /* Wait forever */ while (1) { } + return 0; } diff --git a/sequential_mode/c/sequential_mode_c.slsrc.html b/sequential_mode/c/sequential_mode_c.slsrc.html index d712b4f..bd3cec9 100644 --- a/sequential_mode/c/sequential_mode_c.slsrc.html +++ b/sequential_mode/c/sequential_mode_c.slsrc.html @@ -111,6 +111,7 @@ 00093 00094 00095 +00096 /* Code Disclaimer? */ #include <stdio.h> @@ -147,7 +148,7 @@ } } - main() + int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_context_attr_t * cattr; /* pointer to context attribute object */ @@ -204,6 +205,7 @@ /* Wait forever */ while (1) { } + return 0; } diff --git a/setting_attributes/c/setting_attributes.c b/setting_attributes/c/setting_attributes.c index fd49ccc..6d4ecf1 100644 --- a/setting_attributes/c/setting_attributes.c +++ b/setting_attributes/c/setting_attributes.c @@ -15,7 +15,7 @@ #include -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_topic_t *topic_1; /* pointer to topic object */ @@ -154,5 +154,6 @@ main() #if defined(_MSC_VER) WSACleanup(); #endif + return 0; } diff --git a/setting_attributes/c/setting_attributes_c.slsrc b/setting_attributes/c/setting_attributes_c.slsrc index a65b612..fd052bb 100644 --- a/setting_attributes/c/setting_attributes_c.slsrc +++ b/setting_attributes/c/setting_attributes_c.slsrc @@ -17,7 +17,7 @@ #include /* =semlit,endblock,includes=*/ -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_topic_t *topic_1; /* pointer to topic object */ @@ -192,5 +192,6 @@ main() #if defined(_MSC_VER) WSACleanup(); #endif + return 0; } diff --git a/setting_attributes/c/setting_attributes_c.slsrc.html b/setting_attributes/c/setting_attributes_c.slsrc.html index cf31618..13d3008 100644 --- a/setting_attributes/c/setting_attributes_c.slsrc.html +++ b/setting_attributes/c/setting_attributes_c.slsrc.html @@ -174,6 +174,7 @@ 00156 00157 00158 +00159 /* Example on setting Ultra Messaging attributes */ #include <stdio.h> @@ -191,7 +192,7 @@ #include <lbm/lbm.h> - main() + int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_topic_t *topic_1; /* pointer to topic object */ @@ -330,6 +331,7 @@ #if defined(_MSC_VER) WSACleanup(); #endif + return 0; } diff --git a/source_create/c/source_create_c.slsrc b/source_create/c/source_create_c.slsrc index 03ef0ad..60bb422 100644 --- a/source_create/c/source_create_c.slsrc +++ b/source_create/c/source_create_c.slsrc @@ -17,7 +17,7 @@ #include /* =semlit,endblock,includes=*/ -main() +int main(int argc, char **argv) { /* =semlit,block,variables=*/ lbm_context_t *ctx; /* Context object */ @@ -101,5 +101,6 @@ main() #if defined(_MSC_VER) WSACleanup(); #endif + return 0; } diff --git a/source_notify_callbacks/c/source_notify_callbacks.c b/source_notify_callbacks/c/source_notify_callbacks.c index 0c8712f..84df90a 100644 --- a/source_notify_callbacks/c/source_notify_callbacks.c +++ b/source_notify_callbacks/c/source_notify_callbacks.c @@ -13,6 +13,10 @@ #endif #include +typedef struct source_state_s { + int msgs_rcvd; /* We want to track message count from each source sending to the topic. */ +} source_state_t; + /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ if ((err) < 0) { \ @@ -22,14 +26,19 @@ } \ } while (0) -int new_src_notification_callback(const char *source_name, void *clientd) +void *new_src_notification_callback(const char *source_name, void *clientd) { + source_state_t *source_state = (source_state_t *)malloc(sizeof(source_state_t)); + source_state->msgs_rcvd = 0; + printf("Delivery Controller Created: %s\n", source_name); - return 0; + return source_state; /* This will be available in the receive callback as msg->source_clientd. */ } int src_delete_notification_callback(const char *source_name, void *clientd, void* src_clientd ) { + free(src_clientd); /* This was created by new_src_notification_callback() */ + printf("Delivery Controller Deleted: %s\n", source_name); return 0; } @@ -38,8 +47,13 @@ int src_delete_notification_callback(const char *source_name, void *clientd, voi int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { int err; + source_state_t *source_state = (source_state_t *)msg->source_clientd; switch (msg->type) { + case LBM_MSG_DATA: + source_state->msgs_rcvd ++; + printf("[%s][%s], Received message %d\n", msg->topic_name, msg->source, source_state->msgs_rcvd); + break; case LBM_MSG_BOS: printf("[%s][%s], Beginning of Transport Session\n", msg->topic_name, msg->source); break; @@ -54,7 +68,7 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) return 0; } -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ lbm_context_attr_t * cattr; /* Context attribute object */ @@ -107,4 +121,5 @@ main() /* Windows-specific cleanup overhead */ WSACleanup(); #endif + return 0; } /* main */ diff --git a/source_notify_callbacks/c/source_notify_callbacks.sldoc b/source_notify_callbacks/c/source_notify_callbacks.sldoc index fdabebe..4391a5c 100644 --- a/source_notify_callbacks/c/source_notify_callbacks.sldoc +++ b/source_notify_callbacks/c/source_notify_callbacks.sldoc @@ -12,11 +12,18 @@

Program explanation: source_notify_callbacks.c

+

Per-source State Information

+

As new sources are discovered for the receiver, the user wants to create and maintain some state information + associated with that source. In this simple example, just keep a per-source count of messages received.

+ =semlit,insert,state=

Delivery Controller Create Callback

Here the user callback for the delivery controller being created is defined. This function will execute every time a source is detected (when a source's topic advertisement is received by the receiver's context) that the - receiver is interested in. This callback will execute before a BOS would because BOS required data on the transport - to be received, unlike this function which just requires a TIR on an interested source.

+ receiver is interested in. + UM expects the function to return a pointer to the state information, which + will subsequently be passed to the receive callback as msg->source_clientd. + This callback will execute before a BOS would because BOS required data on the transport + to be received, unlike this function which just requires a TIR on an interested source.

=semlit,insert,create_cb=

Delivery Controller Delete Callback

This is the user callback for when the delivery controller is deleted. A delivery controller would be deleted diff --git a/source_notify_callbacks/c/source_notify_callbacks.sldoc.html b/source_notify_callbacks/c/source_notify_callbacks.sldoc.html index e28f56c..f86a869 100644 --- a/source_notify_callbacks/c/source_notify_callbacks.sldoc.html +++ b/source_notify_callbacks/c/source_notify_callbacks.sldoc.html @@ -7,7 +7,8 @@ Example index

Receiver Source Notification Callbacks (Create and Delete)

This example demonstrates how to configure and code the callbacks for when a receiver creates and deletes a - delivery controller for a specific source.

+ delivery controller for a specific source. This is typically done in support of maintaining per-source + state information.

Like many other callback function in UM, the source notification is configured via a receiver attribute, +

+00016  typedef struct source_state_s {
+00017    int msgs_rcvd;  /* We want to track message count from each source sending to the topic. */
+00018  } source_state_t;
+
+ +

Delivery Controller Create Callback

Here the user callback for the delivery controller being created is defined. This function will execute every time a source is detected (when a source's topic advertisement is received by the receiver's context) that the - receiver is interested in. This callback will execute before a BOS would because BOS required data on the transport - to be received, unlike this function which just requires a TIR on an interested source.

+ receiver is interested in. + UM expects the function to return a pointer to the state information, which + will subsequently be passed to the receive callback as msg->source_clientd. + This callback will execute before a BOS would because BOS required data on the transport + to be received, unlike this function which just requires a TIR on an interested source.

-00025  int new_src_notification_callback(const char *source_name, void *clientd)
-00026  {
-00027          printf("Delivery Controller Created: %s\n", source_name);
-00028          return 0;
-00029  }
+00029  void *new_src_notification_callback(const char *source_name, void *clientd)
+00030  {
+00031          source_state_t *source_state = (source_state_t *)malloc(sizeof(source_state_t));
+00032          source_state->msgs_rcvd = 0;
+00033  
+00034          printf("Delivery Controller Created: %s\n", source_name);
+00035          return source_state;  /* This will be available in the receive callback as msg->source_clientd. */
+00036  }
 
@@ -65,11 +82,13 @@

Delivery Controller Delete Callback

to rely on this callback versus EOS, because this callback is guaranteed if no data has been received for the topic.

-00031  int src_delete_notification_callback(const char *source_name, void *clientd, void* src_clientd )
-00032  {
-00033          printf("Delivery Controller Deleted: %s\n", source_name);
-00034          return 0;
-00035  }
+00038  int src_delete_notification_callback(const char *source_name, void *clientd, void* src_clientd )
+00039  {
+00040          free(src_clientd);  /* This was created by new_src_notification_callback() */
+00041  
+00042          printf("Delivery Controller Deleted: %s\n", source_name);
+00043          return 0;
+00044  }
 
@@ -77,24 +96,29 @@

Standard Receive Callback

This is the standard receiver callback where messages are processed, as well as events like BOS and EOS

-00038  int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd)
-00039  {
-00040          int err;
-00041  
-00042          switch (msg->type) {
-00043          case LBM_MSG_BOS:
-00044                  printf("[%s][%s], Beginning of Transport Session\n", msg->topic_name, msg->source);
-00045                  break;
-00046          case LBM_MSG_EOS:
-00047                  printf("[%s][%s], End of Transport Session\n", msg->topic_name, msg->source);
-00048                  break;
-00049          default:
-00050                  printf("Other event, type=%x\n", msg->type);
-00051                  break;
-00052          }
-00053  
-00054          return 0;
-00055  }
+00047  int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd)
+00048  {
+00049          int err;
+00050          source_state_t *source_state = (source_state_t *)msg->source_clientd;
+00051  
+00052          switch (msg->type) {
+00053          case LBM_MSG_DATA:
+00054                  source_state->msgs_rcvd ++;
+00055                  printf("[%s][%s], Received message %d\n", msg->topic_name, msg->source, source_state->msgs_rcvd);
+00056                  break;
+00057          case LBM_MSG_BOS:
+00058                  printf("[%s][%s], Beginning of Transport Session\n", msg->topic_name, msg->source);
+00059                  break;
+00060          case LBM_MSG_EOS:
+00061                  printf("[%s][%s], End of Transport Session\n", msg->topic_name, msg->source);
+00062                  break;
+00063          default:
+00064                  printf("Other event, type=%x\n", msg->type);
+00065                  break;
+00066          }
+00067  
+00068          return 0;
+00069  }
 
@@ -112,7 +136,7 @@

Declare Notify Structure

must be used to set the user callbacks which have been defined above.

-00064          lbm_rcv_src_notification_func_t srccb;  /* Source notify callback structure */
+00078          lbm_rcv_src_notification_func_t srccb;  /* Source notify callback structure */
 
@@ -121,11 +145,11 @@

Set the Callbacks and Configure Parameter

the API to configure the paramter:

-00086          srccb.create_func = new_src_notification_callback;
-00087          srccb.delete_func = src_delete_notification_callback;
-00088  
-00089          err = lbm_rcv_topic_attr_setopt(rattr, "source_notification_function", &srccb, sizeof(srccb));
-00090          EX_LBM_CHK(err);
+00100          srccb.create_func = new_src_notification_callback;
+00101          srccb.delete_func = src_delete_notification_callback;
+00102  
+00103          err = lbm_rcv_topic_attr_setopt(rattr, "source_notification_function", &srccb, sizeof(srccb));
+00104          EX_LBM_CHK(err);
 
@@ -154,16 +178,16 @@

Windows Only

Windows applications must initialize the Winsock library to utilize sockets.

-00067  #if defined(_WIN32)
-00068          /* windows-specific code */
-00069          WSADATA wsadata;
-00070          int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata);
-00071          if (wsStat != 0)
-00072          {
-00073                  printf("line %d: wsStat=%d\n",__LINE__,wsStat);
-00074                  exit(1);
-00075          }
-00076  #endif
+00081  #if defined(_WIN32)
+00082          /* windows-specific code */
+00083          WSADATA wsadata;
+00084          int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata);
+00085          if (wsStat != 0)
+00086          {
+00087                  printf("line %d: wsStat=%d\n",__LINE__,wsStat);
+00088                  exit(1);
+00089          }
+00090  #endif
 
diff --git a/source_notify_callbacks/c/source_notify_callbacks_c.slsrc b/source_notify_callbacks/c/source_notify_callbacks_c.slsrc index 7e42520..3fe959e 100644 --- a/source_notify_callbacks/c/source_notify_callbacks_c.slsrc +++ b/source_notify_callbacks/c/source_notify_callbacks_c.slsrc @@ -15,6 +15,12 @@ #include /* =semlit,endblock,includes=*/ +/* =semlit,block,state=*/ +typedef struct source_state_s { + int msgs_rcvd; /* We want to track message count from each source sending to the topic. */ +} source_state_t; +/* =semlit,endblock,state=*/ + /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ if ((err) < 0) { \ @@ -25,16 +31,21 @@ } while (0) /* =semlit,block,create_cb=*/ -int new_src_notification_callback(const char *source_name, void *clientd) +void *new_src_notification_callback(const char *source_name, void *clientd) { + source_state_t *source_state = (source_state_t *)malloc(sizeof(source_state_t)); + source_state->msgs_rcvd = 0; + printf("Delivery Controller Created: %s\n", source_name); - return 0; + return source_state; /* This will be available in the receive callback as msg->source_clientd. */ } /* =semlit,endblock,create_cb=*/ /* =semlit,block,delete_cb=*/ int src_delete_notification_callback(const char *source_name, void *clientd, void* src_clientd ) { + free(src_clientd); /* This was created by new_src_notification_callback() */ + printf("Delivery Controller Deleted: %s\n", source_name); return 0; } @@ -45,8 +56,13 @@ int src_delete_notification_callback(const char *source_name, void *clientd, voi int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { int err; + source_state_t *source_state = (source_state_t *)msg->source_clientd; switch (msg->type) { + case LBM_MSG_DATA: + source_state->msgs_rcvd ++; + printf("[%s][%s], Received message %d\n", msg->topic_name, msg->source, source_state->msgs_rcvd); + break; case LBM_MSG_BOS: printf("[%s][%s], Beginning of Transport Session\n", msg->topic_name, msg->source); break; @@ -62,7 +78,7 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) } /* =semlit,endblock,receive_cb=*/ -main() +int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ lbm_context_attr_t * cattr; /* Context attribute object */ @@ -121,4 +137,5 @@ main() /* Windows-specific cleanup overhead */ WSACleanup(); #endif + return 0; } /* main */ diff --git a/source_notify_callbacks/c/source_notify_callbacks_c.slsrc.html b/source_notify_callbacks/c/source_notify_callbacks_c.slsrc.html index b53bc88..9b56dd4 100644 --- a/source_notify_callbacks/c/source_notify_callbacks_c.slsrc.html +++ b/source_notify_callbacks/c/source_notify_callbacks_c.slsrc.html @@ -31,37 +31,37 @@ 00013 00014 00015 -00016 -00017 -00018 +00016 +00017 +00018 00019 00020 00021 00022 00023 00024 -00025 -00026 -00027 -00028 +00025 +00026 +00027 +00028 00029 -00030 -00031 -00032 -00033 -00034 -00035 -00036 +00030 +00031 +00032 +00033 +00034 +00035 +00036 00037 -00038 -00039 -00040 -00041 -00042 -00043 -00044 -00045 -00046 +00038 +00039 +00040 +00041 +00042 +00043 +00044 +00045 +00046 00047 00048 00049 @@ -71,41 +71,41 @@ 00053 00054 00055 -00056 -00057 -00058 -00059 -00060 -00061 -00062 -00063 -00064 -00065 -00066 -00067 -00068 -00069 -00070 -00071 -00072 -00073 -00074 -00075 -00076 +00056 +00057 +00058 +00059 +00060 +00061 +00062 +00063 +00064 +00065 +00066 +00067 +00068 +00069 +00070 +00071 +00072 +00073 +00074 +00075 +00076 00077 -00078 +00078 00079 00080 -00081 -00082 -00083 -00084 -00085 -00086 -00087 -00088 -00089 -00090 +00081 +00082 +00083 +00084 +00085 +00086 +00087 +00088 +00089 +00090 00091 00092 00093 @@ -115,17 +115,32 @@ 00097 00098 00099 -00100 -00101 -00102 -00103 -00104 +00100 +00101 +00102 +00103 +00104 00105 00106 00107 00108 00109 00110 +00111 +00112 +00113 +00114 +00115 +00116 +00117 +00118 +00119 +00120 +00121 +00122 +00123 +00124 +00125 /* source_notify_callback.c - http://ultramessaging.github.io/UMExamples */ #include <stdio.h> @@ -141,6 +156,10 @@ #endif #include <lbm/lbm.h> + typedef struct source_state_s { + int msgs_rcvd; /* We want to track message count from each source sending to the topic. */ + } source_state_t; + /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ if ((err) < 0) { \ @@ -150,14 +169,19 @@ } \ } while (0) - int new_src_notification_callback(const char *source_name, void *clientd) + void *new_src_notification_callback(const char *source_name, void *clientd) { + source_state_t *source_state = (source_state_t *)malloc(sizeof(source_state_t)); + source_state->msgs_rcvd = 0; + printf("Delivery Controller Created: %s\n", source_name); - return 0; + return source_state; /* This will be available in the receive callback as msg->source_clientd. */ } int src_delete_notification_callback(const char *source_name, void *clientd, void* src_clientd ) { + free(src_clientd); /* This was created by new_src_notification_callback() */ + printf("Delivery Controller Deleted: %s\n", source_name); return 0; } @@ -166,8 +190,13 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { int err; + source_state_t *source_state = (source_state_t *)msg->source_clientd; switch (msg->type) { + case LBM_MSG_DATA: + source_state->msgs_rcvd ++; + printf("[%s][%s], Received message %d\n", msg->topic_name, msg->source, source_state->msgs_rcvd); + break; case LBM_MSG_BOS: printf("[%s][%s], Beginning of Transport Session\n", msg->topic_name, msg->source); break; @@ -182,7 +211,7 @@ return 0; } - main() + int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ lbm_context_attr_t * cattr; /* Context attribute object */ @@ -235,6 +264,7 @@ /* Windows-specific cleanup overhead */ WSACleanup(); #endif + return 0; } /* main */ diff --git a/source_notify_callbacks/dotnet/source_notify_callbacks.sldoc.html b/source_notify_callbacks/dotnet/source_notify_callbacks.sldoc.html index d51fa29..dc3a112 100644 --- a/source_notify_callbacks/dotnet/source_notify_callbacks.sldoc.html +++ b/source_notify_callbacks/dotnet/source_notify_callbacks.sldoc.html @@ -7,7 +7,8 @@ Example index

Receiver Source Notification Callbacks (Create and Delete)

This example demonstrates how to configure and code the callbacks for when a receiver creates and deletes a - delivery controller for a specific source.

+ delivery controller for a specific source. This is typically done in support of maintaining per-source + state information.

Like many other callback function in UM, the source notification is configured via a receiver attribute, Example index

Receiver Source Notification Callbacks (Create and Delete)

This example demonstrates how to configure and code the callbacks for when a receiver creates and deletes a - delivery controller for a specific source.

+ delivery controller for a specific source. This is typically done in support of maintaining per-source + state information.

Like many other callback function in UM, the source notification is configured via a receiver attribute, =semlit,tooltip,../../tooltips/receiver_source_notification_function.txt,source_notification_function=which must be set programatically so that the appropriate function pointers can be provided.

@@ -19,5 +20,4 @@ to help debug networking issues. However, this callback is not great at telling the application that a specific topic ready to start receiving messages. Instead, the application can use the source_notification_callback which is demonstrated in this sample application. The source_notification_callback can enable a user callback to be executed - when delivery controller is created for a topic and a separate callback for when a delivery controller is deleted. -

+ when delivery controller is created for a topic and a separate callback for when a delivery controller is deleted.

diff --git a/source_notify_callbacks/java/source_notify_callbacks.sldoc.html b/source_notify_callbacks/java/source_notify_callbacks.sldoc.html index 2ff05a8..5b3227d 100644 --- a/source_notify_callbacks/java/source_notify_callbacks.sldoc.html +++ b/source_notify_callbacks/java/source_notify_callbacks.sldoc.html @@ -7,7 +7,8 @@ Example index

Receiver Source Notification Callbacks (Create and Delete)

This example demonstrates how to configure and code the callbacks for when a receiver creates and deletes a - delivery controller for a specific source.

+ delivery controller for a specific source. This is typically done in support of maintaining per-source + state information.

Like many other callback function in UM, the source notification is configured via a receiver attribute, #include <stdio.h> @@ -299,7 +300,7 @@ return 0; } - main() + int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ lbm_context_attr_t * cattr; /* Context attribute object */ @@ -341,6 +342,7 @@ /* Windows-specific cleanup overhead */ WSACleanup(); #endif + return 0; } /* main */ diff --git a/ump_src_failover/c/ump_src_failover.c b/ump_src_failover/c/ump_src_failover.c index 9ebb980..5bd328b 100644 --- a/ump_src_failover/c/ump_src_failover.c +++ b/ump_src_failover/c/ump_src_failover.c @@ -41,45 +41,45 @@ typedef enum {NOT_INIT, INIT, READY, UNRESP} state_type_e; typedef enum {PRIMARY, BACKUP} mode_type_e; typedef struct app_src_s { - lbm_context_t *ctx; - lbm_src_t *src; - state_type_e state; - mode_type_e mode; + lbm_context_t *ctx; + lbm_src_t *src; + state_type_e state; + mode_type_e mode; } app_src_s; /* Source event handler callback (passed into lbm_src_create()) */ int handle_src_event(lbm_src_t *src, int event, void *ed, void *cd) { - struct app_src_s *app_src = (struct app_src_s *)cd; + struct app_src_s *app_src = (struct app_src_s *)cd; switch (event) { - /* Success event provided only for printing purposes */ - case LBM_SRC_EVENT_UME_REGISTRATION_SUCCESS_EX: - { - lbm_src_event_ume_registration_ex_t *reg = (lbm_src_event_ume_registration_ex_t *)ed; - printf("UME store %u: %s registration success.\n", reg->store_index, reg->store); - break; - } + /* Success event provided only for printing purposes */ + case LBM_SRC_EVENT_UME_REGISTRATION_SUCCESS_EX: + { + lbm_src_event_ume_registration_ex_t *reg = (lbm_src_event_ume_registration_ex_t *)ed; + printf("UME store %u: %s registration success.\n", reg->store_index, reg->store); + break; + } case LBM_SRC_EVENT_UME_REGISTRATION_COMPLETE_EX: - { - lbm_src_event_ume_registration_complete_ex_t *reg = (lbm_src_event_ume_registration_complete_ex_t *)ed; - - printf("UME registration complete. SQN %x.\n", reg->sequence_number); - - app_src->state = READY; - break; - } - case LBM_SRC_EVENT_UME_STORE_UNRESPONSIVE: - { - const char *infostr = (const char *)ed; - - printf("UME store: %s\n", infostr); - if (strstr(infostr, "quorum lost") != NULL) - app_src->state = UNRESP; - break; - } - } - - return 0; + { + lbm_src_event_ume_registration_complete_ex_t *reg = (lbm_src_event_ume_registration_complete_ex_t *)ed; + + printf("UME registration complete. SQN %x.\n", reg->sequence_number); + + app_src->state = READY; + break; + } + case LBM_SRC_EVENT_UME_STORE_UNRESPONSIVE: + { + const char *infostr = (const char *)ed; + + printf("UME store: %s\n", infostr); + if (strstr(infostr, "quorum lost") != NULL) + app_src->state = UNRESP; + break; + } + } + + return 0; } int init_src(app_src_s *app_src) @@ -91,21 +91,21 @@ int init_src(app_src_s *app_src) err = lbm_src_topic_attr_create(&tattr); EX_LBM_CHK(err); - err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_CLEAR_STORE_CONFIG); - EX_LBM_CHK(err); + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_CLEAR_STORE_CONFIG); + EX_LBM_CHK(err); /* Assuming there are stores running on the localhost */ - if (app_src->mode == PRIMARY) - err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_PRIMARY_STORE); - else - err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_SECONDARY_STORE); + if (app_src->mode == PRIMARY) + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_PRIMARY_STORE); + else + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_SECONDARY_STORE); EX_LBM_CHK(err); - if (app_src->mode == PRIMARY) - err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_PRIMARY_SESSION_ID); - else - err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_SECONDARY_SESSION_ID); - EX_LBM_CHK(err); + if (app_src->mode == PRIMARY) + err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_PRIMARY_SESSION_ID); + else + err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_SECONDARY_SESSION_ID); + EX_LBM_CHK(err); /* Need to set store behavior to Quorum-Consensus */ err = lbm_src_topic_attr_str_setopt(tattr, "ume_store_behavior", "qc"); @@ -117,37 +117,37 @@ int init_src(app_src_s *app_src) err = lbm_src_create(&(app_src->src), app_src->ctx, topic, handle_src_event, app_src, NULL); EX_LBM_CHK(err); - app_src->state = INIT; + app_src->state = INIT; } void failover_app_src(app_src_s *app_src) { - int err; /* Used for checking API return codes */ - - /* Delete the source */ - err = lbm_src_delete(app_src->src); - EX_LBM_CHK(err); - - app_src->src = NULL; - app_src->state = NOT_INIT; - app_src->mode = BACKUP; + int err; /* Used for checking API return codes */ + + /* Delete the source */ + err = lbm_src_delete(app_src->src); + EX_LBM_CHK(err); + + app_src->src = NULL; + app_src->state = NOT_INIT; + app_src->mode = BACKUP; } /* Provided simply for printing the state name */ const char* source_state(app_src_s *app_src) { - switch (app_src->state) - { - case NOT_INIT: return "NOT_INIT"; - case INIT: return "INIT"; - case READY: return "READY"; - case UNRESP: return "UNRESP"; - } + switch (app_src->state) + { + case NOT_INIT: return "NOT_INIT"; + case INIT: return "INIT"; + case READY: return "READY"; + case UNRESP: return "UNRESP"; + } } -main() +int main(int argc, char **argv) { - app_src_s app_src; /* App structure to track source */ + app_src_s app_src; /* App structure to track source */ lbm_context_t *ctx; /* Context object */ lbm_context_attr_t * cattr; /* Context attribute object */ int err; /* Used for checking API return codes */ @@ -163,45 +163,46 @@ main() } #endif - err = lbm_context_attr_create(&cattr); - EX_LBM_CHK(err); + err = lbm_context_attr_create(&cattr); + EX_LBM_CHK(err); - err = lbm_context_create(&ctx, cattr, NULL, NULL); - EX_LBM_CHK(err); + err = lbm_context_create(&ctx, cattr, NULL, NULL); + EX_LBM_CHK(err); - app_src.state = NOT_INIT; - app_src.mode = PRIMARY; - app_src.ctx = ctx; + app_src.state = NOT_INIT; + app_src.mode = PRIMARY; + app_src.ctx = ctx; while(1) { - /* Initialize the source if we're not initialized */ - if (app_src.state == NOT_INIT) - init_src(&app_src); - - if (app_src.state == READY) - { - if (lbm_src_send(app_src.src, "test", 4, LBM_SRC_NONBLOCK) == LBM_FAILURE) - { - /* Assume EWOULDBLOCK and wait */ - SLEEP_SEC(1); - } - } - else - { - /* Print a warning that the source is not ready and sleep */ - printf("Source cannot send: %d. Source State: %s\n", lbm_errnum(), source_state(&app_src)); - if (app_src.state == UNRESP && app_src.mode == PRIMARY) - { - printf("Primary store unresponsive, failing over to backup\n"); - failover_app_src(&app_src); - } - else if (app_src.state == UNRESP && app_src.mode == BACKUP) - { - printf("Backup store unresponsive. Exiting\n"); - exit(1); - } - SLEEP_SEC(1); - } + /* Initialize the source if we're not initialized */ + if (app_src.state == NOT_INIT) + init_src(&app_src); + + if (app_src.state == READY) + { + if (lbm_src_send(app_src.src, "test", 4, LBM_SRC_NONBLOCK) == LBM_FAILURE) + { + /* Assume EWOULDBLOCK and wait */ + SLEEP_SEC(1); + } + } + else + { + /* Print a warning that the source is not ready and sleep */ + printf("Source cannot send: %d. Source State: %s\n", lbm_errnum(), source_state(&app_src)); + if (app_src.state == UNRESP && app_src.mode == PRIMARY) + { + printf("Primary store unresponsive, failing over to backup\n"); + failover_app_src(&app_src); + } + else if (app_src.state == UNRESP && app_src.mode == BACKUP) + { + printf("Backup store unresponsive. Exiting\n"); + exit(1); + } + SLEEP_SEC(1); + } } + return 0; } diff --git a/ump_src_failover/c/ump_src_failover.sldoc.html b/ump_src_failover/c/ump_src_failover.sldoc.html index 6e79fb5..edab874 100644 --- a/ump_src_failover/c/ump_src_failover.sldoc.html +++ b/ump_src_failover/c/ump_src_failover.sldoc.html @@ -125,10 +125,10 @@

Define a Custom Source Object

00041 typedef enum {NOT_INIT, INIT, READY, UNRESP} state_type_e; 00042 typedef enum {PRIMARY, BACKUP} mode_type_e; 00043 typedef struct app_src_s { -00044 lbm_context_t *ctx; -00045 lbm_src_t *src; -00046 state_type_e state; -00047 mode_type_e mode; +00044 lbm_context_t *ctx; +00045 lbm_src_t *src; +00046 state_type_e state; +00047 mode_type_e mode; 00048 } app_src_s; @@ -137,11 +137,11 @@

Create the Context

Standard UM code to initialize and create an LBM context:

-00166      err = lbm_context_attr_create(&cattr);
-00167      EX_LBM_CHK(err);
+00166          err = lbm_context_attr_create(&cattr);
+00167          EX_LBM_CHK(err);
 00168  
-00169      err = lbm_context_create(&ctx, cattr, NULL, NULL);
-00170      EX_LBM_CHK(err);
+00169          err = lbm_context_create(&ctx, cattr, NULL, NULL);
+00170          EX_LBM_CHK(err);
 
@@ -151,9 +151,9 @@

Initializing the Customer Source Object

created within it:

-00172      app_src.state = NOT_INIT;
-00173      app_src.mode = PRIMARY;
-00174      app_src.ctx = ctx;
+00172          app_src.state = NOT_INIT;
+00173          app_src.mode = PRIMARY;
+00174          app_src.ctx = ctx;
 
@@ -162,8 +162,8 @@

Configuring the Stores and Creating the Source

the loop, the application intializes/creates a source:

-00179          if (app_src.state == NOT_INIT)
-00180              init_src(&app_src);
+00179                  if (app_src.state == NOT_INIT)
+00180                          init_src(&app_src);
 
@@ -192,8 +192,8 @@

Configuring the Stores and Creating the Source

00091 err = lbm_src_topic_attr_create(&tattr); 00092 EX_LBM_CHK(err); 00093 -00094 err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_CLEAR_STORE_CONFIG); -00095 EX_LBM_CHK(err); +00094 err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_CLEAR_STORE_CONFIG); +00095 EX_LBM_CHK(err); @@ -201,17 +201,17 @@

Configuring the Stores and Creating the Source

initialized to PRIMARY, so it'll use the primary stores and associated SessionID:

-00098      if (app_src->mode == PRIMARY) 
-00099              err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_PRIMARY_STORE);
-00100      else
-00101          err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_SECONDARY_STORE);
+00098          if (app_src->mode == PRIMARY) 
+00099                  err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_PRIMARY_STORE);
+00100          else
+00101                  err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_SECONDARY_STORE);
 00102          EX_LBM_CHK(err);
 00103  
-00104      if (app_src->mode == PRIMARY)
-00105          err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_PRIMARY_SESSION_ID);
-00106      else
-00107          err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_SECONDARY_SESSION_ID);
-00108      EX_LBM_CHK(err);
+00104          if (app_src->mode == PRIMARY)
+00105                  err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_PRIMARY_SESSION_ID);
+00106          else
+00107                  err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_SECONDARY_SESSION_ID);
+00108          EX_LBM_CHK(err);
 
@@ -237,14 +237,14 @@

Handling Source Events / Updating Source State

 00062          case LBM_SRC_EVENT_UME_REGISTRATION_COMPLETE_EX:
-00063      {
-00064          lbm_src_event_ume_registration_complete_ex_t *reg = (lbm_src_event_ume_registration_complete_ex_t *)ed;
+00063          {
+00064                  lbm_src_event_ume_registration_complete_ex_t *reg = (lbm_src_event_ume_registration_complete_ex_t *)ed;
 00065  
-00066          printf("UME registration complete. SQN %x.\n", reg->sequence_number);
+00066                  printf("UME registration complete. SQN %x.\n", reg->sequence_number);
 00067  
-00068          app_src->state = READY;
-00069          break;
-00070      }
+00068                  app_src->state = READY;
+00069                  break;
+00070          }
 
@@ -253,15 +253,15 @@

Handling Source Events / Updating Source State

is lost, the source state must be updated to note this change because it can no longer send messages:

-00071      case LBM_SRC_EVENT_UME_STORE_UNRESPONSIVE:
-00072      {
-00073          const char *infostr = (const char *)ed;
-00074          
-00075          printf("UME store: %s\n", infostr);
-00076          if (strstr(infostr, "quorum lost") != NULL)
-00077              app_src->state = UNRESP;
-00078          break;
-00079      }
+00071          case LBM_SRC_EVENT_UME_STORE_UNRESPONSIVE:
+00072          {
+00073                  const char *infostr = (const char *)ed;
+00074                  
+00075                  printf("UME store: %s\n", infostr);
+00076                  if (strstr(infostr, "quorum lost") != NULL)
+00077                          app_src->state = UNRESP;
+00078                  break;
+00079          }
 
@@ -283,11 +283,11 @@

Automatic Failover

So here is the sample application failing over once the main loop has detected the state as UNRESP:

-00194              if (app_src.state == UNRESP && app_src.mode == PRIMARY)
-00195              {
-00196                  printf("Primary store unresponsive, failing over to backup\n");
-00197                  failover_app_src(&app_src);
-00198              }
+00194                          if (app_src.state == UNRESP && app_src.mode == PRIMARY)
+00195                          {
+00196                                  printf("Primary store unresponsive, failing over to backup\n");
+00197                                  failover_app_src(&app_src);
+00198                          }
 
@@ -300,28 +300,28 @@

Delete the Source and Reset State

First, the source gets deleted:

-00128      err = lbm_src_delete(app_src->src);
-00129      EX_LBM_CHK(err);
+00128          err = lbm_src_delete(app_src->src);
+00129          EX_LBM_CHK(err);
 

Then the state gets updated to NOT_INIT, and the mode set to backup so the backup stores can be configured upon initialization:

-00131      app_src->src = NULL;
-00132      app_src->state = NOT_INIT;
-00133      app_src->mode = BACKUP;
+00131          app_src->src = NULL;
+00132          app_src->state = NOT_INIT;
+00133          app_src->mode = BACKUP;
 

In the event that the backup store goes unresponsive, the sample application is simply coded to exit at this point:

-00199              else if (app_src.state == UNRESP && app_src.mode == BACKUP)
-00200              {
-00201                  printf("Backup store unresponsive. Exiting\n");
-00202                  exit(1);
-00203              }
+00199                          else if (app_src.state == UNRESP && app_src.mode == BACKUP)
+00200                          {
+00201                                  printf("Backup store unresponsive. Exiting\n");
+00202                                  exit(1);
+00203                          }
 
diff --git a/ump_src_failover/c/ump_src_failover_c.slsrc b/ump_src_failover/c/ump_src_failover_c.slsrc index baf56e7..396a414 100644 --- a/ump_src_failover/c/ump_src_failover_c.slsrc +++ b/ump_src_failover/c/ump_src_failover_c.slsrc @@ -52,54 +52,54 @@ typedef enum {NOT_INIT, INIT, READY, UNRESP} state_type_e; typedef enum {PRIMARY, BACKUP} mode_type_e; typedef struct app_src_s { - lbm_context_t *ctx; - lbm_src_t *src; - state_type_e state; - mode_type_e mode; + lbm_context_t *ctx; + lbm_src_t *src; + state_type_e state; + mode_type_e mode; } app_src_s; /* =semlit,endblock,app_src_struct=*/ /* Source event handler callback (passed into lbm_src_create()) */ int handle_src_event(lbm_src_t *src, int event, void *ed, void *cd) { - struct app_src_s *app_src = (struct app_src_s *)cd; + struct app_src_s *app_src = (struct app_src_s *)cd; switch (event) { - /* Success event provided only for printing purposes */ - case LBM_SRC_EVENT_UME_REGISTRATION_SUCCESS_EX: - { - lbm_src_event_ume_registration_ex_t *reg = (lbm_src_event_ume_registration_ex_t *)ed; - printf("UME store %u: %s registration success.\n", reg->store_index, reg->store); - break; - } - /* =semlit,block,reg_complete=*/ + /* Success event provided only for printing purposes */ + case LBM_SRC_EVENT_UME_REGISTRATION_SUCCESS_EX: + { + lbm_src_event_ume_registration_ex_t *reg = (lbm_src_event_ume_registration_ex_t *)ed; + printf("UME store %u: %s registration success.\n", reg->store_index, reg->store); + break; + } + /* =semlit,block,reg_complete=*/ case LBM_SRC_EVENT_UME_REGISTRATION_COMPLETE_EX: - { - lbm_src_event_ume_registration_complete_ex_t *reg = (lbm_src_event_ume_registration_complete_ex_t *)ed; + { + lbm_src_event_ume_registration_complete_ex_t *reg = (lbm_src_event_ume_registration_complete_ex_t *)ed; - printf("UME registration complete. SQN %x.\n", reg->sequence_number); + printf("UME registration complete. SQN %x.\n", reg->sequence_number); - /* =semlit,block,update_state_ready=*/ - app_src->state = READY; - /* =semlit,endblock,update_state_ready=*/ - break; - } - /* =semlit,endblock,reg_complete=*/ - /* =semlit,block,unresponsive=*/ - case LBM_SRC_EVENT_UME_STORE_UNRESPONSIVE: - { - const char *infostr = (const char *)ed; - - printf("UME store: %s\n", infostr); - /* =semlit,block,update_state_UNRESP=*/ - if (strstr(infostr, "quorum lost") != NULL) - app_src->state = UNRESP; - /* =semlit,endblock,update_state_UNRESP=*/ - break; - } - /* =semlit,endblock,unresponsive=*/ - } + /* =semlit,block,update_state_ready=*/ + app_src->state = READY; + /* =semlit,endblock,update_state_ready=*/ + break; + } + /* =semlit,endblock,reg_complete=*/ + /* =semlit,block,unresponsive=*/ + case LBM_SRC_EVENT_UME_STORE_UNRESPONSIVE: + { + const char *infostr = (const char *)ed; + + printf("UME store: %s\n", infostr); + /* =semlit,block,update_state_UNRESP=*/ + if (strstr(infostr, "quorum lost") != NULL) + app_src->state = UNRESP; + /* =semlit,endblock,update_state_UNRESP=*/ + break; + } + /* =semlit,endblock,unresponsive=*/ + } - return 0; + return 0; } int init_src(app_src_s *app_src) @@ -112,27 +112,27 @@ int init_src(app_src_s *app_src) err = lbm_src_topic_attr_create(&tattr); EX_LBM_CHK(err); - err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_CLEAR_STORE_CONFIG); - EX_LBM_CHK(err); - /* =semlit,endblock,init_source_attr=*/ + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_CLEAR_STORE_CONFIG); + EX_LBM_CHK(err); + /* =semlit,endblock,init_source_attr=*/ /* Assuming there are stores running on the localhost */ - /* =semlit,block,set_store=*/ - if (app_src->mode == PRIMARY) - err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_PRIMARY_STORE); - else - err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_SECONDARY_STORE); + /* =semlit,block,set_store=*/ + if (app_src->mode == PRIMARY) + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_PRIMARY_STORE); + else + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_SECONDARY_STORE); EX_LBM_CHK(err); - if (app_src->mode == PRIMARY) - err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_PRIMARY_SESSION_ID); - else - err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_SECONDARY_SESSION_ID); - EX_LBM_CHK(err); - /* =semlit,endblock,set_store=*/ + if (app_src->mode == PRIMARY) + err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_PRIMARY_SESSION_ID); + else + err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_SECONDARY_SESSION_ID); + EX_LBM_CHK(err); + /* =semlit,endblock,set_store=*/ /* Need to set store behavior to Quorum-Consensus */ - /* =semlit,block,complete_init=*/ + /* =semlit,block,complete_init=*/ err = lbm_src_topic_attr_str_setopt(tattr, "ume_store_behavior", "qc"); EX_LBM_CHK(err); @@ -143,46 +143,46 @@ int init_src(app_src_s *app_src) EX_LBM_CHK(err); /* =semlit,endblock,complete_init=*/ - /* =semlit,block,update_state_init=*/ - app_src->state = INIT; - /* =semlit,endblock,update_state_init=*/ + /* =semlit,block,update_state_init=*/ + app_src->state = INIT; + /* =semlit,endblock,update_state_init=*/ } void failover_app_src(app_src_s *app_src) { - int err; /* Used for checking API return codes */ - - /* Delete the source */ - /* =semlit,block,delete_src=*/ - err = lbm_src_delete(app_src->src); - EX_LBM_CHK(err); - /* =semlit,endblock,delete_src=*/ + int err; /* Used for checking API return codes */ + + /* Delete the source */ + /* =semlit,block,delete_src=*/ + err = lbm_src_delete(app_src->src); + EX_LBM_CHK(err); + /* =semlit,endblock,delete_src=*/ - /* =semlit,block,update_state_not_init=*/ - app_src->src = NULL; - app_src->state = NOT_INIT; - app_src->mode = BACKUP; - /* =semlit,endblock,update_state_not_init=*/ + /* =semlit,block,update_state_not_init=*/ + app_src->src = NULL; + app_src->state = NOT_INIT; + app_src->mode = BACKUP; + /* =semlit,endblock,update_state_not_init=*/ } /* Provided simply for printing the state name */ /* =semlit,block,print_state_helper=*/ const char* source_state(app_src_s *app_src) { - switch (app_src->state) - { - case NOT_INIT: return "NOT_INIT"; - case INIT: return "INIT"; - case READY: return "READY"; - case UNRESP: return "UNRESP"; - } + switch (app_src->state) + { + case NOT_INIT: return "NOT_INIT"; + case INIT: return "INIT"; + case READY: return "READY"; + case UNRESP: return "UNRESP"; + } } /* =semlit,endblock,print_state_helper=*/ -main() +int main(int argc, char **argv) { /* =semlit,block,variables=*/ - app_src_s app_src; /* App structure to track source */ + app_src_s app_src; /* App structure to track source */ lbm_context_t *ctx; /* Context object */ lbm_context_attr_t * cattr; /* Context attribute object */ int err; /* Used for checking API return codes */ @@ -200,58 +200,59 @@ main() #endif /* =semlit,block,init_create_context=*/ - err = lbm_context_attr_create(&cattr); - EX_LBM_CHK(err); + err = lbm_context_attr_create(&cattr); + EX_LBM_CHK(err); - err = lbm_context_create(&ctx, cattr, NULL, NULL); - EX_LBM_CHK(err); + err = lbm_context_create(&ctx, cattr, NULL, NULL); + EX_LBM_CHK(err); /* =semlit,endblock,init_create_context=*/ - /* =semlit,block,init_app_src=*/ - app_src.state = NOT_INIT; - app_src.mode = PRIMARY; - app_src.ctx = ctx; - /* =semlit,endblock,init_app_src=*/ + /* =semlit,block,init_app_src=*/ + app_src.state = NOT_INIT; + app_src.mode = PRIMARY; + app_src.ctx = ctx; + /* =semlit,endblock,init_app_src=*/ /* =semlit,block,main_send_loop=*/ while(1) /* =semlit,endblock,main_send_loop=*/ { - /* Initialize the source if we're not initialized */ - /* =semlit,block,start_init=*/ - if (app_src.state == NOT_INIT) - init_src(&app_src); - /* =semlit,endblock,start_init=*/ + /* Initialize the source if we're not initialized */ + /* =semlit,block,start_init=*/ + if (app_src.state == NOT_INIT) + init_src(&app_src); + /* =semlit,endblock,start_init=*/ /* =semlit,block,src_send=*/ - if (app_src.state == READY) - /* =semlit,endblock,src_send=*/ - { - if (lbm_src_send(app_src.src, "test", 4, LBM_SRC_NONBLOCK) == LBM_FAILURE) - { - /* Assume EWOULDBLOCK and wait */ - SLEEP_SEC(1); - } - } - else - { - /* Print a warning that the source is not ready and sleep */ - printf("Source cannot send: %d. Source State: %s\n", lbm_errnum(), source_state(&app_src)); - /* =semlit,block,primary_unresp=*/ - if (app_src.state == UNRESP && app_src.mode == PRIMARY) - { - printf("Primary store unresponsive, failing over to backup\n"); - failover_app_src(&app_src); - } - /* =semlit,endblock,primary_unresp=*/ - /* =semlit,block,backup_unresp=*/ - else if (app_src.state == UNRESP && app_src.mode == BACKUP) - { - printf("Backup store unresponsive. Exiting\n"); - exit(1); - } - /* =semlit,endblock,backup_unresp=*/ - SLEEP_SEC(1); - } + if (app_src.state == READY) + /* =semlit,endblock,src_send=*/ + { + if (lbm_src_send(app_src.src, "test", 4, LBM_SRC_NONBLOCK) == LBM_FAILURE) + { + /* Assume EWOULDBLOCK and wait */ + SLEEP_SEC(1); + } + } + else + { + /* Print a warning that the source is not ready and sleep */ + printf("Source cannot send: %d. Source State: %s\n", lbm_errnum(), source_state(&app_src)); + /* =semlit,block,primary_unresp=*/ + if (app_src.state == UNRESP && app_src.mode == PRIMARY) + { + printf("Primary store unresponsive, failing over to backup\n"); + failover_app_src(&app_src); + } + /* =semlit,endblock,primary_unresp=*/ + /* =semlit,block,backup_unresp=*/ + else if (app_src.state == UNRESP && app_src.mode == BACKUP) + { + printf("Backup store unresponsive. Exiting\n"); + exit(1); + } + /* =semlit,endblock,backup_unresp=*/ + SLEEP_SEC(1); + } } + return 0; } diff --git a/ump_src_failover/c/ump_src_failover_c.slsrc.html b/ump_src_failover/c/ump_src_failover_c.slsrc.html index b8ecbe2..10aab5f 100644 --- a/ump_src_failover/c/ump_src_failover_c.slsrc.html +++ b/ump_src_failover/c/ump_src_failover_c.slsrc.html @@ -223,6 +223,7 @@ 00205 00206 00207 +00208 /* ump_src_failover.c */ #include <stdio.h> @@ -266,45 +267,45 @@ typedef enum {NOT_INIT, INIT, READY, UNRESP} state_type_e; typedef enum {PRIMARY, BACKUP} mode_type_e; typedef struct app_src_s { - lbm_context_t *ctx; - lbm_src_t *src; - state_type_e state; - mode_type_e mode; + lbm_context_t *ctx; + lbm_src_t *src; + state_type_e state; + mode_type_e mode; } app_src_s; /* Source event handler callback (passed into lbm_src_create()) */ int handle_src_event(lbm_src_t *src, int event, void *ed, void *cd) { - struct app_src_s *app_src = (struct app_src_s *)cd; + struct app_src_s *app_src = (struct app_src_s *)cd; switch (event) { - /* Success event provided only for printing purposes */ - case LBM_SRC_EVENT_UME_REGISTRATION_SUCCESS_EX: - { - lbm_src_event_ume_registration_ex_t *reg = (lbm_src_event_ume_registration_ex_t *)ed; - printf("UME store %u: %s registration success.\n", reg->store_index, reg->store); - break; - } + /* Success event provided only for printing purposes */ + case LBM_SRC_EVENT_UME_REGISTRATION_SUCCESS_EX: + { + lbm_src_event_ume_registration_ex_t *reg = (lbm_src_event_ume_registration_ex_t *)ed; + printf("UME store %u: %s registration success.\n", reg->store_index, reg->store); + break; + } case LBM_SRC_EVENT_UME_REGISTRATION_COMPLETE_EX: - { - lbm_src_event_ume_registration_complete_ex_t *reg = (lbm_src_event_ume_registration_complete_ex_t *)ed; + { + lbm_src_event_ume_registration_complete_ex_t *reg = (lbm_src_event_ume_registration_complete_ex_t *)ed; - printf("UME registration complete. SQN %x.\n", reg->sequence_number); + printf("UME registration complete. SQN %x.\n", reg->sequence_number); - app_src->state = READY; - break; - } - case LBM_SRC_EVENT_UME_STORE_UNRESPONSIVE: - { - const char *infostr = (const char *)ed; - - printf("UME store: %s\n", infostr); - if (strstr(infostr, "quorum lost") != NULL) - app_src->state = UNRESP; - break; - } - } + app_src->state = READY; + break; + } + case LBM_SRC_EVENT_UME_STORE_UNRESPONSIVE: + { + const char *infostr = (const char *)ed; + + printf("UME store: %s\n", infostr); + if (strstr(infostr, "quorum lost") != NULL) + app_src->state = UNRESP; + break; + } + } - return 0; + return 0; } int init_src(app_src_s *app_src) @@ -316,21 +317,21 @@ err = lbm_src_topic_attr_create(&tattr); EX_LBM_CHK(err); - err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_CLEAR_STORE_CONFIG); - EX_LBM_CHK(err); + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_CLEAR_STORE_CONFIG); + EX_LBM_CHK(err); /* Assuming there are stores running on the localhost */ - if (app_src->mode == PRIMARY) - err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_PRIMARY_STORE); - else - err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_SECONDARY_STORE); + if (app_src->mode == PRIMARY) + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_PRIMARY_STORE); + else + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_SECONDARY_STORE); EX_LBM_CHK(err); - if (app_src->mode == PRIMARY) - err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_PRIMARY_SESSION_ID); - else - err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_SECONDARY_SESSION_ID); - EX_LBM_CHK(err); + if (app_src->mode == PRIMARY) + err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_PRIMARY_SESSION_ID); + else + err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_SECONDARY_SESSION_ID); + EX_LBM_CHK(err); /* Need to set store behavior to Quorum-Consensus */ err = lbm_src_topic_attr_str_setopt(tattr, "ume_store_behavior", "qc"); @@ -342,37 +343,37 @@ err = lbm_src_create(&(app_src->src), app_src->ctx, topic, handle_src_event, app_src, NULL); EX_LBM_CHK(err); - app_src->state = INIT; + app_src->state = INIT; } void failover_app_src(app_src_s *app_src) { - int err; /* Used for checking API return codes */ - - /* Delete the source */ - err = lbm_src_delete(app_src->src); - EX_LBM_CHK(err); + int err; /* Used for checking API return codes */ + + /* Delete the source */ + err = lbm_src_delete(app_src->src); + EX_LBM_CHK(err); - app_src->src = NULL; - app_src->state = NOT_INIT; - app_src->mode = BACKUP; + app_src->src = NULL; + app_src->state = NOT_INIT; + app_src->mode = BACKUP; } /* Provided simply for printing the state name */ const char* source_state(app_src_s *app_src) { - switch (app_src->state) - { - case NOT_INIT: return "NOT_INIT"; - case INIT: return "INIT"; - case READY: return "READY"; - case UNRESP: return "UNRESP"; - } + switch (app_src->state) + { + case NOT_INIT: return "NOT_INIT"; + case INIT: return "INIT"; + case READY: return "READY"; + case UNRESP: return "UNRESP"; + } } - main() + int main(int argc, char **argv) { - app_src_s app_src; /* App structure to track source */ + app_src_s app_src; /* App structure to track source */ lbm_context_t *ctx; /* Context object */ lbm_context_attr_t * cattr; /* Context attribute object */ int err; /* Used for checking API return codes */ @@ -388,47 +389,48 @@ } #endif - err = lbm_context_attr_create(&cattr); - EX_LBM_CHK(err); + err = lbm_context_attr_create(&cattr); + EX_LBM_CHK(err); - err = lbm_context_create(&ctx, cattr, NULL, NULL); - EX_LBM_CHK(err); + err = lbm_context_create(&ctx, cattr, NULL, NULL); + EX_LBM_CHK(err); - app_src.state = NOT_INIT; - app_src.mode = PRIMARY; - app_src.ctx = ctx; + app_src.state = NOT_INIT; + app_src.mode = PRIMARY; + app_src.ctx = ctx; while(1) { - /* Initialize the source if we're not initialized */ - if (app_src.state == NOT_INIT) - init_src(&app_src); + /* Initialize the source if we're not initialized */ + if (app_src.state == NOT_INIT) + init_src(&app_src); - if (app_src.state == READY) - { - if (lbm_src_send(app_src.src, "test", 4, LBM_SRC_NONBLOCK) == LBM_FAILURE) - { - /* Assume EWOULDBLOCK and wait */ - SLEEP_SEC(1); - } - } - else - { - /* Print a warning that the source is not ready and sleep */ - printf("Source cannot send: %d. Source State: %s\n", lbm_errnum(), source_state(&app_src)); - if (app_src.state == UNRESP && app_src.mode == PRIMARY) - { - printf("Primary store unresponsive, failing over to backup\n"); - failover_app_src(&app_src); - } - else if (app_src.state == UNRESP && app_src.mode == BACKUP) - { - printf("Backup store unresponsive. Exiting\n"); - exit(1); - } - SLEEP_SEC(1); - } + if (app_src.state == READY) + { + if (lbm_src_send(app_src.src, "test", 4, LBM_SRC_NONBLOCK) == LBM_FAILURE) + { + /* Assume EWOULDBLOCK and wait */ + SLEEP_SEC(1); + } + } + else + { + /* Print a warning that the source is not ready and sleep */ + printf("Source cannot send: %d. Source State: %s\n", lbm_errnum(), source_state(&app_src)); + if (app_src.state == UNRESP && app_src.mode == PRIMARY) + { + printf("Primary store unresponsive, failing over to backup\n"); + failover_app_src(&app_src); + } + else if (app_src.state == UNRESP && app_src.mode == BACKUP) + { + printf("Backup store unresponsive. Exiting\n"); + exit(1); + } + SLEEP_SEC(1); + } } + return 0; } From b892ca5e379e6e758b4a958b63381e183b1284b7 Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Fri, 24 Nov 2017 15:37:52 -0600 Subject: [PATCH 03/26] fix minor problems Corrected file naming for check_flight_size_ewouldblock. Fixed compile error for late_join --- .../c/check_flight_size_ewouldblock.sldoc | 4 +- .../check_flight_size_ewouldblock.sldoc.html | 206 +++++------ ... => check_flight_size_ewouldblock_c.slsrc} | 0 ...heck_flight_size_ewouldblock_c.slsrc.html} | 0 ...k_flight_size_ewouldblock_store_xml.slsrc} | 0 ...ght_size_ewouldblock_store_xml.slsrc.html} | 0 late_join/c/late_join.c | 224 ++++++------ late_join/c/late_join.sldoc.html | 67 ++-- late_join/c/late_join_c.slsrc | 248 ++++++------- late_join/c/late_join_c.slsrc.html | 332 ++++++++---------- 10 files changed, 501 insertions(+), 580 deletions(-) rename check_flight_size_ewouldblock/c/{check_flight_size_ewouldblock.slsrc => check_flight_size_ewouldblock_c.slsrc} (100%) rename check_flight_size_ewouldblock/c/{check_flight_size_ewouldblock.slsrc.html => check_flight_size_ewouldblock_c.slsrc.html} (100%) rename check_flight_size_ewouldblock/c/{check_flight_size_ewouldblock_store.slsrc => check_flight_size_ewouldblock_store_xml.slsrc} (100%) rename check_flight_size_ewouldblock/c/{check_flight_size_ewouldblock_store.slsrc.html => check_flight_size_ewouldblock_store_xml.slsrc.html} (100%) diff --git a/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.sldoc b/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.sldoc index f2e06b6..e2b6785 100644 --- a/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.sldoc +++ b/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.sldoc @@ -7,8 +7,8 @@ =semlit,include,../intro.sldoc=

There is one program source file, and a store configuration XML:

    -
  • =semlit,srcfile,check_flight_size_ewouldblock.slsrc,check_flight_size_ewouldblock.c=
  • -
  • =semlit,srcfile,check_flight_size_ewouldblock_store.slsrc,store.xml=
  • +
  • =semlit,srcfile,check_flight_size_ewouldblock_c.slsrc,check_flight_size_ewouldblock.c=
  • +
  • =semlit,srcfile,check_flight_size_ewouldblock_store_xml.slsrc,store.xml=

Program explanation: check_flight_size_ewouldblock.c

Define a Flight Size

diff --git a/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.sldoc.html b/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.sldoc.html index 804909f..4a49ea2 100644 --- a/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.sldoc.html +++ b/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.sldoc.html @@ -56,7 +56,7 @@

Define a Flight Size

size in Ultra Messaging is 1000 messages. For the purpose of this example, it is defined to 500.

-00018  #define DEFAULT_APP_FLIGHT_SIZE 500     /* Used for checking flight size */
+00018  #define DEFAULT_APP_FLIGHT_SIZE 500     /* Used for checking flight size */
 
@@ -65,14 +65,14 @@

Declare Variables

and the char flight[4] variable which is being used to set the flight size via the API.

-00022      lbm_context_t *ctx;         /* Context object */
-00023      lbm_topic_t *topic;         /* Topic object */
-00024      lbm_src_t *src;             /* Source object */
-00025      lbm_src_topic_attr_t * tattr;       /* Source topic attribute object */
-00026      lbm_context_attr_t * cattr;     /* Context attribute object */
-00027      int inflight;                           /* Object used for checking inflight counters */
-00028      char flight[4];
-00029      int err;                /* Used for checking API return codes */
+00022      lbm_context_t *ctx;         /* Context object */
+00023      lbm_topic_t *topic;         /* Topic object */
+00024      lbm_src_t *src;             /* Source object */
+00025      lbm_src_topic_attr_t * tattr;       /* Source topic attribute object */
+00026      lbm_context_attr_t * cattr;     /* Context attribute object */
+00027      int inflight;                           /* Object used for checking inflight counters */
+00028      char flight[4];
+00029      int err;                /* Used for checking API return codes */
 
@@ -81,18 +81,18 @@

Create the context

Creating a Context

-00042      if (lbm_context_attr_create(&cattr) != 0)
-00043      {
-00044          fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg());
-00045          exit(1);
-00046      }
-00047  
-00048      err = lbm_context_create(&ctx, cattr, NULL, NULL);
-00049      if (err)
-00050      {
-00051          printf("line %d: %s\n", __LINE__, lbm_errmsg());
-00052          exit(1);
-00053      }
+00042      if (lbm_context_attr_create(&cattr) != 0)
+00043      {
+00044          fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg());
+00045          exit(1);
+00046      }
+00047  
+00048      err = lbm_context_create(&ctx, cattr, NULL, NULL);
+00049      if (err)
+00050      {
+00051          printf("line %d: %s\n", __LINE__, lbm_errmsg());
+00052          exit(1);
+00053      }
 
@@ -129,39 +129,39 @@

Create Source

-00055      if (lbm_src_topic_attr_create(&tattr) != 0)
-00056      {
-00057              fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg());
-00058              exit(1);
-00059      }
-00060  
-00061      sprintf(flight, "%d", DEFAULT_APP_FLIGHT_SIZE);
-00062      if (lbm_src_topic_attr_str_setopt(tattr, "ume_flight_size", flight) != 0 )
-00063      {
-00064          fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg());
-00065          exit(1);
-00066      }
-00067  
-00068      /* Assuming there is a store running on the localhost at port 29999 */
-00069      if (lbm_src_topic_attr_str_setopt(tattr, "ume_store", "127.0.0.1:29999") != 0 )
-00070          {
-00071          fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg());
-00072          exit(1);
-00073      }
-00074  
-00075      err = lbm_src_topic_alloc(&topic, ctx, "test.topic", tattr);
-00076      if (err)
-00077      {
-00078          printf("lbm_src_topic_alloc - line %d: %s\n", __LINE__, lbm_errmsg());
-00079          exit(1);
-00080      }
-00081  
-00082      err = lbm_src_create(&src, ctx, topic, NULL, NULL, NULL);
-00083      if (err)
-00084      {
-00085          printf("lbm_src_create - line %d: %s\n", __LINE__, lbm_errmsg());
-00086          exit(1);
-00087      }
+00055      if (lbm_src_topic_attr_create(&tattr) != 0)
+00056      {
+00057              fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg());
+00058              exit(1);
+00059      }
+00060  
+00061      sprintf(flight, "%d", DEFAULT_APP_FLIGHT_SIZE);
+00062      if (lbm_src_topic_attr_str_setopt(tattr, "ume_flight_size", flight) != 0 )
+00063      {
+00064          fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg());
+00065          exit(1);
+00066      }
+00067  
+00068      /* Assuming there is a store running on the localhost at port 29999 */
+00069      if (lbm_src_topic_attr_str_setopt(tattr, "ume_store", "127.0.0.1:29999") != 0 )
+00070          {
+00071          fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg());
+00072          exit(1);
+00073      }
+00074  
+00075      err = lbm_src_topic_alloc(&topic, ctx, "test.topic", tattr);
+00076      if (err)
+00077      {
+00078          printf("lbm_src_topic_alloc - line %d: %s\n", __LINE__, lbm_errmsg());
+00079          exit(1);
+00080      }
+00081  
+00082      err = lbm_src_create(&src, ctx, topic, NULL, NULL, NULL);
+00083      if (err)
+00084      {
+00085          printf("lbm_src_create - line %d: %s\n", __LINE__, lbm_errmsg());
+00086          exit(1);
+00087      }
 
@@ -170,7 +170,7 @@

Main Send Loop

to stdout whenever the source fails to send a message due to flight size.

-00089      while(1)
+00089      while(1)
 
@@ -182,7 +182,7 @@

Send a Message

by the UM library.

-00091          if (lbm_src_send(src, "test", 4, LBM_SRC_NONBLOCK) == LBM_FAILURE)
+00091          if (lbm_src_send(src, "test", 4, LBM_SRC_NONBLOCK) == LBM_FAILURE)
 
@@ -192,7 +192,7 @@

Check Send Error

that either lbm_src_send() failed because it hit flight size, or because it hit the rate limiter.

-00093              if (lbm_errnum() == LBM_EWOULDBLOCK)
+00093              if (lbm_errnum() == LBM_EWOULDBLOCK)
 
@@ -202,15 +202,15 @@

Check Flight Size

and that it cannot send until messages are decalred stable, or not-stable in the event of timeout or store loss.

-00095                  if (lbm_src_get_inflight(src, LBM_FLIGHT_SIZE_TYPE_UME, &inflight, NULL, NULL) == 0) 
-00096                  {
-00097                      /* Check to see if the inflight counter is equal to the configured flight size */
-00098                      if (inflight == DEFAULT_APP_FLIGHT_SIZE)
-00099                      {
-00100                          /* Print alert */
-00101                          printf("ALERT: Source is blocked on flight size: %d\n", inflight);
-00102                      }
-00103                  }
+00095                  if (lbm_src_get_inflight(src, LBM_FLIGHT_SIZE_TYPE_UME, &inflight, NULL, NULL) == 0) 
+00096                  {
+00097                      /* Check to see if the inflight counter is equal to the configured flight size */
+00098                      if (inflight == DEFAULT_APP_FLIGHT_SIZE)
+00099                      {
+00100                          /* Print alert */
+00101                          printf("ALERT: Source is blocked on flight size: %d\n", inflight);
+00102                      }
+00103                  }
 
@@ -218,20 +218,20 @@

Includes

Include files for this application. Notice the Windows specific include files - these are not necessary for Linux only applications

-00003  #include <stdio.h>
-00004  
-00005  #if defined(_MSC_VER)
-00006  /* Windows-only includes */
-00007  #include <winsock2.h>
-00008  #define SLEEP(s) Sleep((s)*1000)
-00009  #else
-00010  /* Unix-only includes */
-00011  #include <stdlib.h>
-00012  #include <unistd.h>
-00013  #define SLEEP(s) sleep(s)
-00014  #endif
-00015  
-00016  #include <lbm/lbm.h>
+00003  #include <stdio.h>
+00004  
+00005  #if defined(_MSC_VER)
+00006  /* Windows-only includes */
+00007  #include <winsock2.h>
+00008  #define SLEEP(s) Sleep((s)*1000)
+00009  #else
+00010  /* Unix-only includes */
+00011  #include <stdlib.h>
+00012  #include <unistd.h>
+00013  #define SLEEP(s) sleep(s)
+00014  #endif
+00015  
+00016  #include <lbm/lbm.h>
 
@@ -239,29 +239,29 @@

Store Configuration XML

This is a store configuration file that can be used to run the umestored binary along with this example application

-00001  <?xml version="1.0" encoding="utf-8" ?>
-00002  <ume-store version="1.2">
-00003    <daemon>
-00004      <log>DEMO_STORE.log</log>
-00005      <web-monitor>*:8080/web-monitor>
-00006    </daemon>
-00007    <stores>
-00008      <store name="DEMO_STORE" port="29999">
-00009        <ume-attributes>
-00010            <option name="disk-cache-directory" value="cache" type="store"/>
-00011            <option name="disk-state-directory" value="state" type="store"/>
-00012            <option name="context-name" value="DEMO_STORE"/>
-00013        </ume-attributes>
-00014        <topics>
-00015          <topic pattern=".*" type="PCRE">
-00016            <ume-attributes>
-00017              <option name="repository-type" value="disk" type="store"/>
-00018            </ume-attributes>
-00019          </topic>
-00020        </topics>
-00021      </store>
-00022    </stores>
-00023  </ume-store>
+00001  <?xml version="1.0" encoding="utf-8" ?>
+00002  <ume-store version="1.2">
+00003    <daemon>
+00004      <log>DEMO_STORE.log</log>
+00005      <web-monitor>*:8080/web-monitor>
+00006    </daemon>
+00007    <stores>
+00008      <store name="DEMO_STORE" port="29999">
+00009        <ume-attributes>
+00010            <option name="disk-cache-directory" value="cache" type="store"/>
+00011            <option name="disk-state-directory" value="state" type="store"/>
+00012            <option name="context-name" value="DEMO_STORE"/>
+00013        </ume-attributes>
+00014        <topics>
+00015          <topic pattern=".*" type="PCRE">
+00016            <ume-attributes>
+00017              <option name="repository-type" value="disk" type="store"/>
+00018            </ume-attributes>
+00019          </topic>
+00020        </topics>
+00021      </store>
+00022    </stores>
+00023  </ume-store>
 
diff --git a/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.slsrc b/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock_c.slsrc similarity index 100% rename from check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.slsrc rename to check_flight_size_ewouldblock/c/check_flight_size_ewouldblock_c.slsrc diff --git a/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.slsrc.html b/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock_c.slsrc.html similarity index 100% rename from check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.slsrc.html rename to check_flight_size_ewouldblock/c/check_flight_size_ewouldblock_c.slsrc.html diff --git a/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock_store.slsrc b/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock_store_xml.slsrc similarity index 100% rename from check_flight_size_ewouldblock/c/check_flight_size_ewouldblock_store.slsrc rename to check_flight_size_ewouldblock/c/check_flight_size_ewouldblock_store_xml.slsrc diff --git a/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock_store.slsrc.html b/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock_store_xml.slsrc.html similarity index 100% rename from check_flight_size_ewouldblock/c/check_flight_size_ewouldblock_store.slsrc.html rename to check_flight_size_ewouldblock/c/check_flight_size_ewouldblock_store_xml.slsrc.html diff --git a/late_join/c/late_join.c b/late_join/c/late_join.c index e0fe668..fea8f53 100644 --- a/late_join/c/late_join.c +++ b/late_join/c/late_join.c @@ -15,140 +15,122 @@ #include +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ +} while (0) + + /* Received message handler (passed into lbm_rcv_create()) */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { - switch (msg->type) { - case LBM_MSG_DATA: - if (msg->flags & LBM_MSG_FLAG_RETRANSMIT) - printf("Processing Late Join Message. SQN: %d\n", msg->sequence_number); - else if (msg->flags & LBM_MSG_FLAG_OTR) - printf("Processing OTR Message. SQN: %d\n", msg->sequence_number); - else - printf("Normal Message. SQN: %d\n", msg->sequence_number); - - //some processing - break; - case LBM_MSG_BOS: - printf("Beggining of transport.\n"); - break; - case LBM_MSG_EOS: - printf("End of transport.\n"); - break; - default: - printf("Unknown lbm_msg_t type %x [%s][%s]\n", msg->type, msg->topic_name, msg->source); - break; - } - return 0; + switch (msg->type) { + case LBM_MSG_DATA: + if (msg->flags & LBM_MSG_FLAG_RETRANSMIT) + printf("Processing Late Join Message. SQN: %d\n", msg->sequence_number); + else if (msg->flags & LBM_MSG_FLAG_OTR) + printf("Processing OTR Message. SQN: %d\n", msg->sequence_number); + else + printf("Normal Message. SQN: %d\n", msg->sequence_number); + + /* some processing */ + break; + case LBM_MSG_BOS: + printf("Beggining of transport.\n"); + break; + case LBM_MSG_EOS: + printf("End of transport.\n"); + break; + default: + printf("Unknown lbm_msg_t type %x [%s][%s]\n", msg->type, msg->topic_name, msg->source); + break; + } + return 0; } int main(int argc, char **argv) { - lbm_context_t *ctx; /* pointer to context object */ - lbm_topic_t *topic_1; /* pointer to topic object */ - lbm_src_t *early_src; /* pointer to source object */ - lbm_rcv_t *late_rcv; /* pointer to receiver object */ - lbm_topic_t *rtopic; /* pointer to receiver topic object */ - lbm_context_attr_t * cattr; /* pointer to context attribute object */ - lbm_src_topic_attr_t *tattr; /* pointer to source attribute object */ - int err; /* return status of lbm functions (true=error) */ + lbm_context_t *ctx; /* pointer to context object */ + lbm_topic_t *topic_1; /* pointer to topic object */ + lbm_src_t *early_src; /* pointer to source object */ + lbm_rcv_t *late_rcv; /* pointer to receiver object */ + lbm_topic_t *rtopic; /* pointer to receiver topic object */ + lbm_context_attr_t * cattr; /* pointer to context attribute object */ + lbm_src_topic_attr_t *tattr; /* pointer to source attribute object */ + int err; /* return status of lbm functions (true=error) */ #if defined(_MSC_VER) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2, 2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n", __LINE__, wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2, 2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n", __LINE__, wsStat); + exit(1); + } #endif - /* Initialize the defaults for the context attribute object */ - if (lbm_context_attr_create(&cattr) != 0) - { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); - exit(1); - } - - /* Creating the context */ - err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - /* Initializing the source attribute object */ - if (lbm_src_topic_attr_create(&tattr) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg()); - exit(1); - } - - /* Setting the transport via the source topic string method */ - if (lbm_src_topic_attr_str_setopt(tattr, "late_join", "1") != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg()); - exit(1); - } - if (lbm_src_topic_attr_str_setopt(tattr, "retransmit_retention_size_threshold", "1") - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg()); - exit(1); - } - - /* Allocating the source topic */ - err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic", tattr); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - /* Creating the source */ - err = lbm_src_create(&early_src, ctx, topic_1, NULL, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - /* Wait for topic resolution to happen */ - Sleep(1); - - /* Send a message... we should expect no one to get it because we haven't created the receiver - yet. */ - err = lbm_src_send(early_src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK); - /* Delete the context attribute object */ - lbm_context_attr_delete(cattr); - - err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - err = lbm_rcv_create(&late_rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - SLEEP(100000); - - /* Finished with all LBM functions, delete the receiver and context object. */ - /* Delete the source topic attribute objects */ - lbm_src_topic_attr_delete(tattr); - - /* Finished with all LBM functions, delete the source and context object. */ - lbm_src_delete(early_src); - lbm_rcv_delete(late_rcv); - lbm_context_delete(ctx); + /* Initialize the defaults for the context attribute object */ + err = lbm_context_attr_create(&cattr); + EX_LBM_CHK(err); + + /* Creating the context */ + err = lbm_context_create(&ctx, cattr, NULL, NULL); + EX_LBM_CHK(err); + /* Delete the context attribute object */ + lbm_context_attr_delete(cattr); + + /* Initializing the source attribute object */ + err = lbm_src_topic_attr_create(&tattr); + EX_LBM_CHK(err); + + /* Setting the transport via the source topic string method */ + err = lbm_src_topic_attr_str_setopt(tattr, "late_join", "1"); + EX_LBM_CHK(err); + err = lbm_src_topic_attr_str_setopt(tattr, "retransmit_retention_size_threshold", "1"); + EX_LBM_CHK(err); + + /* Allocating the source topic */ + err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic", tattr); + EX_LBM_CHK(err); + + /* Creating the source */ + err = lbm_src_create(&early_src, ctx, topic_1, NULL, NULL, NULL); + EX_LBM_CHK(err); + + /* Wait for topic resolution to happen */ + SLEEP(1); + + /* Send a message... we should expect no one to get it because we haven't created the receiver + yet. */ + err = lbm_src_send(early_src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK); + + err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL); + EX_LBM_CHK(err); + err = lbm_rcv_create(&late_rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); + EX_LBM_CHK(err); + + SLEEP(100000); + + /* Finished with all LBM functions, delete the receiver and context object. */ + /* Delete the source topic attribute objects */ + err = lbm_src_topic_attr_delete(tattr); + EX_LBM_CHK(err); + + /* Finished with all LBM functions, delete the source and context object. */ + err = lbm_src_delete(early_src); + EX_LBM_CHK(err); + err = lbm_rcv_delete(late_rcv); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); #if defined(_MSC_VER) - WSACleanup(); + WSACleanup(); #endif return 0; } diff --git a/late_join/c/late_join.sldoc.html b/late_join/c/late_join.sldoc.html index 4c1d3ce..b00c51e 100644 --- a/late_join/c/late_join.sldoc.html +++ b/late_join/c/late_join.sldoc.html @@ -20,11 +20,8 @@

Enabling Late Join

Sources by default have late join disabled. To enable late join the application must do two things. The first is to enable late-join. This can be done as follows:

-00090      if (lbm_src_topic_attr_str_setopt(tattr, "late_join", "1") != 0 )
-00091      {
-00092          fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg());
-00093          exit(1);
-00094      }
+00092          err = lbm_src_topic_attr_str_setopt(tattr, "late_join", "1");
+00093          EX_LBM_CHK(err);
 
@@ -33,11 +30,8 @@

Enabling Late Join

means that at least 1 message will be in the buffer at all times. This can be done as follows:

-00095      if (lbm_src_topic_attr_str_setopt(tattr, "retransmit_retention_size_threshold", "1")
-00096      {
-00097          fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg());
-00098          exit(1);
-00099      }
+00094          err = lbm_src_topic_attr_str_setopt(tattr, "retransmit_retention_size_threshold", "1");
+00095          EX_LBM_CHK(err);
 
@@ -47,19 +41,15 @@

Create a source, send message

that the receiver can miss the first few messages published. This is because it takes a non-zero amount of time to resolve the source and join the underlying transport.

-00110      err = lbm_src_create(&early_src, ctx, topic_1, NULL, NULL, NULL);
-00111      if (err)
-00112      {
-00113          printf("line %d: %s\n", __LINE__, lbm_errmsg());
-00114          exit(1);
-00115      }
-00116  
-00117      /* Wait for topic resolution to happen */
-00118      Sleep(1);
-00119  
-00120      /* Send a message... we should expect no one to get it because we haven't created the receiver
-00121         yet. */
-00122      err = lbm_src_send(early_src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK);
+00102          err = lbm_src_create(&early_src, ctx, topic_1, NULL, NULL, NULL);
+00103          EX_LBM_CHK(err);
+00104  
+00105          /* Wait for topic resolution to happen */
+00106          SLEEP(1);
+00107  
+00108          /* Send a message... we should expect no one to get it because we haven't created the receiver
+00109             yet. */
+00110          err = lbm_src_send(early_src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK);
 
@@ -68,7 +58,7 @@

Creating the receiver and receiving late join

the default does not have to be changed. Therefore, the receiver is simply created:

-00132      err = lbm_rcv_create(&late_rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL);
+00114          err = lbm_rcv_create(&late_rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL);
 
@@ -79,16 +69,16 @@

Creating the receiver and receiving late join

be retransmitted via OTR, which is a separate type of retransmission that will not be covered in this example.

-00021      switch (msg->type) {
-00022      case LBM_MSG_DATA:
-00023          if (msg->flags & LBM_MSG_FLAG_RETRANSMIT)
-00024              printf("Processing Late Join Message. SQN: %d\n", msg->sequence_number);
-00025          else if (msg->flags & LBM_MSG_FLAG_OTR)
-00026              printf("Processing OTR Message. SQN: %d\n", msg->sequence_number);
-00027          else
-00028              printf("Normal Message. SQN: %d\n", msg->sequence_number);
-00029  
-00030          //some processing
+00031          switch (msg->type) {
+00032          case LBM_MSG_DATA:
+00033                  if (msg->flags & LBM_MSG_FLAG_RETRANSMIT)
+00034                          printf("Processing Late Join Message. SQN: %d\n", msg->sequence_number);
+00035                  else if (msg->flags & LBM_MSG_FLAG_OTR)
+00036                          printf("Processing OTR Message. SQN: %d\n", msg->sequence_number);
+00037                  else
+00038                          printf("Normal Message. SQN: %d\n", msg->sequence_number);
+00039  
+00040                  /* some processing */
 
@@ -96,9 +86,12 @@

Cleanup

Cleanup in this case is simple. Simple close or delete all source & receiver objects, and then close or delete the context.

-00146      lbm_src_delete(early_src);
-00147      lbm_rcv_delete(late_rcv);
-00148      lbm_context_delete(ctx);
+00125          err = lbm_src_delete(early_src);
+00126          EX_LBM_CHK(err);
+00127          err = lbm_rcv_delete(late_rcv);
+00128          EX_LBM_CHK(err);
+00129          err = lbm_context_delete(ctx);
+00130          EX_LBM_CHK(err);
 
diff --git a/late_join/c/late_join_c.slsrc b/late_join/c/late_join_c.slsrc index e31c27c..0e42686 100644 --- a/late_join/c/late_join_c.slsrc +++ b/late_join/c/late_join_c.slsrc @@ -15,152 +15,134 @@ #include +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ +} while (0) + + /* Received message handler (passed into lbm_rcv_create()) */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { - /* =semlit,block,callback= */ - switch (msg->type) { - case LBM_MSG_DATA: - if (msg->flags & LBM_MSG_FLAG_RETRANSMIT) - printf("Processing Late Join Message. SQN: %d\n", msg->sequence_number); - else if (msg->flags & LBM_MSG_FLAG_OTR) - printf("Processing OTR Message. SQN: %d\n", msg->sequence_number); - else - printf("Normal Message. SQN: %d\n", msg->sequence_number); - - //some processing - /* =semlit,endblock,callback= */ - break; - case LBM_MSG_BOS: - printf("Beggining of transport.\n"); - break; - case LBM_MSG_EOS: - printf("End of transport.\n"); - break; - default: - printf("Unknown lbm_msg_t type %x [%s][%s]\n", msg->type, msg->topic_name, msg->source); - break; - } - return 0; + /* =semlit,block,callback= */ + switch (msg->type) { + case LBM_MSG_DATA: + if (msg->flags & LBM_MSG_FLAG_RETRANSMIT) + printf("Processing Late Join Message. SQN: %d\n", msg->sequence_number); + else if (msg->flags & LBM_MSG_FLAG_OTR) + printf("Processing OTR Message. SQN: %d\n", msg->sequence_number); + else + printf("Normal Message. SQN: %d\n", msg->sequence_number); + + /* some processing */ + /* =semlit,endblock,callback= */ + break; + case LBM_MSG_BOS: + printf("Beggining of transport.\n"); + break; + case LBM_MSG_EOS: + printf("End of transport.\n"); + break; + default: + printf("Unknown lbm_msg_t type %x [%s][%s]\n", msg->type, msg->topic_name, msg->source); + break; + } + return 0; } int main(int argc, char **argv) { - lbm_context_t *ctx; /* pointer to context object */ - lbm_topic_t *topic_1; /* pointer to topic object */ - lbm_src_t *early_src; /* pointer to source object */ - lbm_rcv_t *late_rcv; /* pointer to receiver object */ - lbm_topic_t *rtopic; /* pointer to receiver topic object */ - lbm_context_attr_t * cattr; /* pointer to context attribute object */ - lbm_src_topic_attr_t *tattr; /* pointer to source attribute object */ - int err; /* return status of lbm functions (true=error) */ + lbm_context_t *ctx; /* pointer to context object */ + lbm_topic_t *topic_1; /* pointer to topic object */ + lbm_src_t *early_src; /* pointer to source object */ + lbm_rcv_t *late_rcv; /* pointer to receiver object */ + lbm_topic_t *rtopic; /* pointer to receiver topic object */ + lbm_context_attr_t * cattr; /* pointer to context attribute object */ + lbm_src_topic_attr_t *tattr; /* pointer to source attribute object */ + int err; /* return status of lbm functions (true=error) */ #if defined(_MSC_VER) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2, 2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n", __LINE__, wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2, 2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n", __LINE__, wsStat); + exit(1); + } #endif - /* Initialize the defaults for the context attribute object */ - if (lbm_context_attr_create(&cattr) != 0) - { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); - exit(1); - } - - /* Creating the context */ - err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - /* Initializing the source attribute object */ - if (lbm_src_topic_attr_create(&tattr) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg()); - exit(1); - } - - /* Setting the transport via the source topic string method */ - /* =semlit,block,enable_lj= */ - if (lbm_src_topic_attr_str_setopt(tattr, "late_join", "1") != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg()); - exit(1); - } - /* =semlit,endblock,enable_lj= */ - /* =semlit,block,configure_lj= */ - if (lbm_src_topic_attr_str_setopt(tattr, "retransmit_retention_size_threshold", "1") - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg()); - exit(1); - } - /* =semlit,endblock,configure_lj= */ - - /* Allocating the source topic */ - err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic", tattr); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - /* Creating the source */ - /* =semlit,block,source= */ - err = lbm_src_create(&early_src, ctx, topic_1, NULL, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - /* Wait for topic resolution to happen */ - Sleep(1); - - /* Send a message... we should expect no one to get it because we haven't created the receiver - yet. */ - err = lbm_src_send(early_src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK); - /* =semlit,endblock,source= */ - /* Delete the context attribute object */ - lbm_context_attr_delete(cattr); - - err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - /* =semlit,block,receiver= */ - err = lbm_rcv_create(&late_rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); - /* =semlit,endblock,receiver= */ - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - SLEEP(100000); - - /* Finished with all LBM functions, delete the receiver and context object. */ - /* Delete the source topic attribute objects */ - lbm_src_topic_attr_delete(tattr); - - /* Finished with all LBM functions, delete the source and context object. */ - /* =semlit,block,cleanup= */ - lbm_src_delete(early_src); - lbm_rcv_delete(late_rcv); - lbm_context_delete(ctx); - /* =semlit,endblock,cleanup= */ + /* Initialize the defaults for the context attribute object */ + err = lbm_context_attr_create(&cattr); + EX_LBM_CHK(err); + + /* Creating the context */ + err = lbm_context_create(&ctx, cattr, NULL, NULL); + EX_LBM_CHK(err); + /* Delete the context attribute object */ + lbm_context_attr_delete(cattr); + + /* Initializing the source attribute object */ + err = lbm_src_topic_attr_create(&tattr); + EX_LBM_CHK(err); + + /* Setting the transport via the source topic string method */ + /* =semlit,block,enable_lj= */ + err = lbm_src_topic_attr_str_setopt(tattr, "late_join", "1"); + EX_LBM_CHK(err); + /* =semlit,endblock,enable_lj= */ + /* =semlit,block,configure_lj= */ + err = lbm_src_topic_attr_str_setopt(tattr, "retransmit_retention_size_threshold", "1"); + EX_LBM_CHK(err); + /* =semlit,endblock,configure_lj= */ + + /* Allocating the source topic */ + err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic", tattr); + EX_LBM_CHK(err); + + /* Creating the source */ + /* =semlit,block,source= */ + err = lbm_src_create(&early_src, ctx, topic_1, NULL, NULL, NULL); + EX_LBM_CHK(err); + + /* Wait for topic resolution to happen */ + SLEEP(1); + + /* Send a message... we should expect no one to get it because we haven't created the receiver + yet. */ + err = lbm_src_send(early_src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK); + /* =semlit,endblock,source= */ + + err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL); + EX_LBM_CHK(err); + /* =semlit,block,receiver= */ + err = lbm_rcv_create(&late_rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); + /* =semlit,endblock,receiver= */ + EX_LBM_CHK(err); + + SLEEP(100000); + + /* Finished with all LBM functions, delete the receiver and context object. */ + /* Delete the source topic attribute objects */ + err = lbm_src_topic_attr_delete(tattr); + EX_LBM_CHK(err); + + /* Finished with all LBM functions, delete the source and context object. */ + /* =semlit,block,cleanup= */ + err = lbm_src_delete(early_src); + EX_LBM_CHK(err); + err = lbm_rcv_delete(late_rcv); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); + /* =semlit,endblock,cleanup= */ #if defined(_MSC_VER) - WSACleanup(); + WSACleanup(); #endif return 0; } diff --git a/late_join/c/late_join_c.slsrc.html b/late_join/c/late_join_c.slsrc.html index fd11f29..dd72c2a 100644 --- a/late_join/c/late_join_c.slsrc.html +++ b/late_join/c/late_join_c.slsrc.html @@ -36,26 +36,26 @@ 00018 00019 00020 -00021 -00022 -00023 -00024 -00025 -00026 -00027 -00028 -00029 -00030 -00031 -00032 -00033 -00034 -00035 -00036 -00037 -00038 -00039 -00040 +00021 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 +00036 +00037 +00038 +00039 +00040 00041 00042 00043 @@ -105,72 +105,54 @@ 00087 00088 00089 -00090 -00091 +00090 +00091 00092 00093 -00094 +00094 00095 -00096 -00097 -00098 -00099 +00096 +00097 +00098 +00099 00100 00101 -00102 -00103 -00104 -00105 -00106 -00107 -00108 -00109 +00102 +00103 +00104 +00105 +00106 +00107 +00108 +00109 00110 -00111 -00112 -00113 -00114 -00115 -00116 -00117 -00118 -00119 -00120 -00121 -00122 +00111 +00112 +00113 +00114 +00115 +00116 +00117 +00118 +00119 +00120 +00121 +00122 00123 00124 -00125 -00126 -00127 -00128 -00129 -00130 +00125 +00126 +00127 +00128 +00129 +00130 00131 -00132 +00132 00133 00134 00135 00136 00137 -00138 -00139 -00140 -00141 -00142 -00143 -00144 -00145 -00146 -00147 -00148 -00149 -00150 -00151 -00152 -00153 -00154 -00155 /* Example on setting Ultra Messaging attributes */ #include <stdio.h> @@ -188,140 +170,122 @@ #include <lbm/lbm.h> + /* Example error checking macro. Include after each UM call. */ + #define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ + } while (0) + + /* Received message handler (passed into lbm_rcv_create()) */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { - switch (msg->type) { - case LBM_MSG_DATA: - if (msg->flags & LBM_MSG_FLAG_RETRANSMIT) - printf("Processing Late Join Message. SQN: %d\n", msg->sequence_number); - else if (msg->flags & LBM_MSG_FLAG_OTR) - printf("Processing OTR Message. SQN: %d\n", msg->sequence_number); - else - printf("Normal Message. SQN: %d\n", msg->sequence_number); + switch (msg->type) { + case LBM_MSG_DATA: + if (msg->flags & LBM_MSG_FLAG_RETRANSMIT) + printf("Processing Late Join Message. SQN: %d\n", msg->sequence_number); + else if (msg->flags & LBM_MSG_FLAG_OTR) + printf("Processing OTR Message. SQN: %d\n", msg->sequence_number); + else + printf("Normal Message. SQN: %d\n", msg->sequence_number); - //some processing - break; - case LBM_MSG_BOS: - printf("Beggining of transport.\n"); - break; - case LBM_MSG_EOS: - printf("End of transport.\n"); - break; - default: - printf("Unknown lbm_msg_t type %x [%s][%s]\n", msg->type, msg->topic_name, msg->source); - break; - } - return 0; + /* some processing */ + break; + case LBM_MSG_BOS: + printf("Beggining of transport.\n"); + break; + case LBM_MSG_EOS: + printf("End of transport.\n"); + break; + default: + printf("Unknown lbm_msg_t type %x [%s][%s]\n", msg->type, msg->topic_name, msg->source); + break; + } + return 0; } int main(int argc, char **argv) { - lbm_context_t *ctx; /* pointer to context object */ - lbm_topic_t *topic_1; /* pointer to topic object */ - lbm_src_t *early_src; /* pointer to source object */ - lbm_rcv_t *late_rcv; /* pointer to receiver object */ - lbm_topic_t *rtopic; /* pointer to receiver topic object */ - lbm_context_attr_t * cattr; /* pointer to context attribute object */ - lbm_src_topic_attr_t *tattr; /* pointer to source attribute object */ - int err; /* return status of lbm functions (true=error) */ + lbm_context_t *ctx; /* pointer to context object */ + lbm_topic_t *topic_1; /* pointer to topic object */ + lbm_src_t *early_src; /* pointer to source object */ + lbm_rcv_t *late_rcv; /* pointer to receiver object */ + lbm_topic_t *rtopic; /* pointer to receiver topic object */ + lbm_context_attr_t * cattr; /* pointer to context attribute object */ + lbm_src_topic_attr_t *tattr; /* pointer to source attribute object */ + int err; /* return status of lbm functions (true=error) */ #if defined(_MSC_VER) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2, 2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n", __LINE__, wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2, 2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n", __LINE__, wsStat); + exit(1); + } #endif - /* Initialize the defaults for the context attribute object */ - if (lbm_context_attr_create(&cattr) != 0) - { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); - exit(1); - } + /* Initialize the defaults for the context attribute object */ + err = lbm_context_attr_create(&cattr); + EX_LBM_CHK(err); + + /* Creating the context */ + err = lbm_context_create(&ctx, cattr, NULL, NULL); + EX_LBM_CHK(err); + /* Delete the context attribute object */ + lbm_context_attr_delete(cattr); + + /* Initializing the source attribute object */ + err = lbm_src_topic_attr_create(&tattr); + EX_LBM_CHK(err); + + /* Setting the transport via the source topic string method */ + err = lbm_src_topic_attr_str_setopt(tattr, "late_join", "1"); + EX_LBM_CHK(err); + err = lbm_src_topic_attr_str_setopt(tattr, "retransmit_retention_size_threshold", "1"); + EX_LBM_CHK(err); - /* Creating the context */ - err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - /* Initializing the source attribute object */ - if (lbm_src_topic_attr_create(&tattr) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg()); - exit(1); - } - - /* Setting the transport via the source topic string method */ - if (lbm_src_topic_attr_str_setopt(tattr, "late_join", "1") != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg()); - exit(1); - } - if (lbm_src_topic_attr_str_setopt(tattr, "retransmit_retention_size_threshold", "1") - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg()); - exit(1); - } - - /* Allocating the source topic */ - err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic", tattr); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + /* Allocating the source topic */ + err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic", tattr); + EX_LBM_CHK(err); - /* Creating the source */ - err = lbm_src_create(&early_src, ctx, topic_1, NULL, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + /* Creating the source */ + err = lbm_src_create(&early_src, ctx, topic_1, NULL, NULL, NULL); + EX_LBM_CHK(err); - /* Wait for topic resolution to happen */ - Sleep(1); + /* Wait for topic resolution to happen */ + SLEEP(1); - /* Send a message... we should expect no one to get it because we haven't created the receiver - yet. */ - err = lbm_src_send(early_src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK); - /* Delete the context attribute object */ - lbm_context_attr_delete(cattr); + /* Send a message... we should expect no one to get it because we haven't created the receiver + yet. */ + err = lbm_src_send(early_src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK); - err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - err = lbm_rcv_create(&late_rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL); + EX_LBM_CHK(err); + err = lbm_rcv_create(&late_rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); + EX_LBM_CHK(err); - SLEEP(100000); + SLEEP(100000); - /* Finished with all LBM functions, delete the receiver and context object. */ - /* Delete the source topic attribute objects */ - lbm_src_topic_attr_delete(tattr); + /* Finished with all LBM functions, delete the receiver and context object. */ + /* Delete the source topic attribute objects */ + err = lbm_src_topic_attr_delete(tattr); + EX_LBM_CHK(err); - /* Finished with all LBM functions, delete the source and context object. */ - lbm_src_delete(early_src); - lbm_rcv_delete(late_rcv); - lbm_context_delete(ctx); + /* Finished with all LBM functions, delete the source and context object. */ + err = lbm_src_delete(early_src); + EX_LBM_CHK(err); + err = lbm_rcv_delete(late_rcv); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); #if defined(_MSC_VER) - WSACleanup(); + WSACleanup(); #endif return 0; } From 2bb06b3d26eef079197179086873fd1d0e2f4a37 Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Sat, 25 Nov 2017 19:40:14 -0600 Subject: [PATCH 04/26] src_rsp example Add new example: src_rsp. --- c_index.html | 1 + index.html | 1 + src_rsp/README.txt | 3 + src_rsp/c/blank.html | 1 + src_rsp/c/client.c | 217 +++++++++++ src_rsp/c/client_c.slsrc | 235 ++++++++++++ src_rsp/c/client_c.slsrc.html | 538 +++++++++++++++++++++++++++ src_rsp/c/index.html | 6 + src_rsp/c/server.c | 280 ++++++++++++++ src_rsp/c/server_c.slsrc | 302 ++++++++++++++++ src_rsp/c/server_c.slsrc.html | 664 ++++++++++++++++++++++++++++++++++ src_rsp/c/src_rsp.sldoc | 195 ++++++++++ src_rsp/c/src_rsp.sldoc.html | 453 +++++++++++++++++++++++ 13 files changed, 2896 insertions(+) create mode 100644 src_rsp/README.txt create mode 100644 src_rsp/c/blank.html create mode 100644 src_rsp/c/client.c create mode 100644 src_rsp/c/client_c.slsrc create mode 100644 src_rsp/c/client_c.slsrc.html create mode 100644 src_rsp/c/index.html create mode 100644 src_rsp/c/server.c create mode 100644 src_rsp/c/server_c.slsrc create mode 100644 src_rsp/c/server_c.slsrc.html create mode 100644 src_rsp/c/src_rsp.sldoc create mode 100644 src_rsp/c/src_rsp.sldoc.html diff --git a/c_index.html b/c_index.html index ce21b0e..f32a8a4 100644 --- a/c_index.html +++ b/c_index.html @@ -38,6 +38,7 @@

Examples

sequential_modeC Java C#/.NETExample on how to run a LBM application in sequential mode with a separate context thread setting_attributesC Java C#/.NETExamples on setting UM attributes via the API source_notify_callbacksC Java C#/.NETA sample application that demonstrates how to configure and code the source_notification_callback feature for receivers +src_rspC Java C#/.NETA sample application that demonstrates source-based request responses. ump_receiver_callbacksC Java C#/.NETA sample application that handles all UMP receiver callbacks and logs important data ump_src_failoverC Java C#/.NETExample UMP source application that demonstrates how a persisted source can failover to a backup store diff --git a/index.html b/index.html index b26baf6..8c1b447 100644 --- a/index.html +++ b/index.html @@ -48,6 +48,7 @@

Examples

sequential_modeC Java C#/.NETExample on how to run a LBM application in sequential mode with a separate context thread setting_attributesC Java C#/.NETExamples on setting UM attributes via the API source_notify_callbacksC Java C#/.NETA sample application that demonstrates how to configure and code the source_notification_callback feature for receivers +src_rspC Java C#/.NETA sample application that demonstrates source-based request responses. ump_receiver_callbacksC Java C#/.NETA sample application that handles all UMP receiver callbacks and logs important data ump_src_failoverC Java C#/.NETExample UMP source application that demonstrates how a persisted source can failover to a backup store diff --git a/src_rsp/README.txt b/src_rsp/README.txt new file mode 100644 index 0000000..65b9e3b --- /dev/null +++ b/src_rsp/README.txt @@ -0,0 +1,3 @@ +Summary=A sample application that demonstrates source-based request responses. + +Description= diff --git a/src_rsp/c/blank.html b/src_rsp/c/blank.html new file mode 100644 index 0000000..0841bfc --- /dev/null +++ b/src_rsp/c/blank.html @@ -0,0 +1 @@ +Click a source line number to see the line in context. diff --git a/src_rsp/c/client.c b/src_rsp/c/client.c new file mode 100644 index 0000000..0b77bbc --- /dev/null +++ b/src_rsp/c/client.c @@ -0,0 +1,217 @@ +/* client.c + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ + +#include +#include + +#if defined(_MSC_VER) +/* Windows-only includes */ +#include +#define MSLEEP(s) Sleep(s) +#else +/* Unix-only includes */ +#include +#include +#define MSLEEP(s) usleep((s) * 1000) +#endif + +#include + +typedef struct server_s { + lbm_context_t *ctx; + char *topic_name; /* Topic the server is subscribed to. */ + lbm_src_t *src; /* Source to send requests to server. */ + lbm_rcv_t *rcv; /* Receiver for responses from server. */ + int state; /* 0=Waiting for registration, 1=registered. */ +} server_t; + +/* Header for request messages. */ +typedef struct req_hdr_s { + char data[8]; +} req_hdr_t; + + +#define E(E_err) do { \ + if ((E_err) < 0) { \ + fprintf(stderr, "Error, %s:%d: %s: %s\n", \ + __FILE__, __LINE__, #E_err, lbm_errmsg()); \ + fflush(stderr); \ + abort(); \ + } \ +} while (0) + + +/* Null check. */ +#define N(N_ptr) do { \ + if ((N_ptr) == NULL) { \ + fprintf(stderr, "Error, %s:%d: '%s' is NULL\n", \ + __FILE__, __LINE__, #N_ptr); \ + fflush(stderr); \ + abort(); /* core dump */ \ + } \ +} while (0) + + +int response_rcv_cb(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) +{ + server_t *server = (server_t *)clientd; + req_hdr_t *req_hdr; + const char *req_data; + + switch (msg->type) + { + case LBM_MSG_DATA: /* Received a message from the client. */ + printf("Received %ld bytes on topic %s: '%.*s'\n", + (long)msg->len, msg->topic_name, (int)msg->len, msg->data); + + if (msg->len > 1 && msg->data[0] == 'r') { + /* Should check for success. */ + server->state = 1; /* Registered. */ + } + else if (msg->len > sizeof(req_hdr_t) && msg->data[0] == 'R') { + req_hdr = (req_hdr_t *)msg->data; + req_data = &msg->data[sizeof(req_hdr_t)]; + /* Process response message. */ + } + break; + + case LBM_MSG_BOS: + printf("[%s][%s], BOS\n", msg->topic_name, msg->source); + break; + + case LBM_MSG_EOS: + printf("[%s][%s], EOS\n", msg->topic_name, msg->source); + break; + + default: /* unexpected receiver event */ + printf("Receive event type %d topic='%s', source='%s'\n", + msg->type, msg->topic_name, msg->source); + break; + } /* switch msg->type */ + + return 0; +} /* response_rcv_cb */ + + +int main(int argc, char **argv) +{ + lbm_context_t *ctx; + server_t server; /* State information for the server. */ + char response_topic_name[256]; + + /* Get (pretty much) unique client name. */ + sprintf(response_topic_name, "Client.%lx.Response", (long)getpid()); + +#if defined(_MSC_VER) + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); exit(1); + } +#endif + + server.ctx = NULL; + + server.topic_name = "Server1.Request"; + server.src = NULL; /* Source to send requests to server. */ + server.rcv = NULL; /* Receiver for responses from server. */ + server.state = 0; /* Waiting for registration. */ + + E(lbm_config("client.cfg")); + + E(lbm_context_create(&ctx, NULL, NULL, NULL)); + server.ctx = ctx; + + /* Create source to send requests to server. */ + { + lbm_topic_t *topic; + E(lbm_src_topic_alloc(&topic, ctx, server.topic_name, NULL)); + E(lbm_src_create(&server.src, ctx, topic, NULL, NULL, NULL)); + } + + /* Create receiver for responses from server. */ + { + lbm_topic_t *topic; + E(lbm_rcv_topic_lookup(&topic, ctx, response_topic_name, NULL)); + E(lbm_rcv_create(&server.rcv, ctx, topic, response_rcv_cb, &server, NULL)); + } + + MSLEEP(1); /* Try to reduce the number of tries to register. */ + + /* Register with the server. May need multiple tries. */ + { + int try_cnt = 0; + int backoff_delay = 2; + char register_msg[257]; + sprintf(register_msg, "r%s", response_topic_name); + + while (server.state == 0) { + try_cnt ++; + E(lbm_src_send(server.src, register_msg, + strlen(register_msg) + 1, LBM_MSG_FLUSH | LBM_SRC_BLOCK)); + printf("Sent '%s' to %s; sleep for %d ms\n", register_msg, + server.topic_name, backoff_delay); + + /* Exponential backoff, to max of 1 sec. */ + MSLEEP(backoff_delay); + backoff_delay *= 2; /* Exponential backoff to max of 1 sec. */ + if (backoff_delay > 1000) { + backoff_delay = 1000; + } + } + printf("Took %d tries to register with server.\n", try_cnt); + } + + /* Main work of the program, which includes sending 5 requests. */ + { + int i; + char send_buf[500]; + req_hdr_t *req_hdr = (req_hdr_t *)send_buf; + + memset((char *)req_hdr, '0', sizeof(req_hdr_t)); + req_hdr->data[0] = 'R'; + + for (i = 0; i < 5; i++) { + /* The application builds a request into request_msg. */ + char request_msg[257]; + sprintf(request_msg, "%s.%d", response_topic_name, i); + + /* The application message is copied in after the header. */ + strcpy(&send_buf[sizeof(req_hdr_t)], request_msg); + E(lbm_src_send(server.src, send_buf, strlen(send_buf) + 1, + LBM_MSG_FLUSH | LBM_SRC_NONBLOCK)); + MSLEEP(1000); + } + } + + printf("Client exiting.\n"); + E(lbm_rcv_delete(server.rcv)); + E(lbm_src_delete(server.src)); + + E(lbm_context_delete(ctx)); + +#if defined(_MSC_VER) + WSACleanup(); +#endif + + return 0; +} /* main */ diff --git a/src_rsp/c/client_c.slsrc b/src_rsp/c/client_c.slsrc new file mode 100644 index 0000000..1216e67 --- /dev/null +++ b/src_rsp/c/client_c.slsrc @@ -0,0 +1,235 @@ +/* client.c + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ + +#include +#include + +#if defined(_MSC_VER) +/* Windows-only includes */ +#include +#define MSLEEP(s) Sleep(s) +#else +/* Unix-only includes */ +#include +#include +#define MSLEEP(s) usleep((s) * 1000) +#endif + +#include + +typedef struct server_s { + lbm_context_t *ctx; + char *topic_name; /* Topic the server is subscribed to. */ + lbm_src_t *src; /* Source to send requests to server. */ + lbm_rcv_t *rcv; /* Receiver for responses from server. */ + int state; /* 0=Waiting for registration, 1=registered. */ +} server_t; + +/* Header for request messages. */ +typedef struct req_hdr_s { + char data[8]; +} req_hdr_t; + + +#define E(E_err) do { \ + if ((E_err) < 0) { \ + fprintf(stderr, "Error, %s:%d: %s: %s\n", \ + __FILE__, __LINE__, #E_err, lbm_errmsg()); \ + fflush(stderr); \ + abort(); \ + } \ +} while (0) + + +/* Null check. */ +#define N(N_ptr) do { \ + if ((N_ptr) == NULL) { \ + fprintf(stderr, "Error, %s:%d: '%s' is NULL\n", \ + __FILE__, __LINE__, #N_ptr); \ + fflush(stderr); \ + abort(); /* core dump */ \ + } \ +} while (0) + + +int response_rcv_cb(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) +{ + server_t *server = (server_t *)clientd; + req_hdr_t *req_hdr; + const char *req_data; + + switch (msg->type) + { +/* =semlit,block,register_done= */ + case LBM_MSG_DATA: /* Received a message from the client. */ + printf("Received %ld bytes on topic %s: '%.*s'\n", + (long)msg->len, msg->topic_name, (int)msg->len, msg->data); + + if (msg->len > 1 && msg->data[0] == 'r') { + /* Should check for success. */ + server->state = 1; /* Registered. */ + } +/* =semlit,endblock,register_done= */ + else if (msg->len > sizeof(req_hdr_t) && msg->data[0] == 'R') { + req_hdr = (req_hdr_t *)msg->data; + req_data = &msg->data[sizeof(req_hdr_t)]; + /* Process response message. */ + } + break; + + case LBM_MSG_BOS: + printf("[%s][%s], BOS\n", msg->topic_name, msg->source); + break; + + case LBM_MSG_EOS: + printf("[%s][%s], EOS\n", msg->topic_name, msg->source); + break; + + default: /* unexpected receiver event */ + printf("Receive event type %d topic='%s', source='%s'\n", + msg->type, msg->topic_name, msg->source); + break; + } /* switch msg->type */ + + return 0; +} /* response_rcv_cb */ + + +int main(int argc, char **argv) +{ + lbm_context_t *ctx; + server_t server; /* State information for the server. */ + char response_topic_name[256]; + +/* =semlit,block,client_name= */ + /* Get (pretty much) unique client name. */ + sprintf(response_topic_name, "Client.%lx.Response", (long)getpid()); +/* =semlit,endblock,client_name= */ + +#if defined(_MSC_VER) + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); exit(1); + } +#endif + + server.ctx = NULL; + +/* =semlit,block,server_name= */ + server.topic_name = "Server1.Request"; +/* =semlit,endblock,server_name= */ + server.src = NULL; /* Source to send requests to server. */ + server.rcv = NULL; /* Receiver for responses from server. */ + server.state = 0; /* Waiting for registration. */ + + E(lbm_config("client.cfg")); + + E(lbm_context_create(&ctx, NULL, NULL, NULL)); + server.ctx = ctx; + +/* =semlit,block,req_src_create= */ + /* Create source to send requests to server. */ + { + lbm_topic_t *topic; + E(lbm_src_topic_alloc(&topic, ctx, server.topic_name, NULL)); + E(lbm_src_create(&server.src, ctx, topic, NULL, NULL, NULL)); + } +/* =semlit,endblock,req_src_create= */ + +/* =semlit,block,rsp_rcv_create= */ + /* Create receiver for responses from server. */ + { + lbm_topic_t *topic; + E(lbm_rcv_topic_lookup(&topic, ctx, response_topic_name, NULL)); + E(lbm_rcv_create(&server.rcv, ctx, topic, response_rcv_cb, &server, NULL)); + } +/* =semlit,endblock,rsp_rcv_create= */ + + MSLEEP(1); /* Try to reduce the number of tries to register. */ + + /* Register with the server. May need multiple tries. */ + { + int try_cnt = 0; + int backoff_delay = 2; +/* =semlit,block,register_msg= */ + char register_msg[257]; + sprintf(register_msg, "r%s", response_topic_name); +/* =semlit,endblock,register_msg= */ + +/* =semlit,block,register_loop= */ + while (server.state == 0) { + try_cnt ++; + E(lbm_src_send(server.src, register_msg, + strlen(register_msg) + 1, LBM_MSG_FLUSH | LBM_SRC_BLOCK)); + printf("Sent '%s' to %s; sleep for %d ms\n", register_msg, + server.topic_name, backoff_delay); + + /* Exponential backoff, to max of 1 sec. */ + MSLEEP(backoff_delay); + backoff_delay *= 2; /* Exponential backoff to max of 1 sec. */ + if (backoff_delay > 1000) { + backoff_delay = 1000; + } + } + printf("Took %d tries to register with server.\n", try_cnt); +/* =semlit,endblock,register_loop= */ + } + + /* Main work of the program, which includes sending 5 requests. */ + { + int i; +/* =semlit,block,req_buf= */ + char send_buf[500]; + req_hdr_t *req_hdr = (req_hdr_t *)send_buf; + + memset((char *)req_hdr, '0', sizeof(req_hdr_t)); + req_hdr->data[0] = 'R'; +/* =semlit,endblock,req_buf= */ + +/* =semlit,block,req_sends= */ + for (i = 0; i < 5; i++) { + /* The application builds a request into request_msg. */ + char request_msg[257]; + sprintf(request_msg, "%s.%d", response_topic_name, i); + + /* The application message is copied in after the header. */ + strcpy(&send_buf[sizeof(req_hdr_t)], request_msg); + E(lbm_src_send(server.src, send_buf, strlen(send_buf) + 1, + LBM_MSG_FLUSH | LBM_SRC_NONBLOCK)); + MSLEEP(1000); + } +/* =semlit,endblock,req_sends= */ + } + + printf("Client exiting.\n"); + E(lbm_rcv_delete(server.rcv)); + E(lbm_src_delete(server.src)); + + E(lbm_context_delete(ctx)); + +#if defined(_MSC_VER) + WSACleanup(); +#endif + + return 0; +} /* main */ diff --git a/src_rsp/c/client_c.slsrc.html b/src_rsp/c/client_c.slsrc.html new file mode 100644 index 0000000..c01c35e --- /dev/null +++ b/src_rsp/c/client_c.slsrc.html @@ -0,0 +1,538 @@ +client.c + + + + + + + + +

client.c

+ +

+
00001 +00002 +00003 +00004 +00005 +00006 +00007 +00008 +00009 +00010 +00011 +00012 +00013 +00014 +00015 +00016 +00017 +00018 +00019 +00020 +00021 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 +00036 +00037 +00038 +00039 +00040 +00041 +00042 +00043 +00044 +00045 +00046 +00047 +00048 +00049 +00050 +00051 +00052 +00053 +00054 +00055 +00056 +00057 +00058 +00059 +00060 +00061 +00062 +00063 +00064 +00065 +00066 +00067 +00068 +00069 +00070 +00071 +00072 +00073 +00074 +00075 +00076 +00077 +00078 +00079 +00080 +00081 +00082 +00083 +00084 +00085 +00086 +00087 +00088 +00089 +00090 +00091 +00092 +00093 +00094 +00095 +00096 +00097 +00098 +00099 +00100 +00101 +00102 +00103 +00104 +00105 +00106 +00107 +00108 +00109 +00110 +00111 +00112 +00113 +00114 +00115 +00116 +00117 +00118 +00119 +00120 +00121 +00122 +00123 +00124 +00125 +00126 +00127 +00128 +00129 +00130 +00131 +00132 +00133 +00134 +00135 +00136 +00137 +00138 +00139 +00140 +00141 +00142 +00143 +00144 +00145 +00146 +00147 +00148 +00149 +00150 +00151 +00152 +00153 +00154 +00155 +00156 +00157 +00158 +00159 +00160 +00161 +00162 +00163 +00164 +00165 +00166 +00167 +00168 +00169 +00170 +00171 +00172 +00173 +00174 +00175 +00176 +00177 +00178 +00179 +00180 +00181 +00182 +00183 +00184 +00185 +00186 +00187 +00188 +00189 +00190 +00191 +00192 +00193 +00194 +00195 +00196 +00197 +00198 +00199 +00200 +00201 +00202 +00203 +00204 +00205 +00206 +00207 +00208 +00209 +00210 +00211 +00212 +00213 +00214 +00215 +00216 +00217 + /* client.c + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ + + #include <stdio.h> + #include <string.h> + + #if defined(_MSC_VER) + /* Windows-only includes */ + #include <winsock2.h> + #define MSLEEP(s) Sleep(s) + #else + /* Unix-only includes */ + #include <stdlib.h> + #include <unistd.h> + #define MSLEEP(s) usleep((s) * 1000) + #endif + + #include <lbm/lbm.h> + + typedef struct server_s { + lbm_context_t *ctx; + char *topic_name; /* Topic the server is subscribed to. */ + lbm_src_t *src; /* Source to send requests to server. */ + lbm_rcv_t *rcv; /* Receiver for responses from server. */ + int state; /* 0=Waiting for registration, 1=registered. */ + } server_t; + + /* Header for request messages. */ + typedef struct req_hdr_s { + char data[8]; + } req_hdr_t; + + + #define E(E_err) do { \ + if ((E_err) < 0) { \ + fprintf(stderr, "Error, %s:%d: %s: %s\n", \ + __FILE__, __LINE__, #E_err, lbm_errmsg()); \ + fflush(stderr); \ + abort(); \ + } \ + } while (0) + + + /* Null check. */ + #define N(N_ptr) do { \ + if ((N_ptr) == NULL) { \ + fprintf(stderr, "Error, %s:%d: '%s' is NULL\n", \ + __FILE__, __LINE__, #N_ptr); \ + fflush(stderr); \ + abort(); /* core dump */ \ + } \ + } while (0) + + + int response_rcv_cb(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) + { + server_t *server = (server_t *)clientd; + req_hdr_t *req_hdr; + const char *req_data; + + switch (msg->type) + { + case LBM_MSG_DATA: /* Received a message from the client. */ + printf("Received %ld bytes on topic %s: '%.*s'\n", + (long)msg->len, msg->topic_name, (int)msg->len, msg->data); + + if (msg->len > 1 && msg->data[0] == 'r') { + /* Should check for success. */ + server->state = 1; /* Registered. */ + } + else if (msg->len > sizeof(req_hdr_t) && msg->data[0] == 'R') { + req_hdr = (req_hdr_t *)msg->data; + req_data = &msg->data[sizeof(req_hdr_t)]; + /* Process response message. */ + } + break; + + case LBM_MSG_BOS: + printf("[%s][%s], BOS\n", msg->topic_name, msg->source); + break; + + case LBM_MSG_EOS: + printf("[%s][%s], EOS\n", msg->topic_name, msg->source); + break; + + default: /* unexpected receiver event */ + printf("Receive event type %d topic='%s', source='%s'\n", + msg->type, msg->topic_name, msg->source); + break; + } /* switch msg->type */ + + return 0; + } /* response_rcv_cb */ + + + int main(int argc, char **argv) + { + lbm_context_t *ctx; + server_t server; /* State information for the server. */ + char response_topic_name[256]; + + /* Get (pretty much) unique client name. */ + sprintf(response_topic_name, "Client.%lx.Response", (long)getpid()); + + #if defined(_MSC_VER) + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); exit(1); + } + #endif + + server.ctx = NULL; + + server.topic_name = "Server1.Request"; + server.src = NULL; /* Source to send requests to server. */ + server.rcv = NULL; /* Receiver for responses from server. */ + server.state = 0; /* Waiting for registration. */ + + E(lbm_config("client.cfg")); + + E(lbm_context_create(&ctx, NULL, NULL, NULL)); + server.ctx = ctx; + + /* Create source to send requests to server. */ + { + lbm_topic_t *topic; + E(lbm_src_topic_alloc(&topic, ctx, server.topic_name, NULL)); + E(lbm_src_create(&server.src, ctx, topic, NULL, NULL, NULL)); + } + + /* Create receiver for responses from server. */ + { + lbm_topic_t *topic; + E(lbm_rcv_topic_lookup(&topic, ctx, response_topic_name, NULL)); + E(lbm_rcv_create(&server.rcv, ctx, topic, response_rcv_cb, &server, NULL)); + } + + MSLEEP(1); /* Try to reduce the number of tries to register. */ + + /* Register with the server. May need multiple tries. */ + { + int try_cnt = 0; + int backoff_delay = 2; + char register_msg[257]; + sprintf(register_msg, "r%s", response_topic_name); + + while (server.state == 0) { + try_cnt ++; + E(lbm_src_send(server.src, register_msg, + strlen(register_msg) + 1, LBM_MSG_FLUSH | LBM_SRC_BLOCK)); + printf("Sent '%s' to %s; sleep for %d ms\n", register_msg, + server.topic_name, backoff_delay); + + /* Exponential backoff, to max of 1 sec. */ + MSLEEP(backoff_delay); + backoff_delay *= 2; /* Exponential backoff to max of 1 sec. */ + if (backoff_delay > 1000) { + backoff_delay = 1000; + } + } + printf("Took %d tries to register with server.\n", try_cnt); + } + + /* Main work of the program, which includes sending 5 requests. */ + { + int i; + char send_buf[500]; + req_hdr_t *req_hdr = (req_hdr_t *)send_buf; + + memset((char *)req_hdr, '0', sizeof(req_hdr_t)); + req_hdr->data[0] = 'R'; + + for (i = 0; i < 5; i++) { + /* The application builds a request into <tt>request_msg</tt>. */ + char request_msg[257]; + sprintf(request_msg, "%s.%d", response_topic_name, i); + + /* The application message is copied in after the header. */ + strcpy(&send_buf[sizeof(req_hdr_t)], request_msg); + E(lbm_src_send(server.src, send_buf, strlen(send_buf) + 1, + LBM_MSG_FLUSH | LBM_SRC_NONBLOCK)); + MSLEEP(1000); + } + } + + printf("Client exiting.\n"); + E(lbm_rcv_delete(server.rcv)); + E(lbm_src_delete(server.src)); + + E(lbm_context_delete(ctx)); + + #if defined(_MSC_VER) + WSACleanup(); + #endif + + return 0; + } /* main */ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src_rsp/c/index.html b/src_rsp/c/index.html new file mode 100644 index 0000000..0beb962 --- /dev/null +++ b/src_rsp/c/index.html @@ -0,0 +1,6 @@ + + + + + + diff --git a/src_rsp/c/server.c b/src_rsp/c/server.c new file mode 100644 index 0000000..4ae1b6b --- /dev/null +++ b/src_rsp/c/server.c @@ -0,0 +1,280 @@ +/* server.c + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ + +#include +#include + +#if defined(_MSC_VER) +/* Windows-only includes */ +#include +#define SLEEP(s) Sleep((s)*1000) +#else +/* Unix-only includes */ +#include +#include +#define SLEEP(s) sleep(s) +#endif + +#include + + +/* Header for request messages. */ +typedef struct req_hdr_s { + char data[8]; +} req_hdr_t; + + +#define MAX_RESP_SIZE 7000 +typedef struct client_s { + int state; /* 0=waiting for registration, 1=registered. */ + char *topic_name; + char *source_name; + lbm_context_t *ctx; + lbm_src_t *resp_src; + char send_buf[MAX_RESP_SIZE + sizeof(req_hdr_t)]; +} client_t; + + +/* Very simplistic LBM error handling. */ +#define E(E_err) do { \ + if ((E_err) < 0) { \ + fprintf(stderr, "Error, %s:%d: '%s': %s\n", \ + __FILE__, __LINE__, #E_err, lbm_errmsg()); \ + fflush(stderr); \ + abort(); /* core dump */ \ + } \ +} while (0) + + +/* Null check. */ +#define N(N_ptr) do { \ + if ((N_ptr) == NULL) { \ + fprintf(stderr, "Error, %s:%d: '%s' is NULL\n", \ + __FILE__, __LINE__, #N_ptr); \ + fflush(stderr); \ + abort(); /* core dump */ \ + } \ +} while (0) + + +void handle_register(client_t *client, const char *client_resp_name) +{ + int err; + /* This work should probably be passed to a separate worker thread, but + * I'll do it here to simplify the code. */ + + if (client->state == 1) { + printf("Source '%s' re-confirmed\n", client->topic_name); + /* Reply to client. */ + E(lbm_src_send(client->resp_src, "rOK", 4, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK)); + } + else if (client->state == 0) { + lbm_src_topic_attr_t * src_attr; + lbm_topic_t *lbm_topic; + + /* Create source to send responses to client. */ + E(lbm_src_topic_attr_create(&src_attr)); + E(lbm_src_topic_attr_str_setopt(src_attr, "transport", "lbt-ru")); + E(lbm_src_topic_attr_str_setopt(src_attr, "transport_lbtru_port", "12070")); + E(lbm_src_topic_attr_str_setopt(src_attr, + "transport_source_side_filtering_behavior", "inclusion")); + E(lbm_src_topic_alloc(&lbm_topic, client->ctx, client_resp_name, src_attr)); + /* The following create can fail if a new client joins with the same + * response topic name as an existing client. Should handle this cleanly. */ + err = lbm_src_create(&client->resp_src, client->ctx, lbm_topic, + NULL, NULL, NULL); + if (err) { + printf("Source '%s' failed; %s\n", client_resp_name, lbm_errmsg()); + } + else { + client->state = 1; + client->topic_name = strdup(client_resp_name); N(client->topic_name); + printf("Source '%s' created\n", client->topic_name); + } + + E(lbm_src_topic_attr_delete(src_attr)); + } +} /* handle_register */ + + +void handle_req(client_t *client, req_hdr_t *req_hdr, const char *data, size_t len) +{ + /* Response message is put after the header. */ + char *response_msg = &client->send_buf[sizeof(req_hdr_t)]; + + /* This work should probably be passed to a separate worker thread, but + * I'll do it here to simplify the code. */ + + /* Responses copy the header from the request. */ + memcpy(&client->send_buf[0], (char *)req_hdr, sizeof(req_hdr_t)); + + /* Do the work of the request and put the response in response_msg. + * (For this sample, just echo back the request.) */ + strcpy(response_msg, data); + + /* Reply to client. */ + E(lbm_src_send(client->resp_src, client->send_buf, + strlen(client->send_buf) + 1, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK)); + printf("sent response to '%s'.\n", client->topic_name); +} /* handle_req */ + + +int request_rcv_cb(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) +{ + client_t *client = (client_t *)msg->source_clientd; + + switch (msg->type) + { + case LBM_MSG_DATA: /* Received a message from the client. */ + printf("Received %ld bytes on topic %s: '%.*s'\n", + (long)msg->len, msg->topic_name, (int)msg->len, msg->data); + + /* Register message. */ + if (msg->len > 1 && msg->data[0] == 'r') { + handle_register(client, &msg->data[1]); + } + + /* Request message. */ + else if (msg->len >= sizeof(req_hdr_t) && msg->data[0] == 'R') { + req_hdr_t req_hdr; + memcpy((char *)&req_hdr, msg->data, sizeof(req_hdr_t)); + + handle_req(client, &req_hdr, &msg->data[sizeof(req_hdr_t)], + msg->len - sizeof(req_hdr_t)); + } + else { + printf("Ignored unrecognized command '%c'\n", msg->data[0]); + break; + } + break; + + case LBM_MSG_BOS: + printf("[%s][%s], BOS\n", msg->topic_name, msg->source); + break; + + case LBM_MSG_EOS: + printf("[%s][%s], EOS\n", msg->topic_name, msg->source); + break; + + default: /* unexpected receiver event */ + printf("Receive event type %x topic='%s', source='%s'\n", msg->type, msg->topic_name, msg->source); + break; + } /* switch msg->type */ + + return 0; +} /* request_rcv_cb */ + + +void *start_client_source(const char *source_name, void *clientd) +{ + lbm_context_t *ctx = (lbm_context_t *)clientd;; + client_t *new_client = (client_t *)malloc(sizeof(client_t)); N(new_client); + + new_client->state = 0; /* Waiting for register. */ + new_client->topic_name = NULL; + new_client->source_name = strdup(source_name); N(new_client->source_name); + new_client->ctx = ctx; + new_client->resp_src = NULL; + + return new_client; +} /* start_client_source */ + + +int end_client_source(const char *source_name, void *clientd, void *source_clientd) +{ + if (source_clientd) { + client_t *client = (client_t *)source_clientd; + + if (client->topic_name) { + free(client->topic_name); + } + if (client->source_name) { + free(client->source_name); + } + + E(lbm_src_delete(client->resp_src)); + + free(source_clientd); + } + + return 0; +} /* end_client_source */ + + +int main(int argc, char **argv) +{ + lbm_context_t *ctx; + lbm_rcv_t *rcv; /* Receiver for requests from clients. */ + +#if defined(_MSC_VER) + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); exit(1); + } +#endif + + E(lbm_config("serv.cfg")); + + E(lbm_context_create(&ctx, NULL, NULL, NULL)); + + /* Create receiver for requests from clients. */ + { + lbm_rcv_src_notification_func_t source_notification_function; + lbm_rcv_topic_attr_t *rcv_attr; + lbm_topic_t *topic; + + E(lbm_rcv_topic_attr_create(&rcv_attr)); + + /* Set up per-source state management. */ + source_notification_function.create_func = start_client_source; + source_notification_function.delete_func = end_client_source; + source_notification_function.clientd = ctx; /* Pass this to start_client_source(). */ + E(lbm_rcv_topic_attr_setopt(rcv_attr, "source_notification_function", + &source_notification_function, sizeof(source_notification_function))); + + E(lbm_rcv_topic_lookup(&topic, ctx, "Server1.Request", rcv_attr)); + /* Pass context object as clientd. */ + E(lbm_rcv_create(&rcv, ctx, topic, request_rcv_cb, ctx, NULL)); + + E(lbm_rcv_topic_attr_delete(rcv_attr)); + } + + while (1) { + SLEEP(1); + } + + /* Finished all receiving from this topic, delete the receiver object. */ + E(lbm_rcv_delete(rcv)); + + /* Do not need to delete the topic object - LBM keeps track of topic + * objects and deletes them as-needed. */ + + /* Finished with all LBM functions, delete the context object. */ + E(lbm_context_delete(ctx)); + +#if defined(_MSC_VER) + WSACleanup(); +#endif + + return 0; +} /* main */ diff --git a/src_rsp/c/server_c.slsrc b/src_rsp/c/server_c.slsrc new file mode 100644 index 0000000..f4f834b --- /dev/null +++ b/src_rsp/c/server_c.slsrc @@ -0,0 +1,302 @@ +/* server.c + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ + +#include +#include + +#if defined(_MSC_VER) +/* Windows-only includes */ +#include +#define SLEEP(s) Sleep((s)*1000) +#else +/* Unix-only includes */ +#include +#include +#define SLEEP(s) sleep(s) +#endif + +#include + + +/* Header for request messages. */ +typedef struct req_hdr_s { + char data[8]; +} req_hdr_t; + + +#define MAX_RESP_SIZE 7000 +typedef struct client_s { + int state; /* 0=waiting for registration, 1=registered. */ + char *topic_name; + char *source_name; + lbm_context_t *ctx; + lbm_src_t *resp_src; + char send_buf[MAX_RESP_SIZE + sizeof(req_hdr_t)]; +} client_t; + + +/* Very simplistic LBM error handling. */ +#define E(E_err) do { \ + if ((E_err) < 0) { \ + fprintf(stderr, "Error, %s:%d: '%s': %s\n", \ + __FILE__, __LINE__, #E_err, lbm_errmsg()); \ + fflush(stderr); \ + abort(); /* core dump */ \ + } \ +} while (0) + + +/* Null check. */ +#define N(N_ptr) do { \ + if ((N_ptr) == NULL) { \ + fprintf(stderr, "Error, %s:%d: '%s' is NULL\n", \ + __FILE__, __LINE__, #N_ptr); \ + fflush(stderr); \ + abort(); /* core dump */ \ + } \ +} while (0) + + +/* =semlit,block,do_reg2= */ +void handle_register(client_t *client, const char *client_resp_name) +{ + int err; + /* This work should probably be passed to a separate worker thread, but + * I'll do it here to simplify the code. */ + +/* =semlit,block,rsp_src_ok= */ + if (client->state == 1) { + printf("Source '%s' re-confirmed\n", client->topic_name); + /* Reply to client. */ + E(lbm_src_send(client->resp_src, "rOK", 4, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK)); + } +/* =semlit,endblock,rsp_src_ok= */ + else if (client->state == 0) { + lbm_src_topic_attr_t * src_attr; + lbm_topic_t *lbm_topic; + + /* Create source to send responses to client. */ + E(lbm_src_topic_attr_create(&src_attr)); +/* =semlit,block,rsp_src_config= */ + E(lbm_src_topic_attr_str_setopt(src_attr, "transport", "lbt-ru")); + E(lbm_src_topic_attr_str_setopt(src_attr, "transport_lbtru_port", "12070")); +/* =semlit,endblock,rsp_src_config= */ +/* =semlit,block,rsp_src_config2= */ + E(lbm_src_topic_attr_str_setopt(src_attr, + "transport_source_side_filtering_behavior", "inclusion")); +/* =semlit,endblock,rsp_src_config2= */ + E(lbm_src_topic_alloc(&lbm_topic, client->ctx, client_resp_name, src_attr)); + /* The following create can fail if a new client joins with the same + * response topic name as an existing client. Should handle this cleanly. */ + err = lbm_src_create(&client->resp_src, client->ctx, lbm_topic, + NULL, NULL, NULL); + if (err) { + printf("Source '%s' failed; %s\n", client_resp_name, lbm_errmsg()); + } + else { +/* =semlit,block,rsp_src_created= */ + client->state = 1; + client->topic_name = strdup(client_resp_name); N(client->topic_name); + printf("Source '%s' created\n", client->topic_name); +/* =semlit,endblock,rsp_src_created= */ + } + + E(lbm_src_topic_attr_delete(src_attr)); + } +} /* handle_register */ +/* =semlit,endblock,do_reg2= */ + + +/* =semlit,block,do_req2= */ +void handle_req(client_t *client, req_hdr_t *req_hdr, const char *data, size_t len) +{ + /* Response message is put after the header. */ + char *response_msg = &client->send_buf[sizeof(req_hdr_t)]; + + /* This work should probably be passed to a separate worker thread, but + * I'll do it here to simplify the code. */ + + /* Responses copy the header from the request. */ + memcpy(&client->send_buf[0], (char *)req_hdr, sizeof(req_hdr_t)); + + /* Do the work of the request and put the response in response_msg. + * (For this sample, just echo back the request.) */ + strcpy(response_msg, data); + + /* Reply to client. */ + E(lbm_src_send(client->resp_src, client->send_buf, + strlen(client->send_buf) + 1, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK)); + printf("sent response to '%s'.\n", client->topic_name); +} /* handle_req */ +/* =semlit,endblock,do_req2= */ + + +/* =semlit,block,do_reg0= */ +int request_rcv_cb(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) +{ + client_t *client = (client_t *)msg->source_clientd; +/* =semlit,endblock,do_reg0= */ + + switch (msg->type) + { +/* =semlit,block,do_reg1= */ + case LBM_MSG_DATA: /* Received a message from the client. */ + printf("Received %ld bytes on topic %s: '%.*s'\n", + (long)msg->len, msg->topic_name, (int)msg->len, msg->data); + + /* Register message. */ + if (msg->len > 1 && msg->data[0] == 'r') { + handle_register(client, &msg->data[1]); + } +/* =semlit,endblock,do_reg1= */ + +/* =semlit,block,do_req1= */ + /* Request message. */ + else if (msg->len >= sizeof(req_hdr_t) && msg->data[0] == 'R') { + req_hdr_t req_hdr; + memcpy((char *)&req_hdr, msg->data, sizeof(req_hdr_t)); + + handle_req(client, &req_hdr, &msg->data[sizeof(req_hdr_t)], + msg->len - sizeof(req_hdr_t)); + } +/* =semlit,endblock,do_req1= */ + else { + printf("Ignored unrecognized command '%c'\n", msg->data[0]); + break; + } + break; + + case LBM_MSG_BOS: + printf("[%s][%s], BOS\n", msg->topic_name, msg->source); + break; + + case LBM_MSG_EOS: + printf("[%s][%s], EOS\n", msg->topic_name, msg->source); + break; + + default: /* unexpected receiver event */ + printf("Receive event type %x topic='%s', source='%s'\n", msg->type, msg->topic_name, msg->source); + break; + } /* switch msg->type */ + + return 0; +} /* request_rcv_cb */ + + +/* =semlit,block,start_client= */ +void *start_client_source(const char *source_name, void *clientd) +{ + lbm_context_t *ctx = (lbm_context_t *)clientd;; + client_t *new_client = (client_t *)malloc(sizeof(client_t)); N(new_client); + + new_client->state = 0; /* Waiting for register. */ + new_client->topic_name = NULL; + new_client->source_name = strdup(source_name); N(new_client->source_name); + new_client->ctx = ctx; + new_client->resp_src = NULL; + + return new_client; +} /* start_client_source */ +/* =semlit,endblock,start_client= */ + + +int end_client_source(const char *source_name, void *clientd, void *source_clientd) +{ + if (source_clientd) { + client_t *client = (client_t *)source_clientd; + + if (client->topic_name) { + free(client->topic_name); + } + if (client->source_name) { + free(client->source_name); + } + + E(lbm_src_delete(client->resp_src)); + + free(source_clientd); + } + + return 0; +} /* end_client_source */ + + +int main(int argc, char **argv) +{ + lbm_context_t *ctx; + lbm_rcv_t *rcv; /* Receiver for requests from clients. */ + +#if defined(_MSC_VER) + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); exit(1); + } +#endif + + E(lbm_config("serv.cfg")); + + E(lbm_context_create(&ctx, NULL, NULL, NULL)); + + /* Create receiver for requests from clients. */ + { +/* =semlit,block,src_notif_setopt= */ + lbm_rcv_src_notification_func_t source_notification_function; + lbm_rcv_topic_attr_t *rcv_attr; + lbm_topic_t *topic; + + E(lbm_rcv_topic_attr_create(&rcv_attr)); + + /* Set up per-source state management. */ + source_notification_function.create_func = start_client_source; + source_notification_function.delete_func = end_client_source; + source_notification_function.clientd = ctx; /* Pass this to start_client_source(). */ + E(lbm_rcv_topic_attr_setopt(rcv_attr, "source_notification_function", + &source_notification_function, sizeof(source_notification_function))); + + E(lbm_rcv_topic_lookup(&topic, ctx, "Server1.Request", rcv_attr)); + /* Pass context object as clientd. */ + E(lbm_rcv_create(&rcv, ctx, topic, request_rcv_cb, ctx, NULL)); + + E(lbm_rcv_topic_attr_delete(rcv_attr)); + } +/* =semlit,endblock,src_notif_setopt= */ + + while (1) { + SLEEP(1); + } + + /* Finished all receiving from this topic, delete the receiver object. */ + E(lbm_rcv_delete(rcv)); + + /* Do not need to delete the topic object - LBM keeps track of topic + * objects and deletes them as-needed. */ + + /* Finished with all LBM functions, delete the context object. */ + E(lbm_context_delete(ctx)); + +#if defined(_MSC_VER) + WSACleanup(); +#endif + + return 0; +} /* main */ diff --git a/src_rsp/c/server_c.slsrc.html b/src_rsp/c/server_c.slsrc.html new file mode 100644 index 0000000..3180794 --- /dev/null +++ b/src_rsp/c/server_c.slsrc.html @@ -0,0 +1,664 @@ +server.c + + + + + + + + +

server.c

+ +

+
00001 +00002 +00003 +00004 +00005 +00006 +00007 +00008 +00009 +00010 +00011 +00012 +00013 +00014 +00015 +00016 +00017 +00018 +00019 +00020 +00021 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 +00036 +00037 +00038 +00039 +00040 +00041 +00042 +00043 +00044 +00045 +00046 +00047 +00048 +00049 +00050 +00051 +00052 +00053 +00054 +00055 +00056 +00057 +00058 +00059 +00060 +00061 +00062 +00063 +00064 +00065 +00066 +00067 +00068 +00069 +00070 +00071 +00072 +00073 +00074 +00075 +00076 +00077 +00078 +00079 +00080 +00081 +00082 +00083 +00084 +00085 +00086 +00087 +00088 +00089 +00090 +00091 +00092 +00093 +00094 +00095 +00096 +00097 +00098 +00099 +00100 +00101 +00102 +00103 +00104 +00105 +00106 +00107 +00108 +00109 +00110 +00111 +00112 +00113 +00114 +00115 +00116 +00117 +00118 +00119 +00120 +00121 +00122 +00123 +00124 +00125 +00126 +00127 +00128 +00129 +00130 +00131 +00132 +00133 +00134 +00135 +00136 +00137 +00138 +00139 +00140 +00141 +00142 +00143 +00144 +00145 +00146 +00147 +00148 +00149 +00150 +00151 +00152 +00153 +00154 +00155 +00156 +00157 +00158 +00159 +00160 +00161 +00162 +00163 +00164 +00165 +00166 +00167 +00168 +00169 +00170 +00171 +00172 +00173 +00174 +00175 +00176 +00177 +00178 +00179 +00180 +00181 +00182 +00183 +00184 +00185 +00186 +00187 +00188 +00189 +00190 +00191 +00192 +00193 +00194 +00195 +00196 +00197 +00198 +00199 +00200 +00201 +00202 +00203 +00204 +00205 +00206 +00207 +00208 +00209 +00210 +00211 +00212 +00213 +00214 +00215 +00216 +00217 +00218 +00219 +00220 +00221 +00222 +00223 +00224 +00225 +00226 +00227 +00228 +00229 +00230 +00231 +00232 +00233 +00234 +00235 +00236 +00237 +00238 +00239 +00240 +00241 +00242 +00243 +00244 +00245 +00246 +00247 +00248 +00249 +00250 +00251 +00252 +00253 +00254 +00255 +00256 +00257 +00258 +00259 +00260 +00261 +00262 +00263 +00264 +00265 +00266 +00267 +00268 +00269 +00270 +00271 +00272 +00273 +00274 +00275 +00276 +00277 +00278 +00279 +00280 + /* server.c + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ + + #include <stdio.h> + #include <string.h> + + #if defined(_MSC_VER) + /* Windows-only includes */ + #include <winsock2.h> + #define SLEEP(s) Sleep((s)*1000) + #else + /* Unix-only includes */ + #include <stdlib.h> + #include <unistd.h> + #define SLEEP(s) sleep(s) + #endif + + #include <lbm/lbm.h> + + + /* Header for request messages. */ + typedef struct req_hdr_s { + char data[8]; + } req_hdr_t; + + + #define MAX_RESP_SIZE 7000 + typedef struct client_s { + int state; /* 0=waiting for registration, 1=registered. */ + char *topic_name; + char *source_name; + lbm_context_t *ctx; + lbm_src_t *resp_src; + char send_buf[MAX_RESP_SIZE + sizeof(req_hdr_t)]; + } client_t; + + + /* Very simplistic LBM error handling. */ + #define E(E_err) do { \ + if ((E_err) < 0) { \ + fprintf(stderr, "Error, %s:%d: '%s': %s\n", \ + __FILE__, __LINE__, #E_err, lbm_errmsg()); \ + fflush(stderr); \ + abort(); /* core dump */ \ + } \ + } while (0) + + + /* Null check. */ + #define N(N_ptr) do { \ + if ((N_ptr) == NULL) { \ + fprintf(stderr, "Error, %s:%d: '%s' is NULL\n", \ + __FILE__, __LINE__, #N_ptr); \ + fflush(stderr); \ + abort(); /* core dump */ \ + } \ + } while (0) + + + void handle_register(client_t *client, const char *client_resp_name) + { + int err; + /* This work should probably be passed to a separate worker thread, but + * I'll do it here to simplify the code. */ + + if (client->state == 1) { + printf("Source '%s' re-confirmed\n", client->topic_name); + /* Reply to client. */ + E(lbm_src_send(client->resp_src, "rOK", 4, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK)); + } + else if (client->state == 0) { + lbm_src_topic_attr_t * src_attr; + lbm_topic_t *lbm_topic; + + /* Create source to send responses to client. */ + E(lbm_src_topic_attr_create(&src_attr)); + E(lbm_src_topic_attr_str_setopt(src_attr, "transport", "lbt-ru")); + E(lbm_src_topic_attr_str_setopt(src_attr, "transport_lbtru_port", "12070")); + E(lbm_src_topic_attr_str_setopt(src_attr, + "transport_source_side_filtering_behavior", "inclusion")); + E(lbm_src_topic_alloc(&lbm_topic, client->ctx, client_resp_name, src_attr)); + /* The following create can fail if a new client joins with the same + * response topic name as an existing client. Should handle this cleanly. */ + err = lbm_src_create(&client->resp_src, client->ctx, lbm_topic, + NULL, NULL, NULL); + if (err) { + printf("Source '%s' failed; %s\n", client_resp_name, lbm_errmsg()); + } + else { + client->state = 1; + client->topic_name = strdup(client_resp_name); N(client->topic_name); + printf("Source '%s' created\n", client->topic_name); + } + + E(lbm_src_topic_attr_delete(src_attr)); + } + } /* handle_register */ + + + void handle_req(client_t *client, req_hdr_t *req_hdr, const char *data, size_t len) + { + /* Response message is put after the header. */ + char *response_msg = &client->send_buf[sizeof(req_hdr_t)]; + + /* This work should probably be passed to a separate worker thread, but + * I'll do it here to simplify the code. */ + + /* Responses copy the header from the request. */ + memcpy(&client->send_buf[0], (char *)req_hdr, sizeof(req_hdr_t)); + + /* Do the work of the request and put the response in response_msg. + * (For this sample, just echo back the request.) */ + strcpy(response_msg, data); + + /* Reply to client. */ + E(lbm_src_send(client->resp_src, client->send_buf, + strlen(client->send_buf) + 1, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK)); + printf("sent response to '%s'.\n", client->topic_name); + } /* handle_req */ + + + int request_rcv_cb(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) + { + client_t *client = (client_t *)msg->source_clientd; + + switch (msg->type) + { + case LBM_MSG_DATA: /* Received a message from the client. */ + printf("Received %ld bytes on topic %s: '%.*s'\n", + (long)msg->len, msg->topic_name, (int)msg->len, msg->data); + + /* Register message. */ + if (msg->len > 1 && msg->data[0] == 'r') { + handle_register(client, &msg->data[1]); + } + + /* Request message. */ + else if (msg->len >= sizeof(req_hdr_t) && msg->data[0] == 'R') { + req_hdr_t req_hdr; + memcpy((char *)&req_hdr, msg->data, sizeof(req_hdr_t)); + + handle_req(client, &req_hdr, &msg->data[sizeof(req_hdr_t)], + msg->len - sizeof(req_hdr_t)); + } + else { + printf("Ignored unrecognized command '%c'\n", msg->data[0]); + break; + } + break; + + case LBM_MSG_BOS: + printf("[%s][%s], BOS\n", msg->topic_name, msg->source); + break; + + case LBM_MSG_EOS: + printf("[%s][%s], EOS\n", msg->topic_name, msg->source); + break; + + default: /* unexpected receiver event */ + printf("Receive event type %x topic='%s', source='%s'\n", msg->type, msg->topic_name, msg->source); + break; + } /* switch msg->type */ + + return 0; + } /* request_rcv_cb */ + + + void *start_client_source(const char *source_name, void *clientd) + { + lbm_context_t *ctx = (lbm_context_t *)clientd;; + client_t *new_client = (client_t *)malloc(sizeof(client_t)); N(new_client); + + new_client->state = 0; /* Waiting for register. */ + new_client->topic_name = NULL; + new_client->source_name = strdup(source_name); N(new_client->source_name); + new_client->ctx = ctx; + new_client->resp_src = NULL; + + return new_client; + } /* start_client_source */ + + + int end_client_source(const char *source_name, void *clientd, void *source_clientd) + { + if (source_clientd) { + client_t *client = (client_t *)source_clientd; + + if (client->topic_name) { + free(client->topic_name); + } + if (client->source_name) { + free(client->source_name); + } + + E(lbm_src_delete(client->resp_src)); + + free(source_clientd); + } + + return 0; + } /* end_client_source */ + + + int main(int argc, char **argv) + { + lbm_context_t *ctx; + lbm_rcv_t *rcv; /* Receiver for requests from clients. */ + + #if defined(_MSC_VER) + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); exit(1); + } + #endif + + E(lbm_config("serv.cfg")); + + E(lbm_context_create(&ctx, NULL, NULL, NULL)); + + /* Create receiver for requests from clients. */ + { + lbm_rcv_src_notification_func_t source_notification_function; + lbm_rcv_topic_attr_t *rcv_attr; + lbm_topic_t *topic; + + E(lbm_rcv_topic_attr_create(&rcv_attr)); + + /* Set up per-source state management. */ + source_notification_function.create_func = start_client_source; + source_notification_function.delete_func = end_client_source; + source_notification_function.clientd = ctx; /* Pass this to start_client_source(). */ + E(lbm_rcv_topic_attr_setopt(rcv_attr, "source_notification_function", + &source_notification_function, sizeof(source_notification_function))); + + E(lbm_rcv_topic_lookup(&topic, ctx, "Server1.Request", rcv_attr)); + /* Pass context object as clientd. */ + E(lbm_rcv_create(&rcv, ctx, topic, request_rcv_cb, ctx, NULL)); + + E(lbm_rcv_topic_attr_delete(rcv_attr)); + } + + while (1) { + SLEEP(1); + } + + /* Finished all receiving from this topic, delete the receiver object. */ + E(lbm_rcv_delete(rcv)); + + /* Do not need to delete the topic object - LBM keeps track of topic + * objects and deletes them as-needed. */ + + /* Finished with all LBM functions, delete the context object. */ + E(lbm_context_delete(ctx)); + + #if defined(_MSC_VER) + WSACleanup(); + #endif + + return 0; + } /* main */ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src_rsp/c/src_rsp.sldoc b/src_rsp/c/src_rsp.sldoc new file mode 100644 index 0000000..763052d --- /dev/null +++ b/src_rsp/c/src_rsp.sldoc @@ -0,0 +1,195 @@ + + + + Source-based Request/Response + + + Example index + +

How to use sources to send requests and responses.

+ +

There are two source files associated with this example:

+
    +
  • =semlit,srcfile,client_c.slsrc,client.c= + - (right-click and save as "client.c").
  • +
  • =semlit,srcfile,server_c.slsrc,server.c= + - (right-click and save as "server.c").
  • +
+ +

The UM "request/response" feature provides a convenient, easy-to-code + method for a classic server program to respond to a request sent by a client. + The feature takes care of routing the server's response message back to + the client that sent the request. + It also associates response messages with the corresponding request + messages, even if multiple messages are outstanding. + See Request-Response Sample.

+ +

However, there are advantages for the server to use a normal UM + source to send response messages:

+
    +
  • Choice of transport types. + UM responses are always sent with TCP. + +
  • Reliability settings for non-TCP transports are under user control. + Can be configured to recover messages after long network outages. + +
  • Extra layer of reliability. + The "OTR" feature can recover messages unrecoverably lost by the transport. + +
  • Better application visibility. + Unicast transport types give connect and disconnect events for the + source, and receivers get BOS and EOS events. + +
  • UDP-based transport types can give lower latency. +
+ +

This sample program uses an LBT-RU source to return response messages + to the requesting client program.

+ +

Overall Approach

+ +

Clients use a UM source to send a request to a server, and the server + uses a UM receiver to receive it. + The server then uses a UM source to send a response back to only the + client that sent the request, and that client uses a UM receiver to + receive it. + This sample allows and arbitrary number of client programs to come and + go, without the server being pre-configured to know about them.

+ +

When a client program initializes, it creates a source to send + requests and a receiver to receive responses. + The client then exchanges one or more handshakes to register with the + server, and to verify round-trip connectivity. + This avoids initial message loss due to topic resolution.

+ +

Registration

+ +

The client uses the server's well-known request topic to create + the source.

+ + =semlit,insert,server_name= +

. . .

+ =semlit,insert,req_src_create= + +

The client needs a unique topic to receive is responses. + Using the process PID is an easy, but not robust method..

+ + =semlit,insert,client_name= +

. . .

+ =semlit,insert,rsp_rcv_create= + +

Registration; Client Side

+ +

The registration message that the client sends to the server is + all-ascii, consisting of lower-case 'r' followed by a null-terminated + topic name on which the client receives responses.

+ + =semlit,insert,register_msg= + +

The client sends registration messages repeatedly in a loop, with + exponential backoff delays. + For example, if the server is not running, the client sends registration + attempts at 1, 2, 4, 8, ... milliseconds, to a maximum of 1 second.

+ + =semlit,insert,register_loop= + +

The loop exits when the client receives a registration response.

+ + =semlit,insert,register_done= + +

Registration; Server Side

+ +

The server makes use of source notification create/delete callbacks + to manage client state. + The callbacks are configured as part of creation of the server's + main receiver.

+ + =semlit,insert,src_notif_setopt= + +

Then, when the receiver discovers a new client's source, + start_client_source() is called. + That function only creates the state structure associated with the + new client.

+ + =semlit,insert,start_client= + +

When the client sends its registration message, it is received by + the server, which uses it to create the source used for sending + responses. + The state structure created above is passed to the receiver + callback in msg->source_clientd.

+ + =semlit,insert,do_reg0= + +

Registration requests start with the character 'r'.

+ + =semlit,insert,do_reg1= +

. . .

+ =semlit,insert,do_reg2= + +

The response source is created in a special way. + It is an LBT-RU transport type, with a fixed port number (the choice + of 12070 was arbitrary). + This means that all clients' sources are mapped to the same LBT-RU + transport session.

+ + =semlit,insert,rsp_src_config= + +

To prevent each client's responses from being sent to all clients, + source-side filtering is enabled.

+ + =semlit,insert,rsp_src_config2= + +

On successful source creation, the client state is filled in. + But no reply is sent to the client. + This is because the client has not yet had a chance to discover and + join the new source, so any message sent at this point would not + be delivered.

+ + =semlit,insert,rsp_src_created= + +

The server could set some kind of timer to send its reply, but + to simplify this code, we just wait for the client to retry. + When the next registration request comes in, we send the OK + message. + Thus, it will always take at least 2 tries to register.

+ + =semlit,insert,rsp_src_ok= + +

Request/Response

+ +

This example does not contain the code necessary to associate responses + with their requests. + However, the simple protocol was designed to allow this to be added. + A request message consists of an 8-ascii-byte header followed by the + application message content. +./run.sh client + The first byte of the header is the character 'R' to indicate a request + message. + The other 7 bytes are currently just set to ascii '0' characters, but + could be used as a request ID. + When the server responds to requests, it uses the same header it + received, so the client can maintain a table of outstanding requests. + This logic is not included in this example.

+ +

Request; Client Side

+ +

In this example, the send buffer for requests is declared as an + arbitrary large buffer. + The header is initialized once.

+ + =semlit,insert,req_buf= + +

For this simple example, 5 requests are sent.

+ + =semlit,insert,req_sends= + +

Response; Server Side

+ +

When the server receives the request, it sends a response.

+ + =semlit,insert,do_req1= +

. . .

+ =semlit,insert,do_req2= + + diff --git a/src_rsp/c/src_rsp.sldoc.html b/src_rsp/c/src_rsp.sldoc.html new file mode 100644 index 0000000..fae130c --- /dev/null +++ b/src_rsp/c/src_rsp.sldoc.html @@ -0,0 +1,453 @@ + + + + Source-based Request/Response + + + Example index + +

How to use sources to send requests and responses.

+ +

There are two source files associated with this example:

+
    +
  • client.c + - (right-click and save as "client.c").
  • +
  • server.c + - (right-click and save as "server.c").
  • +
+ +

The UM "request/response" feature provides a convenient, easy-to-code + method for a classic server program to respond to a request sent by a client. + The feature takes care of routing the server's response message back to + the client that sent the request. + It also associates response messages with the corresponding request + messages, even if multiple messages are outstanding. + See Request-Response Sample.

+ +

However, there are advantages for the server to use a normal UM + source to send response messages:

+
    +
  • Choice of transport types. + UM responses are always sent with TCP. + +
  • Reliability settings for non-TCP transports are under user control. + Can be configured to recover messages after long network outages. + +
  • Extra layer of reliability. + The "OTR" feature can recover messages unrecoverably lost by the transport. + +
  • Better application visibility. + Unicast transport types give connect and disconnect events for the + source, and receivers get BOS and EOS events. + +
  • UDP-based transport types can give lower latency. +
+ +

This sample program uses an LBT-RU source to return response messages + to the requesting client program.

+ +

Overall Approach

+ +

Clients use a UM source to send a request to a server, and the server + uses a UM receiver to receive it. + The server then uses a UM source to send a response back to only the + client that sent the request, and that client uses a UM receiver to + receive it. + This sample allows and arbitrary number of client programs to come and + go, without the server being pre-configured to know about them.

+ +

When a client program initializes, it creates a source to send + requests and a receiver to receive responses. + The client then exchanges one or more handshakes to register with the + server, and to verify round-trip connectivity. + This avoids initial message loss due to topic resolution.

+ +

Registration

+ +

The client uses the server's well-known request topic to create + the source.

+ + +
+00134      server.topic_name = "Server1.Request";
+
+ + +

. . .

+ +
+00144      /* Create source to send requests to server. */
+00145      {
+00146          lbm_topic_t *topic;
+00147          E(lbm_src_topic_alloc(&topic, ctx, server.topic_name, NULL));
+00148          E(lbm_src_create(&server.src, ctx, topic, NULL, NULL, NULL));
+00149      }
+
+ + + +

The client needs a unique topic to receive is responses. + Using the process PID is an easy, but not robust method..

+ + +
+00120      /* Get (pretty much) unique client name. */
+00121      sprintf(response_topic_name, "Client.%lx.Response", (long)getpid());
+
+ + +

. . .

+ +
+00151      /* Create receiver for responses from server. */
+00152      {
+00153          lbm_topic_t *topic;
+00154          E(lbm_rcv_topic_lookup(&topic, ctx, response_topic_name, NULL));
+00155          E(lbm_rcv_create(&server.rcv, ctx, topic, response_rcv_cb, &server, NULL));
+00156      }
+
+ + + +

Registration; Client Side

+ +

The registration message that the client sends to the server is + all-ascii, consisting of lower-case 'r' followed by a null-terminated + topic name on which the client receives responses.

+ + +
+00164          char register_msg[257];
+00165          sprintf(register_msg, "r%s", response_topic_name);
+
+ + + +

The client sends registration messages repeatedly in a loop, with + exponential backoff delays. + For example, if the server is not running, the client sends registration + attempts at 1, 2, 4, 8, ... milliseconds, to a maximum of 1 second.

+ + +
+00167          while (server.state == 0) {
+00168              try_cnt ++;
+00169              E(lbm_src_send(server.src, register_msg,
+00170                  strlen(register_msg) + 1, LBM_MSG_FLUSH | LBM_SRC_BLOCK));
+00171              printf("Sent '%s' to %s; sleep for %d ms\n", register_msg,
+00172                  server.topic_name, backoff_delay);
+00173  
+00174              /* Exponential backoff, to max of 1 sec. */
+00175              MSLEEP(backoff_delay);
+00176              backoff_delay *= 2;  /* Exponential backoff to max of 1 sec. */
+00177              if (backoff_delay > 1000) {
+00178                  backoff_delay = 1000;
+00179              }
+00180          }
+00181          printf("Took %d tries to register with server.\n", try_cnt);
+
+ + + +

The loop exits when the client receives a registration response.

+ + +
+00081      case LBM_MSG_DATA:    /* Received a message from the client. */
+00082          printf("Received %ld bytes on topic %s: '%.*s'\n",
+00083              (long)msg->len, msg->topic_name, (int)msg->len, msg->data);
+00084  
+00085          if (msg->len > 1 && msg->data[0] == 'r') {
+00086              /* Should check for success. */
+00087              server->state = 1;  /* Registered. */
+00088          }
+
+ + + +

Registration; Server Side

+ +

The server makes use of source notification create/delete callbacks + to manage client state. + The callbacks are configured as part of creation of the server's + main receiver.

+ + +
+00242          lbm_rcv_src_notification_func_t source_notification_function;
+00243          lbm_rcv_topic_attr_t *rcv_attr;
+00244          lbm_topic_t *topic;
+00245  
+00246          E(lbm_rcv_topic_attr_create(&rcv_attr));
+00247  
+00248          /* Set up per-source state management. */
+00249          source_notification_function.create_func = start_client_source;
+00250          source_notification_function.delete_func = end_client_source;
+00251          source_notification_function.clientd = ctx;  /* Pass this to start_client_source(). */
+00252          E(lbm_rcv_topic_attr_setopt(rcv_attr, "source_notification_function",
+00253              &source_notification_function, sizeof(source_notification_function)));
+00254  
+00255          E(lbm_rcv_topic_lookup(&topic, ctx, "Server1.Request", rcv_attr));
+00256          /* Pass context object as clientd. */
+00257          E(lbm_rcv_create(&rcv, ctx, topic, request_rcv_cb, ctx, NULL));
+00258  
+00259          E(lbm_rcv_topic_attr_delete(rcv_attr));
+00260      }
+
+ + + +

Then, when the receiver discovers a new client's source, + start_client_source() is called. + That function only creates the state structure associated with the + new client.

+ + +
+00186  void *start_client_source(const char *source_name, void *clientd)
+00187  {
+00188      lbm_context_t *ctx = (lbm_context_t *)clientd;;
+00189      client_t *new_client = (client_t *)malloc(sizeof(client_t));  N(new_client);
+00190  
+00191      new_client->state = 0;  /* Waiting for register. */
+00192      new_client->topic_name = NULL;
+00193      new_client->source_name = strdup(source_name);  N(new_client->source_name);
+00194      new_client->ctx = ctx;
+00195      new_client->resp_src = NULL;
+00196  
+00197      return new_client;
+00198  }  /* start_client_source */
+
+ + + +

When the client sends its registration message, it is received by + the server, which uses it to create the source used for sending + responses. + The state structure created above is passed to the receiver + callback in msg->source_clientd.

+ + +
+00140  int request_rcv_cb(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) 
+00141  {
+00142      client_t *client = (client_t *)msg->source_clientd;
+
+ + + +

Registration requests start with the character 'r'.

+ + +
+00146      case LBM_MSG_DATA:  /* Received a message from the client. */
+00147          printf("Received %ld bytes on topic %s: '%.*s'\n",
+00148               (long)msg->len, msg->topic_name, (int)msg->len, msg->data);
+00149  
+00150          /* Register message. */
+00151          if (msg->len > 1 && msg->data[0] == 'r') {
+00152              handle_register(client, &msg->data[1]);
+00153          }
+
+ + +

. . .

+ +
+00078  void handle_register(client_t *client, const char *client_resp_name)
+00079  {
+00080      int err;
+00081      /* This work should probably be passed to a separate worker thread, but
+00082       * I'll do it here to simplify the code. */
+00083  
+00084      if (client->state == 1) {
+00085          printf("Source '%s' re-confirmed\n", client->topic_name);
+00086          /* Reply to client. */
+00087          E(lbm_src_send(client->resp_src, "rOK", 4, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK));
+00088      }
+00089      else if (client->state == 0) {
+00090          lbm_src_topic_attr_t * src_attr;
+00091          lbm_topic_t *lbm_topic;
+00092  
+00093          /* Create source to send responses to client. */
+00094          E(lbm_src_topic_attr_create(&src_attr));
+00095          E(lbm_src_topic_attr_str_setopt(src_attr, "transport", "lbt-ru"));
+00096          E(lbm_src_topic_attr_str_setopt(src_attr, "transport_lbtru_port", "12070"));
+00097          E(lbm_src_topic_attr_str_setopt(src_attr,
+00098              "transport_source_side_filtering_behavior", "inclusion"));
+00099          E(lbm_src_topic_alloc(&lbm_topic, client->ctx, client_resp_name, src_attr));
+00100          /* The following create can fail if a new client joins with the same
+00101           * response topic name as an existing client.  Should handle this cleanly. */
+00102          err = lbm_src_create(&client->resp_src, client->ctx, lbm_topic,
+00103              NULL, NULL, NULL);
+00104          if (err) {
+00105              printf("Source '%s' failed; %s\n", client_resp_name, lbm_errmsg());
+00106          }
+00107          else {
+00108              client->state = 1;
+00109              client->topic_name = strdup(client_resp_name);  N(client->topic_name);
+00110              printf("Source '%s' created\n", client->topic_name);
+00111          }
+00112  
+00113          E(lbm_src_topic_attr_delete(src_attr));
+00114      }
+00115  }  /* handle_register */
+
+ + + +

The response source is created in a special way. + It is an LBT-RU transport type, with a fixed port number (the choice + of 12070 was arbitrary). + This means that all clients' sources are mapped to the same LBT-RU + transport session.

+ + +
+00095          E(lbm_src_topic_attr_str_setopt(src_attr, "transport", "lbt-ru"));
+00096          E(lbm_src_topic_attr_str_setopt(src_attr, "transport_lbtru_port", "12070"));
+
+ + + +

To prevent each client's responses from being sent to all clients, + source-side filtering is enabled.

+ + +
+00097          E(lbm_src_topic_attr_str_setopt(src_attr,
+00098              "transport_source_side_filtering_behavior", "inclusion"));
+
+ + + +

On successful source creation, the client state is filled in. + But no reply is sent to the client. + This is because the client has not yet had a chance to discover and + join the new source, so any message sent at this point would not + be delivered.

+ + +
+00108              client->state = 1;
+00109              client->topic_name = strdup(client_resp_name);  N(client->topic_name);
+00110              printf("Source '%s' created\n", client->topic_name);
+
+ + + +

The server could set some kind of timer to send its reply, but + to simplify this code, we just wait for the client to retry. + When the next registration request comes in, we send the OK + message. + Thus, it will always take at least 2 tries to register.

+ + +
+00084      if (client->state == 1) {
+00085          printf("Source '%s' re-confirmed\n", client->topic_name);
+00086          /* Reply to client. */
+00087          E(lbm_src_send(client->resp_src, "rOK", 4, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK));
+00088      }
+
+ + + +

Request/Response

+ +

This example does not contain the code necessary to associate responses + with their requests. + However, the simple protocol was designed to allow this to be added. + A request message consists of an 8-ascii-byte header followed by the + application message content. +./run.sh client + The first byte of the header is the character 'R' to indicate a request + message. + The other 7 bytes are currently just set to ascii '0' characters, but + could be used as a request ID. + When the server responds to requests, it uses the same header it + received, so the client can maintain a table of outstanding requests. + This logic is not included in this example.

+ +

Request; Client Side

+ +

In this example, the send buffer for requests is declared as an + arbitrary large buffer. + The header is initialized once.

+ + +
+00187          char send_buf[500];
+00188          req_hdr_t *req_hdr = (req_hdr_t *)send_buf;
+00189  
+00190          memset((char *)req_hdr, '0', sizeof(req_hdr_t));
+00191          req_hdr->data[0] = 'R';
+
+ + + +

For this simple example, 5 requests are sent.

+ + +
+00193          for (i = 0; i < 5; i++) {
+00194              /* The application builds a request into <tt>request_msg</tt>. */
+00195              char request_msg[257];
+00196              sprintf(request_msg, "%s.%d", response_topic_name, i);
+00197  
+00198              /* The application message is copied in after the header. */
+00199              strcpy(&send_buf[sizeof(req_hdr_t)], request_msg);
+00200              E(lbm_src_send(server.src, send_buf, strlen(send_buf) + 1,
+00201                  LBM_MSG_FLUSH | LBM_SRC_NONBLOCK));
+00202              MSLEEP(1000);
+00203          }
+
+ + + +

Response; Server Side

+ +

When the server receives the request, it sends a response.

+ + +

+00155          /* Request message. */
+00156          else if (msg->len >= sizeof(req_hdr_t) && msg->data[0] == 'R') {
+00157              req_hdr_t req_hdr;
+00158              memcpy((char *)&req_hdr, msg->data, sizeof(req_hdr_t));
+00159  
+00160              handle_req(client, &req_hdr, &msg->data[sizeof(req_hdr_t)],
+00161                  msg->len - sizeof(req_hdr_t));
+00162          }
+
+ + +

. . .

+ +
+00118  void handle_req(client_t *client, req_hdr_t *req_hdr, const char *data, size_t len)
+00119  {
+00120      /* Response message is put after the header. */
+00121      char *response_msg = &client->send_buf[sizeof(req_hdr_t)];
+00122  
+00123      /* This work should probably be passed to a separate worker thread, but
+00124       * I'll do it here to simplify the code. */
+00125  
+00126      /* Responses copy the header from the request. */
+00127      memcpy(&client->send_buf[0], (char *)req_hdr, sizeof(req_hdr_t));
+00128  
+00129      /* Do the work of the request and put the response in response_msg.
+00130       * (For this sample, just echo back the request.) */
+00131      strcpy(response_msg, data);
+00132      
+00133      /* Reply to client. */
+00134      E(lbm_src_send(client->resp_src, client->send_buf,
+00135          strlen(client->send_buf) + 1, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK));
+00136      printf("sent response to '%s'.\n", client->topic_name);
+00137  }  /* handle_req */
+
+ + + + + From 167b58d75f9b9f8e4a330434fbf4da52aea9afae Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Sat, 25 Nov 2017 20:02:04 -0600 Subject: [PATCH 05/26] Typo Typo --- src_rsp/c/src_rsp.sldoc | 2 +- src_rsp/c/src_rsp.sldoc.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src_rsp/c/src_rsp.sldoc b/src_rsp/c/src_rsp.sldoc index 763052d..551e75b 100644 --- a/src_rsp/c/src_rsp.sldoc +++ b/src_rsp/c/src_rsp.sldoc @@ -186,7 +186,7 @@

Response; Server Side

-

When the server receives the request, it sends a response.

+

When the server receives the request, it sends a response.

=semlit,insert,do_req1=

. . .

diff --git a/src_rsp/c/src_rsp.sldoc.html b/src_rsp/c/src_rsp.sldoc.html index fae130c..3c3b542 100644 --- a/src_rsp/c/src_rsp.sldoc.html +++ b/src_rsp/c/src_rsp.sldoc.html @@ -407,7 +407,7 @@

Request; Client Side

Response; Server Side

-

When the server receives the request, it sends a response.

+

When the server receives the request, it sends a response.


From 8f9d283c9895e6a872a1a2bf7562cad4410bdb2f Mon Sep 17 00:00:00 2001
From: Steve Ford 
Date: Sun, 26 Nov 2017 13:16:54 -0600
Subject: [PATCH 06/26] Consistency

Standardize file heading. Use EX_LBM_CHK.  All indents to tabs.  End function with funct name comment.  Removed unnecessary err and cattr.
---
 cancelling_timers/c/cancelling_timers.c       |  52 +-
 .../c/cancelling_timers.sldoc.html            | 134 ++--
 cancelling_timers/c/cancelling_timers_c.slsrc |  54 +-
 .../c/cancelling_timers_c.slsrc.html          | 252 ++++---
 .../c/check_flight_size_ewouldblock.c         | 114 +--
 .../check_flight_size_ewouldblock.sldoc.html  | 132 ++--
 .../c/check_flight_size_ewouldblock_c.slsrc   | 114 +--
 ...check_flight_size_ewouldblock_c.slsrc.html | 252 +++----
 clean_shutdown/c/clean_shutdown.c             | 116 +--
 clean_shutdown/c/clean_shutdown.sldoc.html    | 177 ++---
 clean_shutdown/c/clean_shutdown_c.slsrc       | 124 ++--
 clean_shutdown/c/clean_shutdown_c.slsrc.html  | 408 ++++++-----
 dump_attributes/c/dump_attributes.c           | 195 +++--
 dump_attributes/c/dump_attributes.sldoc.html  | 202 +++---
 dump_attributes/c/dump_attributes_c.slsrc     | 195 +++--
 .../c/dump_attributes_c.slsrc.html            | 376 +++++-----
 event_q_rcv/c/event_q_rcv.c                   | 104 +--
 event_q_rcv/c/event_q_rcv.sldoc.html          |  16 +-
 event_q_rcv/c/event_q_rcv_c.slsrc             | 104 +--
 event_q_rcv/c/event_q_rcv_c.slsrc.html        | 138 ++--
 event_q_src/c/event_q_src.c                   | 100 +--
 event_q_src/c/event_q_src.sldoc.html          |  15 +-
 event_q_src/c/event_q_src_c.slsrc             | 100 +--
 event_q_src/c/event_q_src_c.slsrc.html        | 136 ++--
 handle_burst/c/handle_burst.c                 |  51 +-
 handle_burst/c/handle_burst.sldoc.html        |  90 +--
 handle_burst/c/handle_burst_c.slsrc           |  51 +-
 handle_burst/c/handle_burst_c.slsrc.html      | 232 +++---
 late_join/c/late_join.c                       | 219 +++---
 late_join/c/late_join.sldoc.html              |  60 +-
 late_join/c/late_join_c.slsrc                 | 243 ++++---
 late_join/c/late_join_c.slsrc.html            | 308 ++++----
 load_config/c/load_config.c                   |  29 +-
 load_config/c/load_config.sldoc.html          |  54 +-
 load_config/c/load_config_c.slsrc             |  29 +-
 load_config/c/load_config_c.slsrc.html        | 122 ++--
 logging_callback/c/logging_callback.c         | 117 +--
 .../c/logging_callback.sldoc.html             |  72 +-
 logging_callback/c/logging_callback_c.slsrc   | 129 ++--
 .../c/logging_callback_c.slsrc.html           | 264 +++----
 minsrc/c/minsrc.c                             | 103 +--
 minsrc/c/minsrc.sldoc.html                    | 130 ++--
 minsrc/c/minsrc_c.slsrc                       | 127 ++--
 minsrc/c/minsrc_c.slsrc.html                  | 270 ++++---
 multi_context/c/multi_context.c               |  64 +-
 multi_context/c/multi_context.sldoc.html      |  72 +-
 multi_context/c/multi_context_c.slsrc         |  76 +-
 multi_context/c/multi_context_c.slsrc.html    | 212 +++---
 no_source_notify/c/no_source_notify.c         |  55 +-
 .../c/no_source_notify.sldoc.html             |  64 +-
 no_source_notify/c/no_source_notify_c.slsrc   |  55 +-
 .../c/no_source_notify_c.slsrc.html           | 190 +++--
 quorum_state/c/quorum_state.c                 | 128 ++--
 quorum_state/c/quorum_state.sldoc.html        | 160 ++---
 quorum_state/c/quorum_state_c.slsrc           | 146 ++--
 quorum_state/c/quorum_state_c.slsrc.html      | 310 ++++----
 request_response/c/request_response.c         |  93 ++-
 .../c/request_response.sldoc.html             | 203 +++---
 request_response/c/request_response_c.slsrc   |  97 ++-
 .../c/request_response_c.slsrc.html           | 338 +++++----
 schedule_timers/c/schedule_timers.c           |  52 +-
 schedule_timers/c/schedule_timers.sldoc.html  |  73 +-
 schedule_timers/c/schedule_timers_c.slsrc     |  54 +-
 .../c/schedule_timers_c.slsrc.html            | 182 +++--
 seq_number_callback/c/seq_number_callback.c   |  72 +-
 .../c/seq_number_callback.sldoc.html          | 144 ++--
 .../c/seq_number_callback_c.slsrc             |  74 +-
 .../c/seq_number_callback_c.slsrc.html        | 284 ++++----
 sequential_mode/c/sequential_mode.c           |  91 ++-
 sequential_mode/c/sequential_mode.sldoc.html  | 131 ++--
 sequential_mode/c/sequential_mode_c.slsrc     |  99 +--
 .../c/sequential_mode_c.slsrc.html            | 268 ++++---
 setting_attributes/c/setting_attributes.c     | 258 ++++---
 .../c/setting_attributes.sldoc.html           | 192 ++---
 .../c/setting_attributes_c.slsrc              | 330 +++++----
 .../c/setting_attributes_c.slsrc.html         | 400 +++++------
 .../c/source_notify_callbacks.c               | 170 +++--
 .../c/source_notify_callbacks.sldoc.html      | 141 ++--
 .../c/source_notify_callbacks_c.slsrc         | 172 +++--
 .../c/source_notify_callbacks_c.slsrc.html    | 400 ++++++-----
 src_rsp/c/client.c                            |  80 +--
 src_rsp/c/client_c.slsrc                      |  80 +--
 src_rsp/c/client_c.slsrc.html                 | 212 +++---
 src_rsp/c/server.c                            |  97 ++-
 src_rsp/c/server_c.slsrc                      |  97 ++-
 src_rsp/c/server_c.slsrc.html                 | 328 +++++----
 src_rsp/c/src_rsp.sldoc                       |  25 +-
 src_rsp/c/src_rsp.sldoc.html                  | 409 ++++++-----
 .../c/ump_receiver_callbacks.c                |  64 +-
 .../c/ump_receiver_callbacks.sldoc.html       | 236 +++---
 .../c/ump_receiver_callbacks_c.slsrc          |  64 +-
 .../c/ump_receiver_callbacks_c.slsrc.html     | 396 ++++++-----
 ump_src_failover/c/ump_src_failover.c         | 309 ++++----
 .../c/ump_src_failover.sldoc.html             | 203 +++---
 ump_src_failover/c/ump_src_failover_c.slsrc   | 399 ++++++-----
 .../c/ump_src_failover_c.slsrc.html           | 670 ++++++++++--------
 x                                             |  23 +
 x.c                                           | 145 ++++
 x.sed                                         |   1 +
 x.x                                           | 145 ++++
 100 files changed, 8848 insertions(+), 7295 deletions(-)
 create mode 100644 x
 create mode 100644 x.c
 create mode 100644 x.sed
 create mode 100644 x.x

diff --git a/cancelling_timers/c/cancelling_timers.c b/cancelling_timers/c/cancelling_timers.c
index be08ea7..742c215 100644
--- a/cancelling_timers/c/cancelling_timers.c
+++ b/cancelling_timers/c/cancelling_timers.c
@@ -1,4 +1,23 @@
-/* Code Disclaimer? */
+/* cancelling_timers.c - see http://ultramessaging.github.io/UMExamples/cancelling_timers/c/index.html
+ *
+ * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved.
+ * Permission is granted to licensees to use
+ * or alter this software for any purpose, including commercial applications,
+ * according to the terms laid out in the Software License Agreement.
+ *
+ * This source code example is provided by Informatica for educational
+ * and evaluation purposes only.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES
+ * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF
+ * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
+ * PURPOSE.  INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE
+ * UNINTERRUPTED OR ERROR-FREE.  INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE
+ * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR
+ * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE
+ * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF
+ * THE LIKELIHOOD OF SUCH DAMAGES.
+ */
 
 #include 
 
@@ -26,18 +45,19 @@
 
 typedef enum {PENDING, FIRED, CANCELED} state_type_e;
 typedef struct app_timer_s {
-  int id;
-  state_type_e state;
-  int sync;
+	int id;
+	state_type_e state;
+	int sync;
 } app_timer_s;
 
 int wait = 1;
 
+
 /* Timer callback function */
 int sample_timer_handler(lbm_context_t *ctx, const void *clientd)
 {
 	struct app_timer_s *my_timer = (struct app_timer_s *)clientd;
-  	if (my_timer->state != PENDING) {  
+	if (my_timer->state != PENDING) {  
 		fprintf(stderr, "ERROR: Timer executed and should have been cancelled\n");
 		exit(1);
 	}
@@ -45,7 +65,8 @@ int sample_timer_handler(lbm_context_t *ctx, const void *clientd)
 	fprintf(stderr, "ERROR: This timer should have been cancelled by now\n");
 
 	return 0;
-}
+}  /* sample_timer_handler */
+
 
 int cancel_timer_cb(lbm_context_t *ctx, const void *clientd)
 {
@@ -57,22 +78,19 @@ int cancel_timer_cb(lbm_context_t *ctx, const void *clientd)
 	my_timer->sync = 0;
 	
 	return 0;
-}
+}  /* cancel_timer_cb */
 
-int main(int argc, void **argv)
+
+int main(int argc, char **argv)
 {
 	lbm_context_t *ctx;                     /* Context object */
-	lbm_context_attr_t * cattr;             /* Context attribute object */
-	int err;                                /* Used for checking API return codes */
 	app_timer_s my_timer;
+	int err;
 
 	my_timer.sync = 0;
 
 	/* Initialize context atrributes and create context */
-	err = lbm_context_attr_create(&cattr);
-	EX_LBM_CHK(err);
-
-	err = lbm_context_create(&ctx, cattr, NULL, NULL);
+	err = lbm_context_create(&ctx, NULL, NULL, NULL);
 	EX_LBM_CHK(err);
 	
 	my_timer.state = PENDING;
@@ -96,11 +114,11 @@ int main(int argc, void **argv)
 	/* Clean up */
 	err = lbm_context_delete(ctx);
 	EX_LBM_CHK(err);
-  
+
 #if defined(_MSC_VER)
 	/* Windows-specific cleanup overhead */
 	WSACleanup();
 #endif
-        return 0;
-}
 
+	return 0;
+}  /* main */
diff --git a/cancelling_timers/c/cancelling_timers.sldoc.html b/cancelling_timers/c/cancelling_timers.sldoc.html
index 8caae35..475a31b 100644
--- a/cancelling_timers/c/cancelling_timers.sldoc.html
+++ b/cancelling_timers/c/cancelling_timers.sldoc.html
@@ -32,12 +32,12 @@ 

Timer State Object

be a proper semphore!

-00027  typedef enum {PENDING, FIRED, CANCELED} state_type_e;
-00028  typedef struct app_timer_s {
-00029    int id;
-00030    state_type_e state;
-00031    int sync;
-00032  } app_timer_s;
+00046  typedef enum {PENDING, FIRED, CANCELED} state_type_e;
+00047  typedef struct app_timer_s {
+00048      int id;
+00049      state_type_e state;
+00050      int sync;
+00051  } app_timer_s;
 
@@ -46,11 +46,8 @@

Initializing the Context

Creating a Context

-00072      err = lbm_context_attr_create(&cattr);
-00073      EX_LBM_CHK(err);
-00074  
-00075      err = lbm_context_create(&ctx, cattr, NULL, NULL);
-00076      EX_LBM_CHK(err);
+00093      err = lbm_context_create(&ctx, NULL, NULL, NULL);
+00094      EX_LBM_CHK(err);
 
@@ -59,18 +56,19 @@

Creating a Timer Callback

not end up being executed though, because it will be cancelled well in advance

-00037  int sample_timer_handler(lbm_context_t *ctx, const void *clientd)
-00038  {
-00039      struct app_timer_s *my_timer = (struct app_timer_s *)clientd;
-00040      if (my_timer->state != PENDING) {  
-00041          fprintf(stderr, "ERROR: Timer executed and should have been cancelled\n");
-00042          exit(1);
-00043      }
-00044  
-00045      fprintf(stderr, "ERROR: This timer should have been cancelled by now\n");
-00046  
-00047      return 0;
-00048  }
+00056  /* Timer callback function */
+00057  int sample_timer_handler(lbm_context_t *ctx, const void *clientd)
+00058  {
+00059      struct app_timer_s *my_timer = (struct app_timer_s *)clientd;
+00060      if (my_timer->state != PENDING) {  
+00061          fprintf(stderr, "ERROR: Timer executed and should have been cancelled\n");
+00062          exit(1);
+00063      }
+00064  
+00065      fprintf(stderr, "ERROR: This timer should have been cancelled by now\n");
+00066  
+00067      return 0;
+00068  }  /* sample_timer_handler */
 
@@ -82,17 +80,17 @@

Creating a Cancel Callback

will not be executed.
-00050  int cancel_timer_cb(lbm_context_t *ctx, const void *clientd)
-00051  {
-00052      struct app_timer_s *my_timer = (struct app_timer_s *)clientd;
-00053      if (my_timer->state == PENDING) {
-00054          lbm_cancel_timer(ctx, my_timer->id, NULL);
-00055          my_timer->state = CANCELED;
-00056      }
-00057      my_timer->sync = 0;
-00058      
-00059      return 0;
-00060  }
+00071  int cancel_timer_cb(lbm_context_t *ctx, const void *clientd)
+00072  {
+00073      struct app_timer_s *my_timer = (struct app_timer_s *)clientd;
+00074      if (my_timer->state == PENDING) {
+00075          lbm_cancel_timer(ctx, my_timer->id, NULL);
+00076          my_timer->state = CANCELED;
+00077      }
+00078      my_timer->sync = 0;
+00079      
+00080      return 0;
+00081  }  /* cancel_timer_cb */
 
@@ -102,11 +100,11 @@

Scheduling the Timer Callback

statee object, set to PENDING

-00078      my_timer.state = PENDING;
-00079      if ((my_timer.id = lbm_schedule_timer(ctx, sample_timer_handler, &my_timer, NULL, 10000)) == -1) {
-00080          fprintf(stderr, "%s:%d, lbm error: '%s'\n", __FILE__, __LINE__, lbm_errmsg());
-00081          exit(1);
-00082      }
+00096      my_timer.state = PENDING;
+00097      if ((my_timer.id = lbm_schedule_timer(ctx, sample_timer_handler, &my_timer, NULL, 10000)) == -1) {
+00098          fprintf(stderr, "%s:%d, lbm error: '%s'\n", __FILE__, __LINE__, lbm_errmsg());
+00099          exit(1);
+00100      }
 
@@ -115,11 +113,11 @@

Cancelling the Timer

callback, and pass in the state object as the client data variable

-00087      if (my_timer.state == PENDING) {
-00088          lbm_schedule_timer(ctx, cancel_timer_cb, &my_timer, NULL, 0);
-00089          /* timer might still fire at this point. */
-00090          my_timer.sync = 1;
-00091      }
+00105      if (my_timer.state == PENDING) {
+00106          lbm_schedule_timer(ctx, cancel_timer_cb, &my_timer, NULL, 0);
+00107          /* timer might still fire at this point. */
+00108          my_timer.sync = 1;
+00109      }
 
@@ -128,8 +126,8 @@

Wait

is not in this sample to maintain simple portability

-00093      while (my_timer.sync)
-00094          SLEEP(1);
+00111      while (my_timer.sync)
+00112          SLEEP(1);
 
@@ -139,14 +137,14 @@

Error Checking

print a message and exit the program:

-00018  /* Example error checking macro.  Include after each UM call. */
-00019  #define EX_LBM_CHK(err) do { \
-00020      if ((err) < 0) { \
-00021          fprintf(stderr, "%s:%d, lbm error: '%s'\n", \
-00022          __FILE__, __LINE__, lbm_errmsg()); \
-00023          exit(1); \
-00024      }  \
-00025  } while (0)
+00037  /* Example error checking macro.  Include after each UM call. */
+00038  #define EX_LBM_CHK(err) do { \
+00039      if ((err) < 0) { \
+00040          fprintf(stderr, "%s:%d, lbm error: '%s'\n", \
+00041          __FILE__, __LINE__, lbm_errmsg()); \
+00042          exit(1); \
+00043      }  \
+00044  } while (0)
 
@@ -162,20 +160,20 @@

Includes

Include files for this application. Notice the Windows specific include files - these are not necessary for Linux only applications

-00003  #include <stdio.h>
-00004  
-00005  #if defined(_MSC_VER)
-00006  /* Windows-only includes */
-00007  #include <winsock2.h>
-00008  #define SLEEP(s) Sleep((s)*1000)
-00009  #else
-00010  /* Unix-only includes */
-00011  #include <stdlib.h>
-00012  #include <unistd.h>
-00013  #define SLEEP(s) sleep(s)
-00014  #endif
-00015  
-00016  #include <lbm/lbm.h>
+00022  #include <stdio.h>
+00023  
+00024  #if defined(_MSC_VER)
+00025  /* Windows-only includes */
+00026  #include <winsock2.h>
+00027  #define SLEEP(s) Sleep((s)*1000)
+00028  #else
+00029  /* Unix-only includes */
+00030  #include <stdlib.h>
+00031  #include <unistd.h>
+00032  #define SLEEP(s) sleep(s)
+00033  #endif
+00034  
+00035  #include <lbm/lbm.h>
 
diff --git a/cancelling_timers/c/cancelling_timers_c.slsrc b/cancelling_timers/c/cancelling_timers_c.slsrc index 898b092..d3ffe1d 100644 --- a/cancelling_timers/c/cancelling_timers_c.slsrc +++ b/cancelling_timers/c/cancelling_timers_c.slsrc @@ -1,4 +1,23 @@ -/* Code Disclaimer? */ +/* cancelling_timers.c - see http://ultramessaging.github.io/UMExamples/cancelling_timers/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ /* =semlit,block,includes=*/ #include @@ -31,9 +50,9 @@ /* =semlit,block,struct_app_timer=*/ typedef enum {PENDING, FIRED, CANCELED} state_type_e; typedef struct app_timer_s { - int id; - state_type_e state; - int sync; + int id; + state_type_e state; + int sync; } app_timer_s; /* =semlit,endblock,struct_app_timer=*/ @@ -41,12 +60,13 @@ typedef struct app_timer_s { int wait = 1; /* =semlit,endblock,int_wait=*/ -/* Timer callback function */ + /* =semlit,block,timer_cb=*/ +/* Timer callback function */ int sample_timer_handler(lbm_context_t *ctx, const void *clientd) { struct app_timer_s *my_timer = (struct app_timer_s *)clientd; - if (my_timer->state != PENDING) { + if (my_timer->state != PENDING) { fprintf(stderr, "ERROR: Timer executed and should have been cancelled\n"); exit(1); } @@ -54,9 +74,10 @@ int sample_timer_handler(lbm_context_t *ctx, const void *clientd) fprintf(stderr, "ERROR: This timer should have been cancelled by now\n"); return 0; -} +} /* sample_timer_handler */ /* =semlit,endblock,timer_cb=*/ + /* =semlit,block,cancel_cb=*/ int cancel_timer_cb(lbm_context_t *ctx, const void *clientd) { @@ -68,24 +89,21 @@ int cancel_timer_cb(lbm_context_t *ctx, const void *clientd) my_timer->sync = 0; return 0; -} +} /* cancel_timer_cb */ /* =semlit,endblock,cancel_cb=*/ -int main(int argc, void **argv) + +int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - int err; /* Used for checking API return codes */ app_timer_s my_timer; + int err; my_timer.sync = 0; /* Initialize context atrributes and create context */ /* =semlit,block,ctx_create=*/ - err = lbm_context_attr_create(&cattr); - EX_LBM_CHK(err); - - err = lbm_context_create(&ctx, cattr, NULL, NULL); + err = lbm_context_create(&ctx, NULL, NULL, NULL); EX_LBM_CHK(err); /* =semlit,endblock,ctx_create=*/ @@ -116,11 +134,11 @@ int main(int argc, void **argv) /* Clean up */ err = lbm_context_delete(ctx); EX_LBM_CHK(err); - + #if defined(_MSC_VER) /* Windows-specific cleanup overhead */ WSACleanup(); #endif - return 0; -} + return 0; +} /* main */ diff --git a/cancelling_timers/c/cancelling_timers_c.slsrc.html b/cancelling_timers/c/cancelling_timers_c.slsrc.html index 436c61d..9a3b318 100644 --- a/cancelling_timers/c/cancelling_timers_c.slsrc.html +++ b/cancelling_timers/c/cancelling_timers_c.slsrc.html @@ -18,111 +18,148 @@
00001 00002 -00003 -00004 -00005 -00006 -00007 -00008 -00009 -00010 -00011 -00012 -00013 -00014 -00015 -00016 +00003 +00004 +00005 +00006 +00007 +00008 +00009 +00010 +00011 +00012 +00013 +00014 +00015 +00016 00017 -00018 -00019 -00020 -00021 -00022 -00023 -00024 -00025 -00026 -00027 -00028 -00029 -00030 -00031 -00032 -00033 -00034 -00035 +00018 +00019 +00020 +00021 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 00036 -00037 -00038 -00039 -00040 -00041 -00042 -00043 -00044 -00045 -00046 -00047 -00048 -00049 -00050 -00051 -00052 -00053 -00054 -00055 -00056 -00057 -00058 -00059 -00060 -00061 -00062 -00063 -00064 -00065 -00066 -00067 -00068 +00037 +00038 +00039 +00040 +00041 +00042 +00043 +00044 +00045 +00046 +00047 +00048 +00049 +00050 +00051 +00052 +00053 +00054 +00055 +00056 +00057 +00058 +00059 +00060 +00061 +00062 +00063 +00064 +00065 +00066 +00067 +00068 00069 00070 -00071 -00072 -00073 -00074 -00075 -00076 -00077 -00078 -00079 -00080 -00081 -00082 +00071 +00072 +00073 +00074 +00075 +00076 +00077 +00078 +00079 +00080 +00081 +00082 00083 00084 00085 00086 -00087 -00088 -00089 -00090 -00091 +00087 +00088 +00089 +00090 +00091 00092 -00093 -00094 +00093 +00094 00095 -00096 -00097 -00098 -00099 -00100 +00096 +00097 +00098 +00099 +00100 00101 00102 00103 00104 -00105 -00106 - /* Code Disclaimer? */ +00105 +00106 +00107 +00108 +00109 +00110 +00111 +00112 +00113 +00114 +00115 +00116 +00117 +00118 +00119 +00120 +00121 +00122 +00123 +00124 + /* cancelling_timers.c - see http://ultramessaging.github.io/UMExamples/cancelling_timers/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include <stdio.h> @@ -150,15 +187,16 @@ typedef enum {PENDING, FIRED, CANCELED} state_type_e; typedef struct app_timer_s { - int id; - state_type_e state; - int sync; + int id; + state_type_e state; + int sync; } app_timer_s; int wait = 1; - /* Timer callback function */ - int sample_timer_handler(lbm_context_t *ctx, const void *clientd) + + /* Timer callback function */ + int sample_timer_handler(lbm_context_t *ctx, const void *clientd) { struct app_timer_s *my_timer = (struct app_timer_s *)clientd; if (my_timer->state != PENDING) { @@ -169,7 +207,8 @@ fprintf(stderr, "ERROR: This timer should have been cancelled by now\n"); return 0; - } + } /* sample_timer_handler */ + int cancel_timer_cb(lbm_context_t *ctx, const void *clientd) { @@ -181,22 +220,19 @@ my_timer->sync = 0; return 0; - } + } /* cancel_timer_cb */ - int main(int argc, void **argv) + + int main(int argc, char **argv) { lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - int err; /* Used for checking API return codes */ app_timer_s my_timer; + int err; my_timer.sync = 0; /* Initialize context atrributes and create context */ - err = lbm_context_attr_create(&cattr); - EX_LBM_CHK(err); - - err = lbm_context_create(&ctx, cattr, NULL, NULL); + err = lbm_context_create(&ctx, NULL, NULL, NULL); EX_LBM_CHK(err); my_timer.state = PENDING; @@ -220,14 +256,14 @@ /* Clean up */ err = lbm_context_delete(ctx); EX_LBM_CHK(err); - + #if defined(_MSC_VER) /* Windows-specific cleanup overhead */ WSACleanup(); #endif - return 0; - } + return 0; + } /* main */
diff --git a/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.c b/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.c index cf92ed0..c051aaf 100644 --- a/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.c +++ b/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.c @@ -1,4 +1,23 @@ -/* Code Disclaimer? */ +/* check_flight_size_ewouldblock.c - see http://ultramessaging.github.io/UMExamples/check_flight_size_ewouldblock/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include @@ -15,18 +34,27 @@ #include +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ +} while (0) + #define DEFAULT_APP_FLIGHT_SIZE 500 /* Used for checking flight size */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object */ - lbm_topic_t *topic; /* Topic object */ - lbm_src_t *src; /* Source object */ - lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - int inflight; /* Object used for checking inflight counters */ + lbm_context_t *ctx; /* Context object */ + lbm_topic_t *topic; /* Topic object */ + lbm_src_t *src; /* Source object */ + lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ + int inflight; /* Object used for checking inflight counters */ char flight[4]; - int err; /* Used for checking API return codes */ + int err; #if defined(_WIN32) /* windows-specific code */ @@ -39,72 +67,44 @@ int main(int argc, char **argv) } #endif - if (lbm_context_attr_create(&cattr) != 0) - { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); - err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - if (lbm_src_topic_attr_create(&tattr) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_create(&tattr); + EX_LBM_CHK(err); sprintf(flight, "%d", DEFAULT_APP_FLIGHT_SIZE); - if (lbm_src_topic_attr_str_setopt(tattr, "ume_flight_size", flight) != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_str_setopt(tattr, "ume_flight_size", flight); + EX_LBM_CHK(err); /* Assuming there is a store running on the localhost at port 29999 */ - if (lbm_src_topic_attr_str_setopt(tattr, "ume_store", "127.0.0.1:29999") != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", "127.0.0.1:29999"); + EX_LBM_CHK(err); err = lbm_src_topic_alloc(&topic, ctx, "test.topic", tattr); - if (err) - { - printf("lbm_src_topic_alloc - line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); err = lbm_src_create(&src, ctx, topic, NULL, NULL, NULL); - if (err) - { - printf("lbm_src_create - line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); while(1) { - if (lbm_src_send(src, "test", 4, LBM_SRC_NONBLOCK) == LBM_FAILURE) + err = lbm_src_send(src, "test", 4, LBM_SRC_NONBLOCK); + if (err == LBM_FAILURE) { if (lbm_errnum() == LBM_EWOULDBLOCK) - { - if (lbm_src_get_inflight(src, LBM_FLIGHT_SIZE_TYPE_UME, &inflight, NULL, NULL) == 0) + { + err = lbm_src_get_inflight(src, LBM_FLIGHT_SIZE_TYPE_UME, &inflight, NULL, NULL); + EX_LBM_CHK(err); + + /* Is inflight counter is equal to the configured flight size? */ + if (inflight == DEFAULT_APP_FLIGHT_SIZE) { - /* Check to see if the inflight counter is equal to the configured flight size */ - if (inflight == DEFAULT_APP_FLIGHT_SIZE) - { - /* Print alert */ - printf("ALERT: Source is blocked on flight size: %d\n", inflight); - } + printf("ALERT: Source is blocked on flight size: %d\n", inflight); } } } } - return 0; -} - + return 0; +} /* main */ diff --git a/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.sldoc.html b/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.sldoc.html index 4a49ea2..18e4ee1 100644 --- a/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.sldoc.html +++ b/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock.sldoc.html @@ -56,7 +56,7 @@

Define a Flight Size

size in Ultra Messaging is 1000 messages. For the purpose of this example, it is defined to 500.

-00018  #define DEFAULT_APP_FLIGHT_SIZE 500     /* Used for checking flight size */
+00046  #define DEFAULT_APP_FLIGHT_SIZE 500     /* Used for checking flight size */
 
@@ -65,14 +65,13 @@

Declare Variables

and the char flight[4] variable which is being used to set the flight size via the API.

-00022      lbm_context_t *ctx;         /* Context object */
-00023      lbm_topic_t *topic;         /* Topic object */
-00024      lbm_src_t *src;             /* Source object */
-00025      lbm_src_topic_attr_t * tattr;       /* Source topic attribute object */
-00026      lbm_context_attr_t * cattr;     /* Context attribute object */
-00027      int inflight;                           /* Object used for checking inflight counters */
-00028      char flight[4];
-00029      int err;                /* Used for checking API return codes */
+00051      lbm_context_t *ctx;    /* Context object */
+00052      lbm_topic_t *topic;    /* Topic object */
+00053      lbm_src_t *src;        /* Source object */
+00054      lbm_src_topic_attr_t * tattr;  /* Source topic attribute object */
+00055      int inflight;          /* Object used for checking inflight counters */
+00056      char flight[4];
+00057      int err;
 
@@ -81,18 +80,8 @@

Create the context

Creating a Context

-00042      if (lbm_context_attr_create(&cattr) != 0)
-00043      {
-00044          fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg());
-00045          exit(1);
-00046      }
-00047  
-00048      err = lbm_context_create(&ctx, cattr, NULL, NULL);
-00049      if (err)
-00050      {
-00051          printf("line %d: %s\n", __LINE__, lbm_errmsg());
-00052          exit(1);
-00053      }
+00070      err = lbm_context_create(&ctx, NULL, NULL, NULL);
+00071      EX_LBM_CHK(err);
 
@@ -129,39 +118,22 @@

Create Source

-00055      if (lbm_src_topic_attr_create(&tattr) != 0)
-00056      {
-00057              fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg());
-00058              exit(1);
-00059      }
-00060  
-00061      sprintf(flight, "%d", DEFAULT_APP_FLIGHT_SIZE);
-00062      if (lbm_src_topic_attr_str_setopt(tattr, "ume_flight_size", flight) != 0 )
-00063      {
-00064          fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg());
-00065          exit(1);
-00066      }
-00067  
-00068      /* Assuming there is a store running on the localhost at port 29999 */
-00069      if (lbm_src_topic_attr_str_setopt(tattr, "ume_store", "127.0.0.1:29999") != 0 )
-00070          {
-00071          fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg());
-00072          exit(1);
-00073      }
-00074  
-00075      err = lbm_src_topic_alloc(&topic, ctx, "test.topic", tattr);
-00076      if (err)
-00077      {
-00078          printf("lbm_src_topic_alloc - line %d: %s\n", __LINE__, lbm_errmsg());
-00079          exit(1);
-00080      }
-00081  
-00082      err = lbm_src_create(&src, ctx, topic, NULL, NULL, NULL);
-00083      if (err)
-00084      {
-00085          printf("lbm_src_create - line %d: %s\n", __LINE__, lbm_errmsg());
-00086          exit(1);
-00087      }
+00073      err = lbm_src_topic_attr_create(&tattr);
+00074      EX_LBM_CHK(err);
+00075  
+00076      sprintf(flight, "%d", DEFAULT_APP_FLIGHT_SIZE);
+00077      err = lbm_src_topic_attr_str_setopt(tattr, "ume_flight_size", flight);
+00078      EX_LBM_CHK(err);
+00079  
+00080      /* Assuming there is a store running on the localhost at port 29999 */
+00081      err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", "127.0.0.1:29999");
+00082      EX_LBM_CHK(err);
+00083  
+00084      err = lbm_src_topic_alloc(&topic, ctx, "test.topic", tattr);
+00085      EX_LBM_CHK(err);
+00086  
+00087      err = lbm_src_create(&src, ctx, topic, NULL, NULL, NULL);
+00088      EX_LBM_CHK(err);
 
@@ -170,7 +142,7 @@

Main Send Loop

to stdout whenever the source fails to send a message due to flight size.

-00089      while(1)
+00090      while(1)
 
@@ -182,7 +154,8 @@

Send a Message

by the UM library.

-00091          if (lbm_src_send(src, "test", 4, LBM_SRC_NONBLOCK) == LBM_FAILURE)
+00092          err = lbm_src_send(src, "test", 4, LBM_SRC_NONBLOCK);
+00093          if (err == LBM_FAILURE)
 
@@ -192,7 +165,7 @@

Check Send Error

that either lbm_src_send() failed because it hit flight size, or because it hit the rate limiter.

-00093              if (lbm_errnum() == LBM_EWOULDBLOCK)
+00095              if (lbm_errnum() == LBM_EWOULDBLOCK)
 
@@ -202,15 +175,14 @@

Check Flight Size

and that it cannot send until messages are decalred stable, or not-stable in the event of timeout or store loss.

-00095                  if (lbm_src_get_inflight(src, LBM_FLIGHT_SIZE_TYPE_UME, &inflight, NULL, NULL) == 0) 
-00096                  {
-00097                      /* Check to see if the inflight counter is equal to the configured flight size */
-00098                      if (inflight == DEFAULT_APP_FLIGHT_SIZE)
-00099                      {
-00100                          /* Print alert */
-00101                          printf("ALERT: Source is blocked on flight size: %d\n", inflight);
-00102                      }
-00103                  }
+00097                  err = lbm_src_get_inflight(src, LBM_FLIGHT_SIZE_TYPE_UME, &inflight, NULL, NULL);
+00098                  EX_LBM_CHK(err);
+00099  
+00100                  /* Is inflight counter is equal to the configured flight size? */
+00101                  if (inflight == DEFAULT_APP_FLIGHT_SIZE)
+00102                  {
+00103                      printf("ALERT: Source is blocked on flight size: %d\n", inflight);
+00104                  }
 
@@ -218,20 +190,20 @@

Includes

Include files for this application. Notice the Windows specific include files - these are not necessary for Linux only applications

-00003  #include <stdio.h>
-00004  
-00005  #if defined(_MSC_VER)
-00006  /* Windows-only includes */
-00007  #include <winsock2.h>
-00008  #define SLEEP(s) Sleep((s)*1000)
-00009  #else
-00010  /* Unix-only includes */
-00011  #include <stdlib.h>
-00012  #include <unistd.h>
-00013  #define SLEEP(s) sleep(s)
-00014  #endif
-00015  
-00016  #include <lbm/lbm.h>
+00022  #include <stdio.h>
+00023  
+00024  #if defined(_MSC_VER)
+00025  /* Windows-only includes */
+00026  #include <winsock2.h>
+00027  #define SLEEP(s) Sleep((s)*1000)
+00028  #else
+00029  /* Unix-only includes */
+00030  #include <stdlib.h>
+00031  #include <unistd.h>
+00032  #define SLEEP(s) sleep(s)
+00033  #endif
+00034  
+00035  #include <lbm/lbm.h>
 
diff --git a/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock_c.slsrc b/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock_c.slsrc index a01946c..5d998eb 100644 --- a/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock_c.slsrc +++ b/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock_c.slsrc @@ -1,4 +1,23 @@ -/* Code Disclaimer? */ +/* check_flight_size_ewouldblock.c - see http://ultramessaging.github.io/UMExamples/check_flight_size_ewouldblock/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ /* =semlit,block,includes=*/ #include @@ -17,21 +36,30 @@ #include /* =semlit,endblock,includes=*/ +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ +} while (0) + /* =semlit,block,default_flight=*/ #define DEFAULT_APP_FLIGHT_SIZE 500 /* Used for checking flight size */ /* =semlit,endblock,default_flight=*/ + int main(int argc, char **argv) { /* =semlit,block,variables=*/ - lbm_context_t *ctx; /* Context object */ - lbm_topic_t *topic; /* Topic object */ - lbm_src_t *src; /* Source object */ - lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - int inflight; /* Object used for checking inflight counters */ + lbm_context_t *ctx; /* Context object */ + lbm_topic_t *topic; /* Topic object */ + lbm_src_t *src; /* Source object */ + lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ + int inflight; /* Object used for checking inflight counters */ char flight[4]; - int err; /* Used for checking API return codes */ + int err; /* =semlit,endblock,variables=*/ #if defined(_WIN32) @@ -46,54 +74,27 @@ int main(int argc, char **argv) #endif /* =semlit,block,init_create_context=*/ - if (lbm_context_attr_create(&cattr) != 0) - { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); - exit(1); - } - - err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); /* =semlit,endblock,init_create_context=*/ /* =semlit,block,init_create_source=*/ - if (lbm_src_topic_attr_create(&tattr) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_create(&tattr); + EX_LBM_CHK(err); sprintf(flight, "%d", DEFAULT_APP_FLIGHT_SIZE); - if (lbm_src_topic_attr_str_setopt(tattr, "ume_flight_size", flight) != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_str_setopt(tattr, "ume_flight_size", flight); + EX_LBM_CHK(err); /* Assuming there is a store running on the localhost at port 29999 */ - if (lbm_src_topic_attr_str_setopt(tattr, "ume_store", "127.0.0.1:29999") != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", "127.0.0.1:29999"); + EX_LBM_CHK(err); err = lbm_src_topic_alloc(&topic, ctx, "test.topic", tattr); - if (err) - { - printf("lbm_src_topic_alloc - line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); err = lbm_src_create(&src, ctx, topic, NULL, NULL, NULL); - if (err) - { - printf("lbm_src_create - line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* =semlit,endblock,init_create_source=*/ /* =semlit,block,main_send_loop=*/ @@ -101,28 +102,27 @@ int main(int argc, char **argv) /* =semlit,endblock,main_send_loop=*/ { /* =semlit,block,src_send=*/ - if (lbm_src_send(src, "test", 4, LBM_SRC_NONBLOCK) == LBM_FAILURE) + err = lbm_src_send(src, "test", 4, LBM_SRC_NONBLOCK); + if (err == LBM_FAILURE) /* =semlit,endblock,src_send=*/ { /* =semlit,block,check_send_error=*/ if (lbm_errnum() == LBM_EWOULDBLOCK) /* =semlit,endblock,check_send_error=*/ - { + { /* =semlit,block,get_flight=*/ - if (lbm_src_get_inflight(src, LBM_FLIGHT_SIZE_TYPE_UME, &inflight, NULL, NULL) == 0) + err = lbm_src_get_inflight(src, LBM_FLIGHT_SIZE_TYPE_UME, &inflight, NULL, NULL); + EX_LBM_CHK(err); + + /* Is inflight counter is equal to the configured flight size? */ + if (inflight == DEFAULT_APP_FLIGHT_SIZE) { - /* Check to see if the inflight counter is equal to the configured flight size */ - if (inflight == DEFAULT_APP_FLIGHT_SIZE) - { - /* Print alert */ - printf("ALERT: Source is blocked on flight size: %d\n", inflight); - } + printf("ALERT: Source is blocked on flight size: %d\n", inflight); } /* =semlit,endblock,get_flight=*/ } } } - return 0; -} - + return 0; +} /* main */ diff --git a/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock_c.slsrc.html b/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock_c.slsrc.html index 640edbd..8ae62cb 100644 --- a/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock_c.slsrc.html +++ b/check_flight_size_ewouldblock/c/check_flight_size_ewouldblock_c.slsrc.html @@ -18,76 +18,76 @@
00001 00002 -00003 -00004 -00005 -00006 -00007 -00008 -00009 -00010 -00011 -00012 -00013 -00014 -00015 -00016 +00003 +00004 +00005 +00006 +00007 +00008 +00009 +00010 +00011 +00012 +00013 +00014 +00015 +00016 00017 -00018 +00018 00019 00020 00021 -00022 -00023 -00024 -00025 -00026 -00027 -00028 -00029 -00030 -00031 -00032 -00033 -00034 -00035 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 00036 00037 00038 00039 00040 00041 -00042 -00043 -00044 -00045 -00046 -00047 -00048 -00049 -00050 -00051 -00052 -00053 -00054 -00055 -00056 -00057 -00058 -00059 -00060 -00061 -00062 -00063 -00064 -00065 -00066 -00067 -00068 -00069 -00070 -00071 -00072 +00042 +00043 +00044 +00045 +00046 +00047 +00048 +00049 +00050 +00051 +00052 +00053 +00054 +00055 +00056 +00057 +00058 +00059 +00060 +00061 +00062 +00063 +00064 +00065 +00066 +00067 +00068 +00069 +00070 +00071 +00072 00073 00074 00075 @@ -103,15 +103,15 @@ 00085 00086 00087 -00088 -00089 -00090 -00091 -00092 -00093 +00088 +00089 +00090 +00091 +00092 +00093 00094 -00095 -00096 +00095 +00096 00097 00098 00099 @@ -119,14 +119,33 @@ 00101 00102 00103 -00104 +00104 00105 00106 00107 00108 00109 00110 - /* Code Disclaimer? */ + /* check_flight_size_ewouldblock.c - see http://ultramessaging.github.io/UMExamples/check_flight_size_ewouldblock/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include <stdio.h> @@ -143,18 +162,27 @@ #include <lbm/lbm.h> + /* Example error checking macro. Include after each UM call. */ + #define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ + } while (0) + #define DEFAULT_APP_FLIGHT_SIZE 500 /* Used for checking flight size */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object */ - lbm_topic_t *topic; /* Topic object */ - lbm_src_t *src; /* Source object */ - lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - int inflight; /* Object used for checking inflight counters */ + lbm_context_t *ctx; /* Context object */ + lbm_topic_t *topic; /* Topic object */ + lbm_src_t *src; /* Source object */ + lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ + int inflight; /* Object used for checking inflight counters */ char flight[4]; - int err; /* Used for checking API return codes */ + int err; #if defined(_WIN32) /* windows-specific code */ @@ -167,75 +195,47 @@ } #endif - if (lbm_context_attr_create(&cattr) != 0) - { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); - err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - if (lbm_src_topic_attr_create(&tattr) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_create(&tattr); + EX_LBM_CHK(err); sprintf(flight, "%d", DEFAULT_APP_FLIGHT_SIZE); - if (lbm_src_topic_attr_str_setopt(tattr, "ume_flight_size", flight) != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_str_setopt(tattr, "ume_flight_size", flight); + EX_LBM_CHK(err); /* Assuming there is a store running on the localhost at port 29999 */ - if (lbm_src_topic_attr_str_setopt(tattr, "ume_store", "127.0.0.1:29999") != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", "127.0.0.1:29999"); + EX_LBM_CHK(err); err = lbm_src_topic_alloc(&topic, ctx, "test.topic", tattr); - if (err) - { - printf("lbm_src_topic_alloc - line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); err = lbm_src_create(&src, ctx, topic, NULL, NULL, NULL); - if (err) - { - printf("lbm_src_create - line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); while(1) { - if (lbm_src_send(src, "test", 4, LBM_SRC_NONBLOCK) == LBM_FAILURE) + err = lbm_src_send(src, "test", 4, LBM_SRC_NONBLOCK); + if (err == LBM_FAILURE) { if (lbm_errnum() == LBM_EWOULDBLOCK) - { - if (lbm_src_get_inflight(src, LBM_FLIGHT_SIZE_TYPE_UME, &inflight, NULL, NULL) == 0) + { + err = lbm_src_get_inflight(src, LBM_FLIGHT_SIZE_TYPE_UME, &inflight, NULL, NULL); + EX_LBM_CHK(err); + + /* Is inflight counter is equal to the configured flight size? */ + if (inflight == DEFAULT_APP_FLIGHT_SIZE) { - /* Check to see if the inflight counter is equal to the configured flight size */ - if (inflight == DEFAULT_APP_FLIGHT_SIZE) - { - /* Print alert */ - printf("ALERT: Source is blocked on flight size: %d\n", inflight); - } + printf("ALERT: Source is blocked on flight size: %d\n", inflight); } } } } - return 0; - } - + return 0; + } /* main */
diff --git a/clean_shutdown/c/clean_shutdown.c b/clean_shutdown/c/clean_shutdown.c index 00eaae6..5a929a6 100644 --- a/clean_shutdown/c/clean_shutdown.c +++ b/clean_shutdown/c/clean_shutdown.c @@ -1,6 +1,26 @@ -/* Code Disclaimer? */ +/* clean_shutdown.c - see http://ultramessaging.github.io/UMExamples/clean_shutdown/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include +#include #if defined(_MSC_VER) /* Windows-only includes */ @@ -18,13 +38,14 @@ int cleanup = 0; /* Example error checking macro. Include after each UM call. */ - #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ - } while (0) +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ +} while (0) + #if defined(_WIN32) DWORD WINAPI eq_thread(void *arg) @@ -45,13 +66,13 @@ void *eq_thread(void *arg) if (cleanup) break; } -} + return 0; +} /* eq_thread */ + /* Callback used to handle request message for receiver */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { - int err; - switch (msg->type) { case LBM_MSG_DATA: printf("LBM_MSG_DATA received\n"); @@ -59,44 +80,41 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) } cleanup = 1; -} + return 0; +} /* rcv_handle_msg */ + int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ - lbm_context_attr_t * cattr; /* pointer to context attribute object */ lbm_topic_t *stopic; /* Source Topic object */ lbm_src_t *src; /* Source object */ lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ lbm_topic_t *rtopic; /* Receiver Topic object */ lbm_event_queue_t *evq = NULL; /* pointer to eventQ handle */ - int err; /* return status of lbm functions (true=error) */ + int err; #if defined(_WIN32) - HANDLE wthrdh; + HANDLE wthrdh; #else - pthread_t pthid; + pthread_t pthid; #endif /* _WIN32 */ - #if defined(_MSC_VER) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + exit(1); + } #endif err = lbm_event_queue_create(&evq, NULL, NULL, NULL); EX_LBM_CHK(err); - err = lbm_context_attr_create(&cattr); - EX_LBM_CHK(err); - - err = lbm_context_create(&ctx, cattr, NULL, NULL); + err = lbm_context_create(&ctx, NULL, NULL, NULL); EX_LBM_CHK(err); err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL); @@ -118,15 +136,15 @@ int main(int argc, char **argv) EX_LBM_CHK(err); #if defined(_WIN32) - if ((wthrdh = CreateThread(NULL, 0, eq_thread, evq, 0, NULL)) == NULL) { - fprintf(stderr, "could not create thread\n"); - exit(1); - } + if ((wthrdh = CreateThread(NULL, 0, eq_thread, evq, 0, NULL)) == NULL) { + fprintf(stderr, "could not create thread\n"); + exit(1); + } #else - if (pthread_create(&pthid, NULL, eq_thread, evq) != 0) { - fprintf(stderr, "could not spawn thread\n"); - exit(1); - } + if (pthread_create(&pthid, NULL, eq_thread, evq) != 0) { + fprintf(stderr, "could not spawn thread\n"); + exit(1); + } #endif /* _WIN32 */ SLEEP(1); @@ -139,18 +157,24 @@ int main(int argc, char **argv) SLEEP(1); } - lbm_event_dispatch_unblock(evq); + err = lbm_event_dispatch_unblock(evq); + EX_LBM_CHK(err); #if defined(_WIN32) - WaitForSingleObject(wthrdh, INFINITE); + WaitForSingleObject(wthrdh, INFINITE); #else - pthread_join(pthid, NULL); + pthread_join(pthid, NULL); #endif /* _WIN32 */ - lbm_rcv_delete(rcv); - lbm_src_delete(src); - lbm_context_delete(ctx); - lbm_event_queue_delete(evq); - return 0; -} + err = lbm_rcv_delete(rcv); + EX_LBM_CHK(err); + err = lbm_src_delete(src); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); + err = lbm_event_queue_delete(evq); + EX_LBM_CHK(err); + + return 0; +} /* main */ diff --git a/clean_shutdown/c/clean_shutdown.sldoc.html b/clean_shutdown/c/clean_shutdown.sldoc.html index 2983d2f..86997bc 100644 --- a/clean_shutdown/c/clean_shutdown.sldoc.html +++ b/clean_shutdown/c/clean_shutdown.sldoc.html @@ -36,14 +36,11 @@

Create Event Queue and Context

event queue first.

-00093      err = lbm_event_queue_create(&evq, NULL, NULL, NULL);
-00094      EX_LBM_CHK(err);
-00095  
-00096      err = lbm_context_attr_create(&cattr);
-00097      EX_LBM_CHK(err);
-00098  
-00099      err = lbm_context_create(&ctx, cattr, NULL, NULL);
-00100      EX_LBM_CHK(err);
+00114      err = lbm_event_queue_create(&evq, NULL, NULL, NULL);
+00115      EX_LBM_CHK(err);
+00116  
+00117      err = lbm_context_create(&ctx, NULL, NULL, NULL);
+00118      EX_LBM_CHK(err);
 
@@ -52,23 +49,23 @@

Create Source and Receiver

later, it is important to delete all sources and receivers before deleting the context.

-00102      err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL);
-00103      EX_LBM_CHK(err);
-00104  
-00105      err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, evq);
-00106      EX_LBM_CHK(err);
-00107  
-00108      err = lbm_src_topic_attr_create(&tattr);
-00109      EX_LBM_CHK(err);
-00110  
-00111      err = lbm_src_topic_alloc(&stopic, ctx, "test.topic", tattr);
-00112      EX_LBM_CHK(err);
-00113  
-00114      err = lbm_src_topic_attr_delete(tattr);
-00115      EX_LBM_CHK(err);
-00116  
-00117      err = lbm_src_create(&src, ctx, stopic, NULL, NULL, NULL);
-00118      EX_LBM_CHK(err);
+00120      err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL);
+00121      EX_LBM_CHK(err);
+00122  
+00123      err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, evq);
+00124      EX_LBM_CHK(err);
+00125  
+00126      err = lbm_src_topic_attr_create(&tattr);
+00127      EX_LBM_CHK(err);
+00128  
+00129      err = lbm_src_topic_alloc(&stopic, ctx, "test.topic", tattr);
+00130      EX_LBM_CHK(err);
+00131  
+00132      err = lbm_src_topic_attr_delete(tattr);
+00133      EX_LBM_CHK(err);
+00134  
+00135      err = lbm_src_create(&src, ctx, stopic, NULL, NULL, NULL);
+00136      EX_LBM_CHK(err);
 
@@ -77,17 +74,17 @@

Spawn Event Queue Thread

application use case as users would want an independent thread that only processes events (like messages) for better performace.

-00120  #if defined(_WIN32)
-00121          if ((wthrdh = CreateThread(NULL, 0, eq_thread, evq, 0, NULL)) == NULL) {
-00122                  fprintf(stderr, "could not create thread\n");
-00123                  exit(1);
-00124          }
-00125  #else
-00126          if (pthread_create(&pthid, NULL, eq_thread, evq) != 0) {
-00127                  fprintf(stderr, "could not spawn thread\n");
-00128                  exit(1);
-00129          }
-00130  #endif /* _WIN32 */
+00138  #if defined(_WIN32)
+00139      if ((wthrdh = CreateThread(NULL, 0, eq_thread, evq, 0, NULL)) == NULL) {
+00140          fprintf(stderr, "could not create thread\n");
+00141          exit(1);
+00142      }
+00143  #else
+00144      if (pthread_create(&pthid, NULL, eq_thread, evq) != 0) {
+00145          fprintf(stderr, "could not spawn thread\n");
+00146          exit(1);
+00147      }
+00148  #endif /* _WIN32 */
 
@@ -97,15 +94,15 @@

Sleep, Send Message, and Wait

thread will simply wait for the receiver to receive the message on the event queue.

-00132      SLEEP(1);
-00133  
-00134      err = lbm_src_send(src, "hello", 5, LBM_MSG_FLUSH);
-00135      EX_LBM_CHK(err);    
-00136  
-00137      /* Wait */
-00138      while (!cleanup) {  
-00139          SLEEP(1);
-00140      }
+00150      SLEEP(1);
+00151  
+00152      err = lbm_src_send(src, "hello", 5, LBM_MSG_FLUSH);
+00153      EX_LBM_CHK(err);    
+00154  
+00155      /* Wait */
+00156      while (!cleanup) {  
+00157          SLEEP(1);
+00158      }
 
@@ -115,13 +112,14 @@

Unblock Event Queue and Kill Thread

thread before continuing.

-00142      lbm_event_dispatch_unblock(evq);
-00143  
-00144  #if defined(_WIN32)
-00145                  WaitForSingleObject(wthrdh, INFINITE);
-00146  #else
-00147                  pthread_join(pthid, NULL);
-00148  #endif /* _WIN32 */
+00160      err = lbm_event_dispatch_unblock(evq);
+00161      EX_LBM_CHK(err);
+00162  
+00163  #if defined(_WIN32)
+00164      WaitForSingleObject(wthrdh, INFINITE);
+00165  #else
+00166      pthread_join(pthid, NULL);
+00167  #endif /* _WIN32 */
 
@@ -130,10 +128,14 @@

Delete Objects in the Correct Order

has been closed. The application can now delete all UM objects in the correct order.

-00150      lbm_rcv_delete(rcv);
-00151      lbm_src_delete(src);
-00152      lbm_context_delete(ctx);
-00153      lbm_event_queue_delete(evq);
+00169      err = lbm_rcv_delete(rcv);
+00170      EX_LBM_CHK(err);
+00171      err = lbm_src_delete(src);
+00172      EX_LBM_CHK(err);
+00173      err = lbm_context_delete(ctx);
+00174      EX_LBM_CHK(err);
+00175      err = lbm_event_queue_delete(evq);
+00176      EX_LBM_CHK(err);
 
@@ -143,13 +145,13 @@

Error Checking

print a message and exit the program:

-00021    #define EX_LBM_CHK(err) do { \
-00022        if ((err) < 0) { \
-00023                fprintf(stderr, "%s:%d, lbm error: '%s'\n", \
-00024                __FILE__, __LINE__, lbm_errmsg()); \
-00025                exit(1); \
-00026        }  \
-00027    } while (0)
+00041  #define EX_LBM_CHK(err) do { \
+00042      if ((err) < 0) { \
+00043          fprintf(stderr, "%s:%d, lbm error: '%s'\n", \
+00044              __FILE__, __LINE__, lbm_errmsg()); \
+00045          exit(1); \
+00046      }  \
+00047  } while (0)
 
@@ -166,20 +168,21 @@

Includes

are not necessary for Linux only applications

-00003  #include <stdio.h>
-00004  
-00005  #if defined(_MSC_VER)
-00006  /* Windows-only includes */
-00007  #include <winsock2.h>
-00008  #define SLEEP(s) Sleep((s)*1000)
-00009  #else
-00010  /* Unix-only includes */
-00011  #include <stdlib.h>
-00012  #include <unistd.h>
-00013  #define SLEEP(s) sleep(s)
-00014  #endif
-00015  
-00016  #include <lbm/lbm.h>
+00022  #include <stdio.h>
+00023  #include <pthread.h>
+00024  
+00025  #if defined(_MSC_VER)
+00026  /* Windows-only includes */
+00027  #include <winsock2.h>
+00028  #define SLEEP(s) Sleep((s)*1000)
+00029  #else
+00030  /* Unix-only includes */
+00031  #include <stdlib.h>
+00032  #include <unistd.h>
+00033  #define SLEEP(s) sleep(s)
+00034  #endif
+00035  
+00036  #include <lbm/lbm.h>
 
@@ -187,16 +190,16 @@

Windows Only

Windows applications must initialize the Winsock library to utilize sockets.

-00082  #if defined(_MSC_VER)
-00083          /* windows-specific code */
-00084          WSADATA wsadata;
-00085          int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata);
-00086          if (wsStat != 0)
-00087          {
-00088                  printf("line %d: wsStat=%d\n",__LINE__,wsStat);
-00089                  exit(1);
-00090          }
-00091  #endif
+00103  #if defined(_MSC_VER)
+00104      /* windows-specific code */
+00105      WSADATA wsadata;
+00106      int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata);
+00107      if (wsStat != 0)
+00108      {
+00109          printf("line %d: wsStat=%d\n",__LINE__,wsStat);
+00110          exit(1);
+00111      }
+00112  #endif
 
diff --git a/clean_shutdown/c/clean_shutdown_c.slsrc b/clean_shutdown/c/clean_shutdown_c.slsrc index 7a65bd3..981958f 100644 --- a/clean_shutdown/c/clean_shutdown_c.slsrc +++ b/clean_shutdown/c/clean_shutdown_c.slsrc @@ -1,7 +1,27 @@ -/* Code Disclaimer? */ +/* clean_shutdown.c - see http://ultramessaging.github.io/UMExamples/clean_shutdown/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ /* =semlit,block,includes=*/ #include +#include #if defined(_MSC_VER) /* Windows-only includes */ @@ -21,15 +41,16 @@ int cleanup = 0; /* Example error checking macro. Include after each UM call. */ /* =semlit,block,error_check=*/ - #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ - } while (0) +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ +} while (0) /* =semlit,endblock,error_check=*/ + /* =semlit,block,eq_thread=*/ #if defined(_WIN32) DWORD WINAPI eq_thread(void *arg) @@ -50,14 +71,14 @@ void *eq_thread(void *arg) if (cleanup) break; } -} + return 0; +} /* eq_thread */ /* =semlit,endblock,eq_thread=*/ + /* Callback used to handle request message for receiver */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { - int err; - switch (msg->type) { case LBM_MSG_DATA: printf("LBM_MSG_DATA received\n"); @@ -65,47 +86,44 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) } cleanup = 1; -} + return 0; +} /* rcv_handle_msg */ + int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ - lbm_context_attr_t * cattr; /* pointer to context attribute object */ lbm_topic_t *stopic; /* Source Topic object */ lbm_src_t *src; /* Source object */ lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ lbm_topic_t *rtopic; /* Receiver Topic object */ lbm_event_queue_t *evq = NULL; /* pointer to eventQ handle */ - int err; /* return status of lbm functions (true=error) */ + int err; #if defined(_WIN32) - HANDLE wthrdh; + HANDLE wthrdh; #else - pthread_t pthid; + pthread_t pthid; #endif /* _WIN32 */ - - /* =semlit,block,windows=*/ + /* =semlit,block,windows=*/ #if defined(_MSC_VER) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + exit(1); + } #endif - /* =semlit,endblock,windows=*/ + /* =semlit,endblock,windows=*/ /* =semlit,block,eq_ctx_create= */ err = lbm_event_queue_create(&evq, NULL, NULL, NULL); EX_LBM_CHK(err); - err = lbm_context_attr_create(&cattr); - EX_LBM_CHK(err); - - err = lbm_context_create(&ctx, cattr, NULL, NULL); + err = lbm_context_create(&ctx, NULL, NULL, NULL); EX_LBM_CHK(err); /* =semlit,endblock,eq_ctx_create=*/ @@ -129,19 +147,19 @@ int main(int argc, char **argv) EX_LBM_CHK(err); /* =semlit,endblock,src_rcv_create=*/ - /* =semlit,block,spawn_thread=*/ + /* =semlit,block,spawn_thread=*/ #if defined(_WIN32) - if ((wthrdh = CreateThread(NULL, 0, eq_thread, evq, 0, NULL)) == NULL) { - fprintf(stderr, "could not create thread\n"); - exit(1); - } + if ((wthrdh = CreateThread(NULL, 0, eq_thread, evq, 0, NULL)) == NULL) { + fprintf(stderr, "could not create thread\n"); + exit(1); + } #else - if (pthread_create(&pthid, NULL, eq_thread, evq) != 0) { - fprintf(stderr, "could not spawn thread\n"); - exit(1); - } + if (pthread_create(&pthid, NULL, eq_thread, evq) != 0) { + fprintf(stderr, "could not spawn thread\n"); + exit(1); + } #endif /* _WIN32 */ - /* =semlit,endblock,spawn_thread=*/ + /* =semlit,endblock,spawn_thread=*/ /* =semlit,block,wait_and_send=*/ SLEEP(1); @@ -156,21 +174,27 @@ int main(int argc, char **argv) /* =semlit,endblock,wait_and_send=*/ /* =semlit,block,unblock_join=*/ - lbm_event_dispatch_unblock(evq); + err = lbm_event_dispatch_unblock(evq); + EX_LBM_CHK(err); #if defined(_WIN32) - WaitForSingleObject(wthrdh, INFINITE); + WaitForSingleObject(wthrdh, INFINITE); #else - pthread_join(pthid, NULL); + pthread_join(pthid, NULL); #endif /* _WIN32 */ /* =semlit,endblock,unblock_join=*/ /* =semlit,block,delete=*/ - lbm_rcv_delete(rcv); - lbm_src_delete(src); - lbm_context_delete(ctx); - lbm_event_queue_delete(evq); + err = lbm_rcv_delete(rcv); + EX_LBM_CHK(err); + err = lbm_src_delete(src); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); + err = lbm_event_queue_delete(evq); + EX_LBM_CHK(err); /* =semlit,endblock,delete=*/ - return 0; -} + + return 0; +} /* main */ diff --git a/clean_shutdown/c/clean_shutdown_c.slsrc.html b/clean_shutdown/c/clean_shutdown_c.slsrc.html index 7fae85a..b375be8 100644 --- a/clean_shutdown/c/clean_shutdown_c.slsrc.html +++ b/clean_shutdown/c/clean_shutdown_c.slsrc.html @@ -18,74 +18,74 @@
00001 00002 -00003 -00004 -00005 -00006 -00007 -00008 -00009 -00010 -00011 -00012 -00013 -00014 -00015 -00016 +00003 +00004 +00005 +00006 +00007 +00008 +00009 +00010 +00011 +00012 +00013 +00014 +00015 +00016 00017 00018 00019 00020 -00021 -00022 -00023 -00024 -00025 -00026 -00027 -00028 -00029 -00030 -00031 -00032 -00033 -00034 -00035 -00036 -00037 -00038 -00039 -00040 -00041 -00042 -00043 -00044 -00045 -00046 -00047 -00048 +00021 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 +00036 +00037 +00038 +00039 +00040 +00041 +00042 +00043 +00044 +00045 +00046 +00047 +00048 00049 -00050 -00051 -00052 -00053 -00054 -00055 -00056 -00057 -00058 -00059 -00060 -00061 -00062 -00063 -00064 -00065 -00066 -00067 -00068 -00069 -00070 +00050 +00051 +00052 +00053 +00054 +00055 +00056 +00057 +00058 +00059 +00060 +00061 +00062 +00063 +00064 +00065 +00066 +00067 +00068 +00069 +00070 00071 00072 00073 @@ -97,84 +97,128 @@ 00079 00080 00081 -00082 -00083 -00084 -00085 -00086 -00087 -00088 -00089 -00090 -00091 +00082 +00083 +00084 +00085 +00086 +00087 +00088 +00089 +00090 +00091 00092 -00093 -00094 -00095 -00096 -00097 -00098 -00099 -00100 +00093 +00094 +00095 +00096 +00097 +00098 +00099 +00100 00101 -00102 -00103 -00104 -00105 -00106 -00107 -00108 -00109 -00110 -00111 -00112 -00113 -00114 -00115 -00116 -00117 -00118 +00102 +00103 +00104 +00105 +00106 +00107 +00108 +00109 +00110 +00111 +00112 +00113 +00114 +00115 +00116 +00117 +00118 00119 -00120 -00121 -00122 -00123 -00124 -00125 -00126 -00127 -00128 -00129 -00130 -00131 -00132 -00133 -00134 -00135 -00136 -00137 -00138 -00139 -00140 -00141 -00142 -00143 -00144 -00145 -00146 -00147 -00148 +00120 +00121 +00122 +00123 +00124 +00125 +00126 +00127 +00128 +00129 +00130 +00131 +00132 +00133 +00134 +00135 +00136 +00137 +00138 +00139 +00140 +00141 +00142 +00143 +00144 +00145 +00146 +00147 +00148 00149 -00150 -00151 -00152 -00153 -00154 -00155 -00156 - /* Code Disclaimer? */ +00150 +00151 +00152 +00153 +00154 +00155 +00156 +00157 +00158 +00159 +00160 +00161 +00162 +00163 +00164 +00165 +00166 +00167 +00168 +00169 +00170 +00171 +00172 +00173 +00174 +00175 +00176 +00177 +00178 +00179 +00180 + /* clean_shutdown.c - see http://ultramessaging.github.io/UMExamples/clean_shutdown/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include <stdio.h> + #include <pthread.h> #if defined(_MSC_VER) /* Windows-only includes */ @@ -192,13 +236,14 @@ int cleanup = 0; /* Example error checking macro. Include after each UM call. */ - #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ - } while (0) + #define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ + } while (0) + #if defined(_WIN32) DWORD WINAPI eq_thread(void *arg) @@ -219,13 +264,13 @@ if (cleanup) break; } - } + return 0; + } /* eq_thread */ + /* Callback used to handle request message for receiver */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { - int err; - switch (msg->type) { case LBM_MSG_DATA: printf("LBM_MSG_DATA received\n"); @@ -233,44 +278,41 @@ } cleanup = 1; - } + return 0; + } /* rcv_handle_msg */ + int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ - lbm_context_attr_t * cattr; /* pointer to context attribute object */ lbm_topic_t *stopic; /* Source Topic object */ lbm_src_t *src; /* Source object */ lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ lbm_topic_t *rtopic; /* Receiver Topic object */ lbm_event_queue_t *evq = NULL; /* pointer to eventQ handle */ - int err; /* return status of lbm functions (true=error) */ + int err; #if defined(_WIN32) - HANDLE wthrdh; + HANDLE wthrdh; #else - pthread_t pthid; + pthread_t pthid; #endif /* _WIN32 */ - #if defined(_MSC_VER) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + exit(1); + } #endif err = lbm_event_queue_create(&evq, NULL, NULL, NULL); EX_LBM_CHK(err); - err = lbm_context_attr_create(&cattr); - EX_LBM_CHK(err); - - err = lbm_context_create(&ctx, cattr, NULL, NULL); + err = lbm_context_create(&ctx, NULL, NULL, NULL); EX_LBM_CHK(err); err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL); @@ -292,15 +334,15 @@ EX_LBM_CHK(err); #if defined(_WIN32) - if ((wthrdh = CreateThread(NULL, 0, eq_thread, evq, 0, NULL)) == NULL) { - fprintf(stderr, "could not create thread\n"); - exit(1); - } + if ((wthrdh = CreateThread(NULL, 0, eq_thread, evq, 0, NULL)) == NULL) { + fprintf(stderr, "could not create thread\n"); + exit(1); + } #else - if (pthread_create(&pthid, NULL, eq_thread, evq) != 0) { - fprintf(stderr, "could not spawn thread\n"); - exit(1); - } + if (pthread_create(&pthid, NULL, eq_thread, evq) != 0) { + fprintf(stderr, "could not spawn thread\n"); + exit(1); + } #endif /* _WIN32 */ SLEEP(1); @@ -313,20 +355,26 @@ SLEEP(1); } - lbm_event_dispatch_unblock(evq); + err = lbm_event_dispatch_unblock(evq); + EX_LBM_CHK(err); #if defined(_WIN32) - WaitForSingleObject(wthrdh, INFINITE); + WaitForSingleObject(wthrdh, INFINITE); #else - pthread_join(pthid, NULL); + pthread_join(pthid, NULL); #endif /* _WIN32 */ - lbm_rcv_delete(rcv); - lbm_src_delete(src); - lbm_context_delete(ctx); - lbm_event_queue_delete(evq); - return 0; - } + err = lbm_rcv_delete(rcv); + EX_LBM_CHK(err); + err = lbm_src_delete(src); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); + err = lbm_event_queue_delete(evq); + EX_LBM_CHK(err); + + return 0; + } /* main */
diff --git a/dump_attributes/c/dump_attributes.c b/dump_attributes/c/dump_attributes.c index bf51ac0..9e20201 100644 --- a/dump_attributes/c/dump_attributes.c +++ b/dump_attributes/c/dump_attributes.c @@ -1,4 +1,23 @@ -/* Example on setting Ultra Messaging attributes */ +/* dump_attributes.c - see http://ultramessaging.github.io/UMExamples/dump_attributes/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include @@ -15,23 +34,32 @@ #include +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ +} while (0) + + int main(int argc, char **argv) { - lbm_context_t *ctx; /* pointer to context object */ - lbm_topic_t *topic_1; /* pointer to topic object */ - lbm_topic_t *topic_2; /* pointer to topic object */ - lbm_src_t *src_1; /* pointer to source object */ - lbm_src_t *src_2; /* pointer to source object */ - lbm_src_topic_attr_t *tattr_1; /* pointer to source attribute object */ - lbm_src_topic_attr_t *tattr_2; /* pointer to source attribute object */ - lbm_context_attr_t * cattr; /* pointer to context attribute object */ + lbm_context_t *ctx; /* pointer to context object */ + lbm_topic_t *topic_1; /* pointer to topic object */ + lbm_topic_t *topic_2; /* pointer to topic object */ + lbm_src_t *src_1; /* pointer to source object */ + lbm_src_t *src_2; /* pointer to source object */ + lbm_src_topic_attr_t *tattr_1; /* pointer to source attribute object */ + lbm_src_topic_attr_t *tattr_2; /* pointer to source attribute object */ + lbm_context_attr_t * cattr; /* pointer to context attribute object */ lbm_config_option_t *configs_option_ptr; /* pointer to configuration options returned from lib*/ - lbm_uint16_t res_port; /* Int to set resolver port */ - lbm_uint16_t des_port; /* Int to set lbtrm destination port */ - int err; /* return status of lbm functions (true=error) */ - int entries; /* Int used to count number of config entries */ - int idx; /* Int used to iterate across config entries */ - + lbm_uint16_t res_port; /* Int to set resolver port */ + lbm_uint16_t des_port; /* Int to set lbtrm destination port */ + int entries; /* Int used to count number of config entries */ + int idx; /* Int used to iterate across config entries */ + int err; #if defined(_MSC_VER) /* windows-specific code */ @@ -45,116 +73,70 @@ int main(int argc, char **argv) #endif /* Initialize the defaults for the context attribute object */ - if (lbm_context_attr_create(&cattr) != 0) - { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_context_attr_create(&cattr); + EX_LBM_CHK(err); /* Setting the resolver address using the string method */ - if (lbm_context_attr_str_setopt(cattr, "resolver_multicast_address", "224.10.11.12") != 0) - { - fprintf(stderr, "lbm_context_attr_str_setopt:resolver_multicast_address: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_context_attr_str_setopt(cattr, "resolver_multicast_address", "224.10.11.12"); + EX_LBM_CHK(err); /* Setting the resolver port using the data-type value method */ res_port = 12345; - if (lbm_context_attr_setopt(cattr, "resolver_multicast_port", &res_port, sizeof(lbm_uint16_t)) != 0) - { - fprintf(stderr, "lbm_context_attr_setopt:resolver_mutlicast_port: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_context_attr_setopt(cattr, "resolver_multicast_port", &res_port, sizeof(lbm_uint16_t)); + EX_LBM_CHK(err); /* Creating the context */ err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* Delete the context attribute object */ - lbm_context_attr_delete(cattr); + err = lbm_context_attr_delete(cattr); + EX_LBM_CHK(err); /* Initializing the source attribute object */ - if (lbm_src_topic_attr_create(&tattr_1) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_create(&tattr_1); + EX_LBM_CHK(err); /* Setting the transport via the source topic string method */ - if (lbm_src_topic_attr_str_setopt(tattr_1, "transport", "lbtrm") != 0) - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_str_setopt(tattr_1, "transport", "lbtrm"); + EX_LBM_CHK(err); /* Setting the lbtrm destination port via the direct value set method */ des_port = 14001; - if (lbm_src_topic_attr_setopt(tattr_1, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_setopt:transport_lbtrm_destination_port: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_setopt(tattr_1, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)); + EX_LBM_CHK(err); /* Allocating the topic */ err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic.1", tattr_1); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* Creating the source */ err = lbm_src_create(&src_1, ctx, topic_1, NULL, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* Initialized the second source attributes as a copy of the first */ - if (lbm_src_topic_attr_dup(&tattr_2, tattr_1) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_dup: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_dup(&tattr_2, tattr_1); + EX_LBM_CHK(err); /* Now modify the destination port for this second source to put the publisher on a different transport */ des_port = 14002; - if (lbm_src_topic_attr_setopt(tattr_2, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_setopt:transport_lbtrm_destination_port: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_setopt(tattr_2, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)); + EX_LBM_CHK(err); /* Allocating the second topic */ err = lbm_src_topic_alloc(&topic_2, ctx, "test.topic.2", tattr_2); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* Creating the source */ err = lbm_src_create(&src_2, ctx, topic_2, NULL, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - /* each lbm object (ctx, src, rcv) has a different number of configuration */ - /* attributes. To allocate the array, call the corresponding *_option_size */ - /* function and allocate enough memory to contain the return strings */ + EX_LBM_CHK(err); + /* each lbm object (ctx, src, rcv) has a different number of configuration + * attributes. To allocate the array, call the corresponding *_option_size + * function and allocate enough memory to contain the return strings. */ entries = lbm_context_attr_option_size(); configs_option_ptr = malloc(entries * sizeof(lbm_config_option_t)); /* Get the attributes for the context */ - if (LBM_FAILURE == lbm_context_dump(ctx, &entries, configs_option_ptr)) - { - fprintf(stderr, "lbm_context_dump error: %s\n", lbm_errmsg()); - return; - } + err = lbm_context_dump(ctx, &entries, configs_option_ptr); + EX_LBM_CHK(err); /* iterate through the returned array and print each option */ for (idx = 0; idx < entries; ++idx) { @@ -163,6 +145,7 @@ int main(int argc, char **argv) /* done with context attributes so free the allocated memory */ free(configs_option_ptr); + /* each lbm object (ctx, src, rcv) has a different number of configuration */ /* options to allocate the array, call the corresponding *_option_size */ /* function and allocate enough memory to contain the return strings */ @@ -170,11 +153,8 @@ int main(int argc, char **argv) configs_option_ptr = malloc(entries * sizeof(lbm_config_option_t)); /* Get the attributes for the first source */ - if (LBM_FAILURE == lbm_src_topic_dump(src_1, &entries, configs_option_ptr)) - { - fprintf(stderr, "lbm_src_topic_dump error: %s\n", lbm_errmsg()); - return; - } + err = lbm_src_topic_dump(src_1, &entries, configs_option_ptr); + EX_LBM_CHK(err); /* iterate through the returned array and print each option */ for (idx = 0; idx < entries; ++idx) { @@ -184,11 +164,8 @@ int main(int argc, char **argv) /* note that configs_option_ptr can be reused for multiple sources without being freed. */ /* Get the attributes for the second source */ - if (LBM_FAILURE == lbm_src_topic_dump(src_2, &entries, configs_option_ptr)) - { - fprintf(stderr, "lbm_src_topic_dump error: %s\n", lbm_errmsg()); - return; - } + err = lbm_src_topic_dump(src_2, &entries, configs_option_ptr); + EX_LBM_CHK(err); /* iterate through the returned array and print each option */ for (idx = 0; idx < entries; ++idx) { @@ -197,18 +174,24 @@ int main(int argc, char **argv) /* done with source attributes so free the allocated memory */ free(configs_option_ptr); + /* Delete the first and second source topic attribute objects */ - lbm_src_topic_attr_delete(tattr_1); - lbm_src_topic_attr_delete(tattr_2); + err = lbm_src_topic_attr_delete(tattr_1); + EX_LBM_CHK(err); + err = lbm_src_topic_attr_delete(tattr_2); + EX_LBM_CHK(err); /* Finished with all LBM functions, delete the source and context object. */ - lbm_src_delete(src_1); - lbm_src_delete(src_2); - lbm_context_delete(ctx); + err = lbm_src_delete(src_1); + EX_LBM_CHK(err); + err = lbm_src_delete(src_2); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); #if defined(_MSC_VER) WSACleanup(); #endif - return 0; -} + return 0; +} /* main */ diff --git a/dump_attributes/c/dump_attributes.sldoc.html b/dump_attributes/c/dump_attributes.sldoc.html index df37e8d..700f74f 100644 --- a/dump_attributes/c/dump_attributes.sldoc.html +++ b/dump_attributes/c/dump_attributes.sldoc.html @@ -34,43 +34,26 @@

Initialization

object is used to configure a sources attributes.

-00079      /* Initializing the source attribute object */
-00080      if (lbm_src_topic_attr_create(&tattr_1) != 0)
-00081      {
-00082          fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg());
-00083          exit(1);
-00084      }
-00085  
-00086      /* Setting the transport via the source topic string method */
-00087      if (lbm_src_topic_attr_str_setopt(tattr_1, "transport", "lbtrm") != 0)
-00088      {
-00089          fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg());
-00090          exit(1);
-00091      }
-00092  
-00093      /* Setting the lbtrm destination port via the direct value set method */
-00094      des_port = 14001;
-00095      if (lbm_src_topic_attr_setopt(tattr_1, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)) != 0)
-00096      {
-00097          fprintf(stderr, "lbm_src_topic_attr_setopt:transport_lbtrm_destination_port: %s\n", lbm_errmsg());
-00098          exit(1);
-00099      }
-00100  
-00101      /* Allocating the topic */
-00102      err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic.1", tattr_1);
-00103      if (err)
-00104      {
-00105          printf("line %d: %s\n", __LINE__, lbm_errmsg());
-00106          exit(1);
-00107      }
-00108  
-00109      /* Creating the source */
-00110      err = lbm_src_create(&src_1, ctx, topic_1, NULL, NULL, NULL);
-00111      if (err)
-00112      {
-00113          printf("line %d: %s\n", __LINE__, lbm_errmsg());
-00114          exit(1);
-00115      }
+00095      /* Initializing the source attribute object */
+00096      err = lbm_src_topic_attr_create(&tattr_1);
+00097      EX_LBM_CHK(err);
+00098  
+00099      /* Setting the transport via the source topic string method */
+00100      err = lbm_src_topic_attr_str_setopt(tattr_1, "transport", "lbtrm");
+00101      EX_LBM_CHK(err);
+00102  
+00103      /* Setting the lbtrm destination port via the direct value set method */
+00104      des_port = 14001;
+00105      err = lbm_src_topic_attr_setopt(tattr_1, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t));
+00106      EX_LBM_CHK(err);
+00107  
+00108      /* Allocating the topic */
+00109      err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic.1", tattr_1);
+00110      EX_LBM_CHK(err);
+00111  
+00112      /* Creating the source */
+00113      err = lbm_src_create(&src_1, ctx, topic_1, NULL, NULL, NULL);
+00114      EX_LBM_CHK(err);
 
@@ -81,36 +64,22 @@

Initialization

in the attributes that will be dumped later.

-00116      /* Initialized the second source attributes as a copy of the first */
-00117      if (lbm_src_topic_attr_dup(&tattr_2, tattr_1) != 0)
-00118      {
-00119          fprintf(stderr, "lbm_src_topic_attr_dup: %s\n", lbm_errmsg());
-00120          exit(1);
-00121      }
-00122  
-00123      /* Now modify the destination port for this second source to put the publisher on a different transport */
-00124      des_port = 14002;
-00125      if (lbm_src_topic_attr_setopt(tattr_2, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)) != 0)
-00126      {
-00127          fprintf(stderr, "lbm_src_topic_attr_setopt:transport_lbtrm_destination_port: %s\n", lbm_errmsg());
-00128          exit(1);
-00129      }
-00130  
-00131      /* Allocating the second topic */
-00132      err = lbm_src_topic_alloc(&topic_2, ctx, "test.topic.2", tattr_2);
-00133      if (err)
-00134      {
-00135          printf("line %d: %s\n", __LINE__, lbm_errmsg());
-00136          exit(1);
-00137      }
-00138  
-00139      /* Creating the source */
-00140      err = lbm_src_create(&src_2, ctx, topic_2, NULL, NULL, NULL);
-00141      if (err)
-00142      {
-00143          printf("line %d: %s\n", __LINE__, lbm_errmsg());
-00144          exit(1);
-00145      }
+00115      /* Initialized the second source attributes as a copy of the first */
+00116      err = lbm_src_topic_attr_dup(&tattr_2, tattr_1);
+00117      EX_LBM_CHK(err);
+00118  
+00119      /* Now modify the destination port for this second source to put the publisher on a different transport */
+00120      des_port = 14002;
+00121      err = lbm_src_topic_attr_setopt(tattr_2, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t));
+00122      EX_LBM_CHK(err);
+00123  
+00124      /* Allocating the second topic */
+00125      err = lbm_src_topic_alloc(&topic_2, ctx, "test.topic.2", tattr_2);
+00126      EX_LBM_CHK(err);
+00127  
+00128      /* Creating the source */
+00129      err = lbm_src_create(&src_2, ctx, topic_2, NULL, NULL, NULL);
+00130      EX_LBM_CHK(err);
 
@@ -131,26 +100,23 @@

Dump Context Attributes

numbers of attributes.

-00146      /* each lbm object (ctx, src, rcv)  has a different number of configuration     */
-00147      /* attributes. To allocate the array, call the corresponding *_option_size      */
-00148      /* function and allocate enough memory to contain the return strings        */
-00149      entries = lbm_context_attr_option_size();
-00150      configs_option_ptr = malloc(entries * sizeof(lbm_config_option_t));
-00151  
-00152      /* Get the attributes for the context */
-00153      if (LBM_FAILURE == lbm_context_dump(ctx, &entries, configs_option_ptr))
-00154      {
-00155          fprintf(stderr, "lbm_context_dump error: %s\n", lbm_errmsg());
-00156          return;
-00157      }
-00158  
-00159      /* iterate through the returned array and print each option */
-00160      for (idx = 0; idx < entries; ++idx) {
-00161          printf("%s[%d]: %s = %s\n", configs_option_ptr[idx].type, idx, configs_option_ptr[idx].oname, configs_option_ptr[idx].val);
-00162      }
-00163  
-00164      /* done with context attributes so free the allocated memory */
-00165      free(configs_option_ptr);
+00131      /* each lbm object (ctx, src, rcv) has a different number of configuration
+00132       * attributes.  To allocate the array, call the corresponding *_option_size
+00133       * function and allocate enough memory to contain the return strings. */
+00134      entries = lbm_context_attr_option_size();
+00135      configs_option_ptr = malloc(entries * sizeof(lbm_config_option_t));
+00136  
+00137      /* Get the attributes for the context */
+00138      err = lbm_context_dump(ctx, &entries, configs_option_ptr);
+00139      EX_LBM_CHK(err);
+00140  
+00141      /* iterate through the returned array and print each option */
+00142      for (idx = 0; idx < entries; ++idx) {
+00143          printf("%s[%d]: %s = %s\n", configs_option_ptr[idx].type, idx, configs_option_ptr[idx].oname, configs_option_ptr[idx].val);
+00144      }
+00145  
+00146      /* done with context attributes so free the allocated memory */
+00147      free(configs_option_ptr);
 
@@ -167,26 +133,23 @@

Dump Source Attributes

Finally, it can be filled by the lbm_*_dump function.

-00166      /* each lbm object (ctx, src, rcv)  has a different number of configuration */
-00167      /* options to allocate the array, call the corresponding *_option_size      */
-00168      /* function and allocate enough memory to contain the return strings        */
-00169      entries = lbm_src_topic_attr_option_size();
-00170      configs_option_ptr = malloc(entries * sizeof(lbm_config_option_t));
-00171  
-00172      /* Get the attributes for the first source */
-00173      if (LBM_FAILURE == lbm_src_topic_dump(src_1, &entries, configs_option_ptr))
-00174      {
-00175          fprintf(stderr, "lbm_src_topic_dump error: %s\n", lbm_errmsg());
-00176          return;
-00177      }
-00178  
-00179      /* iterate through the returned array and print each option */
-00180      for (idx = 0; idx < entries; ++idx) {
-00181          printf("%s[%d]: %s = %s\n", configs_option_ptr[idx].type, idx, configs_option_ptr[idx].oname, configs_option_ptr[idx].val);
-00182      }
-00183  
-00184      /* note that configs_option_ptr can be reused for multiple sources without being freed. */
-00185  
+00149      /* each lbm object (ctx, src, rcv)  has a different number of configuration */
+00150      /* options to allocate the array, call the corresponding *_option_size      */
+00151      /* function and allocate enough memory to contain the return strings        */
+00152      entries = lbm_src_topic_attr_option_size();
+00153      configs_option_ptr = malloc(entries * sizeof(lbm_config_option_t));
+00154  
+00155      /* Get the attributes for the first source */
+00156      err = lbm_src_topic_dump(src_1, &entries, configs_option_ptr);
+00157      EX_LBM_CHK(err);
+00158  
+00159      /* iterate through the returned array and print each option */
+00160      for (idx = 0; idx < entries; ++idx) {
+00161          printf("%s[%d]: %s = %s\n", configs_option_ptr[idx].type, idx, configs_option_ptr[idx].oname, configs_option_ptr[idx].val);
+00162      }
+00163  
+00164      /* note that configs_option_ptr can be reused for multiple sources without being freed. */
+00165  
 
@@ -197,20 +160,17 @@

Dump Source Attributes

no longer be used. Therefore it can & should be freed.

-00186      /* Get the attributes for the second source */
-00187      if (LBM_FAILURE == lbm_src_topic_dump(src_2, &entries, configs_option_ptr))
-00188      {
-00189          fprintf(stderr, "lbm_src_topic_dump error: %s\n", lbm_errmsg());
-00190          return;
-00191      }
-00192  
-00193      /* iterate through the returned array and print each option */
-00194      for (idx = 0; idx < entries; ++idx) {
-00195          printf("%s[%d]: %s = %s\n", configs_option_ptr[idx].type, idx, configs_option_ptr[idx].oname, configs_option_ptr[idx].val);
-00196      }
-00197  
-00198      /* done with source attributes so free the allocated memory */
-00199      free(configs_option_ptr);
+00166      /* Get the attributes for the second source */
+00167      err = lbm_src_topic_dump(src_2, &entries, configs_option_ptr);
+00168      EX_LBM_CHK(err);
+00169  
+00170      /* iterate through the returned array and print each option */
+00171      for (idx = 0; idx < entries; ++idx) {
+00172          printf("%s[%d]: %s = %s\n", configs_option_ptr[idx].type, idx, configs_option_ptr[idx].oname, configs_option_ptr[idx].val);
+00173      }
+00174  
+00175      /* done with source attributes so free the allocated memory */
+00176      free(configs_option_ptr);
 
diff --git a/dump_attributes/c/dump_attributes_c.slsrc b/dump_attributes/c/dump_attributes_c.slsrc index 58d1f5c..a63448f 100644 --- a/dump_attributes/c/dump_attributes_c.slsrc +++ b/dump_attributes/c/dump_attributes_c.slsrc @@ -1,4 +1,23 @@ -/* Example on setting Ultra Messaging attributes */ +/* dump_attributes.c - see http://ultramessaging.github.io/UMExamples/dump_attributes/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include @@ -15,23 +34,32 @@ #include +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ +} while (0) + + int main(int argc, char **argv) { - lbm_context_t *ctx; /* pointer to context object */ - lbm_topic_t *topic_1; /* pointer to topic object */ - lbm_topic_t *topic_2; /* pointer to topic object */ - lbm_src_t *src_1; /* pointer to source object */ - lbm_src_t *src_2; /* pointer to source object */ - lbm_src_topic_attr_t *tattr_1; /* pointer to source attribute object */ - lbm_src_topic_attr_t *tattr_2; /* pointer to source attribute object */ - lbm_context_attr_t * cattr; /* pointer to context attribute object */ + lbm_context_t *ctx; /* pointer to context object */ + lbm_topic_t *topic_1; /* pointer to topic object */ + lbm_topic_t *topic_2; /* pointer to topic object */ + lbm_src_t *src_1; /* pointer to source object */ + lbm_src_t *src_2; /* pointer to source object */ + lbm_src_topic_attr_t *tattr_1; /* pointer to source attribute object */ + lbm_src_topic_attr_t *tattr_2; /* pointer to source attribute object */ + lbm_context_attr_t * cattr; /* pointer to context attribute object */ lbm_config_option_t *configs_option_ptr; /* pointer to configuration options returned from lib*/ - lbm_uint16_t res_port; /* Int to set resolver port */ - lbm_uint16_t des_port; /* Int to set lbtrm destination port */ - int err; /* return status of lbm functions (true=error) */ - int entries; /* Int used to count number of config entries */ - int idx; /* Int used to iterate across config entries */ - + lbm_uint16_t res_port; /* Int to set resolver port */ + lbm_uint16_t des_port; /* Int to set lbtrm destination port */ + int entries; /* Int used to count number of config entries */ + int idx; /* Int used to iterate across config entries */ + int err; #if defined(_MSC_VER) /* windows-specific code */ @@ -45,121 +73,75 @@ int main(int argc, char **argv) #endif /* Initialize the defaults for the context attribute object */ - if (lbm_context_attr_create(&cattr) != 0) - { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_context_attr_create(&cattr); + EX_LBM_CHK(err); /* Setting the resolver address using the string method */ - if (lbm_context_attr_str_setopt(cattr, "resolver_multicast_address", "224.10.11.12") != 0) - { - fprintf(stderr, "lbm_context_attr_str_setopt:resolver_multicast_address: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_context_attr_str_setopt(cattr, "resolver_multicast_address", "224.10.11.12"); + EX_LBM_CHK(err); /* Setting the resolver port using the data-type value method */ res_port = 12345; - if (lbm_context_attr_setopt(cattr, "resolver_multicast_port", &res_port, sizeof(lbm_uint16_t)) != 0) - { - fprintf(stderr, "lbm_context_attr_setopt:resolver_mutlicast_port: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_context_attr_setopt(cattr, "resolver_multicast_port", &res_port, sizeof(lbm_uint16_t)); + EX_LBM_CHK(err); /* Creating the context */ err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* Delete the context attribute object */ - lbm_context_attr_delete(cattr); + err = lbm_context_attr_delete(cattr); + EX_LBM_CHK(err); /*=semlit,block,src_create=*/ /* Initializing the source attribute object */ - if (lbm_src_topic_attr_create(&tattr_1) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_create(&tattr_1); + EX_LBM_CHK(err); /* Setting the transport via the source topic string method */ - if (lbm_src_topic_attr_str_setopt(tattr_1, "transport", "lbtrm") != 0) - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_str_setopt(tattr_1, "transport", "lbtrm"); + EX_LBM_CHK(err); /* Setting the lbtrm destination port via the direct value set method */ des_port = 14001; - if (lbm_src_topic_attr_setopt(tattr_1, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_setopt:transport_lbtrm_destination_port: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_setopt(tattr_1, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)); + EX_LBM_CHK(err); /* Allocating the topic */ err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic.1", tattr_1); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* Creating the source */ err = lbm_src_create(&src_1, ctx, topic_1, NULL, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /*=semlit,endblock,src_create=*/ /*=semlit,block,src_create2=*/ /* Initialized the second source attributes as a copy of the first */ - if (lbm_src_topic_attr_dup(&tattr_2, tattr_1) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_dup: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_dup(&tattr_2, tattr_1); + EX_LBM_CHK(err); /* Now modify the destination port for this second source to put the publisher on a different transport */ des_port = 14002; - if (lbm_src_topic_attr_setopt(tattr_2, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_setopt:transport_lbtrm_destination_port: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_setopt(tattr_2, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)); + EX_LBM_CHK(err); /* Allocating the second topic */ err = lbm_src_topic_alloc(&topic_2, ctx, "test.topic.2", tattr_2); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* Creating the source */ err = lbm_src_create(&src_2, ctx, topic_2, NULL, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /*=semlit,endblock,src_create2=*/ /*=semlit,block,dump_ctx_attr=*/ - /* each lbm object (ctx, src, rcv) has a different number of configuration */ - /* attributes. To allocate the array, call the corresponding *_option_size */ - /* function and allocate enough memory to contain the return strings */ + /* each lbm object (ctx, src, rcv) has a different number of configuration + * attributes. To allocate the array, call the corresponding *_option_size + * function and allocate enough memory to contain the return strings. */ entries = lbm_context_attr_option_size(); configs_option_ptr = malloc(entries * sizeof(lbm_config_option_t)); /* Get the attributes for the context */ - if (LBM_FAILURE == lbm_context_dump(ctx, &entries, configs_option_ptr)) - { - fprintf(stderr, "lbm_context_dump error: %s\n", lbm_errmsg()); - return; - } + err = lbm_context_dump(ctx, &entries, configs_option_ptr); + EX_LBM_CHK(err); /* iterate through the returned array and print each option */ for (idx = 0; idx < entries; ++idx) { @@ -169,6 +151,7 @@ int main(int argc, char **argv) /* done with context attributes so free the allocated memory */ free(configs_option_ptr); /*=semlit,endblock,dump_ctx_attr=*/ + /*=semlit,block,dump_src_attr=*/ /* each lbm object (ctx, src, rcv) has a different number of configuration */ /* options to allocate the array, call the corresponding *_option_size */ @@ -177,11 +160,8 @@ int main(int argc, char **argv) configs_option_ptr = malloc(entries * sizeof(lbm_config_option_t)); /* Get the attributes for the first source */ - if (LBM_FAILURE == lbm_src_topic_dump(src_1, &entries, configs_option_ptr)) - { - fprintf(stderr, "lbm_src_topic_dump error: %s\n", lbm_errmsg()); - return; - } + err = lbm_src_topic_dump(src_1, &entries, configs_option_ptr); + EX_LBM_CHK(err); /* iterate through the returned array and print each option */ for (idx = 0; idx < entries; ++idx) { @@ -193,11 +173,8 @@ int main(int argc, char **argv) /*=semlit,endblock,dump_src_attr=*/ /*=semlit,block,dump_src_attr2=*/ /* Get the attributes for the second source */ - if (LBM_FAILURE == lbm_src_topic_dump(src_2, &entries, configs_option_ptr)) - { - fprintf(stderr, "lbm_src_topic_dump error: %s\n", lbm_errmsg()); - return; - } + err = lbm_src_topic_dump(src_2, &entries, configs_option_ptr); + EX_LBM_CHK(err); /* iterate through the returned array and print each option */ for (idx = 0; idx < entries; ++idx) { @@ -207,18 +184,24 @@ int main(int argc, char **argv) /* done with source attributes so free the allocated memory */ free(configs_option_ptr); /*=semlit,endblock,dump_src_attr2=*/ + /* Delete the first and second source topic attribute objects */ - lbm_src_topic_attr_delete(tattr_1); - lbm_src_topic_attr_delete(tattr_2); + err = lbm_src_topic_attr_delete(tattr_1); + EX_LBM_CHK(err); + err = lbm_src_topic_attr_delete(tattr_2); + EX_LBM_CHK(err); /* Finished with all LBM functions, delete the source and context object. */ - lbm_src_delete(src_1); - lbm_src_delete(src_2); - lbm_context_delete(ctx); + err = lbm_src_delete(src_1); + EX_LBM_CHK(err); + err = lbm_src_delete(src_2); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); #if defined(_MSC_VER) WSACleanup(); #endif - return 0; -} + return 0; +} /* main */ diff --git a/dump_attributes/c/dump_attributes_c.slsrc.html b/dump_attributes/c/dump_attributes_c.slsrc.html index 4ee0394..7901ced 100644 --- a/dump_attributes/c/dump_attributes_c.slsrc.html +++ b/dump_attributes/c/dump_attributes_c.slsrc.html @@ -94,22 +94,22 @@ 00076 00077 00078 -00079 -00080 -00081 -00082 -00083 -00084 -00085 -00086 -00087 -00088 -00089 -00090 -00091 -00092 -00093 -00094 +00079 +00080 +00081 +00082 +00083 +00084 +00085 +00086 +00087 +00088 +00089 +00090 +00091 +00092 +00093 +00094 00095 00096 00097 @@ -130,7 +130,7 @@ 00112 00113 00114 -00115 +00115 00116 00117 00118 @@ -146,91 +146,93 @@ 00128 00129 00130 -00131 -00132 -00133 -00134 -00135 -00136 -00137 -00138 -00139 -00140 -00141 -00142 -00143 -00144 -00145 +00131 +00132 +00133 +00134 +00135 +00136 +00137 +00138 +00139 +00140 +00141 +00142 +00143 +00144 +00145 00146 00147 -00148 -00149 -00150 -00151 -00152 -00153 -00154 -00155 -00156 -00157 -00158 -00159 -00160 -00161 -00162 -00163 -00164 -00165 -00166 -00167 -00168 -00169 -00170 -00171 -00172 -00173 -00174 -00175 -00176 -00177 -00178 -00179 -00180 -00181 -00182 -00183 -00184 -00185 -00186 -00187 -00188 -00189 -00190 -00191 -00192 -00193 -00194 -00195 -00196 -00197 -00198 -00199 -00200 -00201 -00202 -00203 -00204 -00205 -00206 -00207 -00208 -00209 -00210 -00211 -00212 -00213 -00214 - /* Example on setting Ultra Messaging attributes */ +00148 +00149 +00150 +00151 +00152 +00153 +00154 +00155 +00156 +00157 +00158 +00159 +00160 +00161 +00162 +00163 +00164 +00165 +00166 +00167 +00168 +00169 +00170 +00171 +00172 +00173 +00174 +00175 +00176 +00177 +00178 +00179 +00180 +00181 +00182 +00183 +00184 +00185 +00186 +00187 +00188 +00189 +00190 +00191 +00192 +00193 +00194 +00195 +00196 +00197 + /* dump_attributes.c - see http://ultramessaging.github.io/UMExamples/dump_attributes/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include <stdio.h> @@ -247,23 +249,32 @@ #include <lbm/lbm.h> + /* Example error checking macro. Include after each UM call. */ + #define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ + } while (0) + + int main(int argc, char **argv) { - lbm_context_t *ctx; /* pointer to context object */ - lbm_topic_t *topic_1; /* pointer to topic object */ - lbm_topic_t *topic_2; /* pointer to topic object */ - lbm_src_t *src_1; /* pointer to source object */ - lbm_src_t *src_2; /* pointer to source object */ - lbm_src_topic_attr_t *tattr_1; /* pointer to source attribute object */ - lbm_src_topic_attr_t *tattr_2; /* pointer to source attribute object */ - lbm_context_attr_t * cattr; /* pointer to context attribute object */ + lbm_context_t *ctx; /* pointer to context object */ + lbm_topic_t *topic_1; /* pointer to topic object */ + lbm_topic_t *topic_2; /* pointer to topic object */ + lbm_src_t *src_1; /* pointer to source object */ + lbm_src_t *src_2; /* pointer to source object */ + lbm_src_topic_attr_t *tattr_1; /* pointer to source attribute object */ + lbm_src_topic_attr_t *tattr_2; /* pointer to source attribute object */ + lbm_context_attr_t * cattr; /* pointer to context attribute object */ lbm_config_option_t *configs_option_ptr; /* pointer to configuration options returned from lib*/ - lbm_uint16_t res_port; /* Int to set resolver port */ - lbm_uint16_t des_port; /* Int to set lbtrm destination port */ - int err; /* return status of lbm functions (true=error) */ - int entries; /* Int used to count number of config entries */ - int idx; /* Int used to iterate across config entries */ - + lbm_uint16_t res_port; /* Int to set resolver port */ + lbm_uint16_t des_port; /* Int to set lbtrm destination port */ + int entries; /* Int used to count number of config entries */ + int idx; /* Int used to iterate across config entries */ + int err; #if defined(_MSC_VER) /* windows-specific code */ @@ -277,116 +288,70 @@ #endif /* Initialize the defaults for the context attribute object */ - if (lbm_context_attr_create(&cattr) != 0) - { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_context_attr_create(&cattr); + EX_LBM_CHK(err); /* Setting the resolver address using the string method */ - if (lbm_context_attr_str_setopt(cattr, "resolver_multicast_address", "224.10.11.12") != 0) - { - fprintf(stderr, "lbm_context_attr_str_setopt:resolver_multicast_address: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_context_attr_str_setopt(cattr, "resolver_multicast_address", "224.10.11.12"); + EX_LBM_CHK(err); /* Setting the resolver port using the data-type value method */ res_port = 12345; - if (lbm_context_attr_setopt(cattr, "resolver_multicast_port", &res_port, sizeof(lbm_uint16_t)) != 0) - { - fprintf(stderr, "lbm_context_attr_setopt:resolver_mutlicast_port: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_context_attr_setopt(cattr, "resolver_multicast_port", &res_port, sizeof(lbm_uint16_t)); + EX_LBM_CHK(err); /* Creating the context */ err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* Delete the context attribute object */ - lbm_context_attr_delete(cattr); + err = lbm_context_attr_delete(cattr); + EX_LBM_CHK(err); /* Initializing the source attribute object */ - if (lbm_src_topic_attr_create(&tattr_1) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_create(&tattr_1); + EX_LBM_CHK(err); /* Setting the transport via the source topic string method */ - if (lbm_src_topic_attr_str_setopt(tattr_1, "transport", "lbtrm") != 0) - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_str_setopt(tattr_1, "transport", "lbtrm"); + EX_LBM_CHK(err); /* Setting the lbtrm destination port via the direct value set method */ des_port = 14001; - if (lbm_src_topic_attr_setopt(tattr_1, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_setopt:transport_lbtrm_destination_port: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_setopt(tattr_1, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)); + EX_LBM_CHK(err); /* Allocating the topic */ err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic.1", tattr_1); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* Creating the source */ err = lbm_src_create(&src_1, ctx, topic_1, NULL, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* Initialized the second source attributes as a copy of the first */ - if (lbm_src_topic_attr_dup(&tattr_2, tattr_1) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_dup: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_dup(&tattr_2, tattr_1); + EX_LBM_CHK(err); /* Now modify the destination port for this second source to put the publisher on a different transport */ des_port = 14002; - if (lbm_src_topic_attr_setopt(tattr_2, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_setopt:transport_lbtrm_destination_port: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_setopt(tattr_2, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)); + EX_LBM_CHK(err); /* Allocating the second topic */ err = lbm_src_topic_alloc(&topic_2, ctx, "test.topic.2", tattr_2); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* Creating the source */ err = lbm_src_create(&src_2, ctx, topic_2, NULL, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - /* each lbm object (ctx, src, rcv) has a different number of configuration */ - /* attributes. To allocate the array, call the corresponding *_option_size */ - /* function and allocate enough memory to contain the return strings */ + EX_LBM_CHK(err); + /* each lbm object (ctx, src, rcv) has a different number of configuration + * attributes. To allocate the array, call the corresponding *_option_size + * function and allocate enough memory to contain the return strings. */ entries = lbm_context_attr_option_size(); configs_option_ptr = malloc(entries * sizeof(lbm_config_option_t)); /* Get the attributes for the context */ - if (LBM_FAILURE == lbm_context_dump(ctx, &entries, configs_option_ptr)) - { - fprintf(stderr, "lbm_context_dump error: %s\n", lbm_errmsg()); - return; - } + err = lbm_context_dump(ctx, &entries, configs_option_ptr); + EX_LBM_CHK(err); /* iterate through the returned array and print each option */ for (idx = 0; idx < entries; ++idx) { @@ -395,6 +360,7 @@ /* done with context attributes so free the allocated memory */ free(configs_option_ptr); + /* each lbm object (ctx, src, rcv) has a different number of configuration */ /* options to allocate the array, call the corresponding *_option_size */ /* function and allocate enough memory to contain the return strings */ @@ -402,11 +368,8 @@ configs_option_ptr = malloc(entries * sizeof(lbm_config_option_t)); /* Get the attributes for the first source */ - if (LBM_FAILURE == lbm_src_topic_dump(src_1, &entries, configs_option_ptr)) - { - fprintf(stderr, "lbm_src_topic_dump error: %s\n", lbm_errmsg()); - return; - } + err = lbm_src_topic_dump(src_1, &entries, configs_option_ptr); + EX_LBM_CHK(err); /* iterate through the returned array and print each option */ for (idx = 0; idx < entries; ++idx) { @@ -416,11 +379,8 @@ /* note that configs_option_ptr can be reused for multiple sources without being freed. */ /* Get the attributes for the second source */ - if (LBM_FAILURE == lbm_src_topic_dump(src_2, &entries, configs_option_ptr)) - { - fprintf(stderr, "lbm_src_topic_dump error: %s\n", lbm_errmsg()); - return; - } + err = lbm_src_topic_dump(src_2, &entries, configs_option_ptr); + EX_LBM_CHK(err); /* iterate through the returned array and print each option */ for (idx = 0; idx < entries; ++idx) { @@ -429,21 +389,27 @@ /* done with source attributes so free the allocated memory */ free(configs_option_ptr); + /* Delete the first and second source topic attribute objects */ - lbm_src_topic_attr_delete(tattr_1); - lbm_src_topic_attr_delete(tattr_2); + err = lbm_src_topic_attr_delete(tattr_1); + EX_LBM_CHK(err); + err = lbm_src_topic_attr_delete(tattr_2); + EX_LBM_CHK(err); /* Finished with all LBM functions, delete the source and context object. */ - lbm_src_delete(src_1); - lbm_src_delete(src_2); - lbm_context_delete(ctx); + err = lbm_src_delete(src_1); + EX_LBM_CHK(err); + err = lbm_src_delete(src_2); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); #if defined(_MSC_VER) WSACleanup(); #endif - return 0; - } + return 0; + } /* main */ diff --git a/event_q_rcv/c/event_q_rcv.c b/event_q_rcv/c/event_q_rcv.c index c823709..e24ebc8 100644 --- a/event_q_rcv/c/event_q_rcv.c +++ b/event_q_rcv/c/event_q_rcv.c @@ -1,4 +1,23 @@ -/* Example on setting Ultra Messaging attributes */ +/* event_q_rcv.c - see http://ultramessaging.github.io/UMExamples/event_q_rcv/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include @@ -15,6 +34,16 @@ #include +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ +} while (0) + + /* Received message handler (passed into lbm_rcv_create()) */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { @@ -28,17 +57,16 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) break; } return 0; -} +} /* rcv_handle_msg */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* pointer to context object */ - lbm_topic_t *topic_1; /* pointer to topic object */ - lbm_rcv_t *rcv; /* pointer to source object */ - lbm_topic_t *rtopic; /* pointer to receiver topic object */ - lbm_context_attr_t * cattr; /* pointer to context attribute object */ - int err; /* return status of lbm functions (true=error) */ - lbm_event_queue_t *evq = NULL; /* pointer to eventQ handle */ + lbm_context_t *ctx; /* pointer to context object */ + lbm_rcv_t *rcv; /* pointer to source object */ + lbm_topic_t *rtopic; /* pointer to receiver topic object */ + lbm_event_queue_t *evq = NULL; /* pointer to eventQ handle */ + int err; #if defined(_MSC_VER) /* windows-specific code */ @@ -51,58 +79,38 @@ int main(int argc, char **argv) } #endif - /* Initialize the defaults for the context attribute object */ - if (lbm_context_attr_create(&cattr) != 0) - { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); - exit(1); - } - /* Creating the context */ - err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - /* Delete the context attribute object */ - lbm_context_attr_delete(cattr); + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); /* Create an event queue and associate it with a callback */ err = lbm_event_queue_create(&evq, NULL, NULL, NULL); - if (err == LBM_FAILURE) { - fprintf(stderr, "lbm_event_queue_create: %s\n", lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - + EX_LBM_CHK(err); + err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, evq); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); - /* This runs the eventQ for 10 seconds. This means for the next 10 seconds */ - /* all of the sources events will be processed on this thread. */ - if (lbm_event_dispatch(evq, 10000) == LBM_FAILURE) { + /* This runs the eventQ for 10 seconds. This means for the next 10 seconds + * all of the sources events will be processed on this thread. Normally, + * this is done on a separate, application-created thread. */ + err = lbm_event_dispatch(evq, 10000); + if (err == LBM_FAILURE) { fprintf(stderr, "lbm_event_dispatch returned error: %s\n", lbm_errmsg()); } /* Finished with all LBM functions, delete the source and context object. */ - lbm_rcv_delete(rcv); - lbm_context_delete(ctx); - lbm_event_queue_delete(evq); + err = lbm_rcv_delete(rcv); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); + err = lbm_event_queue_delete(evq); + EX_LBM_CHK(err); #if defined(_MSC_VER) WSACleanup(); #endif - return 0; -} + return 0; +} /* main */ diff --git a/event_q_rcv/c/event_q_rcv.sldoc.html b/event_q_rcv/c/event_q_rcv.sldoc.html index d61a68e..e977850 100644 --- a/event_q_rcv/c/event_q_rcv.sldoc.html +++ b/event_q_rcv/c/event_q_rcv.sldoc.html @@ -22,7 +22,7 @@

Creating the Event Queue

The eventQ is initialized by calling lbm_event_queue_create with no other arguments:

-00073      err = lbm_event_queue_create(&evq, NULL, NULL, NULL);
+00087      err = lbm_event_queue_create(&evq, NULL, NULL, NULL);
 
@@ -31,7 +31,7 @@

Create a receiver with an event queue.

events will be delivered to the event queue. They will not be processed until lbm_event_dispatch is called with the event queue.

-00086      err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, evq);
+00093      err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, evq);
 
@@ -41,7 +41,8 @@

Processing Events on the Event Queue

the main() thread will execute events for 10 seconds.

-00095      if (lbm_event_dispatch(evq, 10000) == LBM_FAILURE) {
+00099      err = lbm_event_dispatch(evq, 10000);
+00100      if (err == LBM_FAILURE) {
 
@@ -52,9 +53,12 @@

Cleanup

queue is empty and no new events are being generated, the event queue can safely be delete()'ed.

-00100      lbm_rcv_delete(rcv);
-00101      lbm_context_delete(ctx);
-00102      lbm_event_queue_delete(evq);
+00105      err = lbm_rcv_delete(rcv);
+00106      EX_LBM_CHK(err);
+00107      err = lbm_context_delete(ctx);
+00108      EX_LBM_CHK(err);
+00109      err = lbm_event_queue_delete(evq);
+00110      EX_LBM_CHK(err);
 
diff --git a/event_q_rcv/c/event_q_rcv_c.slsrc b/event_q_rcv/c/event_q_rcv_c.slsrc index 63e1576..83d1aa5 100644 --- a/event_q_rcv/c/event_q_rcv_c.slsrc +++ b/event_q_rcv/c/event_q_rcv_c.slsrc @@ -1,4 +1,23 @@ -/* Example on setting Ultra Messaging attributes */ +/* event_q_rcv.c - see http://ultramessaging.github.io/UMExamples/event_q_rcv/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include @@ -15,6 +34,16 @@ #include +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ +} while (0) + + /* Received message handler (passed into lbm_rcv_create()) */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { @@ -28,17 +57,16 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) break; } return 0; -} +} /* rcv_handle_msg */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* pointer to context object */ - lbm_topic_t *topic_1; /* pointer to topic object */ - lbm_rcv_t *rcv; /* pointer to source object */ - lbm_topic_t *rtopic; /* pointer to receiver topic object */ - lbm_context_attr_t * cattr; /* pointer to context attribute object */ - int err; /* return status of lbm functions (true=error) */ - lbm_event_queue_t *evq = NULL; /* pointer to eventQ handle */ + lbm_context_t *ctx; /* pointer to context object */ + lbm_rcv_t *rcv; /* pointer to source object */ + lbm_topic_t *rtopic; /* pointer to receiver topic object */ + lbm_event_queue_t *evq = NULL; /* pointer to eventQ handle */ + int err; #if defined(_MSC_VER) /* windows-specific code */ @@ -51,66 +79,46 @@ int main(int argc, char **argv) } #endif - /* Initialize the defaults for the context attribute object */ - if (lbm_context_attr_create(&cattr) != 0) - { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); - exit(1); - } - /* Creating the context */ - err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - /* Delete the context attribute object */ - lbm_context_attr_delete(cattr); + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); /* Create an event queue and associate it with a callback */ /* =semlit,block,evq_create= */ err = lbm_event_queue_create(&evq, NULL, NULL, NULL); /* =semlit,endblock,evq_create= */ - if (err == LBM_FAILURE) { - fprintf(stderr, "lbm_event_queue_create: %s\n", lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - + EX_LBM_CHK(err); + /* =semlit,block,rcv_create= */ err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, evq); /* =semlit,endblock,rcv_create= */ - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); - /* This runs the eventQ for 10 seconds. This means for the next 10 seconds */ - /* all of the sources events will be processed on this thread. */ + /* This runs the eventQ for 10 seconds. This means for the next 10 seconds + * all of the sources events will be processed on this thread. Normally, + * this is done on a separate, application-created thread. */ /* =semlit,block,evq_run= */ - if (lbm_event_dispatch(evq, 10000) == LBM_FAILURE) { + err = lbm_event_dispatch(evq, 10000); + if (err == LBM_FAILURE) { /* =semlit,endblock,evq_run= */ fprintf(stderr, "lbm_event_dispatch returned error: %s\n", lbm_errmsg()); } /* Finished with all LBM functions, delete the source and context object. */ /* =semlit,block,evq_close= */ - lbm_rcv_delete(rcv); - lbm_context_delete(ctx); - lbm_event_queue_delete(evq); + err = lbm_rcv_delete(rcv); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); + err = lbm_event_queue_delete(evq); + EX_LBM_CHK(err); /* =semlit,endblock,evq_close= */ #if defined(_MSC_VER) WSACleanup(); #endif - return 0; -} + return 0; +} /* main */ diff --git a/event_q_rcv/c/event_q_rcv_c.slsrc.html b/event_q_rcv/c/event_q_rcv_c.slsrc.html index 753eeda..bab3822 100644 --- a/event_q_rcv/c/event_q_rcv_c.slsrc.html +++ b/event_q_rcv/c/event_q_rcv_c.slsrc.html @@ -88,7 +88,7 @@ 00070 00071 00072 -00073 +00073 00074 00075 00076 @@ -101,30 +101,57 @@ 00083 00084 00085 -00086 -00087 +00086 +00087 00088 00089 00090 00091 00092 -00093 +00093 00094 -00095 +00095 00096 00097 00098 -00099 -00100 -00101 -00102 +00099 +00100 +00101 +00102 00103 00104 -00105 -00106 -00107 -00108 - /* Example on setting Ultra Messaging attributes */ +00105 +00106 +00107 +00108 +00109 +00110 +00111 +00112 +00113 +00114 +00115 +00116 + /* event_q_rcv.c - see http://ultramessaging.github.io/UMExamples/event_q_rcv/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include <stdio.h> @@ -141,6 +168,16 @@ #include <lbm/lbm.h> + /* Example error checking macro. Include after each UM call. */ + #define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ + } while (0) + + /* Received message handler (passed into lbm_rcv_create()) */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { @@ -154,17 +191,16 @@ break; } return 0; - } + } /* rcv_handle_msg */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* pointer to context object */ - lbm_topic_t *topic_1; /* pointer to topic object */ - lbm_rcv_t *rcv; /* pointer to source object */ - lbm_topic_t *rtopic; /* pointer to receiver topic object */ - lbm_context_attr_t * cattr; /* pointer to context attribute object */ - int err; /* return status of lbm functions (true=error) */ - lbm_event_queue_t *evq = NULL; /* pointer to eventQ handle */ + lbm_context_t *ctx; /* pointer to context object */ + lbm_rcv_t *rcv; /* pointer to source object */ + lbm_topic_t *rtopic; /* pointer to receiver topic object */ + lbm_event_queue_t *evq = NULL; /* pointer to eventQ handle */ + int err; #if defined(_MSC_VER) /* windows-specific code */ @@ -177,61 +213,41 @@ } #endif - /* Initialize the defaults for the context attribute object */ - if (lbm_context_attr_create(&cattr) != 0) - { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); - exit(1); - } - /* Creating the context */ - err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - /* Delete the context attribute object */ - lbm_context_attr_delete(cattr); + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); /* Create an event queue and associate it with a callback */ err = lbm_event_queue_create(&evq, NULL, NULL, NULL); - if (err == LBM_FAILURE) { - fprintf(stderr, "lbm_event_queue_create: %s\n", lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - + EX_LBM_CHK(err); + err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, evq); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); - /* This runs the eventQ for 10 seconds. This means for the next 10 seconds */ - /* all of the sources events will be processed on this thread. */ - if (lbm_event_dispatch(evq, 10000) == LBM_FAILURE) { + /* This runs the eventQ for 10 seconds. This means for the next 10 seconds + * all of the sources events will be processed on this thread. Normally, + * this is done on a separate, application-created thread. */ + err = lbm_event_dispatch(evq, 10000); + if (err == LBM_FAILURE) { fprintf(stderr, "lbm_event_dispatch returned error: %s\n", lbm_errmsg()); } /* Finished with all LBM functions, delete the source and context object. */ - lbm_rcv_delete(rcv); - lbm_context_delete(ctx); - lbm_event_queue_delete(evq); + err = lbm_rcv_delete(rcv); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); + err = lbm_event_queue_delete(evq); + EX_LBM_CHK(err); #if defined(_MSC_VER) WSACleanup(); #endif - return 0; - } + return 0; + } /* main */ diff --git a/event_q_src/c/event_q_src.c b/event_q_src/c/event_q_src.c index 90ee4cc..bdb647f 100644 --- a/event_q_src/c/event_q_src.c +++ b/event_q_src/c/event_q_src.c @@ -1,4 +1,23 @@ -/* Example on setting Ultra Messaging attributes */ +/* event_q_src.c + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include @@ -15,6 +34,16 @@ #include +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ +} while (0) + + /* Source event handler. the UM library passes all per-source events */ /* back to the application. This will by default execute on the context */ /* thread. Therefore there should be no blocking calls made. If you must */ @@ -39,7 +68,8 @@ int handle_src_event(lbm_src_t *src, int event, void *ed, void *cd) break; } return 0; -} +} /* handle_src_event */ + int main(int argc, char **argv) { @@ -47,9 +77,8 @@ int main(int argc, char **argv) lbm_topic_t *topic_1; /* pointer to topic object */ lbm_src_t *src; /* pointer to source object */ lbm_src_topic_attr_t *tattr; /* pointer to source attribute object */ - lbm_context_attr_t * cattr; /* pointer to context attribute object */ - int err; /* return status of lbm functions (true=error) */ lbm_event_queue_t *evq = NULL; /* pointer to eventQ handle */ + int err; #if defined(_MSC_VER) /* windows-specific code */ @@ -62,69 +91,48 @@ int main(int argc, char **argv) } #endif - /* Initialize the defaults for the context attribute object */ - if (lbm_context_attr_create(&cattr) != 0) - { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); - exit(1); - } - /* Creating the context */ - err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - /* Delete the context attribute object */ - lbm_context_attr_delete(cattr); + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); /* Initializing the source attribute object */ - if (lbm_src_topic_attr_create(&tattr) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_create(&tattr); + EX_LBM_CHK(err); /* Allocating the topic */ err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic", tattr); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* Create an event queue and associate it with a callback */ - if (lbm_event_queue_create(&evq, NULL, NULL, NULL) == LBM_FAILURE) { - fprintf(stderr, "lbm_event_queue_create: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_event_queue_create(&evq, NULL, NULL, NULL); + EX_LBM_CHK(err); /* Creating the source */ err = lbm_src_create(&src, ctx, topic_1, handle_src_event, NULL, evq); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* This runs the eventQ for 10 seconds. This means for the next 10 seconds */ /* all of the sources events will be processed on this thread. */ - if(lbm_event_dispatch(evq, 10000) == LBM_FAILURE) { + err = lbm_event_dispatch(evq, 10000); + if (err == LBM_FAILURE) { fprintf(stderr, "lbm_event_dispatch returned error: %s\n", lbm_errmsg()); } /* Delete the first and second source topic attribute objects */ - lbm_src_topic_attr_delete(tattr); + err = lbm_src_topic_attr_delete(tattr); + EX_LBM_CHK(err); /* Finished with all LBM functions, delete the source and context object. */ - lbm_src_delete(src); - lbm_context_delete(ctx); - lbm_event_queue_delete(evq); + err = lbm_src_delete(src); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); + err = lbm_event_queue_delete(evq); + EX_LBM_CHK(err); + #if defined(_MSC_VER) WSACleanup(); #endif - return 0; -} + return 0; +} /* main */ diff --git a/event_q_src/c/event_q_src.sldoc.html b/event_q_src/c/event_q_src.sldoc.html index e11d44a..c54e612 100644 --- a/event_q_src/c/event_q_src.sldoc.html +++ b/event_q_src/c/event_q_src.sldoc.html @@ -22,7 +22,7 @@

Creating the Event Queue

The easiest way to creant an event queue is to initialize it by calling lbm_event_queue_create with no arguments.

-00099      if (lbm_event_queue_create(&evq, NULL, NULL, NULL) == LBM_FAILURE) {
+00107      err = lbm_event_queue_create(&evq, NULL, NULL, NULL);
 
@@ -31,7 +31,7 @@

Create a source with an event queue.

events will be delivered to the event queue. They will not be processed until the event queue is run by calling lbm_event_dispatch.

-00105      err = lbm_src_create(&src, ctx, topic_1, handle_src_event, NULL, evq);
+00111      err = lbm_src_create(&src, ctx, topic_1, handle_src_event, NULL, evq);
 
@@ -40,7 +40,7 @@

Processing Events on the Event Queue

will execute queued events on the thread that called lbm_event_dispatch. Events will be processed for the specified amount of time.

-00114      if(lbm_event_dispatch(evq, 10000) == LBM_FAILURE) {
+00116      err = lbm_event_dispatch(evq, 10000);
 
@@ -51,9 +51,12 @@

Cleanup

queue is empty and no new events are being generated, the event queue can safely be _deleted()'ed.

-00122      lbm_src_delete(src);
-00123      lbm_context_delete(ctx);
-00124      lbm_event_queue_delete(evq);
+00126      err = lbm_src_delete(src);
+00127      EX_LBM_CHK(err);
+00128      err = lbm_context_delete(ctx);
+00129      EX_LBM_CHK(err);
+00130      err = lbm_event_queue_delete(evq);
+00131      EX_LBM_CHK(err);
 
diff --git a/event_q_src/c/event_q_src_c.slsrc b/event_q_src/c/event_q_src_c.slsrc index bb103d2..1161f3e 100644 --- a/event_q_src/c/event_q_src_c.slsrc +++ b/event_q_src/c/event_q_src_c.slsrc @@ -1,4 +1,23 @@ -/* Example on setting Ultra Messaging attributes */ +/* event_q_src.c + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include @@ -15,6 +34,16 @@ #include +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ +} while (0) + + /* Source event handler. the UM library passes all per-source events */ /* back to the application. This will by default execute on the context */ /* thread. Therefore there should be no blocking calls made. If you must */ @@ -39,7 +68,8 @@ int handle_src_event(lbm_src_t *src, int event, void *ed, void *cd) break; } return 0; -} +} /* handle_src_event */ + int main(int argc, char **argv) { @@ -47,9 +77,8 @@ int main(int argc, char **argv) lbm_topic_t *topic_1; /* pointer to topic object */ lbm_src_t *src; /* pointer to source object */ lbm_src_topic_attr_t *tattr; /* pointer to source attribute object */ - lbm_context_attr_t * cattr; /* pointer to context attribute object */ - int err; /* return status of lbm functions (true=error) */ lbm_event_queue_t *evq = NULL; /* pointer to eventQ handle */ + int err; #if defined(_MSC_VER) /* windows-specific code */ @@ -62,77 +91,56 @@ int main(int argc, char **argv) } #endif - /* Initialize the defaults for the context attribute object */ - if (lbm_context_attr_create(&cattr) != 0) - { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); - exit(1); - } - /* Creating the context */ - err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - /* Delete the context attribute object */ - lbm_context_attr_delete(cattr); + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); /* Initializing the source attribute object */ - if (lbm_src_topic_attr_create(&tattr) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_create(&tattr); + EX_LBM_CHK(err); /* Allocating the topic */ err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic", tattr); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* Create an event queue and associate it with a callback */ /* =semlit,block,evq_create= */ - if (lbm_event_queue_create(&evq, NULL, NULL, NULL) == LBM_FAILURE) { + err = lbm_event_queue_create(&evq, NULL, NULL, NULL); /* =semlit,endblock,evq_create= */ - fprintf(stderr, "lbm_event_queue_create: %s\n", lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* Creating the source */ /* =semlit,block,src_create= */ err = lbm_src_create(&src, ctx, topic_1, handle_src_event, NULL, evq); /* =semlit,endblock,src_create= */ - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* This runs the eventQ for 10 seconds. This means for the next 10 seconds */ /* all of the sources events will be processed on this thread. */ /* =semlit,block,evq_run= */ - if(lbm_event_dispatch(evq, 10000) == LBM_FAILURE) { + err = lbm_event_dispatch(evq, 10000); /* =semlit,endblock,evq_run= */ + if (err == LBM_FAILURE) { fprintf(stderr, "lbm_event_dispatch returned error: %s\n", lbm_errmsg()); } /* Delete the first and second source topic attribute objects */ - lbm_src_topic_attr_delete(tattr); + err = lbm_src_topic_attr_delete(tattr); + EX_LBM_CHK(err); /* Finished with all LBM functions, delete the source and context object. */ /* =semlit,block,evq_close= */ - lbm_src_delete(src); - lbm_context_delete(ctx); - lbm_event_queue_delete(evq); + err = lbm_src_delete(src); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); + err = lbm_event_queue_delete(evq); + EX_LBM_CHK(err); /* =semlit,endblock,evq_close= */ + #if defined(_MSC_VER) WSACleanup(); #endif - return 0; -} + return 0; +} /* main */ diff --git a/event_q_src/c/event_q_src_c.slsrc.html b/event_q_src/c/event_q_src_c.slsrc.html index 1ab893e..5e90ca0 100644 --- a/event_q_src/c/event_q_src_c.slsrc.html +++ b/event_q_src/c/event_q_src_c.slsrc.html @@ -114,39 +114,66 @@ 00096 00097 00098 -00099 +00099 00100 00101 00102 00103 00104 -00105 +00105 00106 -00107 +00107 00108 00109 00110 -00111 +00111 00112 00113 -00114 +00114 00115 -00116 +00116 00117 00118 00119 00120 00121 -00122 -00123 -00124 +00122 +00123 +00124 00125 -00126 -00127 -00128 -00129 -00130 - /* Example on setting Ultra Messaging attributes */ +00126 +00127 +00128 +00129 +00130 +00131 +00132 +00133 +00134 +00135 +00136 +00137 +00138 + /* event_q_src.c + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include <stdio.h> @@ -163,6 +190,16 @@ #include <lbm/lbm.h> + /* Example error checking macro. Include after each UM call. */ + #define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ + } while (0) + + /* Source event handler. the UM library passes all per-source events */ /* back to the application. This will by default execute on the context */ /* thread. Therefore there should be no blocking calls made. If you must */ @@ -187,7 +224,8 @@ break; } return 0; - } + } /* handle_src_event */ + int main(int argc, char **argv) { @@ -195,9 +233,8 @@ lbm_topic_t *topic_1; /* pointer to topic object */ lbm_src_t *src; /* pointer to source object */ lbm_src_topic_attr_t *tattr; /* pointer to source attribute object */ - lbm_context_attr_t * cattr; /* pointer to context attribute object */ - int err; /* return status of lbm functions (true=error) */ lbm_event_queue_t *evq = NULL; /* pointer to eventQ handle */ + int err; #if defined(_MSC_VER) /* windows-specific code */ @@ -210,72 +247,51 @@ } #endif - /* Initialize the defaults for the context attribute object */ - if (lbm_context_attr_create(&cattr) != 0) - { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); - exit(1); - } - /* Creating the context */ - err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - /* Delete the context attribute object */ - lbm_context_attr_delete(cattr); + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); /* Initializing the source attribute object */ - if (lbm_src_topic_attr_create(&tattr) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_create(&tattr); + EX_LBM_CHK(err); /* Allocating the topic */ err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic", tattr); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* Create an event queue and associate it with a callback */ - if (lbm_event_queue_create(&evq, NULL, NULL, NULL) == LBM_FAILURE) { - fprintf(stderr, "lbm_event_queue_create: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_event_queue_create(&evq, NULL, NULL, NULL); + EX_LBM_CHK(err); /* Creating the source */ err = lbm_src_create(&src, ctx, topic_1, handle_src_event, NULL, evq); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* This runs the eventQ for 10 seconds. This means for the next 10 seconds */ /* all of the sources events will be processed on this thread. */ - if(lbm_event_dispatch(evq, 10000) == LBM_FAILURE) { + err = lbm_event_dispatch(evq, 10000); + if (err == LBM_FAILURE) { fprintf(stderr, "lbm_event_dispatch returned error: %s\n", lbm_errmsg()); } /* Delete the first and second source topic attribute objects */ - lbm_src_topic_attr_delete(tattr); + err = lbm_src_topic_attr_delete(tattr); + EX_LBM_CHK(err); /* Finished with all LBM functions, delete the source and context object. */ - lbm_src_delete(src); - lbm_context_delete(ctx); - lbm_event_queue_delete(evq); + err = lbm_src_delete(src); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); + err = lbm_event_queue_delete(evq); + EX_LBM_CHK(err); + #if defined(_MSC_VER) WSACleanup(); #endif - return 0; - } + return 0; + } /* main */ diff --git a/handle_burst/c/handle_burst.c b/handle_burst/c/handle_burst.c index 5918fb4..c14de67 100644 --- a/handle_burst/c/handle_burst.c +++ b/handle_burst/c/handle_burst.c @@ -1,4 +1,23 @@ -/* handle_burst.c - http://ultramessaging.github.io/UMExamples */ +/* handle_burst.c - see http://ultramessaging.github.io/UMExamples/handle_burst/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include #if defined(_MSC_VER) @@ -16,21 +35,21 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) + /* Used to track the last sequence number received */ int last_sqn = 0; + /* Callback used to handle request message for receiver */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { - int err; - switch (msg->type) { case LBM_MSG_DATA: last_sqn = msg->sequence_number; @@ -51,15 +70,15 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) } return 0; -} +} /* rcv_handle_msg */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ - lbm_topic_t *rtopic; /* Receiver Topic object */ - int err; /* Used for checking API return codes */ + lbm_context_t *ctx; /* Context object */ + lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ + lbm_topic_t *rtopic; /* Receiver Topic object */ + int err; #if defined(_WIN32) /* windows-specific code */ @@ -78,7 +97,7 @@ int main(int argc, char **argv) /* Create receiver for receiving request and sending response */ err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL); - EX_LBM_CHK(err); + EX_LBM_CHK(err); err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); EX_LBM_CHK(err); @@ -95,5 +114,5 @@ int main(int argc, char **argv) /* Windows-specific cleanup overhead */ WSACleanup(); #endif - return 0; + return 0; } /* main */ diff --git a/handle_burst/c/handle_burst.sldoc.html b/handle_burst/c/handle_burst.sldoc.html index 95d18d3..9712872 100644 --- a/handle_burst/c/handle_burst.sldoc.html +++ b/handle_burst/c/handle_burst.sldoc.html @@ -44,15 +44,15 @@

Context and Receiver Creation

Standard context and receiver creation, with a minimal amount of options set:

-00076      err = lbm_context_create(&ctx, NULL, NULL, NULL);
-00077      EX_LBM_CHK(err);
-00078  
-00079      /* Create receiver for receiving request and sending response */
-00080      err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL);
-00081          EX_LBM_CHK(err);
-00082  
-00083      err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL);
-00084      EX_LBM_CHK(err);
+00095      err = lbm_context_create(&ctx, NULL, NULL, NULL);
+00096      EX_LBM_CHK(err);
+00097  
+00098      /* Create receiver for receiving request and sending response */
+00099      err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL);
+00100      EX_LBM_CHK(err);
+00101  
+00102      err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL);
+00103      EX_LBM_CHK(err);
 
@@ -67,9 +67,9 @@

Receiver Message Callback

be processed later on a spearate thread. In either case, the last sequence number should be updated here:

-00035          case LBM_MSG_DATA:
-00036              last_sqn = msg->sequence_number;
-00037              break;
+00054          case LBM_MSG_DATA:
+00055              last_sqn = msg->sequence_number;
+00056              break;
 
@@ -77,9 +77,9 @@

Receiver Message Callback

in this event is the message fragment that is unrecoverable, so it should set the last sequence number variable here as well:

-00038          case LBM_MSG_UNRECOVERABLE_LOSS:
-00039              last_sqn = msg->sequence_number;
-00040              break;
+00057          case LBM_MSG_UNRECOVERABLE_LOSS:
+00058              last_sqn = msg->sequence_number;
+00059              break;
 
@@ -88,13 +88,13 @@

Receiver Message Callback

could be another burst loss event, and the application will want to calculate the size of that burst as well:

-00041          case LBM_MSG_UNRECOVERABLE_LOSS_BURST:
-00042          {
-00043              int burst = msg->sequence_number - last_sqn;
-00044              printf("WARNING: Burst loss of %d messages!\n", burst);
-00045              last_sqn = msg->sequence_number;
-00046              break;
-00047          }
+00060          case LBM_MSG_UNRECOVERABLE_LOSS_BURST:
+00061          {
+00062              int burst = msg->sequence_number - last_sqn;
+00063              printf("WARNING: Burst loss of %d messages!\n", burst);
+00064              last_sqn = msg->sequence_number;
+00065              break;
+00066          }
 
@@ -103,19 +103,19 @@

Includes

are not necessary for Linux only applications

-00003  #include <stdio.h>
-00004  #if defined(_MSC_VER)
-00005  /* Windows-only includes */
-00006  #include <winsock2.h>
-00007  #define SLEEP(s) Sleep((s)*1000)
-00008  #else
-00009  /* Unix-only includes */
-00010  #include <stdlib.h>
-00011  #include <unistd.h>
-00012  #define SLEEP(s) sleep(s)
-00013  #endif
-00014  
-00015  #include <lbm/lbm.h>
+00022  #include <stdio.h>
+00023  #if defined(_MSC_VER)
+00024  /* Windows-only includes */
+00025  #include <winsock2.h>
+00026  #define SLEEP(s) Sleep((s)*1000)
+00027  #else
+00028  /* Unix-only includes */
+00029  #include <stdlib.h>
+00030  #include <unistd.h>
+00031  #define SLEEP(s) sleep(s)
+00032  #endif
+00033  
+00034  #include <lbm/lbm.h>
 
@@ -123,16 +123,16 @@

Windows Only

Windows applications must initialize the Winsock library to utilize sockets.

-00064  #if defined(_WIN32)
-00065      /* windows-specific code */
-00066      WSADATA wsadata;
-00067      int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata);
-00068      if (wsStat != 0)
-00069      {
-00070          printf("line %d: wsStat=%d\n",__LINE__,wsStat);
-00071          exit(1);
-00072      }
-00073  #endif
+00083  #if defined(_WIN32)
+00084      /* windows-specific code */
+00085      WSADATA wsadata;
+00086      int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata);
+00087      if (wsStat != 0)
+00088      {
+00089          printf("line %d: wsStat=%d\n",__LINE__,wsStat);
+00090          exit(1);
+00091      }
+00092  #endif
 
diff --git a/handle_burst/c/handle_burst_c.slsrc b/handle_burst/c/handle_burst_c.slsrc index ae37eb1..d72392d 100644 --- a/handle_burst/c/handle_burst_c.slsrc +++ b/handle_burst/c/handle_burst_c.slsrc @@ -1,4 +1,23 @@ -/* handle_burst.c - http://ultramessaging.github.io/UMExamples */ +/* handle_burst.c - see http://ultramessaging.github.io/UMExamples/handle_burst/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ /* =semlit,block,includes=*/ #include @@ -18,23 +37,23 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) + /* Used to track the last sequence number received */ /* =semlit,block,last=*/ int last_sqn = 0; /* =semlit,endblock,last=*/ + /* Callback used to handle request message for receiver */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { - int err; - switch (msg->type) { /* =semlit,block,data=*/ case LBM_MSG_DATA: @@ -61,15 +80,15 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) } return 0; -} +} /* rcv_handle_msg */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ - lbm_topic_t *rtopic; /* Receiver Topic object */ - int err; /* Used for checking API return codes */ + lbm_context_t *ctx; /* Context object */ + lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ + lbm_topic_t *rtopic; /* Receiver Topic object */ + int err; /* =semlit,block,windows=*/ #if defined(_WIN32) @@ -91,7 +110,7 @@ int main(int argc, char **argv) /* Create receiver for receiving request and sending response */ err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL); - EX_LBM_CHK(err); + EX_LBM_CHK(err); err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); EX_LBM_CHK(err); @@ -109,5 +128,5 @@ int main(int argc, char **argv) /* Windows-specific cleanup overhead */ WSACleanup(); #endif - return 0; + return 0; } /* main */ diff --git a/handle_burst/c/handle_burst_c.slsrc.html b/handle_burst/c/handle_burst_c.slsrc.html index 2561ff3..438558d 100644 --- a/handle_burst/c/handle_burst_c.slsrc.html +++ b/handle_burst/c/handle_burst_c.slsrc.html @@ -18,104 +18,142 @@
00001 00002 -00003 -00004 -00005 -00006 -00007 -00008 -00009 -00010 -00011 -00012 -00013 -00014 -00015 +00003 +00004 +00005 +00006 +00007 +00008 +00009 +00010 +00011 +00012 +00013 +00014 +00015 00016 00017 00018 00019 00020 00021 -00022 -00023 -00024 -00025 -00026 -00027 -00028 -00029 -00030 -00031 -00032 -00033 -00034 -00035 -00036 -00037 -00038 -00039 -00040 -00041 -00042 -00043 -00044 -00045 -00046 -00047 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 +00036 +00037 +00038 +00039 +00040 +00041 +00042 +00043 +00044 +00045 +00046 +00047 00048 00049 00050 00051 00052 00053 -00054 -00055 -00056 -00057 -00058 -00059 -00060 -00061 -00062 -00063 -00064 -00065 -00066 -00067 -00068 -00069 -00070 -00071 -00072 -00073 +00054 +00055 +00056 +00057 +00058 +00059 +00060 +00061 +00062 +00063 +00064 +00065 +00066 +00067 +00068 +00069 +00070 +00071 +00072 +00073 00074 00075 -00076 -00077 -00078 -00079 -00080 -00081 -00082 -00083 -00084 -00085 -00086 -00087 -00088 -00089 -00090 -00091 -00092 +00076 +00077 +00078 +00079 +00080 +00081 +00082 +00083 +00084 +00085 +00086 +00087 +00088 +00089 +00090 +00091 +00092 00093 00094 -00095 -00096 -00097 -00098 -00099 - /* handle_burst.c - http://ultramessaging.github.io/UMExamples */ +00095 +00096 +00097 +00098 +00099 +00100 +00101 +00102 +00103 +00104 +00105 +00106 +00107 +00108 +00109 +00110 +00111 +00112 +00113 +00114 +00115 +00116 +00117 +00118 + /* handle_burst.c - see http://ultramessaging.github.io/UMExamples/handle_burst/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include <stdio.h> #if defined(_MSC_VER) @@ -133,21 +171,21 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) + /* Used to track the last sequence number received */ int last_sqn = 0; + /* Callback used to handle request message for receiver */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { - int err; - switch (msg->type) { case LBM_MSG_DATA: last_sqn = msg->sequence_number; @@ -168,15 +206,15 @@ } return 0; - } + } /* rcv_handle_msg */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ - lbm_topic_t *rtopic; /* Receiver Topic object */ - int err; /* Used for checking API return codes */ + lbm_context_t *ctx; /* Context object */ + lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ + lbm_topic_t *rtopic; /* Receiver Topic object */ + int err; #if defined(_WIN32) /* windows-specific code */ @@ -195,7 +233,7 @@ /* Create receiver for receiving request and sending response */ err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL); - EX_LBM_CHK(err); + EX_LBM_CHK(err); err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); EX_LBM_CHK(err); @@ -212,7 +250,7 @@ /* Windows-specific cleanup overhead */ WSACleanup(); #endif - return 0; + return 0; } /* main */
diff --git a/late_join/c/late_join.c b/late_join/c/late_join.c index fea8f53..378cdf9 100644 --- a/late_join/c/late_join.c +++ b/late_join/c/late_join.c @@ -1,4 +1,23 @@ -/* Example on setting Ultra Messaging attributes */ +/* late_join.c - see http://ultramessaging.github.io/UMExamples/late_join/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include @@ -17,121 +36,115 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) /* Received message handler (passed into lbm_rcv_create()) */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { - switch (msg->type) { - case LBM_MSG_DATA: - if (msg->flags & LBM_MSG_FLAG_RETRANSMIT) - printf("Processing Late Join Message. SQN: %d\n", msg->sequence_number); - else if (msg->flags & LBM_MSG_FLAG_OTR) - printf("Processing OTR Message. SQN: %d\n", msg->sequence_number); - else - printf("Normal Message. SQN: %d\n", msg->sequence_number); - - /* some processing */ - break; - case LBM_MSG_BOS: - printf("Beggining of transport.\n"); - break; - case LBM_MSG_EOS: - printf("End of transport.\n"); - break; - default: - printf("Unknown lbm_msg_t type %x [%s][%s]\n", msg->type, msg->topic_name, msg->source); - break; - } - return 0; -} + switch (msg->type) { + case LBM_MSG_DATA: + if (msg->flags & LBM_MSG_FLAG_RETRANSMIT) + printf("Processing Late Join Message. SQN: %d\n", msg->sequence_number); + else if (msg->flags & LBM_MSG_FLAG_OTR) + printf("Processing OTR Message. SQN: %d\n", msg->sequence_number); + else + printf("Normal Message. SQN: %d\n", msg->sequence_number); + + /* some processing */ + break; + case LBM_MSG_BOS: + printf("Beggining of transport.\n"); + break; + case LBM_MSG_EOS: + printf("End of transport.\n"); + break; + default: + printf("Unknown lbm_msg_t type %x [%s][%s]\n", msg->type, msg->topic_name, msg->source); + break; + } + return 0; +} /* rcv_handle_msg */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* pointer to context object */ - lbm_topic_t *topic_1; /* pointer to topic object */ - lbm_src_t *early_src; /* pointer to source object */ - lbm_rcv_t *late_rcv; /* pointer to receiver object */ - lbm_topic_t *rtopic; /* pointer to receiver topic object */ - lbm_context_attr_t * cattr; /* pointer to context attribute object */ - lbm_src_topic_attr_t *tattr; /* pointer to source attribute object */ - int err; /* return status of lbm functions (true=error) */ + lbm_context_t *ctx; /* pointer to context object */ + lbm_topic_t *topic_1; /* pointer to topic object */ + lbm_src_t *early_src; /* pointer to source object */ + lbm_rcv_t *late_rcv; /* pointer to receiver object */ + lbm_topic_t *rtopic; /* pointer to receiver topic object */ + lbm_src_topic_attr_t *tattr; /* pointer to source attribute object */ + int err; #if defined(_MSC_VER) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2, 2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n", __LINE__, wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2, 2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n", __LINE__, wsStat); + exit(1); + } #endif - /* Initialize the defaults for the context attribute object */ - err = lbm_context_attr_create(&cattr); - EX_LBM_CHK(err); - - /* Creating the context */ - err = lbm_context_create(&ctx, cattr, NULL, NULL); - EX_LBM_CHK(err); - /* Delete the context attribute object */ - lbm_context_attr_delete(cattr); - - /* Initializing the source attribute object */ - err = lbm_src_topic_attr_create(&tattr); - EX_LBM_CHK(err); - - /* Setting the transport via the source topic string method */ - err = lbm_src_topic_attr_str_setopt(tattr, "late_join", "1"); - EX_LBM_CHK(err); - err = lbm_src_topic_attr_str_setopt(tattr, "retransmit_retention_size_threshold", "1"); - EX_LBM_CHK(err); - - /* Allocating the source topic */ - err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic", tattr); - EX_LBM_CHK(err); - - /* Creating the source */ - err = lbm_src_create(&early_src, ctx, topic_1, NULL, NULL, NULL); - EX_LBM_CHK(err); - - /* Wait for topic resolution to happen */ - SLEEP(1); - - /* Send a message... we should expect no one to get it because we haven't created the receiver - yet. */ - err = lbm_src_send(early_src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK); - - err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL); - EX_LBM_CHK(err); - err = lbm_rcv_create(&late_rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); - EX_LBM_CHK(err); - - SLEEP(100000); - - /* Finished with all LBM functions, delete the receiver and context object. */ - /* Delete the source topic attribute objects */ - err = lbm_src_topic_attr_delete(tattr); - EX_LBM_CHK(err); - - /* Finished with all LBM functions, delete the source and context object. */ - err = lbm_src_delete(early_src); - EX_LBM_CHK(err); - err = lbm_rcv_delete(late_rcv); - EX_LBM_CHK(err); - err = lbm_context_delete(ctx); - EX_LBM_CHK(err); + /* Creating the context */ + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); + + /* Initializing the source attribute object */ + err = lbm_src_topic_attr_create(&tattr); + EX_LBM_CHK(err); + + /* Setting the transport via the source topic string method */ + err = lbm_src_topic_attr_str_setopt(tattr, "late_join", "1"); + EX_LBM_CHK(err); + err = lbm_src_topic_attr_str_setopt(tattr, "retransmit_retention_size_threshold", "1"); + EX_LBM_CHK(err); + + /* Allocating the source topic */ + err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic", tattr); + EX_LBM_CHK(err); + + /* Creating the source */ + err = lbm_src_create(&early_src, ctx, topic_1, NULL, NULL, NULL); + EX_LBM_CHK(err); + + /* Wait for topic resolution to happen */ + SLEEP(1); + + /* Send a message... we should expect no one to get it because we haven't + * created the receiver yet. */ + err = lbm_src_send(early_src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK); + EX_LBM_CHK(err); + + err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL); + EX_LBM_CHK(err); + err = lbm_rcv_create(&late_rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); + EX_LBM_CHK(err); + + SLEEP(100000); + + /* Finished with all LBM functions, delete the receiver and context object. + * Delete the source topic attribute objects. */ + err = lbm_src_topic_attr_delete(tattr); + EX_LBM_CHK(err); + + /* Finished with all LBM functions, delete the source and context object. */ + err = lbm_src_delete(early_src); + EX_LBM_CHK(err); + err = lbm_rcv_delete(late_rcv); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); #if defined(_MSC_VER) - WSACleanup(); + WSACleanup(); #endif - return 0; -} - + return 0; +} /* main */ diff --git a/late_join/c/late_join.sldoc.html b/late_join/c/late_join.sldoc.html index b00c51e..d538a34 100644 --- a/late_join/c/late_join.sldoc.html +++ b/late_join/c/late_join.sldoc.html @@ -20,8 +20,8 @@

Enabling Late Join

Sources by default have late join disabled. To enable late join the application must do two things. The first is to enable late-join. This can be done as follows:

-00092          err = lbm_src_topic_attr_str_setopt(tattr, "late_join", "1");
-00093          EX_LBM_CHK(err);
+00105      err = lbm_src_topic_attr_str_setopt(tattr, "late_join", "1");
+00106      EX_LBM_CHK(err);
 
@@ -30,8 +30,8 @@

Enabling Late Join

means that at least 1 message will be in the buffer at all times. This can be done as follows:

-00094          err = lbm_src_topic_attr_str_setopt(tattr, "retransmit_retention_size_threshold", "1");
-00095          EX_LBM_CHK(err);
+00107      err = lbm_src_topic_attr_str_setopt(tattr, "retransmit_retention_size_threshold", "1");
+00108      EX_LBM_CHK(err);
 
@@ -41,15 +41,15 @@

Create a source, send message

that the receiver can miss the first few messages published. This is because it takes a non-zero amount of time to resolve the source and join the underlying transport.

-00102          err = lbm_src_create(&early_src, ctx, topic_1, NULL, NULL, NULL);
-00103          EX_LBM_CHK(err);
-00104  
-00105          /* Wait for topic resolution to happen */
-00106          SLEEP(1);
-00107  
-00108          /* Send a message... we should expect no one to get it because we haven't created the receiver
-00109             yet. */
-00110          err = lbm_src_send(early_src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK);
+00115      err = lbm_src_create(&early_src, ctx, topic_1, NULL, NULL, NULL);
+00116      EX_LBM_CHK(err);
+00117  
+00118      /* Wait for topic resolution to happen */
+00119      SLEEP(1);
+00120  
+00121      /* Send a message... we should expect no one to get it because we haven't
+00122       * created the receiver yet. */
+00123      err = lbm_src_send(early_src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK);
 
@@ -58,7 +58,7 @@

Creating the receiver and receiving late join

the default does not have to be changed. Therefore, the receiver is simply created:

-00114          err = lbm_rcv_create(&late_rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL);
+00128      err = lbm_rcv_create(&late_rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL);
 
@@ -69,16 +69,16 @@

Creating the receiver and receiving late join

be retransmitted via OTR, which is a separate type of retransmission that will not be covered in this example.

-00031          switch (msg->type) {
-00032          case LBM_MSG_DATA:
-00033                  if (msg->flags & LBM_MSG_FLAG_RETRANSMIT)
-00034                          printf("Processing Late Join Message. SQN: %d\n", msg->sequence_number);
-00035                  else if (msg->flags & LBM_MSG_FLAG_OTR)
-00036                          printf("Processing OTR Message. SQN: %d\n", msg->sequence_number);
-00037                  else
-00038                          printf("Normal Message. SQN: %d\n", msg->sequence_number);
-00039  
-00040                  /* some processing */
+00050      switch (msg->type) {
+00051      case LBM_MSG_DATA:
+00052          if (msg->flags & LBM_MSG_FLAG_RETRANSMIT)
+00053              printf("Processing Late Join Message. SQN: %d\n", msg->sequence_number);
+00054          else if (msg->flags & LBM_MSG_FLAG_OTR)
+00055              printf("Processing OTR Message. SQN: %d\n", msg->sequence_number);
+00056          else
+00057              printf("Normal Message. SQN: %d\n", msg->sequence_number);
+00058  
+00059          /* some processing */
 
@@ -86,12 +86,12 @@

Cleanup

Cleanup in this case is simple. Simple close or delete all source & receiver objects, and then close or delete the context.

-00125          err = lbm_src_delete(early_src);
-00126          EX_LBM_CHK(err);
-00127          err = lbm_rcv_delete(late_rcv);
-00128          EX_LBM_CHK(err);
-00129          err = lbm_context_delete(ctx);
-00130          EX_LBM_CHK(err);
+00139      err = lbm_src_delete(early_src);
+00140      EX_LBM_CHK(err);
+00141      err = lbm_rcv_delete(late_rcv);
+00142      EX_LBM_CHK(err);
+00143      err = lbm_context_delete(ctx);
+00144      EX_LBM_CHK(err);
 
diff --git a/late_join/c/late_join_c.slsrc b/late_join/c/late_join_c.slsrc index 0e42686..0cb0882 100644 --- a/late_join/c/late_join_c.slsrc +++ b/late_join/c/late_join_c.slsrc @@ -1,4 +1,23 @@ -/* Example on setting Ultra Messaging attributes */ +/* late_join.c - see http://ultramessaging.github.io/UMExamples/late_join/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include @@ -17,133 +36,127 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) /* Received message handler (passed into lbm_rcv_create()) */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { - /* =semlit,block,callback= */ - switch (msg->type) { - case LBM_MSG_DATA: - if (msg->flags & LBM_MSG_FLAG_RETRANSMIT) - printf("Processing Late Join Message. SQN: %d\n", msg->sequence_number); - else if (msg->flags & LBM_MSG_FLAG_OTR) - printf("Processing OTR Message. SQN: %d\n", msg->sequence_number); - else - printf("Normal Message. SQN: %d\n", msg->sequence_number); - - /* some processing */ - /* =semlit,endblock,callback= */ - break; - case LBM_MSG_BOS: - printf("Beggining of transport.\n"); - break; - case LBM_MSG_EOS: - printf("End of transport.\n"); - break; - default: - printf("Unknown lbm_msg_t type %x [%s][%s]\n", msg->type, msg->topic_name, msg->source); - break; - } - return 0; -} + /* =semlit,block,callback= */ + switch (msg->type) { + case LBM_MSG_DATA: + if (msg->flags & LBM_MSG_FLAG_RETRANSMIT) + printf("Processing Late Join Message. SQN: %d\n", msg->sequence_number); + else if (msg->flags & LBM_MSG_FLAG_OTR) + printf("Processing OTR Message. SQN: %d\n", msg->sequence_number); + else + printf("Normal Message. SQN: %d\n", msg->sequence_number); + + /* some processing */ + /* =semlit,endblock,callback= */ + break; + case LBM_MSG_BOS: + printf("Beggining of transport.\n"); + break; + case LBM_MSG_EOS: + printf("End of transport.\n"); + break; + default: + printf("Unknown lbm_msg_t type %x [%s][%s]\n", msg->type, msg->topic_name, msg->source); + break; + } + return 0; +} /* rcv_handle_msg */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* pointer to context object */ - lbm_topic_t *topic_1; /* pointer to topic object */ - lbm_src_t *early_src; /* pointer to source object */ - lbm_rcv_t *late_rcv; /* pointer to receiver object */ - lbm_topic_t *rtopic; /* pointer to receiver topic object */ - lbm_context_attr_t * cattr; /* pointer to context attribute object */ - lbm_src_topic_attr_t *tattr; /* pointer to source attribute object */ - int err; /* return status of lbm functions (true=error) */ + lbm_context_t *ctx; /* pointer to context object */ + lbm_topic_t *topic_1; /* pointer to topic object */ + lbm_src_t *early_src; /* pointer to source object */ + lbm_rcv_t *late_rcv; /* pointer to receiver object */ + lbm_topic_t *rtopic; /* pointer to receiver topic object */ + lbm_src_topic_attr_t *tattr; /* pointer to source attribute object */ + int err; #if defined(_MSC_VER) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2, 2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n", __LINE__, wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2, 2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n", __LINE__, wsStat); + exit(1); + } #endif - /* Initialize the defaults for the context attribute object */ - err = lbm_context_attr_create(&cattr); - EX_LBM_CHK(err); - - /* Creating the context */ - err = lbm_context_create(&ctx, cattr, NULL, NULL); - EX_LBM_CHK(err); - /* Delete the context attribute object */ - lbm_context_attr_delete(cattr); - - /* Initializing the source attribute object */ - err = lbm_src_topic_attr_create(&tattr); - EX_LBM_CHK(err); - - /* Setting the transport via the source topic string method */ - /* =semlit,block,enable_lj= */ - err = lbm_src_topic_attr_str_setopt(tattr, "late_join", "1"); - EX_LBM_CHK(err); - /* =semlit,endblock,enable_lj= */ - /* =semlit,block,configure_lj= */ - err = lbm_src_topic_attr_str_setopt(tattr, "retransmit_retention_size_threshold", "1"); - EX_LBM_CHK(err); - /* =semlit,endblock,configure_lj= */ - - /* Allocating the source topic */ - err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic", tattr); - EX_LBM_CHK(err); - - /* Creating the source */ - /* =semlit,block,source= */ - err = lbm_src_create(&early_src, ctx, topic_1, NULL, NULL, NULL); - EX_LBM_CHK(err); - - /* Wait for topic resolution to happen */ - SLEEP(1); - - /* Send a message... we should expect no one to get it because we haven't created the receiver - yet. */ - err = lbm_src_send(early_src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK); - /* =semlit,endblock,source= */ - - err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL); - EX_LBM_CHK(err); - /* =semlit,block,receiver= */ - err = lbm_rcv_create(&late_rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); - /* =semlit,endblock,receiver= */ - EX_LBM_CHK(err); - - SLEEP(100000); - - /* Finished with all LBM functions, delete the receiver and context object. */ - /* Delete the source topic attribute objects */ - err = lbm_src_topic_attr_delete(tattr); - EX_LBM_CHK(err); - - /* Finished with all LBM functions, delete the source and context object. */ - /* =semlit,block,cleanup= */ - err = lbm_src_delete(early_src); - EX_LBM_CHK(err); - err = lbm_rcv_delete(late_rcv); - EX_LBM_CHK(err); - err = lbm_context_delete(ctx); - EX_LBM_CHK(err); - /* =semlit,endblock,cleanup= */ + /* Creating the context */ + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); + + /* Initializing the source attribute object */ + err = lbm_src_topic_attr_create(&tattr); + EX_LBM_CHK(err); + + /* Setting the transport via the source topic string method */ + /* =semlit,block,enable_lj= */ + err = lbm_src_topic_attr_str_setopt(tattr, "late_join", "1"); + EX_LBM_CHK(err); + /* =semlit,endblock,enable_lj= */ + /* =semlit,block,configure_lj= */ + err = lbm_src_topic_attr_str_setopt(tattr, "retransmit_retention_size_threshold", "1"); + EX_LBM_CHK(err); + /* =semlit,endblock,configure_lj= */ + + /* Allocating the source topic */ + err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic", tattr); + EX_LBM_CHK(err); + + /* Creating the source */ + /* =semlit,block,source= */ + err = lbm_src_create(&early_src, ctx, topic_1, NULL, NULL, NULL); + EX_LBM_CHK(err); + + /* Wait for topic resolution to happen */ + SLEEP(1); + + /* Send a message... we should expect no one to get it because we haven't + * created the receiver yet. */ + err = lbm_src_send(early_src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK); + /* =semlit,endblock,source= */ + EX_LBM_CHK(err); + + err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL); + EX_LBM_CHK(err); + /* =semlit,block,receiver= */ + err = lbm_rcv_create(&late_rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); + /* =semlit,endblock,receiver= */ + EX_LBM_CHK(err); + + SLEEP(100000); + + /* Finished with all LBM functions, delete the receiver and context object. + * Delete the source topic attribute objects. */ + err = lbm_src_topic_attr_delete(tattr); + EX_LBM_CHK(err); + + /* Finished with all LBM functions, delete the source and context object. */ + /* =semlit,block,cleanup= */ + err = lbm_src_delete(early_src); + EX_LBM_CHK(err); + err = lbm_rcv_delete(late_rcv); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); + /* =semlit,endblock,cleanup= */ #if defined(_MSC_VER) - WSACleanup(); + WSACleanup(); #endif - return 0; -} - + return 0; +} /* main */ diff --git a/late_join/c/late_join_c.slsrc.html b/late_join/c/late_join_c.slsrc.html index dd72c2a..e34edba 100644 --- a/late_join/c/late_join_c.slsrc.html +++ b/late_join/c/late_join_c.slsrc.html @@ -46,16 +46,16 @@ 00028 00029 00030 -00031 -00032 -00033 -00034 -00035 -00036 -00037 -00038 -00039 -00040 +00031 +00032 +00033 +00034 +00035 +00036 +00037 +00038 +00039 +00040 00041 00042 00043 @@ -65,16 +65,16 @@ 00047 00048 00049 -00050 -00051 -00052 -00053 -00054 -00055 -00056 -00057 -00058 -00059 +00050 +00051 +00052 +00053 +00054 +00055 +00056 +00057 +00058 +00059 00060 00061 00062 @@ -107,45 +107,45 @@ 00089 00090 00091 -00092 -00093 -00094 -00095 +00092 +00093 +00094 +00095 00096 00097 00098 00099 00100 00101 -00102 -00103 -00104 -00105 -00106 -00107 -00108 -00109 -00110 +00102 +00103 +00104 +00105 +00106 +00107 +00108 +00109 +00110 00111 00112 00113 -00114 -00115 -00116 -00117 -00118 -00119 -00120 -00121 -00122 -00123 +00114 +00115 +00116 +00117 +00118 +00119 +00120 +00121 +00122 +00123 00124 -00125 -00126 -00127 -00128 -00129 -00130 +00125 +00126 +00127 +00128 +00129 +00130 00131 00132 00133 @@ -153,7 +153,39 @@ 00135 00136 00137 - /* Example on setting Ultra Messaging attributes */ +00138 +00139 +00140 +00141 +00142 +00143 +00144 +00145 +00146 +00147 +00148 +00149 +00150 + /* late_join.c - see http://ultramessaging.github.io/UMExamples/late_join/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include <stdio.h> @@ -172,124 +204,118 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) /* Received message handler (passed into lbm_rcv_create()) */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { - switch (msg->type) { - case LBM_MSG_DATA: - if (msg->flags & LBM_MSG_FLAG_RETRANSMIT) - printf("Processing Late Join Message. SQN: %d\n", msg->sequence_number); - else if (msg->flags & LBM_MSG_FLAG_OTR) - printf("Processing OTR Message. SQN: %d\n", msg->sequence_number); - else - printf("Normal Message. SQN: %d\n", msg->sequence_number); + switch (msg->type) { + case LBM_MSG_DATA: + if (msg->flags & LBM_MSG_FLAG_RETRANSMIT) + printf("Processing Late Join Message. SQN: %d\n", msg->sequence_number); + else if (msg->flags & LBM_MSG_FLAG_OTR) + printf("Processing OTR Message. SQN: %d\n", msg->sequence_number); + else + printf("Normal Message. SQN: %d\n", msg->sequence_number); + + /* some processing */ + break; + case LBM_MSG_BOS: + printf("Beggining of transport.\n"); + break; + case LBM_MSG_EOS: + printf("End of transport.\n"); + break; + default: + printf("Unknown lbm_msg_t type %x [%s][%s]\n", msg->type, msg->topic_name, msg->source); + break; + } + return 0; + } /* rcv_handle_msg */ - /* some processing */ - break; - case LBM_MSG_BOS: - printf("Beggining of transport.\n"); - break; - case LBM_MSG_EOS: - printf("End of transport.\n"); - break; - default: - printf("Unknown lbm_msg_t type %x [%s][%s]\n", msg->type, msg->topic_name, msg->source); - break; - } - return 0; - } int main(int argc, char **argv) { - lbm_context_t *ctx; /* pointer to context object */ - lbm_topic_t *topic_1; /* pointer to topic object */ - lbm_src_t *early_src; /* pointer to source object */ - lbm_rcv_t *late_rcv; /* pointer to receiver object */ - lbm_topic_t *rtopic; /* pointer to receiver topic object */ - lbm_context_attr_t * cattr; /* pointer to context attribute object */ - lbm_src_topic_attr_t *tattr; /* pointer to source attribute object */ - int err; /* return status of lbm functions (true=error) */ + lbm_context_t *ctx; /* pointer to context object */ + lbm_topic_t *topic_1; /* pointer to topic object */ + lbm_src_t *early_src; /* pointer to source object */ + lbm_rcv_t *late_rcv; /* pointer to receiver object */ + lbm_topic_t *rtopic; /* pointer to receiver topic object */ + lbm_src_topic_attr_t *tattr; /* pointer to source attribute object */ + int err; #if defined(_MSC_VER) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2, 2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n", __LINE__, wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2, 2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n", __LINE__, wsStat); + exit(1); + } #endif - /* Initialize the defaults for the context attribute object */ - err = lbm_context_attr_create(&cattr); - EX_LBM_CHK(err); - - /* Creating the context */ - err = lbm_context_create(&ctx, cattr, NULL, NULL); - EX_LBM_CHK(err); - /* Delete the context attribute object */ - lbm_context_attr_delete(cattr); + /* Creating the context */ + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); - /* Initializing the source attribute object */ - err = lbm_src_topic_attr_create(&tattr); - EX_LBM_CHK(err); + /* Initializing the source attribute object */ + err = lbm_src_topic_attr_create(&tattr); + EX_LBM_CHK(err); - /* Setting the transport via the source topic string method */ - err = lbm_src_topic_attr_str_setopt(tattr, "late_join", "1"); - EX_LBM_CHK(err); - err = lbm_src_topic_attr_str_setopt(tattr, "retransmit_retention_size_threshold", "1"); - EX_LBM_CHK(err); + /* Setting the transport via the source topic string method */ + err = lbm_src_topic_attr_str_setopt(tattr, "late_join", "1"); + EX_LBM_CHK(err); + err = lbm_src_topic_attr_str_setopt(tattr, "retransmit_retention_size_threshold", "1"); + EX_LBM_CHK(err); - /* Allocating the source topic */ - err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic", tattr); - EX_LBM_CHK(err); + /* Allocating the source topic */ + err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic", tattr); + EX_LBM_CHK(err); - /* Creating the source */ - err = lbm_src_create(&early_src, ctx, topic_1, NULL, NULL, NULL); - EX_LBM_CHK(err); + /* Creating the source */ + err = lbm_src_create(&early_src, ctx, topic_1, NULL, NULL, NULL); + EX_LBM_CHK(err); - /* Wait for topic resolution to happen */ - SLEEP(1); + /* Wait for topic resolution to happen */ + SLEEP(1); - /* Send a message... we should expect no one to get it because we haven't created the receiver - yet. */ - err = lbm_src_send(early_src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK); + /* Send a message... we should expect no one to get it because we haven't + * created the receiver yet. */ + err = lbm_src_send(early_src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK); + EX_LBM_CHK(err); - err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL); - EX_LBM_CHK(err); - err = lbm_rcv_create(&late_rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); - EX_LBM_CHK(err); + err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL); + EX_LBM_CHK(err); + err = lbm_rcv_create(&late_rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); + EX_LBM_CHK(err); - SLEEP(100000); + SLEEP(100000); - /* Finished with all LBM functions, delete the receiver and context object. */ - /* Delete the source topic attribute objects */ - err = lbm_src_topic_attr_delete(tattr); - EX_LBM_CHK(err); + /* Finished with all LBM functions, delete the receiver and context object. + * Delete the source topic attribute objects. */ + err = lbm_src_topic_attr_delete(tattr); + EX_LBM_CHK(err); - /* Finished with all LBM functions, delete the source and context object. */ - err = lbm_src_delete(early_src); - EX_LBM_CHK(err); - err = lbm_rcv_delete(late_rcv); - EX_LBM_CHK(err); - err = lbm_context_delete(ctx); - EX_LBM_CHK(err); + /* Finished with all LBM functions, delete the source and context object. */ + err = lbm_src_delete(early_src); + EX_LBM_CHK(err); + err = lbm_rcv_delete(late_rcv); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); #if defined(_MSC_VER) - WSACleanup(); + WSACleanup(); #endif - return 0; - } - + return 0; + } /* main */ diff --git a/load_config/c/load_config.c b/load_config/c/load_config.c index adddd67..07456c3 100644 --- a/load_config/c/load_config.c +++ b/load_config/c/load_config.c @@ -1,4 +1,23 @@ -/* load_config.c - http://ultramessaging.github.io/UMExamples */ +/* load_config.c - see http://ultramessaging.github.io/UMExamples/load_config/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include @@ -26,14 +45,16 @@ #define LBM_CONFIG_XML_FILE "../xml_config.xml" #define LBM_APPLICATION_NAME "processA" + int main(int argc, char **argv) { - int err; /* Used for checking API return codes */ + int err; err = lbm_config((const char *)LBM_CONFIG_FLAT_FILE); EX_LBM_CHK(err); err = lbm_config_xml_file((const char *)LBM_CONFIG_XML_FILE, (const char *)LBM_APPLICATION_NAME); EX_LBM_CHK(err); - return 0; -} + + return 0; +} /* main */ diff --git a/load_config/c/load_config.sldoc.html b/load_config/c/load_config.sldoc.html index 9f19e6b..8bd5996 100644 --- a/load_config/c/load_config.sldoc.html +++ b/load_config/c/load_config.sldoc.html @@ -53,9 +53,9 @@

Define Configuration File Names

of this sample application, they are simply defined as macros

-00025  #define LBM_CONFIG_FLAT_FILE "../flat_config.cfg"
-00026  #define LBM_CONFIG_XML_FILE  "../xml_config.xml"
-00027  #define LBM_APPLICATION_NAME "processA"
+00044  #define LBM_CONFIG_FLAT_FILE "../flat_config.cfg"
+00045  #define LBM_CONFIG_XML_FILE  "../xml_config.xml"
+00046  #define LBM_APPLICATION_NAME "processA"
 
@@ -64,8 +64,8 @@

Load Flat File

Here the application is using lbm_config() to load the flat file "flat_config.cfg":

-00033      err = lbm_config((const char *)LBM_CONFIG_FLAT_FILE);
-00034      EX_LBM_CHK(err);
+00053      err = lbm_config((const char *)LBM_CONFIG_FLAT_FILE);
+00054      EX_LBM_CHK(err);
 
@@ -79,8 +79,8 @@

Load XML File

to specific attributes this application should be setting:

-00036      err = lbm_config_xml_file((const char *)LBM_CONFIG_XML_FILE, (const char *)LBM_APPLICATION_NAME);
-00037      EX_LBM_CHK(err);
+00056      err = lbm_config_xml_file((const char *)LBM_CONFIG_XML_FILE, (const char *)LBM_APPLICATION_NAME);
+00057      EX_LBM_CHK(err);
 
@@ -90,14 +90,14 @@

Error Checking

print a message and exit the program:

-00016  /* Example error checking macro.  Include after each UM call. */
-00017  #define EX_LBM_CHK(err) do { \
-00018          if ((err) < 0) { \
-00019                  fprintf(stderr, "%s:%d, lbm error: '%s'\n", \
-00020                  __FILE__, __LINE__, lbm_errmsg()); \
-00021                  exit(1); \
-00022          }  \
-00023  } while (0)
+00035  /* Example error checking macro.  Include after each UM call. */
+00036  #define EX_LBM_CHK(err) do { \
+00037          if ((err) < 0) { \
+00038                  fprintf(stderr, "%s:%d, lbm error: '%s'\n", \
+00039                  __FILE__, __LINE__, lbm_errmsg()); \
+00040                  exit(1); \
+00041          }  \
+00042  } while (0)
 
@@ -113,18 +113,18 @@

Includes

A small effort was made to provide a some portability between Unix and Windows. For example:

-00003  #include <stdio.h>
-00004  
-00005  #if defined(_MSC_VER)
-00006  /* Windows-only includes */
-00007  #include <winsock2.h>
-00008  #else
-00009  /* Unix-only includes */
-00010  #include <stdlib.h>
-00011  #include <unistd.h>
-00012  #endif
-00013  
-00014  #include <lbm/lbm.h>
+00022  #include <stdio.h>
+00023  
+00024  #if defined(_MSC_VER)
+00025  /* Windows-only includes */
+00026  #include <winsock2.h>
+00027  #else
+00028  /* Unix-only includes */
+00029  #include <stdlib.h>
+00030  #include <unistd.h>
+00031  #endif
+00032  
+00033  #include <lbm/lbm.h>
 
diff --git a/load_config/c/load_config_c.slsrc b/load_config/c/load_config_c.slsrc index 468a3aa..b0ed194 100644 --- a/load_config/c/load_config_c.slsrc +++ b/load_config/c/load_config_c.slsrc @@ -1,4 +1,23 @@ -/* load_config.c - http://ultramessaging.github.io/UMExamples */ +/* load_config.c - see http://ultramessaging.github.io/UMExamples/load_config/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ /* =semlit,block,includes=*/ #include @@ -32,10 +51,11 @@ #define LBM_APPLICATION_NAME "processA" /* =semlit,endblock,define_configs=*/ + int main(int argc, char **argv) { /* =semlit,block,vars=*/ - int err; /* Used for checking API return codes */ + int err; /* =semlit,endblock,vars=*/ /* =semlit,block,flat_file=*/ @@ -47,5 +67,6 @@ int main(int argc, char **argv) err = lbm_config_xml_file((const char *)LBM_CONFIG_XML_FILE, (const char *)LBM_APPLICATION_NAME); EX_LBM_CHK(err); /* =semlit,endblock,xml_file=*/ - return 0; -} + + return 0; +} /* main */ diff --git a/load_config/c/load_config_c.slsrc.html b/load_config/c/load_config_c.slsrc.html index 7d6388d..49bc5d6 100644 --- a/load_config/c/load_config_c.slsrc.html +++ b/load_config/c/load_config_c.slsrc.html @@ -18,44 +18,84 @@
00001 00002 -00003 -00004 -00005 -00006 -00007 -00008 -00009 -00010 -00011 -00012 -00013 -00014 +00003 +00004 +00005 +00006 +00007 +00008 +00009 +00010 +00011 +00012 +00013 +00014 00015 -00016 -00017 -00018 -00019 -00020 -00021 -00022 -00023 -00024 -00025 -00026 -00027 -00028 -00029 -00030 -00031 -00032 -00033 -00034 -00035 -00036 -00037 -00038 -00039 - /* load_config.c - http://ultramessaging.github.io/UMExamples */ +00016 +00017 +00018 +00019 +00020 +00021 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 +00036 +00037 +00038 +00039 +00040 +00041 +00042 +00043 +00044 +00045 +00046 +00047 +00048 +00049 +00050 +00051 +00052 +00053 +00054 +00055 +00056 +00057 +00058 +00059 +00060 + /* load_config.c - see http://ultramessaging.github.io/UMExamples/load_config/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include <stdio.h> @@ -83,17 +123,19 @@ #define LBM_CONFIG_XML_FILE "../xml_config.xml" #define LBM_APPLICATION_NAME "processA" + int main(int argc, char **argv) { - int err; /* Used for checking API return codes */ + int err; err = lbm_config((const char *)LBM_CONFIG_FLAT_FILE); EX_LBM_CHK(err); err = lbm_config_xml_file((const char *)LBM_CONFIG_XML_FILE, (const char *)LBM_APPLICATION_NAME); EX_LBM_CHK(err); - return 0; - } + + return 0; + } /* main */
diff --git a/logging_callback/c/logging_callback.c b/logging_callback/c/logging_callback.c index ac76aea..54b52dd 100644 --- a/logging_callback/c/logging_callback.c +++ b/logging_callback/c/logging_callback.c @@ -1,4 +1,23 @@ -/* Code Disclaimer? */ +/* logging_callback.c - see http://ultramessaging.github.io/UMExamples/logging_callback/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include @@ -15,82 +34,74 @@ #include +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ +} while (0) + + /* Logging callback */ int lbm_log_msg(int level, const char *message, void *clientd) { - printf("LOG Level %d: %s\n", level, message); - return 0; -} + printf("LOG Level %d: %s\n", level, message); + return 0; +} /* lbm_log_msg */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* pointer to context object */ - lbm_context_attr_t * cattr; /* pointer to context attribute object */ - lbm_topic_t *topic; /* pointer to topic object */ - lbm_src_topic_attr_t *tattr; /* pointer to source attribute object */ - lbm_src_t *src; /* pointer to source object */ - int err; /* return status of lbm functions (true=error) */ + lbm_context_t *ctx; /* pointer to context object */ + lbm_topic_t *topic; /* pointer to topic object */ + lbm_src_topic_attr_t *tattr; /* pointer to source attribute object */ + lbm_src_t *src; /* pointer to source object */ + int err; #if defined(_MSC_VER) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + exit(1); + } #endif - /* Setup logging callback */ - if (lbm_log(lbm_log_msg, NULL) == LBM_FAILURE) { - fprintf(stderr, "lbm_log: %s\n", lbm_errmsg()); - exit(1); - } + /* Setup logging callback */ + err = lbm_log(lbm_log_msg, NULL); + EX_LBM_CHK(err); - err = lbm_context_create(&ctx, NULL, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); /* Initializing the source attribute object */ - if (lbm_src_topic_attr_create(&tattr) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_create(&tattr); + EX_LBM_CHK(err); /* Setting late_join */ - if (lbm_src_topic_attr_str_setopt(tattr, "late_join", "1") != 0) - { - fprintf(stderr, "lbm_context_attr_str_setopt:late_join: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_str_setopt(tattr, "late_join", "1"); + EX_LBM_CHK(err); /* Allocating the topic */ err = lbm_src_topic_alloc(&topic, ctx, "test.topic.1", tattr); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* Creating the source */ err = lbm_src_create(&src, ctx, topic, NULL, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* At the very least, the following core message should print via the logging callback: */ /* LOG Level 5: Core-5688-539: NOTICE: Source "test.topic.1" has no retention settings (1 message retained max) */ /* Cleanup */ - lbm_src_delete(src); - lbm_context_delete(ctx); - return 0; -} + err = lbm_src_delete(src); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); + return 0; +} /* main */ diff --git a/logging_callback/c/logging_callback.sldoc.html b/logging_callback/c/logging_callback.sldoc.html index fc92d20..8bf8309 100644 --- a/logging_callback/c/logging_callback.sldoc.html +++ b/logging_callback/c/logging_callback.sldoc.html @@ -50,10 +50,8 @@

Setting the Logging Callback

itself. It can be used like this:

-00046          if (lbm_log(lbm_log_msg, NULL) == LBM_FAILURE) {
-00047                  fprintf(stderr, "lbm_log: %s\n", lbm_errmsg());
-00048                  exit(1);
-00049          }
+00075      err = lbm_log(lbm_log_msg, NULL);
+00076      EX_LBM_CHK(err);
 
@@ -63,11 +61,12 @@

Defining the Logging Callback

log file:

-00019  int lbm_log_msg(int level, const char *message, void *clientd)
-00020  {
-00021          printf("LOG Level %d: %s\n", level, message);
-00022          return 0;
-00023  }
+00047  /* Logging callback */
+00048  int lbm_log_msg(int level, const char *message, void *clientd)
+00049  {
+00050      printf("LOG Level %d: %s\n", level, message);
+00051      return 0;
+00052  }  /* lbm_log_msg */
 
@@ -87,11 +86,8 @@

Triggering a log message

Setting the attribute looks like this:

-00066          if (lbm_src_topic_attr_str_setopt(tattr, "late_join", "1") != 0)
-00067          {
-00068                  fprintf(stderr, "lbm_context_attr_str_setopt:late_join: %s\n", lbm_errmsg());
-00069                  exit(1);
-00070          }
+00086      err = lbm_src_topic_attr_str_setopt(tattr, "late_join", "1");
+00087      EX_LBM_CHK(err);
 
@@ -100,20 +96,20 @@

Includes

are not necessary for Linux only applications

-00003  #include <stdio.h>
-00004  
-00005  #if defined(_MSC_VER)
-00006  /* Windows-only includes */
-00007  #include <winsock2.h>
-00008  #define SLEEP(s) Sleep((s)*1000)
-00009  #else
-00010  /* Unix-only includes */
-00011  #include <stdlib.h>
-00012  #include <unistd.h>
-00013  #define SLEEP(s) sleep(s)
-00014  #endif
-00015  
-00016  #include <lbm/lbm.h>
+00022  #include <stdio.h>
+00023  
+00024  #if defined(_MSC_VER)
+00025  /* Windows-only includes */
+00026  #include <winsock2.h>
+00027  #define SLEEP(s) Sleep((s)*1000)
+00028  #else
+00029  /* Unix-only includes */
+00030  #include <stdlib.h>
+00031  #include <unistd.h>
+00032  #define SLEEP(s) sleep(s)
+00033  #endif
+00034  
+00035  #include <lbm/lbm.h>
 
@@ -121,16 +117,16 @@

Windows Only

Windows applications must initialize the Winsock library to utilize sockets.

-00034  #if defined(_MSC_VER)
-00035          /* windows-specific code */
-00036          WSADATA wsadata;
-00037          int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata);
-00038          if (wsStat != 0)
-00039          {
-00040                  printf("line %d: wsStat=%d\n",__LINE__,wsStat);
-00041                  exit(1);
-00042          }
-00043  #endif
+00063  #if defined(_MSC_VER)
+00064      /* windows-specific code */
+00065      WSADATA wsadata;
+00066      int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata);
+00067      if (wsStat != 0)
+00068      {
+00069          printf("line %d: wsStat=%d\n",__LINE__,wsStat);
+00070          exit(1);
+00071      }
+00072  #endif
 
diff --git a/logging_callback/c/logging_callback_c.slsrc b/logging_callback/c/logging_callback_c.slsrc index b6a41fe..445dcc2 100644 --- a/logging_callback/c/logging_callback_c.slsrc +++ b/logging_callback/c/logging_callback_c.slsrc @@ -1,4 +1,23 @@ -/* Code Disclaimer? */ +/* logging_callback.c - see http://ultramessaging.github.io/UMExamples/logging_callback/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ /* =semlit,block,includes=*/ #include @@ -17,92 +36,84 @@ #include /* =semlit,endblock,includes=*/ -/* Logging callback */ +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ +} while (0) + + /* =semlit,block,logging_cb=*/ +/* Logging callback */ int lbm_log_msg(int level, const char *message, void *clientd) { - printf("LOG Level %d: %s\n", level, message); - return 0; -} + printf("LOG Level %d: %s\n", level, message); + return 0; +} /* lbm_log_msg */ /* =semlit,endblock,logging_cb=*/ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* pointer to context object */ - lbm_context_attr_t * cattr; /* pointer to context attribute object */ - lbm_topic_t *topic; /* pointer to topic object */ - lbm_src_topic_attr_t *tattr; /* pointer to source attribute object */ - lbm_src_t *src; /* pointer to source object */ - int err; /* return status of lbm functions (true=error) */ - - /* =semlit,block,windows=*/ + lbm_context_t *ctx; /* pointer to context object */ + lbm_topic_t *topic; /* pointer to topic object */ + lbm_src_topic_attr_t *tattr; /* pointer to source attribute object */ + lbm_src_t *src; /* pointer to source object */ + int err; + + /* =semlit,block,windows=*/ #if defined(_MSC_VER) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + exit(1); + } #endif - /* =semlit,endblock,windows=*/ + /* =semlit,endblock,windows=*/ - /* Setup logging callback */ + /* Setup logging callback */ /* =semlit,block,set_cb=*/ - if (lbm_log(lbm_log_msg, NULL) == LBM_FAILURE) { - fprintf(stderr, "lbm_log: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_log(lbm_log_msg, NULL); + EX_LBM_CHK(err); /* =semlit,endblock,set_cb=*/ - /* =semlit,block,create= */ - err = lbm_context_create(&ctx, NULL, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - /* =semlit,endblock,create=*/ + /* =semlit,block,create= */ + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); + /* =semlit,endblock,create=*/ /* Initializing the source attribute object */ - if (lbm_src_topic_attr_create(&tattr) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_create(&tattr); + EX_LBM_CHK(err); /* Setting late_join */ /* =semlit,block,late_join=*/ - if (lbm_src_topic_attr_str_setopt(tattr, "late_join", "1") != 0) - { - fprintf(stderr, "lbm_context_attr_str_setopt:late_join: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_str_setopt(tattr, "late_join", "1"); + EX_LBM_CHK(err); /* =semlit,endblock,late_join=*/ /* Allocating the topic */ err = lbm_src_topic_alloc(&topic, ctx, "test.topic.1", tattr); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* Creating the source */ err = lbm_src_create(&src, ctx, topic, NULL, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* At the very least, the following core message should print via the logging callback: */ /* LOG Level 5: Core-5688-539: NOTICE: Source "test.topic.1" has no retention settings (1 message retained max) */ /* Cleanup */ - lbm_src_delete(src); - lbm_context_delete(ctx); - return 0; -} + err = lbm_src_delete(src); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); + return 0; +} /* main */ diff --git a/logging_callback/c/logging_callback_c.slsrc.html b/logging_callback/c/logging_callback_c.slsrc.html index 549881c..42dedf5 100644 --- a/logging_callback/c/logging_callback_c.slsrc.html +++ b/logging_callback/c/logging_callback_c.slsrc.html @@ -18,91 +18,91 @@
00001 00002 -00003 -00004 -00005 -00006 -00007 -00008 -00009 -00010 -00011 -00012 -00013 -00014 -00015 -00016 +00003 +00004 +00005 +00006 +00007 +00008 +00009 +00010 +00011 +00012 +00013 +00014 +00015 +00016 00017 00018 -00019 -00020 -00021 -00022 -00023 -00024 -00025 -00026 -00027 -00028 -00029 -00030 -00031 -00032 -00033 -00034 -00035 -00036 -00037 -00038 -00039 -00040 -00041 -00042 -00043 +00019 +00020 +00021 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 +00036 +00037 +00038 +00039 +00040 +00041 +00042 +00043 00044 00045 -00046 -00047 -00048 -00049 -00050 -00051 -00052 -00053 -00054 -00055 -00056 +00046 +00047 +00048 +00049 +00050 +00051 +00052 +00053 +00054 +00055 +00056 00057 00058 00059 00060 00061 00062 -00063 -00064 -00065 -00066 -00067 -00068 -00069 -00070 -00071 -00072 +00063 +00064 +00065 +00066 +00067 +00068 +00069 +00070 +00071 +00072 00073 00074 -00075 -00076 +00075 +00076 00077 -00078 -00079 +00078 +00079 00080 00081 00082 00083 00084 00085 -00086 -00087 +00086 +00087 00088 00089 00090 @@ -112,7 +112,37 @@ 00094 00095 00096 - /* Code Disclaimer? */ +00097 +00098 +00099 +00100 +00101 +00102 +00103 +00104 +00105 +00106 +00107 + /* logging_callback.c - see http://ultramessaging.github.io/UMExamples/logging_callback/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include <stdio.h> @@ -129,85 +159,77 @@ #include <lbm/lbm.h> - /* Logging callback */ - int lbm_log_msg(int level, const char *message, void *clientd) + /* Example error checking macro. Include after each UM call. */ + #define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ + } while (0) + + + /* Logging callback */ + int lbm_log_msg(int level, const char *message, void *clientd) { - printf("LOG Level %d: %s\n", level, message); - return 0; - } + printf("LOG Level %d: %s\n", level, message); + return 0; + } /* lbm_log_msg */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* pointer to context object */ - lbm_context_attr_t * cattr; /* pointer to context attribute object */ - lbm_topic_t *topic; /* pointer to topic object */ - lbm_src_topic_attr_t *tattr; /* pointer to source attribute object */ - lbm_src_t *src; /* pointer to source object */ - int err; /* return status of lbm functions (true=error) */ + lbm_context_t *ctx; /* pointer to context object */ + lbm_topic_t *topic; /* pointer to topic object */ + lbm_src_topic_attr_t *tattr; /* pointer to source attribute object */ + lbm_src_t *src; /* pointer to source object */ + int err; #if defined(_MSC_VER) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + exit(1); + } #endif - /* Setup logging callback */ - if (lbm_log(lbm_log_msg, NULL) == LBM_FAILURE) { - fprintf(stderr, "lbm_log: %s\n", lbm_errmsg()); - exit(1); - } + /* Setup logging callback */ + err = lbm_log(lbm_log_msg, NULL); + EX_LBM_CHK(err); - err = lbm_context_create(&ctx, NULL, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); /* Initializing the source attribute object */ - if (lbm_src_topic_attr_create(&tattr) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_create(&tattr); + EX_LBM_CHK(err); /* Setting late_join */ - if (lbm_src_topic_attr_str_setopt(tattr, "late_join", "1") != 0) - { - fprintf(stderr, "lbm_context_attr_str_setopt:late_join: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_str_setopt(tattr, "late_join", "1"); + EX_LBM_CHK(err); /* Allocating the topic */ err = lbm_src_topic_alloc(&topic, ctx, "test.topic.1", tattr); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* Creating the source */ err = lbm_src_create(&src, ctx, topic, NULL, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* At the very least, the following core message should print via the logging callback: */ /* LOG Level 5: Core-5688-539: NOTICE: Source "test.topic.1" has no retention settings (1 message retained max) */ /* Cleanup */ - lbm_src_delete(src); - lbm_context_delete(ctx); - return 0; - } + err = lbm_src_delete(src); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); + return 0; + } /* main */
diff --git a/minsrc/c/minsrc.c b/minsrc/c/minsrc.c index fd56c77..659bca4 100644 --- a/minsrc/c/minsrc.c +++ b/minsrc/c/minsrc.c @@ -1,4 +1,23 @@ -/* minsrc.c, see http://ultramessaging.github.io/UMExamples/minsrc/c/ */ +/* minsrc.c - see http://ultramessaging.github.io/UMExamples/minsrc/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include @@ -17,71 +36,71 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object: container for UM "instance". */ - lbm_src_t *src; /* Source object: for sending messages. */ - int err; /* UM functions normally return 0 (success) or -1 (error). */ + lbm_context_t *ctx; /* Context object: container for UM "instance". */ + lbm_src_t *src; /* Source object: for sending messages. */ + int err; #if defined(_MSC_VER) - /* Windows-specific startup overhead */ - WSADATA wsadata; - int wsa_err = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsa_err != 0) { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - fprintf(stderr, "%s:%d, WSAStartup error: %d\n", - __FILE__, __LINE__, wsa_err); - exit(1); - } + /* Windows-specific startup overhead */ + WSADATA wsadata; + int wsa_err = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsa_err != 0) { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + fprintf(stderr, "%s:%d, WSAStartup error: %d\n", + __FILE__, __LINE__, wsa_err); + exit(1); + } #endif + /*** Initialization: create necessary UM objects. ***/ - /*** Initialization: create necessary UM objects. ***/ + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); - err = lbm_context_create(&ctx, NULL, NULL, NULL); - EX_LBM_CHK(err); + { + lbm_topic_t *topic; /* Topic object: only needed temporarily. */ - { - lbm_topic_t *topic; /* Topic object: only needed temporarily. */ + err = lbm_src_topic_alloc(&topic, ctx, "Greeting", NULL); + EX_LBM_CHK(err); - err = lbm_src_topic_alloc(&topic, ctx, "Greeting", NULL); - EX_LBM_CHK(err); + err = lbm_src_create(&src, ctx, topic, NULL, NULL, NULL); + EX_LBM_CHK(err); + } - err = lbm_src_create(&src, ctx, topic, NULL, NULL, NULL); - EX_LBM_CHK(err); - } + SLEEP(1); /* Let topic resolution execute. */ - SLEEP(1); /* Let topic resolution execute. */ + /*** Send a message. ***/ - /*** Send a message. ***/ + err = lbm_src_send(src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK); + EX_LBM_CHK(err); - err = lbm_src_send(src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK); - EX_LBM_CHK(err); + /*** Cleanup: delete UM objects. ***/ - /*** Cleanup: delete UM objects. ***/ + SLEEP(3); /* Linger a bit to allow retransmissions. */ - SLEEP(3); /* Linger a bit to allow retransmissions. */ + err = lbm_src_delete(src); + EX_LBM_CHK(err); - err = lbm_src_delete(src); - EX_LBM_CHK(err); - - err = lbm_context_delete(ctx); - EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); #if defined(_MSC_VER) - /* Windows-specific cleanup overhead */ - WSACleanup(); + /* Windows-specific cleanup overhead */ + WSACleanup(); #endif - return 0; + + return 0; } /* main */ diff --git a/minsrc/c/minsrc.sldoc.html b/minsrc/c/minsrc.sldoc.html index 0ab5d4c..a91bc73 100644 --- a/minsrc/c/minsrc.sldoc.html +++ b/minsrc/c/minsrc.sldoc.html @@ -31,10 +31,10 @@

Initialization

created. The first object to be created is a UM context object:

-00047    /*** Initialization: create necessary UM objects. ***/
-00048  
-00049    err = lbm_context_create(&ctx, NULL, NULL, NULL);
-00050    EX_LBM_CHK(err);
+00065      /*** Initialization: create necessary UM objects. ***/
+00066  
+00067      err = lbm_context_create(&ctx, NULL, NULL, NULL);
+00068      EX_LBM_CHK(err);
 
@@ -55,15 +55,15 @@

Initialization

the object used subsequently to send messages.

-00052    {
-00053      lbm_topic_t *topic;    /* Topic object: only needed temporarily. */
-00054  
-00055      err = lbm_src_topic_alloc(&topic, ctx, "Greeting", NULL);
-00056      EX_LBM_CHK(err);
-00057  
-00058      err = lbm_src_create(&src, ctx, topic, NULL, NULL, NULL);
-00059      EX_LBM_CHK(err);
-00060    }
+00070      {
+00071          lbm_topic_t *topic;    /* Topic object: only needed temporarily. */
+00072  
+00073          err = lbm_src_topic_alloc(&topic, ctx, "Greeting", NULL);
+00074          EX_LBM_CHK(err);
+00075  
+00076          err = lbm_src_create(&src, ctx, topic, NULL, NULL, NULL);
+00077          EX_LBM_CHK(err);
+00078      }
 
@@ -88,7 +88,7 @@

Initialization

applications to discover this new source:

-00062    SLEEP(1);  /* Let topic resolution execute. */
+00080      SLEEP(1);  /* Let topic resolution execute. */
 
@@ -113,10 +113,10 @@

Publishing

Now that initialization is complete, it is time to send a message:

-00065    /*** Send a message. ***/
-00066  
-00067    err = lbm_src_send(src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK);
-00068    EX_LBM_CHK(err);
+00083      /*** Send a message. ***/
+00084  
+00085      err = lbm_src_send(src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK);
+00086      EX_LBM_CHK(err);
 
@@ -153,9 +153,9 @@

Cleanup

completed since the last send, so a short sleep is included:

-00071    /*** Cleanup: delete UM objects. ***/
-00072  
-00073    SLEEP(3);  /* Linger a bit to allow retransmissions. */
+00089      /*** Cleanup: delete UM objects. ***/
+00090  
+00091      SLEEP(3);  /* Linger a bit to allow retransmissions. */
 
@@ -176,11 +176,11 @@

Cleanup

When deleting UM objects, order of deletion is important:

-00075    err = lbm_src_delete(src);
-00076    EX_LBM_CHK(err);
-00077  
-00078    err = lbm_context_delete(ctx);
-00079    EX_LBM_CHK(err);
+00093      err = lbm_src_delete(src);
+00094      EX_LBM_CHK(err);
+00095  
+00096      err = lbm_context_delete(ctx);
+00097      EX_LBM_CHK(err);
 
@@ -197,16 +197,16 @@

Misc

between Unix and Windows. For example:

-00005  #if defined(_MSC_VER)
-00006  /* Windows-only includes */
-00007  #include <winsock2.h>
-00008  #define SLEEP(s) Sleep((s)*1000)
-00009  #else
-00010  /* Unix-only includes */
-00011  #include <stdlib.h>
-00012  #include <unistd.h>
-00013  #define SLEEP(s) sleep(s)
-00014  #endif
+00024  #if defined(_MSC_VER)
+00025  /* Windows-only includes */
+00026  #include <winsock2.h>
+00027  #define SLEEP(s) Sleep((s)*1000)
+00028  #else
+00029  /* Unix-only includes */
+00030  #include <stdlib.h>
+00031  #include <unistd.h>
+00032  #define SLEEP(s) sleep(s)
+00033  #endif
 
@@ -225,14 +225,14 @@

Misc

taken: if anything unexpected happens, print a message and exit the program:

-00018  /* Example error checking macro.  Include after each UM call. */
-00019  #define EX_LBM_CHK(err) do { \
-00020    if ((err) < 0) { \
-00021      fprintf(stderr, "%s:%d, lbm error: '%s'\n", \
-00022        __FILE__, __LINE__, lbm_errmsg()); \
-00023      exit(1); \
-00024    }  \
-00025  } while (0)
+00037  /* Example error checking macro.  Include after each UM call. */
+00038  #define EX_LBM_CHK(err) do { \
+00039      if ((err) < 0) { \
+00040          fprintf(stderr, "%s:%d, lbm error: '%s'\n", \
+00041          __FILE__, __LINE__, lbm_errmsg()); \
+00042          exit(1); \
+00043      }  \
+00044  } while (0)
 
@@ -258,23 +258,23 @@

Misc

must at some point call WSAStartup():

-00028  int main(int argc, char **argv)
-00029  {
-00030    lbm_context_t *ctx;  /* Context object: container for UM "instance". */
-00031    lbm_src_t *src;      /* Source object: for sending messages. */
-00032    int err;             /* UM functions normally return 0 (success) or -1 (error). */
-00033  
-00034  #if defined(_MSC_VER)
-00035    /* Windows-specific startup overhead */
-00036    WSADATA wsadata;
-00037    int wsa_err = WSAStartup(MAKEWORD(2,2), &wsadata);
-00038    if (wsa_err != 0) {
-00039      printf("line %d: wsStat=%d\n",__LINE__,wsStat);
-00040      fprintf(stderr, "%s:%d, WSAStartup error: %d\n",
-00041        __FILE__, __LINE__, wsa_err);
-00042      exit(1);
-00043    }
-00044  #endif
+00047  int main(int argc, char **argv)
+00048  {
+00049      lbm_context_t *ctx;  /* Context object: container for UM "instance". */
+00050      lbm_src_t *src;      /* Source object: for sending messages. */
+00051      int err;
+00052  
+00053  #if defined(_MSC_VER)
+00054      /* Windows-specific startup overhead */
+00055      WSADATA wsadata;
+00056      int wsa_err = WSAStartup(MAKEWORD(2,2), &wsadata);
+00057      if (wsa_err != 0) {
+00058          printf("line %d: wsStat=%d\n",__LINE__,wsStat);
+00059          fprintf(stderr, "%s:%d, WSAStartup error: %d\n",
+00060              __FILE__, __LINE__, wsa_err);
+00061          exit(1);
+00062      }
+00063  #endif
 
@@ -283,10 +283,10 @@

Misc

after before exit:

-00082  #if defined(_MSC_VER)
-00083    /* Windows-specific cleanup overhead */
-00084    WSACleanup();
-00085  #endif
+00100  #if defined(_MSC_VER)
+00101      /* Windows-specific cleanup overhead */
+00102      WSACleanup();
+00103  #endif
 
diff --git a/minsrc/c/minsrc_c.slsrc b/minsrc/c/minsrc_c.slsrc index 78ec7b0..915371f 100644 --- a/minsrc/c/minsrc_c.slsrc +++ b/minsrc/c/minsrc_c.slsrc @@ -1,4 +1,23 @@ -/* minsrc.c, see http://ultramessaging.github.io/UMExamples/minsrc/c/ */ +/* minsrc.c - see http://ultramessaging.github.io/UMExamples/minsrc/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include @@ -20,11 +39,11 @@ /*=semlit,block,ex_lbm_chk=*/ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) /*=semlit,endblock,ex_lbm_chk=*/ @@ -32,76 +51,76 @@ /*=semlit,block,wsa_start=*/ int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object: container for UM "instance". */ - lbm_src_t *src; /* Source object: for sending messages. */ - int err; /* UM functions normally return 0 (success) or -1 (error). */ + lbm_context_t *ctx; /* Context object: container for UM "instance". */ + lbm_src_t *src; /* Source object: for sending messages. */ + int err; #if defined(_MSC_VER) - /* Windows-specific startup overhead */ - WSADATA wsadata; - int wsa_err = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsa_err != 0) { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - fprintf(stderr, "%s:%d, WSAStartup error: %d\n", - __FILE__, __LINE__, wsa_err); - exit(1); - } + /* Windows-specific startup overhead */ + WSADATA wsadata; + int wsa_err = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsa_err != 0) { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + fprintf(stderr, "%s:%d, WSAStartup error: %d\n", + __FILE__, __LINE__, wsa_err); + exit(1); + } #endif /*=semlit,endblock,wsa_start=*/ + /*=semlit,block,ctx_create=*/ + /*** Initialization: create necessary UM objects. ***/ -/*=semlit,block,ctx_create=*/ - /*** Initialization: create necessary UM objects. ***/ + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); + /*=semlit,endblock,ctx_create=*/ - err = lbm_context_create(&ctx, NULL, NULL, NULL); - EX_LBM_CHK(err); -/*=semlit,endblock,ctx_create=*/ + /*=semlit,block,src_create=*/ + { + lbm_topic_t *topic; /* Topic object: only needed temporarily. */ -/*=semlit,block,src_create=*/ - { - lbm_topic_t *topic; /* Topic object: only needed temporarily. */ + err = lbm_src_topic_alloc(&topic, ctx, "Greeting", NULL); + EX_LBM_CHK(err); - err = lbm_src_topic_alloc(&topic, ctx, "Greeting", NULL); - EX_LBM_CHK(err); + err = lbm_src_create(&src, ctx, topic, NULL, NULL, NULL); + EX_LBM_CHK(err); + } + /*=semlit,endblock,src_create=*/ - err = lbm_src_create(&src, ctx, topic, NULL, NULL, NULL); - EX_LBM_CHK(err); - } -/*=semlit,endblock,src_create=*/ + /*=semlit,block,tr_sleep=*/ + SLEEP(1); /* Let topic resolution execute. */ + /*=semlit,endblock,tr_sleep=*/ -/*=semlit,block,tr_sleep=*/ - SLEEP(1); /* Let topic resolution execute. */ -/*=semlit,endblock,tr_sleep=*/ + /*=semlit,block,sending=*/ + /*** Send a message. ***/ -/*=semlit,block,sending=*/ - /*** Send a message. ***/ + err = lbm_src_send(src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK); + EX_LBM_CHK(err); + /*=semlit,endblock,sending=*/ - err = lbm_src_send(src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK); - EX_LBM_CHK(err); -/*=semlit,endblock,sending=*/ + /*=semlit,block,linger=*/ + /*** Cleanup: delete UM objects. ***/ -/*=semlit,block,linger=*/ - /*** Cleanup: delete UM objects. ***/ + SLEEP(3); /* Linger a bit to allow retransmissions. */ + /*=semlit,endblock,linger=*/ - SLEEP(3); /* Linger a bit to allow retransmissions. */ -/*=semlit,endblock,linger=*/ + /*=semlit,block,delobj=*/ + err = lbm_src_delete(src); + EX_LBM_CHK(err); -/*=semlit,block,delobj=*/ - err = lbm_src_delete(src); - EX_LBM_CHK(err); - - err = lbm_context_delete(ctx); - EX_LBM_CHK(err); -/*=semlit,endblock,delobj=*/ + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); + /*=semlit,endblock,delobj=*/ /*=semlit,block,wsa_clean=*/ #if defined(_MSC_VER) - /* Windows-specific cleanup overhead */ - WSACleanup(); + /* Windows-specific cleanup overhead */ + WSACleanup(); #endif /*=semlit,endblock,wsa_clean=*/ - return 0; + + return 0; } /* main */ diff --git a/minsrc/c/minsrc_c.slsrc.html b/minsrc/c/minsrc_c.slsrc.html index 0eee956..ae3303b 100644 --- a/minsrc/c/minsrc_c.slsrc.html +++ b/minsrc/c/minsrc_c.slsrc.html @@ -20,90 +20,128 @@ 00002 00003 00004 -00005 -00006 -00007 -00008 -00009 -00010 -00011 -00012 -00013 -00014 +00005 +00006 +00007 +00008 +00009 +00010 +00011 +00012 +00013 +00014 00015 00016 00017 -00018 -00019 -00020 -00021 -00022 -00023 -00024 -00025 -00026 -00027 -00028 -00029 -00030 -00031 -00032 -00033 -00034 -00035 -00036 -00037 -00038 -00039 -00040 -00041 -00042 -00043 -00044 +00018 +00019 +00020 +00021 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 +00036 +00037 +00038 +00039 +00040 +00041 +00042 +00043 +00044 00045 00046 -00047 -00048 -00049 -00050 -00051 -00052 -00053 -00054 -00055 -00056 -00057 -00058 -00059 -00060 -00061 -00062 -00063 +00047 +00048 +00049 +00050 +00051 +00052 +00053 +00054 +00055 +00056 +00057 +00058 +00059 +00060 +00061 +00062 +00063 00064 -00065 -00066 -00067 -00068 +00065 +00066 +00067 +00068 00069 -00070 -00071 -00072 -00073 -00074 -00075 -00076 -00077 -00078 -00079 -00080 +00070 +00071 +00072 +00073 +00074 +00075 +00076 +00077 +00078 +00079 +00080 00081 -00082 -00083 -00084 -00085 -00086 +00082 +00083 +00084 +00085 +00086 00087 - /* minsrc.c, see http://ultramessaging.github.io/UMExamples/minsrc/c/ */ +00088 +00089 +00090 +00091 +00092 +00093 +00094 +00095 +00096 +00097 +00098 +00099 +00100 +00101 +00102 +00103 +00104 +00105 +00106 + /* minsrc.c - see http://ultramessaging.github.io/UMExamples/minsrc/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include <stdio.h> @@ -122,73 +160,73 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object: container for UM "instance". */ - lbm_src_t *src; /* Source object: for sending messages. */ - int err; /* UM functions normally return 0 (success) or -1 (error). */ + lbm_context_t *ctx; /* Context object: container for UM "instance". */ + lbm_src_t *src; /* Source object: for sending messages. */ + int err; #if defined(_MSC_VER) - /* Windows-specific startup overhead */ - WSADATA wsadata; - int wsa_err = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsa_err != 0) { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - fprintf(stderr, "%s:%d, WSAStartup error: %d\n", - __FILE__, __LINE__, wsa_err); - exit(1); - } + /* Windows-specific startup overhead */ + WSADATA wsadata; + int wsa_err = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsa_err != 0) { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + fprintf(stderr, "%s:%d, WSAStartup error: %d\n", + __FILE__, __LINE__, wsa_err); + exit(1); + } #endif + /*** Initialization: create necessary UM objects. ***/ - /*** Initialization: create necessary UM objects. ***/ - - err = lbm_context_create(&ctx, NULL, NULL, NULL); - EX_LBM_CHK(err); + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); - { - lbm_topic_t *topic; /* Topic object: only needed temporarily. */ + { + lbm_topic_t *topic; /* Topic object: only needed temporarily. */ - err = lbm_src_topic_alloc(&topic, ctx, "Greeting", NULL); - EX_LBM_CHK(err); + err = lbm_src_topic_alloc(&topic, ctx, "Greeting", NULL); + EX_LBM_CHK(err); - err = lbm_src_create(&src, ctx, topic, NULL, NULL, NULL); - EX_LBM_CHK(err); - } + err = lbm_src_create(&src, ctx, topic, NULL, NULL, NULL); + EX_LBM_CHK(err); + } - SLEEP(1); /* Let topic resolution execute. */ + SLEEP(1); /* Let topic resolution execute. */ - /*** Send a message. ***/ + /*** Send a message. ***/ - err = lbm_src_send(src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK); - EX_LBM_CHK(err); + err = lbm_src_send(src, "Hello!", 6, LBM_MSG_FLUSH | LBM_SRC_BLOCK); + EX_LBM_CHK(err); - /*** Cleanup: delete UM objects. ***/ + /*** Cleanup: delete UM objects. ***/ - SLEEP(3); /* Linger a bit to allow retransmissions. */ + SLEEP(3); /* Linger a bit to allow retransmissions. */ - err = lbm_src_delete(src); - EX_LBM_CHK(err); + err = lbm_src_delete(src); + EX_LBM_CHK(err); - err = lbm_context_delete(ctx); - EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); #if defined(_MSC_VER) - /* Windows-specific cleanup overhead */ - WSACleanup(); + /* Windows-specific cleanup overhead */ + WSACleanup(); #endif - return 0; + + return 0; } /* main */ diff --git a/multi_context/c/multi_context.c b/multi_context/c/multi_context.c index df0a317..5b5f9d1 100644 --- a/multi_context/c/multi_context.c +++ b/multi_context/c/multi_context.c @@ -1,4 +1,23 @@ -/* Code Disclaimer? */ +/* multi_context.c - see http://ultramessaging.github.io/UMExamples/multi_context/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include @@ -17,37 +36,38 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) #define LBM_CONFIG_XML_FILE "multi_context_config.xml" #define LBM_APPLICATION_NAME "main" + int main(int argc, char **argv) { - lbm_context_t *ctx_1; /* Context object */ - lbm_context_attr_t * cattr_1; /* pointer to context attribute object */ - lbm_context_t *ctx_2; /* Context object */ - lbm_context_attr_t * cattr_2; /* pointer to context attribute object */ - int err; /* Used for checking API return codes */ + lbm_context_t *ctx_1; /* Context object */ + lbm_context_attr_t * cattr_1; /* pointer to context attribute object */ + lbm_context_t *ctx_2; /* Context object */ + lbm_context_attr_t * cattr_2; /* pointer to context attribute object */ + int err; #if defined(_WIN32) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + exit(1); + } #endif err = lbm_config_xml_file((const char *)LBM_CONFIG_XML_FILE, (const char *)LBM_APPLICATION_NAME); - EX_LBM_CHK(err); + EX_LBM_CHK(err); err = lbm_context_attr_create_from_xml(&cattr_1, "TRD1"); EX_LBM_CHK(err); @@ -69,5 +89,5 @@ int main(int argc, char **argv) #if defined(_MSC_VER) WSACleanup(); #endif - return 0; -} + return 0; +} /* main */ diff --git a/multi_context/c/multi_context.sldoc.html b/multi_context/c/multi_context.sldoc.html index 77c9a66..5e9179b 100644 --- a/multi_context/c/multi_context.sldoc.html +++ b/multi_context/c/multi_context.sldoc.html @@ -37,8 +37,8 @@

Define Configuration File Name

of this sample application, they are simply defined as macros

-00027  #define LBM_CONFIG_XML_FILE  "multi_context_config.xml"
-00028  #define LBM_APPLICATION_NAME "main"
+00046  #define LBM_CONFIG_XML_FILE  "multi_context_config.xml"
+00047  #define LBM_APPLICATION_NAME "main"
 
@@ -48,8 +48,8 @@

Load XML File

provided here in order to ensure that this application loads the correct configurations.

-00049      err = lbm_config_xml_file((const char *)LBM_CONFIG_XML_FILE, (const char *)LBM_APPLICATION_NAME);
-00050      EX_LBM_CHK(err);
+00069      err = lbm_config_xml_file((const char *)LBM_CONFIG_XML_FILE, (const char *)LBM_APPLICATION_NAME);
+00070      EX_LBM_CHK(err);
 
@@ -58,11 +58,11 @@

Creating Context 1

to a specific context name (TRD1) define in the XML using the appropriate API like so:

-00052      err = lbm_context_attr_create_from_xml(&cattr_1, "TRD1");
-00053      EX_LBM_CHK(err);
-00054  
-00055      err = lbm_context_create(&ctx_1, cattr_1, NULL, NULL);
-00056      EX_LBM_CHK(err);
+00072      err = lbm_context_attr_create_from_xml(&cattr_1, "TRD1");
+00073      EX_LBM_CHK(err);
+00074  
+00075      err = lbm_context_create(&ctx_1, cattr_1, NULL, NULL);
+00076      EX_LBM_CHK(err);
 
@@ -70,11 +70,11 @@

Creating Context 1

context attribute object:

-00058      err = lbm_context_attr_create_from_xml(&cattr_2, "TRD2");
-00059      EX_LBM_CHK(err);
-00060  
-00061      err = lbm_context_create(&ctx_2, cattr_2, NULL, NULL);
-00062      EX_LBM_CHK(err);
+00078      err = lbm_context_attr_create_from_xml(&cattr_2, "TRD2");
+00079      EX_LBM_CHK(err);
+00080  
+00081      err = lbm_context_create(&ctx_2, cattr_2, NULL, NULL);
+00082      EX_LBM_CHK(err);
 
@@ -84,14 +84,14 @@

Error Checking

print a message and exit the program:

-00018  /* Example error checking macro.  Include after each UM call. */
-00019  #define EX_LBM_CHK(err) do { \
-00020          if ((err) < 0) { \
-00021                  fprintf(stderr, "%s:%d, lbm error: '%s'\n", \
-00022                  __FILE__, __LINE__, lbm_errmsg()); \
-00023                  exit(1); \
-00024          }  \
-00025  } while (0)
+00037  /* Example error checking macro.  Include after each UM call. */
+00038  #define EX_LBM_CHK(err) do { \
+00039      if ((err) < 0) { \
+00040          fprintf(stderr, "%s:%d, lbm error: '%s'\n", \
+00041          __FILE__, __LINE__, lbm_errmsg()); \
+00042          exit(1); \
+00043      }  \
+00044  } while (0)
 
@@ -107,20 +107,20 @@

Includes

A small effort was made to provide a some portability between Unix and Windows. For example:

-00003  #include <stdio.h>
-00004  
-00005  #if defined(_MSC_VER)
-00006  /* Windows-only includes */
-00007  #include <winsock2.h>
-00008  #define SLEEP(s) Sleep((s)*1000)
-00009  #else
-00010  /* Unix-only includes */
-00011  #include <stdlib.h>
-00012  #include <unistd.h>
-00013  #define SLEEP(s) sleep(s)
-00014  #endif
-00015  
-00016  #include <lbm/lbm.h>
+00022  #include <stdio.h>
+00023  
+00024  #if defined(_MSC_VER)
+00025  /* Windows-only includes */
+00026  #include <winsock2.h>
+00027  #define SLEEP(s) Sleep((s)*1000)
+00028  #else
+00029  /* Unix-only includes */
+00030  #include <stdlib.h>
+00031  #include <unistd.h>
+00032  #define SLEEP(s) sleep(s)
+00033  #endif
+00034  
+00035  #include <lbm/lbm.h>
 
diff --git a/multi_context/c/multi_context_c.slsrc b/multi_context/c/multi_context_c.slsrc index fccc439..fc7cb35 100644 --- a/multi_context/c/multi_context_c.slsrc +++ b/multi_context/c/multi_context_c.slsrc @@ -1,4 +1,23 @@ -/* Code Disclaimer? */ +/* multi_context.c - see http://ultramessaging.github.io/UMExamples/multi_context/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ /* =semlit,block,includes=*/ #include @@ -20,11 +39,11 @@ /* =semlit,block,error_check=*/ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) /* =semlit,endblock,error_check=*/ @@ -33,33 +52,34 @@ #define LBM_APPLICATION_NAME "main" /* =semlit,endblock,define_configs=*/ + int main(int argc, char **argv) { - /* =semlit,block,vars=*/ - lbm_context_t *ctx_1; /* Context object */ - lbm_context_attr_t * cattr_1; /* pointer to context attribute object */ - lbm_context_t *ctx_2; /* Context object */ - lbm_context_attr_t * cattr_2; /* pointer to context attribute object */ - int err; /* Used for checking API return codes */ - /* =semlit,endblock,vars=*/ + /* =semlit,block,vars=*/ + lbm_context_t *ctx_1; /* Context object */ + lbm_context_attr_t * cattr_1; /* pointer to context attribute object */ + lbm_context_t *ctx_2; /* Context object */ + lbm_context_attr_t * cattr_2; /* pointer to context attribute object */ + int err; + /* =semlit,endblock,vars=*/ - /* =semlit,block,init_win=*/ + /* =semlit,block,init_win=*/ #if defined(_WIN32) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + exit(1); + } #endif - /* =semlit,endblock,init_win=*/ + /* =semlit,endblock,init_win=*/ - /* =semlit,block,xml_file=*/ + /* =semlit,block,xml_file=*/ err = lbm_config_xml_file((const char *)LBM_CONFIG_XML_FILE, (const char *)LBM_APPLICATION_NAME); - EX_LBM_CHK(err); - /* =semlit,endblock,xml_file=*/ + EX_LBM_CHK(err); + /* =semlit,endblock,xml_file=*/ /* =semlit,block,ctx_1=*/ err = lbm_context_attr_create_from_xml(&cattr_1, "TRD1"); @@ -85,5 +105,5 @@ int main(int argc, char **argv) #if defined(_MSC_VER) WSACleanup(); #endif - return 0; -} + return 0; +} /* main */ diff --git a/multi_context/c/multi_context_c.slsrc.html b/multi_context/c/multi_context_c.slsrc.html index f1d5d1f..20d1c49 100644 --- a/multi_context/c/multi_context_c.slsrc.html +++ b/multi_context/c/multi_context_c.slsrc.html @@ -18,78 +18,117 @@
00001 00002 -00003 -00004 -00005 -00006 -00007 -00008 -00009 -00010 -00011 -00012 -00013 -00014 -00015 -00016 +00003 +00004 +00005 +00006 +00007 +00008 +00009 +00010 +00011 +00012 +00013 +00014 +00015 +00016 00017 -00018 -00019 -00020 -00021 -00022 -00023 -00024 -00025 -00026 -00027 -00028 -00029 -00030 -00031 -00032 -00033 -00034 -00035 -00036 -00037 -00038 -00039 -00040 -00041 -00042 -00043 -00044 -00045 -00046 -00047 +00018 +00019 +00020 +00021 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 +00036 +00037 +00038 +00039 +00040 +00041 +00042 +00043 +00044 +00045 +00046 +00047 00048 -00049 -00050 +00049 +00050 00051 -00052 -00053 -00054 -00055 -00056 +00052 +00053 +00054 +00055 +00056 00057 -00058 -00059 -00060 -00061 -00062 -00063 -00064 -00065 -00066 -00067 +00058 +00059 +00060 +00061 +00062 +00063 +00064 +00065 +00066 +00067 00068 -00069 -00070 +00069 +00070 00071 -00072 -00073 - /* Code Disclaimer? */ +00072 +00073 +00074 +00075 +00076 +00077 +00078 +00079 +00080 +00081 +00082 +00083 +00084 +00085 +00086 +00087 +00088 +00089 +00090 +00091 +00092 +00093 + /* multi_context.c - see http://ultramessaging.github.io/UMExamples/multi_context/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include <stdio.h> @@ -108,33 +147,34 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) #define LBM_CONFIG_XML_FILE "multi_context_config.xml" #define LBM_APPLICATION_NAME "main" + int main(int argc, char **argv) { - lbm_context_t *ctx_1; /* Context object */ - lbm_context_attr_t * cattr_1; /* pointer to context attribute object */ - lbm_context_t *ctx_2; /* Context object */ - lbm_context_attr_t * cattr_2; /* pointer to context attribute object */ - int err; /* Used for checking API return codes */ + lbm_context_t *ctx_1; /* Context object */ + lbm_context_attr_t * cattr_1; /* pointer to context attribute object */ + lbm_context_t *ctx_2; /* Context object */ + lbm_context_attr_t * cattr_2; /* pointer to context attribute object */ + int err; #if defined(_WIN32) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + exit(1); + } #endif err = lbm_config_xml_file((const char *)LBM_CONFIG_XML_FILE, (const char *)LBM_APPLICATION_NAME); @@ -160,8 +200,8 @@ #if defined(_MSC_VER) WSACleanup(); #endif - return 0; - } + return 0; + } /* main */
diff --git a/no_source_notify/c/no_source_notify.c b/no_source_notify/c/no_source_notify.c index 097414b..de9304e 100644 --- a/no_source_notify/c/no_source_notify.c +++ b/no_source_notify/c/no_source_notify.c @@ -1,4 +1,23 @@ -/* no_source_notify.c - http://ultramessaging.github.io/UMExamples */ +/* no_source_notify.c - see http://ultramessaging.github.io/UMExamples/no_source_notify/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include @@ -17,22 +36,21 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) #define NO_SOURCE_QUERIES "25" int no_source = 0; + /* Callback used to handle request message for receiver */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { - int err; - switch (msg->type) { case LBM_MSG_NO_SOURCE_NOTIFICATION: printf("[%s], no sources found for topic after %s queries\n", msg->topic_name, NO_SOURCE_QUERIES); @@ -43,16 +61,16 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) break; } return 0; -} +} /* rcv_handle_msg */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ - lbm_topic_t *rtopic; /* Receiver Topic object */ - lbm_rcv_topic_attr_t * rattr; /* Receiver attribute object */ - int err; /* Used for checking API return codes */ + lbm_context_t *ctx; /* Context object */ + lbm_rcv_t *rcv; /* Receive object: for subscribing to topics. */ + lbm_topic_t *rtopic; /* Receiver Topic object */ + lbm_rcv_topic_attr_t * rattr; /* Receiver attribute object */ + int err; #if defined(_WIN32) /* windows-specific code */ @@ -70,13 +88,13 @@ int main(int argc, char **argv) EX_LBM_CHK(err); err = lbm_rcv_topic_attr_create(&rattr); - EX_LBM_CHK(err); + EX_LBM_CHK(err); err = lbm_rcv_topic_attr_str_setopt(rattr, "resolution_no_source_notification_threshold", NO_SOURCE_QUERIES); EX_LBM_CHK(err); err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", rattr); - EX_LBM_CHK(err); + EX_LBM_CHK(err); err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); EX_LBM_CHK(err); @@ -93,5 +111,6 @@ int main(int argc, char **argv) /* Windows-specific cleanup overhead */ WSACleanup(); #endif - return 0; + + return 0; } /* main */ diff --git a/no_source_notify/c/no_source_notify.sldoc.html b/no_source_notify/c/no_source_notify.sldoc.html index 84af21f..8e49f26 100644 --- a/no_source_notify/c/no_source_notify.sldoc.html +++ b/no_source_notify/c/no_source_notify.sldoc.html @@ -34,14 +34,14 @@

Variables

First there is a macro to define the number of queries threshold before the notification is executed

-00027  #define NO_SOURCE_QUERIES "25"
+00046  #define NO_SOURCE_QUERIES "25"
 

Next there is the global flag variable which the main application thread will wait on.

-00029  int no_source = 0;
+00048  int no_source = 0;
 
@@ -60,8 +60,8 @@

Configure the Threshold Attribute

The attribute can be configured programatically like so:

-00075      err = lbm_rcv_topic_attr_str_setopt(rattr, "resolution_no_source_notification_threshold", NO_SOURCE_QUERIES);
-00076      EX_LBM_CHK(err);    
+00093      err = lbm_rcv_topic_attr_str_setopt(rattr, "resolution_no_source_notification_threshold", NO_SOURCE_QUERIES);
+00094      EX_LBM_CHK(err);    
 
@@ -72,10 +72,10 @@

Handle the Notification Callback

we will simply print a message to stdout.

-00037          case LBM_MSG_NO_SOURCE_NOTIFICATION:
-00038              printf("[%s], no sources found for topic after %s queries\n", msg->topic_name, NO_SOURCE_QUERIES);
-00039              no_source++;
-00040              break;
+00055          case LBM_MSG_NO_SOURCE_NOTIFICATION:
+00056              printf("[%s], no sources found for topic after %s queries\n", msg->topic_name, NO_SOURCE_QUERIES);
+00057              no_source++;
+00058              break;
 
@@ -84,20 +84,20 @@

Includes

are not necessary for Linux only applications

-00003  #include <stdio.h>
-00004  
-00005  #if defined(_MSC_VER)
-00006  /* Windows-only includes */
-00007  #include <winsock2.h>
-00008  #define SLEEP(s) Sleep((s)*1000)
-00009  #else
-00010  /* Unix-only includes */
-00011  #include <stdlib.h>
-00012  #include <unistd.h>
-00013  #define SLEEP(s) sleep(s)
-00014  #endif
-00015  
-00016  #include <lbm/lbm.h>
+00022  #include <stdio.h>
+00023  
+00024  #if defined(_MSC_VER)
+00025  /* Windows-only includes */
+00026  #include <winsock2.h>
+00027  #define SLEEP(s) Sleep((s)*1000)
+00028  #else
+00029  /* Unix-only includes */
+00030  #include <stdlib.h>
+00031  #include <unistd.h>
+00032  #define SLEEP(s) sleep(s)
+00033  #endif
+00034  
+00035  #include <lbm/lbm.h>
 
@@ -105,16 +105,16 @@

Windows Only

Windows applications must initialize the Winsock library to utilize sockets.

-00057  #if defined(_WIN32)
-00058      /* windows-specific code */
-00059      WSADATA wsadata;
-00060      int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata);
-00061      if (wsStat != 0)
-00062      {
-00063          printf("line %d: wsStat=%d\n",__LINE__,wsStat);
-00064          exit(1);
-00065      }
-00066  #endif
+00075  #if defined(_WIN32)
+00076      /* windows-specific code */
+00077      WSADATA wsadata;
+00078      int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata);
+00079      if (wsStat != 0)
+00080      {
+00081          printf("line %d: wsStat=%d\n",__LINE__,wsStat);
+00082          exit(1);
+00083      }
+00084  #endif
 
diff --git a/no_source_notify/c/no_source_notify_c.slsrc b/no_source_notify/c/no_source_notify_c.slsrc index d99d22f..f1c789d 100644 --- a/no_source_notify/c/no_source_notify_c.slsrc +++ b/no_source_notify/c/no_source_notify_c.slsrc @@ -1,4 +1,23 @@ -/* no_source_notify.c - http://ultramessaging.github.io/UMExamples */ +/* no_source_notify.c - see http://ultramessaging.github.io/UMExamples/no_source_notify/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ /* =semlit,block,includes=*/ #include @@ -19,11 +38,11 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) /* =semlit,block,num_queries=*/ @@ -34,11 +53,10 @@ int no_source = 0; /* =semlit,endblock,no_source_var=*/ + /* Callback used to handle request message for receiver */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { - int err; - switch (msg->type) { /* =semlit,block,no_source_cb=*/ case LBM_MSG_NO_SOURCE_NOTIFICATION: @@ -51,16 +69,16 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) break; } return 0; -} +} /* rcv_handle_msg */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ - lbm_topic_t *rtopic; /* Receiver Topic object */ - lbm_rcv_topic_attr_t * rattr; /* Receiver attribute object */ - int err; /* Used for checking API return codes */ + lbm_context_t *ctx; /* Context object */ + lbm_rcv_t *rcv; /* Receive object: for subscribing to topics. */ + lbm_topic_t *rtopic; /* Receiver Topic object */ + lbm_rcv_topic_attr_t * rattr; /* Receiver attribute object */ + int err; /* =semlit,block,windows=*/ #if defined(_WIN32) @@ -80,7 +98,7 @@ int main(int argc, char **argv) EX_LBM_CHK(err); err = lbm_rcv_topic_attr_create(&rattr); - EX_LBM_CHK(err); + EX_LBM_CHK(err); /* =semlit,block,set_attr=*/ err = lbm_rcv_topic_attr_str_setopt(rattr, "resolution_no_source_notification_threshold", NO_SOURCE_QUERIES); @@ -88,7 +106,7 @@ int main(int argc, char **argv) /* =semlit,endblock,set_attr=*/ err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", rattr); - EX_LBM_CHK(err); + EX_LBM_CHK(err); err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); EX_LBM_CHK(err); @@ -105,5 +123,6 @@ int main(int argc, char **argv) /* Windows-specific cleanup overhead */ WSACleanup(); #endif - return 0; + + return 0; } /* main */ diff --git a/no_source_notify/c/no_source_notify_c.slsrc.html b/no_source_notify/c/no_source_notify_c.slsrc.html index f7f171c..a11afc4 100644 --- a/no_source_notify/c/no_source_notify_c.slsrc.html +++ b/no_source_notify/c/no_source_notify_c.slsrc.html @@ -18,70 +18,70 @@
00001 00002 -00003 -00004 -00005 -00006 -00007 -00008 -00009 -00010 -00011 -00012 -00013 -00014 -00015 -00016 +00003 +00004 +00005 +00006 +00007 +00008 +00009 +00010 +00011 +00012 +00013 +00014 +00015 +00016 00017 00018 00019 00020 00021 -00022 -00023 -00024 -00025 -00026 -00027 -00028 -00029 -00030 -00031 -00032 -00033 -00034 -00035 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 00036 -00037 -00038 -00039 -00040 +00037 +00038 +00039 +00040 00041 00042 00043 00044 00045 -00046 +00046 00047 -00048 +00048 00049 00050 00051 00052 00053 00054 -00055 -00056 -00057 -00058 -00059 -00060 -00061 -00062 -00063 -00064 -00065 -00066 +00055 +00056 +00057 +00058 +00059 +00060 +00061 +00062 +00063 +00064 +00065 +00066 00067 00068 00069 @@ -90,16 +90,16 @@ 00072 00073 00074 -00075 -00076 -00077 -00078 -00079 -00080 -00081 -00082 -00083 -00084 +00075 +00076 +00077 +00078 +00079 +00080 +00081 +00082 +00083 +00084 00085 00086 00087 @@ -108,12 +108,50 @@ 00090 00091 00092 -00093 -00094 +00093 +00094 00095 00096 00097 - /* no_source_notify.c - http://ultramessaging.github.io/UMExamples */ +00098 +00099 +00100 +00101 +00102 +00103 +00104 +00105 +00106 +00107 +00108 +00109 +00110 +00111 +00112 +00113 +00114 +00115 +00116 + /* no_source_notify.c - see http://ultramessaging.github.io/UMExamples/no_source_notify/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include <stdio.h> @@ -132,22 +170,21 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) #define NO_SOURCE_QUERIES "25" int no_source = 0; + /* Callback used to handle request message for receiver */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { - int err; - switch (msg->type) { case LBM_MSG_NO_SOURCE_NOTIFICATION: printf("[%s], no sources found for topic after %s queries\n", msg->topic_name, NO_SOURCE_QUERIES); @@ -158,16 +195,16 @@ break; } return 0; - } + } /* rcv_handle_msg */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ - lbm_topic_t *rtopic; /* Receiver Topic object */ - lbm_rcv_topic_attr_t * rattr; /* Receiver attribute object */ - int err; /* Used for checking API return codes */ + lbm_context_t *ctx; /* Context object */ + lbm_rcv_t *rcv; /* Receive object: for subscribing to topics. */ + lbm_topic_t *rtopic; /* Receiver Topic object */ + lbm_rcv_topic_attr_t * rattr; /* Receiver attribute object */ + int err; #if defined(_WIN32) /* windows-specific code */ @@ -185,13 +222,13 @@ EX_LBM_CHK(err); err = lbm_rcv_topic_attr_create(&rattr); - EX_LBM_CHK(err); + EX_LBM_CHK(err); err = lbm_rcv_topic_attr_str_setopt(rattr, "resolution_no_source_notification_threshold", NO_SOURCE_QUERIES); EX_LBM_CHK(err); err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", rattr); - EX_LBM_CHK(err); + EX_LBM_CHK(err); err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); EX_LBM_CHK(err); @@ -208,7 +245,8 @@ /* Windows-specific cleanup overhead */ WSACleanup(); #endif - return 0; + + return 0; } /* main */
diff --git a/quorum_state/c/quorum_state.c b/quorum_state/c/quorum_state.c index 77d8ed7..587afa9 100644 --- a/quorum_state/c/quorum_state.c +++ b/quorum_state/c/quorum_state.c @@ -1,4 +1,23 @@ -/* Code Disclaimer? */ +/* quorum_state.c - see http://ultramessaging.github.io/UMExamples/quorum_state/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include #include @@ -22,8 +41,18 @@ # define SLEEP_SEC(x) sleep(x) #endif +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ +} while (0) + int src_ready = 0; + /* Source event handler callback (passed into lbm_src_create()) */ int handle_src_event(lbm_src_t *src, int event, void *ed, void *cd) { @@ -42,82 +71,56 @@ int handle_src_event(lbm_src_t *src, int event, void *ed, void *cd) } } return 0; -} +} /* handle_src_event */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object */ - lbm_topic_t *topic; /* Topic object */ - lbm_src_t *src; /* Source object */ - lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - int err; /* Used for checking API return codes */ + lbm_context_t *ctx; /* Context object */ + lbm_topic_t *topic; /* Topic object */ + lbm_src_t *src; /* Source object */ + lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ + int err; #if defined(_WIN32) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + exit(1); + } #endif - if (lbm_context_attr_create(&cattr) != 0) - { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); - exit(1); - } - - err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - if (lbm_src_topic_attr_create(&tattr) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg()); - exit(1); - } - - /* Assuming there is a store running on the localhost at port 29999 */ - if (lbm_src_topic_attr_str_setopt(tattr, "ume_store", "127.0.0.1:29999") != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:ume_store: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); + + err = lbm_src_topic_attr_create(&tattr); + EX_LBM_CHK(err); + + /* Assuming there is a store running on the localhost at port 29999 */ + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", "127.0.0.1:29999"); + EX_LBM_CHK(err); /* Need to set store behavior to Quorum-Consensus */ - if (lbm_src_topic_attr_str_setopt(tattr, "ume_store_behavior", "qc") != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:ume_store_behavior: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store_behavior", "qc"); + EX_LBM_CHK(err); - err = lbm_src_topic_alloc(&topic, ctx, "test.topic", tattr); - if (err) - { - printf("lbm_src_topic_alloc - line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_alloc(&topic, ctx, "test.topic", tattr); + EX_LBM_CHK(err); - err = lbm_src_create(&src, ctx, topic, handle_src_event, NULL, NULL); - if (err) - { - printf("lbm_src_create - line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + err = lbm_src_create(&src, ctx, topic, handle_src_event, NULL, NULL); + EX_LBM_CHK(err); while(1) { if (src_ready) { - if (lbm_src_send(src, "test", 4, LBM_SRC_NONBLOCK) == LBM_FAILURE) + err = lbm_src_send(src, "test", 4, LBM_SRC_NONBLOCK); + if (err == LBM_FAILURE) { - /* Assume EWOULDBLOCK and wait */ + /* Assume EWOULDBLOCK, wait, and retry. */ SLEEP_SEC(1); } } @@ -128,5 +131,6 @@ int main(int argc, char **argv) SLEEP_SEC(1); } } - return 0; -} + + return 0; +} /* main */ diff --git a/quorum_state/c/quorum_state.sldoc.html b/quorum_state/c/quorum_state.sldoc.html index e35533c..e5f40fe 100644 --- a/quorum_state/c/quorum_state.sldoc.html +++ b/quorum_state/c/quorum_state.sldoc.html @@ -35,7 +35,7 @@

Create a state variable

initialize as 0, because the source upon creation will not be in a state where it can send.

-00025  int src_ready = 0;
+00053  int src_ready = 0;
 
@@ -44,18 +44,8 @@

Create the context

Creating a Context

-00067          if (lbm_context_attr_create(&cattr) != 0)
-00068          {
-00069                  fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg());
-00070                  exit(1);
-00071          }
-00072  
-00073          err = lbm_context_create(&ctx, cattr, NULL, NULL);
-00074          if (err)
-00075          {
-00076                  printf("line %d: %s\n", __LINE__, lbm_errmsg());
-00077                  exit(1);
-00078          }
+00096      err = lbm_context_create(&ctx, NULL, NULL, NULL);
+00097      EX_LBM_CHK(err);
 
@@ -82,39 +72,22 @@

Create Source

-00080          if (lbm_src_topic_attr_create(&tattr) != 0)
-00081          {
-00082                  fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg());
-00083                  exit(1);
-00084          }
-00085  
-00086          /* Assuming there is a store running on the localhost at port 29999 */
-00087          if (lbm_src_topic_attr_str_setopt(tattr, "ume_store", "127.0.0.1:29999") != 0 )
-00088          {
-00089                  fprintf(stderr, "lbm_src_topic_attr_str_setopt:ume_store: %s\n", lbm_errmsg());
-00090                  exit(1);
-00091          }
-00092  
-00093      /* Need to set store behavior to Quorum-Consensus  */
-00094      if (lbm_src_topic_attr_str_setopt(tattr, "ume_store_behavior", "qc") != 0 )
-00095      {
-00096          fprintf(stderr, "lbm_src_topic_attr_str_setopt:ume_store_behavior: %s\n", lbm_errmsg());
-00097          exit(1);
-00098      }
-00099  
-00100          err = lbm_src_topic_alloc(&topic, ctx, "test.topic", tattr);
-00101          if (err)
-00102          {
-00103                  printf("lbm_src_topic_alloc - line %d: %s\n", __LINE__, lbm_errmsg());
-00104                  exit(1);
-00105          }
-00106  
-00107          err = lbm_src_create(&src, ctx, topic, handle_src_event, NULL, NULL);
-00108          if (err)
-00109          {
-00110                  printf("lbm_src_create - line %d: %s\n", __LINE__, lbm_errmsg());
-00111                  exit(1);
-00112          }
+00099      err = lbm_src_topic_attr_create(&tattr);
+00100      EX_LBM_CHK(err);
+00101  
+00102      /* Assuming there is a store running on the localhost at port 29999 */
+00103      err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", "127.0.0.1:29999");
+00104      EX_LBM_CHK(err);
+00105  
+00106      /* Need to set store behavior to Quorum-Consensus  */
+00107      err = lbm_src_topic_attr_str_setopt(tattr, "ume_store_behavior", "qc");
+00108      EX_LBM_CHK(err);
+00109  
+00110      err = lbm_src_topic_alloc(&topic, ctx, "test.topic", tattr);
+00111      EX_LBM_CHK(err);
+00112  
+00113      err = lbm_src_create(&src, ctx, topic, handle_src_event, NULL, NULL);
+00114      EX_LBM_CHK(err);
 
@@ -156,11 +129,11 @@

Setting the state

store. Setting the state in the registration complete event can look like this:

-00031          case LBM_SRC_EVENT_UME_REGISTRATION_COMPLETE_EX:
-00032          {
-00033              src_ready = 1;
-00034              break;
-00035          }
+00060          case LBM_SRC_EVENT_UME_REGISTRATION_COMPLETE_EX:
+00061          {
+00062              src_ready = 1;
+00063              break;
+00064          }
 
@@ -170,13 +143,13 @@

Setting the state

determine if quorum has actually been lost, like so:

-00036          case LBM_SRC_EVENT_UME_STORE_UNRESPONSIVE:
-00037          {
-00038              const char *infostr = (const char *)ed;
-00039              if (strstr(infostr, "quorum lost") != NULL)
-00040                  src_ready = 0;
-00041              break;
-00042          }
+00065          case LBM_SRC_EVENT_UME_STORE_UNRESPONSIVE:
+00066          {
+00067              const char *infostr = (const char *)ed;
+00068              if (strstr(infostr, "quorum lost") != NULL)
+00069                  src_ready = 0;
+00070              break;
+00071          }
 
@@ -187,7 +160,7 @@

Main Send Loop

to stdout when the source is not in the ready state

-00114      while(1)
+00116      while(1)
 
@@ -197,20 +170,21 @@

Send a Message

notified via the unresponsive source event; in either case the source cannot send.

-00116          if (src_ready)
-00117          {
-00118              if (lbm_src_send(src, "test", 4, LBM_SRC_NONBLOCK) == LBM_FAILURE)
-00119              {
-00120                  /* Assume EWOULDBLOCK and wait */
-00121                  SLEEP_SEC(1);
-00122              }
-00123          }
-00124          else
-00125          {
-00126              /* Print a warning that the source is not ready and sleep */
-00127              printf("Source is not ready to send (no quorum)\n");
-00128              SLEEP_SEC(1);
-00129          }
+00118          if (src_ready)
+00119          {
+00120              err = lbm_src_send(src, "test", 4, LBM_SRC_NONBLOCK);
+00121              if (err  == LBM_FAILURE)
+00122              {
+00123                  /* Assume EWOULDBLOCK, wait, and retry. */
+00124                  SLEEP_SEC(1);
+00125              }
+00126          }
+00127          else
+00128          {
+00129              /* Print a warning that the source is not ready and sleep */
+00130              printf("Source is not ready to send (no quorum)\n");
+00131              SLEEP_SEC(1);
+00132          }
 
@@ -218,21 +192,21 @@

Includes

Include files for this application. Notice the Windows specific include files - these are not necessary for Linux only applications

-00003  #include <stdio.h>
-00004  #include <string.h>
-00005  
-00006  #if defined(_MSC_VER)
-00007  /* Windows-only includes */
-00008  #include <winsock2.h>
-00009  #define SLEEP(s) Sleep((s)*1000)
-00010  #else
-00011  /* Unix-only includes */
-00012  #include <stdlib.h>
-00013  #include <unistd.h>
-00014  #define SLEEP(s) sleep(s)
-00015  #endif
-00016  
-00017  #include <lbm/lbm.h>
+00022  #include <stdio.h>
+00023  #include <string.h>
+00024  
+00025  #if defined(_MSC_VER)
+00026  /* Windows-only includes */
+00027  #include <winsock2.h>
+00028  #define SLEEP(s) Sleep((s)*1000)
+00029  #else
+00030  /* Unix-only includes */
+00031  #include <stdlib.h>
+00032  #include <unistd.h>
+00033  #define SLEEP(s) sleep(s)
+00034  #endif
+00035  
+00036  #include <lbm/lbm.h>
 
@@ -241,11 +215,11 @@

Sleep helper function

sleep() for any number of seconds.

-00019  #if defined(_WIN32)
-00020  #   define SLEEP_SEC(x) Sleep((x)*1000)
-00021  #else
-00022  #   define SLEEP_SEC(x) sleep(x)
-00023  #endif
+00038  #if defined(_WIN32)
+00039  #   define SLEEP_SEC(x) Sleep((x)*1000)
+00040  #else
+00041  #   define SLEEP_SEC(x) sleep(x)
+00042  #endif
 
diff --git a/quorum_state/c/quorum_state_c.slsrc b/quorum_state/c/quorum_state_c.slsrc index 62b7c8c..ffd5865 100644 --- a/quorum_state/c/quorum_state_c.slsrc +++ b/quorum_state/c/quorum_state_c.slsrc @@ -1,4 +1,23 @@ -/* Code Disclaimer? */ +/* quorum_state.c - see http://ultramessaging.github.io/UMExamples/quorum_state/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ /* =semlit,block,includes=*/ #include @@ -26,10 +45,20 @@ #endif /* =semlit,endblock,sleep_macro=*/ +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ +} while (0) + /* =semlit,block,src_ready_int=*/ int src_ready = 0; /* =semlit,endblock,src_ready_int=*/ + /* Source event handler callback (passed into lbm_src_create()) */ int handle_src_event(lbm_src_t *src, int event, void *ed, void *cd) { @@ -52,91 +81,65 @@ int handle_src_event(lbm_src_t *src, int event, void *ed, void *cd) /* =semlit,endblock,unresponsive=*/ } return 0; -} +} /* handle_src_event */ + int main(int argc, char **argv) { - /* =semlit,block,variables=*/ - lbm_context_t *ctx; /* Context object */ - lbm_topic_t *topic; /* Topic object */ - lbm_src_t *src; /* Source object */ - lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - int err; /* Used for checking API return codes */ - /* =semlit,endblock,variables=*/ + /* =semlit,block,variables=*/ + lbm_context_t *ctx; /* Context object */ + lbm_topic_t *topic; /* Topic object */ + lbm_src_t *src; /* Source object */ + lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ + int err; + /* =semlit,endblock,variables=*/ #if defined(_WIN32) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + exit(1); + } #endif - /* =semlit,block,init_create_context=*/ - if (lbm_context_attr_create(&cattr) != 0) - { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); - exit(1); - } - - err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - /* =semlit,endblock,init_create_context=*/ - - /* =semlit,block,init_create_source=*/ - if (lbm_src_topic_attr_create(&tattr) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg()); - exit(1); - } - - /* Assuming there is a store running on the localhost at port 29999 */ - if (lbm_src_topic_attr_str_setopt(tattr, "ume_store", "127.0.0.1:29999") != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:ume_store: %s\n", lbm_errmsg()); - exit(1); - } + /* =semlit,block,init_create_context=*/ + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); + /* =semlit,endblock,init_create_context=*/ + + /* =semlit,block,init_create_source=*/ + err = lbm_src_topic_attr_create(&tattr); + EX_LBM_CHK(err); + + /* Assuming there is a store running on the localhost at port 29999 */ + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", "127.0.0.1:29999"); + EX_LBM_CHK(err); /* Need to set store behavior to Quorum-Consensus */ - if (lbm_src_topic_attr_str_setopt(tattr, "ume_store_behavior", "qc") != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:ume_store_behavior: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store_behavior", "qc"); + EX_LBM_CHK(err); + + err = lbm_src_topic_alloc(&topic, ctx, "test.topic", tattr); + EX_LBM_CHK(err); - err = lbm_src_topic_alloc(&topic, ctx, "test.topic", tattr); - if (err) - { - printf("lbm_src_topic_alloc - line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - err = lbm_src_create(&src, ctx, topic, handle_src_event, NULL, NULL); - if (err) - { - printf("lbm_src_create - line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - /* =semlit,endblock,init_create_source=*/ - - /* =semlit,block,main_send_loop=*/ + err = lbm_src_create(&src, ctx, topic, handle_src_event, NULL, NULL); + EX_LBM_CHK(err); + /* =semlit,endblock,init_create_source=*/ + + /* =semlit,block,main_send_loop=*/ while(1) /* =semlit,endblock,main_send_loop=*/ { /* =semlit,block,src_send=*/ if (src_ready) { - if (lbm_src_send(src, "test", 4, LBM_SRC_NONBLOCK) == LBM_FAILURE) + err = lbm_src_send(src, "test", 4, LBM_SRC_NONBLOCK); + if (err == LBM_FAILURE) { - /* Assume EWOULDBLOCK and wait */ + /* Assume EWOULDBLOCK, wait, and retry. */ SLEEP_SEC(1); } } @@ -148,5 +151,6 @@ int main(int argc, char **argv) } /* =semlit,endblock,src_send=*/ } - return 0; -} + + return 0; +} /* main */ diff --git a/quorum_state/c/quorum_state_c.slsrc.html b/quorum_state/c/quorum_state_c.slsrc.html index 62da0b6..acb8e92 100644 --- a/quorum_state/c/quorum_state_c.slsrc.html +++ b/quorum_state/c/quorum_state_c.slsrc.html @@ -18,102 +18,102 @@
00001 00002 -00003 -00004 -00005 -00006 -00007 -00008 -00009 -00010 -00011 -00012 -00013 -00014 -00015 -00016 -00017 +00003 +00004 +00005 +00006 +00007 +00008 +00009 +00010 +00011 +00012 +00013 +00014 +00015 +00016 +00017 00018 -00019 -00020 -00021 -00022 -00023 -00024 -00025 -00026 -00027 -00028 -00029 -00030 -00031 -00032 -00033 -00034 -00035 -00036 -00037 -00038 -00039 -00040 -00041 -00042 +00019 +00020 +00021 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 +00036 +00037 +00038 +00039 +00040 +00041 +00042 00043 00044 00045 00046 00047 00048 -00049 -00050 -00051 -00052 -00053 -00054 +00049 +00050 +00051 +00052 +00053 +00054 00055 00056 00057 00058 00059 -00060 -00061 -00062 -00063 -00064 -00065 -00066 -00067 -00068 -00069 -00070 -00071 -00072 -00073 -00074 -00075 -00076 -00077 -00078 -00079 -00080 -00081 -00082 -00083 -00084 -00085 -00086 -00087 -00088 -00089 -00090 -00091 -00092 -00093 -00094 -00095 -00096 -00097 -00098 +00060 +00061 +00062 +00063 +00064 +00065 +00066 +00067 +00068 +00069 +00070 +00071 +00072 +00073 +00074 +00075 +00076 +00077 +00078 +00079 +00080 +00081 +00082 +00083 +00084 +00085 +00086 +00087 +00088 +00089 +00090 +00091 +00092 +00093 +00094 +00095 +00096 +00097 +00098 00099 00100 00101 @@ -128,11 +128,11 @@ 00110 00111 00112 -00113 -00114 +00113 +00114 00115 -00116 -00117 +00116 +00117 00118 00119 00120 @@ -145,10 +145,33 @@ 00127 00128 00129 -00130 -00131 -00132 - /* Code Disclaimer? */ +00130 +00131 +00132 +00133 +00134 +00135 +00136 + /* quorum_state.c - see http://ultramessaging.github.io/UMExamples/quorum_state/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include <stdio.h> #include <string.h> @@ -172,8 +195,18 @@ # define SLEEP_SEC(x) sleep(x) #endif + /* Example error checking macro. Include after each UM call. */ + #define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ + } while (0) + int src_ready = 0; + /* Source event handler callback (passed into lbm_src_create()) */ int handle_src_event(lbm_src_t *src, int event, void *ed, void *cd) { @@ -192,82 +225,56 @@ } } return 0; - } + } /* handle_src_event */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object */ - lbm_topic_t *topic; /* Topic object */ - lbm_src_t *src; /* Source object */ - lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - int err; /* Used for checking API return codes */ + lbm_context_t *ctx; /* Context object */ + lbm_topic_t *topic; /* Topic object */ + lbm_src_t *src; /* Source object */ + lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ + int err; #if defined(_WIN32) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + exit(1); + } #endif - if (lbm_context_attr_create(&cattr) != 0) - { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); - exit(1); - } - - err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); - if (lbm_src_topic_attr_create(&tattr) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_create(&tattr); + EX_LBM_CHK(err); - /* Assuming there is a store running on the localhost at port 29999 */ - if (lbm_src_topic_attr_str_setopt(tattr, "ume_store", "127.0.0.1:29999") != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:ume_store: %s\n", lbm_errmsg()); - exit(1); - } + /* Assuming there is a store running on the localhost at port 29999 */ + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", "127.0.0.1:29999"); + EX_LBM_CHK(err); /* Need to set store behavior to Quorum-Consensus */ - if (lbm_src_topic_attr_str_setopt(tattr, "ume_store_behavior", "qc") != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:ume_store_behavior: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store_behavior", "qc"); + EX_LBM_CHK(err); - err = lbm_src_topic_alloc(&topic, ctx, "test.topic", tattr); - if (err) - { - printf("lbm_src_topic_alloc - line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_alloc(&topic, ctx, "test.topic", tattr); + EX_LBM_CHK(err); - err = lbm_src_create(&src, ctx, topic, handle_src_event, NULL, NULL); - if (err) - { - printf("lbm_src_create - line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + err = lbm_src_create(&src, ctx, topic, handle_src_event, NULL, NULL); + EX_LBM_CHK(err); while(1) { if (src_ready) { - if (lbm_src_send(src, "test", 4, LBM_SRC_NONBLOCK) == LBM_FAILURE) + err = lbm_src_send(src, "test", 4, LBM_SRC_NONBLOCK); + if (err == LBM_FAILURE) { - /* Assume EWOULDBLOCK and wait */ + /* Assume EWOULDBLOCK, wait, and retry. */ SLEEP_SEC(1); } } @@ -278,8 +285,9 @@ SLEEP_SEC(1); } } - return 0; - } + + return 0; + } /* main */
diff --git a/request_response/c/request_response.c b/request_response/c/request_response.c index 3b0bd43..cabd43a 100644 --- a/request_response/c/request_response.c +++ b/request_response/c/request_response.c @@ -1,4 +1,23 @@ -/* request_response.c - http://ultramessaging.github.io/UMExamples */ +/* request_response.c - see http://ultramessaging.github.io/UMExamples/request_response/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include @@ -18,15 +37,16 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) /* Global var used to indicate that the application can exit after response received */ int run = 1; + /* Callback used to handle request message for receiver */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { @@ -39,18 +59,22 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) EX_LBM_CHK(err); break; } -} + return 0; +} /* rcv_handle_msg */ + /* Callback used to handle response message */ int handle_response(lbm_request_t *req, lbm_msg_t *msg, void *clientd) { - switch (msg->type) { - case LBM_MSG_RESPONSE: + switch (msg->type) { + case LBM_MSG_RESPONSE: printf("LBM_MSG_RESPONSE received\n"); run = 0; break; } -} + return 0; +} /* handle_response */ + int main(int argc, char **argv) { @@ -58,28 +82,24 @@ int main(int argc, char **argv) lbm_topic_t *stopic; /* Source Topic object */ lbm_src_t *src; /* Source object */ lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ - lbm_context_attr_t * cattr; /* Context attribute object */ lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ lbm_topic_t *rtopic; /* Receiver Topic object */ lbm_request_t *req; /* Request object */ - int err; /* Used for checking API return codes */ + int err; #if defined(_WIN32) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + exit(1); + } #endif - + /* Initialize context atrributes and create context */ - err = lbm_context_attr_create(&cattr); - EX_LBM_CHK(err); - - err = lbm_context_create(&ctx, cattr, NULL, NULL); + err = lbm_context_create(&ctx, NULL, NULL, NULL); EX_LBM_CHK(err); /* Create receiver for receiving request and sending response */ @@ -92,12 +112,12 @@ int main(int argc, char **argv) /* Create source for sending request */ err = lbm_src_topic_attr_create(&tattr); EX_LBM_CHK(err); - + err = lbm_src_topic_alloc(&stopic, ctx, "test.topic", tattr); - EX_LBM_CHK(err); + EX_LBM_CHK(err); err = lbm_src_topic_attr_delete(tattr); - EX_LBM_CHK(err); + EX_LBM_CHK(err); err = lbm_src_create(&src, ctx, stopic, NULL, NULL, NULL); EX_LBM_CHK(err); @@ -106,25 +126,26 @@ int main(int argc, char **argv) EX_LBM_CHK(err); while (run) { /* loop until response received */ - SLEEP(1); - } + SLEEP(1); + } /* Clean up */ err = lbm_request_delete(req); EX_LBM_CHK(err); - err = lbm_src_delete(src); - EX_LBM_CHK(err); + err = lbm_src_delete(src); + EX_LBM_CHK(err); err = lbm_rcv_delete(rcv); EX_LBM_CHK(err); - err = lbm_context_delete(ctx); - EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); #if defined(_MSC_VER) - /* Windows-specific cleanup overhead */ - WSACleanup(); + /* Windows-specific cleanup overhead */ + WSACleanup(); #endif - return 0; + + return 0; } /* main */ diff --git a/request_response/c/request_response.sldoc.html b/request_response/c/request_response.sldoc.html index aeee175..bbba34c 100644 --- a/request_response/c/request_response.sldoc.html +++ b/request_response/c/request_response.sldoc.html @@ -32,15 +32,14 @@

Declare Variables

API calls

-00057      lbm_context_t *ctx;                     /* Context object */
-00058      lbm_topic_t *stopic;                    /* Source Topic object */
-00059      lbm_src_t *src;                         /* Source object */
-00060      lbm_src_topic_attr_t * tattr;           /* Source topic attribute object */
-00061      lbm_context_attr_t * cattr;             /* Context attribute object */
-00062      lbm_rcv_t *rcv;                         /* Receive object: for subscribing to messages. */
-00063      lbm_topic_t *rtopic;                    /* Receiver Topic object */
-00064      lbm_request_t *req;                     /* Request object */
-00065      int err;                                /* Used for checking API return codes */
+00081      lbm_context_t *ctx;                     /* Context object */
+00082      lbm_topic_t *stopic;                    /* Source Topic object */
+00083      lbm_src_t *src;                         /* Source object */
+00084      lbm_src_topic_attr_t * tattr;           /* Source topic attribute object */
+00085      lbm_rcv_t *rcv;                         /* Receive object: for subscribing to messages. */
+00086      lbm_topic_t *rtopic;                    /* Receiver Topic object */
+00087      lbm_request_t *req;                     /* Request object */
+00088      int err;
 
@@ -49,12 +48,12 @@

Create Receiver and Message Callback Function

object (rcv). Note when calling the receiver create API, lbm_rcv_create, the fourth parameter is rcv_handle_message.

-00085      /* Create receiver for receiving request and sending response */
-00086      err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL);
-00087      EX_LBM_CHK(err);
-00088  
-00089      err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL);
-00090      EX_LBM_CHK(err);
+00105      /* Create receiver for receiving request and sending response */
+00106      err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL);
+00107      EX_LBM_CHK(err);
+00108  
+00109      err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL);
+00110      EX_LBM_CHK(err);
 
@@ -66,18 +65,20 @@

Create Receiver and Message Callback Function

handled.

-00031  int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd)
-00032  {
-00033      int err;
-00034  
-00035      switch (msg->type) {
-00036      case LBM_MSG_REQUEST:
-00037          printf("LBM_MSG_REQUEST received\n");
-00038          err = lbm_send_response(msg->response, "response", 8, LBM_SRC_NONBLOCK);
-00039          EX_LBM_CHK(err);
-00040          break;
-00041      }
-00042  }
+00050  /* Callback used to handle request message for receiver */
+00051  int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd)
+00052  {
+00053      int err;
+00054  
+00055      switch (msg->type) {
+00056      case LBM_MSG_REQUEST:
+00057          printf("LBM_MSG_REQUEST received\n");
+00058          err = lbm_send_response(msg->response, "response", 8, LBM_SRC_NONBLOCK);
+00059          EX_LBM_CHK(err);
+00060          break;
+00061      }
+00062      return 0;
+00063  }  /* rcv_handle_msg */
 
@@ -86,17 +87,17 @@

Create source, Send Request and Response Handler Callback

send the request:

-00093      err = lbm_src_topic_attr_create(&tattr);
-00094      EX_LBM_CHK(err);
-00095    
-00096      err = lbm_src_topic_alloc(&stopic, ctx, "test.topic", tattr);
-00097      EX_LBM_CHK(err);
-00098  
-00099      err = lbm_src_topic_attr_delete(tattr);
-00100      EX_LBM_CHK(err);
-00101  
-00102      err = lbm_src_create(&src, ctx, stopic, NULL, NULL, NULL);
-00103      EX_LBM_CHK(err);
+00113      err = lbm_src_topic_attr_create(&tattr);
+00114      EX_LBM_CHK(err);
+00115  
+00116      err = lbm_src_topic_alloc(&stopic, ctx, "test.topic", tattr);
+00117      EX_LBM_CHK(err);
+00118  
+00119      err = lbm_src_topic_attr_delete(tattr);
+00120      EX_LBM_CHK(err);
+00121  
+00122      err = lbm_src_create(&src, ctx, stopic, NULL, NULL, NULL);
+00123      EX_LBM_CHK(err);
 
@@ -106,8 +107,8 @@

Create source, Send Request and Response Handler Callback

handle_response:

-00105      err = lbm_send_request(&req, src, "request", 7, handle_response, NULL, NULL, 0);
-00106      EX_LBM_CHK(err);
+00125      err = lbm_send_request(&req, src, "request", 7, handle_response, NULL, NULL, 0);
+00126      EX_LBM_CHK(err);
 
@@ -116,15 +117,17 @@

Create source, Send Request and Response Handler Callback

lbm_msg_t struct.

-00045  int handle_response(lbm_request_t *req, lbm_msg_t *msg, void *clientd)
-00046  {
-00047          switch (msg->type) {
-00048          case LBM_MSG_RESPONSE:
-00049          printf("LBM_MSG_RESPONSE received\n");
-00050          run = 0;
-00051          break;
-00052      }
-00053  }
+00066  /* Callback used to handle response message */
+00067  int handle_response(lbm_request_t *req, lbm_msg_t *msg, void *clientd)
+00068  {
+00069      switch (msg->type) {
+00070      case LBM_MSG_RESPONSE:
+00071          printf("LBM_MSG_RESPONSE received\n");
+00072          run = 0;
+00073          break;
+00074      }
+00075      return 0;
+00076  }  /* handle_response */
 
@@ -138,8 +141,8 @@

Send Response

on the context thread can result in application deadlock.

-00038          err = lbm_send_response(msg->response, "response", 8, LBM_SRC_NONBLOCK);
-00039          EX_LBM_CHK(err);
+00058          err = lbm_send_response(msg->response, "response", 8, LBM_SRC_NONBLOCK);
+00059          EX_LBM_CHK(err);
 
@@ -149,9 +152,9 @@

Main Loop

will be set to 0 and the loop will break

-00108      while (run) {  /* loop until response received */
-00109              SLEEP(1);
-00110      }
+00128      while (run) {  /* loop until response received */
+00129          SLEEP(1);
+00130      }
 
@@ -161,22 +164,22 @@

Cleanup

when not properly cleaned.

-00113      err = lbm_request_delete(req);
-00114      EX_LBM_CHK(err);
+00133      err = lbm_request_delete(req);
+00134      EX_LBM_CHK(err);
 

Once the request is deleted, the source, receiver and context can be deleted

-00116      err = lbm_src_delete(src);
-00117      EX_LBM_CHK(err);
-00118      
-00119      err = lbm_rcv_delete(rcv);
-00120      EX_LBM_CHK(err);
-00121  
-00122      err = lbm_context_delete(ctx);
-00123      EX_LBM_CHK(err);
+00136      err = lbm_src_delete(src);
+00137      EX_LBM_CHK(err);
+00138      
+00139      err = lbm_rcv_delete(rcv);
+00140      EX_LBM_CHK(err);
+00141  
+00142      err = lbm_context_delete(ctx);
+00143      EX_LBM_CHK(err);
 
@@ -186,14 +189,14 @@

Error Checking

print a message and exit the program:

-00018  /* Example error checking macro.  Include after each UM call. */
-00019  #define EX_LBM_CHK(err) do { \
-00020      if ((err) < 0) { \
-00021              fprintf(stderr, "%s:%d, lbm error: '%s'\n", \
-00022              __FILE__, __LINE__, lbm_errmsg()); \
-00023              exit(1); \
-00024      }  \
-00025  } while (0)
+00037  /* Example error checking macro.  Include after each UM call. */
+00038  #define EX_LBM_CHK(err) do { \
+00039      if ((err) < 0) { \
+00040          fprintf(stderr, "%s:%d, lbm error: '%s'\n", \
+00041              __FILE__, __LINE__, lbm_errmsg()); \
+00042          exit(1); \
+00043      }  \
+00044  } while (0)
 
@@ -209,26 +212,26 @@

Windows Only

Windows applications must initialize the Winsock library to utilize sockets.

-00067  #if defined(_WIN32)
-00068          /* windows-specific code */
-00069          WSADATA wsadata;
-00070          int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata);
-00071          if (wsStat != 0)
-00072          {
-00073                  printf("line %d: wsStat=%d\n",__LINE__,wsStat);
-00074                  exit(1);
-00075          }
-00076  #endif
+00090  #if defined(_WIN32)
+00091      /* windows-specific code */
+00092      WSADATA wsadata;
+00093      int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata);
+00094      if (wsStat != 0)
+00095      {
+00096          printf("line %d: wsStat=%d\n",__LINE__,wsStat);
+00097          exit(1);
+00098      }
+00099  #endif
 

A well-structured Windows networking application will also call WSACleanup() after before exit

-00125  #if defined(_MSC_VER)
-00126      /* Windows-specific cleanup overhead */
-00127      WSACleanup();
-00128  #endif
+00145  #if defined(_MSC_VER)
+00146      /* Windows-specific cleanup overhead */
+00147      WSACleanup();
+00148  #endif
 
@@ -236,20 +239,20 @@

Includes

A small effort was made to provide a some portability between Unix and Windows. For example:

-00003  #include <stdio.h>
-00004  
-00005  #if defined(_MSC_VER)
-00006  /* Windows-only includes */
-00007  #include <winsock2.h>
-00008  #define SLEEP(s) Sleep((s)*1000)
-00009  #else
-00010  /* Unix-only includes */
-00011  #include <stdlib.h>
-00012  #include <unistd.h>
-00013  #define SLEEP(s) sleep(s)
-00014  #endif
-00015  
-00016  #include <lbm/lbm.h>
+00022  #include <stdio.h>
+00023  
+00024  #if defined(_MSC_VER)
+00025  /* Windows-only includes */
+00026  #include <winsock2.h>
+00027  #define SLEEP(s) Sleep((s)*1000)
+00028  #else
+00029  /* Unix-only includes */
+00030  #include <stdlib.h>
+00031  #include <unistd.h>
+00032  #define SLEEP(s) sleep(s)
+00033  #endif
+00034  
+00035  #include <lbm/lbm.h>
 
diff --git a/request_response/c/request_response_c.slsrc b/request_response/c/request_response_c.slsrc index 82d236e..d90b7fc 100644 --- a/request_response/c/request_response_c.slsrc +++ b/request_response/c/request_response_c.slsrc @@ -1,4 +1,23 @@ -/* request_response.c - http://ultramessaging.github.io/UMExamples */ +/* request_response.c - see http://ultramessaging.github.io/UMExamples/request_response/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ /* =semlit,block,includes=*/ #include @@ -21,18 +40,19 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) /* =semlit,endblock,error_check=*/ /* Global var used to indicate that the application can exit after response received */ int run = 1; -/* Callback used to handle request message for receiver */ + /* =semlit,block,rcv_cb=*/ +/* Callback used to handle request message for receiver */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { int err; @@ -46,22 +66,26 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) /* =semlit,endblock,send_resp=*/ break; } -} + return 0; +} /* rcv_handle_msg */ /* =semlit,endblock,rcv_cb=*/ -/* Callback used to handle response message */ + /* =semlit,block,resp_cb=*/ +/* Callback used to handle response message */ int handle_response(lbm_request_t *req, lbm_msg_t *msg, void *clientd) { - switch (msg->type) { - case LBM_MSG_RESPONSE: + switch (msg->type) { + case LBM_MSG_RESPONSE: printf("LBM_MSG_RESPONSE received\n"); run = 0; break; } -} + return 0; +} /* handle_response */ /* =semlit,endblock,resp_cb=*/ + int main(int argc, char **argv) { /* =semlit,block,vars=*/ @@ -69,31 +93,27 @@ int main(int argc, char **argv) lbm_topic_t *stopic; /* Source Topic object */ lbm_src_t *src; /* Source object */ lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ - lbm_context_attr_t * cattr; /* Context attribute object */ lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ lbm_topic_t *rtopic; /* Receiver Topic object */ lbm_request_t *req; /* Request object */ - int err; /* Used for checking API return codes */ + int err; /* =semlit,endblock,vars=*/ /* =semlit,block,init_win=*/ #if defined(_WIN32) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + exit(1); + } #endif /* =semlit,endblock,init_win=*/ - + /* Initialize context atrributes and create context */ - err = lbm_context_attr_create(&cattr); - EX_LBM_CHK(err); - - err = lbm_context_create(&ctx, cattr, NULL, NULL); + err = lbm_context_create(&ctx, NULL, NULL, NULL); EX_LBM_CHK(err); /* =semlit,block,create_rcv=*/ @@ -109,12 +129,12 @@ int main(int argc, char **argv) /* =semlit,block,create_src=*/ err = lbm_src_topic_attr_create(&tattr); EX_LBM_CHK(err); - + err = lbm_src_topic_alloc(&stopic, ctx, "test.topic", tattr); - EX_LBM_CHK(err); + EX_LBM_CHK(err); err = lbm_src_topic_attr_delete(tattr); - EX_LBM_CHK(err); + EX_LBM_CHK(err); err = lbm_src_create(&src, ctx, stopic, NULL, NULL, NULL); EX_LBM_CHK(err); @@ -127,8 +147,8 @@ int main(int argc, char **argv) /* =semlit,block,loop=*/ while (run) { /* loop until response received */ - SLEEP(1); - } + SLEEP(1); + } /* =semlit,endblock,loop=*/ /* Clean up */ @@ -138,21 +158,22 @@ int main(int argc, char **argv) /* =semlit,endblock,del_req=*/ /* =semlit,block,clean=*/ - err = lbm_src_delete(src); - EX_LBM_CHK(err); + err = lbm_src_delete(src); + EX_LBM_CHK(err); err = lbm_rcv_delete(rcv); EX_LBM_CHK(err); - err = lbm_context_delete(ctx); - EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); /* =semlit,endblock,clean=*/ /* =semlit,block,clean_win=*/ #if defined(_MSC_VER) - /* Windows-specific cleanup overhead */ - WSACleanup(); + /* Windows-specific cleanup overhead */ + WSACleanup(); #endif /* =semlit,endblock,clean_win=*/ - return 0; + + return 0; } /* main */ diff --git a/request_response/c/request_response_c.slsrc.html b/request_response/c/request_response_c.slsrc.html index 1db1ca1..8cdb365 100644 --- a/request_response/c/request_response_c.slsrc.html +++ b/request_response/c/request_response_c.slsrc.html @@ -18,135 +18,175 @@
00001 00002 -00003 -00004 -00005 -00006 -00007 -00008 -00009 -00010 -00011 -00012 -00013 -00014 -00015 -00016 +00003 +00004 +00005 +00006 +00007 +00008 +00009 +00010 +00011 +00012 +00013 +00014 +00015 +00016 00017 -00018 -00019 -00020 -00021 -00022 -00023 -00024 -00025 -00026 -00027 -00028 -00029 -00030 -00031 -00032 -00033 -00034 -00035 -00036 -00037 -00038 -00039 -00040 -00041 -00042 -00043 -00044 -00045 -00046 -00047 -00048 -00049 -00050 -00051 -00052 -00053 -00054 -00055 -00056 -00057 -00058 -00059 -00060 -00061 -00062 -00063 -00064 -00065 -00066 -00067 -00068 -00069 -00070 -00071 -00072 -00073 -00074 -00075 -00076 +00018 +00019 +00020 +00021 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 +00036 +00037 +00038 +00039 +00040 +00041 +00042 +00043 +00044 +00045 +00046 +00047 +00048 +00049 +00050 +00051 +00052 +00053 +00054 +00055 +00056 +00057 +00058 +00059 +00060 +00061 +00062 +00063 +00064 +00065 +00066 +00067 +00068 +00069 +00070 +00071 +00072 +00073 +00074 +00075 +00076 00077 00078 00079 00080 -00081 -00082 -00083 -00084 -00085 -00086 -00087 -00088 -00089 -00090 -00091 -00092 -00093 -00094 -00095 -00096 -00097 -00098 -00099 -00100 -00101 -00102 -00103 +00081 +00082 +00083 +00084 +00085 +00086 +00087 +00088 +00089 +00090 +00091 +00092 +00093 +00094 +00095 +00096 +00097 +00098 +00099 +00100 +00101 +00102 +00103 00104 -00105 -00106 -00107 -00108 -00109 -00110 +00105 +00106 +00107 +00108 +00109 +00110 00111 00112 -00113 -00114 -00115 -00116 -00117 -00118 -00119 -00120 -00121 -00122 -00123 +00113 +00114 +00115 +00116 +00117 +00118 +00119 +00120 +00121 +00122 +00123 00124 -00125 -00126 -00127 -00128 -00129 -00130 - /* request_response.c - http://ultramessaging.github.io/UMExamples */ +00125 +00126 +00127 +00128 +00129 +00130 +00131 +00132 +00133 +00134 +00135 +00136 +00137 +00138 +00139 +00140 +00141 +00142 +00143 +00144 +00145 +00146 +00147 +00148 +00149 +00150 +00151 + /* request_response.c - see http://ultramessaging.github.io/UMExamples/request_response/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include <stdio.h> @@ -166,17 +206,18 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ + exit(1); \ } \ } while (0) /* Global var used to indicate that the application can exit after response received */ int run = 1; - /* Callback used to handle request message for receiver */ - int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) + + /* Callback used to handle request message for receiver */ + int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { int err; @@ -187,18 +228,22 @@ EX_LBM_CHK(err); break; } - } + return 0; + } /* rcv_handle_msg */ + - /* Callback used to handle response message */ - int handle_response(lbm_request_t *req, lbm_msg_t *msg, void *clientd) + /* Callback used to handle response message */ + int handle_response(lbm_request_t *req, lbm_msg_t *msg, void *clientd) { - switch (msg->type) { - case LBM_MSG_RESPONSE: + switch (msg->type) { + case LBM_MSG_RESPONSE: printf("LBM_MSG_RESPONSE received\n"); run = 0; break; } - } + return 0; + } /* handle_response */ + int main(int argc, char **argv) { @@ -206,28 +251,24 @@ lbm_topic_t *stopic; /* Source Topic object */ lbm_src_t *src; /* Source object */ lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ - lbm_context_attr_t * cattr; /* Context attribute object */ lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ lbm_topic_t *rtopic; /* Receiver Topic object */ lbm_request_t *req; /* Request object */ - int err; /* Used for checking API return codes */ + int err; #if defined(_WIN32) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + exit(1); + } #endif - + /* Initialize context atrributes and create context */ - err = lbm_context_attr_create(&cattr); - EX_LBM_CHK(err); - - err = lbm_context_create(&ctx, cattr, NULL, NULL); + err = lbm_context_create(&ctx, NULL, NULL, NULL); EX_LBM_CHK(err); /* Create receiver for receiving request and sending response */ @@ -240,7 +281,7 @@ /* Create source for sending request */ err = lbm_src_topic_attr_create(&tattr); EX_LBM_CHK(err); - + err = lbm_src_topic_alloc(&stopic, ctx, "test.topic", tattr); EX_LBM_CHK(err); @@ -254,7 +295,7 @@ EX_LBM_CHK(err); while (run) { /* loop until response received */ - SLEEP(1); + SLEEP(1); } /* Clean up */ @@ -274,7 +315,8 @@ /* Windows-specific cleanup overhead */ WSACleanup(); #endif - return 0; + + return 0; } /* main */
diff --git a/schedule_timers/c/schedule_timers.c b/schedule_timers/c/schedule_timers.c index ebec55f..ecb99f4 100644 --- a/schedule_timers/c/schedule_timers.c +++ b/schedule_timers/c/schedule_timers.c @@ -1,4 +1,23 @@ -/* Code Disclaimer? */ +/* schedule_timers.c - see http://ultramessaging.github.io/UMExamples/schedule_timers/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include @@ -26,31 +45,30 @@ int wait = 1; + /* Timer callback function */ int sample_timer_handler(lbm_context_t *ctx, const void *clientd) { printf("Timer executed. Set wait to 0 so application can cleanly exit\n"); wait = 0; -} + + return 0; +} /* sample_timer_handler */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - int err; /* Used for checking API return codes */ - int timer_id; /* Used to get timer id from schedule API */ + lbm_context_t *ctx; /* Context object */ + int timer_id; /* Used to get timer id from schedule API */ + int err; /* Initialize context atrributes and create context */ - err = lbm_context_attr_create(&cattr); - EX_LBM_CHK(err); - - err = lbm_context_create(&ctx, cattr, NULL, NULL); + err = lbm_context_create(&ctx, NULL, NULL, NULL); EX_LBM_CHK(err); - if ((timer_id = lbm_schedule_timer(ctx, sample_timer_handler, NULL, NULL, 1000)) == -1) { - fprintf(stderr, "%s:%d, lbm error: '%s'\n", __FILE__, __LINE__, lbm_errmsg()); - exit(1); - } + /* Be careful! lbm_schedule_timer() returns >0 on success. */ + timer_id = lbm_schedule_timer(ctx, sample_timer_handler, NULL, NULL, 1000); + EX_LBM_CHK(timer_id); /* Now wait for callback to end the wait and close the application */ while (wait) @@ -59,11 +77,11 @@ int main(int argc, char **argv) /* Clean up */ err = lbm_context_delete(ctx); EX_LBM_CHK(err); - + #if defined(_MSC_VER) /* Windows-specific cleanup overhead */ WSACleanup(); #endif - return 0; -} + return 0; +} /* main */ diff --git a/schedule_timers/c/schedule_timers.sldoc.html b/schedule_timers/c/schedule_timers.sldoc.html index 2ed536f..0279265 100644 --- a/schedule_timers/c/schedule_timers.sldoc.html +++ b/schedule_timers/c/schedule_timers.sldoc.html @@ -24,11 +24,8 @@

Initializing the Context

Creating a Context

-00044      err = lbm_context_attr_create(&cattr);
-00045      EX_LBM_CHK(err);
-00046  
-00047      err = lbm_context_create(&ctx, cattr, NULL, NULL);
-00048      EX_LBM_CHK(err);
+00066      err = lbm_context_create(&ctx, NULL, NULL, NULL);
+00067      EX_LBM_CHK(err);
 
@@ -37,11 +34,14 @@

Creating a Callback

be executed on the UM context thread (at least for the purpose of this example it will be executed on the context thread.

-00030  int sample_timer_handler(lbm_context_t *ctx, const void *clientd)
-00031  {
-00032      printf("Timer executed. Set wait to 0 so application can cleanly exit\n");
-00033      wait = 0;
-00034  }
+00049  /* Timer callback function */
+00050  int sample_timer_handler(lbm_context_t *ctx, const void *clientd)
+00051  {
+00052      printf("Timer executed. Set wait to 0 so application can cleanly exit\n");
+00053      wait = 0;
+00054  
+00055      return 0;
+00056  }  /* sample_timer_handler */
 
@@ -52,10 +52,9 @@

Scheduling the Timer Callback

timer callback, for more information please see
-00050      if ((timer_id = lbm_schedule_timer(ctx, sample_timer_handler, NULL, NULL, 1000)) == -1) {
-00051          fprintf(stderr, "%s:%d, lbm error: '%s'\n", __FILE__, __LINE__, lbm_errmsg());
-00052          exit(1);
-00053      }
+00069      /* Be careful!  lbm_schedule_timer() returns >0 on success. */
+00070      timer_id = lbm_schedule_timer(ctx, sample_timer_handler, NULL, NULL, 1000);
+00071      EX_LBM_CHK(timer_id);
 
@@ -64,8 +63,8 @@

Wait for Timer

will be set to 0 and the application can cleanly exit by deleting the context.

-00056      while (wait)
-00057          SLEEP(1);
+00074      while (wait)
+00075          SLEEP(1);
 
@@ -75,13 +74,13 @@

Error Checking

print a message and exit the program:

-00019  #define EX_LBM_CHK(err) do { \
-00020      if ((err) < 0) { \
-00021          fprintf(stderr, "%s:%d, lbm error: '%s'\n", \
-00022          __FILE__, __LINE__, lbm_errmsg()); \
-00023          exit(1); \
-00024      }  \
-00025  } while (0)
+00038  #define EX_LBM_CHK(err) do { \
+00039      if ((err) < 0) { \
+00040          fprintf(stderr, "%s:%d, lbm error: '%s'\n", \
+00041          __FILE__, __LINE__, lbm_errmsg()); \
+00042          exit(1); \
+00043      }  \
+00044  } while (0)
 
@@ -97,20 +96,20 @@

Includes

Include files for this application. Notice the Windows specific include files - these are not necessary for Linux only applications

-00003  #include <stdio.h>
-00004  
-00005  #if defined(_MSC_VER)
-00006  /* Windows-only includes */
-00007  #include <winsock2.h>
-00008  #define SLEEP(s) Sleep((s)*1000)
-00009  #else
-00010  /* Unix-only includes */
-00011  #include <stdlib.h>
-00012  #include <unistd.h>
-00013  #define SLEEP(s) sleep(s)
-00014  #endif
-00015  
-00016  #include <lbm/lbm.h>
+00022  #include <stdio.h>
+00023  
+00024  #if defined(_MSC_VER)
+00025  /* Windows-only includes */
+00026  #include <winsock2.h>
+00027  #define SLEEP(s) Sleep((s)*1000)
+00028  #else
+00029  /* Unix-only includes */
+00030  #include <stdlib.h>
+00031  #include <unistd.h>
+00032  #define SLEEP(s) sleep(s)
+00033  #endif
+00034  
+00035  #include <lbm/lbm.h>
 
diff --git a/schedule_timers/c/schedule_timers_c.slsrc b/schedule_timers/c/schedule_timers_c.slsrc index 70014a2..6f785aa 100644 --- a/schedule_timers/c/schedule_timers_c.slsrc +++ b/schedule_timers/c/schedule_timers_c.slsrc @@ -1,4 +1,23 @@ -/* Code Disclaimer? */ +/* schedule_timers.c - see http://ultramessaging.github.io/UMExamples/schedule_timers/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ /* =semlit,block,includes=*/ #include @@ -32,36 +51,35 @@ int wait = 1; /* =semlit,endblock,int_wait=*/ -/* Timer callback function */ + /* =semlit,block,timer_cb=*/ +/* Timer callback function */ int sample_timer_handler(lbm_context_t *ctx, const void *clientd) { printf("Timer executed. Set wait to 0 so application can cleanly exit\n"); wait = 0; -} + + return 0; +} /* sample_timer_handler */ /* =semlit,endblock,timer_cb=*/ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - int err; /* Used for checking API return codes */ - int timer_id; /* Used to get timer id from schedule API */ + lbm_context_t *ctx; /* Context object */ + int timer_id; /* Used to get timer id from schedule API */ + int err; /* Initialize context atrributes and create context */ /* =semlit,block,ctx_create=*/ - err = lbm_context_attr_create(&cattr); - EX_LBM_CHK(err); - - err = lbm_context_create(&ctx, cattr, NULL, NULL); + err = lbm_context_create(&ctx, NULL, NULL, NULL); EX_LBM_CHK(err); /* =semlit,endblock,ctx_create=*/ /* =semlit,block,schedule=*/ - if ((timer_id = lbm_schedule_timer(ctx, sample_timer_handler, NULL, NULL, 1000)) == -1) { - fprintf(stderr, "%s:%d, lbm error: '%s'\n", __FILE__, __LINE__, lbm_errmsg()); - exit(1); - } + /* Be careful! lbm_schedule_timer() returns >0 on success. */ + timer_id = lbm_schedule_timer(ctx, sample_timer_handler, NULL, NULL, 1000); + EX_LBM_CHK(timer_id); /* =semlit,endblock,schedule=*/ /* Now wait for callback to end the wait and close the application */ @@ -73,11 +91,11 @@ int main(int argc, char **argv) /* Clean up */ err = lbm_context_delete(ctx); EX_LBM_CHK(err); - + #if defined(_MSC_VER) /* Windows-specific cleanup overhead */ WSACleanup(); #endif - return 0; -} + return 0; +} /* main */ diff --git a/schedule_timers/c/schedule_timers_c.slsrc.html b/schedule_timers/c/schedule_timers_c.slsrc.html index 992227c..8b152cf 100644 --- a/schedule_timers/c/schedule_timers_c.slsrc.html +++ b/schedule_timers/c/schedule_timers_c.slsrc.html @@ -18,61 +18,61 @@
00001 00002 -00003 -00004 -00005 -00006 -00007 -00008 -00009 -00010 -00011 -00012 -00013 -00014 -00015 -00016 +00003 +00004 +00005 +00006 +00007 +00008 +00009 +00010 +00011 +00012 +00013 +00014 +00015 +00016 00017 00018 -00019 -00020 -00021 -00022 -00023 -00024 -00025 -00026 -00027 -00028 -00029 -00030 -00031 -00032 -00033 -00034 -00035 +00019 +00020 +00021 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 00036 00037 -00038 -00039 -00040 -00041 -00042 -00043 -00044 -00045 -00046 -00047 -00048 -00049 -00050 -00051 -00052 -00053 -00054 -00055 -00056 -00057 +00038 +00039 +00040 +00041 +00042 +00043 +00044 +00045 +00046 +00047 +00048 +00049 +00050 +00051 +00052 +00053 +00054 +00055 +00056 +00057 00058 00059 00060 @@ -81,11 +81,48 @@ 00063 00064 00065 -00066 -00067 +00066 +00067 00068 -00069 - /* Code Disclaimer? */ +00069 +00070 +00071 +00072 +00073 +00074 +00075 +00076 +00077 +00078 +00079 +00080 +00081 +00082 +00083 +00084 +00085 +00086 +00087 + /* schedule_timers.c - see http://ultramessaging.github.io/UMExamples/schedule_timers/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include <stdio.h> @@ -113,31 +150,30 @@ int wait = 1; - /* Timer callback function */ - int sample_timer_handler(lbm_context_t *ctx, const void *clientd) + + /* Timer callback function */ + int sample_timer_handler(lbm_context_t *ctx, const void *clientd) { printf("Timer executed. Set wait to 0 so application can cleanly exit\n"); wait = 0; - } + + return 0; + } /* sample_timer_handler */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - int err; /* Used for checking API return codes */ - int timer_id; /* Used to get timer id from schedule API */ + lbm_context_t *ctx; /* Context object */ + int timer_id; /* Used to get timer id from schedule API */ + int err; /* Initialize context atrributes and create context */ - err = lbm_context_attr_create(&cattr); - EX_LBM_CHK(err); - - err = lbm_context_create(&ctx, cattr, NULL, NULL); + err = lbm_context_create(&ctx, NULL, NULL, NULL); EX_LBM_CHK(err); - if ((timer_id = lbm_schedule_timer(ctx, sample_timer_handler, NULL, NULL, 1000)) == -1) { - fprintf(stderr, "%s:%d, lbm error: '%s'\n", __FILE__, __LINE__, lbm_errmsg()); - exit(1); - } + /* Be careful! lbm_schedule_timer() returns >0 on success. */ + timer_id = lbm_schedule_timer(ctx, sample_timer_handler, NULL, NULL, 1000); + EX_LBM_CHK(timer_id); /* Now wait for callback to end the wait and close the application */ while (wait) @@ -146,14 +182,14 @@ /* Clean up */ err = lbm_context_delete(ctx); EX_LBM_CHK(err); - + #if defined(_MSC_VER) /* Windows-specific cleanup overhead */ WSACleanup(); #endif - return 0; - } + return 0; + } /* main */
diff --git a/seq_number_callback/c/seq_number_callback.c b/seq_number_callback/c/seq_number_callback.c index 04ada0a..a93e28a 100644 --- a/seq_number_callback/c/seq_number_callback.c +++ b/seq_number_callback/c/seq_number_callback.c @@ -1,4 +1,23 @@ -/* seq_number_callback.c - http://ultramessaging.github.io/UMExamples */ +/* seq_number_callback.c - see http://ultramessaging.github.io/UMExamples/seq_number_callback/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include @@ -17,18 +36,17 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) + /* Callback used to handle request message for receiver */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { - int err; - switch (msg->type) { case LBM_MSG_UME_REGISTRATION_SUCCESS_EX: { @@ -39,7 +57,7 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) break; } case LBM_MSG_UME_REGISTRATION_COMPLETE_EX: - { + { lbm_msg_ume_registration_complete_ex_t *reg = (lbm_msg_ume_registration_complete_ex_t *)(msg->data); printf("[%s][%s] UME registration complete. SQN %x. Flags %x ", msg->topic_name, msg->source, reg->sequence_number, reg->flags); @@ -51,31 +69,35 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) } return 0; -} +} /* rcv_handle_msg */ + int ume_rcv_seqnum_ex(lbm_ume_rcv_recovery_info_ex_func_info_t *info, void *clientd) { - printf("info->low_sequence_number[%d] is the starting sequence number as determined by registration consensus.\n",info->low_sequence_number); + printf("info->low_sequence_number[%d] is the starting sequence number as determined by registration consensus.\n", info->low_sequence_number); printf("info->high_sequence_number[%d] is the highest sequence number available in the persisted stores.\n", info->high_sequence_number); printf("info->low_rxreq_max_sequence_number[%d] is the lowest sequence number to be requested.\n", info->low_rxreq_max_sequence_number); - - /* Overwrite this variable to set a new starting sequence number. If the message is available in the store, then the receiver will - retransmission starting at this sequence number leading up to the high sequence number. If the new starting sequence number has - yet to be published, the receiver will discard new messages until this sequence number is sent */ + + /* Overwrite this variable to set a new starting sequence number. + * If the message is available in the store, then the receiver will + * retransmission starting at this sequence number leading up to the + * high sequence number. If the new starting sequence number has + * yet to be published, the receiver will discard new messages until + * this sequence number is sent */ info->low_sequence_number = 100; return 0; -} +} /* ume_rcv_seqnum_ex */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ - lbm_topic_t *rtopic; /* Receiver Topic object */ - lbm_rcv_topic_attr_t * rattr; /* Receiver attribute object */ + lbm_context_t *ctx; /* Context object */ + lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ + lbm_topic_t *rtopic; /* Receiver Topic object */ + lbm_rcv_topic_attr_t * rattr; /* Receiver attribute object */ lbm_ume_rcv_recovery_info_ex_func_t cb; /* Sequence number info callback function */ - int err; /* Used for checking API return codes */ + int err; #if defined(_WIN32) /* windows-specific code */ @@ -102,7 +124,7 @@ int main(int argc, char **argv) EX_LBM_CHK(err); err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", rattr); - EX_LBM_CHK(err); + EX_LBM_CHK(err); err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); EX_LBM_CHK(err); @@ -119,5 +141,5 @@ int main(int argc, char **argv) /* Windows-specific cleanup overhead */ WSACleanup(); #endif - return 0; -} /* main */ + return 0; +} /* main */ diff --git a/seq_number_callback/c/seq_number_callback.sldoc.html b/seq_number_callback/c/seq_number_callback.sldoc.html index 3fa6fa8..d59108d 100644 --- a/seq_number_callback/c/seq_number_callback.sldoc.html +++ b/seq_number_callback/c/seq_number_callback.sldoc.html @@ -66,8 +66,8 @@

Context Create

Standard context creation.

-00092      err = lbm_context_create(&ctx, NULL, NULL, NULL);
-00093      EX_LBM_CHK(err);
+00114      err = lbm_context_create(&ctx, NULL, NULL, NULL);
+00115      EX_LBM_CHK(err);
 
@@ -75,7 +75,7 @@

Set Sequence Number Callback Attrribute

Setting the sequence number info callback requires a callback object to be defined:

-00077      lbm_ume_rcv_recovery_info_ex_func_t cb; /* Sequence number info callback function */
+00099      lbm_ume_rcv_recovery_info_ex_func_t cb; /* Sequence number info callback function */
 
@@ -92,10 +92,10 @@

Set Sequence Number Callback Attrribute

like so:

-00099      cb.func = ume_rcv_seqnum_ex;
-00100      cb.clientd = NULL;
-00101      err = lbm_rcv_topic_attr_setopt(rattr, "ume_recovery_sequence_number_info_function", &cb, sizeof(cb));
-00102      EX_LBM_CHK(err);
+00121      cb.func = ume_rcv_seqnum_ex;
+00122      cb.clientd = NULL;
+00123      err = lbm_rcv_topic_attr_setopt(rattr, "ume_recovery_sequence_number_info_function", &cb, sizeof(cb));
+00124      EX_LBM_CHK(err);
 
@@ -107,19 +107,22 @@

The Sequence Number Callback

receiver is starting at the correct sequence number.

-00056  int ume_rcv_seqnum_ex(lbm_ume_rcv_recovery_info_ex_func_info_t *info, void *clientd)
-00057  {
-00058      printf("info->low_sequence_number[%d] is the starting sequence number as determined by registration consensus.\n",info->low_sequence_number);
-00059      printf("info->high_sequence_number[%d] is the highest sequence number available in the persisted stores.\n", info->high_sequence_number);
-00060      printf("info->low_rxreq_max_sequence_number[%d] is the lowest sequence number to be requested.\n", info->low_rxreq_max_sequence_number);
-00061          
-00062      /* Overwrite this variable to set a new starting sequence number. If the message is available in the store, then the receiver will 
-00063         retransmission starting at this sequence number leading up to the high sequence number. If the new starting sequence number has
-00064         yet to be published, the receiver will discard new messages until this sequence number is sent */
-00065      info->low_sequence_number = 100;
-00066  
-00067      return 0;
-00068  }
+00075  int ume_rcv_seqnum_ex(lbm_ume_rcv_recovery_info_ex_func_info_t *info, void *clientd)
+00076  {
+00077      printf("info->low_sequence_number[%d] is the starting sequence number as determined by registration consensus.\n", info->low_sequence_number);
+00078      printf("info->high_sequence_number[%d] is the highest sequence number available in the persisted stores.\n", info->high_sequence_number);
+00079      printf("info->low_rxreq_max_sequence_number[%d] is the lowest sequence number to be requested.\n", info->low_rxreq_max_sequence_number);
+00080  
+00081      /* Overwrite this variable to set a new starting sequence number.
+00082       * If the message is available in the store, then the receiver will 
+00083       * retransmission starting at this sequence number leading up to the
+00084       * high sequence number. If the new starting sequence number has
+00085       * yet to be published, the receiver will discard new messages until
+00086       * this sequence number is sent */
+00087      info->low_sequence_number = 100;
+00088  
+00089      return 0;
+00090  }  /* ume_rcv_seqnum_ex */
 
@@ -136,33 +139,32 @@

Handle Message Callback

for debugging any kind of issues with related to message recovery, connectivity issues, and even performance.

-00028  int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd)
-00029  {
-00030      int err;
-00031  
-00032      switch (msg->type) {
-00033          case LBM_MSG_UME_REGISTRATION_SUCCESS_EX:
-00034          {
-00035              lbm_msg_ume_registration_ex_t *reg = (lbm_msg_ume_registration_ex_t *)(msg->data);
-00036              printf("[%s][%s] store %u: %s UME registration successful. Sequence Number is %d.\n",
-00037                  msg->topic_name, msg->source, reg->store_index, reg->store,reg->sequence_number);
-00038  
-00039              break;
-00040          }
-00041          case LBM_MSG_UME_REGISTRATION_COMPLETE_EX:
-00042                  {
-00043              lbm_msg_ume_registration_complete_ex_t *reg = (lbm_msg_ume_registration_complete_ex_t *)(msg->data);
-00044              printf("[%s][%s] UME registration complete. SQN %x. Flags %x ",
-00045                  msg->topic_name, msg->source, reg->sequence_number, reg->flags);
-00046              break;
-00047          }
-00048          default:
-00049              printf("Other event, type=%x\n", msg->type);
-00050              break;
-00051      }
-00052  
-00053      return 0;
-00054  }
+00047  /* Callback used to handle request message for receiver */
+00048  int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd)
+00049  {
+00050      switch (msg->type) {
+00051          case LBM_MSG_UME_REGISTRATION_SUCCESS_EX:
+00052          {
+00053              lbm_msg_ume_registration_ex_t *reg = (lbm_msg_ume_registration_ex_t *)(msg->data);
+00054              printf("[%s][%s] store %u: %s UME registration successful. Sequence Number is %d.\n",
+00055                  msg->topic_name, msg->source, reg->store_index, reg->store,reg->sequence_number);
+00056  
+00057              break;
+00058          }
+00059          case LBM_MSG_UME_REGISTRATION_COMPLETE_EX:
+00060          {
+00061              lbm_msg_ume_registration_complete_ex_t *reg = (lbm_msg_ume_registration_complete_ex_t *)(msg->data);
+00062              printf("[%s][%s] UME registration complete. SQN %x. Flags %x ",
+00063                  msg->topic_name, msg->source, reg->sequence_number, reg->flags);
+00064              break;
+00065          }
+00066          default:
+00067              printf("Other event, type=%x\n", msg->type);
+00068              break;
+00069      }
+00070  
+00071      return 0;
+00072  }  /* rcv_handle_msg */
 
@@ -171,20 +173,20 @@

Includes

are not necessary for Linux only applications

-00003  #include <stdio.h>
-00004  
-00005  #if defined(_MSC_VER)
-00006  /* Windows-only includes */
-00007  #include <winsock2.h>
-00008  #define SLEEP(s) Sleep((s)*1000)
-00009  #else
-00010  /* Unix-only includes */
-00011  #include <stdlib.h>
-00012  #include <unistd.h>
-00013  #define SLEEP(s) sleep(s)
-00014  #endif
-00015  
-00016  #include <lbm/lbm.h>
+00022  #include <stdio.h>
+00023  
+00024  #if defined(_MSC_VER)
+00025  /* Windows-only includes */
+00026  #include <winsock2.h>
+00027  #define SLEEP(s) Sleep((s)*1000)
+00028  #else
+00029  /* Unix-only includes */
+00030  #include <stdlib.h>
+00031  #include <unistd.h>
+00032  #define SLEEP(s) sleep(s)
+00033  #endif
+00034  
+00035  #include <lbm/lbm.h>
 
@@ -192,16 +194,16 @@

Windows Only

Windows applications must initialize the Winsock library to utilize sockets.

-00080  #if defined(_WIN32)
-00081      /* windows-specific code */
-00082      WSADATA wsadata;
-00083      int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata);
-00084      if (wsStat != 0)
-00085      {
-00086          printf("line %d: wsStat=%d\n",__LINE__,wsStat);
-00087          exit(1);
-00088      }
-00089  #endif
+00102  #if defined(_WIN32)
+00103      /* windows-specific code */
+00104      WSADATA wsadata;
+00105      int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata);
+00106      if (wsStat != 0)
+00107      {
+00108          printf("line %d: wsStat=%d\n",__LINE__,wsStat);
+00109          exit(1);
+00110      }
+00111  #endif
 
diff --git a/seq_number_callback/c/seq_number_callback_c.slsrc b/seq_number_callback/c/seq_number_callback_c.slsrc index 64c9a46..8d308ee 100644 --- a/seq_number_callback/c/seq_number_callback_c.slsrc +++ b/seq_number_callback/c/seq_number_callback_c.slsrc @@ -1,4 +1,23 @@ -/* seq_number_callback.c - http://ultramessaging.github.io/UMExamples */ +/* seq_number_callback.c - see http://ultramessaging.github.io/UMExamples/seq_number_callback/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ /* =semlit,block,includes=*/ #include @@ -19,19 +38,18 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) -/* Callback used to handle request message for receiver */ + /* =semlit,block,handle_msg=*/ +/* Callback used to handle request message for receiver */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { - int err; - switch (msg->type) { case LBM_MSG_UME_REGISTRATION_SUCCESS_EX: { @@ -42,7 +60,7 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) break; } case LBM_MSG_UME_REGISTRATION_COMPLETE_EX: - { + { lbm_msg_ume_registration_complete_ex_t *reg = (lbm_msg_ume_registration_complete_ex_t *)(msg->data); printf("[%s][%s] UME registration complete. SQN %x. Flags %x ", msg->topic_name, msg->source, reg->sequence_number, reg->flags); @@ -54,36 +72,40 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) } return 0; -} +} /* rcv_handle_msg */ /* =semlit,endblock,handle_msg=*/ + /* =semlit,block,cb=*/ int ume_rcv_seqnum_ex(lbm_ume_rcv_recovery_info_ex_func_info_t *info, void *clientd) { - printf("info->low_sequence_number[%d] is the starting sequence number as determined by registration consensus.\n",info->low_sequence_number); + printf("info->low_sequence_number[%d] is the starting sequence number as determined by registration consensus.\n", info->low_sequence_number); printf("info->high_sequence_number[%d] is the highest sequence number available in the persisted stores.\n", info->high_sequence_number); printf("info->low_rxreq_max_sequence_number[%d] is the lowest sequence number to be requested.\n", info->low_rxreq_max_sequence_number); - - /* Overwrite this variable to set a new starting sequence number. If the message is available in the store, then the receiver will - retransmission starting at this sequence number leading up to the high sequence number. If the new starting sequence number has - yet to be published, the receiver will discard new messages until this sequence number is sent */ + + /* Overwrite this variable to set a new starting sequence number. + * If the message is available in the store, then the receiver will + * retransmission starting at this sequence number leading up to the + * high sequence number. If the new starting sequence number has + * yet to be published, the receiver will discard new messages until + * this sequence number is sent */ info->low_sequence_number = 100; return 0; -} +} /* ume_rcv_seqnum_ex */ /* =semlit,endblock,cb=*/ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ - lbm_topic_t *rtopic; /* Receiver Topic object */ - lbm_rcv_topic_attr_t * rattr; /* Receiver attribute object */ + lbm_context_t *ctx; /* Context object */ + lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ + lbm_topic_t *rtopic; /* Receiver Topic object */ + lbm_rcv_topic_attr_t * rattr; /* Receiver attribute object */ /* =semlit,block,cb_var=*/ lbm_ume_rcv_recovery_info_ex_func_t cb; /* Sequence number info callback function */ /* =semlit,endblock,cb_var=*/ - int err; /* Used for checking API return codes */ + int err; /* =semlit,block,windows=*/ #if defined(_WIN32) @@ -116,7 +138,7 @@ int main(int argc, char **argv) /* =semlit,endblock,cb_attr=*/ err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", rattr); - EX_LBM_CHK(err); + EX_LBM_CHK(err); err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); EX_LBM_CHK(err); @@ -133,5 +155,5 @@ int main(int argc, char **argv) /* Windows-specific cleanup overhead */ WSACleanup(); #endif - return 0; -} /* main */ + return 0; +} /* main */ diff --git a/seq_number_callback/c/seq_number_callback_c.slsrc.html b/seq_number_callback/c/seq_number_callback_c.slsrc.html index e508a72..f784654 100644 --- a/seq_number_callback/c/seq_number_callback_c.slsrc.html +++ b/seq_number_callback/c/seq_number_callback_c.slsrc.html @@ -18,50 +18,50 @@
00001 00002 -00003 -00004 -00005 -00006 -00007 -00008 -00009 -00010 -00011 -00012 -00013 -00014 -00015 -00016 +00003 +00004 +00005 +00006 +00007 +00008 +00009 +00010 +00011 +00012 +00013 +00014 +00015 +00016 00017 00018 00019 00020 00021 -00022 -00023 -00024 -00025 -00026 -00027 -00028 -00029 -00030 -00031 -00032 -00033 -00034 -00035 -00036 -00037 -00038 -00039 -00040 -00041 -00042 -00043 -00044 -00045 -00046 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 +00036 +00037 +00038 +00039 +00040 +00041 +00042 +00043 +00044 +00045 +00046 00047 00048 00049 @@ -70,76 +70,117 @@ 00052 00053 00054 -00055 -00056 -00057 -00058 -00059 -00060 -00061 -00062 -00063 -00064 -00065 -00066 -00067 -00068 -00069 -00070 -00071 -00072 +00055 +00056 +00057 +00058 +00059 +00060 +00061 +00062 +00063 +00064 +00065 +00066 +00067 +00068 +00069 +00070 +00071 +00072 00073 00074 -00075 -00076 -00077 -00078 -00079 -00080 -00081 -00082 -00083 -00084 -00085 -00086 -00087 -00088 -00089 -00090 +00075 +00076 +00077 +00078 +00079 +00080 +00081 +00082 +00083 +00084 +00085 +00086 +00087 +00088 +00089 +00090 00091 -00092 -00093 +00092 +00093 00094 00095 00096 00097 00098 -00099 -00100 -00101 -00102 -00103 -00104 -00105 -00106 -00107 -00108 -00109 -00110 -00111 +00099 +00100 +00101 +00102 +00103 +00104 +00105 +00106 +00107 +00108 +00109 +00110 +00111 00112 00113 -00114 -00115 +00114 +00115 00116 00117 00118 00119 00120 -00121 -00122 -00123 - /* seq_number_callback.c - http://ultramessaging.github.io/UMExamples */ +00121 +00122 +00123 +00124 +00125 +00126 +00127 +00128 +00129 +00130 +00131 +00132 +00133 +00134 +00135 +00136 +00137 +00138 +00139 +00140 +00141 +00142 +00143 +00144 +00145 + /* seq_number_callback.c - see http://ultramessaging.github.io/UMExamples/seq_number_callback/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include <stdio.h> @@ -158,18 +199,17 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) - /* Callback used to handle request message for receiver */ - int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) - { - int err; + /* Callback used to handle request message for receiver */ + int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) + { switch (msg->type) { case LBM_MSG_UME_REGISTRATION_SUCCESS_EX: { @@ -180,7 +220,7 @@ break; } case LBM_MSG_UME_REGISTRATION_COMPLETE_EX: - { + { lbm_msg_ume_registration_complete_ex_t *reg = (lbm_msg_ume_registration_complete_ex_t *)(msg->data); printf("[%s][%s] UME registration complete. SQN %x. Flags %x ", msg->topic_name, msg->source, reg->sequence_number, reg->flags); @@ -192,31 +232,35 @@ } return 0; - } + } /* rcv_handle_msg */ + int ume_rcv_seqnum_ex(lbm_ume_rcv_recovery_info_ex_func_info_t *info, void *clientd) { - printf("info->low_sequence_number[%d] is the starting sequence number as determined by registration consensus.\n",info->low_sequence_number); + printf("info->low_sequence_number[%d] is the starting sequence number as determined by registration consensus.\n", info->low_sequence_number); printf("info->high_sequence_number[%d] is the highest sequence number available in the persisted stores.\n", info->high_sequence_number); printf("info->low_rxreq_max_sequence_number[%d] is the lowest sequence number to be requested.\n", info->low_rxreq_max_sequence_number); - - /* Overwrite this variable to set a new starting sequence number. If the message is available in the store, then the receiver will - retransmission starting at this sequence number leading up to the high sequence number. If the new starting sequence number has - yet to be published, the receiver will discard new messages until this sequence number is sent */ + + /* Overwrite this variable to set a new starting sequence number. + * If the message is available in the store, then the receiver will + * retransmission starting at this sequence number leading up to the + * high sequence number. If the new starting sequence number has + * yet to be published, the receiver will discard new messages until + * this sequence number is sent */ info->low_sequence_number = 100; return 0; - } + } /* ume_rcv_seqnum_ex */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ - lbm_topic_t *rtopic; /* Receiver Topic object */ - lbm_rcv_topic_attr_t * rattr; /* Receiver attribute object */ + lbm_context_t *ctx; /* Context object */ + lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ + lbm_topic_t *rtopic; /* Receiver Topic object */ + lbm_rcv_topic_attr_t * rattr; /* Receiver attribute object */ lbm_ume_rcv_recovery_info_ex_func_t cb; /* Sequence number info callback function */ - int err; /* Used for checking API return codes */ + int err; #if defined(_WIN32) /* windows-specific code */ @@ -243,7 +287,7 @@ EX_LBM_CHK(err); err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", rattr); - EX_LBM_CHK(err); + EX_LBM_CHK(err); err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); EX_LBM_CHK(err); @@ -260,8 +304,8 @@ /* Windows-specific cleanup overhead */ WSACleanup(); #endif - return 0; - } /* main */ + return 0; + } /* main */
diff --git a/sequential_mode/c/sequential_mode.c b/sequential_mode/c/sequential_mode.c index 3ba8de6..0fd880c 100644 --- a/sequential_mode/c/sequential_mode.c +++ b/sequential_mode/c/sequential_mode.c @@ -1,6 +1,26 @@ -/* Code Disclaimer? */ +/* sequential_mode.c - see http://ultramessaging.github.io/UMExamples/sequential_mode/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include +#include #if defined(_MSC_VER) /* Windows-only includes */ @@ -15,6 +35,15 @@ #include +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ +} while (0) + #if defined(_WIN32) DWORD WINAPI seq_thread(void *arg) @@ -23,59 +52,47 @@ void *seq_thread(void *arg) #endif /* _WIN32 */ { lbm_context_t *ctx = (lbm_context_t *) arg; + int err; while (1) { - if (lbm_context_process_events(ctx, 500) == -1) - { - printf("ERROR processing context events: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_context_process_events(ctx, 500); + EX_LBM_CHK(err); } -} +} /* seq_thread */ + int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_context_attr_t * cattr; /* pointer to context attribute object */ - int err; /* return status of lbm functions (true=error) */ + int err; #if defined(_WIN32) - HANDLE wthrdh; + HANDLE wthrdh; #else - pthread_t pthids; + pthread_t pthids; #endif /* _WIN32 */ - #if defined(_MSC_VER) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } -#endif - - if (lbm_context_attr_create(&cattr) != 0) + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); + printf("line %d: wsStat=%d\n",__LINE__,wsStat); exit(1); } +#endif + + err = lbm_context_attr_create(&cattr); + EX_LBM_CHK(err); /* Setting the resolver address using the string method */ - if (lbm_context_attr_str_setopt(cattr, "operational_mode", "sequential") != 0) - { - fprintf(stderr, "lbm_context_attr_str_setopt:operational_mode: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_context_attr_str_setopt(cattr, "operational_mode", "sequential"); + EX_LBM_CHK(err); - err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + err = lbm_context_create(&ctx, cattr, NULL, NULL); + EX_LBM_CHK(err); #if defined(_WIN32) if ((wthrdh = CreateThread(NULL, 0, seq_thread, ctx, 0, NULL)) == NULL) { @@ -89,8 +106,8 @@ int main(int argc, char **argv) } #endif /* _WIN32 */ - /* Wait forever */ + /* Wait forever (or until control-c). */ while (1) { } - return 0; -} + return 0; +} /* main */ diff --git a/sequential_mode/c/sequential_mode.sldoc.html b/sequential_mode/c/sequential_mode.sldoc.html index 11d8657..f6a780c 100644 --- a/sequential_mode/c/sequential_mode.sldoc.html +++ b/sequential_mode/c/sequential_mode.sldoc.html @@ -53,25 +53,15 @@

Initialize and Create Context

Setting the operational_mode is required to take advantage of the sequential mode of operation.

-00060      if (lbm_context_attr_create(&cattr) != 0)
-00061      {
-00062          fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg());
-00063          exit(1);
-00064      }
-00065  
-00066      /* Setting the resolver address using the string method */
-00067      if (lbm_context_attr_str_setopt(cattr, "operational_mode", "sequential") != 0) 
-00068      {
-00069          fprintf(stderr, "lbm_context_attr_str_setopt:operational_mode: %s\n", lbm_errmsg());
-00070          exit(1);
-00071      }
-00072  
-00073          err = lbm_context_create(&ctx, cattr, NULL, NULL);
-00074          if (err)
-00075          {
-00076                  printf("line %d: %s\n", __LINE__, lbm_errmsg());
-00077                  exit(1);
-00078          }
+00087      err = lbm_context_attr_create(&cattr);
+00088      EX_LBM_CHK(err);
+00089  
+00090      /* Setting the resolver address using the string method */
+00091      err = lbm_context_attr_str_setopt(cattr, "operational_mode", "sequential");
+00092      EX_LBM_CHK(err);
+00093  
+00094      err = lbm_context_create(&ctx, cattr, NULL, NULL);
+00095      EX_LBM_CHK(err);
 
@@ -81,17 +71,17 @@

Spawn a New Thread

for message delivery. Notice the thread function is "seq_thread", which will be explained in the next block.

-00080  #if defined(_WIN32)
-00081      if ((wthrdh = CreateThread(NULL, 0, seq_thread, ctx, 0, NULL)) == NULL) {
-00082          fprintf(stderr, "could not create thread\n");
-00083          exit(1);
-00084      }
-00085  #else
-00086      if (pthread_create(&pthids, NULL, seq_thread, ctx) != 0) {
-00087          fprintf(stderr, "could not spawn thread\n");
-00088          exit(1);
-00089      }
-00090  #endif /* _WIN32 */
+00097  #if defined(_WIN32)
+00098      if ((wthrdh = CreateThread(NULL, 0, seq_thread, ctx, 0, NULL)) == NULL) {
+00099          fprintf(stderr, "could not create thread\n");
+00100          exit(1);
+00101      }
+00102  #else
+00103      if (pthread_create(&pthids, NULL, seq_thread, ctx) != 0) {
+00104          fprintf(stderr, "could not spawn thread\n");
+00105          exit(1);
+00106      }
+00107  #endif /* _WIN32 */
 
@@ -100,23 +90,21 @@

Sequential Context Thread

calls the process events API, ensures there are no errors, and repeats.
-00019  #if defined(_WIN32)
-00020  DWORD WINAPI seq_thread(void *arg)
-00021  #else
-00022  void *seq_thread(void *arg)
-00023  #endif /* _WIN32 */
-00024  {
-00025      lbm_context_t *ctx = (lbm_context_t *) arg;
-00026  
-00027      while (1)
-00028      {
-00029          if (lbm_context_process_events(ctx, 500) == -1)
-00030          {
-00031              printf("ERROR processing context events: %s\n", lbm_errmsg());
-00032              exit(1);
-00033          }
-00034      }
-00035  }
+00048  #if defined(_WIN32)
+00049  DWORD WINAPI seq_thread(void *arg)
+00050  #else
+00051  void *seq_thread(void *arg)
+00052  #endif /* _WIN32 */
+00053  {
+00054      lbm_context_t *ctx = (lbm_context_t *) arg;
+00055      int err;
+00056  
+00057      while (1)
+00058      {
+00059          err = lbm_context_process_events(ctx, 500);
+00060          EX_LBM_CHK(err);
+00061      }
+00062  }  /* seq_thread */
 
@@ -125,20 +113,21 @@

Includes

are not necessary for Linux only applications

-00003  #include <stdio.h>
-00004  
-00005  #if defined(_MSC_VER)
-00006  /* Windows-only includes */
-00007  #include <winsock2.h>
-00008  #define SLEEP(s) Sleep((s)*1000)
-00009  #else
-00010  /* Unix-only includes */
-00011  #include <stdlib.h>
-00012  #include <unistd.h>
-00013  #define SLEEP(s) sleep(s)
-00014  #endif
-00015  
-00016  #include <lbm/lbm.h>
+00022  #include <stdio.h>
+00023  #include <pthread.h>
+00024  
+00025  #if defined(_MSC_VER)
+00026  /* Windows-only includes */
+00027  #include <winsock2.h>
+00028  #define SLEEP(s) Sleep((s)*1000)
+00029  #else
+00030  /* Unix-only includes */
+00031  #include <stdlib.h>
+00032  #include <unistd.h>
+00033  #define SLEEP(s) sleep(s)
+00034  #endif
+00035  
+00036  #include <lbm/lbm.h>
 
@@ -146,16 +135,16 @@

Windows Only

Windows applications must initialize the Winsock library to utilize sockets.

-00049  #if defined(_MSC_VER)
-00050          /* windows-specific code */
-00051          WSADATA wsadata;
-00052          int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata);
-00053          if (wsStat != 0)
-00054          {
-00055                  printf("line %d: wsStat=%d\n",__LINE__,wsStat);
-00056                  exit(1);
-00057          }
-00058  #endif
+00076  #if defined(_MSC_VER)
+00077      /* windows-specific code */
+00078      WSADATA wsadata;
+00079      int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata);
+00080      if (wsStat != 0)
+00081      {
+00082          printf("line %d: wsStat=%d\n",__LINE__,wsStat);
+00083          exit(1);
+00084      }
+00085  #endif
 
diff --git a/sequential_mode/c/sequential_mode_c.slsrc b/sequential_mode/c/sequential_mode_c.slsrc index c052279..91b3c95 100644 --- a/sequential_mode/c/sequential_mode_c.slsrc +++ b/sequential_mode/c/sequential_mode_c.slsrc @@ -1,7 +1,27 @@ -/* Code Disclaimer? */ +/* sequential_mode.c - see http://ultramessaging.github.io/UMExamples/sequential_mode/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ /* =semlit,block,includes=*/ #include +#include #if defined(_MSC_VER) /* Windows-only includes */ @@ -17,6 +37,15 @@ #include /* =semlit,endblock,includes=*/ +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ +} while (0) + /* =semlit,block,context_thread=*/ #if defined(_WIN32) @@ -26,64 +55,52 @@ void *seq_thread(void *arg) #endif /* _WIN32 */ { lbm_context_t *ctx = (lbm_context_t *) arg; + int err; while (1) { - if (lbm_context_process_events(ctx, 500) == -1) - { - printf("ERROR processing context events: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_context_process_events(ctx, 500); + EX_LBM_CHK(err); } -} +} /* seq_thread */ /* =semlit,endblock,context_thread=*/ + int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_context_attr_t * cattr; /* pointer to context attribute object */ - int err; /* return status of lbm functions (true=error) */ + int err; #if defined(_WIN32) - HANDLE wthrdh; + HANDLE wthrdh; #else - pthread_t pthids; + pthread_t pthids; #endif /* _WIN32 */ - - /* =semlit,block,windows=*/ + /* =semlit,block,windows=*/ #if defined(_MSC_VER) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } -#endif - /* =semlit,endblock,windows=*/ - - /* =semlit,block,create= */ - if (lbm_context_attr_create(&cattr) != 0) + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); + printf("line %d: wsStat=%d\n",__LINE__,wsStat); exit(1); } +#endif + /* =semlit,endblock,windows=*/ + + /* =semlit,block,create= */ + err = lbm_context_attr_create(&cattr); + EX_LBM_CHK(err); /* Setting the resolver address using the string method */ - if (lbm_context_attr_str_setopt(cattr, "operational_mode", "sequential") != 0) - { - fprintf(stderr, "lbm_context_attr_str_setopt:operational_mode: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_context_attr_str_setopt(cattr, "operational_mode", "sequential"); + EX_LBM_CHK(err); - err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - /* =semlit,endblock,create=*/ + err = lbm_context_create(&ctx, cattr, NULL, NULL); + EX_LBM_CHK(err); + /* =semlit,endblock,create=*/ /* =semlit,block,spawn_thread=*/ #if defined(_WIN32) @@ -99,8 +116,8 @@ int main(int argc, char **argv) #endif /* _WIN32 */ /* =semlit,endblock,spawn_thread=*/ - /* Wait forever */ + /* Wait forever (or until control-c). */ while (1) { } - return 0; -} + return 0; +} /* main */ diff --git a/sequential_mode/c/sequential_mode_c.slsrc.html b/sequential_mode/c/sequential_mode_c.slsrc.html index bd3cec9..7418105 100644 --- a/sequential_mode/c/sequential_mode_c.slsrc.html +++ b/sequential_mode/c/sequential_mode_c.slsrc.html @@ -18,40 +18,40 @@
00001 00002 -00003 -00004 -00005 -00006 -00007 -00008 -00009 -00010 -00011 -00012 -00013 -00014 -00015 -00016 +00003 +00004 +00005 +00006 +00007 +00008 +00009 +00010 +00011 +00012 +00013 +00014 +00015 +00016 00017 00018 -00019 -00020 -00021 -00022 -00023 -00024 -00025 -00026 -00027 -00028 -00029 -00030 -00031 -00032 -00033 -00034 -00035 -00036 +00019 +00020 +00021 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 +00036 00037 00038 00039 @@ -63,58 +63,95 @@ 00045 00046 00047 -00048 -00049 -00050 -00051 -00052 -00053 -00054 -00055 -00056 -00057 -00058 -00059 -00060 -00061 -00062 -00063 -00064 -00065 -00066 -00067 -00068 -00069 -00070 -00071 -00072 -00073 -00074 -00075 -00076 -00077 -00078 -00079 -00080 -00081 -00082 -00083 -00084 -00085 -00086 -00087 -00088 -00089 -00090 -00091 -00092 -00093 -00094 -00095 +00048 +00049 +00050 +00051 +00052 +00053 +00054 +00055 +00056 +00057 +00058 +00059 +00060 +00061 +00062 +00063 +00064 +00065 +00066 +00067 +00068 +00069 +00070 +00071 +00072 +00073 +00074 +00075 +00076 +00077 +00078 +00079 +00080 +00081 +00082 +00083 +00084 +00085 +00086 +00087 +00088 +00089 +00090 +00091 +00092 +00093 +00094 +00095 00096 - /* Code Disclaimer? */ +00097 +00098 +00099 +00100 +00101 +00102 +00103 +00104 +00105 +00106 +00107 +00108 +00109 +00110 +00111 +00112 +00113 + /* sequential_mode.c - see http://ultramessaging.github.io/UMExamples/sequential_mode/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include <stdio.h> + #include <pthread.h> #if defined(_MSC_VER) /* Windows-only includes */ @@ -129,6 +166,15 @@ #include <lbm/lbm.h> + /* Example error checking macro. Include after each UM call. */ + #define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ + } while (0) + #if defined(_WIN32) DWORD WINAPI seq_thread(void *arg) @@ -137,59 +183,47 @@ #endif /* _WIN32 */ { lbm_context_t *ctx = (lbm_context_t *) arg; + int err; while (1) { - if (lbm_context_process_events(ctx, 500) == -1) - { - printf("ERROR processing context events: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_context_process_events(ctx, 500); + EX_LBM_CHK(err); } - } + } /* seq_thread */ + int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ lbm_context_attr_t * cattr; /* pointer to context attribute object */ - int err; /* return status of lbm functions (true=error) */ + int err; #if defined(_WIN32) - HANDLE wthrdh; + HANDLE wthrdh; #else - pthread_t pthids; + pthread_t pthids; #endif /* _WIN32 */ - #if defined(_MSC_VER) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } - #endif - - if (lbm_context_attr_create(&cattr) != 0) + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); + printf("line %d: wsStat=%d\n",__LINE__,wsStat); exit(1); } + #endif + + err = lbm_context_attr_create(&cattr); + EX_LBM_CHK(err); /* Setting the resolver address using the string method */ - if (lbm_context_attr_str_setopt(cattr, "operational_mode", "sequential") != 0) - { - fprintf(stderr, "lbm_context_attr_str_setopt:operational_mode: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_context_attr_str_setopt(cattr, "operational_mode", "sequential"); + EX_LBM_CHK(err); - err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + err = lbm_context_create(&ctx, cattr, NULL, NULL); + EX_LBM_CHK(err); #if defined(_WIN32) if ((wthrdh = CreateThread(NULL, 0, seq_thread, ctx, 0, NULL)) == NULL) { @@ -203,11 +237,11 @@ } #endif /* _WIN32 */ - /* Wait forever */ + /* Wait forever (or until control-c). */ while (1) { } - return 0; - } + return 0; + } /* main */
diff --git a/setting_attributes/c/setting_attributes.c b/setting_attributes/c/setting_attributes.c index 6d4ecf1..2793c4f 100644 --- a/setting_attributes/c/setting_attributes.c +++ b/setting_attributes/c/setting_attributes.c @@ -1,4 +1,23 @@ -/* Example on setting Ultra Messaging attributes */ +/* setting_attributes.c - see http://ultramessaging.github.io/UMExamples/setting_attributes/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include @@ -15,145 +34,116 @@ #include +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ +} while (0) + + int main(int argc, char **argv) { - lbm_context_t *ctx; /* pointer to context object */ - lbm_topic_t *topic_1; /* pointer to topic object */ - lbm_topic_t *topic_2; /* pointer to topic object */ - lbm_src_t *src_1; /* pointer to source object */ - lbm_src_t *src_2; /* pointer to source object */ - lbm_src_topic_attr_t *tattr_1; /* pointer to source attribute object */ - lbm_src_topic_attr_t *tattr_2; /* pointer to source attribute object */ - lbm_context_attr_t * cattr; /* pointer to context attribute object */ - lbm_uint16_t res_port; /* Int to set resolver port */ - lbm_uint16_t des_port; /* Int to set lbtrm destination port */ - int err; /* return status of lbm functions (true=error) */ + lbm_context_t *ctx; /* pointer to context object */ + lbm_topic_t *topic_1; /* pointer to topic object */ + lbm_topic_t *topic_2; /* pointer to topic object */ + lbm_src_t *src_1; /* pointer to source object */ + lbm_src_t *src_2; /* pointer to source object */ + lbm_src_topic_attr_t *tattr_1; /* pointer to source attribute object */ + lbm_src_topic_attr_t *tattr_2; /* pointer to source attribute object */ + lbm_context_attr_t * cattr; /* pointer to context attribute object */ + lbm_uint16_t res_port; /* Int to set resolver port */ + lbm_uint16_t des_port; /* Int to set lbtrm destination port */ + int err; #if defined(_MSC_VER) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + exit(1); + } #endif - /* Initialize the defaults for the context attribute object */ - if (lbm_context_attr_create(&cattr) != 0) - { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); - exit(1); - } - - /* Setting the resolver address using the string method */ - if (lbm_context_attr_str_setopt(cattr, "resolver_multicast_address", "224.10.11.12") != 0) - { - fprintf(stderr, "lbm_context_attr_str_setopt:resolver_multicast_address: %s\n", lbm_errmsg()); - exit(1); - } - - /* Setting the resolver port using the data-type value method */ - res_port = 12345; - if (lbm_context_attr_setopt(cattr, "resolver_multicast_port", &res_port, sizeof(lbm_uint16_t)) != 0 ) - { - fprintf(stderr, "lbm_context_attr_setopt:resolver_mutlicast_port: %s\n", lbm_errmsg()); - exit(1); - } - - /* Creating the context */ - err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - /* Delete the context attribute object */ - lbm_context_attr_delete(cattr); - - /* Initializing the source attribute object */ - if (lbm_src_topic_attr_create(&tattr_1) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg()); - exit(1); - } - - /* Setting the transport via the source topic string method */ - if (lbm_src_topic_attr_str_setopt(tattr_1, "transport", "lbtrm") != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg()); - exit(1); - } - - /* Setting the lbtrm destination port via the direct value set method */ - des_port = 14001; - if (lbm_src_topic_attr_setopt(tattr_1, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)) != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_setopt:transport_lbtrm_destination_port: %s\n", lbm_errmsg()); - exit(1); - } - - /* Allocating the topic */ - err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic.1", tattr_1); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - /* Creating the source */ - err = lbm_src_create(&src_1, ctx, topic_1, NULL, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - /* Initialized the second source attributes as a copy of the first */ - if (lbm_src_topic_attr_dup(&tattr_2, tattr_1) != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_dup: %s\n", lbm_errmsg()); - exit(1); - } - - /* Now modify the destination port for this second source to put the publisher on a different transport */ - des_port = 14002; - if (lbm_src_topic_attr_setopt(tattr_2, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)) != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_setopt:transport_lbtrm_destination_port: %s\n", lbm_errmsg()); - exit(1); - } - - /* Allocating the second topic */ - err = lbm_src_topic_alloc(&topic_2, ctx, "test.topic.2", tattr_2); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - /* Creating the source */ - err = lbm_src_create(&src_2, ctx, topic_2, NULL, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - /* Delete the first and second source topic attribute objects */ - lbm_src_topic_attr_delete(tattr_1); - lbm_src_topic_attr_delete(tattr_2); - - /* Finished with all LBM functions, delete the source and context object. */ - lbm_src_delete(src_1); - lbm_src_delete(src_2); - lbm_context_delete(ctx); + /* Initialize the defaults for the context attribute object */ + err = lbm_context_attr_create(&cattr); + EX_LBM_CHK(err); + + /* Setting the resolver address using the string method */ + err = lbm_context_attr_str_setopt(cattr, "resolver_multicast_address", "224.10.11.12"); + EX_LBM_CHK(err); + + /* Setting the resolver port using the data-type value method */ + res_port = 12345; + err = lbm_context_attr_setopt(cattr, "resolver_multicast_port", &res_port, sizeof(lbm_uint16_t)); + EX_LBM_CHK(err); + + /* Creating the context */ + err = lbm_context_create(&ctx, cattr, NULL, NULL); + EX_LBM_CHK(err); + + /* Delete the context attribute object */ + err = lbm_context_attr_delete(cattr); + EX_LBM_CHK(err); + + /* Initializing the source attribute object */ + err = lbm_src_topic_attr_create(&tattr_1); + + /* Setting the transport via the source topic string method */ + err = lbm_src_topic_attr_str_setopt(tattr_1, "transport", "lbtrm"); + EX_LBM_CHK(err); + + /* Setting the lbtrm destination port via the direct value set method */ + des_port = 14001; + err = lbm_src_topic_attr_setopt(tattr_1, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)); + EX_LBM_CHK(err); + + /* Allocating the topic */ + err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic.1", tattr_1); + EX_LBM_CHK(err); + + /* Creating the source */ + err = lbm_src_create(&src_1, ctx, topic_1, NULL, NULL, NULL); + EX_LBM_CHK(err); + + /* Initialized the second source attributes as a copy of the first */ + err = lbm_src_topic_attr_dup(&tattr_2, tattr_1); + EX_LBM_CHK(err); + + /* Now modify the destination port for this second source to put the + * publisher on a different transport. */ + des_port = 14002; + err = lbm_src_topic_attr_setopt(tattr_2, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)); + EX_LBM_CHK(err); + + /* Allocating the second topic */ + err = lbm_src_topic_alloc(&topic_2, ctx, "test.topic.2", tattr_2); + EX_LBM_CHK(err); + + /* Creating the source */ + err = lbm_src_create(&src_2, ctx, topic_2, NULL, NULL, NULL); + EX_LBM_CHK(err); + + /* Delete the first and second source topic attribute objects */ + err = lbm_src_topic_attr_delete(tattr_1); + EX_LBM_CHK(err); + err = lbm_src_topic_attr_delete(tattr_2); + EX_LBM_CHK(err); + + /* Finished with all LBM functions, delete the source and context object. */ + err = lbm_src_delete(src_1); + EX_LBM_CHK(err); + err = lbm_src_delete(src_2); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); #if defined(_MSC_VER) - WSACleanup(); + WSACleanup(); #endif - return 0; -} - + return 0; +} /* main */ diff --git a/setting_attributes/c/setting_attributes.sldoc.html b/setting_attributes/c/setting_attributes.sldoc.html index 55fd4ee..ec96d80 100644 --- a/setting_attributes/c/setting_attributes.sldoc.html +++ b/setting_attributes/c/setting_attributes.sldoc.html @@ -25,8 +25,8 @@

Source Topic Attribute Pointer

two variables are declared.

-00025      lbm_src_topic_attr_t *tattr_1;  /* pointer to source attribute object */
-00026      lbm_src_topic_attr_t *tattr_2;  /* pointer to source attribute object */
+00054      lbm_src_topic_attr_t *tattr_1;  /* pointer to source attribute object */
+00055      lbm_src_topic_attr_t *tattr_2;  /* pointer to source attribute object */
 
@@ -34,7 +34,7 @@

Context Attribute declatation

This is the declaration for the context attribute.

-00027      lbm_context_attr_t * cattr;     /* pointer to context attribute object */
+00056      lbm_context_attr_t * cattr;     /* pointer to context attribute object */
 
@@ -42,8 +42,8 @@

Attribute Variables

Declaring these two variables to be used while setting the topic resolution port and LBTRM destination port

-00028      lbm_uint16_t res_port;          /* Int to set resolver port */
-00029      lbm_uint16_t des_port;          /* Int to set lbtrm destination port */
+00057      lbm_uint16_t res_port;          /* Int to set resolver port */
+00058      lbm_uint16_t des_port;          /* Int to set lbtrm destination port */
 
@@ -53,12 +53,9 @@

Initialize Context Attributes

is created.

-00043      /* Initialize the defaults for the context attribute object */
-00044      if (lbm_context_attr_create(&cattr) != 0)
-00045      {
-00046          fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg());
-00047      exit(1);
-00048      }
+00072      /* Initialize the defaults for the context attribute object */
+00073      err = lbm_context_attr_create(&cattr);
+00074      EX_LBM_CHK(err);
 
@@ -76,12 +73,9 @@

Setting Context Attribute using the String Method

which configures this applications topic resolution multicast address using the string method.

-00050      /* Setting the resolver address using the string method */
-00051      if (lbm_context_attr_str_setopt(cattr, "resolver_multicast_address", "224.10.11.12") != 0) 
-00052      {
-00053          fprintf(stderr, "lbm_context_attr_str_setopt:resolver_multicast_address: %s\n", lbm_errmsg());
-00054          exit(1);
-00055      }
+00076      /* Setting the resolver address using the string method */
+00077      err = lbm_context_attr_str_setopt(cattr, "resolver_multicast_address", "224.10.11.12");
+00078      EX_LBM_CHK(err);
 
@@ -99,13 +93,10 @@

Setting Context Attributes using the Data Type Method

defined previously will use.

-00057      /* Setting the resolver port using the data-type value method */
-00058      res_port = 12345;
-00059      if (lbm_context_attr_setopt(cattr, "resolver_multicast_port", &res_port, sizeof(lbm_uint16_t)) != 0 )
-00060      {
-00061      fprintf(stderr, "lbm_context_attr_setopt:resolver_mutlicast_port: %s\n", lbm_errmsg());
-00062          exit(1);
-00063      }
+00080      /* Setting the resolver port using the data-type value method */
+00081      res_port = 12345;
+00082      err = lbm_context_attr_setopt(cattr, "resolver_multicast_port", &res_port, sizeof(lbm_uint16_t));
+00083      EX_LBM_CHK(err);
 
@@ -113,13 +104,9 @@

Create the Context Using the Attributes

Now create the context using the attributes that were just previously configured. Notice the attributes object as the second parameter

-00065      /* Creating the context */
-00066      err = lbm_context_create(&ctx, cattr, NULL, NULL);
-00067      if (err)
-00068      {
-00069          printf("line %d: %s\n", __LINE__, lbm_errmsg());
-00070          exit(1);
-00071      }
+00085      /* Creating the context */
+00086      err = lbm_context_create(&ctx, cattr, NULL, NULL);
+00087      EX_LBM_CHK(err);
 
@@ -127,8 +114,9 @@

Delete the Attribute Object

Delete the attribute object to clean up

-00073      /* Delete the context attribute object */
-00074      lbm_context_attr_delete(cattr);
+00089      /* Delete the context attribute object */
+00090      err = lbm_context_attr_delete(cattr);
+00091      EX_LBM_CHK(err);
 
@@ -136,12 +124,8 @@

Initialize Source Attribute for test.topic.1

Like the context attribute object, the source topic attribute object must also be initialized

-00076      /* Initializing the source attribute object */
-00077      if (lbm_src_topic_attr_create(&tattr_1) != 0)
-00078      {
-00079          fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg());
-00080          exit(1);
-00081      }
+00093      /* Initializing the source attribute object */
+00094      err = lbm_src_topic_attr_create(&tattr_1);
 
@@ -163,12 +147,9 @@

Setting Source Attribute via String

-00083      /* Setting the transport via the source topic string method */
-00084      if (lbm_src_topic_attr_str_setopt(tattr_1, "transport", "lbtrm") != 0 )
-00085      {
-00086          fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg());
-00087          exit(1);
-00088      }
+00096      /* Setting the transport via the source topic string method */
+00097      err = lbm_src_topic_attr_str_setopt(tattr_1, "transport", "lbtrm");
+00098      EX_LBM_CHK(err);
 
@@ -185,13 +166,10 @@

Setting Source Attribute via Data Type

-00090      /* Setting the lbtrm destination port via the direct value set method */
-00091      des_port = 14001;
-00092      if (lbm_src_topic_attr_setopt(tattr_1, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)) != 0 )
-00093      {
-00094          fprintf(stderr, "lbm_src_topic_attr_setopt:transport_lbtrm_destination_port: %s\n", lbm_errmsg());
-00095          exit(1);
-00096      }
+00100      /* Setting the lbtrm destination port via the direct value set method */
+00101      des_port = 14001;
+00102      err = lbm_src_topic_attr_setopt(tattr_1, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t));
+00103      EX_LBM_CHK(err);
 
@@ -199,13 +177,9 @@

Allocate the Topic for test.topic.1

Allocate the topic for the first publisher

-00098      /* Allocating the topic */
-00099      err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic.1", tattr_1);
-00100      if (err)
-00101      {
-00102          printf("line %d: %s\n", __LINE__, lbm_errmsg());
-00103          exit(1);
-00104      }
+00105      /* Allocating the topic */
+00106      err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic.1", tattr_1);
+00107      EX_LBM_CHK(err);
 
@@ -213,13 +187,9 @@

Create the First Source

Create the source test.topic.1 by calling lbm_src_create(), and passing the attribute object in as the third paramter

-00106      /* Creating the source */
-00107      err = lbm_src_create(&src_1, ctx, topic_1, NULL, NULL, NULL);
-00108      if (err)
-00109      {
-00110          printf("line %d: %s\n", __LINE__, lbm_errmsg());
-00111          exit(1);
-00112      }
+00109      /* Creating the source */
+00110      err = lbm_src_create(&src_1, ctx, topic_1, NULL, NULL, NULL);
+00111      EX_LBM_CHK(err);
 
@@ -228,12 +198,9 @@

Clone Attribues for Second Source

second attribute object. After the copy, alterations can be made prior to the creation of the second source

-00114      /* Initialized the second source attributes as a copy of the first */
-00115      if (lbm_src_topic_attr_dup(&tattr_2, tattr_1) != 0 )
-00116      {
-00117          fprintf(stderr, "lbm_src_topic_attr_dup: %s\n", lbm_errmsg());
-00118          exit(1);
-00119      }
+00113      /* Initialized the second source attributes as a copy of the first */
+00114      err = lbm_src_topic_attr_dup(&tattr_2, tattr_1);
+00115      EX_LBM_CHK(err);
 
@@ -254,13 +221,11 @@

Change the Multicast Port

-00121      /* Now modify the destination port for this second source to put the publisher on a different transport */
-00122      des_port = 14002;
-00123      if (lbm_src_topic_attr_setopt(tattr_2, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)) != 0 )
-00124      {
-00125          fprintf(stderr, "lbm_src_topic_attr_setopt:transport_lbtrm_destination_port: %s\n", lbm_errmsg());
-00126          exit(1);
-00127      }
+00117      /* Now modify the destination port for this second source to put the
+00118       * publisher on a different transport. */
+00119      des_port = 14002;
+00120      err = lbm_src_topic_attr_setopt(tattr_2, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t));
+00121      EX_LBM_CHK(err);
 
@@ -268,21 +233,13 @@

Allocate and Create test.topic.2

Just like previously done for the first publisher, allocate the topic with the configured attributes and create the source

-00129      /* Allocating the second topic */
-00130      err = lbm_src_topic_alloc(&topic_2, ctx, "test.topic.2", tattr_2);
-00131      if (err)
-00132      {
-00133          printf("line %d: %s\n", __LINE__, lbm_errmsg());
-00134          exit(1);
-00135      }
-00136  
-00137      /* Creating the source */
-00138      err = lbm_src_create(&src_2, ctx, topic_2, NULL, NULL, NULL);
-00139      if (err)
-00140      {
-00141          printf("line %d: %s\n", __LINE__, lbm_errmsg());
-00142          exit(1);
-00143      }
+00123      /* Allocating the second topic */
+00124      err = lbm_src_topic_alloc(&topic_2, ctx, "test.topic.2", tattr_2);
+00125      EX_LBM_CHK(err);
+00126  
+00127      /* Creating the source */
+00128      err = lbm_src_create(&src_2, ctx, topic_2, NULL, NULL, NULL);
+00129      EX_LBM_CHK(err);
 
@@ -290,9 +247,11 @@

Delete the Source Attribute Objects

Deleting the source attribute objects is a good best practice

-00145      /* Delete the first and second source topic attribute objects */
-00146      lbm_src_topic_attr_delete(tattr_1);
-00147      lbm_src_topic_attr_delete(tattr_2);
+00131      /* Delete the first and second source topic attribute objects */
+00132      err = lbm_src_topic_attr_delete(tattr_1);
+00133      EX_LBM_CHK(err);
+00134      err = lbm_src_topic_attr_delete(tattr_2);
+00135      EX_LBM_CHK(err);
 
@@ -301,10 +260,13 @@

Delete the Sources and Context

before deleting the context

-00149      /* Finished with all LBM functions, delete the source and context object. */
-00150      lbm_src_delete(src_1);
-00151      lbm_src_delete(src_2);
-00152      lbm_context_delete(ctx);
+00137      /* Finished with all LBM functions, delete the source and context object. */
+00138      err = lbm_src_delete(src_1);
+00139      EX_LBM_CHK(err);
+00140      err = lbm_src_delete(src_2);
+00141      EX_LBM_CHK(err);
+00142      err = lbm_context_delete(ctx);
+00143      EX_LBM_CHK(err);
 
@@ -312,20 +274,20 @@

Includes

Include files for this application. Notice the Windows specific include files - these are not necessary for Linux only applications

-00003  #include <stdio.h>
-00004  
-00005  #if defined(_MSC_VER)
-00006  /* Windows-only includes */
-00007  #include <winsock2.h>
-00008  #define SLEEP(s) Sleep((s)*1000)
-00009  #else
-00010  /* Unix-only includes */
-00011  #include <stdlib.h>
-00012  #include <unistd.h>
-00013  #define SLEEP(s) sleep(s)
-00014  #endif
-00015  
-00016  #include <lbm/lbm.h>
+00022  #include <stdio.h>
+00023  
+00024  #if defined(_MSC_VER)
+00025  /* Windows-only includes */
+00026  #include <winsock2.h>
+00027  #define SLEEP(s) Sleep((s)*1000)
+00028  #else
+00029  /* Unix-only includes */
+00030  #include <stdlib.h>
+00031  #include <unistd.h>
+00032  #define SLEEP(s) sleep(s)
+00033  #endif
+00034  
+00035  #include <lbm/lbm.h>
 
diff --git a/setting_attributes/c/setting_attributes_c.slsrc b/setting_attributes/c/setting_attributes_c.slsrc index fd052bb..001ff72 100644 --- a/setting_attributes/c/setting_attributes_c.slsrc +++ b/setting_attributes/c/setting_attributes_c.slsrc @@ -1,4 +1,23 @@ -/* Example on setting Ultra Messaging attributes */ +/* setting_attributes.c - see http://ultramessaging.github.io/UMExamples/setting_attributes/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ /* =semlit,block,includes=*/ #include @@ -17,181 +36,152 @@ #include /* =semlit,endblock,includes=*/ +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ +} while (0) + + int main(int argc, char **argv) { - lbm_context_t *ctx; /* pointer to context object */ - lbm_topic_t *topic_1; /* pointer to topic object */ - lbm_topic_t *topic_2; /* pointer to topic object */ - lbm_src_t *src_1; /* pointer to source object */ - lbm_src_t *src_2; /* pointer to source object */ - /* =semlit,block,topic_attr=*/ - lbm_src_topic_attr_t *tattr_1; /* pointer to source attribute object */ - lbm_src_topic_attr_t *tattr_2; /* pointer to source attribute object */ - /* =semlit,endblock,topic_attr=*/ - /* =semlit,block,ctx_attr=*/ - lbm_context_attr_t * cattr; /* pointer to context attribute object */ - /* =semlit,endblock,ctx_attr=*/ - /* =semlit,block,attr_settings=*/ - lbm_uint16_t res_port; /* Int to set resolver port */ - lbm_uint16_t des_port; /* Int to set lbtrm destination port */ - /* =semlit,endblock,attr_settings=*/ - int err; /* return status of lbm functions (true=error) */ + lbm_context_t *ctx; /* pointer to context object */ + lbm_topic_t *topic_1; /* pointer to topic object */ + lbm_topic_t *topic_2; /* pointer to topic object */ + lbm_src_t *src_1; /* pointer to source object */ + lbm_src_t *src_2; /* pointer to source object */ + /* =semlit,block,topic_attr=*/ + lbm_src_topic_attr_t *tattr_1; /* pointer to source attribute object */ + lbm_src_topic_attr_t *tattr_2; /* pointer to source attribute object */ + /* =semlit,endblock,topic_attr=*/ + /* =semlit,block,ctx_attr=*/ + lbm_context_attr_t * cattr; /* pointer to context attribute object */ + /* =semlit,endblock,ctx_attr=*/ + /* =semlit,block,attr_settings=*/ + lbm_uint16_t res_port; /* Int to set resolver port */ + lbm_uint16_t des_port; /* Int to set lbtrm destination port */ + /* =semlit,endblock,attr_settings=*/ + int err; #if defined(_MSC_VER) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + exit(1); + } #endif - /* =semlit,block,init_ctx=*/ - /* Initialize the defaults for the context attribute object */ - if (lbm_context_attr_create(&cattr) != 0) - { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); - exit(1); - } - /* =semlit,endblock,init_ctx=*/ - - /* =semlit,block,ctx_res_addr=*/ - /* Setting the resolver address using the string method */ - if (lbm_context_attr_str_setopt(cattr, "resolver_multicast_address", "224.10.11.12") != 0) - { - fprintf(stderr, "lbm_context_attr_str_setopt:resolver_multicast_address: %s\n", lbm_errmsg()); - exit(1); - } - /* =semlit,endblock,ctx_res_addr=*/ - - /* =semlit,block,ctx_res_port=*/ - /* Setting the resolver port using the data-type value method */ - res_port = 12345; - if (lbm_context_attr_setopt(cattr, "resolver_multicast_port", &res_port, sizeof(lbm_uint16_t)) != 0 ) - { - fprintf(stderr, "lbm_context_attr_setopt:resolver_mutlicast_port: %s\n", lbm_errmsg()); - exit(1); - } - /* =semlit,endblock,ctx_res_port=*/ - - /* =semlit,block,ctx_create=*/ - /* Creating the context */ - err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - /* =semlit,endblock,ctx_create=*/ - - /* =semlit,block,ctx_attr_del=*/ - /* Delete the context attribute object */ - lbm_context_attr_delete(cattr); - /* =semlit,endblock,ctx_attr_del=*/ - - /* =semlit,block,topic1_init=*/ - /* Initializing the source attribute object */ - if (lbm_src_topic_attr_create(&tattr_1) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg()); - exit(1); - } - /* =semlit,endblock,topic1_init=*/ - - /* =semlit,block,topic1_transport=*/ - /* Setting the transport via the source topic string method */ - if (lbm_src_topic_attr_str_setopt(tattr_1, "transport", "lbtrm") != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg()); - exit(1); - } - /* =semlit,endblock,topic1_transport=*/ - - /* =semlit,block,topic1_port=*/ - /* Setting the lbtrm destination port via the direct value set method */ - des_port = 14001; - if (lbm_src_topic_attr_setopt(tattr_1, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)) != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_setopt:transport_lbtrm_destination_port: %s\n", lbm_errmsg()); - exit(1); - } - /* =semlit,endblock,topic1_port=*/ - - /* =semlit,block,topic1_alloc=*/ - /* Allocating the topic */ - err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic.1", tattr_1); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - /* =semlit,endblock,topic1_alloc=*/ - - /* =semlit,block,topic1_create=*/ - /* Creating the source */ - err = lbm_src_create(&src_1, ctx, topic_1, NULL, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - /* =semlit,endblock,topic1_create=*/ - - /* =semlit,block,topic2_clone=*/ - /* Initialized the second source attributes as a copy of the first */ - if (lbm_src_topic_attr_dup(&tattr_2, tattr_1) != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_dup: %s\n", lbm_errmsg()); - exit(1); - } - /* =semlit,endblock,topic2_clone=*/ - - /* =semlit,block,topic2_port=*/ - /* Now modify the destination port for this second source to put the publisher on a different transport */ - des_port = 14002; - if (lbm_src_topic_attr_setopt(tattr_2, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)) != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_setopt:transport_lbtrm_destination_port: %s\n", lbm_errmsg()); - exit(1); - } - /* =semlit,endblock,topic2_port=*/ - - /* =semlit,block,topic2_create=*/ - /* Allocating the second topic */ - err = lbm_src_topic_alloc(&topic_2, ctx, "test.topic.2", tattr_2); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - - /* Creating the source */ - err = lbm_src_create(&src_2, ctx, topic_2, NULL, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } - /* =semlit,endblock,topic2_create=*/ - - /* =semlit,block,topic_attr_del=*/ - /* Delete the first and second source topic attribute objects */ - lbm_src_topic_attr_delete(tattr_1); - lbm_src_topic_attr_delete(tattr_2); - /* =semlit,endblock,topic_attr_del=*/ - - /* =semlit,block,clean=*/ - /* Finished with all LBM functions, delete the source and context object. */ - lbm_src_delete(src_1); - lbm_src_delete(src_2); - lbm_context_delete(ctx); - /* =semlit,endblock,clean=*/ + /* =semlit,block,init_ctx=*/ + /* Initialize the defaults for the context attribute object */ + err = lbm_context_attr_create(&cattr); + EX_LBM_CHK(err); + /* =semlit,endblock,init_ctx=*/ + + /* =semlit,block,ctx_res_addr=*/ + /* Setting the resolver address using the string method */ + err = lbm_context_attr_str_setopt(cattr, "resolver_multicast_address", "224.10.11.12"); + EX_LBM_CHK(err); + /* =semlit,endblock,ctx_res_addr=*/ + + /* =semlit,block,ctx_res_port=*/ + /* Setting the resolver port using the data-type value method */ + res_port = 12345; + err = lbm_context_attr_setopt(cattr, "resolver_multicast_port", &res_port, sizeof(lbm_uint16_t)); + EX_LBM_CHK(err); + /* =semlit,endblock,ctx_res_port=*/ + + /* =semlit,block,ctx_create=*/ + /* Creating the context */ + err = lbm_context_create(&ctx, cattr, NULL, NULL); + EX_LBM_CHK(err); + /* =semlit,endblock,ctx_create=*/ + + /* =semlit,block,ctx_attr_del=*/ + /* Delete the context attribute object */ + err = lbm_context_attr_delete(cattr); + EX_LBM_CHK(err); + /* =semlit,endblock,ctx_attr_del=*/ + + /* =semlit,block,topic1_init=*/ + /* Initializing the source attribute object */ + err = lbm_src_topic_attr_create(&tattr_1); + /* =semlit,endblock,topic1_init=*/ + + /* =semlit,block,topic1_transport=*/ + /* Setting the transport via the source topic string method */ + err = lbm_src_topic_attr_str_setopt(tattr_1, "transport", "lbtrm"); + EX_LBM_CHK(err); + /* =semlit,endblock,topic1_transport=*/ + + /* =semlit,block,topic1_port=*/ + /* Setting the lbtrm destination port via the direct value set method */ + des_port = 14001; + err = lbm_src_topic_attr_setopt(tattr_1, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)); + EX_LBM_CHK(err); + /* =semlit,endblock,topic1_port=*/ + + /* =semlit,block,topic1_alloc=*/ + /* Allocating the topic */ + err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic.1", tattr_1); + EX_LBM_CHK(err); + /* =semlit,endblock,topic1_alloc=*/ + + /* =semlit,block,topic1_create=*/ + /* Creating the source */ + err = lbm_src_create(&src_1, ctx, topic_1, NULL, NULL, NULL); + EX_LBM_CHK(err); + /* =semlit,endblock,topic1_create=*/ + + /* =semlit,block,topic2_clone=*/ + /* Initialized the second source attributes as a copy of the first */ + err = lbm_src_topic_attr_dup(&tattr_2, tattr_1); + EX_LBM_CHK(err); + /* =semlit,endblock,topic2_clone=*/ + + /* =semlit,block,topic2_port=*/ + /* Now modify the destination port for this second source to put the + * publisher on a different transport. */ + des_port = 14002; + err = lbm_src_topic_attr_setopt(tattr_2, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)); + EX_LBM_CHK(err); + /* =semlit,endblock,topic2_port=*/ + + /* =semlit,block,topic2_create=*/ + /* Allocating the second topic */ + err = lbm_src_topic_alloc(&topic_2, ctx, "test.topic.2", tattr_2); + EX_LBM_CHK(err); + + /* Creating the source */ + err = lbm_src_create(&src_2, ctx, topic_2, NULL, NULL, NULL); + EX_LBM_CHK(err); + /* =semlit,endblock,topic2_create=*/ + + /* =semlit,block,topic_attr_del=*/ + /* Delete the first and second source topic attribute objects */ + err = lbm_src_topic_attr_delete(tattr_1); + EX_LBM_CHK(err); + err = lbm_src_topic_attr_delete(tattr_2); + EX_LBM_CHK(err); + /* =semlit,endblock,topic_attr_del=*/ + + /* =semlit,block,clean=*/ + /* Finished with all LBM functions, delete the source and context object. */ + err = lbm_src_delete(src_1); + EX_LBM_CHK(err); + err = lbm_src_delete(src_2); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); + /* =semlit,endblock,clean=*/ #if defined(_MSC_VER) - WSACleanup(); + WSACleanup(); #endif - return 0; -} - + return 0; +} /* main */ diff --git a/setting_attributes/c/setting_attributes_c.slsrc.html b/setting_attributes/c/setting_attributes_c.slsrc.html index 13d3008..6c519a8 100644 --- a/setting_attributes/c/setting_attributes_c.slsrc.html +++ b/setting_attributes/c/setting_attributes_c.slsrc.html @@ -18,39 +18,39 @@
00001 00002 -00003 -00004 -00005 -00006 -00007 -00008 -00009 -00010 -00011 -00012 -00013 -00014 -00015 -00016 +00003 +00004 +00005 +00006 +00007 +00008 +00009 +00010 +00011 +00012 +00013 +00014 +00015 +00016 00017 00018 00019 00020 00021 -00022 -00023 -00024 -00025 -00026 -00027 -00028 -00029 -00030 -00031 -00032 -00033 -00034 -00035 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 00036 00037 00038 @@ -58,124 +58,133 @@ 00040 00041 00042 -00043 -00044 -00045 -00046 -00047 -00048 +00043 +00044 +00045 +00046 +00047 +00048 00049 -00050 -00051 -00052 -00053 -00054 -00055 -00056 -00057 -00058 -00059 -00060 -00061 -00062 -00063 +00050 +00051 +00052 +00053 +00054 +00055 +00056 +00057 +00058 +00059 +00060 +00061 +00062 +00063 00064 -00065 -00066 -00067 -00068 -00069 -00070 -00071 -00072 -00073 -00074 +00065 +00066 +00067 +00068 +00069 +00070 +00071 +00072 +00073 +00074 00075 -00076 -00077 -00078 -00079 -00080 -00081 -00082 -00083 -00084 -00085 -00086 -00087 -00088 -00089 -00090 -00091 -00092 -00093 -00094 -00095 -00096 -00097 -00098 -00099 -00100 -00101 -00102 -00103 -00104 -00105 -00106 -00107 -00108 +00076 +00077 +00078 +00079 +00080 +00081 +00082 +00083 +00084 +00085 +00086 +00087 +00088 +00089 +00090 +00091 +00092 +00093 +00094 +00095 +00096 +00097 +00098 +00099 +00100 +00101 +00102 +00103 +00104 +00105 +00106 +00107 +00108 00109 00110 00111 -00112 -00113 +00112 +00113 00114 00115 -00116 -00117 -00118 -00119 -00120 +00116 +00117 +00118 +00119 +00120 00121 -00122 -00123 -00124 -00125 -00126 -00127 -00128 +00122 +00123 +00124 +00125 +00126 +00127 +00128 00129 -00130 -00131 -00132 -00133 -00134 -00135 -00136 -00137 -00138 -00139 -00140 -00141 -00142 -00143 +00130 +00131 +00132 +00133 +00134 +00135 +00136 +00137 +00138 +00139 +00140 +00141 +00142 +00143 00144 -00145 -00146 -00147 +00145 +00146 +00147 00148 -00149 -00150 -00151 -00152 -00153 -00154 -00155 -00156 -00157 -00158 -00159 - /* Example on setting Ultra Messaging attributes */ +00149 + /* setting_attributes.c - see http://ultramessaging.github.io/UMExamples/setting_attributes/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include <stdio.h> @@ -192,6 +201,16 @@ #include <lbm/lbm.h> + /* Example error checking macro. Include after each UM call. */ + #define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ + } while (0) + + int main(int argc, char **argv) { lbm_context_t *ctx; /* pointer to context object */ @@ -204,7 +223,7 @@ lbm_context_attr_t * cattr; /* pointer to context attribute object */ lbm_uint16_t res_port; /* Int to set resolver port */ lbm_uint16_t des_port; /* Int to set lbtrm destination port */ - int err; /* return status of lbm functions (true=error) */ + int err; #if defined(_MSC_VER) /* windows-specific code */ @@ -218,122 +237,83 @@ #endif /* Initialize the defaults for the context attribute object */ - if (lbm_context_attr_create(&cattr) != 0) - { - fprintf(stderr, "lbm_context_attr_create: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_context_attr_create(&cattr); + EX_LBM_CHK(err); /* Setting the resolver address using the string method */ - if (lbm_context_attr_str_setopt(cattr, "resolver_multicast_address", "224.10.11.12") != 0) - { - fprintf(stderr, "lbm_context_attr_str_setopt:resolver_multicast_address: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_context_attr_str_setopt(cattr, "resolver_multicast_address", "224.10.11.12"); + EX_LBM_CHK(err); /* Setting the resolver port using the data-type value method */ res_port = 12345; - if (lbm_context_attr_setopt(cattr, "resolver_multicast_port", &res_port, sizeof(lbm_uint16_t)) != 0 ) - { - fprintf(stderr, "lbm_context_attr_setopt:resolver_mutlicast_port: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_context_attr_setopt(cattr, "resolver_multicast_port", &res_port, sizeof(lbm_uint16_t)); + EX_LBM_CHK(err); /* Creating the context */ err = lbm_context_create(&ctx, cattr, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* Delete the context attribute object */ - lbm_context_attr_delete(cattr); + err = lbm_context_attr_delete(cattr); + EX_LBM_CHK(err); /* Initializing the source attribute object */ - if (lbm_src_topic_attr_create(&tattr_1) != 0) - { - fprintf(stderr, "lbm_src_topic_attr_create: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_create(&tattr_1); /* Setting the transport via the source topic string method */ - if (lbm_src_topic_attr_str_setopt(tattr_1, "transport", "lbtrm") != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_str_setopt:transport: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_str_setopt(tattr_1, "transport", "lbtrm"); + EX_LBM_CHK(err); /* Setting the lbtrm destination port via the direct value set method */ des_port = 14001; - if (lbm_src_topic_attr_setopt(tattr_1, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)) != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_setopt:transport_lbtrm_destination_port: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_setopt(tattr_1, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)); + EX_LBM_CHK(err); /* Allocating the topic */ err = lbm_src_topic_alloc(&topic_1, ctx, "test.topic.1", tattr_1); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* Creating the source */ err = lbm_src_create(&src_1, ctx, topic_1, NULL, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* Initialized the second source attributes as a copy of the first */ - if (lbm_src_topic_attr_dup(&tattr_2, tattr_1) != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_dup: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_dup(&tattr_2, tattr_1); + EX_LBM_CHK(err); - /* Now modify the destination port for this second source to put the publisher on a different transport */ + /* Now modify the destination port for this second source to put the + * publisher on a different transport. */ des_port = 14002; - if (lbm_src_topic_attr_setopt(tattr_2, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)) != 0 ) - { - fprintf(stderr, "lbm_src_topic_attr_setopt:transport_lbtrm_destination_port: %s\n", lbm_errmsg()); - exit(1); - } + err = lbm_src_topic_attr_setopt(tattr_2, "transport_lbtrm_destination_port", &des_port, sizeof(lbm_uint16_t)); + EX_LBM_CHK(err); /* Allocating the second topic */ err = lbm_src_topic_alloc(&topic_2, ctx, "test.topic.2", tattr_2); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* Creating the source */ err = lbm_src_create(&src_2, ctx, topic_2, NULL, NULL, NULL); - if (err) - { - printf("line %d: %s\n", __LINE__, lbm_errmsg()); - exit(1); - } + EX_LBM_CHK(err); /* Delete the first and second source topic attribute objects */ - lbm_src_topic_attr_delete(tattr_1); - lbm_src_topic_attr_delete(tattr_2); + err = lbm_src_topic_attr_delete(tattr_1); + EX_LBM_CHK(err); + err = lbm_src_topic_attr_delete(tattr_2); + EX_LBM_CHK(err); /* Finished with all LBM functions, delete the source and context object. */ - lbm_src_delete(src_1); - lbm_src_delete(src_2); - lbm_context_delete(ctx); + err = lbm_src_delete(src_1); + EX_LBM_CHK(err); + err = lbm_src_delete(src_2); + EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); #if defined(_MSC_VER) WSACleanup(); #endif - return 0; - } - + return 0; + } /* main */
diff --git a/source_notify_callbacks/c/source_notify_callbacks.c b/source_notify_callbacks/c/source_notify_callbacks.c index 84df90a..0ee081b 100644 --- a/source_notify_callbacks/c/source_notify_callbacks.c +++ b/source_notify_callbacks/c/source_notify_callbacks.c @@ -1,4 +1,24 @@ -/* source_notify_callback.c - http://ultramessaging.github.io/UMExamples */ +/* source_notify_callbacks.c - see http://ultramessaging.github.io/UMExamples/source_notify_callbacks/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ + #include #if defined(_MSC_VER) @@ -13,113 +33,117 @@ #endif #include +/* State structure associated with each source the receiver is joined to. */ typedef struct source_state_s { - int msgs_rcvd; /* We want to track message count from each source sending to the topic. */ + int msgs_rcvd; /* Track message count from each source. */ } source_state_t; /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) + void *new_src_notification_callback(const char *source_name, void *clientd) { - source_state_t *source_state = (source_state_t *)malloc(sizeof(source_state_t)); - source_state->msgs_rcvd = 0; + source_state_t *source_state = (source_state_t *)malloc(sizeof(source_state_t)); + source_state->msgs_rcvd = 0; + + printf("Delivery Controller Created: %s\n", source_name); + return source_state; /* This will be available in the receive callback as msg->source_clientd. */ +} /* new_src_notification_callback */ - printf("Delivery Controller Created: %s\n", source_name); - return source_state; /* This will be available in the receive callback as msg->source_clientd. */ -} int src_delete_notification_callback(const char *source_name, void *clientd, void* src_clientd ) { - free(src_clientd); /* This was created by new_src_notification_callback() */ + free(src_clientd); /* This was created by new_src_notification_callback() */ + + printf("Delivery Controller Deleted: %s\n", source_name); + return 0; +} /* src_delete_notification_callback */ - printf("Delivery Controller Deleted: %s\n", source_name); - return 0; -} /* Callback used to handle request message for receiver */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { - int err; - source_state_t *source_state = (source_state_t *)msg->source_clientd; - - switch (msg->type) { - case LBM_MSG_DATA: - source_state->msgs_rcvd ++; - printf("[%s][%s], Received message %d\n", msg->topic_name, msg->source, source_state->msgs_rcvd); - break; - case LBM_MSG_BOS: - printf("[%s][%s], Beginning of Transport Session\n", msg->topic_name, msg->source); - break; - case LBM_MSG_EOS: - printf("[%s][%s], End of Transport Session\n", msg->topic_name, msg->source); - break; - default: - printf("Other event, type=%x\n", msg->type); - break; - } - - return 0; -} + source_state_t *source_state = (source_state_t *)msg->source_clientd; + + switch (msg->type) { + case LBM_MSG_DATA: + source_state->msgs_rcvd ++; + printf("[%s][%s], Received message %d\n", msg->topic_name, msg->source, source_state->msgs_rcvd); + break; + case LBM_MSG_BOS: + printf("[%s][%s], Beginning of Transport Session\n", msg->topic_name, msg->source); + break; + case LBM_MSG_EOS: + printf("[%s][%s], End of Transport Session\n", msg->topic_name, msg->source); + break; + default: + printf("Other event, type=%x\n", msg->type); + break; + } + + return 0; +} /* rcv_handle_msg */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ - lbm_topic_t *rtopic; /* Receiver Topic object */ - lbm_rcv_topic_attr_t * rattr; /* Receiver attribute object */ - lbm_rcv_src_notification_func_t srccb; /* Source notify callback structure */ - int err; /* Used for checking API return codes */ + lbm_context_t *ctx; /* Context object */ + lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ + lbm_topic_t *rtopic; /* Receiver Topic object */ + lbm_rcv_topic_attr_t * rattr; /* Receiver attribute object */ + lbm_rcv_src_notification_func_t srccb; /* Source notify callback structure */ + int err; #if defined(_WIN32) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + exit(1); + } #endif - /* Initialize context atrributes and create context */ - err = lbm_context_create(&ctx, NULL, NULL, NULL); - EX_LBM_CHK(err); + /* Initialize context atrributes and create context */ + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); - /* Create receiver for receiving request and sending response */ - err = lbm_rcv_topic_attr_create(&rattr); - EX_LBM_CHK(err); + /* Create receiver for receiving request and sending response */ + err = lbm_rcv_topic_attr_create(&rattr); + EX_LBM_CHK(err); - srccb.create_func = new_src_notification_callback; - srccb.delete_func = src_delete_notification_callback; + srccb.create_func = new_src_notification_callback; + srccb.delete_func = src_delete_notification_callback; - err = lbm_rcv_topic_attr_setopt(rattr, "source_notification_function", &srccb, sizeof(srccb)); - EX_LBM_CHK(err); + err = lbm_rcv_topic_attr_setopt(rattr, "source_notification_function", &srccb, sizeof(srccb)); + EX_LBM_CHK(err); - err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", rattr); + err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", rattr); EX_LBM_CHK(err); - err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); - EX_LBM_CHK(err); + err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); + EX_LBM_CHK(err); - while (1) { } + /* Wait forever (or until control-c). */ + while (1) { } - err = lbm_rcv_delete(rcv); - EX_LBM_CHK(err); + err = lbm_rcv_delete(rcv); + EX_LBM_CHK(err); - err = lbm_context_delete(ctx); - EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); #if defined(_MSC_VER) - /* Windows-specific cleanup overhead */ - WSACleanup(); + /* Windows-specific cleanup overhead */ + WSACleanup(); #endif - return 0; + return 0; } /* main */ diff --git a/source_notify_callbacks/c/source_notify_callbacks.sldoc.html b/source_notify_callbacks/c/source_notify_callbacks.sldoc.html index f86a869..7d0644a 100644 --- a/source_notify_callbacks/c/source_notify_callbacks.sldoc.html +++ b/source_notify_callbacks/c/source_notify_callbacks.sldoc.html @@ -48,9 +48,10 @@

Per-source State Information

associated with that source. In this simple example, just keep a per-source count of messages received.

-00016  typedef struct source_state_s {
-00017    int msgs_rcvd;  /* We want to track message count from each source sending to the topic. */
-00018  } source_state_t;
+00036  /* State structure associated with each source the receiver is joined to. */
+00037  typedef struct source_state_s {
+00038      int msgs_rcvd;  /* Track message count from each source. */
+00039  } source_state_t;
 
@@ -64,14 +65,14 @@

Delivery Controller Create Callback

to be received, unlike this function which just requires a TIR on an interested source.

-00029  void *new_src_notification_callback(const char *source_name, void *clientd)
-00030  {
-00031          source_state_t *source_state = (source_state_t *)malloc(sizeof(source_state_t));
-00032          source_state->msgs_rcvd = 0;
-00033  
-00034          printf("Delivery Controller Created: %s\n", source_name);
-00035          return source_state;  /* This will be available in the receive callback as msg->source_clientd. */
-00036  }
+00051  void *new_src_notification_callback(const char *source_name, void *clientd)
+00052  {
+00053      source_state_t *source_state = (source_state_t *)malloc(sizeof(source_state_t));
+00054      source_state->msgs_rcvd = 0;
+00055  
+00056      printf("Delivery Controller Created: %s\n", source_name);
+00057      return source_state;  /* This will be available in the receive callback as msg->source_clientd. */
+00058  }  /* new_src_notification_callback */
 
@@ -82,13 +83,13 @@

Delivery Controller Delete Callback

to rely on this callback versus EOS, because this callback is guaranteed if no data has been received for the topic.

-00038  int src_delete_notification_callback(const char *source_name, void *clientd, void* src_clientd )
-00039  {
-00040          free(src_clientd);  /* This was created by new_src_notification_callback() */
-00041  
-00042          printf("Delivery Controller Deleted: %s\n", source_name);
-00043          return 0;
-00044  }
+00061  int src_delete_notification_callback(const char *source_name, void *clientd, void* src_clientd )
+00062  {
+00063      free(src_clientd);  /* This was created by new_src_notification_callback() */
+00064  
+00065      printf("Delivery Controller Deleted: %s\n", source_name);
+00066      return 0;
+00067  }  /* src_delete_notification_callback */
 
@@ -96,29 +97,29 @@

Standard Receive Callback

This is the standard receiver callback where messages are processed, as well as events like BOS and EOS

-00047  int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd)
-00048  {
-00049          int err;
-00050          source_state_t *source_state = (source_state_t *)msg->source_clientd;
-00051  
-00052          switch (msg->type) {
-00053          case LBM_MSG_DATA:
-00054                  source_state->msgs_rcvd ++;
-00055                  printf("[%s][%s], Received message %d\n", msg->topic_name, msg->source, source_state->msgs_rcvd);
-00056                  break;
-00057          case LBM_MSG_BOS:
-00058                  printf("[%s][%s], Beginning of Transport Session\n", msg->topic_name, msg->source);
-00059                  break;
-00060          case LBM_MSG_EOS:
-00061                  printf("[%s][%s], End of Transport Session\n", msg->topic_name, msg->source);
-00062                  break;
-00063          default:
-00064                  printf("Other event, type=%x\n", msg->type);
-00065                  break;
-00066          }
-00067  
-00068          return 0;
-00069  }
+00070  /* Callback used to handle request message for receiver */
+00071  int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd)
+00072  {
+00073      source_state_t *source_state = (source_state_t *)msg->source_clientd;
+00074  
+00075      switch (msg->type) {
+00076      case LBM_MSG_DATA:
+00077          source_state->msgs_rcvd ++;
+00078          printf("[%s][%s], Received message %d\n", msg->topic_name, msg->source, source_state->msgs_rcvd);
+00079          break;
+00080      case LBM_MSG_BOS:
+00081          printf("[%s][%s], Beginning of Transport Session\n", msg->topic_name, msg->source);
+00082          break;
+00083      case LBM_MSG_EOS:
+00084          printf("[%s][%s], End of Transport Session\n", msg->topic_name, msg->source);
+00085          break;
+00086      default:
+00087          printf("Other event, type=%x\n", msg->type);
+00088          break;
+00089      }
+00090  
+00091      return 0;
+00092  }  /* rcv_handle_msg */
 
@@ -136,7 +137,7 @@

Declare Notify Structure

must be used to set the user callbacks which have been defined above.

-00078          lbm_rcv_src_notification_func_t srccb;  /* Source notify callback structure */
+00101      lbm_rcv_src_notification_func_t srccb;  /* Source notify callback structure */
 
@@ -145,11 +146,11 @@

Set the Callbacks and Configure Parameter

the API to configure the paramter:

-00100          srccb.create_func = new_src_notification_callback;
-00101          srccb.delete_func = src_delete_notification_callback;
-00102  
-00103          err = lbm_rcv_topic_attr_setopt(rattr, "source_notification_function", &srccb, sizeof(srccb));
-00104          EX_LBM_CHK(err);
+00123      srccb.create_func = new_src_notification_callback;
+00124      srccb.delete_func = src_delete_notification_callback;
+00125  
+00126      err = lbm_rcv_topic_attr_setopt(rattr, "source_notification_function", &srccb, sizeof(srccb));
+00127      EX_LBM_CHK(err);
 
@@ -158,19 +159,19 @@

Includes

are not necessary for Linux only applications

-00002  #include <stdio.h>
-00003  
-00004  #if defined(_MSC_VER)
-00005  /* Windows-only includes */
-00006  #include <winsock2.h>
-00007  #define SLEEP(s) Sleep((s)*1000)
-00008  #else
-00009  /* Unix-only includes */
-00010  #include <stdlib.h>
-00011  #include <unistd.h>
-00012  #define SLEEP(s) sleep(s)
-00013  #endif
-00014  #include <lbm/lbm.h>
+00022  #include <stdio.h>
+00023  
+00024  #if defined(_MSC_VER)
+00025  /* Windows-only includes */
+00026  #include <winsock2.h>
+00027  #define SLEEP(s) Sleep((s)*1000)
+00028  #else
+00029  /* Unix-only includes */
+00030  #include <stdlib.h>
+00031  #include <unistd.h>
+00032  #define SLEEP(s) sleep(s)
+00033  #endif
+00034  #include <lbm/lbm.h>
 
@@ -178,16 +179,16 @@

Windows Only

Windows applications must initialize the Winsock library to utilize sockets.

-00081  #if defined(_WIN32)
-00082          /* windows-specific code */
-00083          WSADATA wsadata;
-00084          int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata);
-00085          if (wsStat != 0)
-00086          {
-00087                  printf("line %d: wsStat=%d\n",__LINE__,wsStat);
-00088                  exit(1);
-00089          }
-00090  #endif
+00104  #if defined(_WIN32)
+00105      /* windows-specific code */
+00106      WSADATA wsadata;
+00107      int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata);
+00108      if (wsStat != 0)
+00109      {
+00110          printf("line %d: wsStat=%d\n",__LINE__,wsStat);
+00111          exit(1);
+00112      }
+00113  #endif
 
diff --git a/source_notify_callbacks/c/source_notify_callbacks_c.slsrc b/source_notify_callbacks/c/source_notify_callbacks_c.slsrc index 3fe959e..edc8456 100644 --- a/source_notify_callbacks/c/source_notify_callbacks_c.slsrc +++ b/source_notify_callbacks/c/source_notify_callbacks_c.slsrc @@ -1,4 +1,24 @@ -/* source_notify_callback.c - http://ultramessaging.github.io/UMExamples */ +/* source_notify_callbacks.c - see http://ultramessaging.github.io/UMExamples/source_notify_callbacks/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ + /* =semlit,block,includes=*/ #include @@ -16,126 +36,130 @@ /* =semlit,endblock,includes=*/ /* =semlit,block,state=*/ +/* State structure associated with each source the receiver is joined to. */ typedef struct source_state_s { - int msgs_rcvd; /* We want to track message count from each source sending to the topic. */ + int msgs_rcvd; /* Track message count from each source. */ } source_state_t; /* =semlit,endblock,state=*/ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) + /* =semlit,block,create_cb=*/ void *new_src_notification_callback(const char *source_name, void *clientd) { - source_state_t *source_state = (source_state_t *)malloc(sizeof(source_state_t)); - source_state->msgs_rcvd = 0; + source_state_t *source_state = (source_state_t *)malloc(sizeof(source_state_t)); + source_state->msgs_rcvd = 0; - printf("Delivery Controller Created: %s\n", source_name); - return source_state; /* This will be available in the receive callback as msg->source_clientd. */ -} + printf("Delivery Controller Created: %s\n", source_name); + return source_state; /* This will be available in the receive callback as msg->source_clientd. */ +} /* new_src_notification_callback */ /* =semlit,endblock,create_cb=*/ + /* =semlit,block,delete_cb=*/ int src_delete_notification_callback(const char *source_name, void *clientd, void* src_clientd ) { - free(src_clientd); /* This was created by new_src_notification_callback() */ + free(src_clientd); /* This was created by new_src_notification_callback() */ - printf("Delivery Controller Deleted: %s\n", source_name); - return 0; -} + printf("Delivery Controller Deleted: %s\n", source_name); + return 0; +} /* src_delete_notification_callback */ /* =semlit,endblock,delete_cb=*/ -/* Callback used to handle request message for receiver */ + /* =semlit,block,receive_cb=*/ +/* Callback used to handle request message for receiver */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { - int err; - source_state_t *source_state = (source_state_t *)msg->source_clientd; - - switch (msg->type) { - case LBM_MSG_DATA: - source_state->msgs_rcvd ++; - printf("[%s][%s], Received message %d\n", msg->topic_name, msg->source, source_state->msgs_rcvd); - break; - case LBM_MSG_BOS: - printf("[%s][%s], Beginning of Transport Session\n", msg->topic_name, msg->source); - break; - case LBM_MSG_EOS: - printf("[%s][%s], End of Transport Session\n", msg->topic_name, msg->source); - break; - default: - printf("Other event, type=%x\n", msg->type); - break; - } - - return 0; -} + source_state_t *source_state = (source_state_t *)msg->source_clientd; + + switch (msg->type) { + case LBM_MSG_DATA: + source_state->msgs_rcvd ++; + printf("[%s][%s], Received message %d\n", msg->topic_name, msg->source, source_state->msgs_rcvd); + break; + case LBM_MSG_BOS: + printf("[%s][%s], Beginning of Transport Session\n", msg->topic_name, msg->source); + break; + case LBM_MSG_EOS: + printf("[%s][%s], End of Transport Session\n", msg->topic_name, msg->source); + break; + default: + printf("Other event, type=%x\n", msg->type); + break; + } + + return 0; +} /* rcv_handle_msg */ /* =semlit,endblock,receive_cb=*/ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ - lbm_topic_t *rtopic; /* Receiver Topic object */ - lbm_rcv_topic_attr_t * rattr; /* Receiver attribute object */ + lbm_context_t *ctx; /* Context object */ + lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ + lbm_topic_t *rtopic; /* Receiver Topic object */ + lbm_rcv_topic_attr_t * rattr; /* Receiver attribute object */ /* =semlit,block,srccb_var=*/ - lbm_rcv_src_notification_func_t srccb; /* Source notify callback structure */ + lbm_rcv_src_notification_func_t srccb; /* Source notify callback structure */ /* =semlit,endblock,srccb_var=*/ - int err; /* Used for checking API return codes */ + int err; /* =semlit,block,windows=*/ #if defined(_WIN32) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + exit(1); + } #endif /* =semlit,endblock,windows=*/ - /* Initialize context atrributes and create context */ - err = lbm_context_create(&ctx, NULL, NULL, NULL); - EX_LBM_CHK(err); + /* Initialize context atrributes and create context */ + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); - /* Create receiver for receiving request and sending response */ - err = lbm_rcv_topic_attr_create(&rattr); - EX_LBM_CHK(err); + /* Create receiver for receiving request and sending response */ + err = lbm_rcv_topic_attr_create(&rattr); + EX_LBM_CHK(err); /* =semlit,block,set_cbs=*/ - srccb.create_func = new_src_notification_callback; - srccb.delete_func = src_delete_notification_callback; + srccb.create_func = new_src_notification_callback; + srccb.delete_func = src_delete_notification_callback; - err = lbm_rcv_topic_attr_setopt(rattr, "source_notification_function", &srccb, sizeof(srccb)); - EX_LBM_CHK(err); + err = lbm_rcv_topic_attr_setopt(rattr, "source_notification_function", &srccb, sizeof(srccb)); + EX_LBM_CHK(err); /* =semlit,endblock,set_cbs=*/ - err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", rattr); + err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", rattr); EX_LBM_CHK(err); - err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); - EX_LBM_CHK(err); + err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); + EX_LBM_CHK(err); - while (1) { } + /* Wait forever (or until control-c). */ + while (1) { } - err = lbm_rcv_delete(rcv); - EX_LBM_CHK(err); + err = lbm_rcv_delete(rcv); + EX_LBM_CHK(err); - err = lbm_context_delete(ctx); - EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); #if defined(_MSC_VER) - /* Windows-specific cleanup overhead */ - WSACleanup(); + /* Windows-specific cleanup overhead */ + WSACleanup(); #endif - return 0; + return 0; } /* main */ diff --git a/source_notify_callbacks/c/source_notify_callbacks_c.slsrc.html b/source_notify_callbacks/c/source_notify_callbacks_c.slsrc.html index 9b56dd4..5055c02 100644 --- a/source_notify_callbacks/c/source_notify_callbacks_c.slsrc.html +++ b/source_notify_callbacks/c/source_notify_callbacks_c.slsrc.html @@ -17,97 +17,97 @@
00001 -00002 -00003 -00004 -00005 -00006 -00007 -00008 -00009 -00010 -00011 -00012 -00013 -00014 +00002 +00003 +00004 +00005 +00006 +00007 +00008 +00009 +00010 +00011 +00012 +00013 +00014 00015 -00016 -00017 -00018 +00016 +00017 +00018 00019 00020 00021 -00022 -00023 -00024 -00025 -00026 -00027 -00028 -00029 -00030 -00031 -00032 -00033 -00034 -00035 -00036 -00037 -00038 -00039 -00040 -00041 -00042 -00043 -00044 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 +00036 +00037 +00038 +00039 +00040 +00041 +00042 +00043 +00044 00045 00046 -00047 -00048 -00049 -00050 -00051 -00052 -00053 -00054 -00055 -00056 -00057 -00058 -00059 -00060 -00061 -00062 -00063 -00064 -00065 -00066 -00067 -00068 -00069 -00070 -00071 -00072 -00073 -00074 -00075 -00076 -00077 -00078 -00079 -00080 -00081 -00082 -00083 -00084 -00085 -00086 -00087 -00088 -00089 -00090 -00091 -00092 +00047 +00048 +00049 +00050 +00051 +00052 +00053 +00054 +00055 +00056 +00057 +00058 +00059 +00060 +00061 +00062 +00063 +00064 +00065 +00066 +00067 +00068 +00069 +00070 +00071 +00072 +00073 +00074 +00075 +00076 +00077 +00078 +00079 +00080 +00081 +00082 +00083 +00084 +00085 +00086 +00087 +00088 +00089 +00090 +00091 +00092 00093 00094 00095 @@ -115,20 +115,20 @@ 00097 00098 00099 -00100 -00101 -00102 -00103 -00104 -00105 -00106 -00107 -00108 -00109 -00110 -00111 -00112 -00113 +00100 +00101 +00102 +00103 +00104 +00105 +00106 +00107 +00108 +00109 +00110 +00111 +00112 +00113 00114 00115 00116 @@ -138,10 +138,54 @@ 00120 00121 00122 -00123 -00124 -00125 - /* source_notify_callback.c - http://ultramessaging.github.io/UMExamples */ +00123 +00124 +00125 +00126 +00127 +00128 +00129 +00130 +00131 +00132 +00133 +00134 +00135 +00136 +00137 +00138 +00139 +00140 +00141 +00142 +00143 +00144 +00145 +00146 +00147 +00148 +00149 + /* source_notify_callbacks.c - see http://ultramessaging.github.io/UMExamples/source_notify_callbacks/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ + #include <stdio.h> #if defined(_MSC_VER) @@ -156,115 +200,119 @@ #endif #include <lbm/lbm.h> - typedef struct source_state_s { - int msgs_rcvd; /* We want to track message count from each source sending to the topic. */ + /* State structure associated with each source the receiver is joined to. */ + typedef struct source_state_s { + int msgs_rcvd; /* Track message count from each source. */ } source_state_t; /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) + void *new_src_notification_callback(const char *source_name, void *clientd) { - source_state_t *source_state = (source_state_t *)malloc(sizeof(source_state_t)); - source_state->msgs_rcvd = 0; + source_state_t *source_state = (source_state_t *)malloc(sizeof(source_state_t)); + source_state->msgs_rcvd = 0; + + printf("Delivery Controller Created: %s\n", source_name); + return source_state; /* This will be available in the receive callback as msg->source_clientd. */ + } /* new_src_notification_callback */ - printf("Delivery Controller Created: %s\n", source_name); - return source_state; /* This will be available in the receive callback as msg->source_clientd. */ - } int src_delete_notification_callback(const char *source_name, void *clientd, void* src_clientd ) { - free(src_clientd); /* This was created by new_src_notification_callback() */ + free(src_clientd); /* This was created by new_src_notification_callback() */ - printf("Delivery Controller Deleted: %s\n", source_name); - return 0; - } + printf("Delivery Controller Deleted: %s\n", source_name); + return 0; + } /* src_delete_notification_callback */ - /* Callback used to handle request message for receiver */ - int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) + + /* Callback used to handle request message for receiver */ + int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { - int err; - source_state_t *source_state = (source_state_t *)msg->source_clientd; + source_state_t *source_state = (source_state_t *)msg->source_clientd; + + switch (msg->type) { + case LBM_MSG_DATA: + source_state->msgs_rcvd ++; + printf("[%s][%s], Received message %d\n", msg->topic_name, msg->source, source_state->msgs_rcvd); + break; + case LBM_MSG_BOS: + printf("[%s][%s], Beginning of Transport Session\n", msg->topic_name, msg->source); + break; + case LBM_MSG_EOS: + printf("[%s][%s], End of Transport Session\n", msg->topic_name, msg->source); + break; + default: + printf("Other event, type=%x\n", msg->type); + break; + } - switch (msg->type) { - case LBM_MSG_DATA: - source_state->msgs_rcvd ++; - printf("[%s][%s], Received message %d\n", msg->topic_name, msg->source, source_state->msgs_rcvd); - break; - case LBM_MSG_BOS: - printf("[%s][%s], Beginning of Transport Session\n", msg->topic_name, msg->source); - break; - case LBM_MSG_EOS: - printf("[%s][%s], End of Transport Session\n", msg->topic_name, msg->source); - break; - default: - printf("Other event, type=%x\n", msg->type); - break; - } + return 0; + } /* rcv_handle_msg */ - return 0; - } int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ - lbm_topic_t *rtopic; /* Receiver Topic object */ - lbm_rcv_topic_attr_t * rattr; /* Receiver attribute object */ - lbm_rcv_src_notification_func_t srccb; /* Source notify callback structure */ - int err; /* Used for checking API return codes */ + lbm_context_t *ctx; /* Context object */ + lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ + lbm_topic_t *rtopic; /* Receiver Topic object */ + lbm_rcv_topic_attr_t * rattr; /* Receiver attribute object */ + lbm_rcv_src_notification_func_t srccb; /* Source notify callback structure */ + int err; #if defined(_WIN32) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + exit(1); + } #endif - /* Initialize context atrributes and create context */ - err = lbm_context_create(&ctx, NULL, NULL, NULL); - EX_LBM_CHK(err); + /* Initialize context atrributes and create context */ + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); - /* Create receiver for receiving request and sending response */ - err = lbm_rcv_topic_attr_create(&rattr); - EX_LBM_CHK(err); + /* Create receiver for receiving request and sending response */ + err = lbm_rcv_topic_attr_create(&rattr); + EX_LBM_CHK(err); - srccb.create_func = new_src_notification_callback; - srccb.delete_func = src_delete_notification_callback; + srccb.create_func = new_src_notification_callback; + srccb.delete_func = src_delete_notification_callback; - err = lbm_rcv_topic_attr_setopt(rattr, "source_notification_function", &srccb, sizeof(srccb)); - EX_LBM_CHK(err); + err = lbm_rcv_topic_attr_setopt(rattr, "source_notification_function", &srccb, sizeof(srccb)); + EX_LBM_CHK(err); - err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", rattr); + err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", rattr); EX_LBM_CHK(err); - err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); - EX_LBM_CHK(err); + err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); + EX_LBM_CHK(err); - while (1) { } + /* Wait forever (or until control-c). */ + while (1) { } - err = lbm_rcv_delete(rcv); - EX_LBM_CHK(err); + err = lbm_rcv_delete(rcv); + EX_LBM_CHK(err); - err = lbm_context_delete(ctx); - EX_LBM_CHK(err); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); #if defined(_MSC_VER) - /* Windows-specific cleanup overhead */ - WSACleanup(); + /* Windows-specific cleanup overhead */ + WSACleanup(); #endif - return 0; + return 0; } /* main */
diff --git a/src_rsp/c/client.c b/src_rsp/c/client.c index 0b77bbc..aa70c6a 100644 --- a/src_rsp/c/client.c +++ b/src_rsp/c/client.c @@ -1,4 +1,4 @@ -/* client.c +/* client.c - see http://ultramessaging.github.io/UMExamples/client/c/index.html * * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. * Permission is granted to licensees to use @@ -25,12 +25,12 @@ #if defined(_MSC_VER) /* Windows-only includes */ #include -#define MSLEEP(s) Sleep(s) +#define MSLEEP(s) Sleep(s) /* Portable millisecond sleep. */ #else /* Unix-only includes */ #include #include -#define MSLEEP(s) usleep((s) * 1000) +#define MSLEEP(s) usleep((s) * 1000) /* Portable millisecond sleep. */ #endif #include @@ -49,24 +49,13 @@ typedef struct req_hdr_s { } req_hdr_t; -#define E(E_err) do { \ - if ((E_err) < 0) { \ - fprintf(stderr, "Error, %s:%d: %s: %s\n", \ - __FILE__, __LINE__, #E_err, lbm_errmsg()); \ - fflush(stderr); \ - abort(); \ - } \ -} while (0) - - -/* Null check. */ -#define N(N_ptr) do { \ - if ((N_ptr) == NULL) { \ - fprintf(stderr, "Error, %s:%d: '%s' is NULL\n", \ - __FILE__, __LINE__, #N_ptr); \ - fflush(stderr); \ - abort(); /* core dump */ \ - } \ +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) @@ -116,6 +105,7 @@ int main(int argc, char **argv) lbm_context_t *ctx; server_t server; /* State information for the server. */ char response_topic_name[256]; + int err; /* Get (pretty much) unique client name. */ sprintf(response_topic_name, "Client.%lx.Response", (long)getpid()); @@ -136,47 +126,53 @@ int main(int argc, char **argv) server.rcv = NULL; /* Receiver for responses from server. */ server.state = 0; /* Waiting for registration. */ - E(lbm_config("client.cfg")); + err = lbm_config("client.cfg"); + EX_LBM_CHK(err); - E(lbm_context_create(&ctx, NULL, NULL, NULL)); + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); server.ctx = ctx; /* Create source to send requests to server. */ { lbm_topic_t *topic; - E(lbm_src_topic_alloc(&topic, ctx, server.topic_name, NULL)); - E(lbm_src_create(&server.src, ctx, topic, NULL, NULL, NULL)); + err = lbm_src_topic_alloc(&topic, ctx, server.topic_name, NULL); + EX_LBM_CHK(err); + err = lbm_src_create(&server.src, ctx, topic, NULL, NULL, NULL); + EX_LBM_CHK(err); } /* Create receiver for responses from server. */ { lbm_topic_t *topic; - E(lbm_rcv_topic_lookup(&topic, ctx, response_topic_name, NULL)); - E(lbm_rcv_create(&server.rcv, ctx, topic, response_rcv_cb, &server, NULL)); + err = lbm_rcv_topic_lookup(&topic, ctx, response_topic_name, NULL); + EX_LBM_CHK(err); + err = lbm_rcv_create(&server.rcv, ctx, topic, response_rcv_cb, &server, NULL); + EX_LBM_CHK(err); } - MSLEEP(1); /* Try to reduce the number of tries to register. */ - /* Register with the server. May need multiple tries. */ { int try_cnt = 0; - int backoff_delay = 2; + int backoff_delay; char register_msg[257]; sprintf(register_msg, "r%s", response_topic_name); + backoff_delay = 1; /* In milliseconds. */ + MSLEEP(backoff_delay); /* Let TR complete. */ while (server.state == 0) { try_cnt ++; - E(lbm_src_send(server.src, register_msg, - strlen(register_msg) + 1, LBM_MSG_FLUSH | LBM_SRC_BLOCK)); - printf("Sent '%s' to %s; sleep for %d ms\n", register_msg, - server.topic_name, backoff_delay); + err = lbm_src_send(server.src, register_msg, + strlen(register_msg) + 1, LBM_MSG_FLUSH | LBM_SRC_BLOCK); + EX_LBM_CHK(err); + printf("Sent '%s' to %s\n", register_msg, server.topic_name); /* Exponential backoff, to max of 1 sec. */ - MSLEEP(backoff_delay); backoff_delay *= 2; /* Exponential backoff to max of 1 sec. */ if (backoff_delay > 1000) { backoff_delay = 1000; } + MSLEEP(backoff_delay); /* Wait for server response. */ } printf("Took %d tries to register with server.\n", try_cnt); } @@ -197,17 +193,21 @@ int main(int argc, char **argv) /* The application message is copied in after the header. */ strcpy(&send_buf[sizeof(req_hdr_t)], request_msg); - E(lbm_src_send(server.src, send_buf, strlen(send_buf) + 1, - LBM_MSG_FLUSH | LBM_SRC_NONBLOCK)); + err = lbm_src_send(server.src, send_buf, strlen(send_buf) + 1, + LBM_MSG_FLUSH | LBM_SRC_NONBLOCK); + EX_LBM_CHK(err); MSLEEP(1000); } } printf("Client exiting.\n"); - E(lbm_rcv_delete(server.rcv)); - E(lbm_src_delete(server.src)); + err = lbm_rcv_delete(server.rcv); + EX_LBM_CHK(err); + err = lbm_src_delete(server.src); + EX_LBM_CHK(err); - E(lbm_context_delete(ctx)); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); #if defined(_MSC_VER) WSACleanup(); diff --git a/src_rsp/c/client_c.slsrc b/src_rsp/c/client_c.slsrc index 1216e67..0897587 100644 --- a/src_rsp/c/client_c.slsrc +++ b/src_rsp/c/client_c.slsrc @@ -1,4 +1,4 @@ -/* client.c +/* client.c - see http://ultramessaging.github.io/UMExamples/client/c/index.html * * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. * Permission is granted to licensees to use @@ -25,12 +25,12 @@ #if defined(_MSC_VER) /* Windows-only includes */ #include -#define MSLEEP(s) Sleep(s) +#define MSLEEP(s) Sleep(s) /* Portable millisecond sleep. */ #else /* Unix-only includes */ #include #include -#define MSLEEP(s) usleep((s) * 1000) +#define MSLEEP(s) usleep((s) * 1000) /* Portable millisecond sleep. */ #endif #include @@ -49,24 +49,13 @@ typedef struct req_hdr_s { } req_hdr_t; -#define E(E_err) do { \ - if ((E_err) < 0) { \ - fprintf(stderr, "Error, %s:%d: %s: %s\n", \ - __FILE__, __LINE__, #E_err, lbm_errmsg()); \ - fflush(stderr); \ - abort(); \ - } \ -} while (0) - - -/* Null check. */ -#define N(N_ptr) do { \ - if ((N_ptr) == NULL) { \ - fprintf(stderr, "Error, %s:%d: '%s' is NULL\n", \ - __FILE__, __LINE__, #N_ptr); \ - fflush(stderr); \ - abort(); /* core dump */ \ - } \ +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) @@ -118,6 +107,7 @@ int main(int argc, char **argv) lbm_context_t *ctx; server_t server; /* State information for the server. */ char response_topic_name[256]; + int err; /* =semlit,block,client_name= */ /* Get (pretty much) unique client name. */ @@ -142,17 +132,21 @@ int main(int argc, char **argv) server.rcv = NULL; /* Receiver for responses from server. */ server.state = 0; /* Waiting for registration. */ - E(lbm_config("client.cfg")); + err = lbm_config("client.cfg"); + EX_LBM_CHK(err); - E(lbm_context_create(&ctx, NULL, NULL, NULL)); + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); server.ctx = ctx; /* =semlit,block,req_src_create= */ /* Create source to send requests to server. */ { lbm_topic_t *topic; - E(lbm_src_topic_alloc(&topic, ctx, server.topic_name, NULL)); - E(lbm_src_create(&server.src, ctx, topic, NULL, NULL, NULL)); + err = lbm_src_topic_alloc(&topic, ctx, server.topic_name, NULL); + EX_LBM_CHK(err); + err = lbm_src_create(&server.src, ctx, topic, NULL, NULL, NULL); + EX_LBM_CHK(err); } /* =semlit,endblock,req_src_create= */ @@ -160,36 +154,38 @@ int main(int argc, char **argv) /* Create receiver for responses from server. */ { lbm_topic_t *topic; - E(lbm_rcv_topic_lookup(&topic, ctx, response_topic_name, NULL)); - E(lbm_rcv_create(&server.rcv, ctx, topic, response_rcv_cb, &server, NULL)); + err = lbm_rcv_topic_lookup(&topic, ctx, response_topic_name, NULL); + EX_LBM_CHK(err); + err = lbm_rcv_create(&server.rcv, ctx, topic, response_rcv_cb, &server, NULL); + EX_LBM_CHK(err); } /* =semlit,endblock,rsp_rcv_create= */ - MSLEEP(1); /* Try to reduce the number of tries to register. */ - /* Register with the server. May need multiple tries. */ { int try_cnt = 0; - int backoff_delay = 2; + int backoff_delay; /* =semlit,block,register_msg= */ char register_msg[257]; sprintf(register_msg, "r%s", response_topic_name); /* =semlit,endblock,register_msg= */ /* =semlit,block,register_loop= */ + backoff_delay = 1; /* In milliseconds. */ + MSLEEP(backoff_delay); /* Let TR complete. */ while (server.state == 0) { try_cnt ++; - E(lbm_src_send(server.src, register_msg, - strlen(register_msg) + 1, LBM_MSG_FLUSH | LBM_SRC_BLOCK)); - printf("Sent '%s' to %s; sleep for %d ms\n", register_msg, - server.topic_name, backoff_delay); + err = lbm_src_send(server.src, register_msg, + strlen(register_msg) + 1, LBM_MSG_FLUSH | LBM_SRC_BLOCK); + EX_LBM_CHK(err); + printf("Sent '%s' to %s\n", register_msg, server.topic_name); /* Exponential backoff, to max of 1 sec. */ - MSLEEP(backoff_delay); backoff_delay *= 2; /* Exponential backoff to max of 1 sec. */ if (backoff_delay > 1000) { backoff_delay = 1000; } + MSLEEP(backoff_delay); /* Wait for server response. */ } printf("Took %d tries to register with server.\n", try_cnt); /* =semlit,endblock,register_loop= */ @@ -214,18 +210,22 @@ int main(int argc, char **argv) /* The application message is copied in after the header. */ strcpy(&send_buf[sizeof(req_hdr_t)], request_msg); - E(lbm_src_send(server.src, send_buf, strlen(send_buf) + 1, - LBM_MSG_FLUSH | LBM_SRC_NONBLOCK)); + err = lbm_src_send(server.src, send_buf, strlen(send_buf) + 1, + LBM_MSG_FLUSH | LBM_SRC_NONBLOCK); + EX_LBM_CHK(err); MSLEEP(1000); } /* =semlit,endblock,req_sends= */ } printf("Client exiting.\n"); - E(lbm_rcv_delete(server.rcv)); - E(lbm_src_delete(server.src)); + err = lbm_rcv_delete(server.rcv); + EX_LBM_CHK(err); + err = lbm_src_delete(server.src); + EX_LBM_CHK(err); - E(lbm_context_delete(ctx)); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); #if defined(_MSC_VER) WSACleanup(); diff --git a/src_rsp/c/client_c.slsrc.html b/src_rsp/c/client_c.slsrc.html index c01c35e..d474a0b 100644 --- a/src_rsp/c/client_c.slsrc.html +++ b/src_rsp/c/client_c.slsrc.html @@ -85,25 +85,25 @@ 00067 00068 00069 -00070 -00071 -00072 -00073 -00074 -00075 -00076 -00077 +00070 +00071 +00072 +00073 +00074 +00075 +00076 +00077 00078 00079 00080 -00081 -00082 -00083 -00084 -00085 -00086 -00087 -00088 +00081 +00082 +00083 +00084 +00085 +00086 +00087 +00088 00089 00090 00091 @@ -125,8 +125,8 @@ 00107 00108 00109 -00110 -00111 +00110 +00111 00112 00113 00114 @@ -135,11 +135,11 @@ 00117 00118 00119 -00120 -00121 +00120 +00121 00122 00123 -00124 +00124 00125 00126 00127 @@ -149,39 +149,39 @@ 00131 00132 00133 -00134 +00134 00135 -00136 -00137 -00138 -00139 -00140 -00141 -00142 -00143 -00144 -00145 -00146 -00147 -00148 -00149 -00150 +00136 +00137 +00138 +00139 +00140 +00141 +00142 +00143 +00144 +00145 +00146 +00147 +00148 +00149 +00150 00151 00152 -00153 -00154 -00155 -00156 +00153 +00154 +00155 +00156 00157 -00158 -00159 +00158 +00159 00160 -00161 -00162 -00163 -00164 -00165 -00166 +00161 +00162 +00163 +00164 +00165 +00166 00167 00168 00169 @@ -193,21 +193,21 @@ 00175 00176 00177 -00178 -00179 -00180 -00181 +00178 +00179 +00180 +00181 00182 -00183 -00184 -00185 -00186 +00183 +00184 +00185 +00186 00187 -00188 -00189 -00190 -00191 -00192 +00188 +00189 +00190 +00191 +00192 00193 00194 00195 @@ -216,9 +216,9 @@ 00198 00199 00200 -00201 -00202 -00203 +00201 +00202 +00203 00204 00205 00206 @@ -233,7 +233,7 @@ 00215 00216 00217 - /* client.c + /* client.c - see http://ultramessaging.github.io/UMExamples/client/c/index.html * * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. * Permission is granted to licensees to use @@ -260,12 +260,12 @@ #if defined(_MSC_VER) /* Windows-only includes */ #include <winsock2.h> - #define MSLEEP(s) Sleep(s) + #define MSLEEP(s) Sleep(s) /* Portable millisecond sleep. */ #else /* Unix-only includes */ #include <stdlib.h> #include <unistd.h> - #define MSLEEP(s) usleep((s) * 1000) + #define MSLEEP(s) usleep((s) * 1000) /* Portable millisecond sleep. */ #endif #include <lbm/lbm.h> @@ -284,24 +284,13 @@ } req_hdr_t; - #define E(E_err) do { \ - if ((E_err) < 0) { \ - fprintf(stderr, "Error, %s:%d: %s: %s\n", \ - __FILE__, __LINE__, #E_err, lbm_errmsg()); \ - fflush(stderr); \ - abort(); \ - } \ - } while (0) - - - /* Null check. */ - #define N(N_ptr) do { \ - if ((N_ptr) == NULL) { \ - fprintf(stderr, "Error, %s:%d: '%s' is NULL\n", \ - __FILE__, __LINE__, #N_ptr); \ - fflush(stderr); \ - abort(); /* core dump */ \ - } \ + /* Example error checking macro. Include after each UM call. */ + #define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) @@ -351,6 +340,7 @@ lbm_context_t *ctx; server_t server; /* State information for the server. */ char response_topic_name[256]; + int err; /* Get (pretty much) unique client name. */ sprintf(response_topic_name, "Client.%lx.Response", (long)getpid()); @@ -371,47 +361,53 @@ server.rcv = NULL; /* Receiver for responses from server. */ server.state = 0; /* Waiting for registration. */ - E(lbm_config("client.cfg")); + err = lbm_config("client.cfg"); + EX_LBM_CHK(err); - E(lbm_context_create(&ctx, NULL, NULL, NULL)); + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); server.ctx = ctx; /* Create source to send requests to server. */ { lbm_topic_t *topic; - E(lbm_src_topic_alloc(&topic, ctx, server.topic_name, NULL)); - E(lbm_src_create(&server.src, ctx, topic, NULL, NULL, NULL)); + err = lbm_src_topic_alloc(&topic, ctx, server.topic_name, NULL); + EX_LBM_CHK(err); + err = lbm_src_create(&server.src, ctx, topic, NULL, NULL, NULL); + EX_LBM_CHK(err); } /* Create receiver for responses from server. */ { lbm_topic_t *topic; - E(lbm_rcv_topic_lookup(&topic, ctx, response_topic_name, NULL)); - E(lbm_rcv_create(&server.rcv, ctx, topic, response_rcv_cb, &server, NULL)); + err = lbm_rcv_topic_lookup(&topic, ctx, response_topic_name, NULL); + EX_LBM_CHK(err); + err = lbm_rcv_create(&server.rcv, ctx, topic, response_rcv_cb, &server, NULL); + EX_LBM_CHK(err); } - MSLEEP(1); /* Try to reduce the number of tries to register. */ - /* Register with the server. May need multiple tries. */ { int try_cnt = 0; - int backoff_delay = 2; + int backoff_delay; char register_msg[257]; sprintf(register_msg, "r%s", response_topic_name); - while (server.state == 0) { + backoff_delay = 1; /* In milliseconds. */ + MSLEEP(backoff_delay); /* Let TR complete. */ + while (server.state == 0) { try_cnt ++; - E(lbm_src_send(server.src, register_msg, - strlen(register_msg) + 1, LBM_MSG_FLUSH | LBM_SRC_BLOCK)); - printf("Sent '%s' to %s; sleep for %d ms\n", register_msg, - server.topic_name, backoff_delay); + err = lbm_src_send(server.src, register_msg, + strlen(register_msg) + 1, LBM_MSG_FLUSH | LBM_SRC_BLOCK); + EX_LBM_CHK(err); + printf("Sent '%s' to %s\n", register_msg, server.topic_name); /* Exponential backoff, to max of 1 sec. */ - MSLEEP(backoff_delay); backoff_delay *= 2; /* Exponential backoff to max of 1 sec. */ if (backoff_delay > 1000) { backoff_delay = 1000; } + MSLEEP(backoff_delay); /* Wait for server response. */ } printf("Took %d tries to register with server.\n", try_cnt); } @@ -432,17 +428,21 @@ /* The application message is copied in after the header. */ strcpy(&send_buf[sizeof(req_hdr_t)], request_msg); - E(lbm_src_send(server.src, send_buf, strlen(send_buf) + 1, - LBM_MSG_FLUSH | LBM_SRC_NONBLOCK)); + err = lbm_src_send(server.src, send_buf, strlen(send_buf) + 1, + LBM_MSG_FLUSH | LBM_SRC_NONBLOCK); + EX_LBM_CHK(err); MSLEEP(1000); } } printf("Client exiting.\n"); - E(lbm_rcv_delete(server.rcv)); - E(lbm_src_delete(server.src)); + err = lbm_rcv_delete(server.rcv); + EX_LBM_CHK(err); + err = lbm_src_delete(server.src); + EX_LBM_CHK(err); - E(lbm_context_delete(ctx)); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); #if defined(_MSC_VER) WSACleanup(); diff --git a/src_rsp/c/server.c b/src_rsp/c/server.c index 4ae1b6b..031f10b 100644 --- a/src_rsp/c/server.c +++ b/src_rsp/c/server.c @@ -1,4 +1,4 @@ -/* server.c +/* server.c - see http://ultramessaging.github.io/UMExamples/server/c/index.html * * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. * Permission is granted to licensees to use @@ -52,20 +52,17 @@ typedef struct client_s { char send_buf[MAX_RESP_SIZE + sizeof(req_hdr_t)]; } client_t; - -/* Very simplistic LBM error handling. */ -#define E(E_err) do { \ - if ((E_err) < 0) { \ - fprintf(stderr, "Error, %s:%d: '%s': %s\n", \ - __FILE__, __LINE__, #E_err, lbm_errmsg()); \ - fflush(stderr); \ - abort(); /* core dump */ \ - } \ +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) - -/* Null check. */ -#define N(N_ptr) do { \ +/* Error if null. */ +#define NULL_CHK(N_ptr) do { \ if ((N_ptr) == NULL) { \ fprintf(stderr, "Error, %s:%d: '%s' is NULL\n", \ __FILE__, __LINE__, #N_ptr); \ @@ -84,19 +81,25 @@ void handle_register(client_t *client, const char *client_resp_name) if (client->state == 1) { printf("Source '%s' re-confirmed\n", client->topic_name); /* Reply to client. */ - E(lbm_src_send(client->resp_src, "rOK", 4, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK)); + err = lbm_src_send(client->resp_src, "rOK", 4, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK); + EX_LBM_CHK(err); } else if (client->state == 0) { lbm_src_topic_attr_t * src_attr; lbm_topic_t *lbm_topic; /* Create source to send responses to client. */ - E(lbm_src_topic_attr_create(&src_attr)); - E(lbm_src_topic_attr_str_setopt(src_attr, "transport", "lbt-ru")); - E(lbm_src_topic_attr_str_setopt(src_attr, "transport_lbtru_port", "12070")); - E(lbm_src_topic_attr_str_setopt(src_attr, - "transport_source_side_filtering_behavior", "inclusion")); - E(lbm_src_topic_alloc(&lbm_topic, client->ctx, client_resp_name, src_attr)); + err = lbm_src_topic_attr_create(&src_attr); + EX_LBM_CHK(err); + err = lbm_src_topic_attr_str_setopt(src_attr, "transport", "lbt-ru"); + EX_LBM_CHK(err); + err = lbm_src_topic_attr_str_setopt(src_attr, "transport_lbtru_port", "12070"); + EX_LBM_CHK(err); + err = lbm_src_topic_attr_str_setopt(src_attr, + "transport_source_side_filtering_behavior", "inclusion"); + EX_LBM_CHK(err); + err = lbm_src_topic_alloc(&lbm_topic, client->ctx, client_resp_name, src_attr); + EX_LBM_CHK(err); /* The following create can fail if a new client joins with the same * response topic name as an existing client. Should handle this cleanly. */ err = lbm_src_create(&client->resp_src, client->ctx, lbm_topic, @@ -106,17 +109,21 @@ void handle_register(client_t *client, const char *client_resp_name) } else { client->state = 1; - client->topic_name = strdup(client_resp_name); N(client->topic_name); + client->topic_name = strdup(client_resp_name); + NULL_CHK(client->topic_name); printf("Source '%s' created\n", client->topic_name); } - E(lbm_src_topic_attr_delete(src_attr)); + err = lbm_src_topic_attr_delete(src_attr); + EX_LBM_CHK(err); } } /* handle_register */ void handle_req(client_t *client, req_hdr_t *req_hdr, const char *data, size_t len) { + int err; + /* Response message is put after the header. */ char *response_msg = &client->send_buf[sizeof(req_hdr_t)]; @@ -131,8 +138,9 @@ void handle_req(client_t *client, req_hdr_t *req_hdr, const char *data, size_t l strcpy(response_msg, data); /* Reply to client. */ - E(lbm_src_send(client->resp_src, client->send_buf, - strlen(client->send_buf) + 1, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK)); + err = lbm_src_send(client->resp_src, client->send_buf, + strlen(client->send_buf) + 1, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK); + EX_LBM_CHK(err); printf("sent response to '%s'.\n", client->topic_name); } /* handle_req */ @@ -186,11 +194,13 @@ int request_rcv_cb(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) void *start_client_source(const char *source_name, void *clientd) { lbm_context_t *ctx = (lbm_context_t *)clientd;; - client_t *new_client = (client_t *)malloc(sizeof(client_t)); N(new_client); + client_t *new_client = (client_t *)malloc(sizeof(client_t)); + NULL_CHK(new_client); new_client->state = 0; /* Waiting for register. */ new_client->topic_name = NULL; - new_client->source_name = strdup(source_name); N(new_client->source_name); + new_client->source_name = strdup(source_name); + NULL_CHK(new_client->source_name); new_client->ctx = ctx; new_client->resp_src = NULL; @@ -200,6 +210,8 @@ void *start_client_source(const char *source_name, void *clientd) int end_client_source(const char *source_name, void *clientd, void *source_clientd) { + int err; + if (source_clientd) { client_t *client = (client_t *)source_clientd; @@ -210,7 +222,8 @@ int end_client_source(const char *source_name, void *clientd, void *source_clien free(client->source_name); } - E(lbm_src_delete(client->resp_src)); + err = lbm_src_delete(client->resp_src); + EX_LBM_CHK(err); free(source_clientd); } @@ -223,6 +236,7 @@ int main(int argc, char **argv) { lbm_context_t *ctx; lbm_rcv_t *rcv; /* Receiver for requests from clients. */ + int err; #if defined(_MSC_VER) /* windows-specific code */ @@ -233,9 +247,11 @@ int main(int argc, char **argv) } #endif - E(lbm_config("serv.cfg")); + err = lbm_config("serv.cfg"); + EX_LBM_CHK(err); - E(lbm_context_create(&ctx, NULL, NULL, NULL)); + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); /* Create receiver for requests from clients. */ { @@ -243,20 +259,25 @@ int main(int argc, char **argv) lbm_rcv_topic_attr_t *rcv_attr; lbm_topic_t *topic; - E(lbm_rcv_topic_attr_create(&rcv_attr)); + err = lbm_rcv_topic_attr_create(&rcv_attr); + EX_LBM_CHK(err); /* Set up per-source state management. */ source_notification_function.create_func = start_client_source; source_notification_function.delete_func = end_client_source; source_notification_function.clientd = ctx; /* Pass this to start_client_source(). */ - E(lbm_rcv_topic_attr_setopt(rcv_attr, "source_notification_function", - &source_notification_function, sizeof(source_notification_function))); + err = lbm_rcv_topic_attr_setopt(rcv_attr, "source_notification_function", + &source_notification_function, sizeof(source_notification_function)); + EX_LBM_CHK(err); - E(lbm_rcv_topic_lookup(&topic, ctx, "Server1.Request", rcv_attr)); + err = lbm_rcv_topic_lookup(&topic, ctx, "Server1.Request", rcv_attr); + EX_LBM_CHK(err); /* Pass context object as clientd. */ - E(lbm_rcv_create(&rcv, ctx, topic, request_rcv_cb, ctx, NULL)); + err = lbm_rcv_create(&rcv, ctx, topic, request_rcv_cb, ctx, NULL); + EX_LBM_CHK(err); - E(lbm_rcv_topic_attr_delete(rcv_attr)); + err = lbm_rcv_topic_attr_delete(rcv_attr); + EX_LBM_CHK(err); } while (1) { @@ -264,13 +285,15 @@ int main(int argc, char **argv) } /* Finished all receiving from this topic, delete the receiver object. */ - E(lbm_rcv_delete(rcv)); + err = lbm_rcv_delete(rcv); + EX_LBM_CHK(err); /* Do not need to delete the topic object - LBM keeps track of topic * objects and deletes them as-needed. */ /* Finished with all LBM functions, delete the context object. */ - E(lbm_context_delete(ctx)); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); #if defined(_MSC_VER) WSACleanup(); diff --git a/src_rsp/c/server_c.slsrc b/src_rsp/c/server_c.slsrc index f4f834b..ef33652 100644 --- a/src_rsp/c/server_c.slsrc +++ b/src_rsp/c/server_c.slsrc @@ -1,4 +1,4 @@ -/* server.c +/* server.c - see http://ultramessaging.github.io/UMExamples/server/c/index.html * * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. * Permission is granted to licensees to use @@ -52,20 +52,17 @@ typedef struct client_s { char send_buf[MAX_RESP_SIZE + sizeof(req_hdr_t)]; } client_t; - -/* Very simplistic LBM error handling. */ -#define E(E_err) do { \ - if ((E_err) < 0) { \ - fprintf(stderr, "Error, %s:%d: '%s': %s\n", \ - __FILE__, __LINE__, #E_err, lbm_errmsg()); \ - fflush(stderr); \ - abort(); /* core dump */ \ - } \ +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) - -/* Null check. */ -#define N(N_ptr) do { \ +/* Error if null. */ +#define NULL_CHK(N_ptr) do { \ if ((N_ptr) == NULL) { \ fprintf(stderr, "Error, %s:%d: '%s' is NULL\n", \ __FILE__, __LINE__, #N_ptr); \ @@ -86,7 +83,8 @@ void handle_register(client_t *client, const char *client_resp_name) if (client->state == 1) { printf("Source '%s' re-confirmed\n", client->topic_name); /* Reply to client. */ - E(lbm_src_send(client->resp_src, "rOK", 4, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK)); + err = lbm_src_send(client->resp_src, "rOK", 4, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK); + EX_LBM_CHK(err); } /* =semlit,endblock,rsp_src_ok= */ else if (client->state == 0) { @@ -94,16 +92,21 @@ void handle_register(client_t *client, const char *client_resp_name) lbm_topic_t *lbm_topic; /* Create source to send responses to client. */ - E(lbm_src_topic_attr_create(&src_attr)); + err = lbm_src_topic_attr_create(&src_attr); + EX_LBM_CHK(err); /* =semlit,block,rsp_src_config= */ - E(lbm_src_topic_attr_str_setopt(src_attr, "transport", "lbt-ru")); - E(lbm_src_topic_attr_str_setopt(src_attr, "transport_lbtru_port", "12070")); + err = lbm_src_topic_attr_str_setopt(src_attr, "transport", "lbt-ru"); + EX_LBM_CHK(err); + err = lbm_src_topic_attr_str_setopt(src_attr, "transport_lbtru_port", "12070"); + EX_LBM_CHK(err); /* =semlit,endblock,rsp_src_config= */ /* =semlit,block,rsp_src_config2= */ - E(lbm_src_topic_attr_str_setopt(src_attr, - "transport_source_side_filtering_behavior", "inclusion")); + err = lbm_src_topic_attr_str_setopt(src_attr, + "transport_source_side_filtering_behavior", "inclusion"); + EX_LBM_CHK(err); /* =semlit,endblock,rsp_src_config2= */ - E(lbm_src_topic_alloc(&lbm_topic, client->ctx, client_resp_name, src_attr)); + err = lbm_src_topic_alloc(&lbm_topic, client->ctx, client_resp_name, src_attr); + EX_LBM_CHK(err); /* The following create can fail if a new client joins with the same * response topic name as an existing client. Should handle this cleanly. */ err = lbm_src_create(&client->resp_src, client->ctx, lbm_topic, @@ -114,12 +117,14 @@ void handle_register(client_t *client, const char *client_resp_name) else { /* =semlit,block,rsp_src_created= */ client->state = 1; - client->topic_name = strdup(client_resp_name); N(client->topic_name); + client->topic_name = strdup(client_resp_name); + NULL_CHK(client->topic_name); printf("Source '%s' created\n", client->topic_name); /* =semlit,endblock,rsp_src_created= */ } - E(lbm_src_topic_attr_delete(src_attr)); + err = lbm_src_topic_attr_delete(src_attr); + EX_LBM_CHK(err); } } /* handle_register */ /* =semlit,endblock,do_reg2= */ @@ -128,6 +133,8 @@ void handle_register(client_t *client, const char *client_resp_name) /* =semlit,block,do_req2= */ void handle_req(client_t *client, req_hdr_t *req_hdr, const char *data, size_t len) { + int err; + /* Response message is put after the header. */ char *response_msg = &client->send_buf[sizeof(req_hdr_t)]; @@ -142,8 +149,9 @@ void handle_req(client_t *client, req_hdr_t *req_hdr, const char *data, size_t l strcpy(response_msg, data); /* Reply to client. */ - E(lbm_src_send(client->resp_src, client->send_buf, - strlen(client->send_buf) + 1, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK)); + err = lbm_src_send(client->resp_src, client->send_buf, + strlen(client->send_buf) + 1, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK); + EX_LBM_CHK(err); printf("sent response to '%s'.\n", client->topic_name); } /* handle_req */ /* =semlit,endblock,do_req2= */ @@ -205,11 +213,13 @@ int request_rcv_cb(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) void *start_client_source(const char *source_name, void *clientd) { lbm_context_t *ctx = (lbm_context_t *)clientd;; - client_t *new_client = (client_t *)malloc(sizeof(client_t)); N(new_client); + client_t *new_client = (client_t *)malloc(sizeof(client_t)); + NULL_CHK(new_client); new_client->state = 0; /* Waiting for register. */ new_client->topic_name = NULL; - new_client->source_name = strdup(source_name); N(new_client->source_name); + new_client->source_name = strdup(source_name); + NULL_CHK(new_client->source_name); new_client->ctx = ctx; new_client->resp_src = NULL; @@ -220,6 +230,8 @@ void *start_client_source(const char *source_name, void *clientd) int end_client_source(const char *source_name, void *clientd, void *source_clientd) { + int err; + if (source_clientd) { client_t *client = (client_t *)source_clientd; @@ -230,7 +242,8 @@ int end_client_source(const char *source_name, void *clientd, void *source_clien free(client->source_name); } - E(lbm_src_delete(client->resp_src)); + err = lbm_src_delete(client->resp_src); + EX_LBM_CHK(err); free(source_clientd); } @@ -243,6 +256,7 @@ int main(int argc, char **argv) { lbm_context_t *ctx; lbm_rcv_t *rcv; /* Receiver for requests from clients. */ + int err; #if defined(_MSC_VER) /* windows-specific code */ @@ -253,9 +267,11 @@ int main(int argc, char **argv) } #endif - E(lbm_config("serv.cfg")); + err = lbm_config("serv.cfg"); + EX_LBM_CHK(err); - E(lbm_context_create(&ctx, NULL, NULL, NULL)); + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); /* Create receiver for requests from clients. */ { @@ -264,20 +280,25 @@ int main(int argc, char **argv) lbm_rcv_topic_attr_t *rcv_attr; lbm_topic_t *topic; - E(lbm_rcv_topic_attr_create(&rcv_attr)); + err = lbm_rcv_topic_attr_create(&rcv_attr); + EX_LBM_CHK(err); /* Set up per-source state management. */ source_notification_function.create_func = start_client_source; source_notification_function.delete_func = end_client_source; source_notification_function.clientd = ctx; /* Pass this to start_client_source(). */ - E(lbm_rcv_topic_attr_setopt(rcv_attr, "source_notification_function", - &source_notification_function, sizeof(source_notification_function))); + err = lbm_rcv_topic_attr_setopt(rcv_attr, "source_notification_function", + &source_notification_function, sizeof(source_notification_function)); + EX_LBM_CHK(err); - E(lbm_rcv_topic_lookup(&topic, ctx, "Server1.Request", rcv_attr)); + err = lbm_rcv_topic_lookup(&topic, ctx, "Server1.Request", rcv_attr); + EX_LBM_CHK(err); /* Pass context object as clientd. */ - E(lbm_rcv_create(&rcv, ctx, topic, request_rcv_cb, ctx, NULL)); + err = lbm_rcv_create(&rcv, ctx, topic, request_rcv_cb, ctx, NULL); + EX_LBM_CHK(err); - E(lbm_rcv_topic_attr_delete(rcv_attr)); + err = lbm_rcv_topic_attr_delete(rcv_attr); + EX_LBM_CHK(err); } /* =semlit,endblock,src_notif_setopt= */ @@ -286,13 +307,15 @@ int main(int argc, char **argv) } /* Finished all receiving from this topic, delete the receiver object. */ - E(lbm_rcv_delete(rcv)); + err = lbm_rcv_delete(rcv); + EX_LBM_CHK(err); /* Do not need to delete the topic object - LBM keeps track of topic * objects and deletes them as-needed. */ /* Finished with all LBM functions, delete the context object. */ - E(lbm_context_delete(ctx)); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); #if defined(_MSC_VER) WSACleanup(); diff --git a/src_rsp/c/server_c.slsrc.html b/src_rsp/c/server_c.slsrc.html index 3180794..6637d6c 100644 --- a/src_rsp/c/server_c.slsrc.html +++ b/src_rsp/c/server_c.slsrc.html @@ -90,29 +90,29 @@ 00072 00073 00074 -00075 -00076 -00077 +00075 +00076 +00077 00078 00079 00080 -00081 -00082 -00083 +00081 +00082 +00083 00084 00085 00086 -00087 -00088 +00087 +00088 00089 00090 00091 00092 00093 -00094 +00094 00095 00096 -00097 +00097 00098 00099 00100 @@ -131,13 +131,13 @@ 00113 00114 00115 -00116 -00117 -00118 -00119 -00120 -00121 -00122 +00116 +00117 +00118 +00119 +00120 +00121 +00122 00123 00124 00125 @@ -153,39 +153,39 @@ 00135 00136 00137 -00138 -00139 -00140 -00141 -00142 -00143 -00144 -00145 -00146 -00147 -00148 -00149 -00150 -00151 -00152 -00153 -00154 -00155 -00156 -00157 -00158 -00159 -00160 -00161 -00162 -00163 -00164 -00165 -00166 -00167 -00168 -00169 -00170 +00138 +00139 +00140 +00141 +00142 +00143 +00144 +00145 +00146 +00147 +00148 +00149 +00150 +00151 +00152 +00153 +00154 +00155 +00156 +00157 +00158 +00159 +00160 +00161 +00162 +00163 +00164 +00165 +00166 +00167 +00168 +00169 +00170 00171 00172 00173 @@ -201,29 +201,29 @@ 00183 00184 00185 -00186 -00187 -00188 -00189 -00190 -00191 -00192 -00193 +00186 +00187 +00188 +00189 +00190 +00191 +00192 +00193 00194 00195 00196 00197 00198 -00199 -00200 -00201 -00202 -00203 -00204 -00205 -00206 -00207 -00208 +00199 +00200 +00201 +00202 +00203 +00204 +00205 +00206 +00207 +00208 00209 00210 00211 @@ -257,46 +257,69 @@ 00239 00240 00241 -00242 -00243 -00244 -00245 -00246 -00247 -00248 -00249 -00250 -00251 -00252 -00253 -00254 -00255 -00256 -00257 +00242 +00243 +00244 +00245 +00246 +00247 +00248 +00249 +00250 +00251 +00252 +00253 +00254 +00255 +00256 +00257 00258 00259 00260 -00261 -00262 -00263 -00264 -00265 -00266 -00267 -00268 -00269 -00270 -00271 -00272 -00273 -00274 -00275 -00276 -00277 -00278 -00279 -00280 - /* server.c +00261 +00262 +00263 +00264 +00265 +00266 +00267 +00268 +00269 +00270 +00271 +00272 +00273 +00274 +00275 +00276 +00277 +00278 +00279 +00280 +00281 +00282 +00283 +00284 +00285 +00286 +00287 +00288 +00289 +00290 +00291 +00292 +00293 +00294 +00295 +00296 +00297 +00298 +00299 +00300 +00301 +00302 +00303 + /* server.c - see http://ultramessaging.github.io/UMExamples/server/c/index.html * * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. * Permission is granted to licensees to use @@ -350,20 +373,17 @@ char send_buf[MAX_RESP_SIZE + sizeof(req_hdr_t)]; } client_t; - - /* Very simplistic LBM error handling. */ - #define E(E_err) do { \ - if ((E_err) < 0) { \ - fprintf(stderr, "Error, %s:%d: '%s': %s\n", \ - __FILE__, __LINE__, #E_err, lbm_errmsg()); \ - fflush(stderr); \ - abort(); /* core dump */ \ - } \ + /* Example error checking macro. Include after each UM call. */ + #define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) - - /* Null check. */ - #define N(N_ptr) do { \ + /* Error if null. */ + #define NULL_CHK(N_ptr) do { \ if ((N_ptr) == NULL) { \ fprintf(stderr, "Error, %s:%d: '%s' is NULL\n", \ __FILE__, __LINE__, #N_ptr); \ @@ -382,19 +402,25 @@ if (client->state == 1) { printf("Source '%s' re-confirmed\n", client->topic_name); /* Reply to client. */ - E(lbm_src_send(client->resp_src, "rOK", 4, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK)); + err = lbm_src_send(client->resp_src, "rOK", 4, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK); + EX_LBM_CHK(err); } else if (client->state == 0) { lbm_src_topic_attr_t * src_attr; lbm_topic_t *lbm_topic; /* Create source to send responses to client. */ - E(lbm_src_topic_attr_create(&src_attr)); - E(lbm_src_topic_attr_str_setopt(src_attr, "transport", "lbt-ru")); - E(lbm_src_topic_attr_str_setopt(src_attr, "transport_lbtru_port", "12070")); - E(lbm_src_topic_attr_str_setopt(src_attr, - "transport_source_side_filtering_behavior", "inclusion")); - E(lbm_src_topic_alloc(&lbm_topic, client->ctx, client_resp_name, src_attr)); + err = lbm_src_topic_attr_create(&src_attr); + EX_LBM_CHK(err); + err = lbm_src_topic_attr_str_setopt(src_attr, "transport", "lbt-ru"); + EX_LBM_CHK(err); + err = lbm_src_topic_attr_str_setopt(src_attr, "transport_lbtru_port", "12070"); + EX_LBM_CHK(err); + err = lbm_src_topic_attr_str_setopt(src_attr, + "transport_source_side_filtering_behavior", "inclusion"); + EX_LBM_CHK(err); + err = lbm_src_topic_alloc(&lbm_topic, client->ctx, client_resp_name, src_attr); + EX_LBM_CHK(err); /* The following create can fail if a new client joins with the same * response topic name as an existing client. Should handle this cleanly. */ err = lbm_src_create(&client->resp_src, client->ctx, lbm_topic, @@ -404,17 +430,21 @@ } else { client->state = 1; - client->topic_name = strdup(client_resp_name); N(client->topic_name); + client->topic_name = strdup(client_resp_name); + NULL_CHK(client->topic_name); printf("Source '%s' created\n", client->topic_name); } - E(lbm_src_topic_attr_delete(src_attr)); + err = lbm_src_topic_attr_delete(src_attr); + EX_LBM_CHK(err); } } /* handle_register */ void handle_req(client_t *client, req_hdr_t *req_hdr, const char *data, size_t len) { + int err; + /* Response message is put after the header. */ char *response_msg = &client->send_buf[sizeof(req_hdr_t)]; @@ -429,8 +459,9 @@ strcpy(response_msg, data); /* Reply to client. */ - E(lbm_src_send(client->resp_src, client->send_buf, - strlen(client->send_buf) + 1, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK)); + err = lbm_src_send(client->resp_src, client->send_buf, + strlen(client->send_buf) + 1, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK); + EX_LBM_CHK(err); printf("sent response to '%s'.\n", client->topic_name); } /* handle_req */ @@ -484,11 +515,13 @@ void *start_client_source(const char *source_name, void *clientd) { lbm_context_t *ctx = (lbm_context_t *)clientd;; - client_t *new_client = (client_t *)malloc(sizeof(client_t)); N(new_client); + client_t *new_client = (client_t *)malloc(sizeof(client_t)); + NULL_CHK(new_client); new_client->state = 0; /* Waiting for register. */ new_client->topic_name = NULL; - new_client->source_name = strdup(source_name); N(new_client->source_name); + new_client->source_name = strdup(source_name); + NULL_CHK(new_client->source_name); new_client->ctx = ctx; new_client->resp_src = NULL; @@ -498,6 +531,8 @@ int end_client_source(const char *source_name, void *clientd, void *source_clientd) { + int err; + if (source_clientd) { client_t *client = (client_t *)source_clientd; @@ -508,7 +543,8 @@ free(client->source_name); } - E(lbm_src_delete(client->resp_src)); + err = lbm_src_delete(client->resp_src); + EX_LBM_CHK(err); free(source_clientd); } @@ -521,6 +557,7 @@ { lbm_context_t *ctx; lbm_rcv_t *rcv; /* Receiver for requests from clients. */ + int err; #if defined(_MSC_VER) /* windows-specific code */ @@ -531,9 +568,11 @@ } #endif - E(lbm_config("serv.cfg")); + err = lbm_config("serv.cfg"); + EX_LBM_CHK(err); - E(lbm_context_create(&ctx, NULL, NULL, NULL)); + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); /* Create receiver for requests from clients. */ { @@ -541,20 +580,25 @@ lbm_rcv_topic_attr_t *rcv_attr; lbm_topic_t *topic; - E(lbm_rcv_topic_attr_create(&rcv_attr)); + err = lbm_rcv_topic_attr_create(&rcv_attr); + EX_LBM_CHK(err); /* Set up per-source state management. */ source_notification_function.create_func = start_client_source; source_notification_function.delete_func = end_client_source; source_notification_function.clientd = ctx; /* Pass this to start_client_source(). */ - E(lbm_rcv_topic_attr_setopt(rcv_attr, "source_notification_function", - &source_notification_function, sizeof(source_notification_function))); + err = lbm_rcv_topic_attr_setopt(rcv_attr, "source_notification_function", + &source_notification_function, sizeof(source_notification_function)); + EX_LBM_CHK(err); - E(lbm_rcv_topic_lookup(&topic, ctx, "Server1.Request", rcv_attr)); + err = lbm_rcv_topic_lookup(&topic, ctx, "Server1.Request", rcv_attr); + EX_LBM_CHK(err); /* Pass context object as clientd. */ - E(lbm_rcv_create(&rcv, ctx, topic, request_rcv_cb, ctx, NULL)); + err = lbm_rcv_create(&rcv, ctx, topic, request_rcv_cb, ctx, NULL); + EX_LBM_CHK(err); - E(lbm_rcv_topic_attr_delete(rcv_attr)); + err = lbm_rcv_topic_attr_delete(rcv_attr); + EX_LBM_CHK(err); } while (1) { @@ -562,13 +606,15 @@ } /* Finished all receiving from this topic, delete the receiver object. */ - E(lbm_rcv_delete(rcv)); + err = lbm_rcv_delete(rcv); + EX_LBM_CHK(err); /* Do not need to delete the topic object - LBM keeps track of topic * objects and deletes them as-needed. */ /* Finished with all LBM functions, delete the context object. */ - E(lbm_context_delete(ctx)); + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); #if defined(_MSC_VER) WSACleanup(); diff --git a/src_rsp/c/src_rsp.sldoc b/src_rsp/c/src_rsp.sldoc index 551e75b..b0106a7 100644 --- a/src_rsp/c/src_rsp.sldoc +++ b/src_rsp/c/src_rsp.sldoc @@ -34,11 +34,13 @@ Can be configured to recover messages after long network outages.
  • Extra layer of reliability. - The "OTR" feature can recover messages unrecoverably lost by the transport. + The "OTR" feature can recover messages unrecoverably lost by the + transport. + Also, the source can be made persistent for even greater reliability.
  • Better application visibility. - Unicast transport types give connect and disconnect events for the - source, and receivers get BOS and EOS events. + Receivers get BOS, EOS, and unrecoverable loss events, and for + unicast transport types, sources get connect and disconnect events.
  • UDP-based transport types can give lower latency. @@ -58,9 +60,9 @@

    When a client program initializes, it creates a source to send requests and a receiver to receive responses. - The client then exchanges one or more handshakes to register with the - server, and to verify round-trip connectivity. - This avoids initial message loss due to topic resolution.

    + The client then exchanges handshakes with the server to register with it, + and to verify round-trip connectivity. + This verification avoids initial message loss during topic resolution.

    Registration

    @@ -72,13 +74,14 @@ =semlit,insert,req_src_create=

    The client needs a unique topic to receive is responses. - Using the process PID is an easy, but not robust method..

    + Using the process PID is an easy, but non-robust method (two + clients on different machines can have the same PID).

    =semlit,insert,client_name=

    . . .

    =semlit,insert,rsp_rcv_create= -

    Registration; Client Side

    +

    Registration: Client Side

    The registration message that the client sends to the server is all-ascii, consisting of lower-case 'r' followed by a null-terminated @@ -97,7 +100,7 @@ =semlit,insert,register_done= -

    Registration; Server Side

    +

    Registration: Server Side

    The server makes use of source notification create/delete callbacks to manage client state. @@ -172,7 +175,7 @@ received, so the client can maintain a table of outstanding requests. This logic is not included in this example.

    -

    Request; Client Side

    +

    Request: Client Side

    In this example, the send buffer for requests is declared as an arbitrary large buffer. @@ -184,7 +187,7 @@ =semlit,insert,req_sends= -

    Response; Server Side

    +

    Response: Server Side

    When the server receives the request, it sends a response.

    diff --git a/src_rsp/c/src_rsp.sldoc.html b/src_rsp/c/src_rsp.sldoc.html index 3c3b542..e74211c 100644 --- a/src_rsp/c/src_rsp.sldoc.html +++ b/src_rsp/c/src_rsp.sldoc.html @@ -34,11 +34,13 @@

    How to use sources to send requests and responses.

    Can be configured to recover messages after long network outages.
  • Extra layer of reliability. - The "OTR" feature can recover messages unrecoverably lost by the transport. + The "OTR" feature can recover messages unrecoverably lost by the + transport. + Also, the source can be made persistent for even greater reliability.
  • Better application visibility. - Unicast transport types give connect and disconnect events for the - source, and receivers get BOS and EOS events. + Receivers get BOS, EOS, and unrecoverable loss events, and for + unicast transport types, sources get connect and disconnect events.
  • UDP-based transport types can give lower latency. @@ -58,9 +60,9 @@

    Overall Approach

    When a client program initializes, it creates a source to send requests and a receiver to receive responses. - The client then exchanges one or more handshakes to register with the - server, and to verify round-trip connectivity. - This avoids initial message loss due to topic resolution.

    + The client then exchanges handshakes with the server to register with it, + and to verify round-trip connectivity. + This verification avoids initial message loss during topic resolution.

    Registration

    @@ -69,47 +71,52 @@

    Registration

    -00134      server.topic_name = "Server1.Request";
    +00124      server.topic_name = "Server1.Request";
     

    . . .

    -00144      /* Create source to send requests to server. */
    -00145      {
    -00146          lbm_topic_t *topic;
    -00147          E(lbm_src_topic_alloc(&topic, ctx, server.topic_name, NULL));
    -00148          E(lbm_src_create(&server.src, ctx, topic, NULL, NULL, NULL));
    -00149      }
    +00136      /* Create source to send requests to server. */
    +00137      {
    +00138          lbm_topic_t *topic;
    +00139          err = lbm_src_topic_alloc(&topic, ctx, server.topic_name, NULL);
    +00140          EX_LBM_CHK(err);
    +00141          err = lbm_src_create(&server.src, ctx, topic, NULL, NULL, NULL);
    +00142          EX_LBM_CHK(err);
    +00143      }
     

    The client needs a unique topic to receive is responses. - Using the process PID is an easy, but not robust method..

    + Using the process PID is an easy, but non-robust method (two + clients on different machines can have the same PID).

    -00120      /* Get (pretty much) unique client name. */
    -00121      sprintf(response_topic_name, "Client.%lx.Response", (long)getpid());
    +00110      /* Get (pretty much) unique client name. */
    +00111      sprintf(response_topic_name, "Client.%lx.Response", (long)getpid());
     

    . . .

    -00151      /* Create receiver for responses from server. */
    -00152      {
    -00153          lbm_topic_t *topic;
    -00154          E(lbm_rcv_topic_lookup(&topic, ctx, response_topic_name, NULL));
    -00155          E(lbm_rcv_create(&server.rcv, ctx, topic, response_rcv_cb, &server, NULL));
    -00156      }
    +00145      /* Create receiver for responses from server. */
    +00146      {
    +00147          lbm_topic_t *topic;
    +00148          err = lbm_rcv_topic_lookup(&topic, ctx, response_topic_name, NULL);
    +00149          EX_LBM_CHK(err);
    +00150          err = lbm_rcv_create(&server.rcv, ctx, topic, response_rcv_cb, &server, NULL);
    +00151          EX_LBM_CHK(err);
    +00152      }
     
    -

    Registration; Client Side

    +

    Registration: Client Side

    The registration message that the client sends to the server is all-ascii, consisting of lower-case 'r' followed by a null-terminated @@ -117,8 +124,8 @@

    Registration; Client Side

    -00164          char register_msg[257];
    -00165          sprintf(register_msg, "r%s", response_topic_name);
    +00158          char register_msg[257];
    +00159          sprintf(register_msg, "r%s", response_topic_name);
     
    @@ -130,21 +137,23 @@

    Registration; Client Side

    -00167          while (server.state == 0) {
    -00168              try_cnt ++;
    -00169              E(lbm_src_send(server.src, register_msg,
    -00170                  strlen(register_msg) + 1, LBM_MSG_FLUSH | LBM_SRC_BLOCK));
    -00171              printf("Sent '%s' to %s; sleep for %d ms\n", register_msg,
    -00172                  server.topic_name, backoff_delay);
    -00173  
    -00174              /* Exponential backoff, to max of 1 sec. */
    -00175              MSLEEP(backoff_delay);
    -00176              backoff_delay *= 2;  /* Exponential backoff to max of 1 sec. */
    -00177              if (backoff_delay > 1000) {
    -00178                  backoff_delay = 1000;
    -00179              }
    -00180          }
    -00181          printf("Took %d tries to register with server.\n", try_cnt);
    +00161          backoff_delay = 1;  /* In milliseconds. */
    +00162          MSLEEP(backoff_delay);  /* Let TR complete. */
    +00163          while (server.state == 0) {
    +00164              try_cnt ++;
    +00165              err = lbm_src_send(server.src, register_msg,
    +00166                  strlen(register_msg) + 1, LBM_MSG_FLUSH | LBM_SRC_BLOCK);
    +00167              EX_LBM_CHK(err);
    +00168              printf("Sent '%s' to %s\n", register_msg, server.topic_name);
    +00169  
    +00170              /* Exponential backoff, to max of 1 sec. */
    +00171              backoff_delay *= 2;  /* Exponential backoff to max of 1 sec. */
    +00172              if (backoff_delay > 1000) {
    +00173                  backoff_delay = 1000;
    +00174              }
    +00175              MSLEEP(backoff_delay);  /* Wait for server response. */
    +00176          }
    +00177          printf("Took %d tries to register with server.\n", try_cnt);
     
    @@ -153,19 +162,19 @@

    Registration; Client Side

    -00081      case LBM_MSG_DATA:    /* Received a message from the client. */
    -00082          printf("Received %ld bytes on topic %s: '%.*s'\n",
    -00083              (long)msg->len, msg->topic_name, (int)msg->len, msg->data);
    -00084  
    -00085          if (msg->len > 1 && msg->data[0] == 'r') {
    -00086              /* Should check for success. */
    -00087              server->state = 1;  /* Registered. */
    -00088          }
    +00070      case LBM_MSG_DATA:    /* Received a message from the client. */
    +00071          printf("Received %ld bytes on topic %s: '%.*s'\n",
    +00072              (long)msg->len, msg->topic_name, (int)msg->len, msg->data);
    +00073  
    +00074          if (msg->len > 1 && msg->data[0] == 'r') {
    +00075              /* Should check for success. */
    +00076              server->state = 1;  /* Registered. */
    +00077          }
     
    -

    Registration; Server Side

    +

    Registration: Server Side

    The server makes use of source notification create/delete callbacks to manage client state. @@ -174,25 +183,30 @@

    Registration; Server Side

    -00242          lbm_rcv_src_notification_func_t source_notification_function;
    -00243          lbm_rcv_topic_attr_t *rcv_attr;
    -00244          lbm_topic_t *topic;
    -00245  
    -00246          E(lbm_rcv_topic_attr_create(&rcv_attr));
    -00247  
    -00248          /* Set up per-source state management. */
    -00249          source_notification_function.create_func = start_client_source;
    -00250          source_notification_function.delete_func = end_client_source;
    -00251          source_notification_function.clientd = ctx;  /* Pass this to start_client_source(). */
    -00252          E(lbm_rcv_topic_attr_setopt(rcv_attr, "source_notification_function",
    -00253              &source_notification_function, sizeof(source_notification_function)));
    -00254  
    -00255          E(lbm_rcv_topic_lookup(&topic, ctx, "Server1.Request", rcv_attr));
    -00256          /* Pass context object as clientd. */
    -00257          E(lbm_rcv_create(&rcv, ctx, topic, request_rcv_cb, ctx, NULL));
    -00258  
    -00259          E(lbm_rcv_topic_attr_delete(rcv_attr));
    -00260      }
    +00258          lbm_rcv_src_notification_func_t source_notification_function;
    +00259          lbm_rcv_topic_attr_t *rcv_attr;
    +00260          lbm_topic_t *topic;
    +00261  
    +00262          err = lbm_rcv_topic_attr_create(&rcv_attr);
    +00263          EX_LBM_CHK(err);
    +00264  
    +00265          /* Set up per-source state management. */
    +00266          source_notification_function.create_func = start_client_source;
    +00267          source_notification_function.delete_func = end_client_source;
    +00268          source_notification_function.clientd = ctx;  /* Pass this to start_client_source(). */
    +00269          err = lbm_rcv_topic_attr_setopt(rcv_attr, "source_notification_function",
    +00270              &source_notification_function, sizeof(source_notification_function));
    +00271          EX_LBM_CHK(err);
    +00272  
    +00273          err = lbm_rcv_topic_lookup(&topic, ctx, "Server1.Request", rcv_attr);
    +00274          EX_LBM_CHK(err);
    +00275          /* Pass context object as clientd. */
    +00276          err = lbm_rcv_create(&rcv, ctx, topic, request_rcv_cb, ctx, NULL);
    +00277          EX_LBM_CHK(err);
    +00278  
    +00279          err = lbm_rcv_topic_attr_delete(rcv_attr);
    +00280          EX_LBM_CHK(err);
    +00281      }
     
    @@ -204,19 +218,21 @@

    Registration; Server Side

    -00186  void *start_client_source(const char *source_name, void *clientd)
    -00187  {
    -00188      lbm_context_t *ctx = (lbm_context_t *)clientd;;
    -00189      client_t *new_client = (client_t *)malloc(sizeof(client_t));  N(new_client);
    -00190  
    -00191      new_client->state = 0;  /* Waiting for register. */
    -00192      new_client->topic_name = NULL;
    -00193      new_client->source_name = strdup(source_name);  N(new_client->source_name);
    -00194      new_client->ctx = ctx;
    -00195      new_client->resp_src = NULL;
    -00196  
    -00197      return new_client;
    -00198  }  /* start_client_source */
    +00194  void *start_client_source(const char *source_name, void *clientd)
    +00195  {
    +00196      lbm_context_t *ctx = (lbm_context_t *)clientd;;
    +00197      client_t *new_client = (client_t *)malloc(sizeof(client_t));
    +00198      NULL_CHK(new_client);
    +00199  
    +00200      new_client->state = 0;  /* Waiting for register. */
    +00201      new_client->topic_name = NULL;
    +00202      new_client->source_name = strdup(source_name);
    +00203      NULL_CHK(new_client->source_name);
    +00204      new_client->ctx = ctx;
    +00205      new_client->resp_src = NULL;
    +00206  
    +00207      return new_client;
    +00208  }  /* start_client_source */
     
    @@ -229,9 +245,9 @@

    Registration; Server Side

    -00140  int request_rcv_cb(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) 
    -00141  {
    -00142      client_t *client = (client_t *)msg->source_clientd;
    +00148  int request_rcv_cb(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) 
    +00149  {
    +00150      client_t *client = (client_t *)msg->source_clientd;
     
    @@ -240,58 +256,66 @@

    Registration; Server Side

    -00146      case LBM_MSG_DATA:  /* Received a message from the client. */
    -00147          printf("Received %ld bytes on topic %s: '%.*s'\n",
    -00148               (long)msg->len, msg->topic_name, (int)msg->len, msg->data);
    -00149  
    -00150          /* Register message. */
    -00151          if (msg->len > 1 && msg->data[0] == 'r') {
    -00152              handle_register(client, &msg->data[1]);
    -00153          }
    +00154      case LBM_MSG_DATA:  /* Received a message from the client. */
    +00155          printf("Received %ld bytes on topic %s: '%.*s'\n",
    +00156               (long)msg->len, msg->topic_name, (int)msg->len, msg->data);
    +00157  
    +00158          /* Register message. */
    +00159          if (msg->len > 1 && msg->data[0] == 'r') {
    +00160              handle_register(client, &msg->data[1]);
    +00161          }
     

    . . .

    -00078  void handle_register(client_t *client, const char *client_resp_name)
    -00079  {
    -00080      int err;
    -00081      /* This work should probably be passed to a separate worker thread, but
    -00082       * I'll do it here to simplify the code. */
    -00083  
    -00084      if (client->state == 1) {
    -00085          printf("Source '%s' re-confirmed\n", client->topic_name);
    -00086          /* Reply to client. */
    -00087          E(lbm_src_send(client->resp_src, "rOK", 4, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK));
    -00088      }
    -00089      else if (client->state == 0) {
    -00090          lbm_src_topic_attr_t * src_attr;
    -00091          lbm_topic_t *lbm_topic;
    -00092  
    -00093          /* Create source to send responses to client. */
    -00094          E(lbm_src_topic_attr_create(&src_attr));
    -00095          E(lbm_src_topic_attr_str_setopt(src_attr, "transport", "lbt-ru"));
    -00096          E(lbm_src_topic_attr_str_setopt(src_attr, "transport_lbtru_port", "12070"));
    -00097          E(lbm_src_topic_attr_str_setopt(src_attr,
    -00098              "transport_source_side_filtering_behavior", "inclusion"));
    -00099          E(lbm_src_topic_alloc(&lbm_topic, client->ctx, client_resp_name, src_attr));
    -00100          /* The following create can fail if a new client joins with the same
    -00101           * response topic name as an existing client.  Should handle this cleanly. */
    -00102          err = lbm_src_create(&client->resp_src, client->ctx, lbm_topic,
    -00103              NULL, NULL, NULL);
    -00104          if (err) {
    -00105              printf("Source '%s' failed; %s\n", client_resp_name, lbm_errmsg());
    -00106          }
    -00107          else {
    -00108              client->state = 1;
    -00109              client->topic_name = strdup(client_resp_name);  N(client->topic_name);
    -00110              printf("Source '%s' created\n", client->topic_name);
    -00111          }
    -00112  
    -00113          E(lbm_src_topic_attr_delete(src_attr));
    -00114      }
    -00115  }  /* handle_register */
    +00075  void handle_register(client_t *client, const char *client_resp_name)
    +00076  {
    +00077      int err;
    +00078      /* This work should probably be passed to a separate worker thread, but
    +00079       * I'll do it here to simplify the code. */
    +00080  
    +00081      if (client->state == 1) {
    +00082          printf("Source '%s' re-confirmed\n", client->topic_name);
    +00083          /* Reply to client. */
    +00084          err = lbm_src_send(client->resp_src, "rOK", 4, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK);
    +00085          EX_LBM_CHK(err);
    +00086      }
    +00087      else if (client->state == 0) {
    +00088          lbm_src_topic_attr_t * src_attr;
    +00089          lbm_topic_t *lbm_topic;
    +00090  
    +00091          /* Create source to send responses to client. */
    +00092          err = lbm_src_topic_attr_create(&src_attr);
    +00093          EX_LBM_CHK(err);
    +00094          err = lbm_src_topic_attr_str_setopt(src_attr, "transport", "lbt-ru");
    +00095          EX_LBM_CHK(err);
    +00096          err = lbm_src_topic_attr_str_setopt(src_attr, "transport_lbtru_port", "12070");
    +00097          EX_LBM_CHK(err);
    +00098          err = lbm_src_topic_attr_str_setopt(src_attr,
    +00099              "transport_source_side_filtering_behavior", "inclusion");
    +00100          EX_LBM_CHK(err);
    +00101          err = lbm_src_topic_alloc(&lbm_topic, client->ctx, client_resp_name, src_attr);
    +00102          EX_LBM_CHK(err);
    +00103          /* The following create can fail if a new client joins with the same
    +00104           * response topic name as an existing client.  Should handle this cleanly. */
    +00105          err = lbm_src_create(&client->resp_src, client->ctx, lbm_topic,
    +00106              NULL, NULL, NULL);
    +00107          if (err) {
    +00108              printf("Source '%s' failed; %s\n", client_resp_name, lbm_errmsg());
    +00109          }
    +00110          else {
    +00111              client->state = 1;
    +00112              client->topic_name = strdup(client_resp_name);
    +00113              NULL_CHK(client->topic_name);
    +00114              printf("Source '%s' created\n", client->topic_name);
    +00115          }
    +00116  
    +00117          err = lbm_src_topic_attr_delete(src_attr);
    +00118          EX_LBM_CHK(err);
    +00119      }
    +00120  }  /* handle_register */
     
    @@ -304,8 +328,10 @@

    Registration; Server Side

    -00095          E(lbm_src_topic_attr_str_setopt(src_attr, "transport", "lbt-ru"));
    -00096          E(lbm_src_topic_attr_str_setopt(src_attr, "transport_lbtru_port", "12070"));
    +00094          err = lbm_src_topic_attr_str_setopt(src_attr, "transport", "lbt-ru");
    +00095          EX_LBM_CHK(err);
    +00096          err = lbm_src_topic_attr_str_setopt(src_attr, "transport_lbtru_port", "12070");
    +00097          EX_LBM_CHK(err);
     
    @@ -315,8 +341,9 @@

    Registration; Server Side

    -00097          E(lbm_src_topic_attr_str_setopt(src_attr,
    -00098              "transport_source_side_filtering_behavior", "inclusion"));
    +00098          err = lbm_src_topic_attr_str_setopt(src_attr,
    +00099              "transport_source_side_filtering_behavior", "inclusion");
    +00100          EX_LBM_CHK(err);
     
    @@ -329,9 +356,10 @@

    Registration; Server Side

    -00108              client->state = 1;
    -00109              client->topic_name = strdup(client_resp_name);  N(client->topic_name);
    -00110              printf("Source '%s' created\n", client->topic_name);
    +00111              client->state = 1;
    +00112              client->topic_name = strdup(client_resp_name);
    +00113              NULL_CHK(client->topic_name);
    +00114              printf("Source '%s' created\n", client->topic_name);
     
    @@ -344,11 +372,12 @@

    Registration; Server Side

    -00084      if (client->state == 1) {
    -00085          printf("Source '%s' re-confirmed\n", client->topic_name);
    -00086          /* Reply to client. */
    -00087          E(lbm_src_send(client->resp_src, "rOK", 4, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK));
    -00088      }
    +00081      if (client->state == 1) {
    +00082          printf("Source '%s' re-confirmed\n", client->topic_name);
    +00083          /* Reply to client. */
    +00084          err = lbm_src_send(client->resp_src, "rOK", 4, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK);
    +00085          EX_LBM_CHK(err);
    +00086      }
     
    @@ -369,7 +398,7 @@

    Request/Response

    received, so the client can maintain a table of outstanding requests. This logic is not included in this example.

    -

    Request; Client Side

    +

    Request: Client Side

    In this example, the send buffer for requests is declared as an arbitrary large buffer. @@ -377,11 +406,11 @@

    Request; Client Side

    -00187          char send_buf[500];
    -00188          req_hdr_t *req_hdr = (req_hdr_t *)send_buf;
    -00189  
    -00190          memset((char *)req_hdr, '0', sizeof(req_hdr_t));
    -00191          req_hdr->data[0] = 'R';
    +00183          char send_buf[500];
    +00184          req_hdr_t *req_hdr = (req_hdr_t *)send_buf;
    +00185  
    +00186          memset((char *)req_hdr, '0', sizeof(req_hdr_t));
    +00187          req_hdr->data[0] = 'R';
     
    @@ -390,61 +419,65 @@

    Request; Client Side

    -00193          for (i = 0; i < 5; i++) {
    -00194              /* The application builds a request into <tt>request_msg</tt>. */
    -00195              char request_msg[257];
    -00196              sprintf(request_msg, "%s.%d", response_topic_name, i);
    -00197  
    -00198              /* The application message is copied in after the header. */
    -00199              strcpy(&send_buf[sizeof(req_hdr_t)], request_msg);
    -00200              E(lbm_src_send(server.src, send_buf, strlen(send_buf) + 1,
    -00201                  LBM_MSG_FLUSH | LBM_SRC_NONBLOCK));
    -00202              MSLEEP(1000);
    -00203          }
    +00189          for (i = 0; i < 5; i++) {
    +00190              /* The application builds a request into <tt>request_msg</tt>. */
    +00191              char request_msg[257];
    +00192              sprintf(request_msg, "%s.%d", response_topic_name, i);
    +00193  
    +00194              /* The application message is copied in after the header. */
    +00195              strcpy(&send_buf[sizeof(req_hdr_t)], request_msg);
    +00196              err = lbm_src_send(server.src, send_buf, strlen(send_buf) + 1,
    +00197                  LBM_MSG_FLUSH | LBM_SRC_NONBLOCK);
    +00198              EX_LBM_CHK(err);
    +00199              MSLEEP(1000);
    +00200          }
     
    -

    Response; Server Side

    +

    Response: Server Side

    When the server receives the request, it sends a response.

    -00155          /* Request message. */
    -00156          else if (msg->len >= sizeof(req_hdr_t) && msg->data[0] == 'R') {
    -00157              req_hdr_t req_hdr;
    -00158              memcpy((char *)&req_hdr, msg->data, sizeof(req_hdr_t));
    -00159  
    -00160              handle_req(client, &req_hdr, &msg->data[sizeof(req_hdr_t)],
    -00161                  msg->len - sizeof(req_hdr_t));
    -00162          }
    +00163          /* Request message. */
    +00164          else if (msg->len >= sizeof(req_hdr_t) && msg->data[0] == 'R') {
    +00165              req_hdr_t req_hdr;
    +00166              memcpy((char *)&req_hdr, msg->data, sizeof(req_hdr_t));
    +00167  
    +00168              handle_req(client, &req_hdr, &msg->data[sizeof(req_hdr_t)],
    +00169                  msg->len - sizeof(req_hdr_t));
    +00170          }
     

    . . .

    -00118  void handle_req(client_t *client, req_hdr_t *req_hdr, const char *data, size_t len)
    -00119  {
    -00120      /* Response message is put after the header. */
    -00121      char *response_msg = &client->send_buf[sizeof(req_hdr_t)];
    -00122  
    -00123      /* This work should probably be passed to a separate worker thread, but
    -00124       * I'll do it here to simplify the code. */
    -00125  
    -00126      /* Responses copy the header from the request. */
    -00127      memcpy(&client->send_buf[0], (char *)req_hdr, sizeof(req_hdr_t));
    -00128  
    -00129      /* Do the work of the request and put the response in response_msg.
    -00130       * (For this sample, just echo back the request.) */
    -00131      strcpy(response_msg, data);
    -00132      
    -00133      /* Reply to client. */
    -00134      E(lbm_src_send(client->resp_src, client->send_buf,
    -00135          strlen(client->send_buf) + 1, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK));
    -00136      printf("sent response to '%s'.\n", client->topic_name);
    -00137  }  /* handle_req */
    +00123  void handle_req(client_t *client, req_hdr_t *req_hdr, const char *data, size_t len)
    +00124  {
    +00125      int err;
    +00126  
    +00127      /* Response message is put after the header. */
    +00128      char *response_msg = &client->send_buf[sizeof(req_hdr_t)];
    +00129  
    +00130      /* This work should probably be passed to a separate worker thread, but
    +00131       * I'll do it here to simplify the code. */
    +00132  
    +00133      /* Responses copy the header from the request. */
    +00134      memcpy(&client->send_buf[0], (char *)req_hdr, sizeof(req_hdr_t));
    +00135  
    +00136      /* Do the work of the request and put the response in response_msg.
    +00137       * (For this sample, just echo back the request.) */
    +00138      strcpy(response_msg, data);
    +00139      
    +00140      /* Reply to client. */
    +00141      err = lbm_src_send(client->resp_src, client->send_buf,
    +00142          strlen(client->send_buf) + 1, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK);
    +00143      EX_LBM_CHK(err);
    +00144      printf("sent response to '%s'.\n", client->topic_name);
    +00145  }  /* handle_req */
     
    diff --git a/ump_receiver_callbacks/c/ump_receiver_callbacks.c b/ump_receiver_callbacks/c/ump_receiver_callbacks.c index 40db552..c18bca0 100644 --- a/ump_receiver_callbacks/c/ump_receiver_callbacks.c +++ b/ump_receiver_callbacks/c/ump_receiver_callbacks.c @@ -1,4 +1,23 @@ -/* ump_receiver_callbacks.c - http://ultramessaging.github.io/UMExamples */ +/* ump_receiver_callbacks.c - see http://ultramessaging.github.io/UMExamples/ump_receiver_callbacks/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include @@ -17,18 +36,17 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) + /* Callback used to handle request message for receiver */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { - int err; - switch (msg->type) { case LBM_MSG_DATA: printf("DATA [%s][%s][%d]%s%s, %u bytes\n", msg->topic_name, msg->source, msg->sequence_number, @@ -36,9 +54,11 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) ((msg->flags & LBM_MSG_FLAG_OTR) ? "-OTR-" : ""), (unsigned int)msg->len); break; case LBM_MSG_REQUEST: - printf("REQUEST [%s][%s][%d]%s%s, %u bytes\n", msg->topic_name, msg->source, msg->sequence_number, - ((msg->flags & LBM_MSG_FLAG_UME_RETRANSMIT) ? "-RX-" : ""), - ((msg->flags & LBM_MSG_FLAG_OTR) ? "-OTR-" : ""), (unsigned int)msg->len); + printf("REQUEST [%s][%s][%d]%s%s, %u bytes\n", msg->topic_name, + msg->source, msg->sequence_number, + ((msg->flags & LBM_MSG_FLAG_UME_RETRANSMIT) ? "-RX-" : ""), + ((msg->flags & LBM_MSG_FLAG_OTR) ? "-OTR-" : ""), + (unsigned int)msg->len); break; case LBM_MSG_UNRECOVERABLE_LOSS: printf("[%s][%s][%x], LOST\n", msg->topic_name, msg->source, msg->sequence_number); @@ -76,7 +96,7 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) break; } case LBM_MSG_UME_REGISTRATION_COMPLETE_EX: - { + { lbm_msg_ume_registration_complete_ex_t *reg = (lbm_msg_ume_registration_complete_ex_t *)(msg->data); printf("[%s][%s] UME registration complete. SQN %x. Flags %x ", msg->topic_name, msg->source, reg->sequence_number, reg->flags); @@ -116,15 +136,15 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) } return 0; -} +} /* rcv_handle_msg */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ - lbm_topic_t *rtopic; /* Receiver Topic object */ - int err; /* Used for checking API return codes */ + lbm_context_t *ctx; /* Context object */ + lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ + lbm_topic_t *rtopic; /* Receiver Topic object */ + int err; #if defined(_WIN32) /* windows-specific code */ @@ -143,11 +163,12 @@ int main(int argc, char **argv) /* Create receiver for receiving request and sending response */ err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL); - EX_LBM_CHK(err); + EX_LBM_CHK(err); err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); EX_LBM_CHK(err); + /* Wait forever (or until control-c). */ while (1) { } err = lbm_rcv_delete(rcv); @@ -160,5 +181,6 @@ int main(int argc, char **argv) /* Windows-specific cleanup overhead */ WSACleanup(); #endif - return 0; -} /* main */ + + return 0; +} /* main */ diff --git a/ump_receiver_callbacks/c/ump_receiver_callbacks.sldoc.html b/ump_receiver_callbacks/c/ump_receiver_callbacks.sldoc.html index aaf146c..fd5082a 100644 --- a/ump_receiver_callbacks/c/ump_receiver_callbacks.sldoc.html +++ b/ump_receiver_callbacks/c/ump_receiver_callbacks.sldoc.html @@ -23,16 +23,16 @@

    Context/Receiver Create

    is the callback function that will handle all the receiver callback events.

    -00140      /* Initialize context atrributes and create context */
    -00141      err = lbm_context_create(&ctx, NULL, NULL, NULL);
    -00142      EX_LBM_CHK(err);
    -00143  
    -00144      /* Create receiver for receiving request and sending response */
    -00145      err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL);
    -00146          EX_LBM_CHK(err);
    -00147  
    -00148      err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL);
    -00149      EX_LBM_CHK(err);
    +00160      /* Initialize context atrributes and create context */
    +00161      err = lbm_context_create(&ctx, NULL, NULL, NULL);
    +00162      EX_LBM_CHK(err);
    +00163  
    +00164      /* Create receiver for receiving request and sending response */
    +00165      err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL);
    +00166      EX_LBM_CHK(err);
    +00167  
    +00168      err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL);
    +00169      EX_LBM_CHK(err);
     
    @@ -51,11 +51,11 @@

    Message Data Callback (LBM_MSG_DATA)

    can be skipped. However, it would be useful to have the ability to enable logging as part of some kind of application debug mode.

    -00033          case LBM_MSG_DATA:
    -00034              printf("DATA [%s][%s][%d]%s%s, %u bytes\n", msg->topic_name, msg->source, msg->sequence_number,
    -00035                  ((msg->flags & LBM_MSG_FLAG_UME_RETRANSMIT) ? "-RX-" : ""),
    -00036                  ((msg->flags & LBM_MSG_FLAG_OTR) ? "-OTR-" : ""), (unsigned int)msg->len);
    -00037              break;
    +00051          case LBM_MSG_DATA:
    +00052              printf("DATA [%s][%s][%d]%s%s, %u bytes\n", msg->topic_name, msg->source, msg->sequence_number,
    +00053                  ((msg->flags & LBM_MSG_FLAG_UME_RETRANSMIT) ? "-RX-" : ""),
    +00054                  ((msg->flags & LBM_MSG_FLAG_OTR) ? "-OTR-" : ""), (unsigned int)msg->len);
    +00055              break;
     
    @@ -63,11 +63,13 @@

    Request Message (LBM_MSG_REQUEST)

    Similar to data messages above, the only real difference being that these messages can be responded to via the API.

    -00038          case LBM_MSG_REQUEST:
    -00039              printf("REQUEST [%s][%s][%d]%s%s, %u bytes\n", msg->topic_name, msg->source, msg->sequence_number,
    -00040                                  ((msg->flags & LBM_MSG_FLAG_UME_RETRANSMIT) ? "-RX-" : ""),
    -00041                                  ((msg->flags & LBM_MSG_FLAG_OTR) ? "-OTR-" : ""), (unsigned int)msg->len);
    -00042              break;
    +00056          case LBM_MSG_REQUEST:
    +00057              printf("REQUEST [%s][%s][%d]%s%s, %u bytes\n", msg->topic_name,
    +00058                  msg->source, msg->sequence_number,
    +00059                  ((msg->flags & LBM_MSG_FLAG_UME_RETRANSMIT) ? "-RX-" : ""),
    +00060                  ((msg->flags & LBM_MSG_FLAG_OTR) ? "-OTR-" : ""),
    +00061                  (unsigned int)msg->len);
    +00062              break;
     
    @@ -78,9 +80,9 @@

    Unrecoverable Loss (LBM_MSG_UNRECOVERABLE_LOSS)

    The source information will identify the source publishing the messages that have been lost.

    -00043          case LBM_MSG_UNRECOVERABLE_LOSS:
    -00044              printf("[%s][%s][%x], LOST\n", msg->topic_name, msg->source, msg->sequence_number);
    -00045              break;
    +00063          case LBM_MSG_UNRECOVERABLE_LOSS:
    +00064              printf("[%s][%s][%x], LOST\n", msg->topic_name, msg->source, msg->sequence_number);
    +00065              break;
     
    @@ -91,9 +93,9 @@

    Unrecoverable Loss Burst (LBM_MSG_UNRECOVERABLE_LOSS_BURST)

    See sample handle_burst for more information on handling burst loss

    -00046          case LBM_MSG_UNRECOVERABLE_LOSS_BURST:
    -00047              printf("[%s][%s][%x], LOST BURST\n", msg->topic_name, msg->source, msg->sequence_number);
    -00048              break;
    +00066          case LBM_MSG_UNRECOVERABLE_LOSS_BURST:
    +00067              printf("[%s][%s][%x], LOST BURST\n", msg->topic_name, msg->source, msg->sequence_number);
    +00068              break;
     
    @@ -103,9 +105,9 @@

    Beginning of Transport Session (LBM_MSG_BOS)

    source information.

    -00049          case LBM_MSG_BOS:
    -00050              printf("[%s][%s], Beginning of Transport Session\n", msg->topic_name, msg->source);
    -00051              break;
    +00069          case LBM_MSG_BOS:
    +00070              printf("[%s][%s], Beginning of Transport Session\n", msg->topic_name, msg->source);
    +00071              break;
     
    @@ -114,9 +116,9 @@

    End of Transport Session (LBM_MSG_EOS)

    be logged with the same information as BOS.

    -00052          case LBM_MSG_EOS:
    -00053              printf("[%s][%s], End of Transport Session\n", msg->topic_name, msg->source);
    -00054              break;
    +00072          case LBM_MSG_EOS:
    +00073              printf("[%s][%s], End of Transport Session\n", msg->topic_name, msg->source);
    +00074              break;
     
    @@ -135,9 +137,9 @@

    No Source Notification (LBM_MSG_NO_SOURCE_NOTIFICATION)

    Logging this callback is entirely up to the developer, however it could also be useful when trying to debug connectivity issues.

    -00055          case LBM_MSG_NO_SOURCE_NOTIFICATION:
    -00056              printf("[%s], no sources found for topic\n", msg->topic_name);
    -00057              break;
    +00075          case LBM_MSG_NO_SOURCE_NOTIFICATION:
    +00076              printf("[%s], no sources found for topic\n", msg->topic_name);
    +00077              break;
     
    @@ -146,9 +148,9 @@

    UMP Registration Error (LBM_MSG_UME_REGISTRATION_ERROR)

    name and error string provided in the callback.

    -00058          case LBM_MSG_UME_REGISTRATION_ERROR:
    -00059              printf("[%s][%s] UME registration error: %s\n", msg->topic_name, msg->source, msg->data);
    -00060              break;
    +00078          case LBM_MSG_UME_REGISTRATION_ERROR:
    +00079              printf("[%s][%s] UME registration error: %s\n", msg->topic_name, msg->source, msg->data);
    +00080              break;
     
    @@ -159,23 +161,23 @@

    UMP Registration Success (LBM_MSG_UME_REGISTRATION_SUCCESS_EX)

    source and receiver RegID are useful for tracking those components in the store log and store web-monitor.

    -00061          case LBM_MSG_UME_REGISTRATION_SUCCESS_EX:
    -00062          {
    -00063              lbm_msg_ume_registration_ex_t *reg = (lbm_msg_ume_registration_ex_t *)(msg->data);
    -00064              printf("[%s][%s] store %u: %s UME registration successful. SrcRegID %u RcvRegID %u. Flags %x ",
    -00065                  msg->topic_name, msg->source, reg->store_index, reg->store,
    -00066                  reg->src_registration_id, reg->rcv_registration_id, reg->flags);
    -00067              if (reg->flags & LBM_MSG_UME_REGISTRATION_SUCCESS_EX_FLAG_OLD)
    -00068                  printf("OLD[SQN %x] ", reg->sequence_number);
    -00069              if (reg->flags & LBM_MSG_UME_REGISTRATION_SUCCESS_EX_FLAG_NOCACHE)
    -00070                  printf("NOCACHE ");
    -00071              if (reg->flags & LBM_MSG_UME_REGISTRATION_SUCCESS_EX_FLAG_RPP)
    -00072                  printf("RPP ");
    -00073              if (reg->flags & LBM_MSG_UME_REGISTRATION_SUCCESS_EX_FLAG_SRC_SID)
    -00074                  printf("Src Session ID 0x%" PRIx64 " ", reg->src_session_id);
    -00075              printf("\n");
    -00076              break;
    -00077          }
    +00081          case LBM_MSG_UME_REGISTRATION_SUCCESS_EX:
    +00082          {
    +00083              lbm_msg_ume_registration_ex_t *reg = (lbm_msg_ume_registration_ex_t *)(msg->data);
    +00084              printf("[%s][%s] store %u: %s UME registration successful. SrcRegID %u RcvRegID %u. Flags %x ",
    +00085                  msg->topic_name, msg->source, reg->store_index, reg->store,
    +00086                  reg->src_registration_id, reg->rcv_registration_id, reg->flags);
    +00087              if (reg->flags & LBM_MSG_UME_REGISTRATION_SUCCESS_EX_FLAG_OLD)
    +00088                  printf("OLD[SQN %x] ", reg->sequence_number);
    +00089              if (reg->flags & LBM_MSG_UME_REGISTRATION_SUCCESS_EX_FLAG_NOCACHE)
    +00090                  printf("NOCACHE ");
    +00091              if (reg->flags & LBM_MSG_UME_REGISTRATION_SUCCESS_EX_FLAG_RPP)
    +00092                  printf("RPP ");
    +00093              if (reg->flags & LBM_MSG_UME_REGISTRATION_SUCCESS_EX_FLAG_SRC_SID)
    +00094                  printf("Src Session ID 0x%" PRIx64 " ", reg->src_session_id);
    +00095              printf("\n");
    +00096              break;
    +00097          }
     
    @@ -185,20 +187,20 @@

    UMP Registration Complete (LBM_MSG_UME_REGISTRATION_COMPLETE_EX)

    and the consensus sequence number . as this is the first sequence number the receiver should consume going forward.

    -00078          case LBM_MSG_UME_REGISTRATION_COMPLETE_EX:
    -00079                  {
    -00080              lbm_msg_ume_registration_complete_ex_t *reg = (lbm_msg_ume_registration_complete_ex_t *)(msg->data);
    -00081              printf("[%s][%s] UME registration complete. SQN %x. Flags %x ",
    -00082                  msg->topic_name, msg->source, reg->sequence_number, reg->flags);
    -00083              if (reg->flags & LBM_MSG_UME_REGISTRATION_COMPLETE_EX_FLAG_QUORUM)
    -00084                  printf("QUORUM ");
    -00085              if (reg->flags & LBM_MSG_UME_REGISTRATION_COMPLETE_EX_FLAG_RXREQMAX)
    -00086                  printf("RXREQMAX ");
    -00087              if (reg->flags & LBM_MSG_UME_REGISTRATION_COMPLETE_EX_FLAG_SRC_SID)
    -00088                  printf("Src Session ID 0x%" PRIx64 " ", reg->src_session_id);
    -00089              printf("\n");
    -00090              break;
    -00091          }
    +00098          case LBM_MSG_UME_REGISTRATION_COMPLETE_EX:
    +00099          {
    +00100              lbm_msg_ume_registration_complete_ex_t *reg = (lbm_msg_ume_registration_complete_ex_t *)(msg->data);
    +00101              printf("[%s][%s] UME registration complete. SQN %x. Flags %x ",
    +00102                  msg->topic_name, msg->source, reg->sequence_number, reg->flags);
    +00103              if (reg->flags & LBM_MSG_UME_REGISTRATION_COMPLETE_EX_FLAG_QUORUM)
    +00104                  printf("QUORUM ");
    +00105              if (reg->flags & LBM_MSG_UME_REGISTRATION_COMPLETE_EX_FLAG_RXREQMAX)
    +00106                  printf("RXREQMAX ");
    +00107              if (reg->flags & LBM_MSG_UME_REGISTRATION_COMPLETE_EX_FLAG_SRC_SID)
    +00108                  printf("Src Session ID 0x%" PRIx64 " ", reg->src_session_id);
    +00109              printf("\n");
    +00110              break;
    +00111          }
     
    @@ -208,21 +210,21 @@

    UMP Deregistration Success (LBM_MSG_UME_DEREGISTRATION_SUCCESS_EX)

    logged here.

    -00092          case LBM_MSG_UME_DEREGISTRATION_SUCCESS_EX:
    -00093          {
    -00094              lbm_msg_ume_deregistration_ex_t *dereg = (lbm_msg_ume_deregistration_ex_t *)(msg->data);
    -00095              printf("[%s][%s] store %u: %s UME deregistration successful. SrcRegID %u RcvRegID %u. Flags %x ",
    -00096                  msg->topic_name, msg->source, dereg->store_index, dereg->store,
    -00097                  dereg->src_registration_id, dereg->rcv_registration_id, dereg->flags);
    -00098              if (dereg->flags & LBM_MSG_UME_REGISTRATION_SUCCESS_EX_FLAG_OLD)
    -00099                  printf("OLD[SQN %x] ", dereg->sequence_number);
    -00100              if (dereg->flags & LBM_MSG_UME_REGISTRATION_SUCCESS_EX_FLAG_NOCACHE)
    -00101                  printf("NOCACHE ");
    -00102              if (dereg->flags & LBM_MSG_UME_REGISTRATION_SUCCESS_EX_FLAG_RPP)
    -00103                  printf("RPP ");
    -00104              printf("\n");
    -00105              break;
    -00106          }
    +00112          case LBM_MSG_UME_DEREGISTRATION_SUCCESS_EX:
    +00113          {
    +00114              lbm_msg_ume_deregistration_ex_t *dereg = (lbm_msg_ume_deregistration_ex_t *)(msg->data);
    +00115              printf("[%s][%s] store %u: %s UME deregistration successful. SrcRegID %u RcvRegID %u. Flags %x ",
    +00116                  msg->topic_name, msg->source, dereg->store_index, dereg->store,
    +00117                  dereg->src_registration_id, dereg->rcv_registration_id, dereg->flags);
    +00118              if (dereg->flags & LBM_MSG_UME_REGISTRATION_SUCCESS_EX_FLAG_OLD)
    +00119                  printf("OLD[SQN %x] ", dereg->sequence_number);
    +00120              if (dereg->flags & LBM_MSG_UME_REGISTRATION_SUCCESS_EX_FLAG_NOCACHE)
    +00121                  printf("NOCACHE ");
    +00122              if (dereg->flags & LBM_MSG_UME_REGISTRATION_SUCCESS_EX_FLAG_RPP)
    +00123                  printf("RPP ");
    +00124              printf("\n");
    +00125              break;
    +00126          }
     
    @@ -231,9 +233,9 @@

    UMP Deregistration Complete (LBM_MSG_UME_DEREGISTRATION_COMPLETE_EX)

    should be logged. Topic name and source information are sufficient for this callback.

    -00107          case LBM_MSG_UME_DEREGISTRATION_COMPLETE_EX:
    -00108              printf("[%s][%s] UME deregistration complete.\n", msg->topic_name, msg->source);
    -00109              break;
    +00127          case LBM_MSG_UME_DEREGISTRATION_COMPLETE_EX:
    +00128              printf("[%s][%s] UME deregistration complete.\n", msg->topic_name, msg->source);
    +00129              break;
     
    @@ -242,9 +244,9 @@

    UMP Registration Change (LBM_MSG_UME_REGISTRATION_CHANGE)

    the message data should be printed here. The message data will have the change that has been made to registration.

    -00110          case LBM_MSG_UME_REGISTRATION_CHANGE:
    -00111              printf("[%s][%s] UME registration change: %s\n", msg->topic_name, msg->source, msg->data);
    -00112              break;
    +00130          case LBM_MSG_UME_REGISTRATION_CHANGE:
    +00131              printf("[%s][%s] UME registration change: %s\n", msg->topic_name, msg->source, msg->data);
    +00132              break;
     
    @@ -253,9 +255,9 @@

    Other

    other callbacks that could be handled for UMP. However, new callbacks are added, so it's good in the event of a library upgrade.

    -00113          default:
    -00114              printf("Other event, type=%x\n", msg->type);
    -00115              break;
    +00133          default:
    +00134              printf("Other event, type=%x\n", msg->type);
    +00135              break;
     
    @@ -264,20 +266,20 @@

    Includes

    are not necessary for Linux only applications

    -00003  #include <stdio.h>
    -00004  
    -00005  #if defined(_MSC_VER)
    -00006  /* Windows-only includes */
    -00007  #include <winsock2.h>
    -00008  #define SLEEP(s) Sleep((s)*1000)
    -00009  #else
    -00010  /* Unix-only includes */
    -00011  #include <stdlib.h>
    -00012  #include <unistd.h>
    -00013  #define SLEEP(s) sleep(s)
    -00014  #endif
    -00015  
    -00016  #include <lbm/lbm.h>
    +00022  #include <stdio.h>
    +00023  
    +00024  #if defined(_MSC_VER)
    +00025  /* Windows-only includes */
    +00026  #include <winsock2.h>
    +00027  #define SLEEP(s) Sleep((s)*1000)
    +00028  #else
    +00029  /* Unix-only includes */
    +00030  #include <stdlib.h>
    +00031  #include <unistd.h>
    +00032  #define SLEEP(s) sleep(s)
    +00033  #endif
    +00034  
    +00035  #include <lbm/lbm.h>
     
    @@ -285,16 +287,16 @@

    Windows Only

    Windows applications must initialize the Winsock library to utilize sockets.

    -00129  #if defined(_WIN32)
    -00130      /* windows-specific code */
    -00131      WSADATA wsadata;
    -00132      int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata);
    -00133      if (wsStat != 0)
    -00134      {
    -00135          printf("line %d: wsStat=%d\n",__LINE__,wsStat);
    -00136          exit(1);
    -00137      }
    -00138  #endif
    +00149  #if defined(_WIN32)
    +00150      /* windows-specific code */
    +00151      WSADATA wsadata;
    +00152      int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata);
    +00153      if (wsStat != 0)
    +00154      {
    +00155          printf("line %d: wsStat=%d\n",__LINE__,wsStat);
    +00156          exit(1);
    +00157      }
    +00158  #endif
     
    diff --git a/ump_receiver_callbacks/c/ump_receiver_callbacks_c.slsrc b/ump_receiver_callbacks/c/ump_receiver_callbacks_c.slsrc index 0cd5bbc..e439fc8 100644 --- a/ump_receiver_callbacks/c/ump_receiver_callbacks_c.slsrc +++ b/ump_receiver_callbacks/c/ump_receiver_callbacks_c.slsrc @@ -1,4 +1,23 @@ -/* ump_receiver_callbacks.c - http://ultramessaging.github.io/UMExamples */ +/* ump_receiver_callbacks.c - see http://ultramessaging.github.io/UMExamples/ump_receiver_callbacks/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ /* =semlit,block,includes=*/ #include @@ -19,18 +38,17 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) + /* Callback used to handle request message for receiver */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { - int err; - switch (msg->type) { /* =semlit,block,data=*/ case LBM_MSG_DATA: @@ -41,9 +59,11 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) /* =semlit,endblock,data=*/ /* =semlit,block,request=*/ case LBM_MSG_REQUEST: - printf("REQUEST [%s][%s][%d]%s%s, %u bytes\n", msg->topic_name, msg->source, msg->sequence_number, - ((msg->flags & LBM_MSG_FLAG_UME_RETRANSMIT) ? "-RX-" : ""), - ((msg->flags & LBM_MSG_FLAG_OTR) ? "-OTR-" : ""), (unsigned int)msg->len); + printf("REQUEST [%s][%s][%d]%s%s, %u bytes\n", msg->topic_name, + msg->source, msg->sequence_number, + ((msg->flags & LBM_MSG_FLAG_UME_RETRANSMIT) ? "-RX-" : ""), + ((msg->flags & LBM_MSG_FLAG_OTR) ? "-OTR-" : ""), + (unsigned int)msg->len); break; /* =semlit,endblock,request=*/ /* =semlit,block,loss=*/ @@ -97,7 +117,7 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) /* =semlit,endblock,reg_success=*/ /* =semlit,block,reg_complete=*/ case LBM_MSG_UME_REGISTRATION_COMPLETE_EX: - { + { lbm_msg_ume_registration_complete_ex_t *reg = (lbm_msg_ume_registration_complete_ex_t *)(msg->data); printf("[%s][%s] UME registration complete. SQN %x. Flags %x ", msg->topic_name, msg->source, reg->sequence_number, reg->flags); @@ -146,15 +166,15 @@ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) } return 0; -} +} /* rcv_handle_msg */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ - lbm_topic_t *rtopic; /* Receiver Topic object */ - int err; /* Used for checking API return codes */ + lbm_context_t *ctx; /* Context object */ + lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ + lbm_topic_t *rtopic; /* Receiver Topic object */ + int err; /* =semlit,block,windows=*/ #if defined(_WIN32) @@ -176,12 +196,13 @@ int main(int argc, char **argv) /* Create receiver for receiving request and sending response */ err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL); - EX_LBM_CHK(err); + EX_LBM_CHK(err); err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); EX_LBM_CHK(err); /* =semlit,endblock,ctx_rcv_create=*/ + /* Wait forever (or until control-c). */ while (1) { } err = lbm_rcv_delete(rcv); @@ -194,5 +215,6 @@ int main(int argc, char **argv) /* Windows-specific cleanup overhead */ WSACleanup(); #endif - return 0; -} /* main */ + + return 0; +} /* main */ diff --git a/ump_receiver_callbacks/c/ump_receiver_callbacks_c.slsrc.html b/ump_receiver_callbacks/c/ump_receiver_callbacks_c.slsrc.html index 650a54a..4e0e742 100644 --- a/ump_receiver_callbacks/c/ump_receiver_callbacks_c.slsrc.html +++ b/ump_receiver_callbacks/c/ump_receiver_callbacks_c.slsrc.html @@ -18,169 +18,210 @@
    00001 00002 -00003 -00004 -00005 -00006 -00007 -00008 -00009 -00010 -00011 -00012 -00013 -00014 -00015 -00016 +00003 +00004 +00005 +00006 +00007 +00008 +00009 +00010 +00011 +00012 +00013 +00014 +00015 +00016 00017 00018 00019 00020 00021 -00022 -00023 -00024 -00025 -00026 -00027 -00028 -00029 -00030 -00031 -00032 -00033 -00034 -00035 -00036 -00037 -00038 -00039 -00040 -00041 -00042 -00043 -00044 -00045 -00046 -00047 -00048 -00049 -00050 -00051 -00052 -00053 -00054 -00055 -00056 -00057 -00058 -00059 -00060 -00061 -00062 -00063 -00064 -00065 -00066 -00067 -00068 -00069 -00070 -00071 -00072 -00073 -00074 -00075 -00076 -00077 -00078 -00079 -00080 -00081 -00082 -00083 -00084 -00085 -00086 -00087 -00088 -00089 -00090 -00091 -00092 -00093 -00094 -00095 -00096 -00097 -00098 -00099 -00100 -00101 -00102 -00103 -00104 -00105 -00106 -00107 -00108 -00109 -00110 -00111 -00112 -00113 -00114 -00115 -00116 -00117 -00118 -00119 -00120 -00121 -00122 -00123 -00124 -00125 -00126 -00127 -00128 -00129 -00130 -00131 -00132 -00133 -00134 -00135 -00136 -00137 -00138 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 +00036 +00037 +00038 +00039 +00040 +00041 +00042 +00043 +00044 +00045 +00046 +00047 +00048 +00049 +00050 +00051 +00052 +00053 +00054 +00055 +00056 +00057 +00058 +00059 +00060 +00061 +00062 +00063 +00064 +00065 +00066 +00067 +00068 +00069 +00070 +00071 +00072 +00073 +00074 +00075 +00076 +00077 +00078 +00079 +00080 +00081 +00082 +00083 +00084 +00085 +00086 +00087 +00088 +00089 +00090 +00091 +00092 +00093 +00094 +00095 +00096 +00097 +00098 +00099 +00100 +00101 +00102 +00103 +00104 +00105 +00106 +00107 +00108 +00109 +00110 +00111 +00112 +00113 +00114 +00115 +00116 +00117 +00118 +00119 +00120 +00121 +00122 +00123 +00124 +00125 +00126 +00127 +00128 +00129 +00130 +00131 +00132 +00133 +00134 +00135 +00136 +00137 +00138 00139 -00140 -00141 -00142 -00143 -00144 -00145 -00146 -00147 -00148 -00149 -00150 -00151 -00152 -00153 -00154 -00155 -00156 -00157 -00158 +00140 +00141 +00142 +00143 +00144 +00145 +00146 +00147 +00148 +00149 +00150 +00151 +00152 +00153 +00154 +00155 +00156 +00157 +00158 00159 -00160 -00161 -00162 -00163 -00164 - /* ump_receiver_callbacks.c - http://ultramessaging.github.io/UMExamples */ +00160 +00161 +00162 +00163 +00164 +00165 +00166 +00167 +00168 +00169 +00170 +00171 +00172 +00173 +00174 +00175 +00176 +00177 +00178 +00179 +00180 +00181 +00182 +00183 +00184 +00185 +00186 + /* ump_receiver_callbacks.c - see http://ultramessaging.github.io/UMExamples/ump_receiver_callbacks/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include <stdio.h> @@ -199,18 +240,17 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) + /* Callback used to handle request message for receiver */ int rcv_handle_msg(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { - int err; - switch (msg->type) { case LBM_MSG_DATA: printf("DATA [%s][%s][%d]%s%s, %u bytes\n", msg->topic_name, msg->source, msg->sequence_number, @@ -218,9 +258,11 @@ ((msg->flags & LBM_MSG_FLAG_OTR) ? "-OTR-" : ""), (unsigned int)msg->len); break; case LBM_MSG_REQUEST: - printf("REQUEST [%s][%s][%d]%s%s, %u bytes\n", msg->topic_name, msg->source, msg->sequence_number, - ((msg->flags & LBM_MSG_FLAG_UME_RETRANSMIT) ? "-RX-" : ""), - ((msg->flags & LBM_MSG_FLAG_OTR) ? "-OTR-" : ""), (unsigned int)msg->len); + printf("REQUEST [%s][%s][%d]%s%s, %u bytes\n", msg->topic_name, + msg->source, msg->sequence_number, + ((msg->flags & LBM_MSG_FLAG_UME_RETRANSMIT) ? "-RX-" : ""), + ((msg->flags & LBM_MSG_FLAG_OTR) ? "-OTR-" : ""), + (unsigned int)msg->len); break; case LBM_MSG_UNRECOVERABLE_LOSS: printf("[%s][%s][%x], LOST\n", msg->topic_name, msg->source, msg->sequence_number); @@ -258,7 +300,7 @@ break; } case LBM_MSG_UME_REGISTRATION_COMPLETE_EX: - { + { lbm_msg_ume_registration_complete_ex_t *reg = (lbm_msg_ume_registration_complete_ex_t *)(msg->data); printf("[%s][%s] UME registration complete. SQN %x. Flags %x ", msg->topic_name, msg->source, reg->sequence_number, reg->flags); @@ -298,15 +340,15 @@ } return 0; - } + } /* rcv_handle_msg */ + int main(int argc, char **argv) { - lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ - lbm_topic_t *rtopic; /* Receiver Topic object */ - int err; /* Used for checking API return codes */ + lbm_context_t *ctx; /* Context object */ + lbm_rcv_t *rcv; /* Receive object: for subscribing to messages. */ + lbm_topic_t *rtopic; /* Receiver Topic object */ + int err; #if defined(_WIN32) /* windows-specific code */ @@ -325,11 +367,12 @@ /* Create receiver for receiving request and sending response */ err = lbm_rcv_topic_lookup(&rtopic, ctx, "test.topic", NULL); - EX_LBM_CHK(err); + EX_LBM_CHK(err); err = lbm_rcv_create(&rcv, ctx, rtopic, rcv_handle_msg, NULL, NULL); EX_LBM_CHK(err); + /* Wait forever (or until control-c). */ while (1) { } err = lbm_rcv_delete(rcv); @@ -342,8 +385,9 @@ /* Windows-specific cleanup overhead */ WSACleanup(); #endif - return 0; - } /* main */ + + return 0; + } /* main */
    diff --git a/ump_src_failover/c/ump_src_failover.c b/ump_src_failover/c/ump_src_failover.c index 5bd328b..8266c3f 100644 --- a/ump_src_failover/c/ump_src_failover.c +++ b/ump_src_failover/c/ump_src_failover.c @@ -1,4 +1,23 @@ -/* ump_src_failover.c */ +/* ump_src_failover.c - see http://ultramessaging.github.io/UMExamples/ump_src_failover/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include #include @@ -24,11 +43,11 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) /* Store configurations */ @@ -41,168 +60,178 @@ typedef enum {NOT_INIT, INIT, READY, UNRESP} state_type_e; typedef enum {PRIMARY, BACKUP} mode_type_e; typedef struct app_src_s { - lbm_context_t *ctx; - lbm_src_t *src; - state_type_e state; - mode_type_e mode; + lbm_context_t *ctx; + lbm_src_t *src; + state_type_e state; + mode_type_e mode; } app_src_s; + /* Source event handler callback (passed into lbm_src_create()) */ int handle_src_event(lbm_src_t *src, int event, void *ed, void *cd) { - struct app_src_s *app_src = (struct app_src_s *)cd; - switch (event) { - /* Success event provided only for printing purposes */ - case LBM_SRC_EVENT_UME_REGISTRATION_SUCCESS_EX: - { - lbm_src_event_ume_registration_ex_t *reg = (lbm_src_event_ume_registration_ex_t *)ed; - printf("UME store %u: %s registration success.\n", reg->store_index, reg->store); - break; - } - case LBM_SRC_EVENT_UME_REGISTRATION_COMPLETE_EX: - { - lbm_src_event_ume_registration_complete_ex_t *reg = (lbm_src_event_ume_registration_complete_ex_t *)ed; - - printf("UME registration complete. SQN %x.\n", reg->sequence_number); - - app_src->state = READY; - break; - } - case LBM_SRC_EVENT_UME_STORE_UNRESPONSIVE: - { - const char *infostr = (const char *)ed; - - printf("UME store: %s\n", infostr); - if (strstr(infostr, "quorum lost") != NULL) - app_src->state = UNRESP; - break; - } - } - - return 0; -} + struct app_src_s *app_src = (struct app_src_s *)cd; + switch (event) { + /* Success event provided only for printing purposes */ + case LBM_SRC_EVENT_UME_REGISTRATION_SUCCESS_EX: + { + lbm_src_event_ume_registration_ex_t *reg = (lbm_src_event_ume_registration_ex_t *)ed; + printf("UME store %u: %s registration success.\n", reg->store_index, reg->store); + break; + } + case LBM_SRC_EVENT_UME_REGISTRATION_COMPLETE_EX: + { + lbm_src_event_ume_registration_complete_ex_t *reg = (lbm_src_event_ume_registration_complete_ex_t *)ed; + + printf("UME registration complete. SQN %x.\n", reg->sequence_number); + + app_src->state = READY; + break; + } + case LBM_SRC_EVENT_UME_STORE_UNRESPONSIVE: + { + const char *infostr = (const char *)ed; + + printf("UME store: %s\n", infostr); + if (strstr(infostr, "quorum lost") != NULL) + app_src->state = UNRESP; + break; + } + } + + return 0; +} /* handle_src_event */ + int init_src(app_src_s *app_src) { - lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ - lbm_topic_t *topic; /* Topic object */ - int err; /* Used for checking API return codes */ + lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ + lbm_topic_t *topic; /* Topic object */ + int err; + + err = lbm_src_topic_attr_create(&tattr); + EX_LBM_CHK(err); - err = lbm_src_topic_attr_create(&tattr); - EX_LBM_CHK(err); + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_CLEAR_STORE_CONFIG); + EX_LBM_CHK(err); - err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_CLEAR_STORE_CONFIG); - EX_LBM_CHK(err); + /* Assuming there are stores running on the localhost */ + if (app_src->mode == PRIMARY) { + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_PRIMARY_STORE); + EX_LBM_CHK(err); + } + else { + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_SECONDARY_STORE); + EX_LBM_CHK(err); + } - /* Assuming there are stores running on the localhost */ - if (app_src->mode == PRIMARY) - err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_PRIMARY_STORE); - else - err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_SECONDARY_STORE); - EX_LBM_CHK(err); + if (app_src->mode == PRIMARY) { + err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_PRIMARY_SESSION_ID); + EX_LBM_CHK(err); + } + else { + err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_SECONDARY_SESSION_ID); + EX_LBM_CHK(err); + } - if (app_src->mode == PRIMARY) - err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_PRIMARY_SESSION_ID); - else - err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_SECONDARY_SESSION_ID); - EX_LBM_CHK(err); + /* Need to set store behavior to Quorum-Consensus */ + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store_behavior", "qc"); + EX_LBM_CHK(err); - /* Need to set store behavior to Quorum-Consensus */ - err = lbm_src_topic_attr_str_setopt(tattr, "ume_store_behavior", "qc"); - EX_LBM_CHK(err); + err = lbm_src_topic_alloc(&topic, app_src->ctx, "test.topic", tattr); + EX_LBM_CHK(err); - err = lbm_src_topic_alloc(&topic, app_src->ctx, "test.topic", tattr); - EX_LBM_CHK(err); + err = lbm_src_create(&(app_src->src), app_src->ctx, topic, handle_src_event, app_src, NULL); + EX_LBM_CHK(err); - err = lbm_src_create(&(app_src->src), app_src->ctx, topic, handle_src_event, app_src, NULL); - EX_LBM_CHK(err); + app_src->state = INIT; + + return 0; +} /* init_src */ - app_src->state = INIT; -} void failover_app_src(app_src_s *app_src) { - int err; /* Used for checking API return codes */ - - /* Delete the source */ - err = lbm_src_delete(app_src->src); - EX_LBM_CHK(err); + int err; + + /* Delete the source */ + err = lbm_src_delete(app_src->src); + EX_LBM_CHK(err); + + app_src->src = NULL; + app_src->state = NOT_INIT; + app_src->mode = BACKUP; +} /* failover_app_src */ - app_src->src = NULL; - app_src->state = NOT_INIT; - app_src->mode = BACKUP; -} /* Provided simply for printing the state name */ const char* source_state(app_src_s *app_src) { - switch (app_src->state) - { - case NOT_INIT: return "NOT_INIT"; - case INIT: return "INIT"; - case READY: return "READY"; - case UNRESP: return "UNRESP"; - } -} + switch (app_src->state) + { + case NOT_INIT: return "NOT_INIT"; + case INIT: return "INIT"; + case READY: return "READY"; + case UNRESP: return "UNRESP"; + } + return NULL; +} /* source_state */ + int main(int argc, char **argv) { - app_src_s app_src; /* App structure to track source */ - lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - int err; /* Used for checking API return codes */ + app_src_s app_src; /* App structure to track source */ + lbm_context_t *ctx; /* Context object */ + int err; #if defined(_WIN32) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + exit(1); + } #endif - err = lbm_context_attr_create(&cattr); - EX_LBM_CHK(err); - - err = lbm_context_create(&ctx, cattr, NULL, NULL); - EX_LBM_CHK(err); - - app_src.state = NOT_INIT; - app_src.mode = PRIMARY; - app_src.ctx = ctx; - - while(1) - { - /* Initialize the source if we're not initialized */ - if (app_src.state == NOT_INIT) - init_src(&app_src); - - if (app_src.state == READY) - { - if (lbm_src_send(app_src.src, "test", 4, LBM_SRC_NONBLOCK) == LBM_FAILURE) - { - /* Assume EWOULDBLOCK and wait */ - SLEEP_SEC(1); - } - } - else - { - /* Print a warning that the source is not ready and sleep */ - printf("Source cannot send: %d. Source State: %s\n", lbm_errnum(), source_state(&app_src)); - if (app_src.state == UNRESP && app_src.mode == PRIMARY) - { - printf("Primary store unresponsive, failing over to backup\n"); - failover_app_src(&app_src); - } - else if (app_src.state == UNRESP && app_src.mode == BACKUP) - { - printf("Backup store unresponsive. Exiting\n"); - exit(1); - } - SLEEP_SEC(1); - } - } - return 0; -} + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); + + app_src.state = NOT_INIT; + app_src.mode = PRIMARY; + app_src.ctx = ctx; + + while(1) + { + /* Initialize the source if we're not initialized */ + if (app_src.state == NOT_INIT) + init_src(&app_src); + + if (app_src.state == READY) + { + if (lbm_src_send(app_src.src, "test", 4, LBM_SRC_NONBLOCK) == LBM_FAILURE) + { + /* Assume EWOULDBLOCK and wait */ + SLEEP_SEC(1); + } + } + else + { + /* Print a warning that the source is not ready and sleep */ + printf("Source cannot send: %d. Source State: %s\n", lbm_errnum(), source_state(&app_src)); + if (app_src.state == UNRESP && app_src.mode == PRIMARY) + { + printf("Primary store unresponsive, failing over to backup\n"); + failover_app_src(&app_src); + } + else if (app_src.state == UNRESP && app_src.mode == BACKUP) + { + printf("Backup store unresponsive. Exiting\n"); + exit(1); + } + SLEEP_SEC(1); + } + } + return 0; +} /* main */ diff --git a/ump_src_failover/c/ump_src_failover.sldoc.html b/ump_src_failover/c/ump_src_failover.sldoc.html index edab874..1b4e56a 100644 --- a/ump_src_failover/c/ump_src_failover.sldoc.html +++ b/ump_src_failover/c/ump_src_failover.sldoc.html @@ -46,10 +46,10 @@

    Defining Store Configurations

    configuration files.

    -00035  #define UMP_PRIMARY_STORE "127.0.0.1:29999"
    -00036  #define UMP_PRIMARY_SESSION_ID "100"
    -00037  #define UMP_SECONDARY_STORE "127.0.0.1:30000"
    -00038  #define UMP_SECONDARY_SESSION_ID "200"
    +00054  #define UMP_PRIMARY_STORE "127.0.0.1:29999"
    +00055  #define UMP_PRIMARY_SESSION_ID "100"
    +00056  #define UMP_SECONDARY_STORE "127.0.0.1:30000"
    +00057  #define UMP_SECONDARY_SESSION_ID "200"
     
    @@ -105,7 +105,7 @@

    Defining Store Configurations

    defined as a global attribute:

    -00039  #define UMP_CLEAR_STORE_CONFIG "0.0.0.0:0"
    +00058  #define UMP_CLEAR_STORE_CONFIG "0.0.0.0:0"
     
    @@ -122,14 +122,14 @@

    Define a Custom Source Object

    as store the pointer object to the source itself and the sources context

    -00041  typedef enum {NOT_INIT, INIT, READY, UNRESP} state_type_e;
    -00042  typedef enum {PRIMARY, BACKUP} mode_type_e;
    -00043  typedef struct app_src_s {
    -00044          lbm_context_t *ctx;
    -00045          lbm_src_t *src;
    -00046          state_type_e state;
    -00047          mode_type_e mode;
    -00048  } app_src_s;
    +00060  typedef enum {NOT_INIT, INIT, READY, UNRESP} state_type_e;
    +00061  typedef enum {PRIMARY, BACKUP} mode_type_e;
    +00062  typedef struct app_src_s {
    +00063      lbm_context_t *ctx;
    +00064      lbm_src_t *src;
    +00065      state_type_e state;
    +00066      mode_type_e mode;
    +00067  } app_src_s;
     
    @@ -137,11 +137,8 @@

    Create the Context

    Standard UM code to initialize and create an LBM context:

    -00166          err = lbm_context_attr_create(&cattr);
    -00167          EX_LBM_CHK(err);
    -00168  
    -00169          err = lbm_context_create(&ctx, cattr, NULL, NULL);
    -00170          EX_LBM_CHK(err);
    +00198      err = lbm_context_create(&ctx, NULL, NULL, NULL);
    +00199      EX_LBM_CHK(err);
     
    @@ -151,9 +148,9 @@

    Initializing the Customer Source Object

    created within it:

    -00172          app_src.state = NOT_INIT;
    -00173          app_src.mode = PRIMARY;
    -00174          app_src.ctx = ctx;
    +00201      app_src.state = NOT_INIT;
    +00202      app_src.mode = PRIMARY;
    +00203      app_src.ctx = ctx;
     
    @@ -162,8 +159,8 @@

    Configuring the Stores and Creating the Source

    the loop, the application intializes/creates a source:

    -00179                  if (app_src.state == NOT_INIT)
    -00180                          init_src(&app_src);
    +00208          if (app_src.state == NOT_INIT)
    +00209              init_src(&app_src);
     
    @@ -189,11 +186,11 @@

    Configuring the Stores and Creating the Source

    to "0.0.0.0:0":

    -00091          err = lbm_src_topic_attr_create(&tattr);
    -00092          EX_LBM_CHK(err);
    -00093  
    -00094          err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_CLEAR_STORE_CONFIG);
    -00095          EX_LBM_CHK(err);
    +00112      err = lbm_src_topic_attr_create(&tattr);
    +00113      EX_LBM_CHK(err);
    +00114  
    +00115      err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_CLEAR_STORE_CONFIG);
    +00116      EX_LBM_CHK(err);
     
    @@ -201,31 +198,37 @@

    Configuring the Stores and Creating the Source

    initialized to PRIMARY, so it'll use the primary stores and associated SessionID:

    -00098          if (app_src->mode == PRIMARY) 
    -00099                  err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_PRIMARY_STORE);
    -00100          else
    -00101                  err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_SECONDARY_STORE);
    -00102          EX_LBM_CHK(err);
    -00103  
    -00104          if (app_src->mode == PRIMARY)
    -00105                  err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_PRIMARY_SESSION_ID);
    -00106          else
    -00107                  err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_SECONDARY_SESSION_ID);
    -00108          EX_LBM_CHK(err);
    +00119      if (app_src->mode == PRIMARY) {
    +00120          err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_PRIMARY_STORE);
    +00121          EX_LBM_CHK(err);
    +00122      }
    +00123      else {
    +00124          err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_SECONDARY_STORE);
    +00125          EX_LBM_CHK(err);
    +00126      }
    +00127  
    +00128      if (app_src->mode == PRIMARY) {
    +00129          err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_PRIMARY_SESSION_ID);
    +00130          EX_LBM_CHK(err);
    +00131      }
    +00132      else {
    +00133          err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_SECONDARY_SESSION_ID);
    +00134          EX_LBM_CHK(err);
    +00135      }
     

    Finally the sample sets the store behavior to use quorum/consensus and creates the source object:

    -00111          err = lbm_src_topic_attr_str_setopt(tattr, "ume_store_behavior", "qc");
    -00112          EX_LBM_CHK(err);
    -00113  
    -00114          err = lbm_src_topic_alloc(&topic, app_src->ctx, "test.topic", tattr);
    -00115          EX_LBM_CHK(err);
    -00116  
    -00117          err = lbm_src_create(&(app_src->src), app_src->ctx, topic, handle_src_event, app_src, NULL);
    -00118          EX_LBM_CHK(err);
    +00138      err = lbm_src_topic_attr_str_setopt(tattr, "ume_store_behavior", "qc");
    +00139      EX_LBM_CHK(err);
    +00140  
    +00141      err = lbm_src_topic_alloc(&topic, app_src->ctx, "test.topic", tattr);
    +00142      EX_LBM_CHK(err);
    +00143  
    +00144      err = lbm_src_create(&(app_src->src), app_src->ctx, topic, handle_src_event, app_src, NULL);
    +00145      EX_LBM_CHK(err);
     
    @@ -236,15 +239,15 @@

    Handling Source Events / Updating Source State

    registration complete event is coded into the source event handler function, and the complete event should like this:

    -00062          case LBM_SRC_EVENT_UME_REGISTRATION_COMPLETE_EX:
    -00063          {
    -00064                  lbm_src_event_ume_registration_complete_ex_t *reg = (lbm_src_event_ume_registration_complete_ex_t *)ed;
    -00065  
    -00066                  printf("UME registration complete. SQN %x.\n", reg->sequence_number);
    -00067  
    -00068                  app_src->state = READY;
    -00069                  break;
    -00070          }
    +00082      case LBM_SRC_EVENT_UME_REGISTRATION_COMPLETE_EX:
    +00083      {
    +00084          lbm_src_event_ume_registration_complete_ex_t *reg = (lbm_src_event_ume_registration_complete_ex_t *)ed;
    +00085  
    +00086          printf("UME registration complete. SQN %x.\n", reg->sequence_number);
    +00087  
    +00088          app_src->state = READY;
    +00089          break;
    +00090      }
     
    @@ -253,15 +256,15 @@

    Handling Source Events / Updating Source State

    is lost, the source state must be updated to note this change because it can no longer send messages:

    -00071          case LBM_SRC_EVENT_UME_STORE_UNRESPONSIVE:
    -00072          {
    -00073                  const char *infostr = (const char *)ed;
    -00074                  
    -00075                  printf("UME store: %s\n", infostr);
    -00076                  if (strstr(infostr, "quorum lost") != NULL)
    -00077                          app_src->state = UNRESP;
    -00078                  break;
    -00079          }
    +00091      case LBM_SRC_EVENT_UME_STORE_UNRESPONSIVE:
    +00092      {
    +00093          const char *infostr = (const char *)ed;
    +00094          
    +00095          printf("UME store: %s\n", infostr);
    +00096          if (strstr(infostr, "quorum lost") != NULL)
    +00097              app_src->state = UNRESP;
    +00098          break;
    +00099      }
     
    @@ -283,11 +286,11 @@

    Automatic Failover

    So here is the sample application failing over once the main loop has detected the state as UNRESP:

    -00194                          if (app_src.state == UNRESP && app_src.mode == PRIMARY)
    -00195                          {
    -00196                                  printf("Primary store unresponsive, failing over to backup\n");
    -00197                                  failover_app_src(&app_src);
    -00198                          }
    +00223              if (app_src.state == UNRESP && app_src.mode == PRIMARY)
    +00224              {
    +00225                  printf("Primary store unresponsive, failing over to backup\n");
    +00226                  failover_app_src(&app_src);
    +00227              }
     
    @@ -300,28 +303,28 @@

    Delete the Source and Reset State

    First, the source gets deleted:

    -00128          err = lbm_src_delete(app_src->src);
    -00129          EX_LBM_CHK(err);
    +00158      err = lbm_src_delete(app_src->src);
    +00159      EX_LBM_CHK(err);
     

    Then the state gets updated to NOT_INIT, and the mode set to backup so the backup stores can be configured upon initialization:

    -00131          app_src->src = NULL;
    -00132          app_src->state = NOT_INIT;
    -00133          app_src->mode = BACKUP;
    +00161      app_src->src = NULL;
    +00162      app_src->state = NOT_INIT;
    +00163      app_src->mode = BACKUP;
     

    In the event that the backup store goes unresponsive, the sample application is simply coded to exit at this point:

    -00199                          else if (app_src.state == UNRESP && app_src.mode == BACKUP)
    -00200                          {
    -00201                                  printf("Backup store unresponsive. Exiting\n");
    -00202                                  exit(1);
    -00203                          }
    +00228              else if (app_src.state == UNRESP && app_src.mode == BACKUP)
    +00229              {
    +00230                  printf("Backup store unresponsive. Exiting\n");
    +00231                  exit(1);
    +00232              }
     
    @@ -342,21 +345,21 @@

    Includes

    Include files for this application. Notice the Windows specific include files - these are not necessary for Linux only applications

    -00003  #include <stdio.h>
    -00004  #include <string.h>
    -00005  
    -00006  #if defined(_MSC_VER)
    -00007  /* Windows-only includes */
    -00008  #include <winsock2.h>
    -00009  #define SLEEP(s) Sleep((s)*1000)
    -00010  #else
    -00011  /* Unix-only includes */
    -00012  #include <stdlib.h>
    -00013  #include <unistd.h>
    -00014  #define SLEEP(s) sleep(s)
    -00015  #endif
    -00016  
    -00017  #include <lbm/lbm.h>
    +00022  #include <stdio.h>
    +00023  #include <string.h>
    +00024  
    +00025  #if defined(_MSC_VER)
    +00026  /* Windows-only includes */
    +00027  #include <winsock2.h>
    +00028  #define SLEEP(s) Sleep((s)*1000)
    +00029  #else
    +00030  /* Unix-only includes */
    +00031  #include <stdlib.h>
    +00032  #include <unistd.h>
    +00033  #define SLEEP(s) sleep(s)
    +00034  #endif
    +00035  
    +00036  #include <lbm/lbm.h>
     
    @@ -365,11 +368,11 @@

    Sleep helper function

    sleep() for any number of seconds.

    -00019  #if defined(_WIN32)
    -00020  #   define SLEEP_SEC(x) Sleep((x)*1000)
    -00021  #else
    -00022  #   define SLEEP_SEC(x) sleep(x)
    -00023  #endif
    +00038  #if defined(_WIN32)
    +00039  #   define SLEEP_SEC(x) Sleep((x)*1000)
    +00040  #else
    +00041  #   define SLEEP_SEC(x) sleep(x)
    +00042  #endif
     
    diff --git a/ump_src_failover/c/ump_src_failover_c.slsrc b/ump_src_failover/c/ump_src_failover_c.slsrc index 396a414..73ea8a5 100644 --- a/ump_src_failover/c/ump_src_failover_c.slsrc +++ b/ump_src_failover/c/ump_src_failover_c.slsrc @@ -1,4 +1,23 @@ -/* ump_src_failover.c */ +/* ump_src_failover.c - see http://ultramessaging.github.io/UMExamples/ump_src_failover/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ /* =semlit,block,includes=*/ #include @@ -29,11 +48,11 @@ /* Example error checking macro. Include after each UM call. */ /* =semlit,block,errors=*/ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) /* =semlit,endblock,errors=*/ @@ -52,207 +71,217 @@ typedef enum {NOT_INIT, INIT, READY, UNRESP} state_type_e; typedef enum {PRIMARY, BACKUP} mode_type_e; typedef struct app_src_s { - lbm_context_t *ctx; - lbm_src_t *src; - state_type_e state; - mode_type_e mode; + lbm_context_t *ctx; + lbm_src_t *src; + state_type_e state; + mode_type_e mode; } app_src_s; /* =semlit,endblock,app_src_struct=*/ + /* Source event handler callback (passed into lbm_src_create()) */ int handle_src_event(lbm_src_t *src, int event, void *ed, void *cd) { - struct app_src_s *app_src = (struct app_src_s *)cd; - switch (event) { - /* Success event provided only for printing purposes */ - case LBM_SRC_EVENT_UME_REGISTRATION_SUCCESS_EX: - { - lbm_src_event_ume_registration_ex_t *reg = (lbm_src_event_ume_registration_ex_t *)ed; - printf("UME store %u: %s registration success.\n", reg->store_index, reg->store); - break; - } - /* =semlit,block,reg_complete=*/ - case LBM_SRC_EVENT_UME_REGISTRATION_COMPLETE_EX: - { - lbm_src_event_ume_registration_complete_ex_t *reg = (lbm_src_event_ume_registration_complete_ex_t *)ed; - - printf("UME registration complete. SQN %x.\n", reg->sequence_number); - - /* =semlit,block,update_state_ready=*/ - app_src->state = READY; - /* =semlit,endblock,update_state_ready=*/ - break; - } - /* =semlit,endblock,reg_complete=*/ - /* =semlit,block,unresponsive=*/ - case LBM_SRC_EVENT_UME_STORE_UNRESPONSIVE: - { - const char *infostr = (const char *)ed; - - printf("UME store: %s\n", infostr); - /* =semlit,block,update_state_UNRESP=*/ - if (strstr(infostr, "quorum lost") != NULL) - app_src->state = UNRESP; - /* =semlit,endblock,update_state_UNRESP=*/ - break; - } - /* =semlit,endblock,unresponsive=*/ - } - - return 0; -} + struct app_src_s *app_src = (struct app_src_s *)cd; + switch (event) { + /* Success event provided only for printing purposes */ + case LBM_SRC_EVENT_UME_REGISTRATION_SUCCESS_EX: + { + lbm_src_event_ume_registration_ex_t *reg = (lbm_src_event_ume_registration_ex_t *)ed; + printf("UME store %u: %s registration success.\n", reg->store_index, reg->store); + break; + } + /* =semlit,block,reg_complete=*/ + case LBM_SRC_EVENT_UME_REGISTRATION_COMPLETE_EX: + { + lbm_src_event_ume_registration_complete_ex_t *reg = (lbm_src_event_ume_registration_complete_ex_t *)ed; + + printf("UME registration complete. SQN %x.\n", reg->sequence_number); + + /* =semlit,block,update_state_ready=*/ + app_src->state = READY; + /* =semlit,endblock,update_state_ready=*/ + break; + } + /* =semlit,endblock,reg_complete=*/ + /* =semlit,block,unresponsive=*/ + case LBM_SRC_EVENT_UME_STORE_UNRESPONSIVE: + { + const char *infostr = (const char *)ed; + + printf("UME store: %s\n", infostr); + /* =semlit,block,update_state_UNRESP=*/ + if (strstr(infostr, "quorum lost") != NULL) + app_src->state = UNRESP; + /* =semlit,endblock,update_state_UNRESP=*/ + break; + } + /* =semlit,endblock,unresponsive=*/ + } + + return 0; +} /* handle_src_event */ + int init_src(app_src_s *app_src) { - lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ - lbm_topic_t *topic; /* Topic object */ - int err; /* Used for checking API return codes */ - - /* =semlit,block,init_source_attr=*/ - err = lbm_src_topic_attr_create(&tattr); - EX_LBM_CHK(err); - - err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_CLEAR_STORE_CONFIG); - EX_LBM_CHK(err); - /* =semlit,endblock,init_source_attr=*/ - - /* Assuming there are stores running on the localhost */ - /* =semlit,block,set_store=*/ - if (app_src->mode == PRIMARY) - err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_PRIMARY_STORE); - else - err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_SECONDARY_STORE); - EX_LBM_CHK(err); - - if (app_src->mode == PRIMARY) - err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_PRIMARY_SESSION_ID); - else - err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_SECONDARY_SESSION_ID); - EX_LBM_CHK(err); - /* =semlit,endblock,set_store=*/ - - /* Need to set store behavior to Quorum-Consensus */ - /* =semlit,block,complete_init=*/ - err = lbm_src_topic_attr_str_setopt(tattr, "ume_store_behavior", "qc"); - EX_LBM_CHK(err); - - err = lbm_src_topic_alloc(&topic, app_src->ctx, "test.topic", tattr); - EX_LBM_CHK(err); - - err = lbm_src_create(&(app_src->src), app_src->ctx, topic, handle_src_event, app_src, NULL); - EX_LBM_CHK(err); - /* =semlit,endblock,complete_init=*/ - - /* =semlit,block,update_state_init=*/ - app_src->state = INIT; - /* =semlit,endblock,update_state_init=*/ -} + lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ + lbm_topic_t *topic; /* Topic object */ + int err; + + /* =semlit,block,init_source_attr=*/ + err = lbm_src_topic_attr_create(&tattr); + EX_LBM_CHK(err); + + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_CLEAR_STORE_CONFIG); + EX_LBM_CHK(err); + /* =semlit,endblock,init_source_attr=*/ + + /* Assuming there are stores running on the localhost */ + /* =semlit,block,set_store=*/ + if (app_src->mode == PRIMARY) { + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_PRIMARY_STORE); + EX_LBM_CHK(err); + } + else { + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_SECONDARY_STORE); + EX_LBM_CHK(err); + } + + if (app_src->mode == PRIMARY) { + err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_PRIMARY_SESSION_ID); + EX_LBM_CHK(err); + } + else { + err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_SECONDARY_SESSION_ID); + EX_LBM_CHK(err); + } + /* =semlit,endblock,set_store=*/ + + /* Need to set store behavior to Quorum-Consensus */ + /* =semlit,block,complete_init=*/ + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store_behavior", "qc"); + EX_LBM_CHK(err); + + err = lbm_src_topic_alloc(&topic, app_src->ctx, "test.topic", tattr); + EX_LBM_CHK(err); + + err = lbm_src_create(&(app_src->src), app_src->ctx, topic, handle_src_event, app_src, NULL); + EX_LBM_CHK(err); + /* =semlit,endblock,complete_init=*/ + + /* =semlit,block,update_state_init=*/ + app_src->state = INIT; + /* =semlit,endblock,update_state_init=*/ + + return 0; +} /* init_src */ + void failover_app_src(app_src_s *app_src) { - int err; /* Used for checking API return codes */ - - /* Delete the source */ - /* =semlit,block,delete_src=*/ - err = lbm_src_delete(app_src->src); - EX_LBM_CHK(err); - /* =semlit,endblock,delete_src=*/ - - /* =semlit,block,update_state_not_init=*/ - app_src->src = NULL; - app_src->state = NOT_INIT; - app_src->mode = BACKUP; - /* =semlit,endblock,update_state_not_init=*/ -} + int err; + + /* Delete the source */ + /* =semlit,block,delete_src=*/ + err = lbm_src_delete(app_src->src); + EX_LBM_CHK(err); + /* =semlit,endblock,delete_src=*/ + + /* =semlit,block,update_state_not_init=*/ + app_src->src = NULL; + app_src->state = NOT_INIT; + app_src->mode = BACKUP; + /* =semlit,endblock,update_state_not_init=*/ +} /* failover_app_src */ + /* Provided simply for printing the state name */ /* =semlit,block,print_state_helper=*/ const char* source_state(app_src_s *app_src) { - switch (app_src->state) - { - case NOT_INIT: return "NOT_INIT"; - case INIT: return "INIT"; - case READY: return "READY"; - case UNRESP: return "UNRESP"; - } -} + switch (app_src->state) + { + case NOT_INIT: return "NOT_INIT"; + case INIT: return "INIT"; + case READY: return "READY"; + case UNRESP: return "UNRESP"; + } + return NULL; +} /* source_state */ /* =semlit,endblock,print_state_helper=*/ + int main(int argc, char **argv) { - /* =semlit,block,variables=*/ - app_src_s app_src; /* App structure to track source */ - lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - int err; /* Used for checking API return codes */ - /* =semlit,endblock,variables=*/ + /* =semlit,block,variables=*/ + app_src_s app_src; /* App structure to track source */ + lbm_context_t *ctx; /* Context object */ + int err; + /* =semlit,endblock,variables=*/ #if defined(_WIN32) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + exit(1); + } #endif - /* =semlit,block,init_create_context=*/ - err = lbm_context_attr_create(&cattr); - EX_LBM_CHK(err); - - err = lbm_context_create(&ctx, cattr, NULL, NULL); - EX_LBM_CHK(err); - /* =semlit,endblock,init_create_context=*/ - - /* =semlit,block,init_app_src=*/ - app_src.state = NOT_INIT; - app_src.mode = PRIMARY; - app_src.ctx = ctx; - /* =semlit,endblock,init_app_src=*/ - - /* =semlit,block,main_send_loop=*/ - while(1) - /* =semlit,endblock,main_send_loop=*/ - { - /* Initialize the source if we're not initialized */ - /* =semlit,block,start_init=*/ - if (app_src.state == NOT_INIT) - init_src(&app_src); - /* =semlit,endblock,start_init=*/ - - /* =semlit,block,src_send=*/ - if (app_src.state == READY) - /* =semlit,endblock,src_send=*/ - { - if (lbm_src_send(app_src.src, "test", 4, LBM_SRC_NONBLOCK) == LBM_FAILURE) - { - /* Assume EWOULDBLOCK and wait */ - SLEEP_SEC(1); - } - } - else - { - /* Print a warning that the source is not ready and sleep */ - printf("Source cannot send: %d. Source State: %s\n", lbm_errnum(), source_state(&app_src)); - /* =semlit,block,primary_unresp=*/ - if (app_src.state == UNRESP && app_src.mode == PRIMARY) - { - printf("Primary store unresponsive, failing over to backup\n"); - failover_app_src(&app_src); - } - /* =semlit,endblock,primary_unresp=*/ - /* =semlit,block,backup_unresp=*/ - else if (app_src.state == UNRESP && app_src.mode == BACKUP) - { - printf("Backup store unresponsive. Exiting\n"); - exit(1); - } - /* =semlit,endblock,backup_unresp=*/ - SLEEP_SEC(1); - } - } - return 0; -} + /* =semlit,block,init_create_context=*/ + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); + /* =semlit,endblock,init_create_context=*/ + + /* =semlit,block,init_app_src=*/ + app_src.state = NOT_INIT; + app_src.mode = PRIMARY; + app_src.ctx = ctx; + /* =semlit,endblock,init_app_src=*/ + + /* =semlit,block,main_send_loop=*/ + while(1) + /* =semlit,endblock,main_send_loop=*/ + { + /* Initialize the source if we're not initialized */ + /* =semlit,block,start_init=*/ + if (app_src.state == NOT_INIT) + init_src(&app_src); + /* =semlit,endblock,start_init=*/ + + /* =semlit,block,src_send=*/ + if (app_src.state == READY) + /* =semlit,endblock,src_send=*/ + { + if (lbm_src_send(app_src.src, "test", 4, LBM_SRC_NONBLOCK) == LBM_FAILURE) + { + /* Assume EWOULDBLOCK and wait */ + SLEEP_SEC(1); + } + } + else + { + /* Print a warning that the source is not ready and sleep */ + printf("Source cannot send: %d. Source State: %s\n", lbm_errnum(), source_state(&app_src)); + /* =semlit,block,primary_unresp=*/ + if (app_src.state == UNRESP && app_src.mode == PRIMARY) + { + printf("Primary store unresponsive, failing over to backup\n"); + failover_app_src(&app_src); + } + /* =semlit,endblock,primary_unresp=*/ + /* =semlit,block,backup_unresp=*/ + else if (app_src.state == UNRESP && app_src.mode == BACKUP) + { + printf("Backup store unresponsive. Exiting\n"); + exit(1); + } + /* =semlit,endblock,backup_unresp=*/ + SLEEP_SEC(1); + } + } + return 0; +} /* main */ diff --git a/ump_src_failover/c/ump_src_failover_c.slsrc.html b/ump_src_failover/c/ump_src_failover_c.slsrc.html index 10aab5f..082a0d8 100644 --- a/ump_src_failover/c/ump_src_failover_c.slsrc.html +++ b/ump_src_failover/c/ump_src_failover_c.slsrc.html @@ -18,189 +18,189 @@
    00001 00002 -00003 -00004 -00005 -00006 -00007 -00008 -00009 -00010 -00011 -00012 -00013 -00014 -00015 -00016 -00017 +00003 +00004 +00005 +00006 +00007 +00008 +00009 +00010 +00011 +00012 +00013 +00014 +00015 +00016 +00017 00018 -00019 -00020 -00021 -00022 -00023 -00024 -00025 -00026 -00027 -00028 -00029 -00030 -00031 -00032 -00033 -00034 -00035 -00036 -00037 -00038 -00039 -00040 -00041 -00042 -00043 -00044 -00045 -00046 -00047 -00048 -00049 -00050 -00051 +00019 +00020 +00021 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 +00036 +00037 +00038 +00039 +00040 +00041 +00042 +00043 +00044 +00045 +00046 +00047 +00048 +00049 +00050 +00051 00052 00053 -00054 -00055 -00056 -00057 -00058 +00054 +00055 +00056 +00057 +00058 00059 -00060 -00061 -00062 -00063 -00064 -00065 -00066 -00067 -00068 -00069 -00070 -00071 -00072 -00073 -00074 -00075 -00076 -00077 -00078 -00079 +00060 +00061 +00062 +00063 +00064 +00065 +00066 +00067 +00068 +00069 +00070 +00071 +00072 +00073 +00074 +00075 +00076 +00077 +00078 +00079 00080 00081 -00082 -00083 -00084 -00085 -00086 -00087 -00088 -00089 -00090 -00091 -00092 -00093 -00094 -00095 -00096 -00097 -00098 -00099 -00100 -00101 -00102 -00103 -00104 -00105 -00106 -00107 -00108 +00082 +00083 +00084 +00085 +00086 +00087 +00088 +00089 +00090 +00091 +00092 +00093 +00094 +00095 +00096 +00097 +00098 +00099 +00100 +00101 +00102 +00103 +00104 +00105 +00106 +00107 +00108 00109 00110 -00111 -00112 -00113 -00114 -00115 -00116 -00117 -00118 -00119 -00120 -00121 -00122 -00123 -00124 -00125 -00126 -00127 -00128 -00129 -00130 -00131 -00132 -00133 -00134 -00135 +00111 +00112 +00113 +00114 +00115 +00116 +00117 +00118 +00119 +00120 +00121 +00122 +00123 +00124 +00125 +00126 +00127 +00128 +00129 +00130 +00131 +00132 +00133 +00134 +00135 00136 -00137 -00138 -00139 -00140 -00141 -00142 -00143 -00144 -00145 -00146 -00147 +00137 +00138 +00139 +00140 +00141 +00142 +00143 +00144 +00145 +00146 +00147 00148 00149 -00150 -00151 -00152 -00153 +00150 +00151 +00152 +00153 00154 00155 00156 00157 -00158 -00159 +00158 +00159 00160 -00161 -00162 -00163 +00161 +00162 +00163 00164 00165 -00166 -00167 -00168 -00169 -00170 -00171 -00172 -00173 -00174 -00175 -00176 -00177 -00178 -00179 -00180 +00166 +00167 +00168 +00169 +00170 +00171 +00172 +00173 +00174 +00175 +00176 +00177 +00178 +00179 +00180 00181 -00182 -00183 -00184 -00185 +00182 +00183 +00184 +00185 00186 00187 00188 @@ -209,22 +209,70 @@ 00191 00192 00193 -00194 -00195 -00196 -00197 -00198 -00199 -00200 -00201 -00202 -00203 +00194 +00195 +00196 +00197 +00198 +00199 +00200 +00201 +00202 +00203 00204 -00205 +00205 00206 00207 -00208 - /* ump_src_failover.c */ +00208 +00209 +00210 +00211 +00212 +00213 +00214 +00215 +00216 +00217 +00218 +00219 +00220 +00221 +00222 +00223 +00224 +00225 +00226 +00227 +00228 +00229 +00230 +00231 +00232 +00233 +00234 +00235 +00236 +00237 + /* ump_src_failover.c - see http://ultramessaging.github.io/UMExamples/ump_src_failover/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ #include <stdio.h> #include <string.h> @@ -250,11 +298,11 @@ /* Example error checking macro. Include after each UM call. */ #define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ } while (0) /* Store configurations */ @@ -267,171 +315,181 @@ typedef enum {NOT_INIT, INIT, READY, UNRESP} state_type_e; typedef enum {PRIMARY, BACKUP} mode_type_e; typedef struct app_src_s { - lbm_context_t *ctx; - lbm_src_t *src; - state_type_e state; - mode_type_e mode; + lbm_context_t *ctx; + lbm_src_t *src; + state_type_e state; + mode_type_e mode; } app_src_s; + /* Source event handler callback (passed into lbm_src_create()) */ int handle_src_event(lbm_src_t *src, int event, void *ed, void *cd) { - struct app_src_s *app_src = (struct app_src_s *)cd; - switch (event) { - /* Success event provided only for printing purposes */ - case LBM_SRC_EVENT_UME_REGISTRATION_SUCCESS_EX: - { - lbm_src_event_ume_registration_ex_t *reg = (lbm_src_event_ume_registration_ex_t *)ed; - printf("UME store %u: %s registration success.\n", reg->store_index, reg->store); - break; - } - case LBM_SRC_EVENT_UME_REGISTRATION_COMPLETE_EX: - { - lbm_src_event_ume_registration_complete_ex_t *reg = (lbm_src_event_ume_registration_complete_ex_t *)ed; + struct app_src_s *app_src = (struct app_src_s *)cd; + switch (event) { + /* Success event provided only for printing purposes */ + case LBM_SRC_EVENT_UME_REGISTRATION_SUCCESS_EX: + { + lbm_src_event_ume_registration_ex_t *reg = (lbm_src_event_ume_registration_ex_t *)ed; + printf("UME store %u: %s registration success.\n", reg->store_index, reg->store); + break; + } + case LBM_SRC_EVENT_UME_REGISTRATION_COMPLETE_EX: + { + lbm_src_event_ume_registration_complete_ex_t *reg = (lbm_src_event_ume_registration_complete_ex_t *)ed; - printf("UME registration complete. SQN %x.\n", reg->sequence_number); + printf("UME registration complete. SQN %x.\n", reg->sequence_number); - app_src->state = READY; - break; - } - case LBM_SRC_EVENT_UME_STORE_UNRESPONSIVE: - { - const char *infostr = (const char *)ed; - - printf("UME store: %s\n", infostr); - if (strstr(infostr, "quorum lost") != NULL) - app_src->state = UNRESP; - break; - } - } + app_src->state = READY; + break; + } + case LBM_SRC_EVENT_UME_STORE_UNRESPONSIVE: + { + const char *infostr = (const char *)ed; + + printf("UME store: %s\n", infostr); + if (strstr(infostr, "quorum lost") != NULL) + app_src->state = UNRESP; + break; + } + } + + return 0; + } /* handle_src_event */ - return 0; - } int init_src(app_src_s *app_src) { - lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ - lbm_topic_t *topic; /* Topic object */ - int err; /* Used for checking API return codes */ + lbm_src_topic_attr_t * tattr; /* Source topic attribute object */ + lbm_topic_t *topic; /* Topic object */ + int err; - err = lbm_src_topic_attr_create(&tattr); - EX_LBM_CHK(err); + err = lbm_src_topic_attr_create(&tattr); + EX_LBM_CHK(err); - err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_CLEAR_STORE_CONFIG); - EX_LBM_CHK(err); + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_CLEAR_STORE_CONFIG); + EX_LBM_CHK(err); - /* Assuming there are stores running on the localhost */ - if (app_src->mode == PRIMARY) - err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_PRIMARY_STORE); - else - err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_SECONDARY_STORE); + /* Assuming there are stores running on the localhost */ + if (app_src->mode == PRIMARY) { + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_PRIMARY_STORE); EX_LBM_CHK(err); - - if (app_src->mode == PRIMARY) - err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_PRIMARY_SESSION_ID); - else - err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_SECONDARY_SESSION_ID); + } + else { + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store", UMP_SECONDARY_STORE); EX_LBM_CHK(err); + } - /* Need to set store behavior to Quorum-Consensus */ - err = lbm_src_topic_attr_str_setopt(tattr, "ume_store_behavior", "qc"); + if (app_src->mode == PRIMARY) { + err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_PRIMARY_SESSION_ID); EX_LBM_CHK(err); - - err = lbm_src_topic_alloc(&topic, app_src->ctx, "test.topic", tattr); + } + else { + err = lbm_src_topic_attr_str_setopt(tattr, "ume_session_id", UMP_SECONDARY_SESSION_ID); EX_LBM_CHK(err); + } - err = lbm_src_create(&(app_src->src), app_src->ctx, topic, handle_src_event, app_src, NULL); - EX_LBM_CHK(err); + /* Need to set store behavior to Quorum-Consensus */ + err = lbm_src_topic_attr_str_setopt(tattr, "ume_store_behavior", "qc"); + EX_LBM_CHK(err); + + err = lbm_src_topic_alloc(&topic, app_src->ctx, "test.topic", tattr); + EX_LBM_CHK(err); + + err = lbm_src_create(&(app_src->src), app_src->ctx, topic, handle_src_event, app_src, NULL); + EX_LBM_CHK(err); + + app_src->state = INIT; + + return 0; + } /* init_src */ - app_src->state = INIT; - } void failover_app_src(app_src_s *app_src) { - int err; /* Used for checking API return codes */ - - /* Delete the source */ - err = lbm_src_delete(app_src->src); - EX_LBM_CHK(err); + int err; + + /* Delete the source */ + err = lbm_src_delete(app_src->src); + EX_LBM_CHK(err); + + app_src->src = NULL; + app_src->state = NOT_INIT; + app_src->mode = BACKUP; + } /* failover_app_src */ - app_src->src = NULL; - app_src->state = NOT_INIT; - app_src->mode = BACKUP; - } /* Provided simply for printing the state name */ const char* source_state(app_src_s *app_src) { - switch (app_src->state) - { - case NOT_INIT: return "NOT_INIT"; - case INIT: return "INIT"; - case READY: return "READY"; - case UNRESP: return "UNRESP"; - } - } + switch (app_src->state) + { + case NOT_INIT: return "NOT_INIT"; + case INIT: return "INIT"; + case READY: return "READY"; + case UNRESP: return "UNRESP"; + } + return NULL; + } /* source_state */ + int main(int argc, char **argv) { - app_src_s app_src; /* App structure to track source */ - lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - int err; /* Used for checking API return codes */ + app_src_s app_src; /* App structure to track source */ + lbm_context_t *ctx; /* Context object */ + int err; #if defined(_WIN32) - /* windows-specific code */ - WSADATA wsadata; - int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); - if (wsStat != 0) - { - printf("line %d: wsStat=%d\n",__LINE__,wsStat); - exit(1); - } + /* windows-specific code */ + WSADATA wsadata; + int wsStat = WSAStartup(MAKEWORD(2,2), &wsadata); + if (wsStat != 0) + { + printf("line %d: wsStat=%d\n",__LINE__,wsStat); + exit(1); + } #endif - err = lbm_context_attr_create(&cattr); - EX_LBM_CHK(err); + err = lbm_context_create(&ctx, NULL, NULL, NULL); + EX_LBM_CHK(err); - err = lbm_context_create(&ctx, cattr, NULL, NULL); - EX_LBM_CHK(err); + app_src.state = NOT_INIT; + app_src.mode = PRIMARY; + app_src.ctx = ctx; - app_src.state = NOT_INIT; - app_src.mode = PRIMARY; - app_src.ctx = ctx; + while(1) + { + /* Initialize the source if we're not initialized */ + if (app_src.state == NOT_INIT) + init_src(&app_src); - while(1) + if (app_src.state == READY) { - /* Initialize the source if we're not initialized */ - if (app_src.state == NOT_INIT) - init_src(&app_src); - - if (app_src.state == READY) - { - if (lbm_src_send(app_src.src, "test", 4, LBM_SRC_NONBLOCK) == LBM_FAILURE) - { - /* Assume EWOULDBLOCK and wait */ - SLEEP_SEC(1); - } - } - else - { - /* Print a warning that the source is not ready and sleep */ - printf("Source cannot send: %d. Source State: %s\n", lbm_errnum(), source_state(&app_src)); - if (app_src.state == UNRESP && app_src.mode == PRIMARY) - { - printf("Primary store unresponsive, failing over to backup\n"); - failover_app_src(&app_src); - } - else if (app_src.state == UNRESP && app_src.mode == BACKUP) - { - printf("Backup store unresponsive. Exiting\n"); - exit(1); - } - SLEEP_SEC(1); - } + if (lbm_src_send(app_src.src, "test", 4, LBM_SRC_NONBLOCK) == LBM_FAILURE) + { + /* Assume EWOULDBLOCK and wait */ + SLEEP_SEC(1); + } + } + else + { + /* Print a warning that the source is not ready and sleep */ + printf("Source cannot send: %d. Source State: %s\n", lbm_errnum(), source_state(&app_src)); + if (app_src.state == UNRESP && app_src.mode == PRIMARY) + { + printf("Primary store unresponsive, failing over to backup\n"); + failover_app_src(&app_src); + } + else if (app_src.state == UNRESP && app_src.mode == BACKUP) + { + printf("Backup store unresponsive. Exiting\n"); + exit(1); + } + SLEEP_SEC(1); } - return 0; - } + } + return 0; + } /* main */
    diff --git a/x b/x new file mode 100644 index 0000000..b0d5322 --- /dev/null +++ b/x @@ -0,0 +1,23 @@ +cancelling_timers/c/*_c.slsrc +check_flight_size_ewouldblock/c/*_c.slsrc +clean_shutdown/c/*_c.slsrc +dump_attributes/c/*_c.slsrc +event_q_rcv/c/*_c.slsrc +event_q_src/c/*_c.slsrc +handle_burst/c/*_c.slsrc +late_join/c/*_c.slsrc +load_config/c/*_c.slsrc +logging_callback/c/*_c.slsrc +minsrc/c/*_c.slsrc +multi_context/c/*_c.slsrc +no_source_notify/c/*_c.slsrc +quorum_state/c/*_c.slsrc +request_response/c/*_c.slsrc +schedule_timers/c/*_c.slsrc +seq_number_callback/c/*_c.slsrc +sequential_mode/c/*_c.slsrc +setting_attributes/c/*_c.slsrc +source_notify_callbacks/c/*_c.slsrc +src_rsp/c/*_c.slsrc +ump_receiver_callbacks/c/*_c.slsrc +ump_src_failover/c/*_c.slsrc diff --git a/x.c b/x.c new file mode 100644 index 0000000..98bfb2f --- /dev/null +++ b/x.c @@ -0,0 +1,145 @@ +/* cancelling_timers.c - see http://ultramessaging.github.io/UMExamples/cancelling_timers/c/index.html + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ + +/* =semlit,block,includes=*/ +#include + +#if defined(_MSC_VER) +/* Windows-only includes */ +#include +#define SLEEP(s) Sleep((s)*1000) +#else +/* Unix-only includes */ +#include +#include +#define SLEEP(s) sleep(s) +#endif + +#include +/* =semlit,endblock,includes=*/ + +/* =semlit,block,error_check=*/ +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ +} while (0) +/* =semlit,endblock,error_check=*/ + +/* =semlit,block,struct_app_timer=*/ +typedef enum {PENDING, FIRED, CANCELED} state_type_e; +typedef struct app_timer_s { + int id; + state_type_e state; + int sync; +} app_timer_s; +/* =semlit,endblock,struct_app_timer=*/ + +/* =semlit,block,int_wait=*/ +int wait = 1; +/* =semlit,endblock,int_wait=*/ + +/* Timer callback function */ +/* =semlit,block,timer_cb=*/ +int sample_timer_handler(lbm_context_t *ctx, const void *clientd) +{ + struct app_timer_s *my_timer = (struct app_timer_s *)clientd; + if (my_timer->state != PENDING) { + fprintf(stderr, "ERROR: Timer executed and should have been cancelled\n"); + exit(1); + } + + fprintf(stderr, "ERROR: This timer should have been cancelled by now\n"); + + return 0; +} +/* =semlit,endblock,timer_cb=*/ + +/* =semlit,block,cancel_cb=*/ +int cancel_timer_cb(lbm_context_t *ctx, const void *clientd) +{ + struct app_timer_s *my_timer = (struct app_timer_s *)clientd; + if (my_timer->state == PENDING) { + lbm_cancel_timer(ctx, my_timer->id, NULL); + my_timer->state = CANCELED; + } + my_timer->sync = 0; + + return 0; +} +/* =semlit,endblock,cancel_cb=*/ + +int main(int argc, char **argv) +{ + lbm_context_t *ctx; /* Context object */ + lbm_context_attr_t * cattr; /* Context attribute object */ + int err; /* Used for checking API return codes */ + app_timer_s my_timer; + + my_timer.sync = 0; + + /* Initialize context atrributes and create context */ + /* =semlit,block,ctx_create=*/ + err = lbm_context_attr_create(&cattr); + EX_LBM_CHK(err); + + err = lbm_context_create(&ctx, cattr, NULL, NULL); + EX_LBM_CHK(err); + /* =semlit,endblock,ctx_create=*/ + + /* =semlit,block,schedule=*/ + my_timer.state = PENDING; + if ((my_timer.id = lbm_schedule_timer(ctx, sample_timer_handler, &my_timer, NULL, 10000)) == -1) { + fprintf(stderr, "%s:%d, lbm error: '%s'\n", __FILE__, __LINE__, lbm_errmsg()); + exit(1); + } + /* =semlit,endblock,schedule=*/ + + /* Now wait for callback to end the wait and close the application */ + SLEEP(1); + + /* =semlit,block,cancel= */ + if (my_timer.state == PENDING) { + lbm_schedule_timer(ctx, cancel_timer_cb, &my_timer, NULL, 0); + /* timer might still fire at this point. */ + my_timer.sync = 1; + } + /* =semlit,endblock,cancel= */ + + /* =semlit,block,wait=*/ + while (my_timer.sync) + SLEEP(1); + /* =semlit,endblock,wait=*/ + + /* Clean up */ + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); + +#if defined(_MSC_VER) + /* Windows-specific cleanup overhead */ + WSACleanup(); +#endif + return 0; +} + diff --git a/x.sed b/x.sed new file mode 100644 index 0000000..3eaf361 --- /dev/null +++ b/x.sed @@ -0,0 +1 @@ +1,1s|^/\* \([^.]*\).c *$|/\* \1.c - see http://ultramessaging.github.io/UMExamples/\1/c/index.html| diff --git a/x.x b/x.x new file mode 100644 index 0000000..70c01e0 --- /dev/null +++ b/x.x @@ -0,0 +1,145 @@ +/* cancelling_timers.c + * + * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ + +/* =semlit,block,includes=*/ +#include + +#if defined(_MSC_VER) +/* Windows-only includes */ +#include +#define SLEEP(s) Sleep((s)*1000) +#else +/* Unix-only includes */ +#include +#include +#define SLEEP(s) sleep(s) +#endif + +#include +/* =semlit,endblock,includes=*/ + +/* =semlit,block,error_check=*/ +/* Example error checking macro. Include after each UM call. */ +#define EX_LBM_CHK(err) do { \ + if ((err) < 0) { \ + fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ + __FILE__, __LINE__, lbm_errmsg()); \ + exit(1); \ + } \ +} while (0) +/* =semlit,endblock,error_check=*/ + +/* =semlit,block,struct_app_timer=*/ +typedef enum {PENDING, FIRED, CANCELED} state_type_e; +typedef struct app_timer_s { + int id; + state_type_e state; + int sync; +} app_timer_s; +/* =semlit,endblock,struct_app_timer=*/ + +/* =semlit,block,int_wait=*/ +int wait = 1; +/* =semlit,endblock,int_wait=*/ + +/* Timer callback function */ +/* =semlit,block,timer_cb=*/ +int sample_timer_handler(lbm_context_t *ctx, const void *clientd) +{ + struct app_timer_s *my_timer = (struct app_timer_s *)clientd; + if (my_timer->state != PENDING) { + fprintf(stderr, "ERROR: Timer executed and should have been cancelled\n"); + exit(1); + } + + fprintf(stderr, "ERROR: This timer should have been cancelled by now\n"); + + return 0; +} +/* =semlit,endblock,timer_cb=*/ + +/* =semlit,block,cancel_cb=*/ +int cancel_timer_cb(lbm_context_t *ctx, const void *clientd) +{ + struct app_timer_s *my_timer = (struct app_timer_s *)clientd; + if (my_timer->state == PENDING) { + lbm_cancel_timer(ctx, my_timer->id, NULL); + my_timer->state = CANCELED; + } + my_timer->sync = 0; + + return 0; +} +/* =semlit,endblock,cancel_cb=*/ + +int main(int argc, char **argv) +{ + lbm_context_t *ctx; /* Context object */ + lbm_context_attr_t * cattr; /* Context attribute object */ + int err; /* Used for checking API return codes */ + app_timer_s my_timer; + + my_timer.sync = 0; + + /* Initialize context atrributes and create context */ + /* =semlit,block,ctx_create=*/ + err = lbm_context_attr_create(&cattr); + EX_LBM_CHK(err); + + err = lbm_context_create(&ctx, cattr, NULL, NULL); + EX_LBM_CHK(err); + /* =semlit,endblock,ctx_create=*/ + + /* =semlit,block,schedule=*/ + my_timer.state = PENDING; + if ((my_timer.id = lbm_schedule_timer(ctx, sample_timer_handler, &my_timer, NULL, 10000)) == -1) { + fprintf(stderr, "%s:%d, lbm error: '%s'\n", __FILE__, __LINE__, lbm_errmsg()); + exit(1); + } + /* =semlit,endblock,schedule=*/ + + /* Now wait for callback to end the wait and close the application */ + SLEEP(1); + + /* =semlit,block,cancel= */ + if (my_timer.state == PENDING) { + lbm_schedule_timer(ctx, cancel_timer_cb, &my_timer, NULL, 0); + /* timer might still fire at this point. */ + my_timer.sync = 1; + } + /* =semlit,endblock,cancel= */ + + /* =semlit,block,wait=*/ + while (my_timer.sync) + SLEEP(1); + /* =semlit,endblock,wait=*/ + + /* Clean up */ + err = lbm_context_delete(ctx); + EX_LBM_CHK(err); + +#if defined(_MSC_VER) + /* Windows-specific cleanup overhead */ + WSACleanup(); +#endif + return 0; +} + From e38cfb1a68ff0b60d8e9d078814c7050a7f86fc0 Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Mon, 27 Nov 2017 12:12:08 -0600 Subject: [PATCH 07/26] Cosmetic improvement Minor changes to improve readability. --- src_rsp/c/server.c | 9 +- src_rsp/c/server_c.slsrc | 9 +- src_rsp/c/server_c.slsrc.html | 32 ++++--- src_rsp/c/src_rsp.sldoc | 1 - src_rsp/c/src_rsp.sldoc.html | 154 +++++++++++++++++----------------- 5 files changed, 99 insertions(+), 106 deletions(-) diff --git a/src_rsp/c/server.c b/src_rsp/c/server.c index 031f10b..76b729c 100644 --- a/src_rsp/c/server.c +++ b/src_rsp/c/server.c @@ -120,22 +120,21 @@ void handle_register(client_t *client, const char *client_resp_name) } /* handle_register */ -void handle_req(client_t *client, req_hdr_t *req_hdr, const char *data, size_t len) +void handle_req(client_t *client, req_hdr_t *req_hdr, const char *req_msg, size_t len) { int err; - /* Response message is put after the header. */ - char *response_msg = &client->send_buf[sizeof(req_hdr_t)]; - /* This work should probably be passed to a separate worker thread, but * I'll do it here to simplify the code. */ /* Responses copy the header from the request. */ memcpy(&client->send_buf[0], (char *)req_hdr, sizeof(req_hdr_t)); + /* Response message is put after the header. */ + char *response_msg = &client->send_buf[sizeof(req_hdr_t)]; /* Do the work of the request and put the response in response_msg. * (For this sample, just echo back the request.) */ - strcpy(response_msg, data); + strcpy(response_msg, req_msg); /* Reply to client. */ err = lbm_src_send(client->resp_src, client->send_buf, diff --git a/src_rsp/c/server_c.slsrc b/src_rsp/c/server_c.slsrc index ef33652..a92079b 100644 --- a/src_rsp/c/server_c.slsrc +++ b/src_rsp/c/server_c.slsrc @@ -131,22 +131,21 @@ void handle_register(client_t *client, const char *client_resp_name) /* =semlit,block,do_req2= */ -void handle_req(client_t *client, req_hdr_t *req_hdr, const char *data, size_t len) +void handle_req(client_t *client, req_hdr_t *req_hdr, const char *req_msg, size_t len) { int err; - /* Response message is put after the header. */ - char *response_msg = &client->send_buf[sizeof(req_hdr_t)]; - /* This work should probably be passed to a separate worker thread, but * I'll do it here to simplify the code. */ /* Responses copy the header from the request. */ memcpy(&client->send_buf[0], (char *)req_hdr, sizeof(req_hdr_t)); + /* Response message is put after the header. */ + char *response_msg = &client->send_buf[sizeof(req_hdr_t)]; /* Do the work of the request and put the response in response_msg. * (For this sample, just echo back the request.) */ - strcpy(response_msg, data); + strcpy(response_msg, req_msg); /* Reply to client. */ err = lbm_src_send(client->resp_src, client->send_buf, diff --git a/src_rsp/c/server_c.slsrc.html b/src_rsp/c/server_c.slsrc.html index 6637d6c..afcc945 100644 --- a/src_rsp/c/server_c.slsrc.html +++ b/src_rsp/c/server_c.slsrc.html @@ -160,15 +160,15 @@ 00142 00143 00144 -00145 +00145 00146 -00147 +00147 00148 00149 -00150 +00150 00151 00152 -00153 +00153 00154 00155 00156 @@ -176,8 +176,8 @@ 00158 00159 00160 -00161 -00162 +00161 +00162 00163 00164 00165 @@ -185,7 +185,7 @@ 00167 00168 00169 -00170 +00170 00171 00172 00173 @@ -208,7 +208,7 @@ 00190 00191 00192 -00193 +00193 00194 00195 00196 @@ -223,7 +223,7 @@ 00205 00206 00207 -00208 +00208 00209 00210 00211 @@ -272,7 +272,7 @@ 00254 00255 00256 -00257 +00257 00258 00259 00260 @@ -296,7 +296,7 @@ 00278 00279 00280 -00281 +00281 00282 00283 00284 @@ -318,7 +318,6 @@ 00300 00301 00302 -00303 /* server.c - see http://ultramessaging.github.io/UMExamples/server/c/index.html * * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. @@ -441,22 +440,21 @@ } /* handle_register */ - void handle_req(client_t *client, req_hdr_t *req_hdr, const char *data, size_t len) + void handle_req(client_t *client, req_hdr_t *req_hdr, const char *req_msg, size_t len) { int err; - /* Response message is put after the header. */ - char *response_msg = &client->send_buf[sizeof(req_hdr_t)]; - /* This work should probably be passed to a separate worker thread, but * I'll do it here to simplify the code. */ /* Responses copy the header from the request. */ memcpy(&client->send_buf[0], (char *)req_hdr, sizeof(req_hdr_t)); + /* Response message is put after the header. */ + char *response_msg = &client->send_buf[sizeof(req_hdr_t)]; /* Do the work of the request and put the response in response_msg. * (For this sample, just echo back the request.) */ - strcpy(response_msg, data); + strcpy(response_msg, req_msg); /* Reply to client. */ err = lbm_src_send(client->resp_src, client->send_buf, diff --git a/src_rsp/c/src_rsp.sldoc b/src_rsp/c/src_rsp.sldoc index b0106a7..a98ef37 100644 --- a/src_rsp/c/src_rsp.sldoc +++ b/src_rsp/c/src_rsp.sldoc @@ -166,7 +166,6 @@ However, the simple protocol was designed to allow this to be added. A request message consists of an 8-ascii-byte header followed by the application message content. -./run.sh client The first byte of the header is the character 'R' to indicate a request message. The other 7 bytes are currently just set to ascii '0' characters, but diff --git a/src_rsp/c/src_rsp.sldoc.html b/src_rsp/c/src_rsp.sldoc.html index e74211c..5f2de63 100644 --- a/src_rsp/c/src_rsp.sldoc.html +++ b/src_rsp/c/src_rsp.sldoc.html @@ -183,30 +183,30 @@

    Registration: Server Side

    -00258          lbm_rcv_src_notification_func_t source_notification_function;
    -00259          lbm_rcv_topic_attr_t *rcv_attr;
    -00260          lbm_topic_t *topic;
    -00261  
    -00262          err = lbm_rcv_topic_attr_create(&rcv_attr);
    -00263          EX_LBM_CHK(err);
    -00264  
    -00265          /* Set up per-source state management. */
    -00266          source_notification_function.create_func = start_client_source;
    -00267          source_notification_function.delete_func = end_client_source;
    -00268          source_notification_function.clientd = ctx;  /* Pass this to start_client_source(). */
    -00269          err = lbm_rcv_topic_attr_setopt(rcv_attr, "source_notification_function",
    -00270              &source_notification_function, sizeof(source_notification_function));
    -00271          EX_LBM_CHK(err);
    -00272  
    -00273          err = lbm_rcv_topic_lookup(&topic, ctx, "Server1.Request", rcv_attr);
    -00274          EX_LBM_CHK(err);
    -00275          /* Pass context object as clientd. */
    -00276          err = lbm_rcv_create(&rcv, ctx, topic, request_rcv_cb, ctx, NULL);
    -00277          EX_LBM_CHK(err);
    -00278  
    -00279          err = lbm_rcv_topic_attr_delete(rcv_attr);
    -00280          EX_LBM_CHK(err);
    -00281      }
    +00257          lbm_rcv_src_notification_func_t source_notification_function;
    +00258          lbm_rcv_topic_attr_t *rcv_attr;
    +00259          lbm_topic_t *topic;
    +00260  
    +00261          err = lbm_rcv_topic_attr_create(&rcv_attr);
    +00262          EX_LBM_CHK(err);
    +00263  
    +00264          /* Set up per-source state management. */
    +00265          source_notification_function.create_func = start_client_source;
    +00266          source_notification_function.delete_func = end_client_source;
    +00267          source_notification_function.clientd = ctx;  /* Pass this to start_client_source(). */
    +00268          err = lbm_rcv_topic_attr_setopt(rcv_attr, "source_notification_function",
    +00269              &source_notification_function, sizeof(source_notification_function));
    +00270          EX_LBM_CHK(err);
    +00271  
    +00272          err = lbm_rcv_topic_lookup(&topic, ctx, "Server1.Request", rcv_attr);
    +00273          EX_LBM_CHK(err);
    +00274          /* Pass context object as clientd. */
    +00275          err = lbm_rcv_create(&rcv, ctx, topic, request_rcv_cb, ctx, NULL);
    +00276          EX_LBM_CHK(err);
    +00277  
    +00278          err = lbm_rcv_topic_attr_delete(rcv_attr);
    +00279          EX_LBM_CHK(err);
    +00280      }
     
    @@ -218,21 +218,21 @@

    Registration: Server Side

    -00194  void *start_client_source(const char *source_name, void *clientd)
    -00195  {
    -00196      lbm_context_t *ctx = (lbm_context_t *)clientd;;
    -00197      client_t *new_client = (client_t *)malloc(sizeof(client_t));
    -00198      NULL_CHK(new_client);
    -00199  
    -00200      new_client->state = 0;  /* Waiting for register. */
    -00201      new_client->topic_name = NULL;
    -00202      new_client->source_name = strdup(source_name);
    -00203      NULL_CHK(new_client->source_name);
    -00204      new_client->ctx = ctx;
    -00205      new_client->resp_src = NULL;
    -00206  
    -00207      return new_client;
    -00208  }  /* start_client_source */
    +00193  void *start_client_source(const char *source_name, void *clientd)
    +00194  {
    +00195      lbm_context_t *ctx = (lbm_context_t *)clientd;;
    +00196      client_t *new_client = (client_t *)malloc(sizeof(client_t));
    +00197      NULL_CHK(new_client);
    +00198  
    +00199      new_client->state = 0;  /* Waiting for register. */
    +00200      new_client->topic_name = NULL;
    +00201      new_client->source_name = strdup(source_name);
    +00202      NULL_CHK(new_client->source_name);
    +00203      new_client->ctx = ctx;
    +00204      new_client->resp_src = NULL;
    +00205  
    +00206      return new_client;
    +00207  }  /* start_client_source */
     
    @@ -245,9 +245,9 @@

    Registration: Server Side

    -00148  int request_rcv_cb(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) 
    -00149  {
    -00150      client_t *client = (client_t *)msg->source_clientd;
    +00147  int request_rcv_cb(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) 
    +00148  {
    +00149      client_t *client = (client_t *)msg->source_clientd;
     
    @@ -256,14 +256,14 @@

    Registration: Server Side

    -00154      case LBM_MSG_DATA:  /* Received a message from the client. */
    -00155          printf("Received %ld bytes on topic %s: '%.*s'\n",
    -00156               (long)msg->len, msg->topic_name, (int)msg->len, msg->data);
    -00157  
    -00158          /* Register message. */
    -00159          if (msg->len > 1 && msg->data[0] == 'r') {
    -00160              handle_register(client, &msg->data[1]);
    -00161          }
    +00153      case LBM_MSG_DATA:  /* Received a message from the client. */
    +00154          printf("Received %ld bytes on topic %s: '%.*s'\n",
    +00155               (long)msg->len, msg->topic_name, (int)msg->len, msg->data);
    +00156  
    +00157          /* Register message. */
    +00158          if (msg->len > 1 && msg->data[0] == 'r') {
    +00159              handle_register(client, &msg->data[1]);
    +00160          }
     
    @@ -389,7 +389,6 @@

    Request/Response

    However, the simple protocol was designed to allow this to be added. A request message consists of an 8-ascii-byte header followed by the application message content. -./run.sh client The first byte of the header is the character 'R' to indicate a request message. The other 7 bytes are currently just set to ascii '0' characters, but @@ -441,43 +440,42 @@

    Response: Server Side

    -00163          /* Request message. */
    -00164          else if (msg->len >= sizeof(req_hdr_t) && msg->data[0] == 'R') {
    -00165              req_hdr_t req_hdr;
    -00166              memcpy((char *)&req_hdr, msg->data, sizeof(req_hdr_t));
    -00167  
    -00168              handle_req(client, &req_hdr, &msg->data[sizeof(req_hdr_t)],
    -00169                  msg->len - sizeof(req_hdr_t));
    -00170          }
    +00162          /* Request message. */
    +00163          else if (msg->len >= sizeof(req_hdr_t) && msg->data[0] == 'R') {
    +00164              req_hdr_t req_hdr;
    +00165              memcpy((char *)&req_hdr, msg->data, sizeof(req_hdr_t));
    +00166  
    +00167              handle_req(client, &req_hdr, &msg->data[sizeof(req_hdr_t)],
    +00168                  msg->len - sizeof(req_hdr_t));
    +00169          }
     

    . . .

    -00123  void handle_req(client_t *client, req_hdr_t *req_hdr, const char *data, size_t len)
    +00123  void handle_req(client_t *client, req_hdr_t *req_hdr, const char *req_msg, size_t len)
     00124  {
     00125      int err;
     00126  
    -00127      /* Response message is put after the header. */
    -00128      char *response_msg = &client->send_buf[sizeof(req_hdr_t)];
    +00127      /* This work should probably be passed to a separate worker thread, but
    +00128       * I'll do it here to simplify the code. */
     00129  
    -00130      /* This work should probably be passed to a separate worker thread, but
    -00131       * I'll do it here to simplify the code. */
    -00132  
    -00133      /* Responses copy the header from the request. */
    -00134      memcpy(&client->send_buf[0], (char *)req_hdr, sizeof(req_hdr_t));
    -00135  
    -00136      /* Do the work of the request and put the response in response_msg.
    -00137       * (For this sample, just echo back the request.) */
    -00138      strcpy(response_msg, data);
    -00139      
    -00140      /* Reply to client. */
    -00141      err = lbm_src_send(client->resp_src, client->send_buf,
    -00142          strlen(client->send_buf) + 1, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK);
    -00143      EX_LBM_CHK(err);
    -00144      printf("sent response to '%s'.\n", client->topic_name);
    -00145  }  /* handle_req */
    +00130      /* Responses copy the header from the request. */
    +00131      memcpy(&client->send_buf[0], (char *)req_hdr, sizeof(req_hdr_t));
    +00132      /* Response message is put after the header. */
    +00133      char *response_msg = &client->send_buf[sizeof(req_hdr_t)];
    +00134  
    +00135      /* Do the work of the request and put the response in response_msg.
    +00136       * (For this sample, just echo back the request.) */
    +00137      strcpy(response_msg, req_msg);
    +00138      
    +00139      /* Reply to client. */
    +00140      err = lbm_src_send(client->resp_src, client->send_buf,
    +00141          strlen(client->send_buf) + 1, LBM_MSG_FLUSH | LBM_SRC_NONBLOCK);
    +00142      EX_LBM_CHK(err);
    +00143      printf("sent response to '%s'.\n", client->topic_name);
    +00144  }  /* handle_req */
     
    From faedb3edda8e47be311a96438e2fc00444611239 Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Fri, 2 Nov 2018 14:53:10 -0400 Subject: [PATCH 08/26] Added ss_frag --- .gitignore | 2 + README.md | 35 +- c_index.html | 1 + index.html | 1 + ss_frag/README.txt | 3 + ss_frag/c/blank.html | 1 + ss_frag/c/index.html | 6 + ss_frag/c/ss_frag.c | 458 ++++++++++++++ ss_frag/c/ss_frag.sldoc | 58 ++ ss_frag/c/ss_frag.sldoc.html | 218 +++++++ ss_frag/c/ss_frag_c.slsrc | 478 +++++++++++++++ ss_frag/c/ss_frag_c.slsrc.html | 1020 ++++++++++++++++++++++++++++++++ ss_frag/intro.sldoc | 56 ++ 13 files changed, 2336 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 ss_frag/README.txt create mode 100644 ss_frag/c/blank.html create mode 100644 ss_frag/c/index.html create mode 100644 ss_frag/c/ss_frag.c create mode 100644 ss_frag/c/ss_frag.sldoc create mode 100644 ss_frag/c/ss_frag.sldoc.html create mode 100644 ss_frag/c/ss_frag_c.slsrc create mode 100644 ss_frag/c/ss_frag_c.slsrc.html create mode 100644 ss_frag/intro.sldoc diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9bea433 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +.DS_Store diff --git a/README.md b/README.md index 9df96bb..27fb602 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,37 @@ # UMExamples UMExamples provides sample applications for users of Ultra Messaging -Head over to http://ultramessaging.github.io/UMExamples/ to view the Examples +Go to https://ultramessaging.github.io/UMExamples/ so see them rendered +and user-friendly. + + +## Creating Examples + +The examples use a documentation toolset called "semlit". +Go to https://github.com/fordsfords/semlit to get it. + +Here is how I created the "ss_frag" example: + +```mkdir ss_frag +cd ss_frag +mkdir c +cp ../cancelling_timers/README.txt . +vi README.txt``` + +Change appropriately. + +```cp ../cancelling_timers/intro.sldoc . +vi intro.sldoc``` + +Change appropriately. + +```cp ../cancelling_timers/c/cancelling_timers.sldoc c/ss_frag.sldoc +cp ../cancelling_timers/c/cancelling_timers_c.slsrc c/ss_frag_c.slsrc +cd c +vi ss_frag.sldoc``` + +In a separate window: + +```cd c +vi ss_frag_c.slsrc``` + diff --git a/c_index.html b/c_index.html index f32a8a4..d4e8698 100644 --- a/c_index.html +++ b/c_index.html @@ -39,6 +39,7 @@

    Examples

    setting_attributesC Java C#/.NETExamples on setting UM attributes via the API source_notify_callbacksC Java C#/.NETA sample application that demonstrates how to configure and code the source_notification_callback feature for receivers src_rspC Java C#/.NETA sample application that demonstrates source-based request responses. +ss_fragC Java C#/.NETA sample application that demonstrates application-level message fragmentation/reassembly for Smart Source. ump_receiver_callbacksC Java C#/.NETA sample application that handles all UMP receiver callbacks and logs important data ump_src_failoverC Java C#/.NETExample UMP source application that demonstrates how a persisted source can failover to a backup store diff --git a/index.html b/index.html index 8c1b447..11eb11e 100644 --- a/index.html +++ b/index.html @@ -49,6 +49,7 @@

    Examples

    setting_attributesC Java C#/.NETExamples on setting UM attributes via the API source_notify_callbacksC Java C#/.NETA sample application that demonstrates how to configure and code the source_notification_callback feature for receivers src_rspC Java C#/.NETA sample application that demonstrates source-based request responses. +ss_fragC Java C#/.NETA sample application that demonstrates application-level message fragmentation/reassembly for Smart Source. ump_receiver_callbacksC Java C#/.NETA sample application that handles all UMP receiver callbacks and logs important data ump_src_failoverC Java C#/.NETExample UMP source application that demonstrates how a persisted source can failover to a backup store diff --git a/ss_frag/README.txt b/ss_frag/README.txt new file mode 100644 index 0000000..edea64d --- /dev/null +++ b/ss_frag/README.txt @@ -0,0 +1,3 @@ +Summary=A sample application that demonstrates application-level message fragmentation/reassembly for Smart Source. + +Description= diff --git a/ss_frag/c/blank.html b/ss_frag/c/blank.html new file mode 100644 index 0000000..0841bfc --- /dev/null +++ b/ss_frag/c/blank.html @@ -0,0 +1 @@ +Click a source line number to see the line in context. diff --git a/ss_frag/c/index.html b/ss_frag/c/index.html new file mode 100644 index 0000000..6b2c6ea --- /dev/null +++ b/ss_frag/c/index.html @@ -0,0 +1,6 @@ + + + + + + diff --git a/ss_frag/c/ss_frag.c b/ss_frag/c/ss_frag.c new file mode 100644 index 0000000..06d88ad --- /dev/null +++ b/ss_frag/c/ss_frag.c @@ -0,0 +1,458 @@ +/* ss_frag.c - see http://ultramessaging.github.io/UMExamples/ss_frag/c/index.html + * + * Copyright (c) 2005-2018 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ + +#include +#include + +#if defined(_MSC_VER) +/* Windows-only includes */ +#include +#define SLEEP(s) Sleep((s)*1000) +#else +/* Unix-only includes */ +#include +#include +#define SLEEP(s) sleep(s) +#endif + +#include + + +/* Application structure associated with a smart source. + */ +typedef struct { + lbm_context_t *ctx; + lbm_ssrc_t *ssrc; + char *msgbuf_plain; + char *msgbuf_props; + int max_msg_len; + lbm_ssrc_send_ex_info_t info_prop; + lbm_uint32_t int_value_array[2]; + char *key_ptr_array[2]; + char remain_key[8]; +} smart_source_t; + + +/* Receiver state used to reassemble fragmented messages. Used as per-source + * clientd. + */ +typedef struct { + int collecting; /* 1=true, 0=false. */ + char *reassem_buf; + size_t reassem_buf_size; + size_t message_len; /* Size of message being reassembled. */ + size_t offset; /* Current offset within reassem_buf[]. */ + long num_bad_frags; /* Statistic: bad fragemnts. */ +} rcv_state_t; + + +/* + * Simple lbm error handling. + */ + +/* Macro to approximate the basename() function. */ +#define BASENAME(_p) ((strrchr(_p, '/') == NULL) ? (_p) : (strrchr(_p, '/')+1)) + +/* Pass in an LBM return status. If not success, print error and abort. */ +#define LBM_ERR(_e) do {\ + if ((_e) != LBM_OK) {\ + printf("LBM_ERR: at %s:%d (%s)\n",\ + BASENAME(__FILE__), __LINE__, lbm_errmsg());\ + fflush(stdout);\ + abort();\ + }\ +} while (0) + +/* Print error and abort. */ +#define ERR(_s) do {\ + printf("ERR: at %s:%d (%s)\n",\ + BASENAME(__FILE__), __LINE__, _s);\ + fflush(stdout);\ + abort();\ +} while (0) + + +/* Called by receiver callback when a received messager has the "Remain" + * message property, indicating a fragmented message. + */ +void handle_msg_frag(lbm_msg_t *msg, rcv_state_t *rcv_state, + lbm_int32_t remaining) +{ + size_t tot_len; + + if (rcv_state->collecting) { + /* Make sure the fragment is OK. */ + if (remaining >= 0 && + (rcv_state->message_len == (rcv_state->offset + msg->len + remaining))) + { + /* Non-NULL reassem buffer, continue collecting. */ + memcpy(&rcv_state->reassem_buf[rcv_state->offset], msg->data, + msg->len); + rcv_state->offset += msg->len; + + if (remaining == 0) { /* No more, deliver the data. */ + printf("PROCESS message, buf[0]=%d, buf[%ld]=%d\n", + rcv_state->reassem_buf[0], + rcv_state->message_len - 1, + rcv_state->reassem_buf[rcv_state->message_len - 1]); + + /* No longer collecting. */ + rcv_state->collecting = 0; + } + } /* if fragment OK */ + else { /* fragment is not ok. */ + /* Bad fragment (should never happen). */ + printf("Collect error: bad fragment, remaining=%d, offset=%ld, len=%lu, message_len=%ld\n", remaining, rcv_state->offset, msg->len, rcv_state->message_len); + rcv_state->num_bad_frags ++; + + /* Error, stop collecting. */ + rcv_state->collecting = 0; + } + } + + else { /* not collecting */ + /* Not collecting a fragmented message, is this message first frag? */ + if (remaining < 0) { + /* First fragment. */ + rcv_state->collecting = 1; + rcv_state->offset = 0; + rcv_state->message_len = msg->len + (- remaining); + /* Expand buffer if necessary. */ + if (rcv_state->message_len > rcv_state->reassem_buf_size) { + rcv_state->reassem_buf_size = rcv_state->message_len; + rcv_state->reassem_buf = (char *)realloc(rcv_state->reassem_buf, + rcv_state->reassem_buf_size); + } + + /* Collect data. */ + memcpy(&rcv_state->reassem_buf[rcv_state->offset], msg->data, msg->len); + rcv_state->offset += msg->len; + } /* remaining < 0 */ + else { /* Found middle frag without a first frag; discard. */ + /* Probably joined stream in middle of message. */ + printf("info: found middle frag but not collecting, remaining=%d, offset=%ld, len=%lu, message_len=%ld\n", remaining, rcv_state->offset, msg->len, rcv_state->message_len); + rcv_state->num_bad_frags ++; + } + } /* not collecting */ +} /* handle_msg_frag */ + + +/* UM receiver callback. + */ +int msg_rcv_cb(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) +{ + rcv_state_t *rcv_state = (rcv_state_t *)msg->source_clientd; + int err; + + switch (msg->type) { + case LBM_MSG_DATA: + if (msg->properties != NULL) { + lbm_int32_t remaining; + size_t prop_size = sizeof(remaining); + int prop_type = LBM_MSG_PROPERTY_INT; + + /* Found property, is it for fragmentation? */ + err = lbm_msg_properties_get(msg->properties, "Remain", + &remaining, &prop_type, &prop_size); + if (err == LBM_OK) { + handle_msg_frag(msg, rcv_state, remaining); + } + else { + printf("handle messages with other properties.\n"); + } + } /* msg properties not null */ + else { /* msg properties == NULL */ + if (rcv_state->collecting) { + /* Error, non-frag, but state is collecting (should never happen). */ + printf("Collect error non-frag, offset=%ld, len=%lu, message_len=%ld\n", rcv_state->offset, msg->len, rcv_state->message_len); + /* Stop collecting after error. */ + rcv_state->collecting = 0; + rcv_state->num_bad_frags ++; + } + + /* Deliver data message. */ + printf("PROCESS message, buf[0]=%d, buf[%ld]=%d\n", + msg->data[0], + msg->len - 1, + msg->data[msg->len - 1]); + } + break; + + case LBM_MSG_UNRECOVERABLE_LOSS: + case LBM_MSG_UNRECOVERABLE_LOSS_BURST: + if (rcv_state->collecting) { + /* Stop collecting after error. */ + rcv_state->collecting = 0; + rcv_state->num_bad_frags ++; + } + + default: + printf("Non data receiver event, type=%d\n", msg->type); + } /* switch msg type */ + + return 0; +} /* msg_rcv_cb */ + + +/* Callback when a receiver delivery controller is created for a new source. */ +void *per_src_clientd_create(const char *source_name, void *clientd) +{ + rcv_state_t *rcv_state; + + rcv_state = (rcv_state_t *)malloc(sizeof(rcv_state_t)); + + rcv_state->reassem_buf_size = 8192; + rcv_state->reassem_buf = (char *)malloc(rcv_state->reassem_buf_size); + rcv_state->collecting = 0; + rcv_state->num_bad_frags = 0; + + return rcv_state; +} /* per_src_clientd_create */ + + +/* Callback when a receiver delivery controller for an ex-source is deleted. */ +int per_src_clientd_delete(const char *source_name, void *clientd, + void *src_clientd) +{ + rcv_state_t *rcv_state = (rcv_state_t *)src_clientd; + + if (rcv_state->collecting) { + /* Error, state is collecting. */ + printf("Collect error, incomplete fragmented message, offset=%ld, message_len=%ld\n", rcv_state->offset, rcv_state->message_len); + } + if (rcv_state->num_bad_frags > 0) { + printf("Number of bad fragments=%ld\n", rcv_state->num_bad_frags); + } + + free(rcv_state->reassem_buf); + free(rcv_state); + + return 0; +} /* per_src_clientd_delete */ + + +/* Create a SmartSource, and init associated state. + */ +void smart_source_init(smart_source_t *smart_source, lbm_context_t *ctx, + char *topic) +{ + lbm_topic_t *lbm_topic = NULL; + lbm_src_topic_attr_t *src_tattr = NULL; + int prop_count; + size_t opt_len; + int err; + + smart_source->ctx = ctx; + + err = lbm_src_topic_attr_create(&src_tattr); + LBM_ERR(err); + + /* Make sure user's config allows at least 1 msg property. */ + opt_len = sizeof(prop_count); + err = lbm_src_topic_attr_getopt(src_tattr, + "smart_src_message_property_int_count", &prop_count, &opt_len); + LBM_ERR(err); + if (prop_count == 0) { + /* No props configured, add one. */ + prop_count = 1; + err = lbm_src_topic_attr_setopt(src_tattr, + "smart_src_message_property_int_count", &prop_count, &opt_len); + LBM_ERR(err); + } + + /* Find out the user's config for max message length. */ + opt_len = sizeof(smart_source->max_msg_len); + err = lbm_src_topic_attr_getopt(src_tattr, + "smart_src_max_message_length", &(smart_source->max_msg_len), &opt_len); + LBM_ERR(err); + + err = lbm_src_topic_alloc(&lbm_topic, ctx, topic, src_tattr); + LBM_ERR(err); + + err = lbm_ssrc_create(&(smart_source->ssrc), ctx, lbm_topic, NULL, NULL, + NULL); + LBM_ERR(err); + + err = lbm_src_topic_attr_delete(src_tattr); + LBM_ERR(err); + + err = lbm_ssrc_buff_get(smart_source->ssrc, &smart_source->msgbuf_plain, 0); + LBM_ERR(err); + err = lbm_ssrc_buff_get(smart_source->ssrc, &smart_source->msgbuf_props, 0); + LBM_ERR(err); + + /* Set up message property. */ + smart_source->info_prop.flags = LBM_SSRC_SEND_EX_FLAG_PROPERTIES; + smart_source->info_prop.mprop_int_cnt = 1; + smart_source->info_prop.mprop_int_vals = smart_source->int_value_array; + smart_source->info_prop.mprop_int_keys = &smart_source->key_ptr_array[0]; + smart_source->key_ptr_array[0] = smart_source->remain_key; + strncpy(smart_source->remain_key, "Remain", sizeof(smart_source->remain_key)); +} /* smart_source_init */ + + +/* Send a message, fragmenting it if necessary. + */ +void smart_source_send(smart_source_t *smart_source, char *buf, size_t len, + int flags) +{ + int err; + + if (len <= smart_source->max_msg_len) { + /* Message fits in one buffer, send it. */ + memcpy(smart_source->msgbuf_plain, buf, len); + err = lbm_ssrc_send_ex(smart_source->ssrc, smart_source->msgbuf_plain, + len, 0, NULL); + LBM_ERR(err); + } + + else { /* Message does not fit in one buffer */ + int offset; + int remaining; + int this_len; + + /* Fragment message. */ + remaining = len; + offset = 0; + + this_len = smart_source->max_msg_len; + remaining -= this_len; + /* Indicate first fragment with negative remainer. */ + smart_source->int_value_array[0] = - remaining; + memcpy(smart_source->msgbuf_props, &buf[offset], this_len); + err = lbm_ssrc_send_ex(smart_source->ssrc, smart_source->msgbuf_props, + this_len, 0, &(smart_source->info_prop)); + LBM_ERR(err); + offset += this_len; + + /* From now on, need to update the properties. */ + smart_source->info_prop.flags |= LBM_SSRC_SEND_EX_FLAG_UPDATE_PROPERTY_VALUES; + + /* Send rest of fragments. */ + while (remaining > 0) { + if (remaining > smart_source->max_msg_len) { + this_len = smart_source->max_msg_len; + } + else { + this_len = remaining; + } + remaining -= this_len; + smart_source->int_value_array[0] = remaining; + memcpy(smart_source->msgbuf_props, &buf[offset], this_len); + err = lbm_ssrc_send_ex(smart_source->ssrc, smart_source->msgbuf_props, + this_len, 0, &(smart_source->info_prop)); + + offset += this_len; + } /* while */ + } +} /* smart_source_send */ + + +int main(int argc, char **argv) { + lbm_context_t *rctx = NULL; + lbm_context_t *sctx = NULL; + lbm_rcv_topic_attr_t *rcv_attr = NULL; + lbm_rcv_src_notification_func_t src_notif_func; /* config option */ + lbm_topic_t *lbm_topic = NULL; + lbm_rcv_t *rcv; + smart_source_t smart_source; + char *send_buff; + int err; + + err = lbm_config("test.cfg"); + LBM_ERR(err); + + /* Create a pair of contexts, one for publisher, the other for subscriber. + */ + + err = lbm_context_create(&rctx, NULL, NULL, NULL); + LBM_ERR(err); + + err = lbm_context_create(&sctx, NULL, NULL, NULL); + LBM_ERR(err); + + + /* Create receiver. + */ + + err = lbm_rcv_topic_attr_create(&rcv_attr); + LBM_ERR(err); + + src_notif_func.create_func = per_src_clientd_create; + src_notif_func.delete_func = per_src_clientd_delete; + src_notif_func.clientd = NULL; /* Or your own state structure. */ + err = lbm_rcv_topic_attr_setopt(rcv_attr, "source_notification_function", + &src_notif_func, sizeof(src_notif_func)); + LBM_ERR(err); + + err = lbm_rcv_topic_lookup(&lbm_topic, rctx, "topic_1", rcv_attr); + LBM_ERR(err); + + err = lbm_rcv_create(&rcv, rctx, lbm_topic, msg_rcv_cb, NULL, NULL); + LBM_ERR(err); + + + /* Create source. + */ + smart_source_init(&smart_source, sctx, "topic_1"); + + send_buff = (char *)malloc(70000); /* Bigger than 64k, for fun. */ + + SLEEP(1); /* For topic res. */ + + + /* Send messages. + */ + + send_buff[0] = 1; send_buff[999] = 1; + smart_source_send(&smart_source, send_buff, 1000, LBM_MSG_FLUSH); + SLEEP(1); + + send_buff[0] = 2; send_buff[4999] = 2; + smart_source_send(&smart_source, send_buff, 5000, LBM_MSG_FLUSH); + SLEEP(1); + + send_buff[0] = 3; send_buff[19999] = 3; + smart_source_send(&smart_source, send_buff, 20000, LBM_MSG_FLUSH); + SLEEP(1); + + send_buff[0] = 4; send_buff[99] = 4; + smart_source_send(&smart_source, send_buff, 100, LBM_MSG_FLUSH); + SLEEP(1); + + send_buff[0] = 5; send_buff[69999] = 5; + smart_source_send(&smart_source, send_buff, 70000, LBM_MSG_FLUSH); + SLEEP(1); + + + /* Shut down. + */ + + free(send_buff); + + (void)lbm_ssrc_delete(smart_source.ssrc); + (void)lbm_rcv_delete(rcv); + + (void)lbm_context_delete(rctx); + (void)lbm_context_delete(sctx); + + return 0; +} /* main */ diff --git a/ss_frag/c/ss_frag.sldoc b/ss_frag/c/ss_frag.sldoc new file mode 100644 index 0000000..b1dda32 --- /dev/null +++ b/ss_frag/c/ss_frag.sldoc @@ -0,0 +1,58 @@ + + + + Smart Source Message Fragmentation + + + =semlit,include,../intro.sldoc= +

    There is one program source file:

    +
      +
    • =semlit,srcfile,ss_frag_c.slsrc,ss_frag.c= + - (right-click and save as "ss_frag.c") main program.
    • +
    +

    Program explanation: ss_frag.c

    + +

    The ss_frag.c file contains:

    +
      +
    • Source-side code (fragments messages),
    • +
    • Receive-side code (reassembles messages),
    • +
    • Simple demonstration code.
    • +
    +

    Source-Side Code

    +

    At the heart of the source-side code is the function + smart_source_send(): + =semlit,insert,send_funct= +

    CLICK ON A LINE NUBMER TO SEE THE CODE ON THE RIGHT IN CONTEXT!

    +

    This function first checks to see if the application message is + small enough to fit in a single message. If so, it sends the + message without any message properties.

    + =semlit,insert,send_check= +

    For application messages that are too big, they need to be + fragmented. The "Remain" message property is set to negative + of the remaining size after this fragment is sent.

    + =semlit,insert,send_first= +

    Subsequent fragments are sent, chunk at a time, with + a positive "Remain" property.

    + =semlit,insert,send_rest= +

    Send Buffers

    +

    For efficiency and simplicity, two Smart Source send buffers + are used to send messages: msgbuf_plain for small messages + with no properties, and msgbuf_props for large fragmented + messages that have properties. They are initialized in + smart_source_init().

    + =semlit,insert,send_buffs= +

    The message property is also initialized.

    + =semlit,insert,send_props= +

    The source-side code needs to know what the size threshold is for + fragmented messages. It determines this by creating a source + attribute object, which inherets the user's configuration.

    + =semlit,insert,send_attr= +

    Then, the configured value for the option + smart_src_max_message_length (source) + is read.

    + =semlit,insert,send_size= +

    There is also a sanity check to make sure the user configured a + message property.

    + =semlit,insert,send_conf_prop= + + diff --git a/ss_frag/c/ss_frag.sldoc.html b/ss_frag/c/ss_frag.sldoc.html new file mode 100644 index 0000000..c078ee8 --- /dev/null +++ b/ss_frag/c/ss_frag.sldoc.html @@ -0,0 +1,218 @@ + + + + Smart Source Message Fragmentation + + + Example index +

    Smart Source Message Fragmentation

    +

    Ultra Messaging has a feature called + Smart Sources + which provides lower average latency and much lower latency + variation (jitter) than traditional UM sources. + Smart Sources are able to deliver these benefits by trading off reduced + flexibility for simplicity, especially simplicity in memory usage.

    +

    One area of reduced flexibility is related to message sizes. + To avoid dynamic memory allocation/deallocation, Smart Sources require + the user to configure the maximum expected message size. + Also, Smart Sources do not support fragmentation and reassembly of + messages larger than the maximum datagram size. + An application message must fit in a single datagram. + Finally, users of kernel bypass TCP/IP stacks (like Solarflare's Onload) + pay a heavy penalty if IP fragmentation is performed by the kernel. + These users typically want to keep each datagram at or below the + NIC's MTU size (typically 1500 bytes).

    +

    However, many applications have a fairly small average message size, + but occasionally need to send messages that are much larger. + If that worst-case large message size is larger than an MTU, + it cannot be efficiently sent using Onload or other kernel bypass stacks.

    +

    Also, even if IP fragmentation is not a problem, + a Smart Sources pre-allocates its retransmission buffers based on the + worst-case message size. + For applications that normally send small messages but occasionally + need to send very large ones, + this can lead to a significant memory footprint.

    +

    One solution to these problems is for an application to configure Smart + Source for small messages, and perform message fragmentation and + reassembly at the application level. + This example program does just that.

    +

    High-Level Design

    +

    An integer message property with key name "Remain" is used to manage + message fragmentation and reassembly. + Small messages may be sent without a property. + Messages which exceed a configured threshold will be sent in "chunks", + with a message property providing the information needed by the + receiver to reassemble the chunks.

    +

    When the application wants to send a message larger than + [smart_src_max_message_length (source)](https://ultramessaging.github.io/currdoc/doc/Config/grpsmartsource.html#smartsrcmaxmessagelengthsource), + the first fragment is sent with the "Remain" property is a negative + number representing the number of bytes that still need to be sent + (not counting the content of that first message). + Each subsequent message fragment sent has the "Remain" property as + a positive number of the number of bytes remaining + after that message.

    +

    For example, if smart_src_max_message_length is set to 1400 and a + 5000 byte message is sent, 4 UM messages will be sent. + Here are the message lengths and values for the "Remain" property:

    +
      +
    1. length=1400, Remain=-3600
    2. +
    3. length=1400, Remain=2200
    4. +
    5. length=1400, Remain=800
    6. +
    7. length=800, Remain=0
    8. +

      When the receiver sees Remain=0, it can deliver the reassembled message.

      + +

      There is one program source file:

      +
        +
      • ss_frag.c + - (right-click and save as "ss_frag.c") main program.
      • +
      +

      Program explanation: ss_frag.c

      + +

      The ss_frag.c file contains:

      +
        +
      • Source-side code (fragments messages),
      • +
      • Receive-side code (reassembles messages),
      • +
      • Simple demonstration code.
      • +
      +

      Source-Side Code

      +

      At the heart of the source-side code is the function + smart_source_send(): + +

      +00312  /* Send a message, fragmenting it if necessary.
      +00313   */
      +00314  void smart_source_send(smart_source_t *smart_source, char *buf, size_t len,
      +00315    int flags)
      +00316  {
      +
      + + +

      CLICK ON A LINE NUBMER TO SEE THE CODE ON THE RIGHT IN CONTEXT!

      +

      This function first checks to see if the application message is + small enough to fit in a single message. If so, it sends the + message without any message properties.

      + +
      +00319    if (len <= smart_source->max_msg_len) {
      +00320      /* Message fits in one buffer, send it. */
      +00321      memcpy(smart_source->msgbuf_plain, buf, len);
      +00322      err = lbm_ssrc_send_ex(smart_source->ssrc, smart_source->msgbuf_plain,
      +00323        len, 0, NULL);
      +00324      LBM_ERR(err);
      +00325    }
      +
      + + +

      For application messages that are too big, they need to be + fragmented. The "Remain" message property is set to negative + of the remaining size after this fragment is sent.

      + +
      +00336      this_len = smart_source->max_msg_len;
      +00337      remaining -= this_len;
      +00338      /* Indicate first fragment with negative remainer. */
      +00339      smart_source->int_value_array[0] = - remaining;
      +00340      memcpy(smart_source->msgbuf_props, &buf[offset], this_len);
      +00341      err = lbm_ssrc_send_ex(smart_source->ssrc, smart_source->msgbuf_props,
      +00342        this_len, 0, &(smart_source->info_prop));
      +00343      LBM_ERR(err);
      +00344      offset += this_len;
      +
      + + +

      Subsequent fragments are sent, chunk at a time, with + a positive "Remain" property.

      + +
      +00349      /* Send rest of fragments. */
      +00350      while (remaining > 0) {
      +00351        if (remaining > smart_source->max_msg_len) {
      +00352          this_len = smart_source->max_msg_len;
      +00353        }
      +00354        else {
      +00355          this_len = remaining;
      +00356        }
      +00357        remaining -= this_len;
      +00358        smart_source->int_value_array[0] = remaining;
      +00359        memcpy(smart_source->msgbuf_props, &buf[offset], this_len);
      +00360        err = lbm_ssrc_send_ex(smart_source->ssrc, smart_source->msgbuf_props,
      +00361          this_len, 0, &(smart_source->info_prop));
      +00362  
      +00363        offset += this_len;
      +00364      }  /* while */
      +
      + + +

      Send Buffers

      +

      For efficiency and simplicity, two Smart Source send buffers + are used to send messages: msgbuf_plain for small messages + with no properties, and msgbuf_props for large fragmented + messages that have properties. They are initialized in + smart_source_init().

      + +
      +00297    err = lbm_ssrc_buff_get(smart_source->ssrc, &smart_source->msgbuf_plain, 0);
      +00298    LBM_ERR(err);
      +00299    err = lbm_ssrc_buff_get(smart_source->ssrc, &smart_source->msgbuf_props, 0);
      +00300    LBM_ERR(err);
      +
      + + +

      The message property is also initialized.

      + +
      +00302    /* Set up message property. */
      +00303    smart_source->info_prop.flags = LBM_SSRC_SEND_EX_FLAG_PROPERTIES;
      +00304    smart_source->info_prop.mprop_int_cnt = 1;
      +00305    smart_source->info_prop.mprop_int_vals = smart_source->int_value_array;
      +00306    smart_source->info_prop.mprop_int_keys = &smart_source->key_ptr_array[0];
      +00307    smart_source->key_ptr_array[0] = smart_source->remain_key;
      +00308    strncpy(smart_source->remain_key, "Remain", sizeof(smart_source->remain_key));
      +
      + + +

      The source-side code needs to know what the size threshold is for + fragmented messages. It determines this by creating a source + attribute object, which inherets the user's configuration.

      + +
      +00265    err = lbm_src_topic_attr_create(&src_tattr);
      +00266    LBM_ERR(err);
      +
      + + +

      Then, the configured value for the option + smart_src_max_message_length (source) + is read.

      + +
      +00281    /* Find out the user's config for max message length. */
      +00282    opt_len = sizeof(smart_source->max_msg_len);
      +00283    err = lbm_src_topic_attr_getopt(src_tattr,
      +00284      "smart_src_max_message_length", &(smart_source->max_msg_len), &opt_len);
      +00285    LBM_ERR(err);
      +
      + + +

      There is also a sanity check to make sure the user configured a + message property.

      + +
      +00268    /* Make sure user's config allows at least 1 msg property. */
      +00269    opt_len = sizeof(prop_count);
      +00270    err = lbm_src_topic_attr_getopt(src_tattr,
      +00271      "smart_src_message_property_int_count", &prop_count, &opt_len);
      +00272    LBM_ERR(err);
      +00273    if (prop_count == 0) {
      +00274      /* No props configured, add one. */
      +00275      prop_count = 1;
      +00276      err = lbm_src_topic_attr_setopt(src_tattr,
      +00277        "smart_src_message_property_int_count", &prop_count, &opt_len);
      +00278      LBM_ERR(err);
      +00279    }
      +
      + + + + + diff --git a/ss_frag/c/ss_frag_c.slsrc b/ss_frag/c/ss_frag_c.slsrc new file mode 100644 index 0000000..a2656b6 --- /dev/null +++ b/ss_frag/c/ss_frag_c.slsrc @@ -0,0 +1,478 @@ +/* ss_frag.c - see http://ultramessaging.github.io/UMExamples/ss_frag/c/index.html + * + * Copyright (c) 2005-2018 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ + +/* =semlit,block,includes=*/ +#include +#include + +#if defined(_MSC_VER) +/* Windows-only includes */ +#include +#define SLEEP(s) Sleep((s)*1000) +#else +/* Unix-only includes */ +#include +#include +#define SLEEP(s) sleep(s) +#endif + +#include +/* =semlit,endblock,includes=*/ + + +/* Application structure associated with a smart source. + */ +typedef struct { + lbm_context_t *ctx; + lbm_ssrc_t *ssrc; + char *msgbuf_plain; + char *msgbuf_props; + int max_msg_len; + lbm_ssrc_send_ex_info_t info_prop; + lbm_uint32_t int_value_array[2]; + char *key_ptr_array[2]; + char remain_key[8]; +} smart_source_t; + + +/* Receiver state used to reassemble fragmented messages. Used as per-source + * clientd. + */ +typedef struct { + int collecting; /* 1=true, 0=false. */ + char *reassem_buf; + size_t reassem_buf_size; + size_t message_len; /* Size of message being reassembled. */ + size_t offset; /* Current offset within reassem_buf[]. */ + long num_bad_frags; /* Statistic: bad fragemnts. */ +} rcv_state_t; + + +/* + * Simple lbm error handling. + */ + +/* Macro to approximate the basename() function. */ +#define BASENAME(_p) ((strrchr(_p, '/') == NULL) ? (_p) : (strrchr(_p, '/')+1)) + +/* Pass in an LBM return status. If not success, print error and abort. */ +#define LBM_ERR(_e) do {\ + if ((_e) != LBM_OK) {\ + printf("LBM_ERR: at %s:%d (%s)\n",\ + BASENAME(__FILE__), __LINE__, lbm_errmsg());\ + fflush(stdout);\ + abort();\ + }\ +} while (0) + +/* Print error and abort. */ +#define ERR(_s) do {\ + printf("ERR: at %s:%d (%s)\n",\ + BASENAME(__FILE__), __LINE__, _s);\ + fflush(stdout);\ + abort();\ +} while (0) + + +/* Called by receiver callback when a received messager has the "Remain" + * message property, indicating a fragmented message. + */ +void handle_msg_frag(lbm_msg_t *msg, rcv_state_t *rcv_state, + lbm_int32_t remaining) +{ + size_t tot_len; + + if (rcv_state->collecting) { + /* Make sure the fragment is OK. */ + if (remaining >= 0 && + (rcv_state->message_len == (rcv_state->offset + msg->len + remaining))) + { + /* Non-NULL reassem buffer, continue collecting. */ + memcpy(&rcv_state->reassem_buf[rcv_state->offset], msg->data, + msg->len); + rcv_state->offset += msg->len; + + if (remaining == 0) { /* No more, deliver the data. */ + printf("PROCESS message, buf[0]=%d, buf[%ld]=%d\n", + rcv_state->reassem_buf[0], + rcv_state->message_len - 1, + rcv_state->reassem_buf[rcv_state->message_len - 1]); + + /* No longer collecting. */ + rcv_state->collecting = 0; + } + } /* if fragment OK */ + else { /* fragment is not ok. */ + /* Bad fragment (should never happen). */ + printf("Collect error: bad fragment, remaining=%d, offset=%ld, len=%lu, message_len=%ld\n", remaining, rcv_state->offset, msg->len, rcv_state->message_len); + rcv_state->num_bad_frags ++; + + /* Error, stop collecting. */ + rcv_state->collecting = 0; + } + } + + else { /* not collecting */ + /* Not collecting a fragmented message, is this message first frag? */ + if (remaining < 0) { + /* First fragment. */ + rcv_state->collecting = 1; + rcv_state->offset = 0; + rcv_state->message_len = msg->len + (- remaining); + /* Expand buffer if necessary. */ + if (rcv_state->message_len > rcv_state->reassem_buf_size) { + rcv_state->reassem_buf_size = rcv_state->message_len; + rcv_state->reassem_buf = (char *)realloc(rcv_state->reassem_buf, + rcv_state->reassem_buf_size); + } + + /* Collect data. */ + memcpy(&rcv_state->reassem_buf[rcv_state->offset], msg->data, msg->len); + rcv_state->offset += msg->len; + } /* remaining < 0 */ + else { /* Found middle frag without a first frag; discard. */ + /* Probably joined stream in middle of message. */ + printf("info: found middle frag but not collecting, remaining=%d, offset=%ld, len=%lu, message_len=%ld\n", remaining, rcv_state->offset, msg->len, rcv_state->message_len); + rcv_state->num_bad_frags ++; + } + } /* not collecting */ +} /* handle_msg_frag */ + + +/* UM receiver callback. + */ +int msg_rcv_cb(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) +{ + rcv_state_t *rcv_state = (rcv_state_t *)msg->source_clientd; + int err; + + switch (msg->type) { + case LBM_MSG_DATA: + if (msg->properties != NULL) { + lbm_int32_t remaining; + size_t prop_size = sizeof(remaining); + int prop_type = LBM_MSG_PROPERTY_INT; + + /* Found property, is it for fragmentation? */ + err = lbm_msg_properties_get(msg->properties, "Remain", + &remaining, &prop_type, &prop_size); + if (err == LBM_OK) { + handle_msg_frag(msg, rcv_state, remaining); + } + else { + printf("handle messages with other properties.\n"); + } + } /* msg properties not null */ + else { /* msg properties == NULL */ + if (rcv_state->collecting) { + /* Error, non-frag, but state is collecting (should never happen). */ + printf("Collect error non-frag, offset=%ld, len=%lu, message_len=%ld\n", rcv_state->offset, msg->len, rcv_state->message_len); + /* Stop collecting after error. */ + rcv_state->collecting = 0; + rcv_state->num_bad_frags ++; + } + + /* Deliver data message. */ + printf("PROCESS message, buf[0]=%d, buf[%ld]=%d\n", + msg->data[0], + msg->len - 1, + msg->data[msg->len - 1]); + } + break; + + case LBM_MSG_UNRECOVERABLE_LOSS: + case LBM_MSG_UNRECOVERABLE_LOSS_BURST: + if (rcv_state->collecting) { + /* Stop collecting after error. */ + rcv_state->collecting = 0; + rcv_state->num_bad_frags ++; + } + + default: + printf("Non data receiver event, type=%d\n", msg->type); + } /* switch msg type */ + + return 0; +} /* msg_rcv_cb */ + + +/* Callback when a receiver delivery controller is created for a new source. */ +void *per_src_clientd_create(const char *source_name, void *clientd) +{ + rcv_state_t *rcv_state; + + rcv_state = (rcv_state_t *)malloc(sizeof(rcv_state_t)); + + rcv_state->reassem_buf_size = 8192; + rcv_state->reassem_buf = (char *)malloc(rcv_state->reassem_buf_size); + rcv_state->collecting = 0; + rcv_state->num_bad_frags = 0; + + return rcv_state; +} /* per_src_clientd_create */ + + +/* Callback when a receiver delivery controller for an ex-source is deleted. */ +int per_src_clientd_delete(const char *source_name, void *clientd, + void *src_clientd) +{ + rcv_state_t *rcv_state = (rcv_state_t *)src_clientd; + + if (rcv_state->collecting) { + /* Error, state is collecting. */ + printf("Collect error, incomplete fragmented message, offset=%ld, message_len=%ld\n", rcv_state->offset, rcv_state->message_len); + } + if (rcv_state->num_bad_frags > 0) { + printf("Number of bad fragments=%ld\n", rcv_state->num_bad_frags); + } + + free(rcv_state->reassem_buf); + free(rcv_state); + + return 0; +} /* per_src_clientd_delete */ + + +/* Create a SmartSource, and init associated state. + */ +void smart_source_init(smart_source_t *smart_source, lbm_context_t *ctx, + char *topic) +{ + lbm_topic_t *lbm_topic = NULL; + lbm_src_topic_attr_t *src_tattr = NULL; + int prop_count; + size_t opt_len; + int err; + + smart_source->ctx = ctx; + +/* =semlit,block,send_attr=*/ + err = lbm_src_topic_attr_create(&src_tattr); + LBM_ERR(err); +/* =semlit,endblock,send_attr=*/ + +/* =semlit,block,send_conf_prop=*/ + /* Make sure user's config allows at least 1 msg property. */ + opt_len = sizeof(prop_count); + err = lbm_src_topic_attr_getopt(src_tattr, + "smart_src_message_property_int_count", &prop_count, &opt_len); + LBM_ERR(err); + if (prop_count == 0) { + /* No props configured, add one. */ + prop_count = 1; + err = lbm_src_topic_attr_setopt(src_tattr, + "smart_src_message_property_int_count", &prop_count, &opt_len); + LBM_ERR(err); + } +/* =semlit,endblock,send_conf_prop=*/ + +/* =semlit,block,send_size=*/ + /* Find out the user's config for max message length. */ + opt_len = sizeof(smart_source->max_msg_len); + err = lbm_src_topic_attr_getopt(src_tattr, + "smart_src_max_message_length", &(smart_source->max_msg_len), &opt_len); + LBM_ERR(err); +/* =semlit,endblock,send_size=*/ + + err = lbm_src_topic_alloc(&lbm_topic, ctx, topic, src_tattr); + LBM_ERR(err); + + err = lbm_ssrc_create(&(smart_source->ssrc), ctx, lbm_topic, NULL, NULL, + NULL); + LBM_ERR(err); + + err = lbm_src_topic_attr_delete(src_tattr); + LBM_ERR(err); + +/* =semlit,block,send_buffs=*/ + err = lbm_ssrc_buff_get(smart_source->ssrc, &smart_source->msgbuf_plain, 0); + LBM_ERR(err); + err = lbm_ssrc_buff_get(smart_source->ssrc, &smart_source->msgbuf_props, 0); + LBM_ERR(err); +/* =semlit,endblock,send_buffs=*/ + +/* =semlit,block,send_props=*/ + /* Set up message property. */ + smart_source->info_prop.flags = LBM_SSRC_SEND_EX_FLAG_PROPERTIES; + smart_source->info_prop.mprop_int_cnt = 1; + smart_source->info_prop.mprop_int_vals = smart_source->int_value_array; + smart_source->info_prop.mprop_int_keys = &smart_source->key_ptr_array[0]; + smart_source->key_ptr_array[0] = smart_source->remain_key; + strncpy(smart_source->remain_key, "Remain", sizeof(smart_source->remain_key)); +/* =semlit,endblock,send_props=*/ +} /* smart_source_init */ + + +/* =semlit,block,send_funct=*/ +/* Send a message, fragmenting it if necessary. + */ +void smart_source_send(smart_source_t *smart_source, char *buf, size_t len, + int flags) +{ +/* =semlit,endblock,send_funct=*/ + int err; + +/* =semlit,block,send_check=*/ + if (len <= smart_source->max_msg_len) { + /* Message fits in one buffer, send it. */ + memcpy(smart_source->msgbuf_plain, buf, len); + err = lbm_ssrc_send_ex(smart_source->ssrc, smart_source->msgbuf_plain, + len, 0, NULL); + LBM_ERR(err); + } +/* =semlit,endblock,send_check=*/ + + else { /* Message does not fit in one buffer */ + int offset; + int remaining; + int this_len; + + /* Fragment message. */ + remaining = len; + offset = 0; + +/* =semlit,block,send_first=*/ + this_len = smart_source->max_msg_len; + remaining -= this_len; + /* Indicate first fragment with negative remainer. */ + smart_source->int_value_array[0] = - remaining; + memcpy(smart_source->msgbuf_props, &buf[offset], this_len); + err = lbm_ssrc_send_ex(smart_source->ssrc, smart_source->msgbuf_props, + this_len, 0, &(smart_source->info_prop)); + LBM_ERR(err); + offset += this_len; +/* =semlit,endblock,send_first=*/ + + /* From now on, need to update the properties. */ + smart_source->info_prop.flags |= LBM_SSRC_SEND_EX_FLAG_UPDATE_PROPERTY_VALUES; + +/* =semlit,block,send_rest=*/ + /* Send rest of fragments. */ + while (remaining > 0) { + if (remaining > smart_source->max_msg_len) { + this_len = smart_source->max_msg_len; + } + else { + this_len = remaining; + } + remaining -= this_len; + smart_source->int_value_array[0] = remaining; + memcpy(smart_source->msgbuf_props, &buf[offset], this_len); + err = lbm_ssrc_send_ex(smart_source->ssrc, smart_source->msgbuf_props, + this_len, 0, &(smart_source->info_prop)); + + offset += this_len; + } /* while */ +/* =semlit,endblock,send_rest=*/ + } +} /* smart_source_send */ + + +int main(int argc, char **argv) { + lbm_context_t *rctx = NULL; + lbm_context_t *sctx = NULL; + lbm_rcv_topic_attr_t *rcv_attr = NULL; + lbm_rcv_src_notification_func_t src_notif_func; /* config option */ + lbm_topic_t *lbm_topic = NULL; + lbm_rcv_t *rcv; + smart_source_t smart_source; + char *send_buff; + int err; + + err = lbm_config("test.cfg"); + LBM_ERR(err); + + /* Create a pair of contexts, one for publisher, the other for subscriber. + */ + + err = lbm_context_create(&rctx, NULL, NULL, NULL); + LBM_ERR(err); + + err = lbm_context_create(&sctx, NULL, NULL, NULL); + LBM_ERR(err); + + + /* Create receiver. + */ + + err = lbm_rcv_topic_attr_create(&rcv_attr); + LBM_ERR(err); + + src_notif_func.create_func = per_src_clientd_create; + src_notif_func.delete_func = per_src_clientd_delete; + src_notif_func.clientd = NULL; /* Or your own state structure. */ + err = lbm_rcv_topic_attr_setopt(rcv_attr, "source_notification_function", + &src_notif_func, sizeof(src_notif_func)); + LBM_ERR(err); + + err = lbm_rcv_topic_lookup(&lbm_topic, rctx, "topic_1", rcv_attr); + LBM_ERR(err); + + err = lbm_rcv_create(&rcv, rctx, lbm_topic, msg_rcv_cb, NULL, NULL); + LBM_ERR(err); + + + /* Create source. + */ + smart_source_init(&smart_source, sctx, "topic_1"); + + send_buff = (char *)malloc(70000); /* Bigger than 64k, for fun. */ + + SLEEP(1); /* For topic res. */ + + + /* Send messages. + */ + + send_buff[0] = 1; send_buff[999] = 1; + smart_source_send(&smart_source, send_buff, 1000, LBM_MSG_FLUSH); + SLEEP(1); + + send_buff[0] = 2; send_buff[4999] = 2; + smart_source_send(&smart_source, send_buff, 5000, LBM_MSG_FLUSH); + SLEEP(1); + + send_buff[0] = 3; send_buff[19999] = 3; + smart_source_send(&smart_source, send_buff, 20000, LBM_MSG_FLUSH); + SLEEP(1); + + send_buff[0] = 4; send_buff[99] = 4; + smart_source_send(&smart_source, send_buff, 100, LBM_MSG_FLUSH); + SLEEP(1); + + send_buff[0] = 5; send_buff[69999] = 5; + smart_source_send(&smart_source, send_buff, 70000, LBM_MSG_FLUSH); + SLEEP(1); + + + /* Shut down. + */ + + free(send_buff); + + (void)lbm_ssrc_delete(smart_source.ssrc); + (void)lbm_rcv_delete(rcv); + + (void)lbm_context_delete(rctx); + (void)lbm_context_delete(sctx); + + return 0; +} /* main */ diff --git a/ss_frag/c/ss_frag_c.slsrc.html b/ss_frag/c/ss_frag_c.slsrc.html new file mode 100644 index 0000000..3912ecc --- /dev/null +++ b/ss_frag/c/ss_frag_c.slsrc.html @@ -0,0 +1,1020 @@ +ss_frag.c + + + + + + + + +

      ss_frag.c

      + +
      
      +
      00001 +00002 +00003 +00004 +00005 +00006 +00007 +00008 +00009 +00010 +00011 +00012 +00013 +00014 +00015 +00016 +00017 +00018 +00019 +00020 +00021 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 +00036 +00037 +00038 +00039 +00040 +00041 +00042 +00043 +00044 +00045 +00046 +00047 +00048 +00049 +00050 +00051 +00052 +00053 +00054 +00055 +00056 +00057 +00058 +00059 +00060 +00061 +00062 +00063 +00064 +00065 +00066 +00067 +00068 +00069 +00070 +00071 +00072 +00073 +00074 +00075 +00076 +00077 +00078 +00079 +00080 +00081 +00082 +00083 +00084 +00085 +00086 +00087 +00088 +00089 +00090 +00091 +00092 +00093 +00094 +00095 +00096 +00097 +00098 +00099 +00100 +00101 +00102 +00103 +00104 +00105 +00106 +00107 +00108 +00109 +00110 +00111 +00112 +00113 +00114 +00115 +00116 +00117 +00118 +00119 +00120 +00121 +00122 +00123 +00124 +00125 +00126 +00127 +00128 +00129 +00130 +00131 +00132 +00133 +00134 +00135 +00136 +00137 +00138 +00139 +00140 +00141 +00142 +00143 +00144 +00145 +00146 +00147 +00148 +00149 +00150 +00151 +00152 +00153 +00154 +00155 +00156 +00157 +00158 +00159 +00160 +00161 +00162 +00163 +00164 +00165 +00166 +00167 +00168 +00169 +00170 +00171 +00172 +00173 +00174 +00175 +00176 +00177 +00178 +00179 +00180 +00181 +00182 +00183 +00184 +00185 +00186 +00187 +00188 +00189 +00190 +00191 +00192 +00193 +00194 +00195 +00196 +00197 +00198 +00199 +00200 +00201 +00202 +00203 +00204 +00205 +00206 +00207 +00208 +00209 +00210 +00211 +00212 +00213 +00214 +00215 +00216 +00217 +00218 +00219 +00220 +00221 +00222 +00223 +00224 +00225 +00226 +00227 +00228 +00229 +00230 +00231 +00232 +00233 +00234 +00235 +00236 +00237 +00238 +00239 +00240 +00241 +00242 +00243 +00244 +00245 +00246 +00247 +00248 +00249 +00250 +00251 +00252 +00253 +00254 +00255 +00256 +00257 +00258 +00259 +00260 +00261 +00262 +00263 +00264 +00265 +00266 +00267 +00268 +00269 +00270 +00271 +00272 +00273 +00274 +00275 +00276 +00277 +00278 +00279 +00280 +00281 +00282 +00283 +00284 +00285 +00286 +00287 +00288 +00289 +00290 +00291 +00292 +00293 +00294 +00295 +00296 +00297 +00298 +00299 +00300 +00301 +00302 +00303 +00304 +00305 +00306 +00307 +00308 +00309 +00310 +00311 +00312 +00313 +00314 +00315 +00316 +00317 +00318 +00319 +00320 +00321 +00322 +00323 +00324 +00325 +00326 +00327 +00328 +00329 +00330 +00331 +00332 +00333 +00334 +00335 +00336 +00337 +00338 +00339 +00340 +00341 +00342 +00343 +00344 +00345 +00346 +00347 +00348 +00349 +00350 +00351 +00352 +00353 +00354 +00355 +00356 +00357 +00358 +00359 +00360 +00361 +00362 +00363 +00364 +00365 +00366 +00367 +00368 +00369 +00370 +00371 +00372 +00373 +00374 +00375 +00376 +00377 +00378 +00379 +00380 +00381 +00382 +00383 +00384 +00385 +00386 +00387 +00388 +00389 +00390 +00391 +00392 +00393 +00394 +00395 +00396 +00397 +00398 +00399 +00400 +00401 +00402 +00403 +00404 +00405 +00406 +00407 +00408 +00409 +00410 +00411 +00412 +00413 +00414 +00415 +00416 +00417 +00418 +00419 +00420 +00421 +00422 +00423 +00424 +00425 +00426 +00427 +00428 +00429 +00430 +00431 +00432 +00433 +00434 +00435 +00436 +00437 +00438 +00439 +00440 +00441 +00442 +00443 +00444 +00445 +00446 +00447 +00448 +00449 +00450 +00451 +00452 +00453 +00454 +00455 +00456 +00457 +00458 + /* ss_frag.c - see http://ultramessaging.github.io/UMExamples/ss_frag/c/index.html + * + * Copyright (c) 2005-2018 Informatica Corporation. All Rights Reserved. + * Permission is granted to licensees to use + * or alter this software for any purpose, including commercial applications, + * according to the terms laid out in the Software License Agreement. + * + * This source code example is provided by Informatica for educational + * and evaluation purposes only. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES + * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF + * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE + * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE + * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR + * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE + * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF + * THE LIKELIHOOD OF SUCH DAMAGES. + */ + + #include <stdio.h> + #include <string.h> + + #if defined(_MSC_VER) + /* Windows-only includes */ + #include <winsock2.h> + #define SLEEP(s) Sleep((s)*1000) + #else + /* Unix-only includes */ + #include <stdlib.h> + #include <unistd.h> + #define SLEEP(s) sleep(s) + #endif + + #include <lbm/lbm.h> + + + /* Application structure associated with a smart source. + */ + typedef struct { + lbm_context_t *ctx; + lbm_ssrc_t *ssrc; + char *msgbuf_plain; + char *msgbuf_props; + int max_msg_len; + lbm_ssrc_send_ex_info_t info_prop; + lbm_uint32_t int_value_array[2]; + char *key_ptr_array[2]; + char remain_key[8]; + } smart_source_t; + + + /* Receiver state used to reassemble fragmented messages. Used as per-source + * clientd. + */ + typedef struct { + int collecting; /* 1=true, 0=false. */ + char *reassem_buf; + size_t reassem_buf_size; + size_t message_len; /* Size of message being reassembled. */ + size_t offset; /* Current offset within reassem_buf[]. */ + long num_bad_frags; /* Statistic: bad fragemnts. */ + } rcv_state_t; + + + /* + * Simple lbm error handling. + */ + + /* Macro to approximate the basename() function. */ + #define BASENAME(_p) ((strrchr(_p, '/') == NULL) ? (_p) : (strrchr(_p, '/')+1)) + + /* Pass in an LBM return status. If not success, print error and abort. */ + #define LBM_ERR(_e) do {\ + if ((_e) != LBM_OK) {\ + printf("LBM_ERR: at %s:%d (%s)\n",\ + BASENAME(__FILE__), __LINE__, lbm_errmsg());\ + fflush(stdout);\ + abort();\ + }\ + } while (0) + + /* Print error and abort. */ + #define ERR(_s) do {\ + printf("ERR: at %s:%d (%s)\n",\ + BASENAME(__FILE__), __LINE__, _s);\ + fflush(stdout);\ + abort();\ + } while (0) + + + /* Called by receiver callback when a received messager has the "Remain" + * message property, indicating a fragmented message. + */ + void handle_msg_frag(lbm_msg_t *msg, rcv_state_t *rcv_state, + lbm_int32_t remaining) + { + size_t tot_len; + + if (rcv_state->collecting) { + /* Make sure the fragment is OK. */ + if (remaining >= 0 && + (rcv_state->message_len == (rcv_state->offset + msg->len + remaining))) + { + /* Non-NULL reassem buffer, continue collecting. */ + memcpy(&rcv_state->reassem_buf[rcv_state->offset], msg->data, + msg->len); + rcv_state->offset += msg->len; + + if (remaining == 0) { /* No more, deliver the data. */ + printf("PROCESS message, buf[0]=%d, buf[%ld]=%d\n", + rcv_state->reassem_buf[0], + rcv_state->message_len - 1, + rcv_state->reassem_buf[rcv_state->message_len - 1]); + + /* No longer collecting. */ + rcv_state->collecting = 0; + } + } /* if fragment OK */ + else { /* fragment is not ok. */ + /* Bad fragment (should never happen). */ + printf("Collect error: bad fragment, remaining=%d, offset=%ld, len=%lu, message_len=%ld\n", remaining, rcv_state->offset, msg->len, rcv_state->message_len); + rcv_state->num_bad_frags ++; + + /* Error, stop collecting. */ + rcv_state->collecting = 0; + } + } + + else { /* not collecting */ + /* Not collecting a fragmented message, is this message first frag? */ + if (remaining < 0) { + /* First fragment. */ + rcv_state->collecting = 1; + rcv_state->offset = 0; + rcv_state->message_len = msg->len + (- remaining); + /* Expand buffer if necessary. */ + if (rcv_state->message_len > rcv_state->reassem_buf_size) { + rcv_state->reassem_buf_size = rcv_state->message_len; + rcv_state->reassem_buf = (char *)realloc(rcv_state->reassem_buf, + rcv_state->reassem_buf_size); + } + + /* Collect data. */ + memcpy(&rcv_state->reassem_buf[rcv_state->offset], msg->data, msg->len); + rcv_state->offset += msg->len; + } /* remaining < 0 */ + else { /* Found middle frag without a first frag; discard. */ + /* Probably joined stream in middle of message. */ + printf("info: found middle frag but not collecting, remaining=%d, offset=%ld, len=%lu, message_len=%ld\n", remaining, rcv_state->offset, msg->len, rcv_state->message_len); + rcv_state->num_bad_frags ++; + } + } /* not collecting */ + } /* handle_msg_frag */ + + + /* UM receiver callback. + */ + int msg_rcv_cb(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) + { + rcv_state_t *rcv_state = (rcv_state_t *)msg->source_clientd; + int err; + + switch (msg->type) { + case LBM_MSG_DATA: + if (msg->properties != NULL) { + lbm_int32_t remaining; + size_t prop_size = sizeof(remaining); + int prop_type = LBM_MSG_PROPERTY_INT; + + /* Found property, is it for fragmentation? */ + err = lbm_msg_properties_get(msg->properties, "Remain", + &remaining, &prop_type, &prop_size); + if (err == LBM_OK) { + handle_msg_frag(msg, rcv_state, remaining); + } + else { + printf("handle messages with other properties.\n"); + } + } /* msg properties not null */ + else { /* msg properties == NULL */ + if (rcv_state->collecting) { + /* Error, non-frag, but state is collecting (should never happen). */ + printf("Collect error non-frag, offset=%ld, len=%lu, message_len=%ld\n", rcv_state->offset, msg->len, rcv_state->message_len); + /* Stop collecting after error. */ + rcv_state->collecting = 0; + rcv_state->num_bad_frags ++; + } + + /* Deliver data message. */ + printf("PROCESS message, buf[0]=%d, buf[%ld]=%d\n", + msg->data[0], + msg->len - 1, + msg->data[msg->len - 1]); + } + break; + + case LBM_MSG_UNRECOVERABLE_LOSS: + case LBM_MSG_UNRECOVERABLE_LOSS_BURST: + if (rcv_state->collecting) { + /* Stop collecting after error. */ + rcv_state->collecting = 0; + rcv_state->num_bad_frags ++; + } + + default: + printf("Non data receiver event, type=%d\n", msg->type); + } /* switch msg type */ + + return 0; + } /* msg_rcv_cb */ + + + /* Callback when a receiver delivery controller is created for a new source. */ + void *per_src_clientd_create(const char *source_name, void *clientd) + { + rcv_state_t *rcv_state; + + rcv_state = (rcv_state_t *)malloc(sizeof(rcv_state_t)); + + rcv_state->reassem_buf_size = 8192; + rcv_state->reassem_buf = (char *)malloc(rcv_state->reassem_buf_size); + rcv_state->collecting = 0; + rcv_state->num_bad_frags = 0; + + return rcv_state; + } /* per_src_clientd_create */ + + + /* Callback when a receiver delivery controller for an ex-source is deleted. */ + int per_src_clientd_delete(const char *source_name, void *clientd, + void *src_clientd) + { + rcv_state_t *rcv_state = (rcv_state_t *)src_clientd; + + if (rcv_state->collecting) { + /* Error, state is collecting. */ + printf("Collect error, incomplete fragmented message, offset=%ld, message_len=%ld\n", rcv_state->offset, rcv_state->message_len); + } + if (rcv_state->num_bad_frags > 0) { + printf("Number of bad fragments=%ld\n", rcv_state->num_bad_frags); + } + + free(rcv_state->reassem_buf); + free(rcv_state); + + return 0; + } /* per_src_clientd_delete */ + + + /* Create a SmartSource, and init associated state. + */ + void smart_source_init(smart_source_t *smart_source, lbm_context_t *ctx, + char *topic) + { + lbm_topic_t *lbm_topic = NULL; + lbm_src_topic_attr_t *src_tattr = NULL; + int prop_count; + size_t opt_len; + int err; + + smart_source->ctx = ctx; + + err = lbm_src_topic_attr_create(&src_tattr); + LBM_ERR(err); + + /* Make sure user's config allows at least 1 msg property. */ + opt_len = sizeof(prop_count); + err = lbm_src_topic_attr_getopt(src_tattr, + "smart_src_message_property_int_count", &prop_count, &opt_len); + LBM_ERR(err); + if (prop_count == 0) { + /* No props configured, add one. */ + prop_count = 1; + err = lbm_src_topic_attr_setopt(src_tattr, + "smart_src_message_property_int_count", &prop_count, &opt_len); + LBM_ERR(err); + } + + /* Find out the user's config for max message length. */ + opt_len = sizeof(smart_source->max_msg_len); + err = lbm_src_topic_attr_getopt(src_tattr, + "smart_src_max_message_length", &(smart_source->max_msg_len), &opt_len); + LBM_ERR(err); + + err = lbm_src_topic_alloc(&lbm_topic, ctx, topic, src_tattr); + LBM_ERR(err); + + err = lbm_ssrc_create(&(smart_source->ssrc), ctx, lbm_topic, NULL, NULL, + NULL); + LBM_ERR(err); + + err = lbm_src_topic_attr_delete(src_tattr); + LBM_ERR(err); + + err = lbm_ssrc_buff_get(smart_source->ssrc, &smart_source->msgbuf_plain, 0); + LBM_ERR(err); + err = lbm_ssrc_buff_get(smart_source->ssrc, &smart_source->msgbuf_props, 0); + LBM_ERR(err); + + /* Set up message property. */ + smart_source->info_prop.flags = LBM_SSRC_SEND_EX_FLAG_PROPERTIES; + smart_source->info_prop.mprop_int_cnt = 1; + smart_source->info_prop.mprop_int_vals = smart_source->int_value_array; + smart_source->info_prop.mprop_int_keys = &smart_source->key_ptr_array[0]; + smart_source->key_ptr_array[0] = smart_source->remain_key; + strncpy(smart_source->remain_key, "Remain", sizeof(smart_source->remain_key)); + } /* smart_source_init */ + + + /* Send a message, fragmenting it if necessary. + */ + void smart_source_send(smart_source_t *smart_source, char *buf, size_t len, + int flags) + { + int err; + + if (len <= smart_source->max_msg_len) { + /* Message fits in one buffer, send it. */ + memcpy(smart_source->msgbuf_plain, buf, len); + err = lbm_ssrc_send_ex(smart_source->ssrc, smart_source->msgbuf_plain, + len, 0, NULL); + LBM_ERR(err); + } + + else { /* Message does not fit in one buffer */ + int offset; + int remaining; + int this_len; + + /* Fragment message. */ + remaining = len; + offset = 0; + + this_len = smart_source->max_msg_len; + remaining -= this_len; + /* Indicate first fragment with negative remainer. */ + smart_source->int_value_array[0] = - remaining; + memcpy(smart_source->msgbuf_props, &buf[offset], this_len); + err = lbm_ssrc_send_ex(smart_source->ssrc, smart_source->msgbuf_props, + this_len, 0, &(smart_source->info_prop)); + LBM_ERR(err); + offset += this_len; + + /* From now on, need to update the properties. */ + smart_source->info_prop.flags |= LBM_SSRC_SEND_EX_FLAG_UPDATE_PROPERTY_VALUES; + + /* Send rest of fragments. */ + while (remaining > 0) { + if (remaining > smart_source->max_msg_len) { + this_len = smart_source->max_msg_len; + } + else { + this_len = remaining; + } + remaining -= this_len; + smart_source->int_value_array[0] = remaining; + memcpy(smart_source->msgbuf_props, &buf[offset], this_len); + err = lbm_ssrc_send_ex(smart_source->ssrc, smart_source->msgbuf_props, + this_len, 0, &(smart_source->info_prop)); + + offset += this_len; + } /* while */ + } + } /* smart_source_send */ + + + int main(int argc, char **argv) { + lbm_context_t *rctx = NULL; + lbm_context_t *sctx = NULL; + lbm_rcv_topic_attr_t *rcv_attr = NULL; + lbm_rcv_src_notification_func_t src_notif_func; /* config option */ + lbm_topic_t *lbm_topic = NULL; + lbm_rcv_t *rcv; + smart_source_t smart_source; + char *send_buff; + int err; + + err = lbm_config("test.cfg"); + LBM_ERR(err); + + /* Create a pair of contexts, one for publisher, the other for subscriber. + */ + + err = lbm_context_create(&rctx, NULL, NULL, NULL); + LBM_ERR(err); + + err = lbm_context_create(&sctx, NULL, NULL, NULL); + LBM_ERR(err); + + + /* Create receiver. + */ + + err = lbm_rcv_topic_attr_create(&rcv_attr); + LBM_ERR(err); + + src_notif_func.create_func = per_src_clientd_create; + src_notif_func.delete_func = per_src_clientd_delete; + src_notif_func.clientd = NULL; /* Or your own state structure. */ + err = lbm_rcv_topic_attr_setopt(rcv_attr, "source_notification_function", + &src_notif_func, sizeof(src_notif_func)); + LBM_ERR(err); + + err = lbm_rcv_topic_lookup(&lbm_topic, rctx, "topic_1", rcv_attr); + LBM_ERR(err); + + err = lbm_rcv_create(&rcv, rctx, lbm_topic, msg_rcv_cb, NULL, NULL); + LBM_ERR(err); + + + /* Create source. + */ + smart_source_init(&smart_source, sctx, "topic_1"); + + send_buff = (char *)malloc(70000); /* Bigger than 64k, for fun. */ + + SLEEP(1); /* For topic res. */ + + + /* Send messages. + */ + + send_buff[0] = 1; send_buff[999] = 1; + smart_source_send(&smart_source, send_buff, 1000, LBM_MSG_FLUSH); + SLEEP(1); + + send_buff[0] = 2; send_buff[4999] = 2; + smart_source_send(&smart_source, send_buff, 5000, LBM_MSG_FLUSH); + SLEEP(1); + + send_buff[0] = 3; send_buff[19999] = 3; + smart_source_send(&smart_source, send_buff, 20000, LBM_MSG_FLUSH); + SLEEP(1); + + send_buff[0] = 4; send_buff[99] = 4; + smart_source_send(&smart_source, send_buff, 100, LBM_MSG_FLUSH); + SLEEP(1); + + send_buff[0] = 5; send_buff[69999] = 5; + smart_source_send(&smart_source, send_buff, 70000, LBM_MSG_FLUSH); + SLEEP(1); + + + /* Shut down. + */ + + free(send_buff); + + (void)lbm_ssrc_delete(smart_source.ssrc); + (void)lbm_rcv_delete(rcv); + + (void)lbm_context_delete(rctx); + (void)lbm_context_delete(sctx); + + return 0; + } /* main */ +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      diff --git a/ss_frag/intro.sldoc b/ss_frag/intro.sldoc new file mode 100644 index 0000000..e8cae58 --- /dev/null +++ b/ss_frag/intro.sldoc @@ -0,0 +1,56 @@ +Example index +

      Smart Source Message Fragmentation

      +

      Ultra Messaging has a feature called + Smart Sources + which provides lower average latency and much lower latency + variation (jitter) than traditional UM sources. + Smart Sources are able to deliver these benefits by trading off reduced + flexibility for simplicity, especially simplicity in memory usage.

      +

      One area of reduced flexibility is related to message sizes. + To avoid dynamic memory allocation/deallocation, Smart Sources require + the user to configure the maximum expected message size. + Also, Smart Sources do not support fragmentation and reassembly of + messages larger than the maximum datagram size. + An application message must fit in a single datagram. + Finally, users of kernel bypass TCP/IP stacks (like Solarflare's Onload) + pay a heavy penalty if IP fragmentation is performed by the kernel. + These users typically want to keep each datagram at or below the + NIC's MTU size (typically 1500 bytes).

      +

      However, many applications have a fairly small average message size, + but occasionally need to send messages that are much larger. + If that worst-case large message size is larger than an MTU, + it cannot be efficiently sent using Onload or other kernel bypass stacks.

      +

      Also, even if IP fragmentation is not a problem, + a Smart Sources pre-allocates its retransmission buffers based on the + worst-case message size. + For applications that normally send small messages but occasionally + need to send very large ones, + this can lead to a significant memory footprint.

      +

      One solution to these problems is for an application to configure Smart + Source for small messages, and perform message fragmentation and + reassembly at the application level. + This example program does just that.

      +

      High-Level Design

      +

      An integer message property with key name "Remain" is used to manage + message fragmentation and reassembly. + Small messages may be sent without a property. + Messages which exceed a configured threshold will be sent in "chunks", + with a message property providing the information needed by the + receiver to reassemble the chunks.

      +

      When the application wants to send a message larger than + [smart_src_max_message_length (source)](https://ultramessaging.github.io/currdoc/doc/Config/grpsmartsource.html#smartsrcmaxmessagelengthsource), + the first fragment is sent with the "Remain" property is a negative + number representing the number of bytes that still need to be sent + (not counting the content of that first message). + Each subsequent message fragment sent has the "Remain" property as + a positive number of the number of bytes remaining + after that message.

      +

      For example, if smart_src_max_message_length is set to 1400 and a + 5000 byte message is sent, 4 UM messages will be sent. + Here are the message lengths and values for the "Remain" property:

      +
        +
      1. length=1400, Remain=-3600
      2. +
      3. length=1400, Remain=2200
      4. +
      5. length=1400, Remain=800
      6. +
      7. length=800, Remain=0
      8. +

        When the receiver sees Remain=0, it can deliver the reassembled message.

        From 6e2bd8721115e749eb62d749a9f801fd321da434 Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Fri, 2 Nov 2018 16:00:13 -0400 Subject: [PATCH 09/26] Expanded it --- ss_frag/c/ss_frag.c | 34 +++---- ss_frag/c/ss_frag.sldoc | 42 ++++++++- ss_frag/c/ss_frag.sldoc.html | 138 ++++++++++++++++++++++++++- ss_frag/c/ss_frag_c.slsrc | 52 ++++++---- ss_frag/c/ss_frag_c.slsrc.html | 168 ++++++++++++++++----------------- 5 files changed, 308 insertions(+), 126 deletions(-) diff --git a/ss_frag/c/ss_frag.c b/ss_frag/c/ss_frag.c index 06d88ad..a58ce34 100644 --- a/ss_frag/c/ss_frag.c +++ b/ss_frag/c/ss_frag.c @@ -103,7 +103,7 @@ void handle_msg_frag(lbm_msg_t *msg, rcv_state_t *rcv_state, if (remaining >= 0 && (rcv_state->message_len == (rcv_state->offset + msg->len + remaining))) { - /* Non-NULL reassem buffer, continue collecting. */ + /* Collect the fragment. */ memcpy(&rcv_state->reassem_buf[rcv_state->offset], msg->data, msg->len); rcv_state->offset += msg->len; @@ -164,7 +164,22 @@ int msg_rcv_cb(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) switch (msg->type) { case LBM_MSG_DATA: - if (msg->properties != NULL) { + if (msg->properties == NULL) { + /* Fast path (not part of a fragmented messqge). */ + if (rcv_state->collecting) { + /* Error, non-frag, but state is collecting (should never happen). */ + printf("Collect error non-frag, offset=%ld, len=%lu, message_len=%ld\n", rcv_state->offset, msg->len, rcv_state->message_len); + rcv_state->collecting = 0; + rcv_state->num_bad_frags ++; + } + + /* Deliver data message. */ + printf("PROCESS message, buf[0]=%d, buf[%ld]=%d\n", + msg->data[0], + msg->len - 1, + msg->data[msg->len - 1]); + } + else { /* msg properties */ lbm_int32_t remaining; size_t prop_size = sizeof(remaining); int prop_type = LBM_MSG_PROPERTY_INT; @@ -179,21 +194,6 @@ int msg_rcv_cb(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) printf("handle messages with other properties.\n"); } } /* msg properties not null */ - else { /* msg properties == NULL */ - if (rcv_state->collecting) { - /* Error, non-frag, but state is collecting (should never happen). */ - printf("Collect error non-frag, offset=%ld, len=%lu, message_len=%ld\n", rcv_state->offset, msg->len, rcv_state->message_len); - /* Stop collecting after error. */ - rcv_state->collecting = 0; - rcv_state->num_bad_frags ++; - } - - /* Deliver data message. */ - printf("PROCESS message, buf[0]=%d, buf[%ld]=%d\n", - msg->data[0], - msg->len - 1, - msg->data[msg->len - 1]); - } break; case LBM_MSG_UNRECOVERABLE_LOSS: diff --git a/ss_frag/c/ss_frag.sldoc b/ss_frag/c/ss_frag.sldoc index b1dda32..c087067 100644 --- a/ss_frag/c/ss_frag.sldoc +++ b/ss_frag/c/ss_frag.sldoc @@ -10,7 +10,6 @@
      9. =semlit,srcfile,ss_frag_c.slsrc,ss_frag.c= - (right-click and save as "ss_frag.c") main program.
      10. -

        Program explanation: ss_frag.c

        The ss_frag.c file contains:

          @@ -18,9 +17,9 @@
        • Receive-side code (reassembles messages),
        • Simple demonstration code.
        -

        Source-Side Code

        +

        Source-Side Code

        At the heart of the source-side code is the function - smart_source_send(): + smart_source_send():

        =semlit,insert,send_funct=

        CLICK ON A LINE NUBMER TO SEE THE CODE ON THE RIGHT IN CONTEXT!

        This function first checks to see if the application message is @@ -34,7 +33,7 @@

        Subsequent fragments are sent, chunk at a time, with a positive "Remain" property.

        =semlit,insert,send_rest= -

        Send Buffers

        +

        Send Buffers

        For efficiency and simplicity, two Smart Source send buffers are used to send messages: msgbuf_plain for small messages with no properties, and msgbuf_props for large fragmented @@ -54,5 +53,40 @@

        There is also a sanity check to make sure the user configured a message property.

        =semlit,insert,send_conf_prop= +

        Receiver-Side Code

        +

        At the heart of the receiver-side code is the receiver application + callback function smart_source_send():

        + =semlit,insert,rcv_cb= +

        If there is no message property with the message, it is a small + (non-fragmented) message, and can be delivered. + It does a sanity check first to make sure there isn't a fragmented + message in-progress.

        + =semlit,insert,rcv_no_prop= +

        Otherwise, there is a property, which we make sure is "Remain". + =semlit,insert,rcv_tst_prop= +

        Once the message is known to be a fragment, it is passed to the + function handle_msg_frag() for reassembly. + This function has two states it can be in: collecting (in the middle + of a fragmented message), or not collecting (waiting for a negative + "Remain" property to indicate the start of a fragmented message).

        +

        If it is collecting, the newly-received message is validated to make + sure it is the expected next fragment.

        + =semlit,insert,rcv_chk_frag= +

        Once validated, the message content is collected. + If this is the last fragment in the message ("Remain"==0) then the + reassembled message is delivered.

        + =semlit,insert,rcv_collect= +

        First Fragment Processing

        +

        If handle_msg_frag() is called and the receiver state is + not collecting, then the fragment should be the first + fragment of a large message ("Remain" negative).

        + =semlit,insert,rcv_first_frag= +

        Start the collection state.

        + =semlit,insert,rcv_start_collect= +

        To keep the algorithm general, if the fragmented message is larger + than the currently-allocated reassembly buffer, expand it.

        + =semlit,insert,rcv_expand= +

        Finally, collect the first fragment's data.

        + =semlit,insert,rcv_collect_first= diff --git a/ss_frag/c/ss_frag.sldoc.html b/ss_frag/c/ss_frag.sldoc.html index c078ee8..c2bb432 100644 --- a/ss_frag/c/ss_frag.sldoc.html +++ b/ss_frag/c/ss_frag.sldoc.html @@ -66,7 +66,6 @@

        High-Level Design

      11. ss_frag.c - (right-click and save as "ss_frag.c") main program.
      12. -

        Program explanation: ss_frag.c

        The ss_frag.c file contains:

          @@ -74,9 +73,9 @@

          Program explanation: ss_frag.c

        • Receive-side code (reassembles messages),
        • Simple demonstration code.
        -

        Source-Side Code

        +

        Source-Side Code

        At the heart of the source-side code is the function - smart_source_send(): + smart_source_send():

         00312  /* Send a message, fragmenting it if necessary.
        @@ -143,7 +142,7 @@ 

        Source-Side Code

        -

        Send Buffers

        +

        Send Buffers

        For efficiency and simplicity, two Smart Source send buffers are used to send messages: msgbuf_plain for small messages with no properties, and msgbuf_props for large fragmented @@ -213,6 +212,137 @@

        Send Buffers

    +

    Receiver-Side Code

    +

    At the heart of the receiver-side code is the receiver application + callback function smart_source_send():

    + +
    +00158  /* UM receiver callback.
    +00159   */
    +00160  int msg_rcv_cb(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd)
    +00161  {
    +
    + + +

    If there is no message property with the message, it is a small + (non-fragmented) message, and can be delivered. + It does a sanity check first to make sure there isn't a fragmented + message in-progress.

    + +
    +00167        if (msg->properties == NULL) {
    +00168          /* Fast path (not part of a fragmented messqge). */
    +00169          if (rcv_state->collecting) {
    +00170            /* Error, non-frag, but state is collecting (should never happen). */
    +00171            printf("Collect error non-frag, offset=%ld, len=%lu, message_len=%ld\n", rcv_state->offset, msg->len, rcv_state->message_len);
    +00172            rcv_state->collecting = 0;
    +00173            rcv_state->num_bad_frags ++;
    +00174          }
    +00175  
    +00176          /* Deliver data message. */
    +00177          printf("PROCESS message, buf[0]=%d, buf[%ld]=%d\n",
    +00178            msg->data[0],
    +00179            msg->len - 1,
    +00180            msg->data[msg->len - 1]);
    +00181        }
    +
    + + +

    Otherwise, there is a property, which we make sure is "Remain". + +

    +00187          /* Found property, is it for fragmentation? */
    +00188          err = lbm_msg_properties_get(msg->properties, "Remain",
    +00189            &remaining, &prop_type, &prop_size);
    +00190          if (err == LBM_OK) {
    +00191            handle_msg_frag(msg, rcv_state, remaining);
    +00192          }
    +
    + + +

    Once the message is known to be a fragment, it is passed to the + function handle_msg_frag() for reassembly. + This function has two states it can be in: collecting (in the middle + of a fragmented message), or not collecting (waiting for a negative + "Remain" property to indicate the start of a fragmented message).

    +

    If it is collecting, the newly-received message is validated to make + sure it is the expected next fragment.

    + +
    +00101    if (rcv_state->collecting) {
    +00102      /* Make sure the fragment is OK. */
    +00103      if (remaining >= 0 &&
    +00104        (rcv_state->message_len == (rcv_state->offset + msg->len + remaining)))
    +00105      {
    +
    + + +

    Once validated, the message content is collected. + If this is the last fragment in the message ("Remain"==0) then the + reassembled message is delivered.

    + +
    +00106        /* Collect the fragment. */
    +00107        memcpy(&rcv_state->reassem_buf[rcv_state->offset], msg->data,
    +00108          msg->len);
    +00109        rcv_state->offset += msg->len;
    +00110  
    +00111        if (remaining == 0) {  /* No more, deliver the data. */
    +00112          printf("PROCESS message, buf[0]=%d, buf[%ld]=%d\n",
    +00113            rcv_state->reassem_buf[0],
    +00114            rcv_state->message_len - 1,
    +00115            rcv_state->reassem_buf[rcv_state->message_len - 1]);
    +00116  
    +00117          /* No longer collecting. */
    +00118          rcv_state->collecting = 0;
    +00119        }
    +
    + + +

    First Fragment Processing

    +

    If handle_msg_frag() is called and the receiver state is + not collecting, then the fragment should be the first + fragment of a large message ("Remain" negative).

    + +
    +00131    else {  /* not collecting */
    +00132      /* Not collecting a fragmented message, is this message first frag? */
    +00133      if (remaining < 0) {
    +00134        /* First fragment. */
    +
    + + +

    Start the collection state.

    + +
    +00135        rcv_state->collecting = 1;
    +00136        rcv_state->offset = 0;
    +00137        rcv_state->message_len = msg->len + (- remaining);
    +
    + + +

    To keep the algorithm general, if the fragmented message is larger + than the currently-allocated reassembly buffer, expand it.

    + +
    +00138        /* Expand buffer if necessary. */
    +00139        if (rcv_state->message_len > rcv_state->reassem_buf_size) {
    +00140          rcv_state->reassem_buf_size = rcv_state->message_len;
    +00141          rcv_state->reassem_buf = (char *)realloc(rcv_state->reassem_buf,
    +00142            rcv_state->reassem_buf_size);
    +00143        }
    +
    + + +

    Finally, collect the first fragment's data.

    + +
    +00145        /* Collect data. */
    +00146        memcpy(&rcv_state->reassem_buf[rcv_state->offset], msg->data, msg->len);
    +00147        rcv_state->offset += msg->len;
    +
    + + diff --git a/ss_frag/c/ss_frag_c.slsrc b/ss_frag/c/ss_frag_c.slsrc index a2656b6..f4889cc 100644 --- a/ss_frag/c/ss_frag_c.slsrc +++ b/ss_frag/c/ss_frag_c.slsrc @@ -100,12 +100,15 @@ void handle_msg_frag(lbm_msg_t *msg, rcv_state_t *rcv_state, { size_t tot_len; +/* =semlit,block,rcv_chk_frag=*/ if (rcv_state->collecting) { /* Make sure the fragment is OK. */ if (remaining >= 0 && (rcv_state->message_len == (rcv_state->offset + msg->len + remaining))) { - /* Non-NULL reassem buffer, continue collecting. */ +/* =semlit,endblock,rcv_chk_frag=*/ +/* =semlit,block,rcv_collect=*/ + /* Collect the fragment. */ memcpy(&rcv_state->reassem_buf[rcv_state->offset], msg->data, msg->len); rcv_state->offset += msg->len; @@ -119,6 +122,7 @@ void handle_msg_frag(lbm_msg_t *msg, rcv_state_t *rcv_state, /* No longer collecting. */ rcv_state->collecting = 0; } +/* =semlit,endblock,rcv_collect=*/ } /* if fragment OK */ else { /* fragment is not ok. */ /* Bad fragment (should never happen). */ @@ -130,23 +134,31 @@ void handle_msg_frag(lbm_msg_t *msg, rcv_state_t *rcv_state, } } +/* =semlit,block,rcv_first_frag=*/ else { /* not collecting */ /* Not collecting a fragmented message, is this message first frag? */ if (remaining < 0) { /* First fragment. */ +/* =semlit,endblock,rcv_first_frag=*/ +/* =semlit,block,rcv_start_collect=*/ rcv_state->collecting = 1; rcv_state->offset = 0; rcv_state->message_len = msg->len + (- remaining); +/* =semlit,endblock,rcv_start_collect=*/ +/* =semlit,block,rcv_expand=*/ /* Expand buffer if necessary. */ if (rcv_state->message_len > rcv_state->reassem_buf_size) { rcv_state->reassem_buf_size = rcv_state->message_len; rcv_state->reassem_buf = (char *)realloc(rcv_state->reassem_buf, rcv_state->reassem_buf_size); } +/* =semlit,endblock,rcv_expand=*/ +/* =semlit,block,rcv_collect_first=*/ /* Collect data. */ memcpy(&rcv_state->reassem_buf[rcv_state->offset], msg->data, msg->len); rcv_state->offset += msg->len; +/* =semlit,endblock,rcv_collect_first=*/ } /* remaining < 0 */ else { /* Found middle frag without a first frag; discard. */ /* Probably joined stream in middle of message. */ @@ -157,45 +169,51 @@ void handle_msg_frag(lbm_msg_t *msg, rcv_state_t *rcv_state, } /* handle_msg_frag */ +/* =semlit,block,rcv_cb=*/ /* UM receiver callback. */ int msg_rcv_cb(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { +/* =semlit,endblock,rcv_cb=*/ rcv_state_t *rcv_state = (rcv_state_t *)msg->source_clientd; int err; switch (msg->type) { case LBM_MSG_DATA: - if (msg->properties != NULL) { +/* =semlit,block,rcv_no_prop=*/ + if (msg->properties == NULL) { + /* Fast path (not part of a fragmented messqge). */ + if (rcv_state->collecting) { + /* Error, non-frag, but state is collecting (should never happen). */ + printf("Collect error non-frag, offset=%ld, len=%lu, message_len=%ld\n", rcv_state->offset, msg->len, rcv_state->message_len); + rcv_state->collecting = 0; + rcv_state->num_bad_frags ++; + } + + /* Deliver data message. */ + printf("PROCESS message, buf[0]=%d, buf[%ld]=%d\n", + msg->data[0], + msg->len - 1, + msg->data[msg->len - 1]); + } +/* =semlit,endblock,rcv_no_prop=*/ + else { /* msg properties */ lbm_int32_t remaining; size_t prop_size = sizeof(remaining); int prop_type = LBM_MSG_PROPERTY_INT; +/* =semlit,block,rcv_tst_prop=*/ /* Found property, is it for fragmentation? */ err = lbm_msg_properties_get(msg->properties, "Remain", &remaining, &prop_type, &prop_size); if (err == LBM_OK) { handle_msg_frag(msg, rcv_state, remaining); } +/* =semlit,endblock,rcv_tst_prop=*/ else { printf("handle messages with other properties.\n"); } } /* msg properties not null */ - else { /* msg properties == NULL */ - if (rcv_state->collecting) { - /* Error, non-frag, but state is collecting (should never happen). */ - printf("Collect error non-frag, offset=%ld, len=%lu, message_len=%ld\n", rcv_state->offset, msg->len, rcv_state->message_len); - /* Stop collecting after error. */ - rcv_state->collecting = 0; - rcv_state->num_bad_frags ++; - } - - /* Deliver data message. */ - printf("PROCESS message, buf[0]=%d, buf[%ld]=%d\n", - msg->data[0], - msg->len - 1, - msg->data[msg->len - 1]); - } break; case LBM_MSG_UNRECOVERABLE_LOSS: diff --git a/ss_frag/c/ss_frag_c.slsrc.html b/ss_frag/c/ss_frag_c.slsrc.html index 3912ecc..775355b 100644 --- a/ss_frag/c/ss_frag_c.slsrc.html +++ b/ss_frag/c/ss_frag_c.slsrc.html @@ -116,25 +116,25 @@ 00098 00099 00100 -00101 -00102 -00103 -00104 -00105 -00106 -00107 -00108 -00109 -00110 -00111 -00112 -00113 -00114 -00115 -00116 -00117 -00118 -00119 +00101 +00102 +00103 +00104 +00105 +00106 +00107 +00108 +00109 +00110 +00111 +00112 +00113 +00114 +00115 +00116 +00117 +00118 +00119 00120 00121 00122 @@ -146,23 +146,23 @@ 00128 00129 00130 -00131 -00132 -00133 -00134 -00135 -00136 -00137 -00138 -00139 -00140 -00141 -00142 -00143 +00131 +00132 +00133 +00134 +00135 +00136 +00137 +00138 +00139 +00140 +00141 +00142 +00143 00144 -00145 -00146 -00147 +00145 +00146 +00147 00148 00149 00150 @@ -173,41 +173,41 @@ 00155 00156 00157 -00158 -00159 -00160 -00161 +00158 +00159 +00160 +00161 00162 00163 00164 00165 00166 -00167 -00168 -00169 -00170 -00171 -00172 -00173 -00174 -00175 -00176 -00177 -00178 -00179 -00180 -00181 +00167 +00168 +00169 +00170 +00171 +00172 +00173 +00174 +00175 +00176 +00177 +00178 +00179 +00180 +00181 00182 00183 00184 00185 00186 -00187 -00188 -00189 -00190 -00191 -00192 +00187 +00188 +00189 +00190 +00191 +00192 00193 00194 00195 @@ -574,12 +574,12 @@ { size_t tot_len; - if (rcv_state->collecting) { + if (rcv_state->collecting) { /* Make sure the fragment is OK. */ if (remaining >= 0 && (rcv_state->message_len == (rcv_state->offset + msg->len + remaining))) { - /* Non-NULL reassem buffer, continue collecting. */ + /* Collect the fragment. */ memcpy(&rcv_state->reassem_buf[rcv_state->offset], msg->data, msg->len); rcv_state->offset += msg->len; @@ -604,21 +604,21 @@ } } - else { /* not collecting */ + else { /* not collecting */ /* Not collecting a fragmented message, is this message first frag? */ if (remaining < 0) { /* First fragment. */ - rcv_state->collecting = 1; + rcv_state->collecting = 1; rcv_state->offset = 0; rcv_state->message_len = msg->len + (- remaining); - /* Expand buffer if necessary. */ + /* Expand buffer if necessary. */ if (rcv_state->message_len > rcv_state->reassem_buf_size) { rcv_state->reassem_buf_size = rcv_state->message_len; rcv_state->reassem_buf = (char *)realloc(rcv_state->reassem_buf, rcv_state->reassem_buf_size); } - /* Collect data. */ + /* Collect data. */ memcpy(&rcv_state->reassem_buf[rcv_state->offset], msg->data, msg->len); rcv_state->offset += msg->len; } /* remaining < 0 */ @@ -631,7 +631,7 @@ } /* handle_msg_frag */ - /* UM receiver callback. + /* UM receiver callback. */ int msg_rcv_cb(lbm_rcv_t *rcv, lbm_msg_t *msg, void *clientd) { @@ -640,26 +640,11 @@ switch (msg->type) { case LBM_MSG_DATA: - if (msg->properties != NULL) { - lbm_int32_t remaining; - size_t prop_size = sizeof(remaining); - int prop_type = LBM_MSG_PROPERTY_INT; - - /* Found property, is it for fragmentation? */ - err = lbm_msg_properties_get(msg->properties, "Remain", - &remaining, &prop_type, &prop_size); - if (err == LBM_OK) { - handle_msg_frag(msg, rcv_state, remaining); - } - else { - printf("handle messages with other properties.\n"); - } - } /* msg properties not null */ - else { /* msg properties == NULL */ + if (msg->properties == NULL) { + /* Fast path (not part of a fragmented messqge). */ if (rcv_state->collecting) { /* Error, non-frag, but state is collecting (should never happen). */ printf("Collect error non-frag, offset=%ld, len=%lu, message_len=%ld\n", rcv_state->offset, msg->len, rcv_state->message_len); - /* Stop collecting after error. */ rcv_state->collecting = 0; rcv_state->num_bad_frags ++; } @@ -670,6 +655,21 @@ msg->len - 1, msg->data[msg->len - 1]); } + else { /* msg properties */ + lbm_int32_t remaining; + size_t prop_size = sizeof(remaining); + int prop_type = LBM_MSG_PROPERTY_INT; + + /* Found property, is it for fragmentation? */ + err = lbm_msg_properties_get(msg->properties, "Remain", + &remaining, &prop_type, &prop_size); + if (err == LBM_OK) { + handle_msg_frag(msg, rcv_state, remaining); + } + else { + printf("handle messages with other properties.\n"); + } + } /* msg properties not null */ break; case LBM_MSG_UNRECOVERABLE_LOSS: From 378e1febbfc64a40a7854bc09ec0621e54db7e1e Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Mon, 5 Nov 2018 10:35:55 -0500 Subject: [PATCH 10/26] Updates Added a bit more instruction. Removed some cruft. --- README.md | 6 ++- x | 23 --------- x.c | 145 ------------------------------------------------------ x.sed | 1 - x.x | 145 ------------------------------------------------------ 5 files changed, 5 insertions(+), 315 deletions(-) delete mode 100644 x delete mode 100644 x.c delete mode 100644 x.sed delete mode 100644 x.x diff --git a/README.md b/README.md index 27fb602..839a565 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,14 @@ Go to https://ultramessaging.github.io/UMExamples/ so see them rendered and user-friendly. -## Creating Examples +## Semlit The examples use a documentation toolset called "semlit". Go to https://github.com/fordsfords/semlit to get it. +Place ``semlit.sh`` and ``semlit.pl`` into your PATH. + + +## Creating Examples Here is how I created the "ss_frag" example: diff --git a/x b/x deleted file mode 100644 index b0d5322..0000000 --- a/x +++ /dev/null @@ -1,23 +0,0 @@ -cancelling_timers/c/*_c.slsrc -check_flight_size_ewouldblock/c/*_c.slsrc -clean_shutdown/c/*_c.slsrc -dump_attributes/c/*_c.slsrc -event_q_rcv/c/*_c.slsrc -event_q_src/c/*_c.slsrc -handle_burst/c/*_c.slsrc -late_join/c/*_c.slsrc -load_config/c/*_c.slsrc -logging_callback/c/*_c.slsrc -minsrc/c/*_c.slsrc -multi_context/c/*_c.slsrc -no_source_notify/c/*_c.slsrc -quorum_state/c/*_c.slsrc -request_response/c/*_c.slsrc -schedule_timers/c/*_c.slsrc -seq_number_callback/c/*_c.slsrc -sequential_mode/c/*_c.slsrc -setting_attributes/c/*_c.slsrc -source_notify_callbacks/c/*_c.slsrc -src_rsp/c/*_c.slsrc -ump_receiver_callbacks/c/*_c.slsrc -ump_src_failover/c/*_c.slsrc diff --git a/x.c b/x.c deleted file mode 100644 index 98bfb2f..0000000 --- a/x.c +++ /dev/null @@ -1,145 +0,0 @@ -/* cancelling_timers.c - see http://ultramessaging.github.io/UMExamples/cancelling_timers/c/index.html - * - * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. - * Permission is granted to licensees to use - * or alter this software for any purpose, including commercial applications, - * according to the terms laid out in the Software License Agreement. - * - * This source code example is provided by Informatica for educational - * and evaluation purposes only. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES - * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF - * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR - * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE - * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE - * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR - * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE - * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF - * THE LIKELIHOOD OF SUCH DAMAGES. - */ - -/* =semlit,block,includes=*/ -#include - -#if defined(_MSC_VER) -/* Windows-only includes */ -#include -#define SLEEP(s) Sleep((s)*1000) -#else -/* Unix-only includes */ -#include -#include -#define SLEEP(s) sleep(s) -#endif - -#include -/* =semlit,endblock,includes=*/ - -/* =semlit,block,error_check=*/ -/* Example error checking macro. Include after each UM call. */ -#define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ -} while (0) -/* =semlit,endblock,error_check=*/ - -/* =semlit,block,struct_app_timer=*/ -typedef enum {PENDING, FIRED, CANCELED} state_type_e; -typedef struct app_timer_s { - int id; - state_type_e state; - int sync; -} app_timer_s; -/* =semlit,endblock,struct_app_timer=*/ - -/* =semlit,block,int_wait=*/ -int wait = 1; -/* =semlit,endblock,int_wait=*/ - -/* Timer callback function */ -/* =semlit,block,timer_cb=*/ -int sample_timer_handler(lbm_context_t *ctx, const void *clientd) -{ - struct app_timer_s *my_timer = (struct app_timer_s *)clientd; - if (my_timer->state != PENDING) { - fprintf(stderr, "ERROR: Timer executed and should have been cancelled\n"); - exit(1); - } - - fprintf(stderr, "ERROR: This timer should have been cancelled by now\n"); - - return 0; -} -/* =semlit,endblock,timer_cb=*/ - -/* =semlit,block,cancel_cb=*/ -int cancel_timer_cb(lbm_context_t *ctx, const void *clientd) -{ - struct app_timer_s *my_timer = (struct app_timer_s *)clientd; - if (my_timer->state == PENDING) { - lbm_cancel_timer(ctx, my_timer->id, NULL); - my_timer->state = CANCELED; - } - my_timer->sync = 0; - - return 0; -} -/* =semlit,endblock,cancel_cb=*/ - -int main(int argc, char **argv) -{ - lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - int err; /* Used for checking API return codes */ - app_timer_s my_timer; - - my_timer.sync = 0; - - /* Initialize context atrributes and create context */ - /* =semlit,block,ctx_create=*/ - err = lbm_context_attr_create(&cattr); - EX_LBM_CHK(err); - - err = lbm_context_create(&ctx, cattr, NULL, NULL); - EX_LBM_CHK(err); - /* =semlit,endblock,ctx_create=*/ - - /* =semlit,block,schedule=*/ - my_timer.state = PENDING; - if ((my_timer.id = lbm_schedule_timer(ctx, sample_timer_handler, &my_timer, NULL, 10000)) == -1) { - fprintf(stderr, "%s:%d, lbm error: '%s'\n", __FILE__, __LINE__, lbm_errmsg()); - exit(1); - } - /* =semlit,endblock,schedule=*/ - - /* Now wait for callback to end the wait and close the application */ - SLEEP(1); - - /* =semlit,block,cancel= */ - if (my_timer.state == PENDING) { - lbm_schedule_timer(ctx, cancel_timer_cb, &my_timer, NULL, 0); - /* timer might still fire at this point. */ - my_timer.sync = 1; - } - /* =semlit,endblock,cancel= */ - - /* =semlit,block,wait=*/ - while (my_timer.sync) - SLEEP(1); - /* =semlit,endblock,wait=*/ - - /* Clean up */ - err = lbm_context_delete(ctx); - EX_LBM_CHK(err); - -#if defined(_MSC_VER) - /* Windows-specific cleanup overhead */ - WSACleanup(); -#endif - return 0; -} - diff --git a/x.sed b/x.sed deleted file mode 100644 index 3eaf361..0000000 --- a/x.sed +++ /dev/null @@ -1 +0,0 @@ -1,1s|^/\* \([^.]*\).c *$|/\* \1.c - see http://ultramessaging.github.io/UMExamples/\1/c/index.html| diff --git a/x.x b/x.x deleted file mode 100644 index 70c01e0..0000000 --- a/x.x +++ /dev/null @@ -1,145 +0,0 @@ -/* cancelling_timers.c - * - * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. - * Permission is granted to licensees to use - * or alter this software for any purpose, including commercial applications, - * according to the terms laid out in the Software License Agreement. - * - * This source code example is provided by Informatica for educational - * and evaluation purposes only. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INFORMATICA DISCLAIMS ALL WARRANTIES - * EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF - * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR - * PURPOSE. INFORMATICA DOES NOT WARRANT THAT USE OF THE SOFTWARE WILL BE - * UNINTERRUPTED OR ERROR-FREE. INFORMATICA SHALL NOT, UNDER ANY CIRCUMSTANCES, BE - * LIABLE TO LICENSEE FOR LOST PROFITS, CONSEQUENTIAL, INCIDENTAL, SPECIAL OR - * INDIRECT DAMAGES ARISING OUT OF OR RELATED TO THIS AGREEMENT OR THE - * TRANSACTIONS CONTEMPLATED HEREUNDER, EVEN IF INFORMATICA HAS BEEN APPRISED OF - * THE LIKELIHOOD OF SUCH DAMAGES. - */ - -/* =semlit,block,includes=*/ -#include - -#if defined(_MSC_VER) -/* Windows-only includes */ -#include -#define SLEEP(s) Sleep((s)*1000) -#else -/* Unix-only includes */ -#include -#include -#define SLEEP(s) sleep(s) -#endif - -#include -/* =semlit,endblock,includes=*/ - -/* =semlit,block,error_check=*/ -/* Example error checking macro. Include after each UM call. */ -#define EX_LBM_CHK(err) do { \ - if ((err) < 0) { \ - fprintf(stderr, "%s:%d, lbm error: '%s'\n", \ - __FILE__, __LINE__, lbm_errmsg()); \ - exit(1); \ - } \ -} while (0) -/* =semlit,endblock,error_check=*/ - -/* =semlit,block,struct_app_timer=*/ -typedef enum {PENDING, FIRED, CANCELED} state_type_e; -typedef struct app_timer_s { - int id; - state_type_e state; - int sync; -} app_timer_s; -/* =semlit,endblock,struct_app_timer=*/ - -/* =semlit,block,int_wait=*/ -int wait = 1; -/* =semlit,endblock,int_wait=*/ - -/* Timer callback function */ -/* =semlit,block,timer_cb=*/ -int sample_timer_handler(lbm_context_t *ctx, const void *clientd) -{ - struct app_timer_s *my_timer = (struct app_timer_s *)clientd; - if (my_timer->state != PENDING) { - fprintf(stderr, "ERROR: Timer executed and should have been cancelled\n"); - exit(1); - } - - fprintf(stderr, "ERROR: This timer should have been cancelled by now\n"); - - return 0; -} -/* =semlit,endblock,timer_cb=*/ - -/* =semlit,block,cancel_cb=*/ -int cancel_timer_cb(lbm_context_t *ctx, const void *clientd) -{ - struct app_timer_s *my_timer = (struct app_timer_s *)clientd; - if (my_timer->state == PENDING) { - lbm_cancel_timer(ctx, my_timer->id, NULL); - my_timer->state = CANCELED; - } - my_timer->sync = 0; - - return 0; -} -/* =semlit,endblock,cancel_cb=*/ - -int main(int argc, char **argv) -{ - lbm_context_t *ctx; /* Context object */ - lbm_context_attr_t * cattr; /* Context attribute object */ - int err; /* Used for checking API return codes */ - app_timer_s my_timer; - - my_timer.sync = 0; - - /* Initialize context atrributes and create context */ - /* =semlit,block,ctx_create=*/ - err = lbm_context_attr_create(&cattr); - EX_LBM_CHK(err); - - err = lbm_context_create(&ctx, cattr, NULL, NULL); - EX_LBM_CHK(err); - /* =semlit,endblock,ctx_create=*/ - - /* =semlit,block,schedule=*/ - my_timer.state = PENDING; - if ((my_timer.id = lbm_schedule_timer(ctx, sample_timer_handler, &my_timer, NULL, 10000)) == -1) { - fprintf(stderr, "%s:%d, lbm error: '%s'\n", __FILE__, __LINE__, lbm_errmsg()); - exit(1); - } - /* =semlit,endblock,schedule=*/ - - /* Now wait for callback to end the wait and close the application */ - SLEEP(1); - - /* =semlit,block,cancel= */ - if (my_timer.state == PENDING) { - lbm_schedule_timer(ctx, cancel_timer_cb, &my_timer, NULL, 0); - /* timer might still fire at this point. */ - my_timer.sync = 1; - } - /* =semlit,endblock,cancel= */ - - /* =semlit,block,wait=*/ - while (my_timer.sync) - SLEEP(1); - /* =semlit,endblock,wait=*/ - - /* Clean up */ - err = lbm_context_delete(ctx); - EX_LBM_CHK(err); - -#if defined(_MSC_VER) - /* Windows-specific cleanup overhead */ - WSACleanup(); -#endif - return 0; -} - From 3641a41591f133881ba93488ec64c7c736103ee0 Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Mon, 5 Nov 2018 12:53:51 -0500 Subject: [PATCH 11/26] Minor updates Added initial file for source frame. Also removed include block (which produced non-existant line number links). --- ss_frag/c/index.html | 2 +- ss_frag/c/ss_frag.sldoc | 1 + ss_frag/c/ss_frag.sldoc.html | 1 + ss_frag/c/ss_frag_c.slsrc | 2 -- ss_frag/c/ss_frag_c.slsrc.html | 32 ++++++++++++++++---------------- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ss_frag/c/index.html b/ss_frag/c/index.html index 6b2c6ea..a36528e 100644 --- a/ss_frag/c/index.html +++ b/ss_frag/c/index.html @@ -1,6 +1,6 @@ - + diff --git a/ss_frag/c/ss_frag.sldoc b/ss_frag/c/ss_frag.sldoc index c087067..6bd2a69 100644 --- a/ss_frag/c/ss_frag.sldoc +++ b/ss_frag/c/ss_frag.sldoc @@ -9,6 +9,7 @@
    • =semlit,srcfile,ss_frag_c.slsrc,ss_frag.c= - (right-click and save as "ss_frag.c") main program.
    • +=semlit,initialsource,ss_frag_c.slsrc.html=

    The ss_frag.c file contains:

    diff --git a/ss_frag/c/ss_frag.sldoc.html b/ss_frag/c/ss_frag.sldoc.html index c2bb432..aff7d5a 100644 --- a/ss_frag/c/ss_frag.sldoc.html +++ b/ss_frag/c/ss_frag.sldoc.html @@ -65,6 +65,7 @@

    High-Level Design

    • ss_frag.c - (right-click and save as "ss_frag.c") main program.
    • +

    The ss_frag.c file contains:

    diff --git a/ss_frag/c/ss_frag_c.slsrc b/ss_frag/c/ss_frag_c.slsrc index f4889cc..dc9b6cf 100644 --- a/ss_frag/c/ss_frag_c.slsrc +++ b/ss_frag/c/ss_frag_c.slsrc @@ -19,7 +19,6 @@ * THE LIKELIHOOD OF SUCH DAMAGES. */ -/* =semlit,block,includes=*/ #include #include @@ -35,7 +34,6 @@ #endif #include -/* =semlit,endblock,includes=*/ /* Application structure associated with a smart source. diff --git a/ss_frag/c/ss_frag_c.slsrc.html b/ss_frag/c/ss_frag_c.slsrc.html index 775355b..115c7c9 100644 --- a/ss_frag/c/ss_frag_c.slsrc.html +++ b/ss_frag/c/ss_frag_c.slsrc.html @@ -37,21 +37,21 @@ 00019 00020 00021 -00022 -00023 -00024 -00025 -00026 -00027 -00028 -00029 -00030 -00031 -00032 -00033 -00034 -00035 -00036 +00022 +00023 +00024 +00025 +00026 +00027 +00028 +00029 +00030 +00031 +00032 +00033 +00034 +00035 +00036 00037 00038 00039 @@ -495,7 +495,7 @@ * THE LIKELIHOOD OF SUCH DAMAGES. */ - #include <stdio.h> + #include <stdio.h> #include <string.h> #if defined(_MSC_VER) From 974f04749629ea4f6fd146250434d11e8762b644 Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Thu, 15 Nov 2018 10:50:15 -0500 Subject: [PATCH 12/26] Remove cruft Got rid of "wait" global (not used) --- cancelling_timers/c/cancelling_timers.c | 2 - .../c/cancelling_timers.sldoc.html | 74 +++++++++---------- cancelling_timers/c/cancelling_timers_c.slsrc | 4 - .../c/cancelling_timers_c.slsrc.html | 50 ++++++------- 4 files changed, 60 insertions(+), 70 deletions(-) diff --git a/cancelling_timers/c/cancelling_timers.c b/cancelling_timers/c/cancelling_timers.c index 742c215..494aaba 100644 --- a/cancelling_timers/c/cancelling_timers.c +++ b/cancelling_timers/c/cancelling_timers.c @@ -50,8 +50,6 @@ typedef struct app_timer_s { int sync; } app_timer_s; -int wait = 1; - /* Timer callback function */ int sample_timer_handler(lbm_context_t *ctx, const void *clientd) diff --git a/cancelling_timers/c/cancelling_timers.sldoc.html b/cancelling_timers/c/cancelling_timers.sldoc.html index 475a31b..7013d4f 100644 --- a/cancelling_timers/c/cancelling_timers.sldoc.html +++ b/cancelling_timers/c/cancelling_timers.sldoc.html @@ -46,8 +46,8 @@

    Initializing the Context

    Creating a Context

    -00093      err = lbm_context_create(&ctx, NULL, NULL, NULL);
    -00094      EX_LBM_CHK(err);
    +00091      err = lbm_context_create(&ctx, NULL, NULL, NULL);
    +00092      EX_LBM_CHK(err);
     
    @@ -56,19 +56,19 @@

    Creating a Timer Callback

    not end up being executed though, because it will be cancelled well in advance

    -00056  /* Timer callback function */
    -00057  int sample_timer_handler(lbm_context_t *ctx, const void *clientd)
    -00058  {
    -00059      struct app_timer_s *my_timer = (struct app_timer_s *)clientd;
    -00060      if (my_timer->state != PENDING) {  
    -00061          fprintf(stderr, "ERROR: Timer executed and should have been cancelled\n");
    -00062          exit(1);
    -00063      }
    +00054  /* Timer callback function */
    +00055  int sample_timer_handler(lbm_context_t *ctx, const void *clientd)
    +00056  {
    +00057      struct app_timer_s *my_timer = (struct app_timer_s *)clientd;
    +00058      if (my_timer->state != PENDING) {  
    +00059          fprintf(stderr, "ERROR: Timer executed and should have been cancelled\n");
    +00060          exit(1);
    +00061      }
    +00062  
    +00063      fprintf(stderr, "ERROR: This timer should have been cancelled by now\n");
     00064  
    -00065      fprintf(stderr, "ERROR: This timer should have been cancelled by now\n");
    -00066  
    -00067      return 0;
    -00068  }  /* sample_timer_handler */
    +00065      return 0;
    +00066  }  /* sample_timer_handler */
     
    @@ -80,17 +80,17 @@

    Creating a Cancel Callback

    will not be executed.
    -00071  int cancel_timer_cb(lbm_context_t *ctx, const void *clientd)
    -00072  {
    -00073      struct app_timer_s *my_timer = (struct app_timer_s *)clientd;
    -00074      if (my_timer->state == PENDING) {
    -00075          lbm_cancel_timer(ctx, my_timer->id, NULL);
    -00076          my_timer->state = CANCELED;
    -00077      }
    -00078      my_timer->sync = 0;
    -00079      
    -00080      return 0;
    -00081  }  /* cancel_timer_cb */
    +00069  int cancel_timer_cb(lbm_context_t *ctx, const void *clientd)
    +00070  {
    +00071      struct app_timer_s *my_timer = (struct app_timer_s *)clientd;
    +00072      if (my_timer->state == PENDING) {
    +00073          lbm_cancel_timer(ctx, my_timer->id, NULL);
    +00074          my_timer->state = CANCELED;
    +00075      }
    +00076      my_timer->sync = 0;
    +00077      
    +00078      return 0;
    +00079  }  /* cancel_timer_cb */
     
    @@ -100,11 +100,11 @@

    Scheduling the Timer Callback

    statee object, set to PENDING

    -00096      my_timer.state = PENDING;
    -00097      if ((my_timer.id = lbm_schedule_timer(ctx, sample_timer_handler, &my_timer, NULL, 10000)) == -1) {
    -00098          fprintf(stderr, "%s:%d, lbm error: '%s'\n", __FILE__, __LINE__, lbm_errmsg());
    -00099          exit(1);
    -00100      }
    +00094      my_timer.state = PENDING;
    +00095      if ((my_timer.id = lbm_schedule_timer(ctx, sample_timer_handler, &my_timer, NULL, 10000)) == -1) {
    +00096          fprintf(stderr, "%s:%d, lbm error: '%s'\n", __FILE__, __LINE__, lbm_errmsg());
    +00097          exit(1);
    +00098      }
     
    @@ -113,11 +113,11 @@

    Cancelling the Timer

    callback, and pass in the state object as the client data variable

    -00105      if (my_timer.state == PENDING) {
    -00106          lbm_schedule_timer(ctx, cancel_timer_cb, &my_timer, NULL, 0);
    -00107          /* timer might still fire at this point. */
    -00108          my_timer.sync = 1;
    -00109      }
    +00103      if (my_timer.state == PENDING) {
    +00104          lbm_schedule_timer(ctx, cancel_timer_cb, &my_timer, NULL, 0);
    +00105          /* timer might still fire at this point. */
    +00106          my_timer.sync = 1;
    +00107      }
     
    @@ -126,8 +126,8 @@

    Wait

    is not in this sample to maintain simple portability

    -00111      while (my_timer.sync)
    -00112          SLEEP(1);
    +00109      while (my_timer.sync)
    +00110          SLEEP(1);
     
    diff --git a/cancelling_timers/c/cancelling_timers_c.slsrc b/cancelling_timers/c/cancelling_timers_c.slsrc index d3ffe1d..e2919c2 100644 --- a/cancelling_timers/c/cancelling_timers_c.slsrc +++ b/cancelling_timers/c/cancelling_timers_c.slsrc @@ -56,10 +56,6 @@ typedef struct app_timer_s { } app_timer_s; /* =semlit,endblock,struct_app_timer=*/ -/* =semlit,block,int_wait=*/ -int wait = 1; -/* =semlit,endblock,int_wait=*/ - /* =semlit,block,timer_cb=*/ /* Timer callback function */ diff --git a/cancelling_timers/c/cancelling_timers_c.slsrc.html b/cancelling_timers/c/cancelling_timers_c.slsrc.html index 9a3b318..f54cf49 100644 --- a/cancelling_timers/c/cancelling_timers_c.slsrc.html +++ b/cancelling_timers/c/cancelling_timers_c.slsrc.html @@ -68,9 +68,9 @@ 00050 00051 00052 -00053 -00054 -00055 +00053 +00054 +00055 00056 00057 00058 @@ -82,10 +82,10 @@ 00064 00065 00066 -00067 -00068 -00069 -00070 +00067 +00068 +00069 +00070 00071 00072 00073 @@ -95,8 +95,8 @@ 00077 00078 00079 -00080 -00081 +00080 +00081 00082 00083 00084 @@ -106,28 +106,28 @@ 00088 00089 00090 -00091 -00092 -00093 -00094 -00095 +00091 +00092 +00093 +00094 +00095 00096 00097 00098 -00099 -00100 +00099 +00100 00101 00102 -00103 -00104 +00103 +00104 00105 00106 00107 -00108 -00109 -00110 -00111 -00112 +00108 +00109 +00110 +00111 +00112 00113 00114 00115 @@ -138,8 +138,6 @@ 00120 00121 00122 -00123 -00124 /* cancelling_timers.c - see http://ultramessaging.github.io/UMExamples/cancelling_timers/c/index.html * * Copyright (c) 2005-2017 Informatica Corporation. All Rights Reserved. @@ -192,8 +190,6 @@ int sync; } app_timer_s; - int wait = 1; - /* Timer callback function */ int sample_timer_handler(lbm_context_t *ctx, const void *clientd) From 138e79bf9e5a8ffae0b91cd57a31905da484ebf5 Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Thu, 15 Nov 2018 11:48:21 -0500 Subject: [PATCH 13/26] bug fix, misc improvements In ss_frag, passed ptr to opt_len to setopt. Fixed to pass opt_len by value. Also added C compile step to build to verify source code. Also changed "wait" to "wait_flag" to avoid symbol conflict. --- bld.sh | 6 + schedule_timers/c/schedule_timers.c | 6 +- schedule_timers/c/schedule_timers.sldoc | 4 +- schedule_timers/c/schedule_timers.sldoc.html | 8 +- schedule_timers/c/schedule_timers_c.slsrc | 6 +- .../c/schedule_timers_c.slsrc.html | 6 +- ss_frag/c/ss_frag.c | 3 +- ss_frag/c/ss_frag.sldoc | 4 +- ss_frag/c/ss_frag.sldoc.html | 119 +++++++++-------- ss_frag/c/ss_frag_c.slsrc | 3 +- ss_frag/c/ss_frag_c.slsrc.html | 34 ++--- ss_frag/c/test.cfg | 11 ++ ss_frag/c/test_cfg.txt | 11 ++ ss_frag/c/test_cfg.txt.html | 126 ++++++++++++++++++ 14 files changed, 255 insertions(+), 92 deletions(-) create mode 100644 ss_frag/c/test.cfg create mode 100644 ss_frag/c/test_cfg.txt create mode 100644 ss_frag/c/test_cfg.txt.html diff --git a/bld.sh b/bld.sh index 7cdfd00..665fb76 100755 --- a/bld.sh +++ b/bld.sh @@ -30,6 +30,12 @@ cat bld.tmp | while read F; do : # find each tool semlit.sh "$T.sldoc" # Don't let example maintainers edit the output files chmod -w *.c *.h *.java *.cs >/dev/null 2>&1 + # Try compile (check for errors) + if ls *.c >/dev/null 2>&1; then : + echo "bld.sh: Info: gcc -I$LBM_PLATFORM/include -g -c *.c" + gcc $* -I$LBM_PLATFORM/include -g -c *.c + rm -f *.o + fi cd .. done cd .. diff --git a/schedule_timers/c/schedule_timers.c b/schedule_timers/c/schedule_timers.c index ecb99f4..05d3f3e 100644 --- a/schedule_timers/c/schedule_timers.c +++ b/schedule_timers/c/schedule_timers.c @@ -43,14 +43,14 @@ } \ } while (0) -int wait = 1; +int wait_flag = 1; /* Timer callback function */ int sample_timer_handler(lbm_context_t *ctx, const void *clientd) { printf("Timer executed. Set wait to 0 so application can cleanly exit\n"); - wait = 0; + wait_flag = 0; return 0; } /* sample_timer_handler */ @@ -71,7 +71,7 @@ int main(int argc, char **argv) EX_LBM_CHK(timer_id); /* Now wait for callback to end the wait and close the application */ - while (wait) + while (wait_flag) SLEEP(1); /* Clean up */ diff --git a/schedule_timers/c/schedule_timers.sldoc b/schedule_timers/c/schedule_timers.sldoc index 268c5ef..d60ae2d 100644 --- a/schedule_timers/c/schedule_timers.sldoc +++ b/schedule_timers/c/schedule_timers.sldoc @@ -19,14 +19,14 @@

    The callback function defined below is the application callback that will be invoked when the scheduled timer expires. This callback will be executed on the UM context thread (at least for the purpose of this example it will be executed on the context thread.

    =semlit,insert,timer_cb= -

    Note that inside the callback, the global "wait" variable is set to 0, this allows the main thread to stop tight-looping and exit.

    +

    Note that inside the callback, the global "wait_flag" variable is set to 0, this allows the main thread to stop tight-looping and exit.

    Scheduling the Timer Callback

    Here the application is actually scheduling the callback timer, set to be executed in 1000 milliseconds. The return value should be saved by the application in the event that the application wishes to cancel the timer before it executes. Special care must be taken when cancelling timer callback, for more information please see For the purpose of this example application, it is using the global variable "wait_flag" as a semaphore essentially. Once the timer executes, wait will be set to 0 and the application can cleanly exit by deleting the context.

    =semlit,insert,wait=

    Error Checking

    diff --git a/schedule_timers/c/schedule_timers.sldoc.html b/schedule_timers/c/schedule_timers.sldoc.html index 0279265..6b63cfd 100644 --- a/schedule_timers/c/schedule_timers.sldoc.html +++ b/schedule_timers/c/schedule_timers.sldoc.html @@ -38,14 +38,14 @@

    Creating a Callback

    00050 int sample_timer_handler(lbm_context_t *ctx, const void *clientd) 00051 { 00052 printf("Timer executed. Set wait to 0 so application can cleanly exit\n"); -00053 wait = 0; +00053 wait_flag = 0; 00054 00055 return 0; 00056 } /* sample_timer_handler */
    -

    Note that inside the callback, the global "wait" variable is set to 0, this allows the main thread to stop tight-looping and exit.

    +

    Note that inside the callback, the global "wait_flag" variable is set to 0, this allows the main thread to stop tight-looping and exit.

    Scheduling the Timer Callback

    Here the application is actually scheduling the callback timer, set to be executed in 1000 milliseconds. The return value should be saved by the application in the event that the application wishes to cancel the timer before it executes. Special care must be taken when cancelling @@ -59,11 +59,11 @@

    Scheduling the Timer Callback

    Wait for Timer

    -

    For the purpose of this example application, it is using the global variable "wait" as a semaphore essentially. Once the timer executes, wait +

    For the purpose of this example application, it is using the global variable "wait_flag" as a semaphore essentially. Once the timer executes, wait will be set to 0 and the application can cleanly exit by deleting the context.

    -00074      while (wait)
    +00074      while (wait_flag)
     00075          SLEEP(1);
     
    diff --git a/schedule_timers/c/schedule_timers_c.slsrc b/schedule_timers/c/schedule_timers_c.slsrc index 6f785aa..f39cd45 100644 --- a/schedule_timers/c/schedule_timers_c.slsrc +++ b/schedule_timers/c/schedule_timers_c.slsrc @@ -48,7 +48,7 @@ /* =semlit,endblock,error_check=*/ /* =semlit,block,int_wait=*/ -int wait = 1; +int wait_flag = 1; /* =semlit,endblock,int_wait=*/ @@ -57,7 +57,7 @@ int wait = 1; int sample_timer_handler(lbm_context_t *ctx, const void *clientd) { printf("Timer executed. Set wait to 0 so application can cleanly exit\n"); - wait = 0; + wait_flag = 0; return 0; } /* sample_timer_handler */ @@ -84,7 +84,7 @@ int main(int argc, char **argv) /* Now wait for callback to end the wait and close the application */ /* =semlit,block,wait=*/ - while (wait) + while (wait_flag) SLEEP(1); /* =semlit,endblock,wait=*/ diff --git a/schedule_timers/c/schedule_timers_c.slsrc.html b/schedule_timers/c/schedule_timers_c.slsrc.html index 8b152cf..2c45889 100644 --- a/schedule_timers/c/schedule_timers_c.slsrc.html +++ b/schedule_timers/c/schedule_timers_c.slsrc.html @@ -148,14 +148,14 @@ } \ } while (0) - int wait = 1; + int wait_flag = 1; /* Timer callback function */ int sample_timer_handler(lbm_context_t *ctx, const void *clientd) { printf("Timer executed. Set wait to 0 so application can cleanly exit\n"); - wait = 0; + wait_flag = 0; return 0; } /* sample_timer_handler */ @@ -176,7 +176,7 @@ EX_LBM_CHK(timer_id); /* Now wait for callback to end the wait and close the application */ - while (wait) + while (wait_flag) SLEEP(1); /* Clean up */ diff --git a/ss_frag/c/ss_frag.c b/ss_frag/c/ss_frag.c index a58ce34..408d31c 100644 --- a/ss_frag/c/ss_frag.c +++ b/ss_frag/c/ss_frag.c @@ -273,8 +273,9 @@ void smart_source_init(smart_source_t *smart_source, lbm_context_t *ctx, if (prop_count == 0) { /* No props configured, add one. */ prop_count = 1; + opt_len = sizeof(prop_count); err = lbm_src_topic_attr_setopt(src_tattr, - "smart_src_message_property_int_count", &prop_count, &opt_len); + "smart_src_message_property_int_count", &prop_count, opt_len); LBM_ERR(err); } diff --git a/ss_frag/c/ss_frag.sldoc b/ss_frag/c/ss_frag.sldoc index 6bd2a69..100c0c5 100644 --- a/ss_frag/c/ss_frag.sldoc +++ b/ss_frag/c/ss_frag.sldoc @@ -5,11 +5,13 @@ =semlit,include,../intro.sldoc= -

    There is one program source file:

    +

    There is one program source file and one test configuration file:

    • =semlit,srcfile,ss_frag_c.slsrc,ss_frag.c= - (right-click and save as "ss_frag.c") main program.
    • =semlit,initialsource,ss_frag_c.slsrc.html= +
    • =semlit,srcfile,test_cfg.txt,test.cfg= + - (right-click and save as "test.cfg") main program.

    The ss_frag.c file contains:

    diff --git a/ss_frag/c/ss_frag.sldoc.html b/ss_frag/c/ss_frag.sldoc.html index aff7d5a..09ab8db 100644 --- a/ss_frag/c/ss_frag.sldoc.html +++ b/ss_frag/c/ss_frag.sldoc.html @@ -61,11 +61,13 @@

    High-Level Design

  • length=800, Remain=0
  • When the receiver sees Remain=0, it can deliver the reassembled message.

    -

    There is one program source file:

    +

    There is one program source file and one test configuration file:

    • ss_frag.c - (right-click and save as "ss_frag.c") main program.
    • +
    • test.cfg + - (right-click and save as "test.cfg") main program.

    The ss_frag.c file contains:

    @@ -79,11 +81,11 @@

    Source-Side Code

    smart_source_send():

    -00312  /* Send a message, fragmenting it if necessary.
    -00313   */
    -00314  void smart_source_send(smart_source_t *smart_source, char *buf, size_t len,
    -00315    int flags)
    -00316  {
    +00313  /* Send a message, fragmenting it if necessary.
    +00314   */
    +00315  void smart_source_send(smart_source_t *smart_source, char *buf, size_t len,
    +00316    int flags)
    +00317  {
     
    @@ -93,13 +95,13 @@

    Source-Side Code

    message without any message properties.

    -00319    if (len <= smart_source->max_msg_len) {
    -00320      /* Message fits in one buffer, send it. */
    -00321      memcpy(smart_source->msgbuf_plain, buf, len);
    -00322      err = lbm_ssrc_send_ex(smart_source->ssrc, smart_source->msgbuf_plain,
    -00323        len, 0, NULL);
    -00324      LBM_ERR(err);
    -00325    }
    +00320    if (len <= smart_source->max_msg_len) {
    +00321      /* Message fits in one buffer, send it. */
    +00322      memcpy(smart_source->msgbuf_plain, buf, len);
    +00323      err = lbm_ssrc_send_ex(smart_source->ssrc, smart_source->msgbuf_plain,
    +00324        len, 0, NULL);
    +00325      LBM_ERR(err);
    +00326    }
     
    @@ -108,15 +110,15 @@

    Source-Side Code

    of the remaining size after this fragment is sent.

    -00336      this_len = smart_source->max_msg_len;
    -00337      remaining -= this_len;
    -00338      /* Indicate first fragment with negative remainer. */
    -00339      smart_source->int_value_array[0] = - remaining;
    -00340      memcpy(smart_source->msgbuf_props, &buf[offset], this_len);
    -00341      err = lbm_ssrc_send_ex(smart_source->ssrc, smart_source->msgbuf_props,
    -00342        this_len, 0, &(smart_source->info_prop));
    -00343      LBM_ERR(err);
    -00344      offset += this_len;
    +00337      this_len = smart_source->max_msg_len;
    +00338      remaining -= this_len;
    +00339      /* Indicate first fragment with negative remainer. */
    +00340      smart_source->int_value_array[0] = - remaining;
    +00341      memcpy(smart_source->msgbuf_props, &buf[offset], this_len);
    +00342      err = lbm_ssrc_send_ex(smart_source->ssrc, smart_source->msgbuf_props,
    +00343        this_len, 0, &(smart_source->info_prop));
    +00344      LBM_ERR(err);
    +00345      offset += this_len;
     
    @@ -124,22 +126,22 @@

    Source-Side Code

    a positive "Remain" property.

    -00349      /* Send rest of fragments. */
    -00350      while (remaining > 0) {
    -00351        if (remaining > smart_source->max_msg_len) {
    -00352          this_len = smart_source->max_msg_len;
    -00353        }
    -00354        else {
    -00355          this_len = remaining;
    -00356        }
    -00357        remaining -= this_len;
    -00358        smart_source->int_value_array[0] = remaining;
    -00359        memcpy(smart_source->msgbuf_props, &buf[offset], this_len);
    -00360        err = lbm_ssrc_send_ex(smart_source->ssrc, smart_source->msgbuf_props,
    -00361          this_len, 0, &(smart_source->info_prop));
    -00362  
    -00363        offset += this_len;
    -00364      }  /* while */
    +00350      /* Send rest of fragments. */
    +00351      while (remaining > 0) {
    +00352        if (remaining > smart_source->max_msg_len) {
    +00353          this_len = smart_source->max_msg_len;
    +00354        }
    +00355        else {
    +00356          this_len = remaining;
    +00357        }
    +00358        remaining -= this_len;
    +00359        smart_source->int_value_array[0] = remaining;
    +00360        memcpy(smart_source->msgbuf_props, &buf[offset], this_len);
    +00361        err = lbm_ssrc_send_ex(smart_source->ssrc, smart_source->msgbuf_props,
    +00362          this_len, 0, &(smart_source->info_prop));
    +00363  
    +00364        offset += this_len;
    +00365      }  /* while */
     
    @@ -151,23 +153,23 @@

    Send Buffers

    smart_source_init().

    -00297    err = lbm_ssrc_buff_get(smart_source->ssrc, &smart_source->msgbuf_plain, 0);
    -00298    LBM_ERR(err);
    -00299    err = lbm_ssrc_buff_get(smart_source->ssrc, &smart_source->msgbuf_props, 0);
    -00300    LBM_ERR(err);
    +00298    err = lbm_ssrc_buff_get(smart_source->ssrc, &smart_source->msgbuf_plain, 0);
    +00299    LBM_ERR(err);
    +00300    err = lbm_ssrc_buff_get(smart_source->ssrc, &smart_source->msgbuf_props, 0);
    +00301    LBM_ERR(err);
     

    The message property is also initialized.

    -00302    /* Set up message property. */
    -00303    smart_source->info_prop.flags = LBM_SSRC_SEND_EX_FLAG_PROPERTIES;
    -00304    smart_source->info_prop.mprop_int_cnt = 1;
    -00305    smart_source->info_prop.mprop_int_vals = smart_source->int_value_array;
    -00306    smart_source->info_prop.mprop_int_keys = &smart_source->key_ptr_array[0];
    -00307    smart_source->key_ptr_array[0] = smart_source->remain_key;
    -00308    strncpy(smart_source->remain_key, "Remain", sizeof(smart_source->remain_key));
    +00303    /* Set up message property. */
    +00304    smart_source->info_prop.flags = LBM_SSRC_SEND_EX_FLAG_PROPERTIES;
    +00305    smart_source->info_prop.mprop_int_cnt = 1;
    +00306    smart_source->info_prop.mprop_int_vals = smart_source->int_value_array;
    +00307    smart_source->info_prop.mprop_int_keys = &smart_source->key_ptr_array[0];
    +00308    smart_source->key_ptr_array[0] = smart_source->remain_key;
    +00309    strncpy(smart_source->remain_key, "Remain", sizeof(smart_source->remain_key));
     
    @@ -186,11 +188,11 @@

    Send Buffers

    is read.

    -00281    /* Find out the user's config for max message length. */
    -00282    opt_len = sizeof(smart_source->max_msg_len);
    -00283    err = lbm_src_topic_attr_getopt(src_tattr,
    -00284      "smart_src_max_message_length", &(smart_source->max_msg_len), &opt_len);
    -00285    LBM_ERR(err);
    +00282    /* Find out the user's config for max message length. */
    +00283    opt_len = sizeof(smart_source->max_msg_len);
    +00284    err = lbm_src_topic_attr_getopt(src_tattr,
    +00285      "smart_src_max_message_length", &(smart_source->max_msg_len), &opt_len);
    +00286    LBM_ERR(err);
     
    @@ -206,10 +208,11 @@

    Send Buffers

    00273 if (prop_count == 0) { 00274 /* No props configured, add one. */ 00275 prop_count = 1; -00276 err = lbm_src_topic_attr_setopt(src_tattr, -00277 "smart_src_message_property_int_count", &prop_count, &opt_len); -00278 LBM_ERR(err); -00279 } +00276 opt_len = sizeof(prop_count); +00277 err = lbm_src_topic_attr_setopt(src_tattr, +00278 "smart_src_message_property_int_count", &prop_count, opt_len); +00279 LBM_ERR(err); +00280 }
    diff --git a/ss_frag/c/ss_frag_c.slsrc b/ss_frag/c/ss_frag_c.slsrc index dc9b6cf..f773582 100644 --- a/ss_frag/c/ss_frag_c.slsrc +++ b/ss_frag/c/ss_frag_c.slsrc @@ -294,8 +294,9 @@ void smart_source_init(smart_source_t *smart_source, lbm_context_t *ctx, if (prop_count == 0) { /* No props configured, add one. */ prop_count = 1; + opt_len = sizeof(prop_count); err = lbm_src_topic_attr_setopt(src_tattr, - "smart_src_message_property_int_count", &prop_count, &opt_len); + "smart_src_message_property_int_count", &prop_count, opt_len); LBM_ERR(err); } /* =semlit,endblock,send_conf_prop=*/ diff --git a/ss_frag/c/ss_frag_c.slsrc.html b/ss_frag/c/ss_frag_c.slsrc.html index 115c7c9..3862191 100644 --- a/ss_frag/c/ss_frag_c.slsrc.html +++ b/ss_frag/c/ss_frag_c.slsrc.html @@ -295,13 +295,13 @@ 00277 00278 00279 -00280 -00281 +00280 +00281 00282 00283 00284 00285 -00286 +00286 00287 00288 00289 @@ -312,36 +312,36 @@ 00294 00295 00296 -00297 +00297 00298 00299 00300 -00301 -00302 +00301 +00302 00303 00304 00305 00306 00307 00308 -00309 +00309 00310 00311 -00312 +00312 00313 00314 00315 00316 -00317 +00317 00318 -00319 +00319 00320 00321 00322 00323 00324 00325 -00326 +00326 00327 00328 00329 @@ -351,7 +351,7 @@ 00333 00334 00335 -00336 +00336 00337 00338 00339 @@ -360,11 +360,11 @@ 00342 00343 00344 -00345 +00345 00346 00347 00348 -00349 +00349 00350 00351 00352 @@ -380,7 +380,7 @@ 00362 00363 00364 -00365 +00365 00366 00367 00368 @@ -474,6 +474,7 @@ 00456 00457 00458 +00459 /* ss_frag.c - see http://ultramessaging.github.io/UMExamples/ss_frag/c/index.html * * Copyright (c) 2005-2018 Informatica Corporation. All Rights Reserved. @@ -749,8 +750,9 @@ if (prop_count == 0) { /* No props configured, add one. */ prop_count = 1; + opt_len = sizeof(prop_count); err = lbm_src_topic_attr_setopt(src_tattr, - "smart_src_message_property_int_count", &prop_count, &opt_len); + "smart_src_message_property_int_count", &prop_count, opt_len); LBM_ERR(err); } diff --git a/ss_frag/c/test.cfg b/ss_frag/c/test.cfg new file mode 100644 index 0000000..61b105f --- /dev/null +++ b/ss_frag/c/test.cfg @@ -0,0 +1,11 @@ +# test.cfg + +source transport lbtrm +source smart_src_max_message_length 1400 +source smart_src_message_property_int_count 2 +source smart_src_user_buffer_count 2 + +# The following should be uncommented and changed according to your network. +#context resolver_multicast_address 239.101.3.1 +#context transport_lbtrm_multicast_address_low 239.101.3.10 +#context transport_lbtrm_multicast_address_high 239.101.3.14 diff --git a/ss_frag/c/test_cfg.txt b/ss_frag/c/test_cfg.txt new file mode 100644 index 0000000..61b105f --- /dev/null +++ b/ss_frag/c/test_cfg.txt @@ -0,0 +1,11 @@ +# test.cfg + +source transport lbtrm +source smart_src_max_message_length 1400 +source smart_src_message_property_int_count 2 +source smart_src_user_buffer_count 2 + +# The following should be uncommented and changed according to your network. +#context resolver_multicast_address 239.101.3.1 +#context transport_lbtrm_multicast_address_low 239.101.3.10 +#context transport_lbtrm_multicast_address_high 239.101.3.14 diff --git a/ss_frag/c/test_cfg.txt.html b/ss_frag/c/test_cfg.txt.html new file mode 100644 index 0000000..9b8aaff --- /dev/null +++ b/ss_frag/c/test_cfg.txt.html @@ -0,0 +1,126 @@ +test.cfg + + + + + + + + +

    test.cfg

    + +
    
    +
    00001 +00002 +00003 +00004 +00005 +00006 +00007 +00008 +00009 +00010 +00011 + # test.cfg + + source transport lbtrm + source smart_src_max_message_length 1400 + source smart_src_message_property_int_count 2 + source smart_src_user_buffer_count 2 + + # The following should be uncommented and changed according to your network. + #context resolver_multicast_address 239.101.3.1 + #context transport_lbtrm_multicast_address_low 239.101.3.10 + #context transport_lbtrm_multicast_address_high 239.101.3.14 +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    From 11599d5d904aa0499d74d190cf70c1f1661d5e86 Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Tue, 12 Feb 2019 07:28:49 -0500 Subject: [PATCH 14/26] Update index.html Removed link to ss_frag (6.12 handles SS fragmentation/reassembly). --- index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/index.html b/index.html index 11eb11e..8c1b447 100644 --- a/index.html +++ b/index.html @@ -49,7 +49,6 @@

    Examples

    setting_attributesC Java C#/.NETExamples on setting UM attributes via the API source_notify_callbacksC Java C#/.NETA sample application that demonstrates how to configure and code the source_notification_callback feature for receivers src_rspC Java C#/.NETA sample application that demonstrates source-based request responses. -ss_fragC Java C#/.NETA sample application that demonstrates application-level message fragmentation/reassembly for Smart Source. ump_receiver_callbacksC Java C#/.NETA sample application that handles all UMP receiver callbacks and logs important data ump_src_failoverC Java C#/.NETExample UMP source application that demonstrates how a persisted source can failover to a backup store From 670fae43f3bd3145d200e126b8b86a8f0c9db544 Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Fri, 23 Aug 2019 11:12:55 -0400 Subject: [PATCH 15/26] Update with latest look/feel/legal --- index.html | 54 +- infa_logo.png | Bin 0 -> 38351 bytes style/doxygen_manual.css | 1114 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 1161 insertions(+), 7 deletions(-) create mode 100644 infa_logo.png create mode 100644 style/doxygen_manual.css diff --git a/index.html b/index.html index 8c1b447..65723b0 100644 --- a/index.html +++ b/index.html @@ -1,10 +1,17 @@ - - -UMExamples - Learning the Ultra Messaging API by example - +UMExamples - Learning the Ultra Messaging API by example + + - -

    Welcome to UMExamples

    + +
    +
    +
    +Informatica

    +
    Welcome to UMExamples
    +

    + +© Copyright Informatica LLC 2004-2019. +

    Ultra Messaging Examples (UMExamples) is a documentation suite aimed at providing high quality educational samples for the Informatica Ultra Messaging @@ -20,7 +27,8 @@

    Welcome to UMExamples

    examples are not available in all laguages.

    If you would like to see only those examples available in a particular language, -you can visit: C examples Java examples C#/.NET examples

    +you can visit:

    +

    The master list is always available at: All examples

    @@ -52,5 +60,37 @@

    Examples

    ump_receiver_callbacksC Java C#/.NETA sample application that handles all UMP receiver callbacks and logs important data ump_src_failoverC Java C#/.NETExample UMP source application that demonstrates how a persisted source can failover to a backup store + +
    + +

    Notices

    +

    This software and documentation are provided only under a separate license +agreement containing restrictions on use and disclosure. +No part of this document may be reproduced or transmitted in any form, +by any means (electronic, photocopying, recording or otherwise) +without prior consent of Informatica LLC. + +

    A current list of Informatica trademarks is available on the web at +https://www.informatica.com/trademarks.html. + +

    Portions of this software and/or documentation are subject to copyright +held by third parties. +Required third party notices are included with the product. + +

    Informatica software is protected by patents as detailed at +https://www.informatica.com/legal/patents.html. + +

    The information in this documentation is subject to change without notice. +If you find any problems in this documentation, please report them to us in +writing at Informatica LLC 2100 Seaport Blvd. Redwood City, CA 94063. + +

    Informatica products are warranted according to the terms and conditions +of the agreements under which they are provided. +
    INFORMATICA LLC PROVIDES THE INFORMATION IN THIS DOCUMENT "AS IS" WITHOUT +WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING WITHOUT ANY WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ANY WARRANTY OR +CONDITION OF NON-INFRINGEMENT. +

    + diff --git a/infa_logo.png b/infa_logo.png new file mode 100644 index 0000000000000000000000000000000000000000..e3d8b45f058982807f6ee573e9543d2f9cb8247e GIT binary patch literal 38351 zcmeEsi8s{k`~M(`ib_R`>fk5`dbg!5~ zARK)V2y5A%-QdaIHwr=!$Y}`diq>`ij70*f*2%?2YRmHx6eNb8j1{cG3oYiAVgVz_dH*ZKn<_-7pX&^~?e@R#tixKM~S;@afDR zhXemWg=ma2tnPp>a{U^7=_WiIzw+fWvVvwau}BCsAKWTl3*-et{NJDdv%vpZ;Qu=d z*muiQiSLJw{ZH_(%`b0qKrFO6Jjl55Apj~nf4-h#S8mNPT%Vypso%!p^Q(JV|9##% zB;Lnzbb1VGd_9-#-zQNKtOE8jwkgE>iPcrBs9!4hwa=@UBrg$e|sQ1 zdln}D-eUsx^f`R2#sByH-B-f6?+eJ|JA06I?_d1Aa0x8zN_Y7&1j}mdx^0_5OcUN_ z{`WDKYdLHuKUS)?NaJXJ6}?WL>M}MY-GtxbMuQJ?PlZypSD~aH2b^%USGLJ-3tW7q z$)Wg3>&GUC=!rTf?ylz3I;W=9SKjxijmSn!|Ia3+hFrd(Y$va0iLKPpRO6dA{fh&m zXx(PO5wI1-^Zzr66);JP@)cATls4o4q$tWOTgfVt``@)vYw-TbYE`BwX77xDN>R+8 z&!3B96|e}55XZ+8qvNB40&F`*X8y7&=1gB$m0vhT6}B!l`F!-)wED~6KCxhBS1zqC zeyM6a)4<&9_Urg#!lMRZ+=Z_t6G+KosFlXphW5V<&JLX7>azC-3bRdja@0XS_55J; zmywSG>lY?UCXry?RGD{4{`0#qOobZ?G-H|}`yTGAe+)7l9F~QGZK1E7@d8RuI ztXqQhgw?=Q&wN#8EVRVZAh(2)t5p2@w-vsMfb%hVKQ`H6%^vCKH8`-L14|tDk4>07 zsW$6B+4+F%og-I)>@Lg|C=NsihKTU7z44!aE_3hkSn9a0VSF%G%K zvhcsWDZB{2a$)9L7W#g9+%ppYU5OdBkHIss3RL2+y%v1`v(If{hD7NIimK)JjrCM^ zpa`n|zwa-A@6YzU-OiL`p!PBTzRAKh)&Q$UuWOS{VO`S zL4rqhKImLA7C{Z193HI}`OD@fAFvAWN3$ma|1+F~?b24#RLY|M3ZI7{9!)IlcY^$A z>5S1i*FOO=2?0i2K5D(=YWAWANqvw;{{?Fbh`NW>;gs#~AVg|&s*tx*9mib$%T9m+ zY}Ke69+(gRi@V|R$lHHu>1rIty{~`9Qb`HdRsNNtddwnBU0|BQ6U|-nI|_!|gV-`&lDum5Zx2{l0pYGCSpeY*#7=C+ikx(5xOsFIW|zzKpWgSs z1l9)$yxS4?19hSF*H2lH<(imcuc&-aGLGkB@Bg-xUI)hU}ut!ez*WUa>m-02V3g4Yxb<-Jia9X&@v|HMsb zVxA^P(me>s@{Hl-ucLCW8v1yDgK%jZh{gVWuT+f>&o=y*MmI1Z)t<5>lCpbCKjsR4 zhWv?_(8QOT97jDg!CBVQBcGCQMtsc^8h@1a8?Qr;>@4522g{4D0`?q_Z~oEw5zzV3 zF%T?Kt|03k{uK{5K$uxP>8bF(_1HYi?!w3?4sh%Xp^3ka&C%qT@mML$curipPzanp zMIdqbn=C-Aa(+8q+c1o~d$3X!4a0C$^?L7lDcL6$=wpegsqQUf|Ih4|K-sZh=sb?}D$pRDKK$F6+eLRbnw z&;y)yv4_B|up3i<$r{cop!n(tK%qebGsqdv^+$_PR)LMP0NuYvwWu23K!OOdJ2lOy z9#Wdo{jKOlVD#oT;9=X3c3CYh<#E&+?y_A{ZUXkbzw^je`v+=zv@5qkX2x4j0<2B~p7q5XAE#fIbvN*<&(D9oQf8g7m ze0a8W_YlZ^Obv*}$RVMdmM{NWE(Xirhu-XfQ4!m|)_Tyx{D)IMFEt~MR6GAbm5)!4 zx(xkgp#F_x*nfV`G-n&ULdLXwjSPMw}lK+I@@g7f#uj zQI#0h*Z3Hi`8y3*P__$@{o?=YM?(d6PDo86;f*MzLzc%&nVVmnJjXMM{XZj1Xy&PlJq_jKphOwzmfQV~Mz;^2i`XD4UJ-w0}vKU3#?y^-HDaEh7a3kYv;u|XvF)W*IAihG2-e7q#+jg*K8JHnD zcwv#OMs$g9l)_zwjb{;iVD-fd&7}>MJJGxXe00z>3;jsUP@a-rba~(4OqMl<*gd4Q z8(>G!Bdl`uLcN3)DOBhUHa$>nJ$Le!sw=GNcsIxl%&;1ziHkGueArz&_MDFxPzHbSniu=mlSsfSotA zJ6fNUPz8rmi?Qa=%?N0$Aq_-L^Lg9|thw%Aw6<3h?{k1AkRp7?orHJP8v%ik*bMzH zA^zE6KYUOaW1ZpTiQzro5$24YPlB%v&*|i&T^Ce$Y;zfe$iZt_fx4)1{0y~{{$s$Zzb_n-_RyIX;r(w!@ko7R}&8g3cUkF}nuDxV#k zu=8KBTOU?6rV~igaJZNV$})ijft<|2#<*v`h+8tEyj9Y$E&sw~g(PW*akG`9ZivDd z#tEe1A3GJ`p1`f}EKoso&wO@(V&_%jtrLg}@nfZ4C;6kWY0%9sDAF~P9TMvB2D<=!j zt`*F`om*07l7~?CPq6c+U|Idj!16!ggGJc+lK4ht9Knjj5?XdG=dxqxihJOMlW=ks zx6Cb4HMjHyV1&7utg$M@fzvSWE~v3Vd2!(SyMypS6Ij-<31JAt)jizG2F|W zJExfBT)y17BCt~pK8g3$EQ!L-U(02aW{uUS>@T_uf%F-{)l_jGU?IXd&gf}K>lyLB z7YBcA#vGey-utn3>8l~=ob6k&^Y5W8-*&`wzdks8W3U-2rANu$`GAaB&SjviK*L#_ zgjIwE3;EK-&Ln<$eE{Y$q`V6P=>nbu!KOzkhE9A|=7AJGcxlBEig>9ykvMEDPgyFu zTo~#zuq4#I-lMn5VZ1(L1HelYbA9j^EUWbWWiVY!!p75xY%uiV9by54%fTq^u&m>JrmU^jAV(t;NDau?jZyijehSjM^#-d);ee3|%6lP& zU@|%vNeMcCcy?v_{3-#IB59~bS!JP`)V8bJ^SS1d{w>bo%3NyHJDDZIvzk~z>( z16A@m)xiR>kb@&uR*@OZYZw>^kkWEc+;(-Y)NRy2JwbT@%_-72l3UXUzP1J&FQ}L2ti?lZhJ#PzWHG8Qu`z~d^DT~}C<92S%v-D@X4?Q`XXxGj(F*ilYaYOW9 zYeuk}WZ^UEc#?6Lx&|<6QZbgCM)dQs^^?WL`r05jGltoB(19J;E|d~P9#SM3UP<9PO)N+&-^V?fBWZzMttM0pqo{?PNeRs<(^0R8Q_#D&Yj%q|b8srj%$r zp#+VqXA==1(6Dp-RP^0UM|M!tEh=T>GZaa3*(#(puo=cO` zy*5B(m4@PmpkCLV**z+TRlpC1YQDd&Vb^#b#{qK1LBX&b?PJ_~M_^ZIqIbSh2{lcr zWCw$#^|*Y$vj5m@qpvs#GruUm$EGj#IFCJQzEh*;{o;^7sFHGU??RJL?*f3I=ZzO} z(WGtvSySd-h(+2?a+R58Nj+-7CzAlb2I}00oy0O)pJ@V#B^{98i)wmCYCHwXiZ+M` zkxk!)laQ!~Dt!(d2_*fOns%og$CBGKXCaF>;R4x2Z6Dk9^1s9q{ju3^ow?I>3_X$| z>w~$?zQ#kAv{r0HDf?~q9qD)f*fec&D38NebC)?Ep6%K}5d{w=(wh1Zf-sXY41fW` z4=5A2I7-l5l&76K_^3YcqY=TscOm%Jj%L7SNvs0ZnyB&jpi>%(mLVI0QSWQyOH$*w z%gl}fkk&imeN)P3@aY>@Fg0MR$^&1@2VZJ1%2)}g?%6p54E*f}!HyA)kxz0U1jHT3 zMgahp3UmNFNcEu9z@E_0V3Pyb^bM4Y`U@YM#DTl55N#R54c>nw;nqTpXRtO&vInSu zaKBlbivX`eLSKL`S1WPGbo zLVkCVfUL``Qjo;sJu)9caT0(?xV3Nq8sAhWid(TFoyJv(Y`OoQ8baaunl44+cn%lz z0wm~>&rOcWE)UQ)_Ndh%eh-zUorh-&C4X$59$^Mq*z!4!MG#k4k+~B8Ykcjsz^VvX zrFVgT_O8GKS3v&h{+??sa&`jlwpkX>5UPmnzAg#6`F2QXgA1TX7$7dLEl5MGOyKcQ zF=I3>wRl0^Y9>tP4M4B4(>OT5wr0es9CNsW0j79?(S%3>z_uV#=YZ(}@He2$vjUcs zCu_1nN@JZJLQSyPmzazMqJEZ3M+r8@*qc7*SwgNS`$(>|`ib{hN&rino=6p_{%KW06gN43B|evM36PK`J`5 zVX;`=0d&ilIPUI1hkHCIF|L>~C{Biho;e~VWlX`%O}~VVXA^^A;9fV%8wXv;?zPvm1qdr;TWp*20MTm6Q=vT{~5oXzluMS|B6}X-L~_&5)<`w zV&|%cih3GDi7GsYer%0lY<{0e`ZZBX#?H&nwfN<~M%yaN(TA6k=IrdorRhHHxQI;} zuF7rz|4Kt_xn!=TT2POvJPAG+VAp=Y;3kL_lPsQZ$(S*x@`L6tc=~3twjIVEsb5bP z(eoYZSlv(6z@tV4=jzE)GmSHP=}BlFUCK|`sTAUQSg``B-7Qb5-!7Z@0E%9E^{EOw zPr_`IPbLT57)EHQcC4kOjbHT{hEff^nNX@8y8OP$(g%%HV$qz`gCKW|LVaMc+V#QD zb9=jKqMLcE%ps5TBBoV?7np%;uQk5I?#v=cjAyF4hXU!cbrOU2s}U+?m5BF(XJUvd z{Vhjpjkj_UMBOz%oo0wSdVPt3Cx%*j?mvy-C&bcvqqAedsd2kh5kw1 zTII{x2rz~Zvc)%g$LKe|T&NH1_EOv68lXl^q!7~wTI4q$uOgGAI>q7}#p(E1g;(hP ziykC_G^5c}HK{RS+^~p}Y(%YMNSJymF>|h^xI~|++^WQqq!-qE^I8_qxU1NSI`qPU zlixsBsDUf6B2AVi%oaw&CHo5If7SUFj;L;LDF8S4f znYRh1q)`MxCplLzVBoa0b4{mbx_T4F20SQ#+1G%gPAR#V|9Pcc~Kz>Q)zPSevlT zYPd{N+0d7Q`r^RR#-jyT$N24JXsnSPL~23l=ltsJ@i}gq%n#^f< zQhOraapiY+O>%-dGmiUXmj`xx45salVri(g*Q12HS{i~1C#aKKL_ z9U5!b+V2A0#3>b1|W*j@wlq2&nKiKtOI7#c$jfo0u*1Axh&Gk&~p-f%^$_fyc)VY`GtL&3`{>rN-} z?gJ(xJo@N3+~tAw@Tstvo+{)J!wB9aNB?jLJ%AuYq>H*P@%6{fXC+hfTS~pAu-WL% z4d_HNapU$$pY&6i#0cORX1vqzBfXu;%ow^^Rw=$O)`(Ix&>;vP%of{h8g=V@@!xL& z008%$?n;6WKE!OhZDqT!WGPk%C>T*D@?v>z49dopWw_h9^7-qqG9*G_ zB;6In#Rk4^IrGy57UO!-MS_e018jy3;0d<1Fu`ms{DH-Jy#64u z+6Ro28&IQH8vN3sOko`J4OT&PvmHt*{DcadD8a7O7t@GgXvN^*^{9O-tlttZ&hQ!E zzXFW1;j|Up!(Z)_t0|}~qFm}aP!?#ckLG*FpOH#rLN^n!TR%W$u11_5x(p{M1jlXm z4O#ll2Fw{}fuS)FJ70rQZ2(Np=*RE&a6}U{7KYC65jfFtEOCxR_JW0|;i8XsC}lYI z8>3Ly;dCQRh1Jr?P549-qpFpET}S)e)ZQEY`{&7hU+gmkl9qs_IMcj27JlbyJ6Mpy6XLB`h<&gfw@?<(`kVvTmS{83I$#v?;vf`d}6`*$L!zn2|9>0giBh z6J8_uZ_L1C*1%W7=BCtOVe*U=w) zhA~v=j0!1T(xdRe*V?f4mlvc4rmwn$y)eYXY!bT9KXU;OO!!;C}90Lna`AoXD&8e@osL_kg--dw>@8plo*{{r? zU7~?Lh8R*!@4F<>Ke@lf2ELLymWBBh%NnSOskt#IRnpIS;9CK<0Y0b?xQYUw{$=|b zU5#E!{}IKhi}&CNJvbeX8FmV~>TCv=dyCCBMo+y{vm%Xzje@HMETa;eB!8#|8=^`- zl`&CK=y?9qTUeGI9RC(8v$)da2uECk(}Bk&=~r!Hd+t}Cv8dJoWH~nECH5oZ=F#1+ zv1Ai?i7uMq7lkjd@@iP+ld!$m)E-iaomYpiEkXqiCSo&26ip?-2%ZeHHG^Lsdpe_= zl}wZ!u+w;nHA-P@@eJ4>!-rxU;t#XPrLTeEeD!DIsg5;m8J|U>5q4xf& ze3RpVv6ug-ueD6+UO2)OP7m4I+uvM;$N~)jt}EY6(#Tc7xd1yqiw*FFH!0yx^n21} z*N3%MyeFWZ$41!K1&t^GII@$7!v*tGb?g6hXy~HjB=vJNU2dPj>&)4J3+Y#gJ=NX( zR4+haL;zam#-P$%iM4tjB8$Dw4pU=3NVno}$iU7A?$AfZ`4h51gfTH(dci!EyLKgv zJ$2l0t7U+%HNUb~RvwPf-nx6%1#nzCR0DKBHRPE^BbJ=V_?`pb$`F{XT;&r|tw%gZ zy}_!O?^G8OR3qEz^-}4?BiR8oA=?eZwb;FSt63lL7(**^%Wl{Y#@w4ET{s~J8={O0 zj8_%Ib=q8%7t_gaX=TX4<(~Sy0z}PKOtK-GRxu})qQ6zL7H{Qr)11rqMjIHGE+vp0 zoq}jj3_5CC-XOTEuL7Pq5nF$IOXkbOsB+gK(93UQ1Kbu)N9n)`P61&!r5%3C*iq-T z#@!WezL)2ESI_4Ui*0`XXrg`h=B^f@f;!{v==jAFEK?PKwP2oOpyjB=8kMs{6lDab zn=YJIfy3?0;ZjB#so!-p4s2i7p#+891VF*Asjbko8%e!#99*)@bZ-k^oi(DT-U z6RHs@Y=D%9uerh)B6Py18rSqY7s>G<$~|mW93#1c`Wl_|H>)JMVi+X_v^sav?g6^@ zSW{00WdqtmQ07o6FF`=6d(>yA!8qLv_(%*f+LAzD;Qj$_0I}HYhTd2wKqJ;b>&`5A zh2i`%;)rng+Jf+Lv?3RLEoXJw#Qd&A^y{}+4lxuQlV06huGt}mvW55DE=0rCl<4yN z^+z3pAq*F|S{34nKz;BI!zp9RqfeO!4DP~dY2N`!sqr|*C4u6#)>X5f#}|u!%&+p< zjK4xWKd3B1e-s&eSAbX#s`KO-Ds(fmcwzkOS$w@|j_f_algt(QlnOKBh*d?GOWpZI zH*1E3zE%&!XSCFHC|=olAb?EvM?(W_4Z z1F7~R88)s+m|;;2#|Bt$!4&i5VlG?<{R|SmR*Ai*-ru}X?~2)WUpOi3XRtMVz2&R& zCxnuH0_`+oz;5+!K$e1;owFA!f1jJBp2zRKQrF=H|~aK~$53>17&xGoT2 z<>d!gYX-u<#(JcLq^H?MQ$JaGO{~%`pdA-ZJKlhUd8Fjl$(0y`j_MZ01;C-5Ok^0X za(GasjHvg61DYvDd5G06_*(doP&MeMC8pIjJP6A44|aOKikff%GdLjl#pY@nCqIP< z;qkcD31k*#H50bcNjfZWHYRIVfD;@MJ2%H;?3K@SYGM~xZ~ECV4H;5Qa|jx z-&~EMC6y916AOT%=(6-ajzu+k-$#>=Gc$8tPXzA?I7Q`&EilgX;udw`nW+qq3|=dj zyOSWsO0X(!D@&P~M6bP{WVKu5N=+KAehmZaE7VFvsRe7~F0kvd{Y};u)nKKLAvGxd z`m@oReV{9|!fcy$?UVSvh}{Bw?@8D&LNF_&>27PfoVE_C`NHAZX@o)HXKjGx z)P}pyu|5DD3)I-!?UjkrS)5P7yemko$9v<0DiKeP+#iKXO#mz_#A55OVuqocNkf*} z^W9K@BhgxsJ*4QpAC8Z?Lr28eaYtLzXvMJ+BWg8S7l}*#%#F2xHVDV#)w#5w9v0Dbr2I z(KPCcd9YX=kz>=%6VLo^VOol?(>FOrz*y6KIDT^GhX;%?=5uu6o^s}5l^4sL2jL(3 z#XJs$Zg9&TbTW}x;wMdrkOO#rF@Yp;8?ZTxX$niz`Bx$asg+R4i9Q~}F&Lu|u_wth zAlDU*iNEP$DFhhmIj+d|0<5PorEo||o4g3+0T&~hA@>7JJ_^AH6+X1o3D;R+K#42c z5AH+pRME}3AtC#bJjV{ZWa27N>OE|Zdc~8H1sXklOk>lBGV?y%T+OFC2I~-`7)mvu zyd3`JMa@tTaoy|MObLxe|0wSFx}sCV4Y7KmYNrI~E&Ji~1{xo2HkCa|5-TAtfA0G-(1~dr-V!&0h^@jP!w6w0bilseL0Bnyu@-xk?>=)v`?AfGVV_Kc4r3 zY2-F8)b|WIJa(#gp-y}>+^2E_9;-`PDe~FZ2d0<_a1mI-!I<(@U0Uh)tZJR28^G1T zOgUW1UCwTUK^yh^P7vM}V1m{|bud9PxI%wLak>)846|?TJTo6YC;?_uFEK=XjwJ^b@3l&;a!>Xi2uZA#huX7AYS~Em(lF2F4{m^6sCbfK3gF`);0o{Vl zX`mH!TR7H^!N`EYxyxMf$Al~mG$3t|i0N}WUl0UmINcp1COP+Z^o7x(TSYS*RyJ z%{*rcE-^Rrpc5HHhdJX{)!qZEj$zEe_I>9p;F(#(*LPK_>HSbC12jiaO?-LYLVZEM zT`grCDwRz~!87BCLa)fV#=Q>bKkC)S)9X=H)tn_EF@f1ej_h{JoXF79{fK17RS9Sba zf_Z*9&9!xfQ%RKnUuPn^|wQj}f&eI3(?TRZrut#@) zCPYYxbFL|a))B(N`WPx(LAC0o(NyuO>bEQcQ(-e1D~xs9QTikPM-^t?6?+`Iy55NtHoK&Xak27P%*Xa&~HH`P*!WIaIW_%gCqSP8U&@ zza4G!3*Dt&@pJD|o`nZV5a_!0aAGe*Y4rrTyT!kT9q`iBLWGYg_ zd7W;rU0gmfc?g-Ea*IWF^w>@XCRZp2NwuhU;Rzw zhgy|~mcOAE(0La<49n{zeq{e4q0eT@@*J-e!-){v(~WCKGLPw)r|xy{$JZw#kp zoiq?>nEyVz=vr|yIg7>Z$S;zeV4LfGw^26ciL&vER)v3tp50zdi%}tCca<<{^|aY1 zYq>HNyQh}BXy#N`UW+~3EE`1)u{H!L@_E?>t*?FSsJ6W7T>1FsU5h`+JTp}}shN-r z-WOloCU3UoO@Agcti#i6oSh%;IUyXwLTPqkC?bbv&YFat|M6u z>fxEg60*;h-+3RFehQ1uU%6M%ohGa#n0d)lj_dR5%ELJ%vhAcwYa%MTy4y(iKpG4(e%HgC`PIZOBPH! zrK?z!vUPF3vzudliafp7BCyJoW7d*iF~*#{tJf_4{=GY@LKeY?{2$-1nf0{~Yru!l z(M^GR$8%bAQ{=sE7bmGzz`=cuA2tTW5jTT{6x>BIHcwwFN~uspBoAVvr!$4p59It>`q?O7 zXN{O!q!hkvf7?)Xx3#hV>A=15$E$+0++&EDt%g^rLZ8L2B%7LsW~Gz%@SH5R7@$cy zc76PnsqOFoO|0X!J`Lh_m8)+!BbA;Y%}|n(4Xp_Ed8Xb|le_qi7P|-8J2Pi#Kb(6i zr&zBOqSjCla&qd*eOu83M*9d{V_DIL=da*cSAVohg$}GR)MP3QIeGVt$CK*g)UGH# zLRgLObz%7=#VKsPBF*=;aWTKI;#YMn^1EH?B}MiCt@-#SncF8O)ph(04e9DAmgUFA z)>ohNvCsbcBBH5K(Y{A`V5JkC1kqsYJ==vhk#!YzQ`~}X&e(T_J|xgTHXglLVG=HW z+x6Blhum)VR=I)(bhAM@4ne{=JJDT(dk8Jr?aHRN-fAmH`bGlqK$_icU&)b0-txFy zEB5oA{ciUjtGlit(bY4>m2wM}N_Q`wadOuZK<2utw&*rpP8N>2&lr2~B?c}DJTC@Vb*YFo(< z^E?#d;kiT>YoN(peM}Nrx#+;vmi%l(&5KGR(Dz*0W04v$kSe;Y*0wuktlei1wZ5L_ z5N@`n?``3It@_5>IvQ`|Oz+oWnWxep{biBNdx>p65TxBanRMvmpk20q9fL><(SnN0 z2C_L!8`v(jXtR0th72YAqsnog3L`Vb?akZdGEtibSyQN)r*a!|_(SST9y8>K2AW;L z;ViaVT5xMtxC`a2hG+0d_tO-ph)6C7ugg;?$*8mSVS}^t#WUmKWjPb<-*fKKx7Mk+|9TV zZ&q?1DqPMsR;^0wYOeJRI!uk*Tg|Aa)Knu99y207$$ zgRyR-?Gc;Hd(cbg>JK8Ba;1Em9=3BasjWifkbB3p>*{H!)@I@g4SCCtQnzR;btYB6 zmIE1x)c8agB?RA%3BF1q+&?4-=P5-js|71hnVw+N5h;{9 zk^?NHHHC5?yXMPQ@Hv%tw&2394gUKFrBkbCnkwbcnpQp<-_nX|eSYGvDxAihxx)80 zLMHsVgYW0)!l(wR(?R#ug!4s=yYC9XpnEmW3uhM`JkRduM;-OCkl;dQlgWZ?>a0YB z2F+6LTZXs#9C>tGWs0=+jvR71F8-1p*`@X1?QebG$wvGNTS1?j3O^2n2U?kBZ~Q!r zYn_O!Tl|Seb%&gX6od#wiRXn($Bp*qq=7j&dHRhmo}tdwiH zV&y}-vhc(G;#9NoT|=(VS8tBO!vkr0O?%Y>?{67Wj+HSE%63h^fBeel(A1Sndir5f zwX_a`TFC+Bv&a@!erLGcV*X1p#?kS}q=Q<8(S7m1#F1%$&wxs!{ zpM0D?;um@E88k84gQ+$}*VWTtA73E*@Rr1bpzS7WGgZB8jXl`ZZ#?J;G-tD_rIE(y zza9kQ4E?qk2imG`il5AUQ+z#?)mPl$XqH_RUv zL`gO6cOOxtlpH2>aLqtClGRj~CdtfQ%}MtoZNtraU(b;7mERP{<$jR)SX{);GUKiw zuA0*RaZp9+<=4|-aQ=~I(J{Jt_$0zlp>vFBlJSv|2-%PZso zMX*!;jqZN&+JsAIR7)}+g%kX5n_mfS&OH_G^)jCgd4P3I0@N7b@)J+p-K*OC1MVUk zSQK_Zp;4x_L*jT=yjrQ!W9jOPiE2G=)8T6((ZXR(yhGW$7fIx|WW#d?N83(bu5D3y z-P~FiIeexw?4WDre$bn}HR`WSlW8SkS2Z=#?Y-PT2Ro@xk$Daiu83vsAH$R~4syEc zpR{8m!>-k=ri)#%?dq0i?bU7UemiopH0e88fprODJKNTx9#_iZeq*fol|;F?oS4{| zrh}y}59&b}ONk)4@UC;&(SBIzQ`K%SChJ>id&J&mNzdPv4vZTAg!@(T+8Z6<1$$lg^|nwK@QW*PB%z|7*>)qWkmCPEZ+9B+hpd*!_=gN zN3k7jE&7dL!kqmqzRO|naXKh}!jWyO4^G@(JG9J#w6pdVwpmunnf*Mf;X~~Vj_C@q z4c@K07Ch0>{dC-3s^B?2Y8!eW@bYYWx7)K%a=?4scX`+|2cJ%%A{OcNEMJd@>%Nnk zpw%`s@4wo@>S1_|+P6#YHS1w}z2d`J!#7SL&wjkN&hu&Xp!NkDw(guF)L!=<=8K{_ z@Q?Pprm&B-!;zPKr7mK9?kb-R6s#Ax!`U-v&wB|+LlM;$@cB_jgl_Wkg z%@(H1aZbp|28#w&jf8V@pwHCDJ>3j~3);E}5470X@8#81;ZhSvqA|WpYyoUEQLJQ~ zQ%P5g!L^%Ok=GxmHa#j$g(f}&oHFM^@`DBqmc{n8N3(lF+X?izSB9|s+u669HMe`< z0XA>MgY6T?K)6+5cg@1N*k}jT`_O{?JO+71C>i&jmv>w}EUpEjtQP6rVbjjU$g0Jz5Nico|y8nLNU&sO&(;rtV%`A~Vkd+3SV~ z1=E_H^r*p z2~v938!F3PPmSx>t_vlWq+6DRuNB;qci1&+b5+4qW^WkpGmqScv0#?v0oEi&MMFNn zS6abhaH~>e=MuoGD@3wc*u<6d4K=BW4xQPb&Zds+nN*AHY|-8Gw7~zWUh-|BEtRn0 zbdMEFBvU6w5;hzZAsr@_7yQp~JlC}pah$knNz;jE9yz=>#dnRdZ`e&9ZL6jFeM_@@ zRaEEx9Z?X%dPUh70J~h!>v?KcNt+Z5x#bpn1tEf2T-_w`CbsZxc;|k5O(MsK3Ui9N zn|?jMp_}^+?z_C_(tp1NC_A9|p0FfdAIG&7)}R6R<&E1;D~W`r%KxCqBI^f%)j&5FXP%r*drL z(Ul+g`&6v;<%DkvVZS2pE$wNPF!@*OwkAS5Is$3vu!c4%@SybLe?An10Wp6 zcMRHvx~lN}<+DRy+zuFh(o+)1enUHbITsbE7TQx$H@3@X%v05ppl$!u3@|p_27uAq+ zz~`~=9?ZIKZV71XTv;N4_#rJ6TpAQX{MmvMW z(Me7{&%~TOUps8;+UgaA1fJjmaS=U>u1qcR^>KbyH%4II@Z~+Se)4Yd!kK3cp(xIU ziA8b+?~v5DmQZJ6n!EFmn71K}ME z>tpsH%~SW9S^c~2fJ0=B*q=)yYVRpqA?%IMbI3!XB5$ljE5hOdynbhlcfMRA1d9vp zGWxL1{qJ z0XXe`acD{4@m8xavoI^PFH<}|!cNVvSBWR{lVgS4X7vn+v%`)@m+`sjXIf`>$tl2q zR4!=y_FagU>>Ou(FDiR04{st*W-r#uR+(u;IycbBaVlLn&lmSmTw>*q@56X zBYszvyF1#VMDmtooQG`1sn!T!u6}}`@ip^T`^eE2`swrcw8Qd!^;hnzhqn1x*6kpB zyf3R-u@=&h5IoCA-ewhnR%e=oF2W1M=;z|gHeKtIN`orAR zVXY!xeBhxkjROQQrPLguKfZ5c=C)*bt>Ro3Yp-N|3RS;`Vx{$HED$oI8exj(+&`Z41q4jowg z`PABF{Zoe*MOMFLNNx@aXHN$!&=cP!8@S+IJxEs5E$_a*ZMPi%68k)DcF*T3%d1d9 zglce110G6#Xx0}&G{uo|>Z)3Ec4BWvFk`{zmub6R*IcMj0N&kghopYEs$k;fSkAep zh#YnW(IJAhk{4%PT?2{ao3&#vu~%;6nK?5}WHRUc(}WK`2VM8$ih1MHuH6%|!8{_N zSpxV7&l39IfZD?PC_u?_Xc53$Pa5E5A01^ld4yX^t78i4)PWzxr;1S zAIWM6a*fBh>qjQ%J=>q;72YrImSlC7T4Aj@I`5Zr-;ji0)MvxW(1vFor+LWDhf@-A zd~HIQc?ZThKD=^aAH1M+OY#xa^tf}iOsONWTtBQ!c=)h*I!SogO2J!AT!wwNUz`hn zd;huIG)Kp^`;E|3X?4OHs7WaIDTKfR-C;NQHMVw05ED11G2L^uM)VgLBVevU>yYN+ zTO2&W!o%_85izZvu0vl6AL{dd85`{m0KQDX&En0^RqY9tm0@e;jum@jd82HC<07d4 zl`~fhU-$5uiqfEOP!$a=2|2~OsqdS$?_MJYnBL;*yB!SxSI*b!W#-v&!+aiXk;*%k zb{=V!8u?N5gPxlU=sOKThq4=gvYtnO7dEhZBXL*42=qJ3#)k=-?@Tks;tzcyr;mzx zk8HL|#<>oCNYs?|?g`VB_?f0^hs@R~+vi_CE9#x_9pQHCLE7!LTf_k6N7j;MVh5fi zd}szH1_-G;(j8-6k|ya%vEE_c~ld1|Ly`6t@$Z7AQ2XWOG#fp#4oyN{2Pn?IGd z#7BdD0Nn_Ou3bulPXo596VIvfgSii5X5`!?Ot&V80l%-*(Ae)f0IK z*Gn@n6aFSCRPY+eH1~K%reJAois*iFR`m&_@o4nY7!|#5UM-m}U-yVj;lziq^q5-< zRSO}IiVMn@R@;xemW!JSE3D)0$)PU|k*yNvGH{e1SlJ z1mgT4{wP7S_m=1U+tH8ZN>>&7^t#<7?Ro9l>>X`Ue&yUkSNL`7viQh{%96OVVB#s3 zX#4z6x5a7$3AT134;JfR3$;EDAAW=gV}$Q_5iqmr^t?(z~Ry3fV?kwwWGtP zw#v@@$T#<)@yEd z%(0}LnV+2ZhH%lXHUA8cDS0>LT3h(CNxt&n*>FVPPd!p+J90N1DVAc%W3S(~cFdD? ze2?4yMwYKn{KFnT@g?-W&webU?5%cJ$hrFbl-yKLt6%Gl@ZrbNdrn}l+|y#IZ#@5q z)XxrA3+7f18~4u2s5nAW3p%;;w<+MeP z-}`u|2lt%!d7anm`5Nc-I`4CWqut`b(#`YRt%9ePyM)b8KS_H*>FQ-%df*Jo^~%yq zPx&U(?nj@Qr`@?lQD3ma@jwMFtn}%q%CxSN?|i@E2NV(hCf+`WhC2vlcCPEXSIiJT z6OK`9M_mpn_ho6dD4GlDxyxEph-Yk|HrL=baAM_%GGrai)swJa_d9)Da0^llUf7fi z7>SHS5kxql2onH6RF1vuy6tveByegUb+7~Zm&FF*?qNobzMteLS{rb>P)3R-sYl~S zNLpkZrR|da-5yN37XQA=PG#hwc0x@?x3^?ha5&X0)$e5z-1Im)-S;T-|aTM_3CND zIky8??wIZTAi7&L4Zy=LDlY>08p8bKW4 zQ1%Ki$}L*UM3r}fN3MqiU`!|C#t(VwVU#*`eKQc-OOsKB5n16E*o(6Yv$EMbcFL?& zog*=8QpMaFd*-k-LQ}j~_%CQCqf}~u{YV1#%%K?bW4{*W*!ot5lJ@#q2U#Br68zxF zP6n!8sUPPepK_zYIeJq+!x?yGspJC_OBr*?9w40Ubo7}H9^w^H?yLq{d1EKSK{gMC zDxuqQp0)ibQ^dpiX;RWf3PD^7YKxRV#J8@wJq=Y!;*zD4ooi6gLE{-0_E}!y=y9A6 zR+i~J8|@!Ur1^r3p(7~m#n7scohK*4dw4_bgAw=1pyb>HU&2qvq|CM_u~}No0_kK{ zFezoc8RA-gI2~npA8LezQ!IuEJ_B zuFzGiA5hvZYU0DgAXczR{FXEOykKNiwap;QsO0;Ot&mu~fjs>fE}HDo^j6pKg(W44 z?%!xLhFkQ;*8G@+DsR0tSO+Vwo9-13ycd#s~riCIe%Q+2OGC&}v1dFl-y z!m6pxt_Y1trW4-ryzXpd>PCpJb{HU2vGshkKa!5?Cpr1q#Z-hy2{-L5;)Z6#Jtd_s zcSkx@bOCgQ4L@9`?t}uIHzt99z7dTUPWgEcXojiS-mKCL>JCIiU=$Tx;vVrtPZQUj zgWBR1;#s|UsSJTL1Fn90!rbeR1p9vs!gIT@S6yN z$lWr^Gts?rpc6PvfU>)~Wi?C8HBYH}o3r1Ri?pvy&cj^g3N_FsKA=s--$>|+UR#rj z%x-f^w=Qb?o(U8w^9T^lXddU9t{7-p8Fe-Pz+}+gj5JMU`zbrGK}&~z85Xtx1D@V{ zE{b>GEm>*7+pD2vg-9W9FL@kfZFFQ=b(Oh~rVW2y*1|{Goik@$FIB{{4t4=M0;9=P zC(sAE?JrVute4!6UyAJH;LQc>0p`QzHr6L1g$s`m%}^8aZV7@NvI9+C_<%)Hz$`w!6;y;&4#DfWlU| z0XFS>(3eJm@cDqm7c7_A1<2qb z9f*cBac?3lxKZh3RZFtR{?{}%3-wkjy+uH@2l2*FaF~Q`bhNH+leKkj8;`UkHA~T5 zLL0mTt94dg(~3go_jC;==ugwH#eMc#^4v_gPS8jqgI_CPhUN~Dr^*cidmY^HrNTZ3 zsDICVf<7a}P6=fsO23aB><$VbsJm#w*bZ;Z>`;BrC0kbUX1?AVfJl}$hwxUKV1V3@ zZ(pDi3DS7p-|oVH)zMwv_*J;V!8$pyiyxK}6vo4$EJl&7H5KC~`4IE4zE` z+oUTcK=P43HqjBWPpw#|F9P7HVBx*sjR=bBFPgh2{L0Aj#3UpexDm4I8sAshj!aMV zq5Q$HrS73k*&D7R2|^-5yTt5*JZILef-57|1ObH2o0!ZtZ`K4*A~j&h@witm=)1Sh zfKg=;y_$X}>49y+_l=XU%F*J~V}75FU(!=y_-6o?fOXDWsr|P8;Di|}snnhF!06fE zU#ZersElJ9?UuhJA3(_+J+C4I_q(wrKg;J~`r4D9GMw!b5#kLo_wp*ZOx7q&G)|WCzcOC@Gt!-QVt~Vr8_uQx{xn;|Wt{oQK^!88h=NBF_`=zrXN2m`y0zxuggK9tTde>gZBsdn7h`O0RvjUW z!jpcAIF+1~s$YeD6gqoPX^L`sQn7@6HCCjvQxNn5Vju2MlyP_Nb*z0HctlG0DhuCsMt=c;f(Y(6_$RA%i@XCU8Mr> zpeGZl&-yPuPaMkbbYIi*{DN4NC<|agc&~WLDRKdh#Ehy@W^blv!!$F}_P+DfljMg zFXN>oHqxot1z{?y$>Yq(SK(b*1;9_TYv4`OHY_<*58@Y%?5rw0Wg#GU!7_w@i>#(O zyHcr(CIOQcF~|Jc`cmj|Zjg9?v}l+124j5{P)oI%G;Jz|ep~5A^5#%V#^#$5hh)z( zx#9fb@^cMgVI}d60ynCZ!x?YdS-?QqbBNM*WWWJLnDdy+p+E@EcXQwY&e%;zF+b~1 zZ!WnWN-kLeuv3e=Ts?TuHINNJxxyI?r0?n@f{18JZVS2nfpVqGyupeD`AuZj;Z(Ji^ilsz8e zMcQh(X>tO=0XD6&*t8RqkfN2H^qGUusXX!CYY#lS=tR0-nhAL@k6i~VI5WWm*Y@ia`O+9?c+8X2# zY975j+?$i70^%z z31@T;E_Mo3CMaWsgoNdKzSJ->E_B4P|;R}wB+ZL^{2KIo%<`WF=R-CIGA z8HAm#Jo82w@3mB4N!FBy;@g}8(=DR0Pq2#QV~ZdyD{7XMLReuOXe0ixf+3JOP;#yr#c5$I z*#Z41Ef=iiyW{-IU^eRECLuXZ%9z0$ReNDAB&(b7*pM3F+95FysfMo*tWy{zW!Jj( z^v105=Pk{cLf1%kx#1K=93cH=?e%;GuRHO>dc)j1(-}jpe34tT4d)`Qdx#&vT^p&r zg%d0ET8K@W>wG^VZ>;wpn|oheg&y#=s_u@pMdWFmx(|=33+WddmfDeXftZ)Z@~{!o zA1c9vA}3PORjLqqCTFWfwq6o-N)Rr{I%F;M(E*JR#XWUc+UGq753E;=twGQ09LCq* zbOWy&SKbcuza*w;OiK5>j9JP=EMfX#K=6*6a&Cr!?}snvu=?~9R;#e+3KQSS0qwkTrUjq^kL25x_UeGM=vk=`yjtgO7!yjl#Y+ixP zu+5{aZ*<&eJseZVYmfsm>MfHfVK*!t+h{`RII9by5rk5#i0djz-2U;`yKnF221Ry$ zZ(7-26tpt=@okbbWR>t>?XEZZgQuKTITNS{Qp-)gR$d)k`%ymHy)Bec&W`#gmNaj2 z%C8^=O|(weuqy|vMKsD#H8{LG@C{BCsmBEaMN;VE+9y0*#T?yUNY$so?G~t{7-{~( zLx?!BZbf~5njeRjqe^yTp`3$miHP^>gl>ha>&1t7pDRx$#IPb|M2J99Ux>q(7a`=^MJh zBD%lm)9u0JL~-a7zw1}gUSD_l`7$dj)ucYMkK~PqMwVa|6z%tD0semJ9f{3#1+WMn zR$uS=r3Z+~VG5E{6uA})lu)S3HV~_LU5Z|m`G@lYd{7Le$+-bJJz;-9q!WKlVYA$V z1eKhSp|(k)S2 zUN+_D5Ij){)3xAOk#R}#d7n)PQm#as?~e{?Q!e&5`f zX-_vE`C7{4zC87Y(`k1$a=dwl?F&WUT*3{EuKwd7!pl}S->oPqDCAihljMnB8zTIX zlCpa9?WkZCLdEs#s`c!_3C6$W1q_hUbfRA1`Ou+5RctWLVNRa>&&!g>X~S*0zvX|{ zBjR{_pZ#QkS|pqyo3zs9PUWZA!*OaH_b$w%iT6V@r6MsU!|fsy4|lJ>uZ0Pi$qv{z zW$tHw<_?~^s#FTghaQ!lnqDREVRV``LsQaVKQgZQP48&%UM1@z-Cw0aHx zLj?$NMF1vWwBa7R@|)$Uj5m#6-);ELs*{AI^^N}B3-E29u$Pcr>&`<1N0Z>xXF-Kj z!~9avhe@~60`isAE;*>JajmKDUg9?v`a3O1 zEs}57&-kZhmxif~_kfiFu#`M)C~rJY8np7KCslIK8*psMp71Uf3mA*~-Nsnpe4&kl zsOexBUeCYxkYd=W%K^;|FAvu?46d{a-lgw`oK*>4(hUSj4~ zdvo;8z@EVTa#}#ljmc=U{f8heDALQ|&B|hWOjWyqePa9a(I$D6bJ?k~#`1auB)e_u zj}l++=kgG&G7gLZY#l+{)~erCICBm<`e*`)dNdPmbcuzamIoByxO;-ARx4RJO8iPw z>@&;#EtBuF%<{CVE)9gs@6v3BduZIL+O6E2q>IGJ7i;6gA^Q0jnasvrlBMWOJSk1m z$#>{NDmI0LiBEz@sxEd}mML3t;xbnztLlsoPbaUSsxw4pD>7>52Ki;$>4bls74Bc1 zyce&``z4pF_P0*!G$)ns%OO?4MxV?SvNP8S4DitNh?O> z;68r{K3N+=Gf*Xh9xP|4lHUFjN9K>uludxlSP1q5&hq$)-r$QBV00!B*DYQVR+A{e zLB0-RSaWKR1^r<3-=$rJ`BZNxiahJ;F zb0+8-aZs>#Ff1NjMPh?V%Z82nWxAE=S;l@H{!{>h(dOo~^8L&_^xFqE<21!PLD-h1 z05#g2Mx3sh?n33JVAXVtZDMN5du=IU166Wh!LJuz1{U0u+;!>0LXn{5WmKB!JH6HS zlFdx4FH0tBXL5ag57kAjR>EJR{Y71;;k1uySw8d$A5*ayAK#oF!+xjt8yUR`wkb@V z8c~Mym~waRSpk?q<3Ksg{pRa$w8F2FJgWe*R#G7vZu~X+83Z&FYjXsYBw8Hd@MM*ZP{7mXQ6HkamZS|0{p$OV{x9R z{z(vJLLkr+yj&P^Y&6wnRrSn(qF>@EfuBlQ(G_^FjA)fTWYp31qQFL_H1%{fQ^43Z zmlnOtbwEMnbkxYPd`#n*NSi9(slTR~I^>uw2vN7gGqQ!rQf|^e8j2ishUVEG< zh<>CmeD=r^Rw0rjd8L6lM6!SuwSI9{4>*VS^7!zD;!C&P&T;lH_fT*Sa%w+s*lAVW zquue$&ESl5V67OH3YsqKxV=yB$!R*hRcO?_sO;%d_}T6FYybjx%cub$l{ z%-`eV1Ey)fA?jiN1UsHi#gn-xg1MCH-`*uxPi%cTK3BTC3T;EL^5=Zf&XTXyYmkcr zF-R*Xk?BW)Q0BgRrWZGSl4^cp_Z{as)3QFsteJjD^vmLbj~)!tV=GUxMy&bsnE9X? zb`zM$>t;2YOBv|BH2Jy3#ka+=GsEbWeElC@9=(7Q6V|>pdiRA=!a~Es@wv* zh%dgU{k>qpZxUrPNj~qo)LLnC+|u}Fg-BPz{BuKG>EzPvS*ZK{=+K#JLOKWM3ms%) z(P*Nn_d4sAxi>JDZ%!1pYyIxvOHtzir`Gy*O{%gu38+N+#Z0VrJxa9ovoR&5s)x;P z;dt0iVw^pBeXO_i&?~<^Rma)SpM~=AFh_WEy_onBj*u08kzO>a79W$hW@z^D!oV@1 zM&zC48fg%yfeLfI-TILw5(Bcs?+af!3gWO_b?;e~6)*D1ufUIUHchVVPdOATh zo0yZPvN46zYFf#zDVwp$$gJ|0C$(RCq6#)Z5uIXwc*^gxdAyH}1pea(tJmUFn23Kx zRnPs@oxSHVigTchnS~8XMvf7K00@2Ca&B0&FoGN+Y-(C z!MB$F%@&L*9R!o^Rl`I`nMNNqna0thc8C4Sn^HkLRpkwq7RLeCiC%HR>8v%qgW_+K zF?Bpgeg`H%jrv~s#e!xUr6#aI>((V74qtwyB;g7afFjDBLuBG7UpcAubhgR`KsDG= z08%rTTG+C%Zt^784nke-@iIWyY+=jPTKxI`(oTtuGg+QwlrddSSO(+@*l;FPg(12P zFw#gx?mg@!x%mv(Og!IPa>ku0jeSJYS#7$ApvazeJLpOy;k8f2`IT9;z6lXN9_a3MZ^a-k};KOMgRz!PqpUdx(pRS*-sbn4Ko*Pm3&8{WK zX0@p0X5bh%uHaocFL~EZrjiN}PIF2)!+24Yc3j^`V-S+1XWaEx9s6Nm-OC!(J?Lu6__TqIy?G1m;e^rTvX5Qyy-mZRa`WbWJ_1-ag{7tycGDl+-IH9QR1Tw%^#osmt ziVBuk0~i5~AdnvUjEyZa4xD~7&|8D-4Uvh~BXv+V$h(12JWWa@%wwoKu~nbGBc)*b z`&UNSZ$j6sVWtG_gpG^k3r4dl9;UHv4}dRq6M)5(GNpjw;Zy@{2_wdAJk?PHTS``eyzZFSw z&h!ihZ24gonz%plWLeUTaTX`L=TPCOczHfkCnwM3VdwguM8+cyw){IYU>_%+jP)4=-&0lFD$in@pLme~k zoNZz}I$Fw{wDJCR@szSfggb9n>u5Bdm%Wh@=?|f~TL-;j@5imji`H;~(4b~9J~3*~ zQpV#WuZqj}!;g?(VEd&ZwhC4-DbzZo)hdNQ5~KVL6yM|3m;k6EY1?*F%s+yiRpoj0 zI}Ev(H^i4o`=3}DKvBKG>!s#?{ht@M>Qgcd3Mv|4 zwYe#W4E1roS{WXqoRg@ltgL05c7weSCrRsvK&0pt#f2&{6lPzPGs_B|8aWc} zcYrm#>=LQ6N3D;B3=L)x9xPNiFxBHkXS>A&8aV~0QT}Q6f!t@IjOH*A!qJPFn@i@j zPUVf-t2ROFKFQmgxCvwpY(E9e>oLp`|47jjG2C~)GYY(=kRculQVmIMQ(l5zmo-v| zc9xd?c@AF~8NLftlF$~J5ThD1+L3Dt^VjkNX!(A_6=Q-X9@^QF(%ZwYA3nQv6Ck|5v?` zo;*65r>s&EMZRGvQ5=#TXn~H!Bs}GMoIIsX#-%sy#k&Ol_Ao;WkBB5K;Wu9mLD@tq z0?4n>5LCfRQ2oy7BF^-9EqwI}xA{-vlk=Q|#HWQP?E@);^ZlkEpK+t7%}ZkI+N=+f z_LKWvd8Wrxqu1dviC-u)wfRqql`-^FhpJE<-kg-fbXLG9z82w82db3lI#H>*A675;=dUYx9ifs$Y7I7;sX(y-~?WbfInR4H>b#=jmI5wHYbVp=XJ%pkm!gc2s_2H|+Q;+%}wsFP=mPK@(@9pzxB(AD#9Olk1c%FU(qwP^w zpR$MVes-GV%K4YsW4K3!1jG%vY672<nZiS!S?he9oovsUTz{YW?=C@;J#4qm=RX z5VM7QW@}BOWjr2P@fpQvkt=MDHt?RRbv+vRC zHH}(sSQ*7quk%iH)*^;-W1_B4h5h;6+CTYLKtwW8&lq|6T(_ZI@iSW zt-wY;iUKRb(0UxTq6qM+a)p$olVhTxHQuk!j*XLam=cb{ap`wSQ^%K(U;~Z`arW|{ z@gDIuNx#G{-gKrPA|hpR?1kI&Mr~--v%nk3*8~q&<L zc5j>`3~?^#CoZV9w3+HY141WeP%o_6rH2D$da>Di52ck)5txaVNGQca#DTK>*;kIt zy#j$O_@OjYx@!-KQ0y17;^$}KGo*opQ+`HZ_hZ=I zn8rTgsy@68F#&|>e$5!lfym*^75bL1B=fzWwWu(%qD*j!YrcN2>F$QB;;mBC@7G1_xTp%jIDRIz>5el)XjSoV=}m6xE}h@hh!~FY0PuCJ;b(YWGO^qtnX$O@wqrc z3|>1N7hg)-gL%M0et}Kn?HDor@P>ooMi$aRtb~mpL=|^~Z|~|qg!84Vn0~+OecYUJ z9hxLKs0_~@=xsy30TzR9>+$wavwNmcoj~T$Q_BxtUwh#GpjhLYH}5^XD@z!YliHR3 z5@ysQcPg6K?5A|dRs&n0i4BZtNGFpcojgM|`Sl=WNg3(xSt2Tqye9MKWlh>IGE?`) z2Ju0{7e^Q3Gp{%j);Qw`qUyRgk(7_sm@?-vJE-+}81RGD<*n(S)sbHevL6l*>BfEamLER@-EiLXd#yx)at6qvg9`D&_OSXONiu z9Ov*T@_m#$EvG}-qR>P`g_mgKMWr`>X}@OZhubvFpkN{C^ILM@oe zZS=`5ju={Js=4Z^tzg`WB7H)W@dv+>a27ZYi&{_4VeIVG4iX?-qd|w=4Q-sUg8AT! z=w!yN=)yB?=;b+yRQS`*{XQcgU#Q0~@4H9OYS zxMEkwz*3)T%8upZCymba~34+qN27 zH_)pB!kgF}@TNT26_{Ol!muzrj6d_1oSFXs;_fg4IXQKBl*33#X)S~~l5{#J*tlY% zhUq|l$26xx+4xsEk>K=zYhUIu(S&S)VAi^FRYCIT!{Fc%nO9CM4Nc9Qfpt~^y^3(K zw!0g9d$;s{^OYskv(7)^R%GBOWL%VcCKtTL;LDTc1|#?>LP~2gz?@3JoW7h-f_@x+Sy>ucUW8r+ zVzJLs+4i8<@|7gOwzu`OO)S;sZzchls(w?VAl&6be`l<%{QP~Q^z%(K=;cdbSB}a% zR}bRpvl_hcB&z!aS2i#+zzyd#;5I_u5h{xJpqHsLbzUiqUVh)pWtQA1bH|Ns9J?Xt zMs--@fVbbpQ6Hx8rd)%EpL9U`Iy{=^;dF>JUp;4xds$L*QSv*5ka%`bb^Sz#)aQ+|BqoO8R6(VDDh zASW-jQT^nAC+fgIqtnJ=@gDek5tzb|L_#a7_S%-aZcwJmi-!nVo!o`)C1vo&c4;_2 zRRV!qQPZ1w(KM&?x8d2!jw@1OPpgi_X+)Vk0h?^o*t`N8y4ryn5p5);oGOyW<{Z!h=mfW543vXm0^-Va?x|n>{ zw;$c|pnWsuF4(4MO(Ng%T?z~l%+-MLYh%*wy zN$f$;2**WFAxb&P<3-VQSop+09w>oRL`laD4Zy+k&3D)dLw1fnAdMn-Pxma zOJy>>dPFenZ8b*Ud6b_2?xC(wCj29rCh?T>SvmUI{pcCON))nc%BQ7e22nODwxi98 z_3uq#$P8WfYnd^fu<~(sG@5Ug_$r2{A{8JB)fO{_6~duQS? zUVWo(mnAs!XTMEr=Z8wYEjZS;vnW4aV1#*yPQC6EIHUDTOkB0rubQ5Rf-Qy05lg0NDXPFyh0kC)kb!vm9(wZeq0bk~hGcOHDn zV3!f>Y*E>6_`Yv+V>)w&$+6F$nyC(%s_ts*YJFX6I}mbwEu6(@ntHT;=1YQVCRZjQ z(js2BJwLt<+}kt3vSe!PHCXK{*!ftUyN@g1lSopwBSF{SL`_U$qo~cx3o<1z=+8C# zL$}NJOl$&g{?uJHG2V^PWB+?TeK$AMw)ZC3PNvGK&Rtj#Rk`!SJdrW(R|lknAMNJ+ zctg%sUk#kk9t!bNU0UWW$kM z=1t0I!`Z?0Da@5__M%KRG?v;Lpn3jwx@x^}CvV)9hiX3!ff&9p-%`zwUsLDKg>)1g z-qAIsusYm?wCJdbHBj{BS{>QFmBK4nT+s$)7fyCn6B92rD^0HK8JPM63q;znNy=2C zlC6_5RmV|!W8!{K{!jPV<*3k~Rgf|@7w<(?^iCW^ncdokqUc+#r*v82SG;U$HEt31 zh9`pb;I0YkxL;M(g)SqbQ#H3|RB=Y#OqopQ1X;iw)wbh5m~DMNxy+>mlJ>0>ZaAaj zgZ`nIPa`9fTAsh0BjYGYpPsaT>)VXBh`)=A@kIG?mO6Ljc3Ao}Z~n`nY4`7?AIzLw zVrSHGRyL2nnDg#@fzah0GJ9g8=i_z3>1O+8f}WPKGn(6dLq}(7y4~{;#fL3nOT!%5 z&{2h5DcceDH1f=eZW+FfJ&`hc$3BU{_T6aV++P2$HFT-!I}H%4m!S+CVgehTZn35& z^Ud`XR2Td3&Ds+kW@d5Z&1q+XU?d2+OyfC@hQL&WH4Y#|WryYY!czh&HvxYZn~) z1w7_nw7N8%MFJ4O+Q~`u>_g;`|1pjt?w1-`-^XpT#nm0s;JfPc<9Vf9>(NyHYk#HK zWsaXds{2La>%Gz$`z?CYchr9RZ`^o&ZiNqz(hn=llzwYShOO$xhKNp|+IAGcY4XC; z9qGbp; z)wq!TXB4DEW0l`gWBYscOlT9ZW>MUTJ~fSlwd30|jee^kJK#Xr9RQq`>bjd!LVGR5 zrw85r>VvTG=dTyn=R*^v%Xh(fY|Iyktnv>%ka~mu_M$HBt_~V5_b19oH`BN6Y2tpR zbl*PCFui45UwIbxXjxTEg7sj7+}Ejcrb2)EAhCJ|xvsL^42yqQT#`&ZZ%(eU9ja=Q zY*E(b`fcL%LdXOgOiPkDkeu-X(Zj*acCn|cqik_k#PjPK**lZsjAHh^f|8PSn{Vc0 z39<`;{0kt3e23n{gJn3)E&fvN?N8OF(b5SEdigXT-n4=5zgs)@d)dV*L&UCk4yca2 zpSARlUEsAY`+Q_Kv21btlzWjb&RCrVaMUkWQrf;=Qm8XG?usZFPi!NrF?Jz;>$OZ`7jz9PThZ>i}gSNy*zADc2M}V zC1asR^}3DHYHQ&gA6rQjIOr~A{~+VjQ{PxW+vsG5?^p1=pRB^M)NztmJ1eYnKT%pc zUJ{3N;*TE^vz2LX4?$+Mx7(^kp8VPvEEC}PIY^_ui!ay#<|L=e950+Y?Xfy)u3DRS zShkKB^!I~rqD5nejj^Wn<%J- zlj;;0JYx6(G;vwTeUJs9a|J@7jT>rwoaE1xDG@;7J8JUOKK9|zkr&P+cC+BnYrAep zX$O!|Nxc+Tw`=|`wBQi#5l}d_|8%anx<%WR zH{VF2`%sXCK%7)rL3_ke?Uf{AKSF|m^JjOpVI<-m!zYR(18YfCk#!lx#i?LU)9e=wJ2Ke-ok4AW4Z|j4FF#peNas0}|CKY^H zDn2}i?|Znkrc3%glY3Ob#a8KjgP)dm{Gu8G2`3*tNOn~}?adsK&RS^f(?*}-M;^v$ z3oV=t*$j)&nvUHb&*ZkaU(T^Js+G;#>8oiowo{*6PkScc#LswM_k_}K9=~&rbJV1Q zBTF544E7!_nIfqI?e@0xK-(4mBQ}JNQ=$l z*BEMiBvYME+>gL^r|GmOV0YU+lMD06Rw>>gENzx>p`XDeHJ4zj3UYVX{(F#uY$!W; zP=o4`@dne7`&bzyjl3A~=xcMTa9&F@!y*n)|G_hvOf@rW-v%qs+n3Vxv!UJi^u{^7 zKnAM*Ir1f`oU+N+b`sE?Um^j9u^xp{t1J#m4K>@Dy^Iu90TYvSCh-=VU9KEf(xuLH zeJ6MO;F+~AiR6CZ>2Xz<@%60S8>lfvp?bm991U+77Ki}Qm@bJvYa`hEhy^xIBBSA#;+(fR=1jZRk<%xUjHwKHz@bURc7SP2fXtv5A>ZiCTrMzQ;M502lTcD|Cj zkgsa;+QM&9jCUyOA2L?(@R<_LnOP4;Iv{C4hB-S&+7nj!Ekz8A6M#c7Nz}8r^rVHN znmWFRGXEHx&34A^UV*goF3h-c1C_TrIzE?Ls=l3AT{tMC@1rsLG87z2{w`LsX+P0& zb^jmg-NFLNdHYAhnz7e9-$aAK>Y88g-(PhE9MS|UTJ#iEjuR~u$Kst!U9Rqq zWe|#YQePcD{#JmMtN2U?ZyYHPr3*QHHVl0}88zJOw2f=3Wms&i>2L$s%Z+W~>vSFZ zRK`!CQmMT`Sx5aFL)p1-I zGVQ{N{tvd~)cxjU2Nwsh}&wX{d*i!S7M+e7vxwXH#a@xoDl0aFhs(Ujsy&OQHw|P1cTfc?iE5{p%bJ zI$tw>xq_RK5t|LFF?6CE>dbHgBH!df^u&I`d~*-~K;c@m7)zCHeM1 zLB{U2op}BJdCUjXLO+9p6N~g-3YOU3R-(Q=1rg}x6EMg^{{ztO>p*hqk%X{mJC)ju zlv_uM*bl%Mr2-5kePM>G&zsjmeu}92%T$RnN~isYac*m}f^1Ssza8_=k&a<+kC9n$ zk*CV`3t0T-C^M9I-ux9fGh5YPV(4h%7W%(#H}IJX^4t|-7I&xvEKh-820P=HTzQ$&uPsp+90%y2 zxqVc9;}Frq)yT7%Qv6+zaqtM?WgYvT+V6X($zM?*(=Ya$6Tz4Uuu^bDYevI90z${$ z;5408C&j#kJTV>5RfV+{6gfTq`4m@Rni*0o6=n{SEq2U@{OQCO9-m136)fKL?(|I| zz#DZJhghr9pPx8f|LX;$$B?S1;FxMLNgW3}tey@c$2rG}a5R`@=3+dP^L zrbw>tvQT`a`o|S5#RrmK(tzf$Y#}XTYKnl>F%D|icO1`c|FfoM za_3h1@zp601qMxI5H`dzlH*pB7Qz)y4qDsO)rL(0z`rMU`Ha{}qFz8+;ufNZGKFRk zKF$9e`x&^2&P5K|m1G-zKk~a^w7QFbte(TM%=FLydI4cF zRi}pekIlzwhH5xcPkmTabq6<`LA&;9I!Zu5!2xd3X=3fH@TmW9jvQc)?;$xNYjO5g z96j*W&0vWi_hZ!urFjple)oz3@p}}|s95LJbe`X?9Ql>1|4myW%Bcv%caaFiT{eGya1*kf$cLN0Cs2$`(IB07D{>@<)mwNJzfBexDXTv0!y5)x#xXIQ^TZtJ(4_Xy$=5$>q14OG_|6;o<2s zwp$3`kWD9Ff(**z(}x9q0t0Gq0Hlb_a2`Ki%iTszJTwcIP6aHPOw(~F`9u9ZJ}|>E zPaHZcoZR(mhxM_YDTru){(A}-tuK6qFEAF|wB`t+u+n|{)90J{gTow&72Ie)K0Ue1 zCKwjaYZHBH4e^!$UtMo2Sbgx72CPy~JyE|4r=0{@fT?3+6(?P3hd7>ur5&e%tqJ{2)ghpY;Nn2a<3HiN;0*$CzH^irVvygk!=q*g4JZdv z*#0&Eew~jVG`RYwf!;OHfNEg%#vcQhd>NmKHa<*?BK&tCfV@kxQjSz`^H%t6JMjv% zz?G_;IYWehpGZw0el=&v^6#%u0`b=h3Wafh0v@x1Gj6l)tl~_pe+GndW)pf;(hSVR zoCI^_<$u~`pT}paPy4=ar@Ea9X)*C3B~|`2U@>KX5SnVBNcQjVRQ*9xR0An*j8*+X zFv9ki7m>Ec8~CywLb*m+3)ZSf#rw2N6Qz(okcK(oRp3OrEHNe_Zbf6j{`)WV-%jUN zkd%AQIn?15tBrC|`u$7YF zzYS7BgVeCz^M4yGg9fQ#D}2xXG}sLW4N}5-rT!8&eX&0%{Nlhk*&hk4T*7Bc1|pL9 z*8ngeoN6Ha?*o9<(wNd!0N3>D**Kan{bgX?8864kS2!ZDT z2ma8-i0_Ti`PKbnwlUKT$c}SMY^1V5N$S zce+AW!OY*kgCU3&c8kP;-x9EiK4lf&3V~rgA!1G(8!iF<{G~?u_n+OK2a@kbgh}7{ zLm$!@OlUJ~#g^lb%B;Tt4PwKZZT>c31`Qm;S9t$6m?8u$5u)@P|AU11=$G1k+I}T{|0z*#w}1{<<5WY0R{DuFKul^Gp(@BHY%l{i59j}D09*$0GC$kD22xkE2{n*X|4oMz@PlMr^B+I(?r8v3@o$nc zjILXrnt1q|GQ8|!VBX&&ev9$X-~RXC|2XhJ4*Y-SKw##NV+lbz30oDh{*!sADrzZ| I-Zl&VKkc6&^#A|> literal 0 HcmV?d00001 diff --git a/style/doxygen_manual.css b/style/doxygen_manual.css new file mode 100644 index 0000000..9ce2ad4 --- /dev/null +++ b/style/doxygen_manual.css @@ -0,0 +1,1114 @@ +/* The standard CSS for doxygen */ + +body, table, div, p, dl { + font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif; + font-size: 13px; + line-height: 1.3; +} + +/* @group Heading Levels */ + +h1 { + font-size: 150%; +} + +.mytitle { + font-size: 350%; + font-weight: bold; + margin: 10px 2px; +} + +.title { + font-size: 150%; + font-weight: bold; + margin: 10px 2px; +} + +h2 { + font-size: 120%; +} + +h3 { + font-size: 100%; +} + +h1, h2, h3, h4, h5, h6 { + -webkit-transition: text-shadow 0.5s linear; + -moz-transition: text-shadow 0.5s linear; + -ms-transition: text-shadow 0.5s linear; + -o-transition: text-shadow 0.5s linear; + transition: text-shadow 0.5s linear; + margin-right: 15px; +} + +h1.glow, h2.glow, h3.glow, h4.glow, h5.glow, h6.glow { + text-shadow: 0 0 15px cyan; +} + +dt { + font-weight: bold; +} + +div.multicol { + -moz-column-gap: 1em; + -webkit-column-gap: 1em; + -moz-column-count: 3; + -webkit-column-count: 3; +} + +p.startli, p.startdd, p.starttd { + margin-top: 2px; +} + +p.endli { + margin-bottom: 0px; +} + +p.enddd { + margin-bottom: 4px; +} + +p.endtd { + margin-bottom: 2px; +} + +/* @end */ + +caption { + font-weight: bold; +} + +span.legend { + font-size: 70%; + text-align: center; +} + +h3.version { + font-size: 90%; + text-align: center; +} + +div.qindex, div.navtab{ + background-color: #F1F1F1; + border: 1px solid #BDBDBD; + text-align: center; +} + +div.qindex, div.navpath { + width: 100%; + line-height: 140%; +} + +div.navtab { + margin-right: 15px; +} + +/* @group Link Styling */ + +a { + color: #6464FF; + font-weight: normal; + text-decoration: none; +} + +.contents a:visited { + color: #6464FF; +} + +a:hover { + text-decoration: underline; +} + +a.qindex { + font-weight: bold; +} + +a.qindexHL { + font-weight: bold; + background-color: #B8B8B8; + color: #ffffff; + border: 1px double #A8A8A8; +} + +.contents a.qindexHL:visited { + color: #ffffff; +} + +a.el { + font-weight: bold; +} + +a.elRef { +} + +a.code, a.code:visited { + color: #4665A2; +} + +a.codeRef, a.codeRef:visited { + color: #4665A2; +} + +/* @end */ + +dl.el { + margin-left: -1cm; +} + +pre.fragment { + border: 1px solid #C4CFE5; + background-color: #FBFCFD; + padding: 4px 6px; + margin: 4px 8px 4px 2px; + overflow: auto; + word-wrap: break-word; + font-size: 9pt; + line-height: 125%; + font-family: monospace, fixed; + font-size: 105%; +} + +div.fragment { + padding: 4px; + margin: 4px; + background-color: #FCFCFC; + border: 1px solid #D5D5D5; +} + +div.line { + font-family: monospace, fixed; + font-size: 13px; + line-height: 1.0; + text-wrap: unrestricted; + white-space: -moz-pre-wrap; /* Moz */ + white-space: -pre-wrap; /* Opera 4-6 */ + white-space: -o-pre-wrap; /* Opera 7 */ + white-space: pre-wrap; /* CSS3 */ + word-wrap: break-word; /* IE 5.5+ */ + text-indent: -53px; + padding-left: 53px; + padding-bottom: 0px; + margin: 0px; +} + +span.lineno { + padding-right: 4px; + text-align: right; + border-right: 2px solid #0F0; + background-color: #E8E8E8; + white-space: pre; +} +span.lineno a { + background-color: #D8D8D8; +} + +span.lineno a:hover { + background-color: #C8C8C8; +} + +div.ah { + background-color: black; + font-weight: bold; + color: #ffffff; + margin-bottom: 3px; + margin-top: 3px; + padding: 0.2em; + border: solid thin #333; + border-radius: 0.5em; + -webkit-border-radius: .5em; + -moz-border-radius: .5em; + box-shadow: 2px 2px 3px #999; + -webkit-box-shadow: 2px 2px 3px #999; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; + background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#000),color-stop(0.3, #444)); + background-image: -moz-linear-gradient(center top, #eee 0%, #444 40%, #000); +} + +div.groupHeader { + margin-left: 16px; + margin-top: 12px; + font-weight: bold; +} + +div.groupText { + margin-left: 16px; + font-style: italic; +} + +body { + background-color: #CCCCCC; + color: black; + margin: 0; +} + +div.contents { + margin-bottom: 10px; + padding: 12px; + margin-left: auto; + margin-right: auto; + width: 800px; + background-color: white; + -moz-border-radius-bottomleft: 8px; + -moz-border-radius-bottomright: 8px; + /* firefox specific markup */ + -moz-box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 5px; + /* webkit specific markup */ + -webkit-box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.15); +} + +td.indexkey { + background-color: #F1F1F1; + font-weight: bold; + border: 1px solid #D5D5D5; + margin: 2px 0px 2px 0; + padding: 2px 10px; + white-space: nowrap; + vertical-align: top; +} + +td.indexvalue { + background-color: #F1F1F1; + border: 1px solid #D5D5D5; + padding: 2px 10px; + margin: 2px 0px; +} + +tr.memlist { + background-color: #F2F2F2; +} + +p.formulaDsp { + text-align: center; +} + +img.formulaDsp { + +} + +img.formulaInl { + vertical-align: middle; +} + +div.center { + text-align: center; + margin-top: 0px; + margin-bottom: 0px; + padding: 0px; +} + +div.center img { + border: 0px; +} + +address.footer { + text-align: right; + padding-right: 12px; + background-color: #8080A0; + color: white; +} + +img.footer { + border: 0px; + vertical-align: middle; +} + +/* @group Code Colorization */ + +span.keyword { + color: #008000 +} + +span.keywordtype { + color: #604020 +} + +span.keywordflow { + color: #e08000 +} + +span.comment { + color: #800000 +} + +span.preprocessor { + color: #806020 +} + +span.stringliteral { + color: #002080 +} + +span.charliteral { + color: #008080 +} + +span.vhdldigit { + color: #ff00ff +} + +span.vhdlchar { + color: #000000 +} + +span.vhdlkeyword { + color: #700070 +} + +span.vhdllogic { + color: #ff0000 +} + +blockquote { + background-color: #F9F9F9; + border-left: 2px solid #B8B8B8; + margin: 0 24px 0 4px; + padding: 0 12px 0 16px; +} + +/* @end */ + +/* +.search { + color: #003399; + font-weight: bold; +} + +form.search { + margin-bottom: 0px; + margin-top: 0px; +} + +input.search { + font-size: 75%; + color: #000080; + font-weight: normal; + background-color: #e8eef2; +} +*/ + +td.tiny { + font-size: 75%; +} + +.dirtab { + padding: 4px; + border-collapse: collapse; + border: 1px solid #BDBDBD; +} + +th.dirtab { + background: #F1F1F1; + font-weight: bold; +} + +hr { + height: 0px; + border: none; + border-top: 1px solid #7A7A7A; +} + +hr.footer { + display: none; +} + +/* @group Member Descriptions */ + +table.memberdecls { + border-spacing: 0px; + padding: 0px; +} + +.mdescLeft, .mdescRight, +.memItemLeft, .memItemRight, +.memTemplItemLeft, .memTemplItemRight, .memTemplParams { + background-color: #FAFAFA; + border: none; + margin: 4px; + padding: 1px 0 0 8px; +} + +.mdescLeft, .mdescRight { + padding: 0px 8px 4px 8px; + color: #555; +} + +.memItemLeft, .memItemRight, .memTemplParams { + border-top: 1px solid #D5D5D5; +} + +.memItemLeft, .memTemplItemLeft { + white-space: nowrap; +} + +.memItemRight { + width: 100%; +} + +.memTemplParams { + color: #747474; + white-space: nowrap; +} + +/* @end */ + +/* @group Member Details */ + +/* Styles for detailed member documentation */ + +.memtemplate { + font-size: 80%; + color: #747474; + font-weight: normal; + margin-left: 9px; +} + +.memnav { + background-color: #F1F1F1; + border: 1px solid #BDBDBD; + text-align: center; + margin: 2px; + margin-right: 15px; + padding: 2px; +} + +.mempage { + width: 100%; +} + +.memitem { + padding: 0; + margin-bottom: 10px; + margin-right: 5px; + -webkit-transition: box-shadow 0.5s linear; + -moz-transition: box-shadow 0.5s linear; + -ms-transition: box-shadow 0.5s linear; + -o-transition: box-shadow 0.5s linear; + transition: box-shadow 0.5s linear; +} + +.memitem.glow { + box-shadow: 0 0 15px cyan; +} + +.memname { + white-space: nowrap; + font-weight: bold; + margin-left: 6px; +} + +.memproto, dl.reflist dt { + border-top: 1px solid #C0C0C0; + border-left: 1px solid #C0C0C0; + border-right: 1px solid #C0C0C0; + padding: 6px 0px 6px 0px; + color: #3D3D3D; + font-weight: bold; + text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); + /* opera specific markup */ + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + border-top-right-radius: 8px; + border-top-left-radius: 8px; + /* firefox specific markup */ + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + -moz-border-radius-topright: 8px; + -moz-border-radius-topleft: 8px; + /* webkit specific markup */ + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + -webkit-border-top-right-radius: 8px; + -webkit-border-top-left-radius: 8px; + background-image:url('nav_f.png'); + background-repeat:repeat-x; + background-color: #EAEAEA; + +} + +.memdoc, dl.reflist dd { + border-bottom: 1px solid #C0C0C0; + border-left: 1px solid #C0C0C0; + border-right: 1px solid #C0C0C0; + padding: 2px 5px; + background-color: #FCFCFC; + border-top-width: 0; + /* opera specific markup */ + border-bottom-left-radius: 8px; + border-bottom-right-radius: 8px; + box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + /* firefox specific markup */ + -moz-border-radius-bottomleft: 8px; + -moz-border-radius-bottomright: 8px; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; + background-image: -moz-linear-gradient(center top, #FFFFFF 0%, #FFFFFF 60%, #F9F9F9 95%, #F2F2F2); + /* webkit specific markup */ + -webkit-border-bottom-left-radius: 8px; + -webkit-border-bottom-right-radius: 8px; + -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); + background-image: -webkit-gradient(linear,center top,center bottom,from(#FFFFFF), color-stop(0.6,#FFFFFF), color-stop(0.60,#FFFFFF), color-stop(0.95,#F9F9F9), to(#F2F2F2)); +} + +dl.reflist dt { + padding: 5px; +} + +dl.reflist dd { + margin: 0px 0px 10px 0px; + padding: 5px; +} + +.paramkey { + text-align: right; +} + +.paramtype { + white-space: nowrap; +} + +.paramname { + color: #602020; + white-space: nowrap; +} +.paramname em { + font-style: normal; +} + +.params, .retval, .exception, .tparams { + border-spacing: 6px 2px; +} + +.params .paramname, .retval .paramname { + font-weight: bold; + vertical-align: top; +} + +.params .paramtype { + font-style: italic; + vertical-align: top; +} + +.params .paramdir { + font-family: "courier new",courier,monospace; + vertical-align: top; +} + + + + +/* @end */ + +/* @group Directory (tree) */ + +/* for the tree view */ + +.ftvtree { + font-family: sans-serif; + margin: 0px; +} + +/* these are for tree view when used as main index */ + +.directory { + font-size: 9pt; + font-weight: bold; + margin: 5px; +} + +.directory h3 { + margin: 0px; + margin-top: 1em; + font-size: 11pt; +} + +/* +The following two styles can be used to replace the root node title +with an image of your choice. Simply uncomment the next two styles, +specify the name of your image and be sure to set 'height' to the +proper pixel height of your image. +*/ + +/* +.directory h3.swap { + height: 61px; + background-repeat: no-repeat; + background-image: url("yourimage.gif"); +} +.directory h3.swap span { + display: none; +} +*/ + +.directory > h3 { + margin-top: 0; +} + +.directory p { + margin: 0px; + white-space: nowrap; +} + +.directory div { + display: none; + margin: 0px; +} + +.directory img { + vertical-align: -30%; +} + +/* these are for tree view when not used as main index */ + +.directory-alt { + font-size: 100%; + font-weight: bold; +} + +.directory-alt h3 { + margin: 0px; + margin-top: 1em; + font-size: 11pt; +} + +.directory-alt > h3 { + margin-top: 0; +} + +.directory-alt p { + margin: 0px; + white-space: nowrap; +} + +.directory-alt div { + display: none; + margin: 0px; +} + +.directory-alt img { + vertical-align: -30%; +} + +/* @end */ + +div.dynheader { + margin-top: 8px; +} + +address { + font-style: normal; + color: #464646; +} + +table.doxtable { + border-collapse:collapse; + margin-top: 4px; + margin-bottom: 4px; +} + +table.doxtable td, table.doxtable th { + border: 1px solid #4A4A4A; + padding: 3px 7px 2px; +} + +table.doxtable th { + background-color: #5B5B5B; + color: #FFFFFF; + font-size: 110%; + padding-bottom: 4px; + padding-top: 5px; + text-align:left; +} + +table.fieldtable { + width: 100%; + margin-bottom: 10px; + border: 1px solid #C0C0C0; + border-spacing: 0px; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + border-radius: 4px; + -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; + -webkit-box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); + box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); +} + +.fieldtable td, .fieldtable th { + padding: 3px 7px 2px; +} + +.fieldtable td.fieldtype, .fieldtable td.fieldname { + white-space: nowrap; + border-right: 1px solid #C0C0C0; + border-bottom: 1px solid #C0C0C0; + vertical-align: top; +} + +.fieldtable td.fielddoc { + border-bottom: 1px solid #C0C0C0; + width: 100%; +} + +.fieldtable tr:last-child td { + border-bottom: none; +} + +.fieldtable th { + background-image:url('nav_f.png'); + background-repeat:repeat-x; + background-color: #EAEAEA; + font-size: 90%; + color: #3D3D3D; + padding-bottom: 4px; + padding-top: 5px; + text-align:left; + -moz-border-radius-topleft: 4px; + -moz-border-radius-topright: 4px; + -webkit-border-top-left-radius: 4px; + -webkit-border-top-right-radius: 4px; + border-top-left-radius: 4px; + border-top-right-radius: 4px; + border-bottom: 1px solid #C0C0C0; +} + + +.tabsearch { + top: 0px; + left: 10px; + height: 36px; + background-image: url('tab_b.png'); + z-index: 101; + overflow: hidden; + font-size: 13px; +} + +.navpath ul +{ + font-size: 11px; + background-image:url('tab_b.png'); + background-repeat:repeat-x; + height:30px; + line-height:30px; + color:#ABABAB; + border:solid 1px #D3D3D3; + overflow:hidden; + margin:0px; + padding:0px; +} + +.navpath li +{ + list-style-type:none; + float:left; + padding-left:10px; + padding-right:15px; + background-image:url('bc_s.png'); + background-repeat:no-repeat; + background-position:right; + color:#595959; +} + +.navpath li.navelem a +{ + height:32px; + display:block; + text-decoration: none; + outline: none; +} + +.navpath li.navelem a:hover +{ + color:#929292; +} + +.navpath li.footer +{ + list-style-type:none; + float:right; + padding-left:10px; + padding-right:15px; + background-image:none; + background-repeat:no-repeat; + background-position:right; + color:#595959; + font-size: 8pt; +} + + +div.summary +{ + float: right; + font-size: 8pt; + padding-right: 5px; + width: 50%; + text-align: right; +} + +div.summary a +{ + white-space: nowrap; +} + +div.ingroups +{ + margin-left: 5px; + font-size: 8pt; + padding-left: 5px; + width: 50%; + text-align: left; +} + +div.ingroups a +{ + white-space: nowrap; +} + +div.header +{ + background-image:url('nav_h.png'); + background-repeat:repeat-x; + background-color: #FAFAFA; + border-bottom: 1px solid #D5D5D5; + margin-left: auto; + margin-right: auto; + width: 800px; + padding-left: 12px; + padding-right: 12px; + /* firefox specific markup */ + -moz-box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 5px; + /* webkit specific markup */ + -webkit-box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.15); +} + +div.headertitle +{ + padding: 5px 5px 5px 0px; +} + +dl +{ + padding: 0 0 0 10px; +} + +dl.section +{ + padding: 0 0 0 6px; +} + +dl.note +{ + margin-left:-7px; + padding-left: 3px; + border-left:4px solid; + border-color: #D0C000; +} + +dl.warning, dl.attention +{ + margin-left:-7px; + padding-left: 3px; + border-left:4px solid; + border-color: #FF0000; +} + +dl.pre, dl.post, dl.invariant +{ + margin-left:-7px; + padding-left: 3px; + border-left:4px solid; + border-color: #00D000; +} + +dl.deprecated +{ + margin-left:-7px; + padding-left: 3px; + border-left:4px solid; + border-color: #505050; +} + +dl.todo +{ + margin-left:-7px; + padding-left: 3px; + border-left:4px solid; + border-color: #00C0E0; +} + +dl.test +{ + margin-left:-7px; + padding-left: 3px; + border-left:4px solid; + border-color: #3030E0; +} + +dl.bug +{ + margin-left:-7px; + padding-left: 3px; + border-left:4px solid; + border-color: #C08050; +} + +dl.section dd { + margin-bottom: 1em; +} + +#projectlogo +{ + text-align: center; + vertical-align: bottom; + border-collapse: separate; +} + +#projectlogo img +{ + border: 0px none; +} + +#projectname +{ + font: 300% Tahoma, Arial,sans-serif; + margin: 0px; + padding: 2px 0px; +} + +#projectbrief +{ + font: 120% Tahoma, Arial,sans-serif; + margin: 0px; + padding: 0px; +} + +#projectnumber +{ + font: 50% Tahoma, Arial,sans-serif; + margin: 0px; + padding: 0px; +} + +#titlearea +{ + padding: 0px; + margin: 0px; + width: 100%; + border-bottom: 1px solid #848484; + visibility: hidden; + height: 0px; +} + +.image +{ + text-align: center; +} + +.dotgraph +{ + text-align: center; +} + +.mscgraph +{ + text-align: center; +} + +.caption +{ + font-weight: bold; +} + +div.zoom +{ + border: 1px solid #AFAFAF; +} + +dl.citelist { + margin-bottom:50px; +} + +dl.citelist dt { + color:#545454; + float:left; + font-weight:bold; + margin-right:10px; + padding:5px; +} + +dl.citelist dd { + margin:2px 0; + padding:5px 0; +} + +div.toc { + padding: 14px 25px; + background-color: #F6F6F6; + border: 1px solid #DDDDDD; + border-radius: 7px 7px 7px 7px; + float: right; + height: auto; + margin: 0 20px 10px 10px; + width: 200px; +} + +div.toc li { + background: url("bdwn.png") no-repeat scroll 0 5px transparent; + font: 10px/1.2 Verdana,DejaVu Sans,Geneva,sans-serif; + margin-top: 5px; + padding-left: 10px; + padding-top: 2px; +} + +div.toc h3 { + font: bold 12px/1.2 Arial,FreeSans,sans-serif; + border-bottom: 0 none; + color: #606060; + margin: 0; +} + +div.toc ul { + list-style: none outside none; + border: medium none; + padding: 0px; +} + +div.toc li.level1 { + margin-left: 0px; +} + +div.toc li.level2 { + margin-left: 15px; +} + +div.toc li.level3 { + margin-left: 30px; +} + +div.toc li.level4 { + margin-left: 45px; +} + +@media print +{ + #top { display: none; } + #side-nav { display: none; } + #nav-path { display: none; } + body { overflow:visible; } + h1, h2, h3, h4, h5, h6 { page-break-after: avoid; } + .summary { display: none; } + .memitem { page-break-inside: avoid; } + #doc-content + { + margin-left:0 !important; + height:auto !important; + width:auto !important; + overflow:inherit; + display:inline; + } + pre.fragment + { + overflow: visible; + text-wrap: unrestricted; + white-space: -moz-pre-wrap; /* Moz */ + white-space: -pre-wrap; /* Opera 4-6 */ + white-space: -o-pre-wrap; /* Opera 7 */ + white-space: pre-wrap; /* CSS3 */ + word-wrap: break-word; /* IE 5.5+ */ + } +} + From b96a730f4984830c1ad3ee92313ac66ad1afb4f5 Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Fri, 23 Aug 2019 12:44:11 -0400 Subject: [PATCH 16/26] fixed visited link colors --- index.html | 2 +- style/doxygen_manual.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 65723b0..f4c2d3d 100644 --- a/index.html +++ b/index.html @@ -1,6 +1,6 @@ UMExamples - Learning the Ultra Messaging API by example - +
    diff --git a/style/doxygen_manual.css b/style/doxygen_manual.css index 9ce2ad4..c9d6a06 100644 --- a/style/doxygen_manual.css +++ b/style/doxygen_manual.css @@ -112,7 +112,7 @@ a { } .contents a:visited { - color: #6464FF; + color: white; } a:hover { From e2ebdd200b2bdc96f4d706697c760f8837c7c506 Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Thu, 30 Jan 2020 18:03:51 -0500 Subject: [PATCH 17/26] Update index.html --- index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/index.html b/index.html index f4c2d3d..92d23df 100644 --- a/index.html +++ b/index.html @@ -36,6 +36,7 @@

    Examples

    + From 52d8b70963a7493338ab2f13742dc228a8638b7e Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Thu, 30 Jan 2020 18:09:09 -0500 Subject: [PATCH 18/26] Update index.html --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 92d23df..29dc4a3 100644 --- a/index.html +++ b/index.html @@ -36,7 +36,7 @@

    Examples

    MtoolsInformatica "mtools" are a set of multicast test tools. Binaries and source code available for free.
    cancelling_timersC Java C#/.NETExample on how a context can schedule and safely cancel timer callbacks
    check_flight_size_ewouldblockC Java C#/.NETA send can fail with an EWOULDBLOCK error, which can have different root causes. One cause for a persisted source is exceeding flight size. This example shows how to determine if flight size is the cause of an EWOULDBLOCK error.
    clean_shutdownC Java C#/.NETExample on how to properly clean up a UM application
    - + From e12c4b0bab433ded880c09b5d3ed2bb0380a5ff4 Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Thu, 30 Jan 2020 18:12:06 -0500 Subject: [PATCH 19/26] Update index.html --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 29dc4a3..86f2ccb 100644 --- a/index.html +++ b/index.html @@ -36,7 +36,7 @@

    Examples

    MtoolsInformatica "mtools" are a set of multicast test tools. Binaries and source code available for free.
    MtoolsInformatica "mtools" are a set of multicast test tools. Binaries and source code available for free.
    cancelling_timersC Java C#/.NETExample on how a context can schedule and safely cancel timer callbacks
    check_flight_size_ewouldblockC Java C#/.NETA send can fail with an EWOULDBLOCK error, which can have different root causes. One cause for a persisted source is exceeding flight size. This example shows how to determine if flight size is the cause of an EWOULDBLOCK error.
    clean_shutdownC Java C#/.NETExample on how to properly clean up a UM application
    - + From fd4d645d5566dc8dd85561730388ee577f9c9fd1 Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Thu, 30 Jan 2020 18:13:46 -0500 Subject: [PATCH 20/26] Update index.html --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 86f2ccb..9aee9b1 100644 --- a/index.html +++ b/index.html @@ -36,7 +36,7 @@

    Examples

    MtoolsInformatica "mtools" are a set of multicast test tools. Binaries and source code available for free.
    MtoolsInformatica "mtools" are a set of multicast test tools. Binaries and source code available for free.
    cancelling_timersC Java C#/.NETExample on how a context can schedule and safely cancel timer callbacks
    check_flight_size_ewouldblockC Java C#/.NETA send can fail with an EWOULDBLOCK error, which can have different root causes. One cause for a persisted source is exceeding flight size. This example shows how to determine if flight size is the cause of an EWOULDBLOCK error.
    clean_shutdownC Java C#/.NETExample on how to properly clean up a UM application
    - +  From d34e52349067cc5a65e26359ba2b79eaea4de96a Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Thu, 30 Jan 2020 18:20:29 -0500 Subject: [PATCH 21/26] Update index.html --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 9aee9b1..5c29e60 100644 --- a/index.html +++ b/index.html @@ -36,7 +36,7 @@

    Examples

    MtoolsInformatica "mtools" are a set of multicast test tools. Binaries and source code available for free.
    MtoolsInformatica "mtools" are a set of multicast test tools. Binaries and source code available for free.
    cancelling_timersC Java C#/.NETExample on how a context can schedule and safely cancel timer callbacks
    check_flight_size_ewouldblockC Java C#/.NETA send can fail with an EWOULDBLOCK error, which can have different root causes. One cause for a persisted source is exceeding flight size. This example shows how to determine if flight size is the cause of an EWOULDBLOCK error.
    clean_shutdownC Java C#/.NETExample on how to properly clean up a UM application
    -  + From da9e2683715589ea46e0ed0f0777f7b25798047e Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Thu, 30 Jan 2020 18:23:37 -0500 Subject: [PATCH 22/26] Update c_index.html --- c_index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/c_index.html b/c_index.html index d4e8698..3e4aca0 100644 --- a/c_index.html +++ b/c_index.html @@ -18,6 +18,7 @@

    C Examples

    Examples

    MtoolsInformatica "mtools" are a set of multicast test tools. Binaries and source code available for free.
    mtoolsCInformatica "mtools" are a set of multicast test tools. Binaries and source code available for free.
    cancelling_timersC Java C#/.NETExample on how a context can schedule and safely cancel timer callbacks
    check_flight_size_ewouldblockC Java C#/.NETA send can fail with an EWOULDBLOCK error, which can have different root causes. One cause for a persisted source is exceeding flight size. This example shows how to determine if flight size is the cause of an EWOULDBLOCK error.
    clean_shutdownC Java C#/.NETExample on how to properly clean up a UM application
    + From e71573de9cc14b82748fdd76c69fc1cf58458616 Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Thu, 30 Jan 2020 18:27:23 -0500 Subject: [PATCH 23/26] Common style --- c_index.html | 7 +++---- dotnet_index.html | 7 +++---- java_index.html | 7 +++---- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/c_index.html b/c_index.html index 3e4aca0..8191217 100644 --- a/c_index.html +++ b/c_index.html @@ -1,7 +1,6 @@ - - -UMExamples - C Language - +UMExamples - C Language + +

    C Examples

    diff --git a/dotnet_index.html b/dotnet_index.html index c2883bd..35e39e5 100644 --- a/dotnet_index.html +++ b/dotnet_index.html @@ -1,7 +1,6 @@ - - -UMExamples - C#/.NET Language - +UMExamples - C#/.NET Language + +

    C#/.NET Examples

    diff --git a/java_index.html b/java_index.html index 904d3e8..bf80a6f 100644 --- a/java_index.html +++ b/java_index.html @@ -1,7 +1,6 @@ - - -UMExamples - Java Language - +UMExamples - Java Language + +

    Java Examples

    From 409e99fa2dcd2b5a3b92dd3da58f677c372938a9 Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Thu, 30 Jan 2020 18:33:11 -0500 Subject: [PATCH 24/26] common styles --- c_index.html | 42 +++++++++++++++++++++++++++++++++++++++++- dotnet_index.html | 43 ++++++++++++++++++++++++++++++++++++++++++- index.html | 4 +--- java_index.html | 42 +++++++++++++++++++++++++++++++++++++++++- 4 files changed, 125 insertions(+), 6 deletions(-) diff --git a/c_index.html b/c_index.html index 8191217..9ab25c6 100644 --- a/c_index.html +++ b/c_index.html @@ -2,7 +2,16 @@ - + +
    +
    +
    +Informatica

    +
    Welcome to UMExamples
    +

    + +© Copyright Informatica LLC 2004-2020. +

    C Examples

    Examples written in C.

    @@ -43,5 +52,36 @@

    Examples

    mtoolsCInformatica "mtools" are a set of multicast test tools. Binaries and source code available for free.
    cancelling_timersC Java C#/.NETExample on how a context can schedule and safely cancel timer callbacks
    check_flight_size_ewouldblockC Java C#/.NETA send can fail with an EWOULDBLOCK error, which can have different root causes. One cause for a persisted source is exceeding flight size. This example shows how to determine if flight size is the cause of an EWOULDBLOCK error.
    clean_shutdownC Java C#/.NETExample on how to properly clean up a UM application
    ump_receiver_callbacksC Java C#/.NETA sample application that handles all UMP receiver callbacks and logs important data
    ump_src_failoverC Java C#/.NETExample UMP source application that demonstrates how a persisted source can failover to a backup store
    + +
    + +

    Notices

    +

    This software and documentation are provided only under a separate license +agreement containing restrictions on use and disclosure. +No part of this document may be reproduced or transmitted in any form, +by any means (electronic, photocopying, recording or otherwise) +without prior consent of Informatica LLC. + +

    A current list of Informatica trademarks is available on the web at +https://www.informatica.com/trademarks.html. + +

    Portions of this software and/or documentation are subject to copyright +held by third parties. +Required third party notices are included with the product. + +

    Informatica software is protected by patents as detailed at +https://www.informatica.com/legal/patents.html. + +

    The information in this documentation is subject to change without notice. +If you find any problems in this documentation, please report them to us in +writing at Informatica LLC 2100 Seaport Blvd. Redwood City, CA 94063. + +

    Informatica products are warranted according to the terms and conditions +of the agreements under which they are provided. +
    INFORMATICA LLC PROVIDES THE INFORMATION IN THIS DOCUMENT "AS IS" WITHOUT +WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING WITHOUT ANY WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ANY WARRANTY OR +CONDITION OF NON-INFRINGEMENT. +

    diff --git a/dotnet_index.html b/dotnet_index.html index 35e39e5..04efa6f 100644 --- a/dotnet_index.html +++ b/dotnet_index.html @@ -2,7 +2,17 @@ - + +
    +
    +
    +Informatica

    +
    Welcome to UMExamples
    +

    + +© Copyright Informatica LLC 2004-2020. +
    +

    C#/.NET Examples

    Examples written in C#/.NET.

    @@ -39,5 +49,36 @@

    Examples

    source_notify_callbacksC Java C#/.NETA sample application that demonstrates how to configure and code the source_notification_callback feature for receivers ump_receiver_callbacksC Java C#/.NETA sample application that handles all UMP receiver callbacks and logs important data + +
    + +

    Notices

    +

    This software and documentation are provided only under a separate license +agreement containing restrictions on use and disclosure. +No part of this document may be reproduced or transmitted in any form, +by any means (electronic, photocopying, recording or otherwise) +without prior consent of Informatica LLC. + +

    A current list of Informatica trademarks is available on the web at +https://www.informatica.com/trademarks.html. + +

    Portions of this software and/or documentation are subject to copyright +held by third parties. +Required third party notices are included with the product. + +

    Informatica software is protected by patents as detailed at +https://www.informatica.com/legal/patents.html. + +

    The information in this documentation is subject to change without notice. +If you find any problems in this documentation, please report them to us in +writing at Informatica LLC 2100 Seaport Blvd. Redwood City, CA 94063. + +

    Informatica products are warranted according to the terms and conditions +of the agreements under which they are provided. +
    INFORMATICA LLC PROVIDES THE INFORMATION IN THIS DOCUMENT "AS IS" WITHOUT +WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING WITHOUT ANY WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ANY WARRANTY OR +CONDITION OF NON-INFRINGEMENT. +

    diff --git a/index.html b/index.html index 5c29e60..be43f71 100644 --- a/index.html +++ b/index.html @@ -10,7 +10,7 @@
    Welcome to UMExamples


    -© Copyright Informatica LLC 2004-2019. +© Copyright Informatica LLC 2004-2020.

    Ultra Messaging Examples (UMExamples) is a documentation suite aimed at @@ -91,7 +91,5 @@

    Notices

    WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING WITHOUT ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ANY WARRANTY OR CONDITION OF NON-INFRINGEMENT. - - diff --git a/java_index.html b/java_index.html index bf80a6f..8e0be37 100644 --- a/java_index.html +++ b/java_index.html @@ -2,7 +2,16 @@ - + +
    +
    +
    +Informatica

    +
    Welcome to UMExamples
    +

    + +© Copyright Informatica LLC 2004-2020. +

    Java Examples

    Examples written in Java.

    @@ -39,5 +48,36 @@

    Examples

    source_notify_callbacksC Java C#/.NETA sample application that demonstrates how to configure and code the source_notification_callback feature for receivers ump_receiver_callbacksC Java C#/.NETA sample application that handles all UMP receiver callbacks and logs important data + +
    + +

    Notices

    +

    This software and documentation are provided only under a separate license +agreement containing restrictions on use and disclosure. +No part of this document may be reproduced or transmitted in any form, +by any means (electronic, photocopying, recording or otherwise) +without prior consent of Informatica LLC. + +

    A current list of Informatica trademarks is available on the web at +https://www.informatica.com/trademarks.html. + +

    Portions of this software and/or documentation are subject to copyright +held by third parties. +Required third party notices are included with the product. + +

    Informatica software is protected by patents as detailed at +https://www.informatica.com/legal/patents.html. + +

    The information in this documentation is subject to change without notice. +If you find any problems in this documentation, please report them to us in +writing at Informatica LLC 2100 Seaport Blvd. Redwood City, CA 94063. + +

    Informatica products are warranted according to the terms and conditions +of the agreements under which they are provided. +
    INFORMATICA LLC PROVIDES THE INFORMATION IN THIS DOCUMENT "AS IS" WITHOUT +WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING WITHOUT ANY WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ANY WARRANTY OR +CONDITION OF NON-INFRINGEMENT. +

    From 08563486214ccfa6590fd607579b49734d32a9b7 Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Fri, 8 Apr 2022 17:06:28 -0400 Subject: [PATCH 25/26] Update index.html --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index be43f71..6257d38 100644 --- a/index.html +++ b/index.html @@ -36,7 +36,7 @@

    Examples

    - + From 2a0925574b972f0d2009bbfbcbaad85922b86c14 Mon Sep 17 00:00:00 2001 From: Steve Ford Date: Fri, 8 Apr 2022 17:21:52 -0400 Subject: [PATCH 26/26] Update c_index.html --- c_index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c_index.html b/c_index.html index 9ab25c6..45b66c0 100644 --- a/c_index.html +++ b/c_index.html @@ -26,7 +26,7 @@

    C Examples

    Examples

    mtoolsCInformatica "mtools" are a set of multicast test tools. Binaries and source code available for free.
    mtoolsCInformatica "mtools" are a set of multicast test tools. Binaries and source code available for free.
    cancelling_timersC Java C#/.NETExample on how a context can schedule and safely cancel timer callbacks
    check_flight_size_ewouldblockC Java C#/.NETA send can fail with an EWOULDBLOCK error, which can have different root causes. One cause for a persisted source is exceeding flight size. This example shows how to determine if flight size is the cause of an EWOULDBLOCK error.
    clean_shutdownC Java C#/.NETExample on how to properly clean up a UM application
    - +
    mtoolsCInformatica "mtools" are a set of multicast test tools. Binaries and source code available for free.
    mtoolsCInformatica "mtools" are a set of multicast test tools. Binaries and source code available for free.
    cancelling_timersC Java C#/.NETExample on how a context can schedule and safely cancel timer callbacks
    check_flight_size_ewouldblockC Java C#/.NETA send can fail with an EWOULDBLOCK error, which can have different root causes. One cause for a persisted source is exceeding flight size. This example shows how to determine if flight size is the cause of an EWOULDBLOCK error.
    clean_shutdownC Java C#/.NETExample on how to properly clean up a UM application