2 Created on Feb 17, 2014 5 @link: http://hierarchical-cluster-engine.com/ 6 @copyright: Copyright © 2013-2014 IOIX Ukraine 7 @license: http://hierarchical-cluster-engine.com/license/ 11 from NodeManagerResponse
import NodeManagerResponse
17 import Constants
as CONSTANTS
18 import AdminExceptions
24 def __init__(self, errorCode=CONSTANTS.ERROR_NO, connectionBuilder=None, connectionIdGenerator=None):
26 if connectionBuilder ==
None:
27 if connectionIdGenerator ==
None:
39 errorCode = CONSTANTS.ERROR_NO
40 if response.get_uid() != message[CONSTANTS.STRING_MSGID_NAME]:
41 errorCode = CONSTANTS.ERROR_BAD_MSG_ID
47 if exceptionString !=
None:
48 if exceptionString == CONSTANTS.STRING_EXCEPTION_WRONG_CONNECTION_KEY:
57 exceptionString =
None 59 adminConnection =
None 62 adminConnection = self.connectionBuilder.build(transport.Consts.ADMIN_CONNECT_TYPE, connectParams)
63 except KeyError
as exp:
64 exceptionString = CONSTANTS.STRING_EXCEPTION_WRONG_CONNECTION_KEY
66 if adminConnection !=
None:
67 request =
Request(message[CONSTANTS.STRING_MSGID_NAME])
68 request.add_data(message[CONSTANTS.STRING_BODY_NAME])
69 adminConnection.send(request)
72 if commandTimeout ==
None:
73 elapsedTime = node.getElapsedTime()
74 if elapsedTime >= node.getTimeout():
75 exceptionString = CONSTANTS.STRING_EXCEPTION_ADMIN_TIMEOUT
77 localTimeout = node.getTimeout() - elapsedTime
79 localTimeout = commandTimeout
83 respond = adminConnection.recv(localTimeout)
84 except ConnectionTimeout
as exp:
85 exceptionString = exp.message
86 adminConnection.close()
87 self.raiseAdminExceptions(exceptionString)
88 return self.createNodeManagerResponse(respond, message)
NodeManagerResponse class that represents admin modules response.
def makeRequest(self, node, message, commandTimeout=None)
makeRequest main class method, it gets node and message params, interact with transport layer...
NodeManagerRequest class contents all data needed for admin level's request sending.
AdminExceptions module keepts admin module native exceptions.
def __init__(self, errorCode=CONSTANTS.ERROR_NO, connectionBuilder=None, connectionIdGenerator=None)
def raiseAdminExceptions(self, exceptionString)
raiseAdminExceptions method generates exceptions based on analyze of exceptionString param's data ...
It's a wrapper similar to zmsg.hpp in sense of encapsulation of hce message structure.
The builder is used to encapsulation routine of creation various type of connections.
def createNodeManagerResponse(self, response, message)
IDGenerator is used to generate unique id for connections.