def connectPort(self, connection, connectionId):

        if self.logger:
            self.logger.trace('bulkio::OutPort  connectPort ENTER ')

        self.port_lock.acquire()
        try:
           try:
              port = connection._narrow(self.PortType)
              if port == None:
                  raise Port.InvalidPort(1, "Invalid Port for Connection ID:" + str(connectionId) )
              self.outConnections[str(connectionId)] = port

              if self.logger:
                  self.logger.debug('bulkio::OutPort  CONNECT PORT:' + str(self.name) + ' CONNECTION:' + str(connectionId) )
              
           except:
              if self.logger:
                  self.logger.error('bulkio::OutPort  CONNECT PORT:' + str(self.name) + ' PORT FAILED NARROW')
              raise Port.InvalidPort(1, "Invalid Port for Connection ID:" + str(connectionId) )
        finally:
            self.port_lock.release()

        if self.logger:
            self.logger.trace('bulkio::OutPort  connectPort EXIT ')
    def connectPort(self, connection, connectionId):
        if self.logger:
            self.logger.trace('OutShortPort_customized:  connectPort ENTER ')

        self.port_lock.acquire()
        try:
            try:
                port = connection._narrow(self.PortType)
                self.outConnections[str(connectionId)] = port
                self.refreshSRI = True

                if self.logger:
                    self.logger.debug(
                        'OutShortPort_customized:  CONNECT PORT:' +
                        str(self.name) + ' CONNECTION:' + str(connectionId))

            except:
                if self.logger:
                    self.logger.error(
                        'OutShortPort_customized:  CONNECT PORT:' +
                        str(self.name) + ' PORT FAILED NARROW')
                raise Port.InvalidPort(
                    1, "Invalid Port for Connection ID:" + str(connectionId))
        finally:
            self.port_lock.release()

        self.pushSRI_on_connection(connectionId)

        if self.logger:
            self.logger.trace('OutShortPort_customized:  connectPort EXIT ')
예제 #3
0
    def connectPort(self, connection, connectionId):
        OutPort.connectPort( self, connection, connectionId )
        self.port_lock.acquire()
        try:
            try:
                portListed = False
                port = self.outConnections[str(connectionId)]

                if self._portLog:
                    self._portLog.trace("bulkio::OutAttachablePort connectPort(), Filter Table %s" % self.filterTable)
                for ftPtr in self.filterTable:
                    # check if port was listed in connection filter table
                    if ftPtr.port_name == self.name:
                        portListed = True

                    if (ftPtr.port_name == self.name) and (ftPtr.connection_id == connectionId):
                        desiredStreamId = ftPtr.stream_id
                        self.streamContainer.addConnectionToStream(connectionId,port,desiredStreamId)

                if not portListed:
                    self.streamContainer.addConnectionToAllStreams(connectionId,port) 

                self.updateSRIForAllConnections()
            except Exception, e:
                if self._portLog:
                    self._portLog.error("CONNECTION FAILED, CONNECTION %s , EXCEPTION: %s" ,  connectionId, str(e))
                raise Port.InvalidPort(1, "Invalid Port for Connection ID:" + str(connectionId) )
        finally:
            self.port_lock.release()
        self.streamContainer.printState("After connectPort")
예제 #4
0
 def connectPort(self, connection, connectionId):
     self.port_lock.acquire()
     try:
        try:
           port = connection._narrow(self.PortType)
           self.outConnections[str(connectionId)] = port
           self.refreshSRI = True
        except:
           raise Port.InvalidPort(1, "Invalid Port for Connection ID:" + str(connectionId) )
     finally:
         self.port_lock.release()
예제 #5
0
 def __init__(self, name, max_attachments=None, logger=None, interface=None ):
     OutPort.__init__(self, name, interface, OutAttachablePort.TRANSFER_TYPE, logger, bits=8)
     self.max_attachments = max_attachments
     self.streamContainer = OutAttachablePort.StreamContainer()
     self.sriDict = {} # key=streamID  value=SriMapStruct
     self.filterTable = []
     if not interface:
         if self._portLog:
             self._portLog.error("OutAttachablePort __init__ - an interface must be specified, set to BULKIO.dataSDDS or BULKIO.dataVITA49")
         raise Port.InvalidPort(1, "OutAttachablePort __init__ - an interface must be specified, set to BULKIO.dataSDDS or BULKIO.dataVITA49")
     self.interface=interface # BULKIO port interface (valid options are BULKIO.dataSDDS or BULKIO.dataVITA49)
     self.setLogger(self._portLog)
예제 #6
0
 def __init__(self,
              name,
              logger=None,
              attachDetachCallback=None,
              sriCmp=sri.compare,
              timeCmp=timestamp.compare,
              PortType=_TYPE_,
              newSriCallback=None,
              sriChangeCallback=None,
              interface=None):
     self.name = name
     self.logger = logger
     self.port_lock = threading.Lock()
     self.sri_query_lock = threading.Lock()
     self._attachedStreams = {
     }  # key=attach_id, value = (streamDef, userid)
     self.stats = InStats(name, PortType)
     self.sriDict = {}  # key=streamID, value=(StreamSRI, PrecisionUTCTime)
     self.attachDetachCallback = attachDetachCallback
     self.newSriCallback = newSriCallback
     self.sriChangeCallback = sriChangeCallback
     self.sri_cmp = sriCmp
     self.time_cmp = timeCmp
     self.sriChanged = False
     if not interface:
         if self.logger:
             self.logger.error(
                 "InAttachablePort __init__ - an interface must be specified, set to BULKIO.dataSDDS or BULKIO.dataVITA49"
             )
         raise Port.InvalidPort(
             1,
             "InAttachablePort __init__ - an interface must be specified, set to BULKIO.dataSDDS or BULKIO.dataVITA49"
         )
     self.interface = interface  # BULKIO port interface (valid options are BULKIO.dataSDDS or BULKIO.dataVITA49)
     self.setNewAttachDetachListener(attachDetachCallback)
     if self.logger:
         self.logger.debug("bulkio::InAttachablePort CTOR port:" +
                           str(self.name) + " using interface " +
                           str(self.interface))
예제 #7
0
    def connectPort(self, connection, connectionId):
        if self._portLog:
            self._portLog.trace('bulkio::OutPort  connectPort ENTER ')

        if connection is None:
            raise CF.Port.InvalidPort(1, 'Nil object reference')

        # Attempt to check the type of the remote object to reject invalid
        # types; note this does not require the lock
        repo_id = self.PortType._NP_RepositoryId
        try:
            valid = connection._is_a(repo_id)
        except:
            # If _is_a throws an exception, assume the remote object is
            # unreachable (probably dead)
            raise CF.Port.InvalidPort(1, 'Object unreachable')

        if not valid:
            raise CF.Port.InvalidPort(1, 'Object does not support '+repo_id)

        port = connection._narrow(self.PortType)

        # Acquire the state lock before modifying the container
        with self.port_lock:
            # Prevent duplicate connection IDs
            if str(connectionId) in self.outConnections:
                raise Port.OccupiedPort()

            self.outConnections[str(connectionId)] = port
            self.stats.add(connectionId)

            if self._portLog:
                self._portLog.debug('bulkio::OutPort  CONNECT PORT:%s CONNECTION:%s', self.name, connectionId)

        if self._portLog:
            self._portLog.trace('bulkio::OutPort  connectPort EXIT ')