Commit 17e9ce75 authored by Filippos Giannakos's avatar Filippos Giannakos
Browse files

pithos: Fix excessive RADOS threads.

When a RADOS ioctx is acquired, new threads are spawn in the background by
librados. Make sure we do not instantiate multiple RADOS ioctx, but instantiate
only one and reuse it.
parent 891490b2
......@@ -48,15 +48,21 @@ class RadosBlocker(object):
blocksize = None
blockpool = None
hashtype = None
rados = None
rados_ctx = None
@classmethod
def get_rados_ctx(cls, pool):
if cls.rados_ctx is None:
cls.rados = Rados(conffile=CEPH_CONF_FILE)
cls.rados.connect()
cls.rados_ctx = cls.rados.open_ioctx(pool)
return cls.rados_ctx
def __init__(self, **params):
blocksize = params['blocksize']
blockpool = params['blockpool']
rados = Rados(conffile=CEPH_CONF_FILE)
rados.connect()
ioctx = rados.open_ioctx(blockpool)
hashtype = params['hashtype']
try:
hasher = newhasher(hashtype)
......@@ -69,8 +75,7 @@ class RadosBlocker(object):
self.blocksize = blocksize
self.blockpool = blockpool
self.rados = rados
self.ioctx = ioctx
self.ioctx = RadosBlocker.get_rados_ctx(self.blockpool)
self.hashtype = hashtype
self.hashlen = len(emptyhash)
self.emptyhash = emptyhash
......
......@@ -38,7 +38,6 @@ from rados import *
CEPH_CONF_FILE = "/etc/ceph/ceph.conf"
class RadosMapper(object):
"""Mapper.
Required constructor parameters: mappath, namelen.
......@@ -46,19 +45,25 @@ class RadosMapper(object):
mappool = None
namelen = None
rados = None
rados_ctx = None
@classmethod
def get_rados_ctx(cls, pool):
if cls.rados_ctx is None:
cls.rados = Rados(conffile=CEPH_CONF_FILE)
cls.rados.connect()
cls.rados_ctx = cls.rados.open_ioctx(pool)
return cls.rados_ctx
def __init__(self, **params):
self.params = params
self.namelen = params['namelen']
mappool = params['mappool']
rados = Rados(conffile=CEPH_CONF_FILE)
rados.connect()
ioctx = rados.open_ioctx(mappool)
self.mappool = mappool
self.rados = rados
self.ioctx = ioctx
self.ioctx = RadosMapper.get_rados_ctx(mappool)
def _get_rear_map(self, maphash, create=0):
name = hexlify(maphash)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment