FACT++  1.0
bigClient.cxx
Go to the documentation of this file.
1 #include <dic.hxx>
2 
3 class Service : public DimInfo
4 {
5  int n_bad;
6  int n_good;
7 
8  void infoHandler()
9  {
10  char *ptr;
11  ptr = (char *)getData();
12  // cout << getName() << " received " << ptr << endl;
13  if(ptr[0] == '-')
14  {
15  n_bad = 1;
16  n_good = 0;
17  }
18  if(ptr[0] == 'h')
19  {
20  n_good = 1;
21  n_bad = 0;
22  }
23  }
24 public :
25  Service(char *name) : DimInfo(name,"--")
26  {n_bad = 0; n_good = 0;}
27  int getNgood() {return n_good;}
28  int getNbad() {return n_bad;}
29 };
30 
31 
32 int main(int argc, char *argv[])
33 {
34  int i, n, msgSize, nServices = 0;
35  Service **services;
36  float mps,tpm;
37  DimBrowser br;
38  char name[132], *format;
39 
40  sscanf(argv[1],"%d",&nServices);
41  services = new Service*[nServices];
42  for(i = 0; i < nServices; i++)
43  {
44  services[i] = 0;
45  }
46  for(i = 0; i < nServices; i++)
47  {
48  sprintf(name,"BENCH_SERVICE_%03d",i);
49  services[i] = new Service(name);
50  }
51  while(1)
52  {
53  sleep(10);
54  n = 0;
55  for(i = 0; i < nServices; i++)
56  {
57  if(services[i])
58  n += services[i]->getNgood();
59  }
60  cout << "N Good = "<< n << endl;
61  n = 0;
62  for(i = 0; i < nServices; i++)
63  {
64  if(services[i])
65  n += services[i]->getNbad();
66  }
67  cout << "N bad = "<< n << endl;
68  }
69 }
std::string format
Definition: Service.h:9
int n_bad
Definition: bigClient.cxx:5
int i
Definition: db_dim_client.c:21
Definition: dic.hxx:31
int getNgood()
Definition: bigClient.cxx:27
int n_good
Definition: bigClient.cxx:6
void * getData()
Definition: diccpp.cxx:213
Service(char *name)
Definition: bigClient.cxx:25
int getNbad()
Definition: bigClient.cxx:28
void infoHandler()
Definition: bigClient.cxx:8
std::string name
Definition: Service.h:6
int main(int argc, char *argv[])
Definition: bigClient.cxx:32
sprintf(name1,"NewService%d", i)