Loading...
Searching...
No Matches
ProxyPrefixFile.hh
Go to the documentation of this file.
//------------------------------------------------------------------------------
// Copyright (c) 2011-2017 by European Organization for Nuclear Research (CERN)
// Author: Elvin Sindrilaru <esindril@cern.ch>
//------------------------------------------------------------------------------
// This file is part of the XRootD software suite.
//
// XRootD is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// XRootD is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
//
// In applying this licence, CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
//------------------------------------------------------------------------------
#ifndef SRC_XRDAPPS_PROXYPLUGIN_PROXYPREFIXFILE_HH_
#define SRC_XRDAPPS_PROXYPLUGIN_PROXYPREFIXFILE_HH_
#include "XrdCl/XrdClDefaultEnv.hh"
#include "XrdCl/XrdClPlugInInterface.hh"
#include <utility>
using namespace XrdCl;
namespace xrdcl_proxy
{
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
class ProxyPrefixFile: public XrdCl::FilePlugIn
{
public:
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
ProxyPrefixFile();
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
virtual ~ProxyPrefixFile() override;
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
virtual XRootDStatus Open(const std::string& url,
OpenFlags::Flags flags,
Access::Mode mode,
ResponseHandler* handler,
uint16_t timeout) override;
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
virtual XRootDStatus Close(ResponseHandler* handler,
uint16_t timeout) override
{
return pFile->Close(handler, timeout);
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
virtual XRootDStatus Stat(bool force,
ResponseHandler* handler,
uint16_t timeout) override
{
return pFile->Stat(force, handler, timeout);
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
virtual XRootDStatus Read(uint64_t offset,
uint32_t size,
void* buffer,
ResponseHandler* handler,
uint16_t timeout) override
{
return pFile->Read(offset, size, buffer, handler, timeout);
}
//------------------------------------------------------------------------
//------------------------------------------------------------------------
virtual XRootDStatus PgRead( uint64_t offset,
uint32_t size,
void *buffer,
ResponseHandler *handler,
uint16_t timeout ) override
{
return pFile->PgRead(offset, size, buffer, handler, timeout);
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
virtual XRootDStatus Write(uint64_t offset,
uint32_t size,
const void* buffer,
ResponseHandler* handler,
uint16_t timeout) override
{
return pFile->Write(offset, size, buffer, handler, timeout);
}
//------------------------------------------------------------------------
//------------------------------------------------------------------------
virtual XRootDStatus Write( uint64_t offset,
Buffer &&buffer,
ResponseHandler *handler,
uint16_t timeout = 0 ) override
{
return pFile->Write(offset, std::move(buffer), handler, timeout);
}
//------------------------------------------------------------------------
//------------------------------------------------------------------------
virtual XRootDStatus Write( uint64_t offset,
uint32_t size,
Optional<uint64_t> fdoff,
int fd,
ResponseHandler *handler,
uint16_t timeout = 0 ) override
{
return pFile->Write(offset, size, fdoff, fd, handler, timeout);
}
//------------------------------------------------------------------------
//------------------------------------------------------------------------
virtual XRootDStatus PgWrite( uint64_t offset,
uint32_t nbpgs,
const void *buffer,
std::vector<uint32_t> &cksums,
ResponseHandler *handler,
uint16_t timeout ) override
{
return pFile->PgWrite(offset, nbpgs, buffer, cksums, handler, timeout);
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
virtual XRootDStatus Sync(ResponseHandler* handler,
uint16_t timeout) override
{
return pFile->Sync(handler, timeout);
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
virtual XRootDStatus Truncate(uint64_t size,
ResponseHandler* handler,
uint16_t timeout) override
{
return pFile->Truncate(size, handler, timeout);
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
virtual XRootDStatus VectorRead(const ChunkList& chunks,
void* buffer,
ResponseHandler* handler,
uint16_t timeout) override
{
return pFile->VectorRead(chunks, buffer, handler, timeout);
}
//------------------------------------------------------------------------
//------------------------------------------------------------------------
virtual XRootDStatus VectorWrite( const ChunkList &chunks,
ResponseHandler *handler,
uint16_t timeout = 0 ) override
{
return pFile->VectorWrite(chunks, handler, timeout);
}
//------------------------------------------------------------------------
//------------------------------------------------------------------------
virtual XRootDStatus WriteV( uint64_t offset,
const struct iovec *iov,
int iovcnt,
ResponseHandler *handler,
uint16_t timeout = 0 ) override
{
return pFile->WriteV(offset, iov, iovcnt, handler, timeout);
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
virtual XRootDStatus Fcntl(const Buffer& arg,
ResponseHandler* handler,
uint16_t timeout) override
{
return pFile->Fcntl(arg, handler, timeout);
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
virtual XRootDStatus Visa(ResponseHandler* handler,
uint16_t timeout) override
{
return pFile->Visa(handler, timeout);
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
virtual bool IsOpen() const override
{
return pFile->IsOpen();
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
virtual bool SetProperty(const std::string& name,
const std::string& value) override
{
return pFile->SetProperty(name, value);
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
virtual bool GetProperty(const std::string& name,
std::string& value) const override
{
return pFile->GetProperty(name, value);
}
private:
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
inline std::string trim(const std::string& in) const;
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
inline std::string GetPrefixUrl() const;
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
std::list<std::string> GetExclDomains() const;
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
std::string ConstructFinalUrl(const std::string& orig_url) const;
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
std::string GetFqdn(const std::string& hostname) const;
bool mIsOpen;
XrdCl::File* pFile;
};
} // namespace xrdcl_proxy
#endif
XrdClDefaultEnv.hh
XrdClPlugInInterface.hh
trim
void trim(std::string &str)
Definition XrdHttpReq.cc:77
XrdCl::Buffer
Binary blob representation.
Definition XrdClBuffer.hh:34
XrdCl::FilePlugIn
An interface for file plug-ins.
Definition XrdClPlugInInterface.hh:39
XrdCl::File
A file.
Definition XrdClFile.hh:46
XrdCl::Optional
Definition XrdClOptional.hh:44
XrdCl::ResponseHandler
Handle an async response.
Definition XrdClXRootDResponses.hh:1127
XrdCl::XRootDStatus
Request status.
Definition XrdClXRootDResponses.hh:219
xrdcl_proxy::ProxyPrefixFile::ProxyPrefixFile
ProxyPrefixFile()
Constructor.
Definition ProxyPrefixFile.cc:40
xrdcl_proxy::ProxyPrefixFile::Open
virtual XRootDStatus Open(const std::string &url, OpenFlags::Flags flags, Access::Mode mode, ResponseHandler *handler, uint16_t timeout) override
Open.
Definition ProxyPrefixFile.cc:59
xrdcl_proxy::ProxyPrefixFile::Write
virtual XRootDStatus Write(uint64_t offset, Buffer &&buffer, ResponseHandler *handler, uint16_t timeout=0) override
Write.
Definition ProxyPrefixFile.hh:122
xrdcl_proxy::ProxyPrefixFile::Fcntl
virtual XRootDStatus Fcntl(const Buffer &arg, ResponseHandler *handler, uint16_t timeout) override
Fcntl.
Definition ProxyPrefixFile.hh:211
xrdcl_proxy::ProxyPrefixFile::Close
virtual XRootDStatus Close(ResponseHandler *handler, uint16_t timeout) override
Close.
Definition ProxyPrefixFile.hh:66
xrdcl_proxy::ProxyPrefixFile::Truncate
virtual XRootDStatus Truncate(uint64_t size, ResponseHandler *handler, uint16_t timeout) override
Truncate.
Definition ProxyPrefixFile.hh:168
xrdcl_proxy::ProxyPrefixFile::VectorRead
virtual XRootDStatus VectorRead(const ChunkList &chunks, void *buffer, ResponseHandler *handler, uint16_t timeout) override
VectorRead.
Definition ProxyPrefixFile.hh:178
xrdcl_proxy::ProxyPrefixFile::PgRead
virtual XRootDStatus PgRead(uint64_t offset, uint32_t size, void *buffer, ResponseHandler *handler, uint16_t timeout) override
PgRead.
Definition ProxyPrefixFile.hh:98
xrdcl_proxy::ProxyPrefixFile::SetProperty
virtual bool SetProperty(const std::string &name, const std::string &value) override
SetProperty.
Definition ProxyPrefixFile.hh:238
xrdcl_proxy::ProxyPrefixFile::VectorWrite
virtual XRootDStatus VectorWrite(const ChunkList &chunks, ResponseHandler *handler, uint16_t timeout=0) override
VectorWrite.
Definition ProxyPrefixFile.hh:189
xrdcl_proxy::ProxyPrefixFile::PgWrite
virtual XRootDStatus PgWrite(uint64_t offset, uint32_t nbpgs, const void *buffer, std::vector< uint32_t > &cksums, ResponseHandler *handler, uint16_t timeout) override
PgWrite.
Definition ProxyPrefixFile.hh:146
xrdcl_proxy::ProxyPrefixFile::Write
virtual XRootDStatus Write(uint64_t offset, uint32_t size, Optional< uint64_t > fdoff, int fd, ResponseHandler *handler, uint16_t timeout=0) override
Write.
Definition ProxyPrefixFile.hh:133
xrdcl_proxy::ProxyPrefixFile::Stat
virtual XRootDStatus Stat(bool force, ResponseHandler *handler, uint16_t timeout) override
Stat.
Definition ProxyPrefixFile.hh:75
xrdcl_proxy::ProxyPrefixFile::Visa
virtual XRootDStatus Visa(ResponseHandler *handler, uint16_t timeout) override
Visa.
Definition ProxyPrefixFile.hh:221
xrdcl_proxy::ProxyPrefixFile::Read
virtual XRootDStatus Read(uint64_t offset, uint32_t size, void *buffer, ResponseHandler *handler, uint16_t timeout) override
Read.
Definition ProxyPrefixFile.hh:86
xrdcl_proxy::ProxyPrefixFile::IsOpen
virtual bool IsOpen() const override
IsOpen.
Definition ProxyPrefixFile.hh:230
xrdcl_proxy::ProxyPrefixFile::GetProperty
virtual bool GetProperty(const std::string &name, std::string &value) const override
GetProperty.
Definition ProxyPrefixFile.hh:247
xrdcl_proxy::ProxyPrefixFile::Write
virtual XRootDStatus Write(uint64_t offset, uint32_t size, const void *buffer, ResponseHandler *handler, uint16_t timeout) override
Write.
Definition ProxyPrefixFile.hh:110
xrdcl_proxy::ProxyPrefixFile::Sync
virtual XRootDStatus Sync(ResponseHandler *handler, uint16_t timeout) override
Sync.
Definition ProxyPrefixFile.hh:159
xrdcl_proxy::ProxyPrefixFile::WriteV
virtual XRootDStatus WriteV(uint64_t offset, const struct iovec *iov, int iovcnt, ResponseHandler *handler, uint16_t timeout=0) override
Definition ProxyPrefixFile.hh:199
xrdcl_proxy::ProxyPrefixFile::~ProxyPrefixFile
virtual ~ProxyPrefixFile() override
Destructor.
Definition ProxyPrefixFile.cc:48
XrdCl
Definition XrdClAction.hh:34
XrdCl::ChunkList
std::vector< ChunkInfo > ChunkList
List of chunks.
Definition XrdClXRootDResponses.hh:1056
XrdCl::value
Response NullRef< Response >::value
Definition XrdClOperationHandlers.hh:128
xrdcl_proxy
Definition ProxyPrefixFile.cc:36
XrdCl::Access::Mode
Mode
Access mode.
Definition XrdClFileSystem.hh:122
XrdCl::OpenFlags::Flags
Flags
Open flags, may be or'd when appropriate.
Definition XrdClFileSystem.hh:76
iov
Definition XrdOucIOVec.hh:65