Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:46

0001 #include "Utilities/StorageFactory/interface/StorageMaker.h"
0002 #include "Utilities/StorageFactory/interface/StorageMakerFactory.h"
0003 #include "Utilities/StorageFactory/interface/StorageFactory.h"
0004 #include "Utilities/LStoreAdaptor/interface/LStoreFile.h"
0005 #include "FWCore/Utilities/interface/Exception.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include <unistd.h>
0008 #include <iostream>
0009 
0010 namespace edm::storage {
0011   class LStoreStorageMaker : public StorageMaker {
0012   public:
0013     /** Open a storage object for the given URL (protocol + path), using the
0014       @a mode bits.  No temporary files are downloaded.  */
0015     std::unique_ptr<Storage> open(const std::string &proto,
0016                                   const std::string &path,
0017                                   int mode,
0018                                   const AuxSettings &) const override {
0019       std::string fullpath = proto + ":" + path;
0020       return std::make_unique<LStoreFile>(fullpath, mode);
0021     }
0022 
0023     /* I don't think this is necessary - Melo
0024   virtual void stagein (const std::string &proto, const std::string &path)
0025   {
0026     std::string fullpath(proto + ":" + path);
0027     XrdClientAdmin admin(fullpath.c_str());
0028     if (admin.Connect())
0029     {
0030       XrdOucString str(fullpath.c_str());
0031       XrdClientUrlSet url(str);
0032       admin.Prepare(url.GetFile().c_str(), kXR_stage | kXR_noerrs, 0);
0033     }
0034   }
0035 */
0036 
0037     bool check(const std::string &proto,
0038                const std::string &path,
0039                const AuxSettings &,
0040                IOOffset *size = nullptr) const override {
0041       std::string fullpath = proto + ":" + path;
0042       try {
0043         LStoreFile fileObj(fullpath);  // = LStoreFile (fullpath);
0044         *size = fileObj.position(0, Storage::END);
0045       } catch (cms::Exception &e) {
0046         return false;
0047       }
0048       return true;
0049     }
0050   };
0051 }  // namespace edm::storage
0052 
0053 using namespace edm::storage;
0054 DEFINE_EDM_PLUGIN(StorageMakerFactory, LStoreStorageMaker, "lstore");