Exemple #1
0
static
ds_ctxt_t *
compress_init(const char *root)
{
	ds_ctxt_t		*ctxt;
	ds_compress_ctxt_t	*compress_ctxt;
	datasink_t		*dest_ds;
	datasink_t		*pipe_ds;
	ds_ctxt_t		*dest_ctxt;
	comp_thread_ctxt_t	*threads;

	dest_ds = &datasink_buffer;

	dest_ctxt = dest_ds->init(root);
	if (dest_ctxt == NULL) {
		msg("compress: failed to initialize the buffer datasink.\n");
		return NULL;
	}

	/* Use a 1 MB buffer for compressed output stream */
	ds_buffer_set_size(dest_ctxt, 1024 * 1024);

	/* Decide whether the compressed data will be stored in local files or
	streamed to an archive */
	pipe_ds = xtrabackup_stream ? &datasink_stream : &datasink_local;
	dest_ctxt->pipe_ctxt = pipe_ds->init(root);
	if (dest_ctxt->pipe_ctxt == NULL) {
		msg("compress: failed to initialize the target datasink.\n");
		return NULL;
	}

	/* Create and initialize the worker threads */
	threads = create_worker_threads(xtrabackup_compress_threads);
	if (threads == NULL) {
		msg("compress: failed to create worker threads.\n");
		dest_ds->deinit(dest_ctxt);
		return NULL;
	}

	ctxt = (ds_ctxt_t *) my_malloc(sizeof(ds_ctxt_t) +
				       sizeof(ds_compress_ctxt_t),
				       MYF(MY_FAE));

	compress_ctxt = (ds_compress_ctxt_t *) (ctxt + 1);
	compress_ctxt->dest_ctxt = dest_ctxt;
	compress_ctxt->threads = threads;
	compress_ctxt->nthreads = xtrabackup_compress_threads;

	ctxt->datasink = &datasink_compress;
	ctxt->ptr = compress_ctxt;

	return ctxt;
}
Exemple #2
0
int main() {
    taosocks::win_sock wsa;

    taosocks::client_queue queue;
    taosocks::socket_server_t server;
    server.start("127.0.0.1", 1080, 128);

    create_worker_threads(queue);

    taosocks::client_t client;
    while (server.accept(&client)) {
        queue.push(client);
    }

    return 0;
}
Exemple #3
0
/* 
 * Executes main thread. 
 * Currently performs no sanity checks
 */
    int 
main(int argc, char **argv) 
{
    int num_disks = atoi(argv[1]);
    int num_worker_threads = atoi(argv[2]);
    int num_iterations = atoi(argv[3]);
    pthread_mutexattr_settype(&attribute, PTHREAD_MUTEX_ERRORCHECK);
    job quit_job;
    quit_job.message = QUIT;
    int j;

    // make disc threads
    create_disk_threads(num_disks);

    // create worker threads
    create_worker_threads(num_worker_threads,num_disks, num_iterations);

    // catch all worker threads
    for(j=0; j < num_worker_threads; j++) {
        pthread_join(workers[j].thread_id, NULL); 
    }
    fprintf(stdout,"\nWorker threads finished: %d\n",j);

    // send quit message
    for(j=0; j < num_disks; j++) {
        cbuffer_add(&quit_job,&discs[j].write_cbuf); 
        fprintf(stdout,"\nsend quit to disc: %d\n",j);
    }

    // catch disc threads
    for(j=0; j < num_disks; j++) {
        pthread_join(discs[j].thread_id, NULL); 
        printf("Actually quit\n");
    }

    printf("Num disks: %d\nNum worker threads: %d\nNum iterations: %d\n"
            , num_disks, num_worker_threads, num_iterations);
    exit(0);
}