]> git.uio.no Git - u/mrichter/AliRoot.git/blame - SHUTTLE/test/TestClientDP.C
updated test classes (alberto)
[u/mrichter/AliRoot.git] / SHUTTLE / test / TestClientDP.C
CommitLineData
4b4eb769 1void GetValues(const char* host, Int_t port, const char* request,
2 Long_t startTime, Long_t endTime)
3{
4
5 AliDCSClient client(host, port, 10000, 5);
6
7 Int_t result;
8
9 TTimeStamp currentTime;
10 TMap values;
11
12 TString rString(request);
13
14 TObjArray* requests = rString.Tokenize(",");
15
16 cout<<"Requests: "<<requests->GetEntries()<<endl;
17
18 TStopwatch sw;
19 sw.Start();
20
21 if (requests->GetEntries() > 1) {
22
23 TIter iter(requests);
24 TObjString* aString;
25 while ((aString = (TObjString*) iter.Next())) {
26 values.Add(new TObjString(aString->String()), NULL);
27 }
28
29 result = client.GetDPValues(startTime, endTime, values);
30
31 } else {
32 TObjArray* valueSet = new TObjArray();
33 valueSet->SetOwner(1);
34
35 values.Add(new TObjString(request), valueSet);
36
37 result = client.GetDPValues(request, startTime,
38 endTime, *valueSet);
39 }
40
41 if (result < 0) {
42 cout<<"Communication failure: "<<
43 AliDCSClient::GetErrorString(result)<<endl;
44
45 if (result == AliDCSClient::fgkServerError) {
46 cout<<"Server error code: "<<
47 client.GetServerErrorCode()<<endl;
48 cout<<client.GetServerError()<<endl;
49 }
50 }
51
52 sw.Stop();
53 cout<<"Elapsed time: "<<sw.RealTime()<<endl;
54 if (result > 0) {
55 cout<<"Time per value: "<<sw.RealTime()/result<<endl;
56 }
57 cout<<"Received values: "<<result<<endl;
58
59 TIter iter(&values);
60 TObjString* aRequest;
61 while ((aRequest = (TObjString*) iter.Next())) {
62
63 TObjArray* valueSet = (TObjArray*) values.GetValue(aRequest);
64
65 cout<<" '"<<aRequest->String()<<"' values: "
66 <<valueSet->GetEntriesFast()<<endl;
67
68 TIter valIter(valueSet);
69 AliDCSValue* aValue;
70 while ((aValue = (AliDCSValue*) valIter.Next())) {
71 cout<<aValue->ToString()<<endl;
72 }
73 }
74
75/*
76 TFile file("dump.root", "UPDATE");
77 file.cd();
78 valueSet->Write();
79 file.Close();
80*/
81
82 values.DeleteAll();
83 delete requests;
84
85 cout<<"All values returned in runrange: "<<endl;
86 cout<<"StartTime: "<<TTimeStamp(startTime).AsString()<<endl;
87 cout<<"EndTime: "<<TTimeStamp(endTime).AsString()<<endl;
88}
89
90void TestClientDP(const char* host, Int_t port, const char* request,
91 UInt_t startShift, UInt_t endShift) {
92
93 gSystem->Load("libSHUTTLE");
94
95// AliLog::EnableDebug(kFALSE);
96// AliLog::SetGlobalDebugLevel(3);
97
98 TTimeStamp currentTime;
99
100 GetValues(host, port, request,
101 currentTime.GetSec() - startShift,
102 currentTime.GetSec() - endShift);
103
104 cout<<"Client done"<<endl;
105}