Beispiel #1
0
static void cpg_benchmark (
	cpg_handle_t handle,
	int write_size)
{
	struct timeval tv1, tv2, tv_elapsed;
	unsigned int res;
	cpg_flow_control_state_t flow_control_state;

	alarm_notice = 0;

	write_count = 0;
	alarm (10);

	gettimeofday (&tv1, NULL);
	do {
		/*
		 * Test checkpoint write
		 */
		cpg_flow_control_state_get (handle, &flow_control_state);
		if (flow_control_state == CPG_FLOW_CONTROL_DISABLED) {
retry:
			res = cpg_zcb_mcast_joined (handle, CPG_TYPE_AGREED, data, write_size);
			if (res == CS_ERR_TRY_AGAIN) {
				goto retry;
			}
		}
		res = cpg_dispatch (handle, CS_DISPATCH_ALL);
		if (res != CS_OK) {
			printf ("cpg dispatch returned error %d\n", res);
			exit (1);
		}
	} while (alarm_notice == 0);
	gettimeofday (&tv2, NULL);
	timersub (&tv2, &tv1, &tv_elapsed);

	printf ("%5d messages received ", write_count);
	printf ("%5d bytes per write ", write_size);
	printf ("%7.3f Seconds runtime ",
		(tv_elapsed.tv_sec + (tv_elapsed.tv_usec / 1000000.0)));
	printf ("%9.3f TP/s ",
		((float)write_count) /  (tv_elapsed.tv_sec + (tv_elapsed.tv_usec / 1000000.0)));
	printf ("%7.3f MB/s.\n",
		((float)write_count) * ((float)write_size) /  ((tv_elapsed.tv_sec + (tv_elapsed.tv_usec / 1000000.0)) * 1000000.0));
}
Beispiel #2
0
static void send_some_more_messages_zcb (void)
{
	msg_t *my_msg;
	int i;
	int send_now;
	size_t payload_size;
	size_t total_size;
	unsigned int sha1_len;
	cs_error_t res;
	cpg_flow_control_state_t fc_state;
	void *zcb_buffer;

	if (cpg_fd < 0)
		return;

	send_now = my_msgs_to_send;
	payload_size = (rand() % 100000);
	total_size = payload_size + sizeof (msg_t);
	cpg_zcb_alloc (cpg_handle, total_size, &zcb_buffer);

	my_msg = (msg_t*)zcb_buffer;

	qb_log(LOG_DEBUG, "send_now:%d", send_now);
	my_msg->pid = my_pid;
	my_msg->nodeid = my_nodeid;
	my_msg->size = sizeof (msg_t) + payload_size;
	my_msg->seq = my_msgs_sent;
	for (i = 0; i < payload_size; i++) {
		my_msg->payload[i] = i;
	}
	PK11_DigestBegin(sha1_context);
	PK11_DigestOp(sha1_context,  my_msg->payload, payload_size);
	PK11_DigestFinal(sha1_context, my_msg->sha1, &sha1_len, sizeof(my_msg->sha1));

	for (i = 0; i < send_now; i++) {

		res = cpg_flow_control_state_get (cpg_handle, &fc_state);
		if (res == CS_OK && fc_state == CPG_FLOW_CONTROL_ENABLED) {
			/* lets do this later */
			send_some_more_messages_later ();
			qb_log (LOG_INFO, "flow control enabled.");
			goto free_buffer;
		}

		res = cpg_zcb_mcast_joined (cpg_handle, CPG_TYPE_AGREED, zcb_buffer, total_size);
		if (res == CS_ERR_TRY_AGAIN) {
			/* lets do this later */
			send_some_more_messages_later ();
			goto free_buffer;
		} else if (res != CS_OK) {
			qb_log (LOG_ERR, "cpg_mcast_joined error:%d, exiting.",
				res);
			exit (-2);
		}

		my_msgs_sent++;
		my_msgs_to_send--;
	}
free_buffer:
	cpg_zcb_free (cpg_handle, zcb_buffer);
}
Beispiel #3
0
static void send_some_more_messages_zcb (void)
{
	msg_t *my_msg;
	int i;
	int send_now;
	size_t payload_size;
	size_t total_size;
	hash_state sha1_hash;
	cs_error_t res;
	cpg_flow_control_state_t fc_state;
	void *zcb_buffer;

	if (cpg_fd < 0)
		return;

	send_now = my_msgs_to_send;
	payload_size = (rand() % 100000);
	total_size = payload_size + sizeof (msg_t);
	cpg_zcb_alloc (cpg_handle, total_size, &zcb_buffer);

	my_msg = (msg_t*)zcb_buffer;

	//syslog (LOG_DEBUG,"%s() send_now:%d", __func__, send_now);
	my_msg->pid = my_pid;
	my_msg->nodeid = my_nodeid;
	my_msg->size = sizeof (msg_t) + payload_size;
	my_msg->seq = 0;
	for (i = 0; i < payload_size; i++) {
		my_msg->payload[i] = i;
	}
	sha1_init (&sha1_hash);
	sha1_process (&sha1_hash, my_msg->payload, payload_size);
	sha1_done (&sha1_hash, my_msg->sha1);

	for (i = 0; i < send_now; i++) {

		res = cpg_flow_control_state_get (cpg_handle, &fc_state);
		if (res == CS_OK && fc_state == CPG_FLOW_CONTROL_ENABLED) {
			/* lets do this later */
			send_some_more_messages_later ();
			syslog (LOG_INFO, "%s() flow control enabled.", __func__);
			goto free_buffer;
		}

		res = cpg_zcb_mcast_joined (cpg_handle, CPG_TYPE_AGREED, zcb_buffer, total_size);
		if (res == CS_ERR_TRY_AGAIN) {
			/* lets do this later */
			send_some_more_messages_later ();
//			if (i > 0) {
//				syslog (LOG_INFO, "%s() TRY_AGAIN %d to send.",
//					__func__, my_msgs_to_send);
//			}
			goto free_buffer;
		} else if (res != CS_OK) {
			syslog (LOG_ERR, "%s() -> cpg_mcast_joined error:%d, exiting.",
				__func__, res);
			exit (-2);
		}

		my_msgs_to_send--;
	}
free_buffer:
	cpg_zcb_free (cpg_handle, zcb_buffer);
}