8 #ifndef SRC_XRDCL_XRDCLECHANDLER_HH_
9 #define SRC_XRDCL_XRDCLECHANDLER_HH_
55 if( !st.
IsOK() )
return st;
58 writer->Open( handler, timeout );
70 if( !st.
IsOK() )
return st;
73 reader->Open( handler, timeout );
86 (void)url; (void)mode;
87 return Open( flags, handler, timeout );
104 std::string commit = redir.GetPath()
105 +
"?xrdec.objid=" + objcfg->obj
106 +
"&xrdec.close=true&xrdec.size=" + std::to_string( curroff );
109 std::string ckstype = cksHelper->GetType();
111 auto st = cksHelper->GetCheckSum( cksval, ckstype );
114 handler->HandleResponse( new XRootDStatus( st ), nullptr );
117 commit +=
"&xrdec.cksum=" + cksval;
134 handler->HandleResponse( st, rsp );
136 return XRootDStatus();
150 if( !objcfg->nomtfile )
151 return fs.Stat( redir.GetPath(), handler, timeout );
153 if( !force && statcache )
155 auto rsp = StatRsp( statcache->GetSize() );
156 Schedule( handler, rsp );
163 statcache->SetSize( writer->GetSize() );
164 auto rsp = StatRsp( statcache->GetSize() );
165 Schedule( handler, rsp );
172 statcache->SetSize( reader->GetSize() );
173 auto rsp = StatRsp( statcache->GetSize() );
174 Schedule( handler, rsp );
192 reader->Read( offset, size, buffer, handler, timeout );
206 cksHelper->Update( buffer, size );
210 writer->Write( size, buffer, handler );
220 return writer || reader;
229 std::unique_ptr<LocationInfo> ptr( info );
230 if( !st.
IsOK() )
return st;
231 if( info->
GetSize() < objcfg->nbchunks )
233 unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
234 shuffle (info->
Begin(), info->
End(), std::default_random_engine(seed));
235 for(
size_t i = 0; i < objcfg->nbchunks; ++i )
237 auto &location = info->
At( i );
238 objcfg->plgr.emplace_back(
"root://" + location.GetAddress() +
'/' );
247 std::unique_ptr<LocationInfo> ptr( info );
248 if( !st.
IsOK() )
return st;
249 if( info->
GetSize() < objcfg->nbdata )
251 for(
size_t i = 0; i < info->
GetSize(); ++i )
253 auto &location = info->
At( i );
254 objcfg->plgr.emplace_back(
"root://" + location.GetAddress() +
'/' );
277 std::unique_ptr<XrdEc::StrmWriter>
writer;
295 std::vector<std::string> && plgr ) :
296 nbdta( nbdta ), nbprt( nbprt ), chsz( chsz ), plgr(
std::move( plgr ) )
315 objcfg->
plgr = std::move( plgr );
316 return new EcHandler( url, objcfg,
nullptr );
Definition: XrdClAnyObject.hh:33
void Set(Type object, bool own=true)
Definition: XrdClAnyObject.hh:59
Binary blob representation.
Definition: XrdClBuffer.hh:34
void FromString(const std::string str)
Fill the buffer from a string.
Definition: XrdClBuffer.hh:205
static PostMaster * GetPostMaster()
Get default post master.
Definition: XrdClEcHandler.hh:24
static void Schedule(ResponseHandler *handler, AnyObject *rsp)
Definition: XrdClEcHandler.hh:268
std::unique_ptr< XrdEc::Reader > reader
Definition: XrdClEcHandler.hh:278
XRootDStatus LoadPlacement(const std::string &path)
Definition: XrdClEcHandler.hh:243
static AnyObject * StatRsp(uint64_t size)
Definition: XrdClEcHandler.hh:259
XRootDStatus Close(ResponseHandler *handler, uint16_t timeout)
Definition: XrdClEcHandler.hh:94
std::unique_ptr< XrdEc::ObjCfg > objcfg
Definition: XrdClEcHandler.hh:276
FileSystem fs
Definition: XrdClEcHandler.hh:275
XRootDStatus Open(const std::string &url, OpenFlags::Flags flags, Access::Mode mode, ResponseHandler *handler, uint16_t timeout)
Definition: XrdClEcHandler.hh:80
XRootDStatus Write(uint64_t offset, uint32_t size, const void *buffer, ResponseHandler *handler, uint16_t timeout)
Definition: XrdClEcHandler.hh:199
uint64_t curroff
Definition: XrdClEcHandler.hh:279
XRootDStatus Stat(bool force, ResponseHandler *handler, uint16_t timeout)
Definition: XrdClEcHandler.hh:145
bool IsOpen() const
Definition: XrdClEcHandler.hh:218
XRootDStatus Read(uint64_t offset, uint32_t size, void *buffer, ResponseHandler *handler, uint16_t timeout)
Definition: XrdClEcHandler.hh:184
URL redir
Definition: XrdClEcHandler.hh:274
std::unique_ptr< XrdEc::StrmWriter > writer
Definition: XrdClEcHandler.hh:277
XRootDStatus Open(uint16_t flags, ResponseHandler *handler, uint16_t timeout)
Definition: XrdClEcHandler.hh:41
std::unique_ptr< StatInfo > statcache
Definition: XrdClEcHandler.hh:281
virtual ~EcHandler()
Definition: XrdClEcHandler.hh:37
EcHandler(const URL &redir, XrdEc::ObjCfg *objcfg, std::unique_ptr< CheckSumHelper > cksHelper)
Definition: XrdClEcHandler.hh:26
std::unique_ptr< CheckSumHelper > cksHelper
Definition: XrdClEcHandler.hh:280
XRootDStatus LoadPlacement()
Definition: XrdClEcHandler.hh:225
Plugin factory.
Definition: XrdClEcHandler.hh:289
uint64_t chsz
Definition: XrdClEcHandler.hh:330
EcPlugInFactory(uint8_t nbdta, uint8_t nbprt, uint64_t chsz, std::vector< std::string > &&plgr)
Constructor.
Definition: XrdClEcHandler.hh:294
std::vector< std::string > plgr
Definition: XrdClEcHandler.hh:331
uint8_t nbdta
Definition: XrdClEcHandler.hh:328
virtual FilePlugIn * CreateFile(const std::string &u)
Create a file plug-in for the given URL.
Definition: XrdClEcHandler.hh:310
uint8_t nbprt
Definition: XrdClEcHandler.hh:329
virtual FileSystemPlugIn * CreateFileSystem(const std::string &url)
Create a file system plug-in for the given URL.
Definition: XrdClEcHandler.hh:322
virtual ~EcPlugInFactory()
Destructor.
Definition: XrdClEcHandler.hh:303
An interface for file plug-ins.
Definition: XrdClPlugInInterface.hh:39
An interface for file plug-ins.
Definition: XrdClPlugInInterface.hh:284
Send file/filesystem queries to an XRootD cluster.
Definition: XrdClFileSystem.hh:203
XRootDStatus Query(QueryCode::Code queryCode, const Buffer &arg, ResponseHandler *handler, uint16_t timeout=0) XRD_WARN_UNUSED_RESULT
void QueueJob(Job *job, void *arg=0)
Add a job to be run.
Definition: XrdClJobManager.hh:92
Path location info.
Definition: XrdClXRootDResponses.hh:44
uint32_t GetSize() const
Get number of locations.
Definition: XrdClXRootDResponses.hh:152
Iterator Begin()
Get the location begin iterator.
Definition: XrdClXRootDResponses.hh:168
Location & At(uint32_t index)
Get the location at index.
Definition: XrdClXRootDResponses.hh:160
Iterator End()
Get the location end iterator.
Definition: XrdClXRootDResponses.hh:184
Plugin factory.
Definition: XrdClPlugInInterface.hh:549
JobManager * GetJobManager()
Get the job manager object user by the post master.
Handle an async response.
Definition: XrdClXRootDResponses.hh:1117
static ResponseHandler * Wrap(std::function< void(XRootDStatus &, AnyObject &)> func)
virtual void HandleResponse(XRootDStatus *status, AnyObject *response)
Definition: XrdClXRootDResponses.hh:1146
Call the user callback.
Definition: XrdClResponseJob.hh:31
Object stat info.
Definition: XrdClXRootDResponses.hh:400
void SetSize(uint64_t size)
Set size.
URL representation.
Definition: XrdClURL.hh:31
const std::string & GetPath() const
Get the path.
Definition: XrdClURL.hh:212
Request status.
Definition: XrdClXRootDResponses.hh:219
bool enable_plugins
Definition: XrdEcConfig.hh:77
static Config & Instance()
Singleton access.
Definition: XrdEcConfig.hh:46
Definition: XrdEcReader.hh:58
Definition: XrdEcStrmWriter.hh:53
Definition: XrdClAnyObject.hh:26
const uint16_t stError
An error occurred that could potentially be retried.
Definition: XrdClStatus.hh:32
const uint16_t errInternal
Internal error.
Definition: XrdClStatus.hh:56
const uint16_t errInvalidOp
Definition: XrdClStatus.hh:51
const uint16_t errNotSupported
Definition: XrdClStatus.hh:62
EcHandler * GetEcHandler(const URL &headnode, const URL &redirurl)
Definition: XrdOucJson.hh:4517
Mode
Access mode.
Definition: XrdClFileSystem.hh:122
Flags
Open flags, may be or'd when appropriate.
Definition: XrdClFileSystem.hh:76
@ Delete
Definition: XrdClFileSystem.hh:80
@ Read
Open only for reading.
Definition: XrdClFileSystem.hh:95
@ New
Definition: XrdClFileSystem.hh:86
@ Write
Open only for writing.
Definition: XrdClFileSystem.hh:97
@ None
Nothing.
Definition: XrdClFileSystem.hh:77
@ Update
Open for reading and writing.
Definition: XrdClFileSystem.hh:96
@ OpaqueFile
Implementation dependent.
Definition: XrdClFileSystem.hh:58
bool IsOK() const
We're fine.
Definition: XrdClStatus.hh:123
Definition: XrdEcObjCfg.hh:33
std::vector< std::string > plgr
Definition: XrdEcObjCfg.hh:92