24 #include "THttpServer.h"
25 #include "TRootSniffer.h"
26 #include "TRootSnifferStore.h"
52 virtual void SetField(Int_t lvl,
const char* field,
const char* value, Bool_t with_quotes)
55 if (!strcmp(
"value",
"true")) {
curr.
SetField(field,
true);
return; }
56 if (!strcmp(
"value",
"false")) {
curr.
SetField(field,
false);
return; }
57 if ((strlen(value)>2) && (*value==
'[')) {
66 if ((strcmp(field,
"_autoload")==0) && (*value ==
'/')) {
70 res.ReplaceAll(
";/", std::string(
"/") +
prefix);
73 if ((strcmp(field,
"_icon")==0) && (*value ==
'/'))
93 dabc::Worker(MakePair(name)),
97 fRootCmds(
dabc::CommandsQueue::kindPostponed),
100 fEnabled = Cfg(
"enabled", cmd).AsBool(
false);
101 if (!fEnabled)
return;
102 fPrefix = Cfg(
"prefix", cmd).AsStr(
"ROOT");
115 EOUT(
"sniffer was not enabled - why it is started??");
119 fHierarchy.Create(
"ROOT",
true);
120 InitializeHierarchy();
122 Publish(fHierarchy, fPrefix);
135 if (cmd.
IsName(dabc::CmdGetBinary::CmdName()) ||
136 cmd.
IsName(dabc::CmdGetNamesList::CmdName()) ||
137 cmd.
IsName(dabc::CmdHierarchyExec::CmdName())) {
153 sniff->ScanHierarchy(
"DABC", path, &store);
162 std::string itemname = cmd.
GetStr(
"subitem");
163 std::string binkind = cmd.
GetStr(
"Kind");
164 std::string query = cmd.
GetStr(
"Query");
168 TString realfilename;
169 std::string filename = std::string(
"/") + itemname + std::string(
"/") + binkind;
171 if (serv->IsFileRequested(filename.c_str(), realfilename)) {
172 DOUT0(
"Item %s Send file %s ", filename.c_str(), realfilename.Data());
175 char *ptr = THttpServer::ReadFileContent(realfilename.Data(), len);
182 if (binkind ==
"root.bin") {
185 uint64_t version = 0;
186 dabc::Url url(std::string(
"getbin?") + query);
187 if (url.IsValid() && url.HasOption(
"version"))
188 version = (unsigned) url.GetOptionInt(
"version", 0);
190 ULong_t objhash = sniff->GetItemHash(itemname.c_str());
192 bool binchanged =
true;
195 binchanged = fHierarchy.IsBinItemChanged(itemname, objhash, version);
203 fHierarchy.FillBinHeader(itemname, cmd);
211 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,13,0)
215 if (!sniff->Produce(itemname, binkind, query, str)) {
216 EOUT(
"ROOT sniffer producer fails for item %s kind %s", itemname.c_str(), binkind.c_str());
230 if (!sniff->Produce(itemname.c_str(), binkind.c_str(), query.c_str(), ptr, length, str)) {
231 EOUT(
"ROOT sniffer producer fails for item %s kind %s", itemname.c_str(), binkind.c_str());
243 if (binkind ==
"root.bin") {
245 ULong_t mhash = sniff->GetStreamerInfoHash();
249 fHierarchy.FillBinHeader(itemname, cmd, mhash);
262 if (fLastUpdate.null() || fLastUpdate.Expired(3.)) {
263 DOUT3(
"Update ROOT structures");
264 RescanHierarchy(sniff, fRoot);
265 fLastUpdate.GetNow();
270 fHierarchy.Update(fRoot);
277 if (cmd.
IsName(dabc::CmdGetBinary::CmdName())) {
278 cmd.
Reply(ProcessGetBinary(serv, sniff, cmd));
280 if (cmd.
IsName(dabc::CmdGetNamesList::CmdName())) {
281 std::string item = cmd.
GetStr(
"subitem");
286 if (fLastUpdate.null() || fLastUpdate.Expired(3.)) {
287 RescanHierarchy(sniff, fRoot);
288 fLastUpdate.GetNow();
290 fHierarchy.Update(fRoot);
295 RescanHierarchy(sniff, res, item.c_str());
306 if (cmd.
IsName(dabc::CmdHierarchyExec::CmdName())) {
317 if (fRootCmds.Size()>0) cmd = fRootCmds.Pop();
318 doagain = !cmd.
null();
virtual void SetField(Int_t lvl, const char *field, const char *value, Bool_t with_quotes)
virtual void CloseNode(Int_t, Int_t)
virtual ~TRootSnifferStoreDabc()
TRootSnifferStoreDabc(dabc::Hierarchy &_top, const std::string &_prefix)
virtual void CreateNode(Int_t lvl, const char *nodename)
virtual void BeforeNextChild(Int_t, Int_t, Int_t)
Reference on memory from memory pool.
static Buffer CreateBuffer(BufferSize_t sz)
This static method create independent buffer for any other memory pools Therefore it can be used in s...
static void SetResNamesList(dabc::Command &cmd, Hierarchy &res)
Represents command with its arguments.
bool SetRawData(Buffer rawdata)
Set raw data to the command, which can be transported also between nodes.
std::string GetStr(const std::string &name, const std::string &dflt="") const
void ReplyFalse()
Reply on the command with false (cmd_false==0) value.
void ReplyTrue()
Reply on the command with true (cmd_true==1) value.
void Reply(int res=cmd_noresult)
Replied on the command.
Represents objects hierarchy of remote (or local) DABC process.
Hierarchy CreateHChild(const std::string &name, bool allowslahes=false, bool sortorder=false)
Create child item in hierarchy with specified name If allowslahes enabled, instead of subfolders item...
void Create(const std::string &name, bool withmutex=false)
Create top-level object with specified name.
Lock guard for posix mutex.
std::vector< int64_t > AsIntVect() const
bool SetField(const std::string &name, const RecordField &v)
const char * GetName() const
Return name of referenced object, if object not assigned, returns "---".
Reference GetParentRef() const
Returns reference on parent object.
bool IsName(const char *name) const
Returns true if object name is the same as specified one.
bool null() const
Returns true if reference contains nullptr.
Uniform Resource Locator interpreter.
virtual void OnThreadAssigned()
virtual int ExecuteCommand(Command cmd)
Main method where commands are executed.
virtual void OnThreadAssigned()
Monitor(const std::string &name, dabc::Command cmd=nullptr)
virtual double ProcessTimeout(double last_diff)
void RescanHierarchy(TRootSniffer *sniff, dabc::Hierarchy &main, const char *path=0)
Method scans normal objects, registered in ROOT and DABC.
virtual int ProcessGetBinary(THttpServer *serv, TRootSniffer *sniff, dabc::Command cmd)
void ProcessActionsInRootContext(THttpServer *serv, TRootSniffer *sniff)
virtual int ExecuteCommand(dabc::Command cmd)
Main method where commands are executed.
int main(int numc, char *args[])