summaryrefslogtreecommitdiffstats
path: root/geo-replication/syncdaemon/configinterface.py
diff options
context:
space:
mode:
authorAjeet Jha <ajha@redhat.com>2013-12-02 12:37:34 +0530
committerVijay Bellur <vbellur@redhat.com>2014-01-27 09:43:19 -0800
commit30592e7f92515c5df620f300d6a3df6373ac6200 (patch)
tree851c232b1e3be7f5458cf6c753b92be2f482ad17 /geo-replication/syncdaemon/configinterface.py
parentc8b9a9e9f82af7e752d4d881313374713701441d (diff)
gsyncd / geo-rep: geo-replication fixes
-> "threaded" hybrid crawl. -> Enabling metatadata synchronization. -> Handling EINVAL/ESTALE gracefully while syncing metadata. -> Improvments to changelog crawl code. -> Initial crawl changelog generation format. -> No gsyncd restart when checkpoint updated. -> Fix symlink handling in hybrid crawl. -> Slave's xtime key is 'stime'. -> tar+ssh as data synchronization. -> Instead of 'raise', just log in warning level for xtime missing cases. -> Fix for JSON object load failure -> Get new config value after config value reset. -> Skip already processed changelogs. -> Saving status of each individual worker thread. -> GFID fetch on slave for purges. -> Add tar ssh keys and config options. -> Fix nlink count when using backend. -> Include "data" operation for hardlink. -> Use changelog time prefix as slave's time. -> Process changelogs in parallel. Change-Id: I09fcbb2e2e418149a6d8435abd2ac6b2f015bb06 BUG: 1036539 Signed-off-by: Ajeet Jha <ajha@redhat.com> Reviewed-on: http://review.gluster.org/6404 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com> Reviewed-on: http://review.gluster.org/6809 Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'geo-replication/syncdaemon/configinterface.py')
-rw-r--r--geo-replication/syncdaemon/configinterface.py41
1 files changed, 39 insertions, 2 deletions
diff --git a/geo-replication/syncdaemon/configinterface.py b/geo-replication/syncdaemon/configinterface.py
index a326e8246..0f764c47a 100644
--- a/geo-replication/syncdaemon/configinterface.py
+++ b/geo-replication/syncdaemon/configinterface.py
@@ -5,6 +5,10 @@ except ImportError:
import configparser as ConfigParser
import re
from string import Template
+import os
+import errno
+import sys
+from stat import ST_DEV, ST_INO, ST_MTIME
from syncdutils import escape, unescape, norm, update_file, GsyncdError
@@ -65,8 +69,38 @@ class GConffile(object):
self.auxdicts = dd
self.config = ConfigParser.RawConfigParser()
self.config.read(path)
+ self.dev, self.ino, self.mtime = -1, -1, -1
self._normconfig()
+ def _load(self):
+ try:
+ sres = os.stat(self.path)
+ self.dev = sres[ST_DEV]
+ self.ino = sres[ST_INO]
+ self.mtime = sres[ST_MTIME]
+ except (OSError, IOError):
+ if sys.exc_info()[1].errno == errno.ENOENT:
+ sres = None
+
+ self.config.read(self.path)
+ self._normconfig()
+
+ def get_realtime(self, opt):
+ try:
+ sres = os.stat(self.path)
+ except (OSError, IOError):
+ if sys.exc_info()[1].errno == errno.ENOENT:
+ sres = None
+ else:
+ raise
+
+ # compare file system stat with that of our stream file handle
+ if not sres or sres[ST_DEV] != self.dev or \
+ sres[ST_INO] != self.ino or self.mtime != sres[ST_MTIME]:
+ self._load()
+
+ return self.get(opt, printValue=False)
+
def section(self, rx=False):
"""get the section name of the section representing .peers in .config"""
peers = self.peers
@@ -162,7 +196,7 @@ class GConffile(object):
if self.config.has_section(self.section()):
update_from_sect(self.section(), MultiDict(dct, *self.auxdicts))
- def get(self, opt=None):
+ def get(self, opt=None, printValue=True):
"""print the matching key/value pairs from .config,
or if @opt given, the value for @opt (according to the
logic described in .update_to)
@@ -173,7 +207,10 @@ class GConffile(object):
opt = norm(opt)
v = d.get(opt)
if v:
- print(v)
+ if printValue:
+ print(v)
+ else:
+ return v
else:
for k, v in d.iteritems():
if k == '__name__':