Exemplo n.º 1
0
    def handle(self):
        """
            This function handles any inputs to our tx socket
        """
        sock = self.request

        logger.debug("Handler got message, forwarding to scheduler...")

        # Receive our header
        msg = NodeMessage()
        header = sock.recv(len(msg))

        # Receive our data
        msg._unpack(header)
        if msg.length > 0:
            msg.data = sock.recv(msg.length)

        # Forward data along to our scheduler
        TX_QUEUE.put(msg)
Exemplo n.º 2
0
 def handle(self):
     """
         This function handles any inputs to our tx socket
     """
     sock = self.request
     
     logger.debug("Handler got message, forwarding to scheduler...")
     
     # Receive our header
     msg = NodeMessage()
     header = sock.recv(len(msg))
     
     # Receive our data
     msg._unpack(header)
     if msg.length > 0:
         msg.data = sock.recv(msg.length)
     
     # Forward data along to our scheduler
     TX_QUEUE.put(msg)
Exemplo n.º 3
0
    def handle(self):
        """
            This function handles any inputs to our tx socket
        """
        sock = self.request

        logger.debug("Database handler got message, processing...")

        # Receive our header
        node_message = NodeMessage()
        header = sock.recv(len(node_message))

        # Receive our data
        node_message._unpack(header)
        if node_message.length > 0:
            node_message.data = sock.recv(node_message.length)

        # Grab our mutex to ensure only 1 write at time.
        with db_mutex:
            if node_message.type == G.MESSAGE_TYPE.DB_GPS:
                update_fn = DatabaseServer.DB.update_gps
            elif node_message.type == G.MESSAGE_TYPE.DB_PERSON:
                update_fn = DatabaseServer.DB.update_person
            elif node_message.type == G.MESSAGE_TYPE.DB_SERVICE:
                update_fn = DatabaseServer.DB.update_service
            else:
                logger.error("Got unrecognized DB packet. (Type: %d)" %
                             node_message.type)
                return False

            rtn_data = update_fn(node_message)
            if rtn_data is not False:
                logger.debug("Successfully updated db.")
                sock.sendall( ` rtn_data `)
            else:
                logger.debug("Db update failed.")
                sock.sendall("0")
Exemplo n.º 4
0
    def handle(self):
        """
            This function handles any inputs to our tx socket
        """
        sock = self.request

        logger.debug("Database handler got message, processing...")
        
        # Receive our header
        node_message = NodeMessage()
        header = sock.recv(len(node_message))
        
        # Receive our data
        node_message._unpack(header)
        if node_message.length > 0:
            node_message.data = sock.recv(node_message.length)

        # Grab our mutex to ensure only 1 write at time.
        with db_mutex:
            if node_message.type == G.MESSAGE_TYPE.DB_GPS:
                update_fn = DatabaseServer.DB.update_gps
            elif node_message.type == G.MESSAGE_TYPE.DB_PERSON:
                update_fn = DatabaseServer.DB.update_person
            elif node_message.type == G.MESSAGE_TYPE.DB_SERVICE:
                update_fn = DatabaseServer.DB.update_service
            else:
                logger.error("Got unrecognized DB packet. (Type: %d)"%
                             node_message.type)
                return False
            
            rtn_data = update_fn(node_message)
            if rtn_data is not False:
                logger.debug("Successfully updated db.")
                sock.sendall(`rtn_data`)
            else:
                logger.debug("Db update failed.")
                sock.sendall("0")