3 * dataManagerImpl.C - provide the interface methods for the dataManager thread
7 * Revision 1.37 1995/02/16 19:10:44 markc
8 * Removed start slash from comments
10 * Revision 1.36 1995/02/16 08:16:42 markc
11 * Changed Bool to bool
12 * Changed igen-xdr functions to use string/vectors rather than char igen-arrays
14 * Revision 1.35 1995/01/26 17:58:23 jcargill
15 * Changed igen-generated include files to new naming convention; fixed
16 * some bugs compiling with gcc-2.6.3.
18 * Revision 1.34 1994/11/09 18:39:36 rbi
19 * the "Don't Blame Me" commit
21 * Revision 1.33 1994/11/07 08:24:37 jcargill
22 * Added ability to suppress search on children of a resource, rather than
23 * the resource itself.
25 * Revision 1.32 1994/11/04 16:30:41 rbi
26 * added getAvailableDaemons()
28 * Revision 1.31 1994/11/02 11:46:21 markc
29 * Changed shadowing nam.
31 * Revision 1.30 1994/09/30 19:17:47 rbi
32 * Abstraction interface change.
34 * Revision 1.29 1994/09/22 00:56:05 markc
35 * Added const to args to addExecutable()
37 * Revision 1.28 1994/08/22 15:59:07 markc
38 * Add interface calls to support daemon definitions.
40 * Revision 1.27 1994/08/11 02:17:42 newhall
41 * added dataManager interface routine destroyPerformanceStream
43 * Revision 1.26 1994/08/08 20:15:20 hollings
44 * added suppress instrumentation command.
46 * Revision 1.25 1994/08/05 16:03:59 hollings
47 * more consistant use of stringHandle vs. char *.
49 * Revision 1.24 1994/07/25 14:55:37 hollings
50 * added suppress resource option.
52 * Revision 1.23 1994/07/14 23:45:54 hollings
53 * added hybrid cost model.
55 * Revision 1.22 1994/07/07 03:29:35 markc
56 * Added interface function to start a paradyn daemon
58 * Revision 1.21 1994/07/02 01:43:12 markc
59 * Removed all uses of type aggregation from enableDataCollection.
60 * The metricInfo structure now contains the aggregation operator.
62 * Revision 1.20 1994/06/27 21:23:29 rbi
63 * Abstraction-specific resources and mapping info
65 * Revision 1.19 1994/06/17 22:08:00 hollings
66 * Added code to provide upcall for resource batch mode when a large number
67 * of resources is about to be added.
69 * Revision 1.18 1994/06/14 15:23:17 markc
70 * Added support for aggregation.
72 * Revision 1.17 1994/06/02 16:08:16 hollings
73 * fixed duplicate naming problem for printResources.
75 * Revision 1.16 1994/05/31 19:11:33 hollings
76 * Changes to permit direct access to resources and resourceLists.
78 * Revision 1.15 1994/05/10 03:57:38 hollings
79 * Changed data upcall to return array of buckets.
81 * Revision 1.14 1994/05/09 20:56:22 hollings
82 * added changeState callback.
84 * Revision 1.13 1994/04/21 23:24:27 hollings
85 * removed process name from calls to RPC_make_arg_list.
87 * Revision 1.12 1994/04/20 15:30:11 hollings
88 * Added error numbers.
89 * Added data manager function to get histogram buckets.
91 * Revision 1.11 1994/04/19 22:08:38 rbi
92 * Added getTotValue method to get non-normalized metric data.
94 * Revision 1.10 1994/04/18 22:28:32 hollings
95 * Changes to create a canonical form of a resource list.
97 * Revision 1.9 1994/04/06 21:26:41 markc
98 * Added "include <assert.h>"
100 * Revision 1.8 1994/04/01 20:45:05 hollings
101 * Added calls to query bucketWidth and max number of bins.
103 * Revision 1.7 1994/03/31 01:39:01 markc
104 * Added dataManager continue/pause Process.
106 * Revision 1.6 1994/03/20 01:49:49 markc
107 * Gave process structure a buffer to allow multiple writers. Added support
108 * to register name of paradyn daemon. Changed addProcess to return type int.
110 * Revision 1.5 1994/03/08 17:39:34 hollings
111 * Added foldCallback and getResourceListName.
113 * Revision 1.4 1994/02/24 04:36:32 markc
114 * Added an upcall to dyninstRPC.I to allow paradynd's to report information at
115 * startup. Added a data member to the class that igen generates.
116 * Make depend differences due to new header files that igen produces.
117 * Added support to allow asynchronous starts of paradynd's. The dataManager has
118 * an advertised port that new paradynd's can connect to.
120 * Revision 1.3 1994/02/08 17:20:29 hollings
121 * Fix to not core dump when parent is null.
123 * Revision 1.2 1994/02/03 23:26:59 hollings
124 * Changes to work with g++ version 2.5.2.
126 * Revision 1.1 1994/02/02 00:42:34 hollings
127 * Changes to the Data manager to reflect the file naming convention and
128 * to support the integration of the Performance Consultant.
130 * Revision 1.1 1994/01/28 01:34:18 hollings
131 * The initial version of the Data Management thread.
139 #include "dataManager.thread.SRVR.h"
140 #include "dataManager.thread.CLNT.h"
141 #include "dyninstRPC.xdr.CLNT.h"
142 #include "DMinternals.h"
145 // the argument list passed to paradynds
146 vector<string> paradynDaemon::args = 0;
148 applicationContext *dataManager::createApplicationContext(errorHandler foo)
150 appContext = new applicationContext(foo);
154 void dataManager::setResourceSearchSuppress(applicationContext *app,
155 resource *res, bool newValue)
157 if (res) res->setSuppress(newValue);
160 void dataManager::setResourceSearchChildrenSuppress(applicationContext *app,
164 if (res) res->setSuppressChildren(newValue);
167 void dataManager::setResourceInstSuppress(applicationContext *app,
168 resource *res, bool newValue)
170 if (res) app->setInstSuppress(res, newValue);
173 bool dataManager::addDaemon(applicationContext *app,
174 char *machine, char *login, char *name)
176 return (app->getDaemon(machine, login, name));
179 bool dataManager::defineDaemon(applicationContext *app,
187 return (app->defineDaemon(command, dir, login, name, machine, flavor));
190 bool dataManager::addExecutable(applicationContext *app,
195 vector<string> *argv)
197 return(app->addExecutable(machine, login, name, dir, *argv));
200 bool dataManager::applicationDefined(applicationContext *app)
202 return(app->applicationDefined());
205 bool dataManager::startApplication(applicationContext *app)
207 return(app->startApplication());
210 bool dataManager::pauseApplication(applicationContext *app)
212 return(app->pauseApplication());
215 bool dataManager::pauseProcess(applicationContext *app, int pid)
217 return(app->pauseProcess(pid));
220 bool dataManager::continueApplication(applicationContext *app)
222 return(app->continueApplication());
225 bool dataManager::continueProcess(applicationContext *app, int pid)
227 return(app->continueProcess(pid));
230 bool dataManager::detachApplication(applicationContext *app, bool pause)
232 return(app->detachApplication(pause));
235 performanceStream *dataManager::createPerformanceStream(applicationContext *ap,
241 performanceStream *ps;
243 td = getRequestingThread();
244 ps = new performanceStream(ap, dt, dc, cc, td);
250 int dataManager::destroyPerformanceStream(applicationContext *ap,
251 performanceStream *ps){
253 performanceStream *temp;
255 if(temp = ap->streams.find(ps)){
256 ok = ap->streams.remove(ps);
263 String_Array dataManager::getAvailableMetrics(applicationContext *ap)
265 return(ap->getAvailableMetrics());
268 metric *dataManager::findMetric(applicationContext *ap, char *name)
270 return(ap->findMetric(name));
273 resourceList *dataManager::getRootResources()
275 return(resource::rootResource->getChildren());
278 resource *dataManager::getRootResource()
280 return(resource::rootResource);
283 metricInstance *dataManager::enableDataCollection(performanceStream *ps,
287 return(ps->enableDataCollection(rl, m));
290 void dataManager::disableDataCollection(performanceStream *ps,
293 if (mi) ps->disableDataCollection(mi);
296 void dataManager::enableResourceCreationNotification(performanceStream *ps,
299 ps->enableResourceCreationNotification(r);
302 void dataManager::disableResourceCreationNotification(performanceStream *ps,
305 ps->disableResourceCreationNotification(r);
308 metric *dataManager::getMetric(metricInstance *mi)
313 stringHandle dataManager::getMetricNameFromMI(metricInstance *mi)
315 return(mi->met->getName());
318 stringHandle dataManager::getMetricName(metric *m)
320 return(m->getName());
323 float dataManager::getMetricValue(metricInstance *mi)
325 return(mi->getValue());
328 float dataManager::getTotValue(metricInstance *mi)
330 return(mi->getTotValue());
333 void dataManager::setSampleRate(performanceStream *ps, timeStamp rate)
335 ps->setSampleRate(rate);
338 float dataManager::getPredictedDataCost(applicationContext *a,
342 return(a->getPredictedDataCost(rl, m));
345 float dataManager::getCurrentHybridCost(applicationContext *a)
347 return(a->getCurrentHybridCost());
350 int dataManager::getSampleValues(metricInstance *mi,
351 sampleValue *buckets,
359 if (!hist) return(-1);
361 return(hist->getBuckets(buckets, numberOfBuckets, first));
364 void dataManager::printResources()
369 void dataManager::printStatus(applicationContext *appl)
374 void dataManager::coreProcess(applicationContext *app, int pid)
376 app->coreProcess(pid);
380 // Now for the upcalls. We provide code that get called in the thread that
381 // requested the call back.
383 void dataManagerUser::newMetricDefined(metricInfoCallback cb,
384 performanceStream *ps,
390 void dataManagerUser::newResourceDefined(resourceInfoCallback cb,
391 performanceStream *ps,
393 resource *newResource,
396 (cb)(ps, parent, newResource, name);
399 void dataManagerUser::changeResourceBatchMode(resourceBatchModeCallback cb,
400 performanceStream *ps,
406 void dataManagerUser::histFold(histFoldCallback cb,
407 performanceStream *ps,
413 void dataManagerUser::changeState(appStateChangeCallback cb,
414 performanceStream *ps,
420 void dataManagerUser::newPerfData(sampleDataCallbackFunc func,
421 performanceStream *ps,
423 sampleValue *buckets,
427 (func)(ps, mi, buckets, count, first);
430 T_dyninstRPC::metricInfo *dataManager::getMetricInfo(metric *met) {
431 return(met->getInfo());
434 resource *dataManager::newResource(applicationContext *app,
441 // calls to this method should specify an abstraction,
442 // but that involves a bunch of other changes that I don't want
443 // to make right now.
444 // the kludge works because we know that all calls to this method
445 // are for BASE abstraction resources.
446 child = createResource(res, name, "BASE");
447 app->tellDaemonsOfResource((const char *) res->getFullName(), name);
451 timeStamp dataManager::getCurrentBucketWidth()
453 return(Histogram::bucketSize);
456 int dataManager::getMaxBins()
458 return(Histogram::numBins);
461 void dataManager::printDaemons(applicationContext *app)
466 String_Array dataManager::getAvailableDaemons(applicationContext *ap)
468 return(ap->getAvailableDaemons());
471 double dataManager::firstSampleTime(int program, double first) {