4084 Dyre Tjeldvoll 2012-10-04
Adding SocketServer.ThreadingMixIn as base class to make the backend web server multi-threaded
modified:
storage/ndb/mcc/request_handler.py
4083 Dyre Tjeldvoll 2012-10-03
Support configurable unit tests for backend
modified:
storage/ndb/mcc/tst/tst_main.py
=== modified file 'storage/ndb/mcc/request_handler.py'
--- a/storage/ndb/mcc/request_handler.py 2012-10-02 08:08:00 +0000
+++ b/storage/ndb/mcc/request_handler.py 2012-10-04 07:08:54 +0000
@@ -44,6 +44,7 @@ import optparse
import webbrowser
import zipfile
import tempfile
+import threading
import util
from clusterhost import produce_ABClusterHost
@@ -254,6 +255,11 @@ def handle_removeClusterReq(req, body):
directories belonging to the cluster."""
pass
+def log_thread_name():
+ cur_thread = threading.current_thread()
+ _logger.debug("cur_thread="+str(cur_thread.name))
+
+
class ConfiguratorHandler(BaseHTTPServer.BaseHTTPRequestHandler):
"""Handler class for web server requests to the configurator backend. To be
used with a BaseHTTPServer.HTTPServer to create a working server."""
@@ -268,7 +274,7 @@ class ConfiguratorHandler(BaseHTTPServer
def do_GET(self):
"""Handles GET requests by returning the specified file. Attempts to guess
the MIME type and set the Content-Type accordingly."""
-
+ log_thread_name()
f = None
try:
self.send_response(200)
@@ -294,6 +300,7 @@ class ConfiguratorHandler(BaseHTTPServer
def do_POST(self):
"""Handles POST requests, in the form of json-serialized command (request)
objects, from the frontend."""
+ log_thread_name()
try:
# Assume all post requests are json
assert 'application/json' in self.headers['Content-Type']
@@ -330,7 +337,8 @@ class ConfiguratorHandler(BaseHTTPServer
self.server.logger.info(msg=(fmt%args))
-class ConfiguratorServer(BaseHTTPServer.HTTPServer):
+class ConfiguratorServer(SocketServer.ThreadingMixIn, BaseHTTPServer.HTTPServer):
+ """Specialization of HTTPServer which adds ssl wrapping, shutdown on close and MT (by also inheriting SocketServer.ThreadingMixIn."""
def __init__(self, opts):
# Cannot use super() here, as BaseServer is not a new-style class
SocketServer.TCPServer.__init__(self, (opts['server'], opts['port']), ConfiguratorHandler)
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-5.5-cluster-7.2 branch (Dyre.Tjeldvoll:4083 to 4084) | Dyre Tjeldvoll | 4 Oct |