1 #include "../src/visithread.h"
3 #define TESTMETRIC "blah,blah blah,metric 3,metric 4,last metric"
4 #define TESTRESOURCE "resource1/blah1/foo1,resource2/foo2,resource3"
7 main(int argc,char *argv[]){
11 visualizationUser *vup;
13 char temp[128], temp2[128];
18 metricType_Array mets;
19 resourceType *resources;
20 resourceType_Array res;
23 int mId,rId,bNum,bWidth,nval;
29 fprintf(stdout,"incorrect num arguments: client1 server_executable\n");
32 fprintf(stderr,"in client\n");
33 arg_list = new char*[argc+1];
34 arg_list[i++] = strdup(argv[1]);
36 sprintf(temp,"%s",TESTMETRIC);
37 arg_list[i++] = strdup(temp);
38 sprintf(temp,"%s",TESTRESOURCE);
39 arg_list[i++] = strdup(temp);
44 fprintf(stderr,"in client before RPCprocessCreate\n");
45 fd = RPCprocessCreate(&pid, "localhost", "", argv[1],arg_list);
47 perror("process Create");
52 fprintf(stderr,"in client before new visualizationUser\n");
53 vup = new visualizationUser(fd,NULL,NULL);
55 fprintf(stderr,"in client before while loop\n");
60 // these don't do anything yet
62 vup->awaitResponce(-1);
65 while((wch < 0) || (wch > 7)){
66 fprintf(stdout,"\n---------------------------------------------\n");
67 fprintf(stdout,"enter number of operation to perform:\n");
68 fprintf(stdout,"---------------------------------------------\n");
69 fprintf(stdout,"0:data values 1:fold 2:invalid m/r 3:add m/r\n");
70 fprintf(stdout,"4:new m/r 5:phase 6:print 7:quit\n");
71 fprintf(stdout,"---------------------------------------------\n\n");
76 fprintf(stdout,"\nSend Data values to server process:\n");
77 fprintf(stdout,"enter number of dataValues\n");
79 data = (dataValue *)malloc(sizeof(dataValue)*nval);
81 fprintf(stdout,"enter metricId (int)\n");
82 scanf("%d",&data[i].metricId);
83 fprintf(stdout,"enter resourceId (int)\n");
84 scanf("%d",&data[i].resourceId);
85 fprintf(stdout,"enter bucketNum (int)\n");
86 scanf("%d",&data[i].bucketNum);
87 fprintf(stdout,"enter data value (float)\n");
98 fprintf(stdout,"\nFold:\n");
99 fprintf(stdout,"enter new bucket width value (float)\n");
104 fprintf(stdout,"\nInvalidate Metric and Resources:\n");
105 fprintf(stdout,"enter metricId (int)\n");
107 fprintf(stdout,"enter resourceId (int)\n");
109 vup->InvalidMR(mId,rId);
112 fprintf(stdout,"\nAdd Metrics and Resorces:\n");
113 fprintf(stdout,"enter number of metrics (int)\n");
115 metrics = (metricType *)malloc(sizeof(metricType)*nMets);
116 for(i=0;i<nMets;i++){
117 fprintf(stdout,"enter metric name (string), Id (int), units (string), and aggregate(0 or 1)\n");
118 scanf("%s%d%s%d",temp,&metrics[i].Id,temp2,&metrics[i].aggregate);
119 metrics[i].name = strdup(temp);
120 metrics[i].units = strdup(temp2);
124 fprintf(stdout,"enter number of resources (int)\n");
126 resources = (resourceType *)malloc(sizeof(resourceType)*nRes);
128 fprintf(stdout,"enter resources name (string), Id (int)\n");
129 scanf("%s%d",temp,&resources[i].Id);
130 resources[i].name = strdup(temp);
133 res.data = resources;
134 fprintf(stdout,"enter numBuckets (int)\n");
136 fprintf(stdout,"enter bucket width (float)\n");
138 vup->AddMetricsResources(mets,res,bWidth,bNum);
139 for(i=0;i<nMets;i++){
140 free(metrics[i].name);
141 free(metrics[i].units);
144 free(resources[i].name);
150 fprintf(stdout,"\nNew Metrics and Resorces: not currently supported\n");
151 fprintf(stdout,"enter number of metrics (int)\n");
153 metrics = (metricType *)malloc(sizeof(metricType)*nMets);
154 for(i=0;i<nMets;i++){
155 fprintf(stdout,"enter metric name(string), Id (int), units(string), and aggregate (int 0 or 1)\n");
156 scanf("%s%d%s%d",temp,&metrics[i].Id,temp2,&metrics[i].aggregate);
157 metrics[i].name = strdup(temp);
158 metrics[i].units = strdup(temp2);
162 fprintf(stdout,"enter number of resources (int)\n");
164 resources = (resourceType *)malloc(sizeof(resourceType)*nRes);
166 fprintf(stdout,"enter resources name (string), Id (int)\n");
167 scanf("%s%d",temp,&resources[i].Id);
168 resources[i].name = strdup(temp);
171 res.data = resources;
172 vup->NewMetricsResources(mets,res);
173 for(i=0;i<nMets;i++){
174 free(metrics[i].name);
175 free(metrics[i].units);
178 free(resources[i].name);
184 fprintf(stdout,"\nPhase:\n");
185 fprintf(stdout,"enter phase name(string), begin(float), end(float)\n");
186 scanf("%s%f%f",temp,&num,&num2);
187 vup->Phase(num,num2,temp);
190 vup->Phase(3.4,4.5,"blah");