Exemplo n.º 1
0
/**
 * Add a FULL NODE Entry, which has port, group and node id inside
 * Add a Node and Group to the Topology Info.
 */
int
cc_add_fullnode_group_entry(cluster_config_t * cc, cf_node fullnode ) {
	static char * meth = "add_fullnode_group_entry()";
	int rc = 0;
//	printf("[ENTER]<%s:%s> fullnode(%"PRIx64")\n", MOD, meth, fullnode );

	// Look for the group -- if found, then save the index.
	// And, if not found, add it, and save the index.
	cc_group_t group_id = cc_compute_group_id( fullnode );
	int group_ndx = cc_add_group( cc, group_id );

	// Group is all set.  Now add the node (we shouldn't have one already).
	int node_ndx = cc_add_fullnode( cc, fullnode );

	// Quick validation step -- if the membership array shows a NON-negative
	// entry, point that out, but ALSO
	if( cc->membership[node_ndx]  > 0 && cc->membership[node_ndx] != group_ndx) {
		cf_debug(AS_PARTITION, "[ERROR]<%s:%s>Adding FULLNODE[%d](%"PRIx64") MEMBER(%d) \n",
				MOD, meth, node_ndx, fullnode, cc->membership[node_ndx] );
		rc = -1;
	}

	// Just overwrite the weird case for now -- and we'll figure it out later.
	// TODO: Handle the overwrite error if it ever comes up.  It would probably
	// be ONLY a user error -- but it most likely shows that the user screwed
	// up the config file.
	cc->membership[node_ndx] = group_ndx;
	cc->group_node_count[group_ndx]++; // One more in this group

	return rc;
} // end add_node_group_entry()
/**
 * Add Node/Group Entry
 * Add a Node and Group to the Topology Info.
 */
int
cc_add_node_group_entry(cluster_config_t *cc, const cc_node_t node,
		const cc_group_t group) {
	int rc = 0;

	// Look for the group -- if found, then save the index.
	// And, if not found, add it, and save the index.
	int group_ndx = cc_add_group(cc, group);

	// Group is all set.  Now add the node (we shouldn't have one already).
	int node_ndx = cc_add_node(cc, node);

	// Quick validation step -- if the membership array shows a NON-negative
	// entry, point that out, but ALSO
	if (cc->membership[node_ndx]  > 0
			&& cc->membership[node_ndx] != group_ndx) {
		cf_debug(AS_PARTITION, "adding node:%d group:%d set:%d",
				node, group, cc->membership[node_ndx]);
		rc = -1;
	}

	// Just overwrite the weird case for now -- and we'll figure it out later.
	// TODO: Handle the overwrite error if it ever comes up.  It would probably
	// be ONLY a user error -- but it most likely shows that the user screwed
	// up the config file.
	cc->membership[node_ndx] = group_ndx;
	cc->group_node_count[group_ndx]++; // One more in this group

	return rc;
} // end add_node_group_entry()