Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
TMPIClientInfo.cxx
Go to the documentation of this file.
1// @(#)root/io:$Id$
2// Author: Amit Bashyal, August 2018
3
4/*************************************************************************
5 * Copyright (C) 1995-2002, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TMPIClientInfo.h"
13#include "TSystem.h"
14#include "TClass.h"
15#include "TKey.h"
16
17
19
23{
24 fLocalName.Form("%s-%d-%d", filename, clientId, gSystem->GetPid());
25}
26
28{
29 // Register the new file as coming from this client.
30 if (file != fFile) {
31 if (fFile) {
33 // delete the previous memory file (if any)
34 delete file;
35 } else {
36 fFile = file;
37 }
38 }
39 TTimeStamp now;
40 fTimeSincePrevContact = now.AsDouble() - fLastContact.AsDouble();
41 fLastContact = now;
43}
44
46{
47 if (destination == 0 || source == 0)
48 return;
49 TIter nextkey(source->GetListOfKeys());
50 TKey *key;
51 while ((key = (TKey *)nextkey())) {
53 if (cl->InheritsFrom(TDirectory::Class())) {
54 TDirectory *source_subdir = (TDirectory *)source->GetList()->FindObject(key->GetName());
55 if (!source_subdir) {
56 source_subdir = (TDirectory *)key->ReadObj();
57 }
58 TDirectory *destination_subdir = destination->GetDirectory(key->GetName());
59 if (!destination_subdir) {
60 destination_subdir = destination->mkdir(key->GetName());
61 }
62 MigrateKey(destination, source);
63 } else {
64 TKey *oldkey = destination->GetKey(key->GetName());
65 if (oldkey) {
66 oldkey->Delete();
67 delete oldkey;
68 }
69 TKey *newkey = new TKey(destination, *key, 0 /* pidoffset */);
70 destination->GetFile()->SumBuffer(newkey->GetObjlen());
71 newkey->WriteFile(0);
72 if (destination->GetFile()->TestBit(TFile::kWriteError)) {
73 return;
74 }
75 }
76 }
77 destination->SaveSelf();
78}
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
Definition RtypesCore.h:60
externTSystem * gSystem
Definition TSystem.h:582
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:2994
Describe directory structure in memory.
Definition TDirectory.h:45
static TClass * Class()
virtual TList * GetList() const
Definition TDirectory.h:223
virtual TDirectory * GetDirectory(const char *namecycle, Bool_t printError=false, const char *funcname="GetDirectory")
Find a directory using apath.
virtual TFile * GetFile() const
Definition TDirectory.h:221
virtual TKey * GetKey(const char *, Short_t=9999) const
Definition TDirectory.h:222
virtual void SaveSelf(Bool_t=kFALSE)
Definition TDirectory.h:256
virtual TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE)
Create a sub-directory "a" or a hierarchy of sub-directories "a/b/c/...".
virtual TList * GetListOfKeys() const
Definition TDirectory.h:224
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
Definition TFile.h:130
void SumBuffer(Int_t bufsize)
Increment statistics for buffer sizes of objects in this file.
Definition TFile.cxx:2470
@ kWriteError
Definition TFile.h:268
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition TKey.h:28
void Delete(Option_t *option="") override
Delete an object from the file.
Definition TKey.cxx:572
Int_t GetObjlen() const
Definition TKey.h:89
virtual const char * GetClassName() const
Definition TKey.h:77
virtual TObject * ReadObj()
To read a TObject* from the file.
Definition TKey.cxx:792
virtual Int_t WriteFile(Int_t cycle=1, TFile *f=nullptr)
Write the encoded object supported by this key.
Definition TKey.cxx:1472
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
Definition TList.cxx:708
TTimeStamp fLastContact
virtual ~TMPIClientInfo()
Double_t fTimeSincePrevContact
void SetFile(TFile *file)
static void MigrateKey(TDirectory *destination, TDirectory *source)
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
Bool_t TestBit(UInt_t f) const
Definition TObject.h:204
The TTimeStamp encapsulates seconds and ns since EPOCH.
Definition TTimeStamp.h:45
Double_t AsDouble() const
Definition TTimeStamp.h:112
auto filename
void file()
Definition file.C:11