xrootd
XrdClientReadAhead.hh
Go to the documentation of this file.
00001 #ifndef XRD_CLI_READAHEAD
00002 #define XRD_CLI_READAHEAD
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*               X r d C l i e n t R e a d A h e a d . h h                    */
00006 /*                                                                            */
00007 /* Author: Fabrizio Furano (CERN IT-DM, 2009)                                 */
00008 /*                                                                            */
00009 /* This file is part of the XRootD software suite.                            */
00010 /*                                                                            */
00011 /* XRootD is free software: you can redistribute it and/or modify it under    */
00012 /* the terms of the GNU Lesser General Public License as published by the     */
00013 /* Free Software Foundation, either version 3 of the License, or (at your     */
00014 /* option) any later version.                                                 */
00015 /*                                                                            */
00016 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
00017 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
00018 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
00019 /* License for more details.                                                  */
00020 /*                                                                            */
00021 /* You should have received a copy of the GNU Lesser General Public License   */
00022 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
00023 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
00024 /*                                                                            */
00025 /* The copyright holder's institutional names and contributor's names may not */
00026 /* be used to endorse or promote products derived from this software without  */
00027 /* specific prior written permission of the institution or contributor.       */
00028 /******************************************************************************/
00029 
00031 //                                                                      //
00032 // Classes to implement a selectable read ahead decision maker          //
00033 //                                                                      //
00035 
00036 class XrdClientReadAheadMgr {
00037 public:
00038    enum XrdClient_RAStrategy {
00039       RAStr_none,
00040       RAStr_pureseq,
00041       RAStr_SlidingAvg
00042    };
00043 
00044 protected:
00045    long RASize;
00046    XrdClient_RAStrategy currstrategy;
00047 
00048 public:
00049       
00050    static XrdClientReadAheadMgr *CreateReadAheadMgr(XrdClient_RAStrategy strategy);
00051    
00052 
00053    XrdClientReadAheadMgr() { RASize = 0; };
00054    virtual ~XrdClientReadAheadMgr() {};
00055 
00056    virtual int GetReadAheadHint(long long offset, long len, long long &raoffset, long &ralen, long blksize) = 0;
00057    virtual int Reset() = 0;
00058    virtual void SetRASize(long bytes) { RASize = bytes; };
00059    
00060    static bool TrimReadRequest(long long &offs, long &len, long rasize, long blksize);
00061 
00062    XrdClient_RAStrategy GetCurrentStrategy() { return currstrategy; }
00063 };
00064 #endif