| | |
| | | } |
| | | } |
| | | |
| | | void start_resycle() { |
| | | shm_mm_wrapper_start_resycle(); |
| | | } |
| | | |
| | | |
| | | // 打印接受到的订阅消息 |
| | | void *print_sub_msg(void *sockt) { |
| | | pthread_detach(pthread_self()); |
| | |
| | | double difftime = end.tv_sec * 1000000 + end.tv_usec - (start.tv_sec * 1000000 + start.tv_usec); |
| | | long diffsec = (long) (difftime/1000000); |
| | | long diffusec = difftime - diffsec*1000000; |
| | | fprintf(stderr,"发送数目: %ld, 用时: (%ld sec %ld usec), 平均: %f\n", total, diffsec, diffusec, difftime/total ); |
| | | fprintf(stderr,"发送数目:%ld, 成功数目: %ld, 用时: (%ld sec %ld usec), 平均: %f\n", |
| | | SCALE*node_arr_size, total, diffsec, diffusec, difftime/total ); |
| | | // fflush(stdout); |
| | | |
| | | } |
| | |
| | | LoggerFactory::getLogger()->debug( "pub to %d nodes\n", n); |
| | | } |
| | | net_mod_socket_close(client); |
| | | } |
| | | |
| | | |
| | | int main(int argc, char *argv[]) { |
| | | shm_mm_wrapper_init(512); |
| | | |
| | | argument_t opt = parse_args(argc, argv); |
| | | |
| | | // port = atoi(argv[2]); |
| | | |
| | | if(opt.fun == NULL) { |
| | | usage(argv[0]); |
| | | exit(1); |
| | | } |
| | | |
| | | if (strcmp("start_net_proxy", opt.fun) == 0 ) { |
| | | if(opt.port == 0) { |
| | | usage(argv[0]); |
| | | exit(1); |
| | | } |
| | | start_net_proxy(opt); |
| | | |
| | | } |
| | | else if (strcmp("start_bus_server", opt.fun) == 0) { |
| | | |
| | | start_bus_server(opt); |
| | | } |
| | | else if (strcmp("start_reply", opt.fun) == 0) { |
| | | if(opt.key == 0) { |
| | | usage(argv[0]); |
| | | exit(1); |
| | | } |
| | | start_reply(opt.key); |
| | | } |
| | | else if (strcmp("start_net_client", opt.fun) == 0) { |
| | | if(opt.sendlist == 0) { |
| | | fprintf(stderr, "Missing sendlist .\n"); |
| | | usage(argv[0]); |
| | | exit(1); |
| | | } |
| | | if(opt.publist == 0) { |
| | | fprintf(stderr, "Missing publist.\n"); |
| | | usage(argv[0]); |
| | | exit(1); |
| | | } |
| | | start_net_client(opt.sendlist, opt.publist); |
| | | } |
| | | else if (strcmp("one_sendto_many", opt.fun) == 0) { |
| | | if(opt.sendlist == 0) { |
| | | fprintf(stderr, "Missing sendlist .\n"); |
| | | usage(argv[0]); |
| | | exit(1); |
| | | } |
| | | |
| | | one_sendto_many(opt.sendlist); |
| | | } |
| | | else if (strcmp("test_net_sendandrecv", opt.fun) == 0) { |
| | | if(opt.sendlist == 0) { |
| | | fprintf(stderr, "Missing sendlist .\n"); |
| | | usage(argv[0]); |
| | | exit(1); |
| | | } |
| | | |
| | | test_net_sendandrecv(opt.sendlist); |
| | | } |
| | | else if (strcmp("test_net_pub_threads", opt.fun) == 0) { |
| | | if(opt.publist == 0) { |
| | | fprintf(stderr, "Missing publist .\n"); |
| | | usage(argv[0]); |
| | | exit(1); |
| | | } |
| | | |
| | | test_net_pub_threads(opt.publist); |
| | | } |
| | | else if (strcmp("test_net_pub", opt.fun) == 0) { |
| | | if(opt.publist == 0) { |
| | | fprintf(stderr, "Missing publist .\n"); |
| | | usage(argv[0]); |
| | | exit(1); |
| | | } |
| | | |
| | | test_net_pub(opt.publist); |
| | | } |
| | | |
| | | else { |
| | | usage(argv[0]); |
| | | exit(1); |
| | | |
| | | } |
| | | |
| | | printf("==========end========\n"); |
| | | shm_mm_wrapper_destroy(); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | printf("============node list end==========\n"); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | int main(int argc, char *argv[]) { |
| | | shm_mm_wrapper_init(512); |
| | | |
| | | argument_t opt = parse_args(argc, argv); |
| | | |
| | | // port = atoi(argv[2]); |
| | | |
| | | if(opt.fun == NULL) { |
| | | usage(argv[0]); |
| | | exit(1); |
| | | } |
| | | |
| | | if (strcmp("start_net_proxy", opt.fun) == 0 ) { |
| | | if(opt.port == 0) { |
| | | usage(argv[0]); |
| | | exit(1); |
| | | } |
| | | start_net_proxy(opt); |
| | | |
| | | } |
| | | else if (strcmp("start_bus_server", opt.fun) == 0) { |
| | | |
| | | start_bus_server(opt); |
| | | } |
| | | else if (strcmp("start_reply", opt.fun) == 0) { |
| | | if(opt.key == 0) { |
| | | usage(argv[0]); |
| | | exit(1); |
| | | } |
| | | start_reply(opt.key); |
| | | } |
| | | else if (strcmp("start_net_client", opt.fun) == 0) { |
| | | if(opt.sendlist == 0) { |
| | | fprintf(stderr, "Missing sendlist .\n"); |
| | | usage(argv[0]); |
| | | exit(1); |
| | | } |
| | | if(opt.publist == 0) { |
| | | fprintf(stderr, "Missing publist.\n"); |
| | | usage(argv[0]); |
| | | exit(1); |
| | | } |
| | | start_net_client(opt.sendlist, opt.publist); |
| | | } |
| | | else if (strcmp("one_sendto_many", opt.fun) == 0) { |
| | | if(opt.sendlist == 0) { |
| | | fprintf(stderr, "Missing sendlist .\n"); |
| | | usage(argv[0]); |
| | | exit(1); |
| | | } |
| | | |
| | | one_sendto_many(opt.sendlist); |
| | | } |
| | | else if (strcmp("test_net_sendandrecv", opt.fun) == 0) { |
| | | if(opt.sendlist == 0) { |
| | | fprintf(stderr, "Missing sendlist .\n"); |
| | | usage(argv[0]); |
| | | exit(1); |
| | | } |
| | | |
| | | test_net_sendandrecv(opt.sendlist); |
| | | } |
| | | else if (strcmp("test_net_pub_threads", opt.fun) == 0) { |
| | | if(opt.publist == 0) { |
| | | fprintf(stderr, "Missing publist .\n"); |
| | | usage(argv[0]); |
| | | exit(1); |
| | | } |
| | | |
| | | test_net_pub_threads(opt.publist); |
| | | } |
| | | else if (strcmp("test_net_pub", opt.fun) == 0) { |
| | | if(opt.publist == 0) { |
| | | fprintf(stderr, "Missing publist .\n"); |
| | | usage(argv[0]); |
| | | exit(1); |
| | | } |
| | | |
| | | test_net_pub(opt.publist); |
| | | } |
| | | else if (strcmp("start_resycle", opt.fun) == 0) { |
| | | start_resycle(); |
| | | } |
| | | |
| | | else { |
| | | usage(argv[0]); |
| | | exit(1); |
| | | |
| | | } |
| | | |
| | | printf("==========end========\n"); |
| | | // shm_mm_wrapper_destroy(); |
| | | |
| | | } |