int main(int argc, char *argv[]) { FTB_client_t cinfo; FTB_client_handle_t handle; FTB_event_handle_t ehandle; int ret = 0, i = 0; FTB_event_info_t event_info[1] = { {"SIMPLE_EVENT", "INFO"} }; if (argc > 1) { if (strcasecmp(argv[1], "usage") == 0) { printf("./ftb_simple_publisher\n"); exit(0); } } printf("Begin\n"); /* Specify the client information and call FTB_Connect */ memset(&cinfo, 0, sizeof(cinfo)); strcpy(cinfo.event_space, "FTB.FTB_EXAMPLES.SIMPLE"); strcpy(cinfo.client_subscription_style, "FTB_SUBSCRIPTION_NONE"); ret = FTB_Connect(&cinfo, &handle); if (ret != FTB_SUCCESS) { printf("FTB_Connect did not return a success\n"); exit(-1); } /* * Declare the events that this client wants to publispublishh. The events and * their severity are defined in the event_info structure */ ret = FTB_Declare_publishable_events(handle, 0, event_info, 1); if (ret != FTB_SUCCESS) { printf("FTB_Declare_publishable_events failed ret=%d!\n", ret); exit(-1); } /* Publish 10 events */ for (i = 0; i < 10; i++) { printf("Publish an event\n"); /* Publish an event. There are no event properties for this event */ ret = FTB_Publish(handle, "SIMPLE_EVENT", NULL, &ehandle); if (ret != FTB_SUCCESS) { printf("FTB_Publish did not return a success\n"); exit(-1); } printf("Sleeping for 10 seconds\n"); sleep(10); } /* Disconnect from FTB */ printf("FTB_Disconnect\n"); FTB_Disconnect(handle); printf("End\n"); return 0; }
void MPIDU_Ftb_finalize(void) { MPIR_FUNC_VERBOSE_STATE_DECL(MPID_STATE_MPIDU_FTB_FINALIZE); MPIR_FUNC_VERBOSE_ENTER(MPID_STATE_MPIDU_FTB_FINALIZE); CHECK_FTB_ERROR(FTB_Disconnect(client_handle)); MPIR_FUNC_VERBOSE_EXIT(MPID_STATE_MPIDU_FTB_FINALIZE); return; }
HYD_status HYDT_ftb_finalize(void) { int ret; HYD_status status = HYD_SUCCESS; ret = FTB_Disconnect(ch); if (ret) HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR, "ftb disconnect\n"); fn_exit: HYDU_FUNC_EXIT(); return status; fn_fail: goto fn_exit; }
int main(int argc, char *argv[]) { FTB_client_handle_t handle; FTB_client_t cinfo; FTB_subscribe_handle_t shandle; FTB_event_handle_t ehandle; double event_latency; int ret = 0; if (argc >= 2) { if (strcasecmp(argv[1], "server") == 0) { if (argc > 2) { fprintf(stderr, "Starting pingpong server. Ignoring additional arguments.\n"); } else { fprintf(stderr, "Starting pingpong server\n"); is_server = 1; } } else if (strcasecmp(argv[1], "client") == 0) { if (argc >= 3) { is_server = 0; int i = 0; for (i = 0; i < strlen(argv[2]); i++) { if ((argv[2][i] >= '0') && (argv[2][i] <= '9')) continue; else { printf("Pingpong iterations not a valid number\n"); exit(0); } } iter = atoi(argv[2]); if (iter < 1) { printf("Pingpong iterations cannot be less than 1\n"); exit(0); } if (argc > 3) { fprintf(stderr, "Starting pingpong client with iterations %d. Ignoring additional arguments\n", iter); } else { fprintf(stderr, "Starting pingpong client with iterations %d\n", iter); } } else if (argc < 3) { fprintf(stderr, "Number of iterations missing from the client pingpong program\n"); exit(0); } } else { printf ("For pingpong server: ./ftb_pingpong server\nFor pingpong client: ./ftb_pingpong client <number of iterations>\n"); exit(0); } } else { printf ("For pingpong server: ./ftb_pingpong server\nFor pingpong client: ./ftb_pingpong client <number of iterations>\n"); exit(0); } /* * Specify the client properties and call FTB_Connect. * Note that the pingpong component will subscribe to events using the * notification subscription mechanism */ memset(&cinfo, 0, sizeof(cinfo)); strcpy(cinfo.event_space, "FTB.FTB_EXAMPLES.Pingpong"); strcpy(cinfo.client_subscription_style, "FTB_SUBSCRIPTION_NOTIFY"); ret = FTB_Connect(&cinfo, &handle); if (ret != FTB_SUCCESS) { printf("FTB_Connect is not successful ret=%d\n", ret); exit(-1); } /* * This component will publish two events, as defined in the event_info * structure below */ FTB_event_info_t event_info[2] = { {"PINGPONG_EVENT_SRV", "INFO"} , {"PINGPONG_EVENT_CLI", "INFO"} }; ret = FTB_Declare_publishable_events(handle, 0, event_info, 2); if (ret != FTB_SUCCESS) { printf("FTB_Declare_publishable_events failed ret=%d!\n", ret); exit(-1); } if (is_server) { /* * The pingong server subscribes for all event of name * PINGPONG_EVENT_CLI and calls the pingpong_server function to * handle these events */ ret = FTB_Subscribe(&shandle, handle, "event_name=PINGPONG_EVENT_CLI", pingpong_server, (void *) &handle); if (ret != FTB_SUCCESS) { printf("FTB_Subscribe failed!\n"); exit(-1); } signal(SIGINT, Sig_handler); signal(SIGTERM, Sig_handler); } else { /* * The pingpong client subscribes to all events of event name * PINGPONG_EVENT_SRV and calls a function pingpong_client callback * function to handle these events */ ret = FTB_Subscribe(&shandle, handle, "event_name=PINGPONG_EVENT_SRV", pingpong_client, (void *) &handle); if (ret != FTB_SUCCESS) { printf("FTB_Subscribe failed!\n"); exit(-1); } gettimeofday(&begin, NULL); /* * After subscription, the client throws the first PINGPONG_EVENT_CLI * event. Subsequent events will be thrown by the client and server * callback function */ FTB_Publish(handle, "PINGPONG_EVENT_CLI", NULL, &ehandle); } while (!done) { sleep(1); } /* Calculate the latency at the client side */ if (!is_server) { event_latency = (end.tv_sec - begin.tv_sec) * 1000000 + (end.tv_usec - begin.tv_usec); event_latency /= iter; printf("Latency: %.3f microseconds\n", event_latency); } FTB_Disconnect(handle); return 0; }