Exemplo n.º 1
0
/*
 * Returns 1 if 'votequorum' is active. The called then knows that
 * votequorum calls should work and can provide extra information
 */
static int using_votequorum(void)
{
	const char *quorumtype = get_quorum_type();
	int using_voteq;

	if (!quorumtype)
		return 0;

	if (strcmp(quorumtype, "corosync_votequorum") == 0)
		using_voteq = 1;
	else
		using_voteq = 0;

	free((void *)quorumtype);
	return using_voteq;
}
Exemplo n.º 2
0
/*
 * Returns 1 if 'votequorum' is active. The called then knows that
 * votequorum calls should work and can provide extra information
 */
static int using_votequorum(void)
{
	char quorumtype[256];
	int using_voteq;

	memset(quorumtype, 0, sizeof(quorumtype));

	if (get_quorum_type(quorumtype, sizeof(quorumtype))) {
		return -1;
	}

	if (strcmp(quorumtype, "corosync_votequorum") == 0) {
		using_voteq = 1;
	} else {
		using_voteq = 0;
	}

	return using_voteq;
}
Exemplo n.º 3
0
static int display_quorum_data(int is_quorate,
			       nodeid_format_t nodeid_format, name_format_t name_format, sorttype_t sort_type,
			       int loop)
{
	struct votequorum_info info;
	int err;
	char quorumtype[256];
	time_t t;

	memset(quorumtype, 0, sizeof(quorumtype));

	printf("Quorum information\n");
	printf("------------------\n");
	time(&t);
	printf("Date:             %s", ctime((const time_t *)&t));

	if (get_quorum_type(quorumtype, sizeof(quorumtype))) {
		strncpy(quorumtype, "Not configured", sizeof(quorumtype) - 1);
	}
	printf("Quorum provider:  %s\n", quorumtype);
	printf("Nodes:            %d\n", g_view_list_entries);
	if (nodeid_format == NODEID_FORMAT_DECIMAL) {
		printf("Node ID:          %u\n", our_nodeid);
	} else {
		printf("Node ID:          0x%08x\n", our_nodeid);
	}

	if (v_handle) {
		printf("Ring ID:          %d/%" PRIu64 "\n", g_ring_id_rep_node, g_ring_id);
	}
	else {
		printf("Ring ID:          %" PRIu64 "\n", g_ring_id);
	}
	printf("Quorate:          %s\n", is_quorate?"Yes":"No");

	if (!v_handle) {
		return CS_OK;
	}

	err=votequorum_getinfo(v_handle, our_nodeid, &info);
	if ((err == CS_OK) || (err == CS_ERR_NOT_EXIST)) {
		printf("\nVotequorum information\n");
		printf("----------------------\n");
		printf("Expected votes:   %d\n", info.node_expected_votes);
		printf("Highest expected: %d\n", info.highest_expected);
		printf("Total votes:      %d\n", info.total_votes);
		printf("Quorum:           %d %s\n", info.quorum, info.flags & VOTEQUORUM_INFO_QUORATE?" ":"Activity blocked");
		printf("Flags:            ");
		if (info.flags & VOTEQUORUM_INFO_TWONODE) printf("2Node ");
		if (info.flags & VOTEQUORUM_INFO_QUORATE) printf("Quorate ");
		if (info.flags & VOTEQUORUM_INFO_WAIT_FOR_ALL) printf("WaitForAll ");
		if (info.flags & VOTEQUORUM_INFO_LAST_MAN_STANDING) printf("LastManStanding ");
		if (info.flags & VOTEQUORUM_INFO_AUTO_TIE_BREAKER) printf("AutoTieBreaker ");
		if (info.flags & VOTEQUORUM_INFO_ALLOW_DOWNSCALE) printf("AllowDownscale ");
		if (info.flags & VOTEQUORUM_INFO_QDEVICE_REGISTERED) printf("Qdevice ");
		printf("\n");
	} else {
		fprintf(stderr, "Unable to get node info: %s\n", cs_strerror(err));
	}

	display_nodes_data(nodeid_format, name_format, sort_type);

	return err;
}
Exemplo n.º 4
0
static void show_status(void)
{
	quorum_handle_t q_handle;
	votequorum_handle_t v_handle;
	votequorum_callbacks_t v_callbacks;
	quorum_callbacks_t callbacks;
	struct votequorum_info info;
	int is_quorate;
	int err;

	callbacks.quorum_notify_fn = quorum_notification_fn;
	err=quorum_initialize(&q_handle, &callbacks);
	if (err != CS_OK) {
		fprintf(stderr, "Cannot connect to quorum service, is it loaded?\n");
		return;
	}

	err=quorum_getquorate(q_handle, &is_quorate);
	if (err != CS_OK) {
		fprintf(stderr, "quorum_getquorate FAILED: %d\n", err);
		return;
	}

	err=quorum_trackstart(q_handle, CS_TRACK_CURRENT);
	if (err != CS_OK) {
		fprintf(stderr, "quorum_trackstart FAILED: %d\n", err);
		return;
	}

	g_called = 0;
	while (g_called == 0)
		quorum_dispatch(q_handle, CS_DISPATCH_ONE);

	quorum_finalize(q_handle);

	printf("Version:          %s\n", VERSION);
	printf("Nodes:            %d\n", g_view_list_entries);
	printf("Ring ID:          %" PRIu64 "\n", g_ring_id);
	printf("Quorum type:      %s\n", get_quorum_type());
	printf("Quorate:          %s\n", is_quorate?"Yes":"No");

	if (using_votequorum()) {

		v_callbacks.votequorum_notify_fn = NULL;
		v_callbacks.votequorum_expectedvotes_notify_fn = NULL;

		if ( (err=votequorum_initialize(&v_handle, &v_callbacks)) != CS_OK) {
			fprintf(stderr, "votequorum_initialize FAILED: %d, this is probably a configuration error\n", err);
			goto err_exit;
		}
		if ( (err=votequorum_getinfo(v_handle, 0, &info)) != CS_OK)
			fprintf(stderr, "votequorum_getinfo FAILED: %d\n", err);
		else {
			printf("Node votes:       %d\n", info.node_votes);
			printf("Expected votes:   %d\n", info.node_expected_votes);
			printf("Highest expected: %d\n", info.highest_expected);
			printf("Total votes:      %d\n", info.total_votes);
			printf("Quorum:           %d %s\n", info.quorum, info.flags & VOTEQUORUM_INFO_FLAG_QUORATE?" ":"Activity blocked");
			printf("Flags:            ");
			if (info.flags & VOTEQUORUM_INFO_FLAG_HASSTATE) printf("HasState ");
			if (info.flags & VOTEQUORUM_INFO_FLAG_DISALLOWED) printf("DisallowedNodes ");
			if (info.flags & VOTEQUORUM_INFO_FLAG_TWONODE) printf("2Node ");
			if (info.flags & VOTEQUORUM_INFO_FLAG_QUORATE) printf("Quorate ");
			printf("\n");
		}
	}

	err_exit:
	return;
}