CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/Utilities/XrdAdaptor/plugins/XrdStorageMaker.cc

Go to the documentation of this file.
00001 #include "Utilities/StorageFactory/interface/StorageMaker.h"
00002 #include "Utilities/StorageFactory/interface/StorageMakerFactory.h"
00003 #include "Utilities/XrdAdaptor/src/XrdFile.h"
00004 #include "XrdClient/XrdClientAdmin.hh"
00005 #include "XrdClient/XrdClientUrlSet.hh"
00006 #include "XrdClient/XrdClientEnv.hh"
00007 
00008 class XrdStorageMaker : public StorageMaker
00009 {
00010 public:
00013   virtual Storage *open (const std::string &proto,
00014                          const std::string &path,
00015                          int mode)
00016   {
00017     std::string fullpath(proto + ":" + path);
00018     return new XrdFile (fullpath, mode);
00019   }
00020 
00021   virtual void stagein (const std::string &proto, const std::string &path)
00022   {
00023     std::string fullpath(proto + ":" + path);
00024     XrdClientAdmin admin(fullpath.c_str());
00025     if (admin.Connect())
00026     {
00027       XrdOucString str(fullpath.c_str());
00028       XrdClientUrlSet url(str);
00029       admin.Prepare(url.GetFile().c_str(), kXR_stage | kXR_noerrs, 0);
00030     }
00031   }
00032 
00033   virtual bool check (const std::string &proto,
00034                       const std::string &path,
00035                       IOOffset *size = 0)
00036   {
00037     std::string fullpath(proto + ":" + path);
00038     XrdClientAdmin admin(fullpath.c_str());
00039     if (! admin.Connect())
00040       return false; // FIXME: Throw?
00041 
00042     long      id;
00043     long      flags;
00044     long      modtime;
00045     long long xrdsize;
00046 
00047     XrdOucString str(fullpath.c_str());
00048     XrdClientUrlSet url(str);
00049 
00050     if (! admin.Stat(url.GetFile().c_str(), id, xrdsize, flags, modtime))
00051       return false; // FIXME: Throw?
00052 
00053     *size = xrdsize;
00054     return true;
00055   }
00056 
00057   virtual void setDebugLevel (unsigned int level)
00058   {
00059     EnvPutInt("DebugLevel", level);
00060   }
00061 };
00062 
00063 DEFINE_EDM_PLUGIN (StorageMakerFactory, XrdStorageMaker, "root");