Commit 9113300d authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

masterd: Move job queue into context object

The job queue must be called from cmdlib when adding or removing
nodes to the cluster. Moving it to the context objects makes
this possible.

Reviewed-by: iustinp
parent f78346f5
......@@ -84,24 +84,22 @@ class IOServer(SocketServer.UnixStreamServer):
cleanup at shutdown.
def __init__(self, address, rqhandler, context):
def __init__(self, address, rqhandler):
"""IOServer constructor
address: the address to bind this IOServer to
rqhandler: RequestHandler type object
context: Context Object common to all worker threads
SocketServer.UnixStreamServer.__init__(self, address, rqhandler)
self.context = context
# We'll only start threads once we've forked.
self.jobqueue = None
self.context = None
self.request_workers = None
def setup_queue(self):
self.jobqueue = jqueue.JobQueue(self.context)
self.context = GanetiContext()
self.request_workers = workerpool.WorkerPool(CLIENT_REQUEST_WORKERS,
......@@ -133,8 +131,8 @@ class IOServer(SocketServer.UnixStreamServer):
if self.request_workers:
if self.jobqueue:
if self.context:
class ClientRqHandler(SocketServer.BaseRequestHandler):
......@@ -203,7 +201,7 @@ class ClientOps:
self.server = server
def handle_request(self, method, args):
queue = self.server.jobqueue
queue = self.server.context.jobqueue
# TODO: Parameter validation
......@@ -269,13 +267,17 @@ class GanetiContext(object):
assert self.__class__._instance is None, "double GanetiContext instance"
# Create a ConfigWriter...
# Create global configuration object
self.cfg = config.ConfigWriter()
# And a GanetiLockingManager...
# Locking manager
self.glm = locking.GanetiLockManager(
# Job queue
self.jobqueue = jqueue.JobQueue(self)
# setting this also locks the class against attribute modifications
self.__class__._instance = self
......@@ -318,7 +320,7 @@ def main():
master = IOServer(constants.MASTER_SOCKET, ClientRqHandler, GanetiContext())
master = IOServer(constants.MASTER_SOCKET, ClientRqHandler)
# become a daemon
if options.fork:
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