diff options
author | Ajeet Jha <ajha@redhat.com> | 2013-12-02 12:37:34 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2013-12-12 00:16:03 -0800 |
commit | f999c17da5a5353196e68e7a68af64f91df6b902 (patch) | |
tree | d2e1df4111c492662f1e7eb5cfc6f0236af3818e /geo-replication/syncdaemon/configinterface.py | |
parent | 8f2fc6fb3a63ca87d82b6fa933f94fb1e3283a26 (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>
Diffstat (limited to 'geo-replication/syncdaemon/configinterface.py')
-rw-r--r-- | geo-replication/syncdaemon/configinterface.py | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/geo-replication/syncdaemon/configinterface.py b/geo-replication/syncdaemon/configinterface.py index a326e824681..0f764c47a7e 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__': |