Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -48,15 +48,21 @@ class RadosBlocker(object): ...@@ -48,15 +48,21 @@ class RadosBlocker(object):
blocksize = None blocksize = None
blockpool = None blockpool = None
hashtype = 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): def __init__(self, **params):
blocksize = params['blocksize'] blocksize = params['blocksize']
blockpool = params['blockpool'] blockpool = params['blockpool']
rados = Rados(conffile=CEPH_CONF_FILE)
rados.connect()
ioctx = rados.open_ioctx(blockpool)
hashtype = params['hashtype'] hashtype = params['hashtype']
try: try:
hasher = newhasher(hashtype) hasher = newhasher(hashtype)
...@@ -69,8 +75,7 @@ class RadosBlocker(object): ...@@ -69,8 +75,7 @@ class RadosBlocker(object):
self.blocksize = blocksize self.blocksize = blocksize
self.blockpool = blockpool self.blockpool = blockpool
self.rados = rados self.ioctx = RadosBlocker.get_rados_ctx(self.blockpool)
self.ioctx = ioctx
self.hashtype = hashtype self.hashtype = hashtype
self.hashlen = len(emptyhash) self.hashlen = len(emptyhash)
self.emptyhash = emptyhash self.emptyhash = emptyhash
......
...@@ -38,7 +38,6 @@ from rados import * ...@@ -38,7 +38,6 @@ from rados import *
CEPH_CONF_FILE = "/etc/ceph/ceph.conf" CEPH_CONF_FILE = "/etc/ceph/ceph.conf"
class RadosMapper(object): class RadosMapper(object):
"""Mapper. """Mapper.
Required constructor parameters: mappath, namelen. Required constructor parameters: mappath, namelen.
...@@ -46,19 +45,25 @@ class RadosMapper(object): ...@@ -46,19 +45,25 @@ class RadosMapper(object):
mappool = None mappool = None
namelen = 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): def __init__(self, **params):
self.params = params self.params = params
self.namelen = params['namelen'] self.namelen = params['namelen']
mappool = params['mappool'] mappool = params['mappool']
rados = Rados(conffile=CEPH_CONF_FILE)
rados.connect()
ioctx = rados.open_ioctx(mappool)
self.mappool = mappool self.mappool = mappool
self.rados = rados self.ioctx = RadosMapper.get_rados_ctx(mappool)
self.ioctx = ioctx
def _get_rear_map(self, maphash, create=0): def _get_rear_map(self, maphash, create=0):
name = hexlify(maphash) name = hexlify(maphash)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment