Logo ROOT   6.14/05
Reference Guide
TDavixFileInternal.h
Go to the documentation of this file.
1 // @(#)root/net:$Id$
2 // Author: Adrien Devresse and Tigran Mkrtchyan
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TDavixFileInternal
13 #define ROOT_TDavixFileInternal
14 
15 #include "TUrl.h"
16 #include "TMutex.h"
17 
18 #include <vector>
19 #include <iterator>
20 #include <algorithm>
21 #include <errno.h>
22 #include <stdlib.h>
23 #include <unistd.h>
24 #include <fcntl.h>
25 #include <sys/stat.h>
26 #include <sstream>
27 #include <string>
28 #include <cstring>
29 
30 //////////////////////////////////////////////////////////////////////////
31 // //
32 // TDavixFileInternal //
33 // //
34 // //
35 // Support class, common to TDavixFile and TDavixSystem //
36 // //
37 // Authors: Adrien Devresse (CERN IT/SDC) //
38 // Fabrizio Furano (CERN IT/SDC) //
39 // //
40 // September 2013 //
41 // //
42 //////////////////////////////////////////////////////////////////////////
43 
44 namespace Davix {
45  class Context;
46  class RequestParams;
47  class DavPosix;
48  class DavFile;
49 }
50 struct Davix_fd;
51 
52 
54  friend class TDavixFile;
55  friend class TDavixSystem;
56 
57 private:
58  TDavixFileInternal(const TUrl & mUrl, Option_t* mopt) :
59  positionLock(),
60  openLock(),
61  davixContext(getDavixInstance()),
62  davixParam(NULL),
63  davixPosix(NULL),
64  davixFd(NULL),
65  fUrl(mUrl),
66  opt(mopt),
67  oflags(0),
68  dirdVec() { }
69 
70  TDavixFileInternal(const char* url, Option_t* mopt) :
71  positionLock(),
72  openLock(),
73  davixContext(getDavixInstance()),
74  davixParam(NULL),
75  davixPosix(NULL),
76  davixFd(NULL),
77  fUrl(url),
78  opt(mopt),
79  oflags(0),
80  dirdVec() { }
81 
83 
85  {
86  // singleton init
87  if (davixFd == NULL) {
88  TLockGuard l(&(openLock));
89  if (davixFd == NULL) {
90  davixFd = this->Open();
91  }
92  }
93  return davixFd;
94  }
95 
96  Davix_fd * Open();
97 
98  void Close();
99 
100  void enableGridMode();
101 
102  void setAwsRegion(const std::string & region);
103  void setAwsToken(const std::string & token);
104  void setAwsAlternate(const bool &option);
105 
106  void setS3Auth(const std::string & secret, const std::string & access,
107  const std::string & region, const std::string & token);
108 
109  void parseConfig();
110 
111  void parseParams(Option_t* option);
112 
113  void init();
114 
115  bool isMyDird(void* fd);
116 
117  void addDird(void* fd);
118 
119  void removeDird(void* fd);
120 
121  std::vector<std::string> getReplicas()
122  {
123  return replicas;
124  }
125 
128 
129  std::vector<std::string> replicas;
130 
131  // DAVIX
132  Davix::Context *davixContext;
133  Davix::RequestParams *davixParam;
134  Davix::DavPosix *davixPosix;
135  Davix_fd *davixFd;
138  int oflags;
139  std::vector<void*> dirdVec;
140 
141 public:
142  Int_t DavixStat(const char *url, struct stat *st);
143 
144  static Davix::Context* getDavixInstance();
145 };
146 
147 #endif
Definition: TMutex.h:30
TDavixFileInternal(const char *url, Option_t *mopt)
const char Option_t
Definition: RtypesCore.h:62
This class represents a WWW compatible URL.
Definition: TUrl.h:35
Davix::RequestParams * davixParam
Small helper to keep current directory context.
int Int_t
Definition: RtypesCore.h:41
Davix_fd * getDavixFileInstance()
Davix::DavPosix * davixPosix
TDavixFileInternal(const TUrl &mUrl, Option_t *mopt)
std::vector< std::string > getReplicas()
std::vector< void * > dirdVec
static Int_t init()
auto * l
Definition: textangle.C:4
std::vector< std::string > replicas
Davix::Context * davixContext