xmlChar *limit;
xmlChar *commfabric;
xmlChar *branch;
+ xmlChar *membership;
+ xmlChar *failure_behavior;
xmlChar *accounting;
xmlChar *ewma;
xmlChar *mainloop_intervals;
xmlNodePtr fields = ident->children;
ident_peer *current = NULL;
+ /* The struct has been memsetted to 0, this is just to be safe. */
+ common->zk_host = NULL;
+ common->peers = NULL;
+ common->members = NULL;
+ common->next = NULL;
+
/* Make sure no required fields are missing. */
id = xmlGetProp(ident, (const xmlChar *) "id");
if (id == NULL) {
xmlFree(commfabric);
}
- /* Only care about branching factor if we're using gossip. */
+ /* Only care about branching factor and failure detector if we're using gossip. */
if (common->commfabric == COMM_GOSSIP) {
branch = xmlGetProp(ident, (const xmlChar *) "branch");
if (branch == NULL) {
common->branch = atoi((const char *) branch);
xmlFree(branch);
}
+
+ membership = xmlGetProp(ident, (const xmlChar *) "membership");
+ if (membership == NULL) {
+ printlog(LOG_CRITICAL, "Ident missing membership protocol selection.\n");
+ return EINVAL;
+ } else {
+ if (!xmlStrcmp(membership, (const xmlChar *) "SWIM")) {
+ common->membership = SWIM;
+ } else if (!xmlStrcmp(membership, (const xmlChar *) "ZOOKEEPER")) {
+#ifdef BUILD_ZOOKEEPER
+ common->membership = ZOOKEEPER;
+#else
+ printlog(LOG_CRITICAL, "Zookeeper requested, but support not compiled into DRL at configure time.\n");
+ xmlFree(membership);
+ return EINVAL;
+#endif
+ } else {
+ printlog(LOG_CRITICAL, "Unknown/invalid gossip group membership protocol.\n");
+ xmlFree(membership);
+ return EINVAL;
+ }
+ xmlFree(membership);
+ }
+
+ failure_behavior = xmlGetProp(ident, (const xmlChar *) "failure_behavior");
+ if (failure_behavior == NULL) {
+ printlog(LOG_CRITICAL, "Ident missing failure handling behavior.\n");
+ return EINVAL;
+ } else {
+ if (!xmlStrcmp(failure_behavior, (const xmlChar *) "PANIC")) {
+ common->failure_behavior = PANIC;
+ } else if (!xmlStrcmp(failure_behavior, (const xmlChar *) "QUORUM")) {
+ common->failure_behavior = QUORUM;
+ } else {
+ printlog(LOG_CRITICAL, "Unknown/invalid gossip failure behavior policy.\n");
+ xmlFree(failure_behavior);
+ return EINVAL;
+ }
+ xmlFree(failure_behavior);
+ }
}
accounting = xmlGetProp(ident, (const xmlChar *) "accounting");
current->next = NULL;
}
xmlFree(ip);
+ } else if ((!xmlStrcmp(fields->name, (const xmlChar *) "zkhost"))) {
+ xmlChar *host = xmlNodeListGetString(doc, fields->children, 1);
+
+ common->zk_host = strdup((const char *) host);
+ if (common->zk_host == NULL) {
+ return ENOMEM;
+ }
+
+ xmlFree(host);
}
fields = fields->next;
}
return EINVAL;
}
+ if (common->membership == ZOOKEEPER && common->zk_host == NULL) {
+ printlog(LOG_CRITICAL, "Group membership protocol ZOOKEEPER requires a zkhost field.\n");
+ return EINVAL;
+ }
+
/* No errors. */
return 0;
}