Exemple #1
0
 def ClusterBroadcast(self, method, *args):
     with bluepy.Timer('machoNet::ClusterBroadcast'):
         callTimer = base.CallTimer('ClusterBroadcast::%s (Broadcast\\Client)' % method)
         try:
             self.ForwardNotifyDown(macho.Notification(destination=macho.MachoAddress(broadcastID=method, idtype='nodeID'), payload=(1, args)))
             self.ForwardNotifyDown(macho.Notification(destination=macho.MachoAddress(broadcastID=method, idtype='+nodeID', narrowcast=self.machoNet.GetConnectedProxyNodes()), payload=(1, args)))
             if method.startswith('Process'):
                 sm.ChainEventWithoutTheStars(method, args)
             elif method.startswith('Do'):
                 sm.SendEventWithoutTheStars(method, args)
             else:
                 sm.ScatterEventWithoutTheStars(method, args)
         finally:
             callTimer.Done()
Exemple #2
0
 def SinglecastByWorldSpaceID(self, instanceid, method, *args):
     with bluepy.Timer('machoNet::SinglecastByWorldSpaceID'):
         callTimer = base.CallTimer('SinglecastByWorldSpaceID::%s (Broadcast\\Client)' % method)
         try:
             self.ForwardNotifyDown(macho.Notification(destination=macho.MachoAddress(broadcastID=method, idtype='worldspaceid', narrowcast=[instanceid]), payload=(1, args)))
         finally:
             callTimer.Done()
Exemple #3
0
 def NarrowcastByNodeIDsWithoutTheStars(self, nodeids, method, args, kwargs):
     if len(nodeids):
         if 'sourceNodeID' in kwargs:
             source = macho.MachoAddress(nodeID=kwargs['sourceNodeID'], service=None, callID=None)
         else:
             source = macho.MachoAddress()
         destination = macho.MachoAddress(broadcastID=method, idtype='nodeID', narrowcast=nodeids)
         self.ForwardNotifyDown(macho.Notification(source=source, destination=destination, payload=(1, args)))
 def NarrowcastByShipIDs(self, shipids, method, *args):
     if not shipids:
         return
     callTimer = base.CallTimer('NarrowcastByShipIDs::%s (Broadcast\\Client)' % method)
     try:
         self.ForwardNotifyDown(macho.Notification(destination=macho.MachoAddress(broadcastID=method, idtype='shipid', narrowcast=shipids), payload=(1, args)))
     finally:
         callTimer.Done()
Exemple #5
0
 def ScattercastWithoutTheStars(self, idtype, ids, method, args):
     if not idtype.startswith('+'):
         idtype = '*%s' % idtype
     if ids:
         self.ForwardNotifyDown(
             macho.Notification(destination=macho.MachoAddress(
                 broadcastID=method, idtype=idtype, narrowcast=ids),
                                payload=(1, args)))
Exemple #6
0
 def ClientBroadcast(self, method, *args):
     with bluepy.Timer('machoNet::ClientBroadcast'):
         callTimer = base.CallTimer('ClientBroadcast::%s (Broadcast\\Client)' % method)
         try:
             packet = macho.Notification(destination=macho.MachoAddress(broadcastID=method, idtype='clientID'), payload=(1, args))
             self.ForwardNotifyDown(packet)
         finally:
             callTimer.Done()
 def NarrowcastBySolarSystemID2s(self, solarsystemid2s, method, *args):
     if not solarsystemid2s:
         return
     callTimer = base.CallTimer('NarrowcastBySolarSystemID2s::%s (Broadcast\\Client)' % method)
     try:
         self.ForwardNotifyDown(macho.Notification(destination=macho.MachoAddress(broadcastID=method, idtype='solarsystemid2', narrowcast=solarsystemid2s), payload=(1, args)))
     finally:
         callTimer.Done()
Exemple #8
0
 def NarrowcastByCharIDs(self, charids, method, *args):
     if not charids:
         return
     with bluepy.Timer('machoNet::NarrowcastByCharIDs'):
         callTimer = base.CallTimer('NarrowcastByCharIDs::%s (Broadcast\\Client)' % method)
         try:
             self.ForwardNotifyDown(macho.Notification(destination=macho.MachoAddress(broadcastID=method, idtype='charid', narrowcast=charids), payload=(1, args)))
         finally:
             callTimer.Done()
 def SinglecastByCorporationID(self, corpid, method, *args):
     callTimer = base.CallTimer(
         'SinglecastByCorporationID::%s (Broadcast\\Client)' % method)
     try:
         self.ForwardNotifyDown(
             macho.Notification(destination=macho.MachoAddress(
                 broadcastID=method, idtype='corpid', narrowcast=[corpid]),
                                payload=(1, args)))
     finally:
         callTimer.Done()
Exemple #10
0
 def SinglecastByServiceMaskWithoutTheStars(self, serviceMask, method, args, kwargs):
     destination = macho.MachoAddress(broadcastID=method, idtype='serviceMask', narrowcast=[serviceMask])
     source = macho.MachoAddress()
     self.ForwardNotifyDown(macho.Notification(source=source, destination=destination, payload=(1, args)))
     if macho.mode == 'server' and self.machoNet.serviceMask & serviceMask:
         if method.startswith('Process'):
             sm.ChainEventWithoutTheStars(method, args)
         elif method.startswith('Do'):
             sm.SendEventWithoutTheStars(method, args)
         else:
             sm.ScatterEventWithoutTheStars(method, args)
Exemple #11
0
 def NarrowcastToObservers(self, sourceEntityID, method, *args):
     with bluepy.Timer('machoNet::NarrowcastToObservers'):
         callTimer = base.CallTimer('NarrowcastToObservers::%s (Broadcast\\Client)' % method)
         try:
             if not self.apertureService:
                 self.apertureService = sm.GetService('apertureServer')
             charids = self.apertureService.GetSubjectObservers(sourceEntityID)
             if charids:
                 self.ForwardNotifyDown(macho.Notification(destination=macho.MachoAddress(broadcastID=method, idtype='charid', narrowcast=charids), payload=(1, args)))
         finally:
             callTimer.Done()
 def SinglecastBySolarSystemID2(self, solarsystemid2, method, *args):
     callTimer = base.CallTimer(
         'SinglecastBySolarSystemID2::%s (Broadcast\\Client)' % method)
     try:
         self.ForwardNotifyDown(
             macho.Notification(destination=macho.MachoAddress(
                 broadcastID=method,
                 idtype='solarsystemid2',
                 narrowcast=[solarsystemid2]),
                                payload=(1, args)))
     finally:
         callTimer.Done()
Exemple #13
0
 def ServerBroadcast(self, method, *args):
     with bluepy.Timer('machoNet::ServerBroadcast'):
         callTimer = base.CallTimer('ServerBroadcast::%s (Broadcast\\Client)' % method)
         try:
             self.ForwardNotifyDown(macho.Notification(destination=macho.MachoAddress(broadcastID=method, idtype='nodeID'), payload=(1, args)))
             if macho.mode == 'server':
                 if method.startswith('Process'):
                     sm.ChainEventWithoutTheStars(method, args)
                 elif method.startswith('Do'):
                     sm.SendEventWithoutTheStars(method, args)
                 else:
                     sm.ScatterEventWithoutTheStars(method, args)
         finally:
             callTimer.Done()
Exemple #14
0
    def RemoteServiceNotifyWithoutTheStars(self, sess, nodeID, service, method, args, keywords):
        while 1:
            try:
                if sess is None:
                    self.machoNet.LogError('Session is None during RemoteServiceNotify')
                    log.LogTraceback()
                if nodeID is None and macho.mode == 'client':
                    nodeID = self.services.get(service, None)
                    if nodeID is None and service in self.machoNet.serviceInfo:
                        where = self.machoNet.serviceInfo[service]
                        for k, v in self.machoNet.serviceInfo.iteritems():
                            if k != service and v == where:
                                nodeID = self.services.get(k, None)
                                break

                    if nodeID is None and self.machoNet.serviceInfo.get(service, None) is not None:
                        self.machoNet.LogInfo("I haven't got a clue where ", service, ' should run, although I could guess any of these: ', str(self.services.keys()))
                if nodeID is None:
                    if macho.mode == 'server':
                        proxies = self.machoNet.GetConnectedProxyNodes()
                        if not proxies:
                            raise UnMachoDestination('No proxy available')
                        destination = macho.MachoAddress(nodeID=random.choice(proxies), service=service)
                    else:
                        destination = macho.MachoAddress(service=service)
                elif isinstance(nodeID, macho.MachoAddress):
                    destination = nodeID
                else:
                    destination = macho.MachoAddress(nodeID=nodeID, service=service)
                if keywords:
                    kw2 = copy.copy(keywords)
                else:
                    kw2 = {}
                if currentcall:
                    machoTimeout = kw2.get('machoTimeout', currentcall.packet.oob.get('machoTimeout', None))
                else:
                    machoTimeout = kw2.get('machoTimeout', None)
                if 'machoTimeout' in kw2:
                    del kw2['machoTimeout']
                if kw2:
                    payload = (1,
                     method,
                     args,
                     kw2)
                else:
                    payload = (1, method, args)
                packet = macho.Notification(destination=destination, payload=payload)
                if machoTimeout is not None:
                    packet.oob['machoTimeout'] = machoTimeout
                mask = sess.Masquerade()
                try:
                    callTimer = base.CallTimer('%s::%s (ServiceNotify\\Client)' % (service, method))
                    try:
                        self.ForwardNotifyDown(packet)
                    finally:
                        callTimer.Done()

                finally:
                    mask.UnMask()

            except WrongMachoNode as e:
                sys.exc_clear()
                self.services[service] = e.payload
                if nodeID == e.payload:
                    self.machoNet.LogError('Redirected to same node', nodeID)
                    raise UnMachoDestination('Failed to redirect call, because we were being redirected to the same place we were trying to call in the first place (%s)' % nodeID)
                else:
                    self.machoNet.LogInfo('Redirecting call to node ', e.payload, ' that was originally intended for node ', nodeID)
                    nodeID = e.payload
                    continue
            except UserError as e:
                if e.msg in ('UnMachoDestination', 'GPSTransportClosed'):
                    self.services.clear()
                raise 
            except StandardError:
                self.services.clear()
                raise 

            return
Exemple #15
0
 def ObjectcastWithoutTheStars(self, object, method, args):
     objectID = base.GetObjectUUID(object)
     self.ForwardNotifyDown(macho.Notification(destination=macho.MachoAddress(broadcastID=method, idtype='objectID', narrowcast=[objectID]), payload=(1, args)))
Exemple #16
0
    def ObjectCallWithoutTheStars(self, oob, persistantObjectID, blocking, sess, destination, objectID, method, args, keywords):
        cachable, versionCheck, throwOK, cachedResultRecord, cacheKey, cacheDetails = sm.GetService('objectCaching').PerformCachedMethodCall(None, persistantObjectID, method, args)
        if cachable:
            if not versionCheck:
                if throwOK:
                    sm.GetService('objectCaching').LogInfo('Local cache hit with throw for remote object ', persistantObjectID, '::', method, '(', args, ')')
                    raise objectCaching.CacheOK()
                elif cachedResultRecord:
                    sm.GetService('objectCaching').LogInfo('Local cache hit for remote object ', persistantObjectID, '::', method, '(', args, ')')
                    return cachedResultRecord['lret']
        if keywords:
            kw2 = copy.copy(keywords)
        else:
            kw2 = {}
        if kw2.get('machoVersion', None) is None:
            if cachedResultRecord is not None and cachedResultRecord['version'] is not None:
                kw2['machoVersion'] = cachedResultRecord['version']
            else:
                kw2['machoVersion'] = 1
        if currentcall:
            machoTimeout = kw2.get('machoTimeout', currentcall.packet.oob.get('machoTimeout', None))
        else:
            machoTimeout = kw2.get('machoTimeout', None)
        if 'machoTimeout' in kw2:
            del kw2['machoTimeout']
        payload = (1, self.ToPickle((objectID,
          method,
          args,
          kw2)))
        if blocking == 1:
            packet = macho.CallReq(destination=destination, payload=payload)
            if oob:
                packet.oob = oob
            if machoTimeout is not None:
                packet.oob['machoTimeout'] = machoTimeout
            if self.added_objects:
                if 'OID+' in packet.oob:
                    packet.oob['OID+'].update(self.added_objects)
                else:
                    packet.oob['OID+'] = self.added_objects
            try:
                callTimer = base.CallTimer('Remote Object Call::%s (ObjectCall\\Client)' % (method,))
                try:
                    retval = self.ForwardCallDown(packet)
                finally:
                    callTimer.Done()

                retval = self.FromPickle(retval.payload, packet.destination)
            except objectCaching.CacheOK:
                if cachedResultRecord is None:
                    raise 
                sys.exc_clear()
                sm.GetService('objectCaching').LogInfo('Version matches for remote object ', persistantObjectID, '::', method, '(', args, ')')
                sm.GetService('objectCaching').UpdateVersionCheckPeriod(cacheKey)
                return cachedResultRecord['lret']

            if isinstance(retval, objectCaching.CachedMethodCallResult):
                sm.GetService('objectCaching').CacheMethodCall(persistantObjectID, method, args, retval)
                retval = retval.GetResult()
            return retval
        else:
            packet = macho.Notification(destination=destination, payload=payload)
            if oob:
                packet.oob = oob
            if machoTimeout is not None:
                packet.oob['machoTimeout'] = machoTimeout
            if self.added_objects:
                if 'OID+' in packet.oob:
                    packet.oob['OID+'].update(self.added_objects)
                else:
                    packet.oob['OID+'] = self.added_objects
            self.ForwardNotifyDown(packet)
            return MachoBoobyTrap()
Exemple #17
0
 def NarrowcastByClientIDsWithoutTheStars(self, clientids, method, args):
     if len(clientids):
         packet = macho.Notification(destination=macho.MachoAddress(broadcastID=method, idtype='clientID', narrowcast=clientids), payload=(1, args))
         self.ForwardNotifyDown(packet)