def __init__(self, root, drive, account, logger, pending_timeout=None, stale_reads_ok=False): # WARNING: The following four fields are referenced as fields by our # callers outside of this module, do not remove. # Create a dummy db_file in Glusterfs.RUN_DIR global _db_file if not _db_file: _db_file = os.path.join(Glusterfs.RUN_DIR, 'db_file.db') if not do_exists(_db_file): do_touch(_db_file) self.db_file = _db_file self.metadata = {} self.pending_timeout = pending_timeout or 10 self.stale_reads_ok = stale_reads_ok # The following fields are common self.root = root assert logger is not None self.logger = logger self.account = account self.datadir = os.path.join(root, drive) self._dir_exists = None
def __init__(self, root, drive, account, logger, pending_timeout=None, stale_reads_ok=False): # WARNING: The following four fields are referenced as fields by our # callers outside of this module, do not remove. # Create a dummy db_file in Glusterfs.RUN_DIR global _db_file if not _db_file: _db_file = os.path.join(Glusterfs.RUN_DIR, 'db_file.db') if not do_exists(_db_file): do_touch(_db_file) self.db_file = _db_file self.metadata = {} self.pending_timeout = pending_timeout or 10 self.stale_reads_ok = stale_reads_ok # The following fields are common self.root = root assert logger is not None self.logger = logger self.account = account self.datadir = os.path.join(root, drive) self._dir_exists = False # nthread=0 is intentional. This ensures that no green pool is # used. Call to force_run_in_thread() will ensure that the method # passed as arg is run in a real external thread using eventlet.tpool # which has a threadpool of 20 threads (default) self.threadpool = ThreadPool(nthreads=0)
def _dir_exists_read_metadata(self): self._dir_exists = do_exists(self.datadir) if self._dir_exists: try: self.metadata = _read_metadata(self.datadir) except GlusterFileSystemIOError as err: if err.errno in (errno.ENOENT, errno.ESTALE): return False raise return self._dir_exists
def update_put_timestamp(self, timestamp): """ Update the PUT timestamp for the container. If the container does not exist, create it using a PUT timestamp of the given value. If the container does exist, update the PUT timestamp only if it is later than the existing value. """ if not do_exists(self.datadir): self.initialize(timestamp) else: if timestamp > self.metadata[X_PUT_TIMESTAMP]: self.metadata[X_PUT_TIMESTAMP] = (timestamp, 0) write_metadata(self.datadir, self.metadata)
def is_deleted(self): # The intention of this method is to check the file system to see if # the directory actually exists. return not do_exists(self.datadir)
def _dir_exists_read_metadata(self): self._dir_exists = do_exists(self.datadir) if self._dir_exists: self.metadata = _read_metadata(self.datadir) return self._dir_exists
def get_info_is_deleted(self): if not do_exists(self.datadir): return {}, True info = self.get_info() return info, False