ResolveGPCS.py (3235B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\carbon\common\script\net\ResolveGPCS.py 2 import types 3 from carbon.common.script.net.machoNetAddress import MachoAddress 4 from carbon.common.script.net.machoNetExceptions import UnMachoDestination, WrongMachoNode 5 from carbon.common.script.util.timerstuff import ClockThis 6 from cluster import MACHONETMSG_TYPE_RESOLVE_REQ 7 from machonet_tracing import IngressTracer 8 9 class ResolveGPCS: 10 __guid__ = 'gpcs.Resolve' 11 12 def CallUp(self, packet): 13 if getattr(packet.destination, 'service', 0): 14 if packet.payload[1] == 'MachoBindObject': 15 nodeID = None 16 else: 17 nodeID = ClockThis('machoNet::GPCS::gpcs.Resolve::CallUp::MachoResolve', sm.StartServiceAndWaitForRunningState(packet.destination.service).MachoResolve, session.GetActualSession()) 18 if type(nodeID) == types.StringType: 19 if packet.command == MACHONETMSG_TYPE_RESOLVE_REQ: 20 return packet.Response(0, nodeID) 21 raise UnMachoDestination("Failed to resolve %s, reason='%s'" % (packet.destination.service, nodeID)) 22 elif nodeID is None: 23 if packet.command == MACHONETMSG_TYPE_RESOLVE_REQ: 24 rsp = packet.Response(1, '') 25 rsp.source = MachoAddress(service=packet.destination.service) 26 return rsp 27 else: 28 if packet.command == MACHONETMSG_TYPE_RESOLVE_REQ: 29 rsp = packet.Response(1, '') 30 rsp.source = MachoAddress(nodeID=nodeID, service=packet.destination.service) 31 return rsp 32 if nodeID != self.machoNet.GetNodeID(): 33 IngressTracer.set_error_state(WrongMachoNode.__guid__) 34 raise WrongMachoNode(nodeID) 35 return self.ForwardCallUp(packet) 36 37 def NotifyUp(self, packet): 38 if getattr(packet.destination, 'service', 0): 39 nodeID = sm.StartServiceAndWaitForRunningState(packet.destination.service).MachoResolve(session.GetActualSession()) 40 if type(nodeID) == types.StringType: 41 self.machoNet.LogError('Resolve failed during notification. Packet lost. Failure reason=', nodeID) 42 raise UnMachoDestination("Failed to resolve %s, reason='%s'" % (packet.destination.service, nodeID)) 43 elif nodeID is None: 44 pass 45 else: 46 thisNodeID = self.machoNet.GetNodeID() 47 if nodeID != thisNodeID: 48 self.machoNet.LogInfo('Notification packet recieved on the wrong node(', thisNodeID, '), forwarding to the correct one ', nodeID) 49 packet.destination = MachoAddress(nodeID=nodeID, service=packet.destination.service) 50 proxyID = self.machoNet.GetProxyNodeIDFromClientID(packet.source.clientID) 51 proxyMachoNet = self.machoNet.session.ConnectToRemoteService('machoNet', nodeID=proxyID) 52 proxyMachoNet.NoBlock.ForwardNotificationToNode(packet.source, packet.destination, packet.userID, packet.payload) 53 return 54 return self.ForwardNotifyUp(packet)