Exemplo n.º 1
0
/*
 * return  1 if quorate
 *         0 if not quorate
 *        -1 on error
 */
static int show_status(nodeid_format_t nodeid_format, name_format_t name_format, sorttype_t sort_type)
{
	int is_quorate;
	int err;

	err=quorum_getquorate(q_handle, &is_quorate);
	if (err != CS_OK) {
		fprintf(stderr, "Unable to get cluster quorate status: %s\n", cs_strerror(err));
		goto quorum_err;
	}

	err=quorum_trackstart(q_handle, CS_TRACK_CURRENT);
	if (err != CS_OK) {
		fprintf(stderr, "Unable to start quorum status tracking: %s\n", cs_strerror(err));
		goto quorum_err;
	}

	g_called = 0;
	while (g_called == 0 && err == CS_OK) {
		err = quorum_dispatch(q_handle, CS_DISPATCH_ONE);
		if (err != CS_OK) {
			fprintf(stderr, "Unable to dispatch quorum status: %s\n", cs_strerror(err));
		}
	}

	if (quorum_trackstop(q_handle) != CS_OK) {
		fprintf(stderr, "Unable to stop quorum status tracking: %s\n", cs_strerror(err));
	}

	if (using_votequorum()) {

		if ( (err=votequorum_trackstart(v_handle, 0LL, CS_TRACK_CURRENT)) != CS_OK) {
			fprintf(stderr, "Unable to start votequorum status tracking: %s\n", cs_strerror(err));
			goto quorum_err;
		}

		g_vq_called = 0;
		while (g_vq_called == 0 && err == CS_OK) {
			err = votequorum_dispatch(v_handle, CS_DISPATCH_ONE);
			if (err != CS_OK) {
				fprintf(stderr, "Unable to dispatch votequorum status: %s\n", cs_strerror(err));
			}
		}
	}

quorum_err:
	if (err != CS_OK) {
		return -1;
	}

	err = display_quorum_data(is_quorate, nodeid_format, name_format, sort_type, 0);
	if (err != CS_OK) {
		return -1;
	}

	return is_quorate;
}
Exemplo n.º 2
0
void close_cluster(void)
{
	quorum_trackstop(qh);
	quorum_finalize(qh);
}