On 10/07/2014 04:38 AM, Frank Ch. Eigler wrote:
[..]
Thanks, I'll study your code and steal lots of bits. I'm leaning
toward a little simpler solution in some ways. For example, how about
just use one pcp context per "fetch-group"?
IIRC, the optFetch API that fetchGroup uses decides how many contexts
to use based (in part) on the instance profiles.
That would make it less
necessary to have special time-setting or profile-manipulation
wrappers, since it would compose with the normal PMAPI functions.
well, you'll still need the pmSetMode() wrapper for multiple contexts
because multiple hosts or archives are supported. So __pmFetchGroupArchiveMode
just walks all of the contexts in each of the fetch groups, vis :
void
__pmFetchGroupArchiveMode(int mode, const struct timeval *when, int interval)
{
int fg;
int c;
fetchGroup *group;
int curcontext = pmWhichContext();
for (fg=0; fg < nfetchGroups; fg++) {
group = &fetchGroups[fg];
for (c=0; c < group->ncontexts; c++) {
if (group->contexts[c] >= 0) {
pmUseContext(group->contexts[c]);
pmSetMode(mode, when, interval);
}
}
}
if (curcontext >= 0)
pmUseContext(curcontext);
}
BTW, I doubt this code is thread safe ...
|