From 9174317d7857acc68eb682396a0669dad059ad0c Mon Sep 17 00:00:00 2001 From: rdm Date: Sat, 29 Nov 2003 00:15:18 +0000 Subject: [PATCH] add support for TCastorFile (use CASTOR over rootd) and use AliEn as catalog. --- RAW/AARUN | 1 + RAW/AliRawEvent.cxx | 179 ++++++++++++++++++++++++++++++++++++++------ RAW/AliRawEvent.h | 46 ++++++++---- RAW/LinkDef.h | 1 + RAW/Make-macros | 4 +- RAW/Makefile | 2 +- RAW/alimdc.cxx | 17 +++-- 7 files changed, 201 insertions(+), 49 deletions(-) diff --git a/RAW/AARUN b/RAW/AARUN index a2e73a30e4c..b7c34a27580 100644 --- a/RAW/AARUN +++ b/RAW/AARUN @@ -1,4 +1,5 @@ ./alimdc 1000000000 0 -0 -datebig.raw # endless loop to RFIO ./alimdc 1000000000 0 +0 -datebig.raw # endless loop to rootd +./alimdc 1000000000 0 %0 -datebig.raw # endless loop to CASTOR/rootd ./alimdc 1000000000 0 0 -datebig.raw # endless loop to local file in /tmp ./alimdc 1000000000 0 @0 -datebig.raw # endless loop to /dev/null diff --git a/RAW/AliRawEvent.cxx b/RAW/AliRawEvent.cxx index f36d416f2e7..82889aaa7c9 100644 --- a/RAW/AliRawEvent.cxx +++ b/RAW/AliRawEvent.cxx @@ -20,12 +20,13 @@ #include #include -#include #include #include #include #include #include +#include +#include #if defined(__APPLE__) #undef Free @@ -48,6 +49,7 @@ ClassImp(AliRawData) ClassImp(AliStats) ClassImp(AliRawDB) ClassImp(AliRawRFIODB) +ClassImp(AliRawCastorDB) ClassImp(AliRawRootdDB) ClassImp(AliRawNullDB) ClassImp(AliTagDB) @@ -56,7 +58,7 @@ ClassImp(AliRunDB) ClassImp(AliMDC) // Which MDC is this... -const Int_t kMDC = 4; +const Int_t kMDC = 5; // Fixed file system locations for the different DB's #ifdef USE_RDM @@ -65,14 +67,20 @@ const char *kRawDBFS[2] = { "/tmp/mdc1", "/tmp/mdc2" }; const char *kTagDBFS = "/tmp/mdc1/tags"; const char *kRunDBFS = "/tmp/mdc1/meta"; const char *kRFIOFS = "rfio:/castor/cern.ch/user/r/rdm"; +const char *kCastorFS = "castor:/castor/cern.ch/user/r/rdm"; const char *kRootdFS = "root://localhost//tmp/mdc1"; +const char *kAlienHost = "alien://aliens7.cern.ch:15000/?direct"; +const char *kAlienDir = "/alice_mdc/DC"; #else const char *kFifo = "/tmp/alimdc.fifo"; -const char *kRawDBFS[2] = { "/scratch/mdc1", "/scratch/mdc2" }; -const char *kTagDBFS = "/scratch/mdc1/tags"; -const char *kRunDBFS = "/scratch/mdc1/meta"; -const char *kRFIOFS = "rfio:/castor/cern.ch/lcg/alicemdc4"; +const char *kRawDBFS[2] = { "/data1/mdc", "/data2/mdc" }; +const char *kTagDBFS = "/data1/mdc/tags"; +const char *kRunDBFS = "/data1/mdc/meta"; +const char *kRFIOFS = "rfio:/castor/cern.ch/lcg/dc5"; +const char *kCastorFS = "castor:/castor/cern.ch/lcg/dc5"; const char *kRootdFS = "root://localhost//tmp/mdc1"; +const char *kAlienHost = "alien://aliens7.cern.ch:15000/?direct"; +const char *kAlienDir = "/alice_mdc/DC"; #endif // Maximum size of tag db files @@ -372,6 +380,7 @@ void AliStats::WriteToDB(AliRawDB *rawdb) AliRunDB *rundb = new AliRunDB; rundb->Update(this); rundb->UpdateRDBMS(this); + rundb->UpdateAliEn(this); delete rundb; } @@ -580,8 +589,8 @@ AliRawRFIODB::AliRawRFIODB(AliRawEvent *event, Double_t maxsize, Int_t compress) // THESE ENVIRONMENT SYMBOLS ARE NOW DEFINED BY THE ALICE DATE SETUP // THEREFORE WE SHALL NOT USE ANY HARDCODED VALUES BUT RATHER USE // WHATEVER HAS BEEN SET IN THE DATE SITE - //gSystem->Setenv("STAGE_POOL", "mdc4"); - //gSystem->Setenv("STAGE_HOST", "lxshare003d"); + //gSystem->Setenv("STAGE_POOL", "lcg00"); + //gSystem->Setenv("STAGE_HOST", "stage013"); init = 1; } #endif @@ -649,8 +658,106 @@ void AliRawRFIODB::Close() // Close DB, this also deletes the fTree fRawDB->Close(); - if (AliMDC::DeleteFiles()) - gSystem->Exec(Form("rfrm %s", fRawDB->GetName())); + if (AliMDC::DeleteFiles()) { + TUrl u(fRawDB->GetName()); + gSystem->Exec(Form("rfrm %s", u.GetFile())); + } + + delete fRawDB; + fRawDB = 0; +} + + +//______________________________________________________________________________ +AliRawCastorDB::AliRawCastorDB(AliRawEvent *event, Double_t maxsize, Int_t compress) + : AliRawDB(event, maxsize, compress, kFALSE) +{ + // Create a new raw DB that will be accessed via CASTOR and rootd. + +#ifndef USE_RDM + static int init = 0; + // Set STAGE_POOL environment variable to current host + if (!init) { + // THESE ENVIRONMENT SYMBOLS ARE NOW DEFINED BY THE ALICE DATE SETUP + // THEREFORE WE SHALL NOT USE ANY HARDCODED VALUES BUT RATHER USE + // WHATEVER HAS BEEN SET IN THE DATE SITE + //gSystem->Setenv("STAGE_POOL", "lcg00"); + //gSystem->Setenv("STAGE_HOST", "stage013"); + init = 1; + } +#endif + + if (!Create()) + MakeZombie(); + else + fRawDB->UseCache(50, 0x200000); //0x100000 = 1MB) +} + +//______________________________________________________________________________ +const char *AliRawCastorDB::GetFileName() +{ + // Return filename based on hostname and date and time. This will make + // each file unique. Also the directory will be made unique for each + // day by adding the date to the fs. Assumes there is always enough + // space on the device. + + static TString fname; + + TString fs = kCastorFS; + TString fsr = kRFIOFS; + TDatime dt; + + // make a new subdirectory for each day + fs += "/adc-"; + fs += dt.GetDate(); + + fsr += "/adc-"; + fsr += dt.GetDate(); + + Long_t id, size, flags, time; + if (gSystem->GetPathInfo(fsr, &id, &size, &flags, &time) == 1) { + // directory does not exist, create it + if (gSystem->mkdir(fsr, kTRUE) == -1) { + Error("GetFileName", "cannot create dir %s, using %s", fsr.Data(), + kRFIOFS); + fs = kCastorFS; + } + } + // FIXME: should check if fs is a directory + + TString hostname = gSystem->HostName(); + Int_t pos; + if ((pos = hostname.Index(".")) != kNPOS) + hostname.Remove(pos); + + fname = fs + "/" + hostname + "_"; + fname += dt.GetDate(); + fname += "_"; + fname += dt.GetTime(); + fname += ".root"; + + return fname; +} + +//______________________________________________________________________________ +void AliRawCastorDB::Close() +{ + // Close raw CASTOR/rootd DB. + + if (!fRawDB) return; + + fRawDB->cd(); + + // Write the tree. + fTree->Write(); + + // Close DB, this also deletes the fTree + fRawDB->Close(); + + if (AliMDC::DeleteFiles()) { + TUrl u(fRawDB->GetName()); + gSystem->Exec(Form("rfrm %s", u.GetFile())); + } delete fRawDB; fRawDB = 0; @@ -1015,6 +1122,26 @@ void AliRunDB::UpdateRDBMS(AliStats *stats) delete db; } +//______________________________________________________________________________ +void AliRunDB::UpdateAliEn(AliStats *stats) +{ + // Record file in AliEn catalog. + + TGrid *g = TGrid::Connect(kAlienHost, ""); + + TString lfn = kAlienDir; + lfn += "/"; + lfn += gSystem->BaseName(stats->GetFileName()); + +printf("AliEn: AddFile(%s, %s, %d)\n", lfn.Data(), stats->GetFileName(), + (int)stats->GetFileSize()); + + // crashes on ia64 + //g->AddFile(lfn, stats->GetFileName(), (int)stats->GetFileSize()); + + delete g; +} + //______________________________________________________________________________ void AliRunDB::Close() { @@ -1035,8 +1162,7 @@ public: //______________________________________________________________________________ AliMDC::AliMDC(Int_t fd, Int_t compress, Double_t maxFileSize, Bool_t useFilter, - Bool_t useRFIO, Bool_t useROOTD, Bool_t useDEVNULL, - Bool_t useLoop, Bool_t delFiles) + EWriteMode mode, Bool_t useLoop, Bool_t delFiles) { // Create MDC processor object. @@ -1044,9 +1170,7 @@ AliMDC::AliMDC(Int_t fd, Int_t compress, Double_t maxFileSize, Bool_t useFilter, fCompress = compress; fMaxFileSize = maxFileSize; fUseFilter = useFilter; - fUseRFIO = useRFIO; - fUseRootd = useROOTD; - fUseDevNull = useDEVNULL; + fWriteMode = mode; fUseLoop = useLoop; fUseFifo = kFALSE; fUseEb = kFALSE; @@ -1086,11 +1210,13 @@ AliMDC::AliMDC(Int_t fd, Int_t compress, Double_t maxFileSize, Bool_t useFilter, fUseFifo ? "fifo" : (fUseEb ? "eb" : "file"), fMaxFileSize, fUseFilter ? "on" : "off", fUseLoop ? "yes" : "no", fCompress, fgDeleteFiles ? "yes" : "no"); - if (fUseRFIO) + if (fWriteMode == kRFIO) printf(", use RFIO\n"); - else if (fUseRootd) + else if (fWriteMode == kROOTD) printf(", use rootd\n"); - else if (fUseDevNull) + else if (fWriteMode == kCASTOR) + printf(", use CASTOR/rootd\n"); + else if (fWriteMode == kDEVNULL) printf(", write raw data to /dev/null\n"); else printf("\n"); @@ -1136,11 +1262,13 @@ Int_t AliMDC::Run() // Create new raw DB. AliRawDB *rawdb; - if (fUseRFIO) + if (fWriteMode == kRFIO) rawdb = new AliRawRFIODB(event, fMaxFileSize, fCompress); - else if (fUseRootd) + else if (fWriteMode == kROOTD) rawdb = new AliRawRootdDB(event, fMaxFileSize, fCompress); - else if (fUseDevNull) + else if (fWriteMode == kCASTOR) + rawdb = new AliRawCastorDB(event, fMaxFileSize, fCompress); + else if (fWriteMode == kDEVNULL) rawdb = new AliRawNullDB(event, fMaxFileSize, fCompress); else rawdb = new AliRawDB(event, fMaxFileSize, fCompress); @@ -1149,8 +1277,10 @@ Int_t AliMDC::Run() printf("Filling raw DB %s\n", rawdb->GetDBName()); // Create new tag DB. - AliTagDB *tagdb; - if (fUseDevNull) + AliTagDB *tagdb = 0; +#if 0 + // no tagdb for the time being to get maximum speed + if (fWriteMode == kDEVNULL) tagdb = new AliTagNullDB(event->GetHeader(), kMaxTagFileSize); else tagdb = new AliTagDB(event->GetHeader(), kMaxTagFileSize); @@ -1158,6 +1288,7 @@ Int_t AliMDC::Run() tagdb = 0; else printf("Filling tag DB %s\n", tagdb->GetDBName()); +#endif // Create AliStats object AliStats *stats = new AliStats(rawdb->GetDBName(), fCompress, fUseFilter); @@ -1381,7 +1512,7 @@ Int_t AliMDC::Run() } // Check size of tag db - if (tagdb->FileFull()) { + if (tagdb && tagdb->FileFull()) { if (!tagdb->NextFile()) tagdb = 0; else diff --git a/RAW/AliRawEvent.h b/RAW/AliRawEvent.h index 5f4f8988826..f28380190c0 100644 --- a/RAW/AliRawEvent.h +++ b/RAW/AliRawEvent.h @@ -302,6 +302,21 @@ public: }; +class AliRawCastorDB : public AliRawDB { + +private: + const char *GetFileName(); + +public: + AliRawCastorDB(AliRawEvent *event, Double_t maxsize, Int_t compress); + ~AliRawCastorDB() { Close(); } + + void Close(); + + ClassDef(AliRawCastorDB,0) // Raw DB via CASTOR and rootd +}; + + class AliRawRootdDB : public AliRawDB { private: @@ -391,6 +406,7 @@ public: void Update(AliStats *stats); void UpdateRDBMS(AliStats *stats); + void UpdateAliEn(AliStats *stats); void Close(); ClassDef(AliRunDB,0) // Run (bookkeeping) DB @@ -399,20 +415,21 @@ public: class AliMDC : public TObject { +public: + enum EWriteMode { kLOCAL, kRFIO, kROOTD, kCASTOR, kDEVNULL }; + private: - Int_t fFd; // DATE input stream - Int_t fCompress; // compression factor used for raw output DB - Int_t fNumEvents; // number of events processed - Int_t fDebugLevel; // controls debug print-out - Double_t fMaxFileSize; // maximum size of raw output DB - Bool_t fUseFifo; // read from fifo, file otherwise - Bool_t fUseEb; // use event builder API instead of fifo - Bool_t fUseFilter; // use 3rd level trigger filter - Bool_t fUseRFIO; // write directly to RFIO file - Bool_t fUseRootd; // write directly to rootd file - Bool_t fUseDevNull; // write to /dev/null - Bool_t fUseLoop; // loop on input source (must be file) - Bool_t fStopLoop; // break from endless loop (triggered by SIGUSR1) + Int_t fFd; // DATE input stream + Int_t fCompress; // compression factor used for raw output DB + Int_t fNumEvents; // number of events processed + Int_t fDebugLevel; // controls debug print-out + Double_t fMaxFileSize; // maximum size of raw output DB + EWriteMode fWriteMode; // write mode (local, rfio, rootd, castor, /dev/null) + Bool_t fUseFifo; // read from fifo, file otherwise + Bool_t fUseEb; // use event builder API instead of fifo + Bool_t fUseFilter; // use 3rd level trigger filter + Bool_t fUseLoop; // loop on input source (must be file) + Bool_t fStopLoop; // break from endless loop (triggered by SIGUSR1) static Bool_t fgDeleteFiles; @@ -427,8 +444,7 @@ private: public: AliMDC(Int_t fd, Int_t compress, Double_t maxFileSize, Bool_t useFilter, - Bool_t useRFIO, Bool_t useROOTD, Bool_t useDEVNULL, - Bool_t useLoop, Bool_t delFiles); + EWriteMode mode, Bool_t useLoop, Bool_t delFiles); ~AliMDC() { } Int_t Run(); diff --git a/RAW/LinkDef.h b/RAW/LinkDef.h index aa81c286606..2dc818c4bf2 100644 --- a/RAW/LinkDef.h +++ b/RAW/LinkDef.h @@ -13,6 +13,7 @@ #pragma link C++ class AliStats; #pragma link C++ class AliRawDB; #pragma link C++ class AliRawRFIODB; +#pragma link C++ class AliRawCastorDB; #pragma link C++ class AliRawRootdDB; #pragma link C++ class AliRawNullDB; #pragma link C++ class AliTagDB; diff --git a/RAW/Make-macros b/RAW/Make-macros index efcacbe88cc..5e3c7460551 100644 --- a/RAW/Make-macros +++ b/RAW/Make-macros @@ -4,8 +4,8 @@ ROOTH = TH1.h SRCS = AliRawEvent.cxx \ AliRawReader.cxx AliRawReaderFile.cxx AliRawReaderRoot.cxx \ - AliTPCBuffer160.cxx AliTPCHuffman.cxx AliTPCCompression.cxx \ - AliTPCRawStream.cxx \ + AliRawReaderDate.cxx AliTPCBuffer160.cxx AliTPCHuffman.cxx \ + AliTPCCompression.cxx AliTPCRawStream.cxx \ AliITSRawStream.cxx AliITSRawStreamSPD.cxx \ AliITSRawStreamSDD.cxx AliITSRawStreamSSD.cxx diff --git a/RAW/Makefile b/RAW/Makefile index afc2a677dae..65c55527a72 100644 --- a/RAW/Makefile +++ b/RAW/Makefile @@ -5,7 +5,7 @@ include $(ROOTSYS)/test/Makefile.arch LDFLAGS += -Wl,-rpath,/ROOT/Linux/CurrentRelease/root/lib \ -Wl,-rpath,/date/smi/linux \ -Wl,-rpath,/date/dim/linux \ - -Wl,-rpath,/adcRoot/alimdc4 + -Wl,-rpath,/adcRoot/alimdc5 ifneq ($(findstring rdm,$(MAKECMDGOALS)),) CXXFLAGS += -DUSE_RDM diff --git a/RAW/alimdc.cxx b/RAW/alimdc.cxx index 3b631238ab7..622b468f22f 100644 --- a/RAW/alimdc.cxx +++ b/RAW/alimdc.cxx @@ -69,7 +69,8 @@ static void Usage(const char *prognam) fprintf(stderr, " = state of 3rd level filter (0 or 1)\n"); fprintf(stderr, " = compression level (see TFile)\n"); fprintf(stderr, " (precede by - to use RFIO, -0 is RFIO and 0 compression)\n"); - fprintf(stderr, " (precede by + to use rootd, -0 is rootd and 0 compression)\n"); + fprintf(stderr, " (precede by + to use rootd, +0 is rootd and 0 compression)\n"); + fprintf(stderr, " (precede by %% to use Castor/rootd, %%0 is Castor/rootd and 0 compression)\n"); fprintf(stderr, " (precede by @ to use /dev/null as sink)\n"); #ifdef USE_EB fprintf(stderr, " [date_file] = optional input file (default reads from DATE EventBuffer)\n"); @@ -114,7 +115,7 @@ int main(int argc, char **argv) } #endif - Bool_t useRFIO = kFALSE, useROOTD = kFALSE, useDEVNULL = kFALSE; + AliMDC::EWriteMode wmode = AliMDC::kLOCAL; Bool_t useFilter = kFALSE, useLoop = kFALSE; Bool_t delFiles = kFALSE; Int_t fd = -1, compress; @@ -136,13 +137,16 @@ int main(int argc, char **argv) useFilter = kTRUE; if (argv[3][0] == '-') { - useRFIO = kTRUE; + wmode = AliMDC::kRFIO; compress = atoi(argv[3]+1); } else if (argv[3][0] == '+') { - useROOTD = kTRUE; + wmode = AliMDC::kROOTD; + compress = atoi(argv[3]+1); + } else if (argv[3][0] == '%') { + wmode = AliMDC::kCASTOR; compress = atoi(argv[3]+1); } else if (argv[3][0] == '@') { - useDEVNULL = kTRUE; + wmode = AliMDC::kDEVNULL; compress = atoi(argv[3]+1); } else compress = atoi(argv[3]); @@ -164,8 +168,7 @@ int main(int argc, char **argv) } // Create MDC processor object and process input stream - AliMDC mdcproc(fd, compress, maxFileSize, useFilter, useRFIO, useROOTD, - useDEVNULL, useLoop, delFiles); + AliMDC mdcproc(fd, compress, maxFileSize, useFilter, wmode, useLoop, delFiles); #ifdef USE_DEBUG mdcproc.SetDebugLevel(3); -- 2.39.3