Exemplo n.º 1
0
void start_server()
{
	//open_lua();
    //start_logger();
	start_workers();
    start_listener(g_self_ip, g_self_port);
}
Exemplo n.º 2
0
	ThreadProcessor(int max_wait_for_job_sec = 200, int number_of_worker_threads = 0):
		io_mutex_(), cond_(),
		initialized_(false), actors_(),
		number_messages_(0), done_(false), message_list_(),
		max_wait_for_job_sec_(max_wait_for_job_sec),
		number_of_worker_threads_(number_of_worker_threads) {
		start_workers();
	}
Exemplo n.º 3
0
int main(int argc, char **argv)
{
    get_options(argc, argv);

    int sock = listening();
    daemonize();
    start_workers(sock);

    return EXIT_SUCCESS;
}
Exemplo n.º 4
0
int lsx_init_threads(lsx_thread_state_t *state, sox_bool use_threads,
		     int count, void **ctx, int (*flow)(per_thread_state_t *))
{
    int i;
    state->use_threads = use_threads;
    state->count = count;
    state->pth = lsx_calloc(count, sizeof(per_thread_state_t));
    for (i = 0; i < count; ++i)
	state->pth[i].flow = flow;
    if (ctx) {
	for (i = 0; i < count; ++i)
	    state->pth[i].ctx = ctx[i];
    }
    if (use_threads && start_workers(state, worker_thread) < 0) {
	stop_workers(state);
	return -1;
    }
    return 0;
}
Exemplo n.º 5
0
int main(int argc, char* argv[])
{
    app_params p = {0};
    parse_args(argc, argv, &p);

    struct rte_ring *tx_rings[p.nb_rx_queue];
    rx_worker_params rx_params[p.nb_rx_workers];
    tx_worker_params tx_params[p.nb_tx_workers];

    // initialize
    kaf_init(p.nb_tx_workers, p.kafka_topic, p.kafka_config_path, p.kafka_stats_path);
    init_receive(p.enabled_port_mask, p.nb_rx_queue, p.nb_rx_desc);
    init_transmit(tx_rings, p.nb_rx_queue, p.tx_ring_size);

    // start receive and transmit workers
    start_workers(rx_params, tx_params, tx_rings, &p);
    monitor_workers(rx_params, p.nb_rx_workers, tx_params, p.nb_tx_workers);
    wait_for_workers();

    // clean up
    kaf_close();
    return 0;
}
Exemplo n.º 6
0
int
main(int argc, char *argv[])
{
	table_type ttype;
	int ch, cnt, ret, runs;
	char *working_dir;
	const char *config_open;

	if ((g.progname = strrchr(argv[0], DIR_DELIM)) == NULL)
		g.progname = argv[0];
	else
		++g.progname;

	config_open = NULL;
	ret = 0;
	working_dir = NULL;
	ttype = MIX;
	g.checkpoint_name = "WiredTigerCheckpoint";
	if ((g.home = malloc(512)) == NULL)
		testutil_die(ENOMEM, "Unable to allocate memory");
	g.nkeys = 10000;
	g.nops = 100000;
	g.ntables = 3;
	g.nworkers = 1;
	runs = 1;

	while ((ch = __wt_getopt(
	    g.progname, argc, argv, "c:C:h:k:l:n:r:t:T:W:")) != EOF)
		switch (ch) {
		case 'c':
			g.checkpoint_name = __wt_optarg;
			break;
		case 'C':			/* wiredtiger_open config */
			config_open = __wt_optarg;
			break;
		case 'h':			/* wiredtiger_open config */
			working_dir = __wt_optarg;
			break;
		case 'k':			/* rows */
			g.nkeys = (u_int)atoi(__wt_optarg);
			break;
		case 'l':			/* log */
			if ((g.logfp = fopen(__wt_optarg, "w")) == NULL) {
				fprintf(stderr,
				    "%s: %s\n", __wt_optarg, strerror(errno));
				return (EXIT_FAILURE);
			}
			break;
		case 'n':			/* operations */
			g.nops = (u_int)atoi(__wt_optarg);
			break;
		case 'r':			/* runs */
			runs = atoi(__wt_optarg);
			break;
		case 't':
			switch (__wt_optarg[0]) {
			case 'c':
				ttype = COL;
				break;
			case 'l':
				ttype = LSM;
				break;
			case 'm':
				ttype = MIX;
				break;
			case 'r':
				ttype = ROW;
				break;
			default:
				return (usage());
			}
			break;
		case 'T':
			g.ntables = atoi(__wt_optarg);
			break;
		case 'W':
			g.nworkers = atoi(__wt_optarg);
			break;
		default:
			return (usage());
		}

	argc -= __wt_optind;
	if (argc != 0)
		return (usage());

	/* Clean up on signal. */
	(void)signal(SIGINT, onint);

	testutil_work_dir_from_path(g.home, 512, working_dir);

	printf("%s: process %" PRIu64 "\n", g.progname, (uint64_t)getpid());
	for (cnt = 1; (runs == 0 || cnt <= runs) && g.status == 0; ++cnt) {
		printf("    %d: %u workers, %u tables\n",
		    cnt, g.nworkers, g.ntables);

		(void)cleanup();		/* Clean up previous runs */

		/* Setup a fresh set of cookies in the global array. */
		if ((g.cookies = calloc(
		    (size_t)(g.ntables), sizeof(COOKIE))) == NULL) {
			(void)log_print_err("No memory", ENOMEM, 1);
			break;
		}

		g.running = 1;

		if ((ret = wt_connect(config_open)) != 0) {
			(void)log_print_err("Connection failed", ret, 1);
			break;
		}

		if ((ret = start_checkpoints()) != 0) {
			(void)log_print_err("Start checkpoints failed", ret, 1);
			break;
		}
		if ((ret = start_workers(ttype)) != 0) {
			(void)log_print_err("Start workers failed", ret, 1);
			break;
		}

		g.running = 0;
		if ((ret = end_checkpoints()) != 0) {
			(void)log_print_err("Start workers failed", ret, 1);
			break;
		}

		free(g.cookies);
		g.cookies = NULL;
		if ((ret = wt_shutdown()) != 0) {
			(void)log_print_err("Start workers failed", ret, 1);
			break;
		}
	}
	if (g.logfp != NULL)
		(void)fclose(g.logfp);

	/* Ensure that cleanup is done on error. */
	(void)wt_shutdown();
	free(g.cookies);
	return (g.status);
}