summaryrefslogtreecommitdiffstats
path: root/geo-replication
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2015-12-17 12:39:30 +0530
committerVenky Shankar <vshankar@redhat.com>2016-01-03 22:06:39 -0800
commitfd26e57537316da736768f32c12058e1e01123ce (patch)
tree1cc483d3941f0739c1996d3a6f6a923fa20c679a /geo-replication
parent78cd19946cd255e1dc483f19f49c4961902292d8 (diff)
geo-rep: Fix getting subvol number
Fix getting subvol number if the volume type is tier. If the volume type was tier, the subvol number was calculated incorrectly and hence few of workers didn't become ACTIVE resulting in files not being replicated from corresponding brick. This patch addresses the same. BUG: 1293309 Change-Id: I318de346657d330a2394507514bdff61feb92d27 Signed-off-by: Kotresh HR <khiremat@redhat.com> Reviewed-on: http://review.gluster.org/12994 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Aravinda VK <avishwan@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-on: http://review.gluster.org/13059
Diffstat (limited to 'geo-replication')
-rw-r--r--geo-replication/syncdaemon/gsyncd.py2
-rw-r--r--geo-replication/syncdaemon/monitor.py62
2 files changed, 47 insertions, 17 deletions
diff --git a/geo-replication/syncdaemon/gsyncd.py b/geo-replication/syncdaemon/gsyncd.py
index 759052ec153..fdb5348d363 100644
--- a/geo-replication/syncdaemon/gsyncd.py
+++ b/geo-replication/syncdaemon/gsyncd.py
@@ -306,7 +306,7 @@ def main_i():
op.add_option('--feedback-fd', dest='feedback_fd', type=int,
help=SUPPRESS_HELP, action='callback', callback=store_local)
op.add_option('--rpc-fd', dest='rpc_fd', type=str, help=SUPPRESS_HELP)
- op.add_option('--subvol-num', dest='subvol_num', type=int,
+ op.add_option('--subvol-num', dest='subvol_num', type=str,
help=SUPPRESS_HELP)
op.add_option('--listen', dest='listen', help=SUPPRESS_HELP,
action='callback', callback=store_local_curry(True))
diff --git a/geo-replication/syncdaemon/monitor.py b/geo-replication/syncdaemon/monitor.py
index cfffe9f88bd..a7978993035 100644
--- a/geo-replication/syncdaemon/monitor.py
+++ b/geo-replication/syncdaemon/monitor.py
@@ -32,14 +32,26 @@ from gsyncdstatus import GeorepStatus, set_monitor_status
ParseError = XET.ParseError if hasattr(XET, 'ParseError') else SyntaxError
-def get_subvol_num(brick_idx, replica_count, disperse_count):
+def get_subvol_num(brick_idx, vol, hot):
+ tier = vol.is_tier()
+ disperse_count = vol.disperse_count(tier, hot)
+ replica_count = vol.replica_count(tier, hot)
+
+ if (tier and not hot):
+ brick_idx = brick_idx - vol.get_hot_bricks_count(tier)
+
subvol_size = disperse_count if disperse_count > 0 else replica_count
cnt = int((brick_idx + 1) / subvol_size)
rem = (brick_idx + 1) % subvol_size
if rem > 0:
- return cnt + 1
+ cnt = cnt + 1
+
+ if (tier and hot):
+ return "hot_" + str(cnt)
+ elif (tier and not hot):
+ return "cold_" + str(cnt)
else:
- return cnt
+ return str(cnt)
def get_slave_bricks_status(host, vol):
@@ -99,6 +111,9 @@ class Volinfo(object):
def get(self, elem):
return self.tree.findall('.//' + elem)
+ def is_tier(self):
+ return (self.get('typeStr')[0].text == 'Tier')
+
def is_hot(self, brickpath):
logging.debug('brickpath: ' + repr(brickpath))
return brickpath in self.hot_bricks
@@ -121,21 +136,33 @@ class Volinfo(object):
self.volume, self.host)
return ids[0].text
- @property
- @memoize
- def replica_count(self):
- return int(self.get('replicaCount')[0].text)
+ def replica_count(self, tier, hot):
+ if (tier and hot):
+ return int(self.get('hotBricks/hotreplicaCount')[0].text)
+ elif (tier and not hot):
+ return int(self.get('coldBricks/coldreplicaCount')[0].text)
+ else:
+ return int(self.get('replicaCount')[0].text)
- @property
- @memoize
- def disperse_count(self):
- return int(self.get('disperseCount')[0].text)
+ def disperse_count(self, tier, hot):
+ if (tier and hot):
+ return int(self.get('hotBricks/hotdisperseCount')[0].text)
+ elif (tier and not hot):
+ return int(self.get('coldBricks/colddisperseCount')[0].text)
+ else:
+ return int(self.get('disperseCount')[0].text)
@property
@memoize
def hot_bricks(self):
return [b.text for b in self.get('hotBricks/brick')]
+ def get_hot_bricks_count(self, tier):
+ if (tier):
+ return int(self.get('hotBricks/hotbrickCount')[0].text)
+ else:
+ return 0
+
class Monitor(object):
"""class which spawns and manages gsyncd workers"""
@@ -418,11 +445,14 @@ def distribute(*resources):
else:
slaves = slavevols
- workerspex = [(brick['dir'], slaves[idx % len(slaves)],
- get_subvol_num(idx, mvol.replica_count, mvol.disperse_count),
- mvol.is_hot(":".join([brick['host'], brick['dir']])))
- for idx, brick in enumerate(mvol.bricks)
- if is_host_local(brick['host'])]
+ workerspex = []
+ for idx, brick in enumerate(mvol.bricks):
+ if is_host_local(brick['host']):
+ is_hot = mvol.is_hot(":".join([brick['host'], brick['dir']]))
+ workerspex.append((brick['dir'],
+ slaves[idx % len(slaves)],
+ get_subvol_num(idx, mvol, is_hot),
+ is_hot))
logging.info('worker specs: ' + repr(workerspex))
return workerspex, suuid, slave_vol, slave_host, master