Back to index

nordugrid-arc-nox  1.1.0~rc6
Public Member Functions | Public Attributes | Static Public Attributes
storage.shepherd.hardlinkingbackend.ApacheBackend Class Reference
Inheritance diagram for storage.shepherd.hardlinkingbackend.ApacheBackend:
Inheritance graph
[legend]
Collaboration diagram for storage.shepherd.hardlinkingbackend.ApacheBackend:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def prepareToGet
def prepareToPut
def checkingThread
def copyTo
def copyFrom
def remove
def list
def getAvailableSpace
def generateLocalID
def matchProtocols
def checksum

Public Attributes

 apacheuser
 uid
 ssl_config
 file_arrived
 datadir
 transferdir
 turlprefix
 idstore

Static Public Attributes

list public_request_names = []
list supported_protocols = ['http']

Detailed Description

Backend for Apache with hardlinking

Definition at line 152 of file hardlinkingbackend.py.


Constructor & Destructor Documentation

def storage.shepherd.hardlinkingbackend.ApacheBackend.__init__ (   self,
  backendcfg,
  ns_uri,
  file_arrived,
  ssl_config 
)
docstring for __init__

Reimplemented from storage.shepherd.hardlinkingbackend.HardlinkingBackend.

Definition at line 157 of file hardlinkingbackend.py.

00157 
00158     def __init__(self, backendcfg, ns_uri, file_arrived, ssl_config):
00159         HardlinkingBackend.__init__(self, backendcfg, ns_uri, file_arrived, ssl_config)
00160         self.apacheuser = str(backendcfg.Get('ApacheUser'))
00161         self.uid = os.getuid()
00162         _, _, _, self.apachegid, _, _, _ = pwd.getpwnam(self.apacheuser) 
00163         log.msg(arc.VERBOSE, "ApacheBackend datadir:", self.datadir)
00164         log.msg(arc.VERBOSE, "ApacheBackend transferdir:", self.transferdir)
00165         


Member Function Documentation

docstring for checkingThread

Definition at line 46 of file hardlinkingbackend.py.

00046 
00047     def checkingThread(self, period):
00048         """docstring for checkingThread"""
00049         while True:
00050             try:
00051                 time.sleep(period)
00052                 for localID, referenceID in self.idstore.items():
00053                     filename = os.path.join(self.datadir, localID)
00054                     try:
00055                         nlink = os.stat(filename)[stat.ST_NLINK]
00056                     except:
00057                         # if the file does not exist, maybe it's already removed
00058                         del self.idstore[localID]
00059                         nlink = 0
00060                     log.msg(arc.VERBOSE, 'checking', localID, referenceID, nlink)
00061                     if nlink == 1:
00062                         # if there is just one link for this file, it is already removed from the transfer dir
00063                         self.file_arrived(referenceID)
00064                         del self.idstore[localID]
00065             except:
00066                 log.msg()
00067     
00068         

def storage.shepherd.hardlinkingbackend.HardlinkingBackend.checksum (   self,
  localID,
  checksumType 
) [inherited]

Definition at line 135 of file hardlinkingbackend.py.

00135 
00136     def checksum(self, localID, checksumType):
00137         return create_checksum(file(os.path.join(self.datadir, localID), 'rb'), checksumType)
00138 

Here is the call graph for this function:

def storage.shepherd.hardlinkingbackend.HardlinkingBackend.copyFrom (   self,
  localID,
  turl,
  protocol 
) [inherited]

Definition at line 75 of file hardlinkingbackend.py.

00075 
00076     def copyFrom(self, localID, turl, protocol):
00077         # TODO: download to a separate file, and if checksum OK, then copy the file 
00078         f = file(os.path.join(self.datadir, localID), 'wb')
00079         log.msg(arc.VERBOSE, self.turlprefix, 'Downloading file from', turl)
00080         download_from_turl(turl, protocol, f, ssl_config = self.ssl_config)
00081         f.close()

Here is the call graph for this function:

def storage.shepherd.hardlinkingbackend.HardlinkingBackend.copyTo (   self,
  localID,
  turl,
  protocol 
) [inherited]

Definition at line 69 of file hardlinkingbackend.py.

00069 
00070     def copyTo(self, localID, turl, protocol):
00071         f = file(os.path.join(self.datadir, localID),'rb')
00072         log.msg(arc.VERBOSE, self.turlprefix, 'Uploading file to', turl)
00073         upload_to_turl(turl, protocol, f, ssl_config = self.ssl_config)
00074         f.close()
    

Here is the call graph for this function:

Definition at line 129 of file hardlinkingbackend.py.

00129 
00130     def generateLocalID(self):
00131         return arc.UUID()

Definition at line 122 of file hardlinkingbackend.py.

00122 
00123     def getAvailableSpace(self):
00124         try:
00125             f = os.statvfs(self.datadir)
00126             return f.f_frsize * f.f_bavail
00127         except:
00128             return None

Definition at line 119 of file hardlinkingbackend.py.

00119 
00120     def list(self):
00121         return os.listdir(os.datadir)

def storage.shepherd.hardlinkingbackend.HardlinkingBackend.matchProtocols (   self,
  protocols 
) [inherited]

Definition at line 132 of file hardlinkingbackend.py.

00132 
00133     def matchProtocols(self, protocols):
00134         return [protocol for protocol in protocols if protocol in self.supported_protocols]

def storage.shepherd.hardlinkingbackend.ApacheBackend.prepareToGet (   self,
  referenceID,
  localID,
  protocol 
)

Reimplemented from storage.shepherd.hardlinkingbackend.HardlinkingBackend.

Definition at line 166 of file hardlinkingbackend.py.

00166 
00167     def prepareToGet(self, referenceID, localID, protocol):
00168         turl = HardlinkingBackend.prepareToGet(self, referenceID, localID, protocol)
00169         if turl != None:
00170             filepath = os.path.join(self.datadir, localID)
00171             # set group to apache to make it readable to Apache
00172             os.chown(filepath, self.uid, self.apachegid)
00173             # set it to readonly
00174             os.chmod(filepath, 0440)
00175         return turl

def storage.shepherd.hardlinkingbackend.ApacheBackend.prepareToPut (   self,
  referenceID,
  localID,
  protocol 
)

Reimplemented from storage.shepherd.hardlinkingbackend.HardlinkingBackend.

Definition at line 176 of file hardlinkingbackend.py.

00176 
00177     def prepareToPut(self, referenceID, localID, protocol):
00178         turl = HardlinkingBackend.prepareToPut(self, referenceID, localID, protocol)
00179         datapath = os.path.join(self.datadir, localID)
00180         # set group to apache to make it readable to Apache
00181         os.chown(datapath, self.uid, self.apachegid)
00182         # set file group writable
00183         os.chmod(datapath, 0660)
00184         return turl
def storage.shepherd.hardlinkingbackend.HardlinkingBackend.remove (   self,
  localID 
) [inherited]

Definition at line 111 of file hardlinkingbackend.py.

00111 
00112     def remove(self, localID):
00113         try:
00114             fn = os.path.join(self.datadir, localID)
00115             os.remove(fn)
00116         except:
00117             return 'failed: ' + traceback.format_exc()
00118         return 'removed'


Member Data Documentation

Definition at line 159 of file hardlinkingbackend.py.

Definition at line 26 of file hardlinkingbackend.py.

Definition at line 24 of file hardlinkingbackend.py.

Definition at line 43 of file hardlinkingbackend.py.

Definition at line 18 of file hardlinkingbackend.py.

Definition at line 23 of file hardlinkingbackend.py.

Definition at line 19 of file hardlinkingbackend.py.

Definition at line 29 of file hardlinkingbackend.py.

Definition at line 30 of file hardlinkingbackend.py.

Definition at line 160 of file hardlinkingbackend.py.


The documentation for this class was generated from the following file: