Esempio n. 1
0
    def __init__(self,
                 proxy_host,
                 frontend_host,
                 proxy_port,
                 frontend_port,
                 report_interval=5):
        """Dpe Constructor

        Args:
            proxy_host (String): local hostname
            frontend_host (String): frontend hostname
            proxy_port (int): proxy port, default is 7791
            frontend_port (int): frontend port, default is 7791
            report_interval (int): time interval in seconds for reporting
                service to update the frontend

        Returns:
            Dpe: Dpe object
        """
        if proxy_host == frontend_host and proxy_host == frontend_port:
            proxy_host = xMsgUtil.host_to_ip(proxy_host)
            frontend_host = proxy_host
            _is_frontend = True
        else:
            proxy_host = xMsgUtil.host_to_ip(proxy_host)
            frontend_host = xMsgUtil.host_to_ip(frontend_host)
            _is_frontend = False

        dpe_name = DpeName(str(proxy_host), proxy_port, ClaraLang.PYTHON)

        super(Dpe, self).__init__(dpe_name.canonical_name(), proxy_host,
                                  proxy_port, frontend_host, frontend_port)
        self.dpe_name = dpe_name
        self._is_frontend = _is_frontend
        self._logger = ClaraLogger(repr(self))
        self._print_logo()

        if not self._is_frontend:
            self._report = DpeReport(self, getuser())
            self._report_control = Event()
            self._report_service = _ReportingService(self._report_control,
                                                     report_interval, self)
            self._report_service.start()

        self.subscription_handler = None
        self._start()
Esempio n. 2
0
 def register_data(self, n):
     r_data = xMsgRegistration_pb2.xMsgRegistration()
     r_data.name = "name%s" % n
     r_data.description = "description"
     r_data.host = xMsgUtil.host_to_ip("localhost")
     r_data.port = 8888
     r_data.domain = "domain%s" % n
     r_data.subject = "subject%s" % n
     r_data.type = "xtype%s" % n
     return r_data
Esempio n. 3
0
 def __init__(self,
              host="localhost",
              pub_port=xMsgConstants.DEFAULT_PORT,
              sub_port=None):
     """"By default creates an address using localhost and default port if
     no parameters are given
     """
     self.host = xMsgUtil.host_to_ip(host)
     self.pub_port = pub_port
     self.sub_port = sub_port or default_sub_port(self.pub_port)
Esempio n. 4
0
    def __init__(self, driver, publishers_db, subscribers_db):
        super(xMsgRegUpdater, self).__init__()
        self.driver = driver
        self.publishers_db = publishers_db
        self.subscribers_db = subscribers_db
        self.name = "%s_registration_updater" % xMsgUtil.host_to_ip(
            "localhost")
        self.daemon = True

        # Lock used to lock xMsgNode databases access
        self.lock = threading.Lock()
Esempio n. 5
0
    def __init__(self, host="localhost", port=xMsgConstants.REGISTRAR_PORT):
        """Constructor that converts host name into a dotted notation
        of the IP address.

        It creates an instance of the cMsgAddress using user provided host and
        port. If port is not defined uses default port

        Args:
            host (String): The registrar service hostname
            port (int): The registrar port number
        """
        self.host = xMsgUtil.host_to_ip(host)
        self.port = port
        self.address = "tcp://%s:%d" % (self.host, self.port)
 def _get_clara_base(self, fe_host):
     return ClaraBase(self.name,
                      ClaraUtils.localhost(),
                      xMsgConstants.DEFAULT_PORT,
                      xMsgUtil.host_to_ip(fe_host),
                      xMsgConstants.REGISTRAR_PORT)
Esempio n. 7
0
 def _get_ctrl_id_prefix():
     python_id = 3
     localhost = xMsgUtil.host_to_ip("localhost")
     ip_hash = int(hash(localhost)) & sys.maxint
     return python_id * 100000000 + (ip_hash % 1000) * 100000
Esempio n. 8
0
 def localhost():
     return xMsgUtil.host_to_ip("localhost")