MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / clusterNodeAddFailureReport

Function clusterNodeAddFailureReport

src/cluster.cpp:863–886  ·  view source on GitHub ↗

This function is called every time we get a failure report from a node. * The side effect is to populate the fail_reports list (or to update * the timestamp of an existing report). * * 'failing' is the node that is in failure state according to the * 'sender' node. * * The function returns 0 if it just updates a timestamp of an existing * failure report from the same sender. 1 is returned

Source from the content-addressed store, hash-verified

861 * failure report from the same sender. 1 is returned if a new failure
862 * report is created. */
863int clusterNodeAddFailureReport(clusterNode *failing, clusterNode *sender) {
864 list *l = failing->fail_reports;
865 listNode *ln;
866 listIter li;
867 clusterNodeFailReport *fr;
868
869 /* If a failure report from the same sender already exists, just update
870 * the timestamp. */
871 listRewind(l,&li);
872 while ((ln = listNext(&li)) != NULL) {
873 fr = (clusterNodeFailReport*)ln->value;
874 if (fr->node == sender) {
875 fr->time = mstime();
876 return 0;
877 }
878 }
879
880 /* Otherwise create a new report. */
881 fr = (clusterNodeFailReport*)zmalloc(sizeof(*fr), MALLOC_LOCAL);
882 fr->node = sender;
883 fr->time = mstime();
884 listAddNodeTail(l,fr);
885 return 1;
886}
887
888/* Remove failure reports that are too old, where too old means reasonably
889 * older than the global node timeout. Note that anyway for a node to be

Callers 1

Calls 5

listRewindFunction · 0.85
listNextFunction · 0.85
zmallocFunction · 0.85
listAddNodeTailFunction · 0.85
mstimeFunction · 0.70

Tested by

no test coverage detected