AliDCSClient "multiSplit" option added in the DCS configuration
[u/mrichter/AliRoot.git] / SHUTTLE / DCSClient / macros / TestClientAlias.C
1 TMap* GetValues(const char* host, Int_t port, const char* request,
2         UInt_t startTime, UInt_t endTime) 
3 {
4         AliDCSClient client(host, port, 1000, 20, 100);
5         // The 5th parameter switches from single alias to multi aliases!
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         TMap* values=0;
19         
20         TStopwatch sw;
21         sw.Start();
22         
23         if(requests->GetEntries() == 0) return NULL;
24
25 //              TIter iter(requests);
26 //              TObjString* aString;
27 //              TObjArray* valueSet;
28 //              while ((aString = (TObjString*) iter.Next())) {
29 //                    cout<<"  Querying: "<<aString->GetName()<<endl;
30 //                    valueSet = new TObjArray();
31 //                    valueSet->SetOwner(1);
32 // 
33 //                      result = client.GetAliasValues(aString->GetName(), startTime,
34 //                              endTime, valueSet);
35 //                      values.Add(aString->Clone(), valueSet);
36 //              }
37  
38         values = client.GetAliasValues(requests, startTime, endTime);
39
40         if (!values) {
41                 cout<<"Communication failure: "<<
42                         client.GetServerError().Data() <<endl;
43                 return NULL;
44         }
45         
46         sw.Stop();
47         cout<<"Elapsed time: "<<sw.RealTime()<<endl;
48
49         cout<<"Time per alias: "<<sw.RealTime()/requests->GetEntries()<<endl;
50
51         cout<<"Received values: "<<endl;
52
53         Int_t nValues=0;
54
55         TIter iter(values);
56         TObjString* aRequest;
57         while ((aRequest = (TObjString*) iter.Next())) {
58
59                 TObjArray* valueSet = (TObjArray*) values->GetValue(aRequest);
60                 
61                 cout<<" '"<<aRequest->String()<<"' values: " 
62                         <<valueSet->GetEntriesFast()<<endl;
63
64                 TIter valIter(valueSet);
65                 AliDCSValue* aValue;
66                 while ((aValue = (AliDCSValue*) valIter.Next())) {
67                         cout<<aValue->ToString()<<endl;
68                         nValues++;
69                 } 
70         }
71         
72         cout<<"Number of received values: "<< nValues <<endl;
73         
74
75 /*
76         TFile file("dump.root", "UPDATE");
77         file.cd();
78         values.Write("DCSAliasMap", TObject::kSingleKey);
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         return values;
90 }
91
92 TMap* TestClientAlias(const char* host, Int_t port, const char* request,
93         UInt_t startShift, UInt_t endShift) {
94
95         gSystem->Load("$ALICE_ROOT/SHUTTLE/DCSClient/AliDCSClient");
96
97 //      AliLog::EnableDebug(kFALSE);
98 //      AliLog::SetGlobalDebugLevel(3);
99
100         TTimeStamp currentTime;
101
102         
103         TMap* values = GetValues(host, port, request,
104                 currentTime.GetSec() - startShift, 
105                 currentTime.GetSec() - endShift);
106
107                 
108 // SHUTTLE query interval 
109 /*      
110         TMap* values = GetValues(host, port, request,
111                 1181300060, 
112                 1181307260);
113 */
114         if(values) values->Print();
115
116         cout << endl;
117         cout <<"Client done"<<endl;
118         
119         return values;
120 }