Beispiel #1
0
static int node_recovery(int argc, char **argv)
{
	int i, ret;

	if (!raw_output) {
		printf("Nodes In Recovery:\n");
		printf("  Id   Host:Port         V-Nodes       Zone\n");
	}

	for (i = 0; i < sd_nodes_nr; i++) {
		char host[128];
		struct sd_node_req req;

		addr_to_str(host, sizeof(host), sd_nodes[i].nid.addr, 0);

		sd_init_req((struct sd_req *)&req, SD_OP_STAT_RECOVERY);

		ret = send_light_req_get_response((struct sd_req *)&req, host,
						  sd_nodes[i].nid.port);
		if (ret == SD_RES_NODE_IN_RECOVERY) {
			addr_to_str(host, sizeof(host),
					sd_nodes[i].nid.addr, sd_nodes[i].nid.port);
			printf(raw_output ? "%d %s %d %d\n" : "%4d   %-20s%5d%11d\n",
				   i, host, sd_nodes[i].nr_vnodes,
				   sd_nodes[i].zone);
		}
	}

	return EXIT_SUCCESS;
}
Beispiel #2
0
/* Light request only contains header, without body content. */
int send_light_req(struct sd_req *hdr, const char *host, int port)
{
	int ret = send_light_req_get_response(hdr, host, port);

	if (ret == -1)
		return -1;

	if (ret != SD_RES_SUCCESS) {
		fprintf(stderr, "Response's result: %s\n",
			sd_strerror(ret));
		return -1;
	}

	return 0;
}