• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python connection_info.ConnectionState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pysandesh.connection_info.ConnectionState的典型用法代码示例。如果您正苦于以下问题:Python ConnectionState类的具体用法?Python ConnectionState怎么用?Python ConnectionState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ConnectionState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, conf):
     self._conf = conf
     module = Module.CONTRAIL_TOPOLOGY
     self._moduleid = ModuleNames[module]
     node_type = Module2NodeType[module]
     self._node_type_name = NodeTypeNames[node_type]
     self._hostname = socket.gethostname()
     self._instance_id = '0'
     if self._conf.sandesh_send_rate_limit() is not None:
         SandeshSystem.set_sandesh_send_rate_limit( \
             self._conf.sandesh_send_rate_limit())
     sandesh_global.init_generator(self._moduleid, self._hostname,
                                   self._node_type_name, self._instance_id,
                                   self._conf.collectors(), 
                                   self._node_type_name,
                                   self._conf.http_port(),
                                   ['contrail_topology.sandesh'],
                                   self._conf._disc)
     sandesh_global.set_logging_params(
         enable_local_log=self._conf.log_local(),
         category=self._conf.log_category(),
         level=self._conf.log_level(),
         file=self._conf.log_file(),
         enable_syslog=self._conf.use_syslog(),
         syslog_facility=self._conf.syslog_facility())
     ConnectionState.init(sandesh_global, self._hostname, self._moduleid,
         self._instance_id,
         staticmethod(ConnectionState.get_process_state_cb),
         NodeStatusUVE, NodeStatus)
开发者ID:Pojen-Huang,项目名称:contrail-controller,代码行数:29,代码来源:topology_uve.py


示例2: __init__

    def __init__(self, conf, instance='0'):
        self._conf = conf
        module = Module.CONTRAIL_SNMP_COLLECTOR
        self._moduleid = ModuleNames[module]
        node_type = Module2NodeType[module]
        self._node_type_name = NodeTypeNames[node_type]
        self._hostname = socket.gethostname()
        self._instance_id = instance
        sandesh_global.init_generator(self._moduleid, self._hostname,
                                      self._node_type_name, self._instance_id,
                                      self._conf.collectors(),
                                      self._node_type_name,
                                      self._conf.http_port(),
                                      ['contrail_snmp_collector.gen_py',
                                      'opserver.sandesh'],
                                      self._conf._disc)
        sandesh_global.set_logging_params(
            enable_local_log=self._conf.log_local(),
            category=self._conf.log_category(),
            level=self._conf.log_level(),
            file=self._conf.log_file(),
            enable_syslog=self._conf.use_syslog(),
            syslog_facility=self._conf.syslog_facility())
        ConnectionState.init(sandesh_global, self._hostname, self._moduleid,
            self._instance_id,
            staticmethod(ConnectionState.get_process_state_cb),
            NodeStatusUVE, NodeStatus)

        self.if_stat = {}
        self._logger = sandesh_global.logger()
开发者ID:skizhak,项目名称:contrail-controller,代码行数:30,代码来源:snmpuve.py


示例3: _redis_inst_up

    def _redis_inst_up(self, r_inst, redish):
	if not self._redis_uve_map[r_inst]:
            r_ip = r_inst[0]
            r_port = r_inst[1]
	    self._redis_uve_map[r_inst] = redish
	    ConnectionState.update(ConnectionType.REDIS_UVE,
		r_ip + ":" + str(r_port), ConnectionStatus.UP)
开发者ID:piotrkasprzyk,项目名称:contrail-controller,代码行数:7,代码来源:uveserver.py


示例4: sandesh_init

    def sandesh_init(self):
        """ Init Sandesh """
        self._sandesh = Sandesh()

        # Register custom sandesh request handlers.
        self._redefine_sandesh_handles()

        # Initialize Sandesh generator.
        self._sandesh.init_generator(
            self._module["name"], self._module["hostname"],
            self._module["node_type_name"], self._module["instance_id"],
            self._args.random_collectors, 'kube_manager_context',
            int(self._args.http_server_port),
            ['cfgm_common', 'kube_manager'],
            logger_class=self._args.logger_class,
            logger_config_file=self._args.logging_conf,
            config=self._args.sandesh_config)

        # Set Sandesh logging params.
        self._sandesh.set_logging_params(
            enable_local_log=self._args.log_local,
            category=self._args.log_category, level=self._args.log_level,
            file=self._args.log_file, enable_syslog=self._args.use_syslog,
            syslog_facility=self._args.syslog_facility)

        # Connect to collector.
        ConnectionState.init(
            self._sandesh, self._module["hostname"], self._module["name"],
            self._module["instance_id"],
            staticmethod(ConnectionState.get_process_state_cb),
            NodeStatusUVE, NodeStatus, self._module["table"])
开发者ID:cijohnson,项目名称:contrail-controller,代码行数:31,代码来源:logger.py


示例5: run

 def run(self):
     lck = False
     while True:
         try:
             k, value = self._redis.brpop("DELETED")
             self._sem.acquire()
             lck = True
             self._logger.debug("%s del received for " % value)
             # value is of the format: 
             # DEL:<key>:<src>:<node-type>:<module>:<instance-id>:<message-type>:<seqno>
             self._redis.delete(value)
         except redis.exceptions.ResponseError:
             #send redis connection down msg. Coule be bcos of authentication
             ConnectionState.update(conn_type = ConnectionType.REDIS,
                 name = 'UVE', status = ConnectionStatus.DOWN,
                 message = 'UVE result : Connection Error',
                 server_addrs = ['%s:%d' % (self._local_redis_uve[0],
                 self._local_redis_uve[1])])
             sys.exit()
         except redis.exceptions.ConnectionError:
             if lck:
                 self._sem.release()
                 lck = False
             gevent.sleep(5)
         else:
             if lck:
                 self._sem.release()
                 lck = False
             self._logger.debug("Deleted %s" % value)
             self._logger.debug("UVE %s Type %s" % (key, typ))
开发者ID:lebauce,项目名称:contrail-controller,代码行数:30,代码来源:uveserver.py


示例6: __init__

 def __init__(self, rule_file, discovery_server,
              discovery_port, collector_addr):
     EventManager.__init__(
         self, rule_file, discovery_server,
         discovery_port, collector_addr, sandesh_global)
     self.node_type = 'contrail-analytics'
     self.table = "ObjectCollectorInfo"
     self.module = Module.ANALYTICS_NODE_MGR
     self.module_id = ModuleNames[self.module]
     self.supervisor_serverurl = "unix:///var/run/supervisord_analytics.sock"
     self.add_current_process()
     node_type = Module2NodeType[self.module]
     node_type_name = NodeTypeNames[node_type]
     _disc = self.get_discovery_client()
     sandesh_global.init_generator(
         self.module_id, socket.gethostname(),
         node_type_name, self.instance_id, self.collector_addr,
         self.module_id, 8104, ['analytics', 'nodemgr.common.sandesh'], _disc)
     sandesh_global.set_logging_params(enable_local_log=True)
     ConnectionState.init(sandesh_global, socket.gethostname(), self.module_id,
         self.instance_id,
         staticmethod(ConnectionState.get_process_state_cb),
         NodeStatusUVE, NodeStatus, self.table)
     self.send_system_cpu_info()
     self.third_party_process_list = [ ]
开发者ID:VikaSliusarchuk,项目名称:contrail-controller,代码行数:25,代码来源:analytics_event_manager.py


示例7: _redis_inst_down

    def _redis_inst_down(self, r_inst):
	if self._redis_uve_map[r_inst]:
            r_ip = r_inst[0]
            r_port = r_inst[1]
	    self._redis_uve_map[r_inst] = None
	    ConnectionState.update(ConnectionType.REDIS_UVE,
		r_ip + ":" + str(r_port), ConnectionStatus.DOWN)
开发者ID:piotrkasprzyk,项目名称:contrail-controller,代码行数:7,代码来源:uveserver.py


示例8: __init__

    def __init__(self, db, discovery, args=None):
        self._args = args
        self._db = db

        module = Module.SVC_MONITOR
        node_type = Module2NodeType[module]
        self._module_name = ModuleNames[module]
        self._node_type_name = NodeTypeNames[node_type]
        self._instance_id = INSTANCE_ID_DEFAULT
        self._hostname = socket.gethostname()

        #sandesh init
        self._sandesh = self._sandesh_init(discovery)

        # connection state init
        ConnectionState.init(self._sandesh, self._hostname, self._module_name,
            self._instance_id,
            staticmethod(ConnectionState.get_process_state_cb),
            NodeStatusUVE, NodeStatus)

        #create cpu_info object to send periodic updates
        sysinfo_req = False
        cpu_info = vnc_cpu_info.CpuInfo(self._module_name, 
            self._instance_id, sysinfo_req, self._sandesh, 60)
        self._cpu_info = cpu_info
开发者ID:GIC-de,项目名称:contrail-controller,代码行数:25,代码来源:logger.py


示例9: __init__

    def __init__(self, rule_file, discovery_server,
                 discovery_port, collector_addr):
        self.node_type = "contrail-config"
        self.module = Module.CONFIG_NODE_MGR
        self.module_id = ModuleNames[self.module]
        self.supervisor_serverurl = "unix:///var/run/supervisord_config.sock"
        self.add_current_process()
        node_type = Module2NodeType[self.module]
        node_type_name = NodeTypeNames[node_type]
        self.sandesh_global = sandesh_global
        EventManager.__init__(
            self, rule_file, discovery_server,
            discovery_port, collector_addr, sandesh_global)
        _disc = self.get_discovery_client()
        sandesh_global.init_generator(
            self.module_id, socket.gethostname(),
            node_type_name, self.instance_id, self.collector_addr,
            self.module_id, 8100, ['cfgm_common.uve'], _disc)
        sandesh_global.set_logging_params(enable_local_log=True)
        ConnectionState.init(sandesh_global, socket.gethostname(),
		self.module_id, self.instance_id,
		staticmethod(ConnectionState.get_process_state_cb),
		NodeStatusUVE, NodeStatus)
        self.send_system_cpu_info()
        self.third_party_process_list = [ ]
开发者ID:avallark,项目名称:contrail-controller,代码行数:25,代码来源:config_event_manager.py


示例10: heartbeat

    def heartbeat(self):
        while True:
            # send heartbeat for each published object seperately
            # dictionary can change size during iteration
            pub_list = self.pubdata.copy()
            for cookie in pub_list:
                payload = {'cookie': cookie}
                self.syslog('Sending cookie %s in heartbeat' % cookie)
                try:
                    r = requests.post(
                        self.hburl, data=json.dumps(payload), headers=self._headers)
                except requests.exceptions.ConnectionError:
                    service, data = pub_list[cookie]
                    ConnectionState.update(conn_type = ConnectionType.DISCOVERY,
                        name = service, status = ConnectionState.DOWN,
                        server_addrs = ['%s:%s' % (self._server_ip, \
                            self._server_port)],
                        message = 'HeartBeat - Connection Error') 
                    self.syslog('Connection Error')
                    continue

                # if DS lost track of our data, republish
                if r.status_code == 404:
                    # forget cached cookie and object; will re-learn
                    self.syslog('Server lost track of token %s' % (cookie))
                    service, data = self.pubdata[cookie]
                    del self.pubdata[cookie]
                    self._publish_int(service, data)
            gevent.sleep(HC_INTERVAL)
开发者ID:ifzing,项目名称:contrail-controller,代码行数:29,代码来源:client.py


示例11: _cassandra_init_conn_pools

    def _cassandra_init_conn_pools(self):
        for ks, cf_list in self._keyspaces.items():
            pool = pycassa.ConnectionPool(
                ks,
                self._server_list,
                max_overflow=-1,
                use_threadlocal=True,
                prefill=True,
                pool_size=20,
                pool_timeout=120,
                max_retries=-1,
                timeout=5,
            )

            rd_consistency = pycassa.cassandra.ttypes.ConsistencyLevel.QUORUM
            wr_consistency = pycassa.cassandra.ttypes.ConsistencyLevel.QUORUM

            for (cf, _) in cf_list:
                self._cf_dict[cf] = ColumnFamily(
                    pool, cf, read_consistency_level=rd_consistency, write_consistency_level=wr_consistency
                )

        ConnectionState.update(
            conn_type=ConnectionType.DATABASE,
            name="Cassandra",
            status=ConnectionStatus.UP,
            message="",
            server_addrs=self._server_list,
        )
        self._conn_state = ConnectionStatus.UP
        msg = "Cassandra connection ESTABLISHED"
        self._logger(msg, level=SandeshLevel.SYS_NOTICE)
开发者ID:dhoutz,项目名称:contrail-controller,代码行数:32,代码来源:vnc_cassandra.py


示例12: __init__

 def __init__(self, conf):
     self._conf = conf
     module = Module.CONTRAIL_TOPOLOGY
     self._moduleid = ModuleNames[module]
     node_type = Module2NodeType[module]
     self._node_type_name = NodeTypeNames[node_type]
     self._hostname = socket.gethostname()
     self.table = "ObjectCollectorInfo"
     self._instance_id = '0'
     sandesh_global.init_generator(self._moduleid, self._hostname,
                                   self._node_type_name, self._instance_id,
                                   self._conf.random_collectors,
                                   self._node_type_name,
                                   self._conf.http_port(),
                                   ['contrail_topology.sandesh'],
                                   config=self._conf.sandesh_config())
     sandesh_global.set_logging_params(
         enable_local_log=self._conf.log_local(),
         category=self._conf.log_category(),
         level=self._conf.log_level(),
         file=self._conf.log_file(),
         enable_syslog=self._conf.use_syslog(),
         syslog_facility=self._conf.syslog_facility())
     ConnectionState.init(sandesh_global, self._hostname, self._moduleid,
         self._instance_id,
         staticmethod(ConnectionState.get_process_state_cb),
         NodeStatusUVE, NodeStatus, self.table)
     self._logger = sandesh_global.logger()
开发者ID:cijohnson,项目名称:contrail-controller,代码行数:28,代码来源:topology_uve.py


示例13: connection_state_update

 def connection_state_update(self, status, message=None):
     ConnectionState.update(
         conn_type=ConnType.APISERVER, name='ApiServer',
         status=status,
         message=message or 'ApiServer Connection State updated',
         server_addrs=['%s:%s' % (self._args.api_server_ip,
                                  self._args.api_server_port)])
开发者ID:Juniper,项目名称:contrail-controller,代码行数:7,代码来源:device_manager.py


示例14: conn_state_notify

 def conn_state_notify(self, svc, msg='', up=True, servers=''):
     ctype = self.map_svc(svc)
     status = self.map_sts(up)
     if isinstance(servers, basestring):
         servers = [servers]
     ConnectionState.update(conn_type=ctype, name='SNMP', status=status,
             message=msg, server_addrs=servers)
开发者ID:cijohnson,项目名称:contrail-controller,代码行数:7,代码来源:snmpuve.py


示例15: update_redis_uve_list

    def update_redis_uve_list(self, redis_uve_list):
        newlist = set(redis_uve_list)
        chg = False
        # if some redis instances are gone, remove them from our map
        for test_elem in self._redis_uve_map.keys():
            if test_elem not in newlist:
                chg = True
                r_ip = test_elem[0]
                r_port = test_elem[1]
                del self._redis_uve_map[test_elem]
                ConnectionState.delete(ConnectionType.REDIS_UVE,\
                    r_ip+":"+str(r_port)) 
        
        # new redis instances need to be inserted into the map
        for test_elem in newlist:
            if test_elem not in self._redis_uve_map:
                chg = True
                r_ip = test_elem[0]
                r_port = test_elem[1]
                self._redis_uve_map[test_elem] = None
                ConnectionState.update(ConnectionType.REDIS_UVE,\
                    r_ip+":"+str(r_port), ConnectionStatus.INIT)
        if chg:
            self._logger.error("updated redis_uve_list %s" % str(self._redis_uve_map)) 

        # Exercise redis connections to update health
        if len(newlist):
            self.get_uve("ObjectCollectorInfo:__NONE__", False, None)
开发者ID:aklik,项目名称:contrail-controller,代码行数:28,代码来源:uveserver.py


示例16: __init__

    def __init__(self, rule_file, discovery_server,
                 discovery_port, collector_addr):
        self.module = Module.COMPUTE_NODE_MGR
        self.module_id = ModuleNames[self.module]

        node_type = Module2NodeType[self.module]
        node_type_name = NodeTypeNames[node_type]
        self.sandesh_global = sandesh_global
        EventManager.__init__(self, rule_file, discovery_server,
                              discovery_port, collector_addr, sandesh_global)
        self.node_type = "contrail-vrouter"
        self.table = "ObjectVRouter"
        _disc = self.get_discovery_client()
        sandesh_global.init_generator(
            self.module_id, socket.gethostname(),
            node_type_name, self.instance_id, self.collector_addr,
            self.module_id, 8102, ['vrouter.loadbalancer',
                'nodemgr.common.sandesh'], _disc)
        sandesh_global.set_logging_params(enable_local_log=True)
        self.supervisor_serverurl = "unix:///var/run/supervisord_vrouter.sock"
        self.add_current_process()
        ConnectionState.init(sandesh_global, socket.gethostname(), self.module_id,
            self.instance_id,
            staticmethod(ConnectionState.get_process_state_cb),
            NodeStatusUVE, NodeStatus, self.table)

        self.lb_stats = LoadbalancerStatsUVE()
        self.send_system_cpu_info()
        self.third_party_process_dict = {}
开发者ID:dsundarraj,项目名称:contrail-controller,代码行数:29,代码来源:vrouter_event_manager.py


示例17: sandesh_init

    def sandesh_init(self, http_server_port=None):
        """ Init sandesh """
        self._sandesh = Sandesh()
        self.redefine_sandesh_handles()
        if not http_server_port:
            http_server_port = self._args.http_server_port
        self._sandesh.init_generator(
            self._module_name, self._hostname, self._node_type_name,
            self._instance_id, self._args.random_collectors,
            '%s_context' % self.context, int(http_server_port),
            ['cfgm_common', '%s.sandesh' % self.module_pkg],
            logger_class=self._args.logger_class,
            logger_config_file=self._args.logging_conf,
            config=self._args.sandesh_config)

        self._sandesh.set_logging_params(
            enable_local_log=self._args.log_local,
            category=self._args.log_category,
            level=self._args.log_level,
            file=self._args.log_file,
            enable_syslog=self._args.use_syslog,
            syslog_facility=self._args.syslog_facility)

        # connection state init
        ConnectionState.init(
                self._sandesh, self._hostname, self._module_name,
                self._instance_id,
                staticmethod(ConnectionState.get_conn_state_cb),
                NodeStatusUVE, NodeStatus, self.table)
        VncGreenlet.register_sandesh_handler()
开发者ID:Juniper,项目名称:contrail-controller,代码行数:30,代码来源:vnc_logger.py


示例18: sandesh_init

    def sandesh_init(self):
        """ Init Sandesh """
        self._sandesh = Sandesh()

        # Initialize Sandesh generator.
        self._sandesh.init_generator(
            self.module['name'], self.module['hostname'],
            self.module['node_type_name'], self.module['instance_id'],
            self._args.collectors, 'mesos_manager_context',
            int(self._args.http_server_port),
            ['cfgm_common', 'mesos_manager.sandesh'],
            logger_class=self._args.logger_class,
            logger_config_file=self._args.logging_conf,
            config=self._args.sandesh_config)

        # Set Sandesh logging params.
        self._sandesh.set_logging_params(
            enable_local_log=self._args.log_local,
            category=self._args.log_category,
            level=self._args.log_level, file=self._args.log_file,
            enable_syslog=self._args.use_syslog,
            syslog_facility=self._args.syslog_facility)

        # Connect to collector.
        ConnectionState.init(self._sandesh, self.module['hostname'],
            self.module['name'], self.module['instance_id'],
            staticmethod(ConnectionState.get_process_state_cb),
            NodeStatusUVE, NodeStatus, self.module['table'])
开发者ID:cijohnson,项目名称:contrail-controller,代码行数:28,代码来源:logger.py


示例19: _sandesh_connection_info_update

 def _sandesh_connection_info_update(self, status, message):
     from pysandesh.connection_info import ConnectionState
     from pysandesh.gen_py.process_info.ttypes import ConnectionStatus, \
         ConnectionType
     ConnectionState.update(conn_type = ConnectionType.ZOOKEEPER,
             name = 'Zookeeper', status = getattr(ConnectionStatus, status),
             message = message,
             server_addrs = self._server_list.split(','))
开发者ID:Juniper,项目名称:contrail-dev-controller,代码行数:8,代码来源:zkclient.py


示例20: connection_state_update

 def connection_state_update(self, status, message=None):
     ConnectionState.update(
         conn_type=ConnectionType.APISERVER,
         name="ApiServer",
         status=status,
         message=message or "",
         server_addrs=["%s:%s" % (self._args.api_server_ip, self._args.api_server_port)],
     )
开发者ID:facetothefate,项目名称:contrail-controller,代码行数:8,代码来源:device_manager.py



注:本文中的pysandesh.connection_info.ConnectionState类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sandesh_base.Sandesh类代码示例发布时间:2022-05-27
下一篇:
Python pysam.Samfile类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap