Add one protocol instance for monitoring.
15390
def addInstance(self, inst_id):
        
        self.instances.add(inst_id)
        self.requestTracker.add_instance(inst_id)
        self.numOrderedRequests[inst_id] = (0, 0)
        rm = self.create_throughput_measurement(self.config)

        self.throughputs[inst_id] = rm
        lm = self.latency_measurement_cls(self.config)
        self.clientAvgReqLatencies[inst_id] = lm
        if self.acc_monitor:
            self.acc_monitor.add_instance(inst_id)
789038
def _add_monitor(monitors, handle, callback, devices, events):
    """"""

    for conn_string in devices:
        data = monitors.get(conn_string)
        if data is None:
            data = dict()
            monitors[conn_string] = data

        for event in events:
            event_dict = data.get(event)
            if event_dict is None:
                event_dict = dict()
                data[event] = event_dict

            event_dict[handle] = callback
1274996
def make_client(api_version, session=None,
                endpoint=None, service_type='monitoring'):
    """"""

    client_cls = utils.get_client_class('monitoring', api_version, VERSION_MAP)
    c = client_cls(
        session=session,
        service_type=service_type,
        endpoint=endpoint,
        app_name='monascaclient',
        app_version=version.version_string,
    )

    return c
601083
def addServer(self, normalPort, sslPort, f, name):
        
        tcp = internet.TCPServer(normalPort, f)
        tcp.setName(name)
        self.servers.append(tcp)
        if sslPort is not None:
            ssl = internet.SSLServer(sslPort, f, contextFactory=self.sslfac)
            ssl.setName(name+'s')
            self.servers.append(ssl)
28691
def _ensure_create_ha_compliant(self, router, router_type):
        """"""
        details = router.pop(ha.DETAILS, {})
        if details == ATTR_NOT_SPECIFIED:
            details = {}
        res = {ha.ENABLED: router.pop(ha.ENABLED, ATTR_NOT_SPECIFIED),
               ha.DETAILS: details}

        if not is_attr_set(res[ha.ENABLED]):
            res[ha.ENABLED] = router_type['ha_enabled_by_default']
        if res[ha.ENABLED] and not cfg.CONF.ha.ha_support_enabled:
            raise ha.HADisabled()
        if not res[ha.ENABLED]:
            return res
        if not is_attr_set(details.get(ha.TYPE, ATTR_NOT_SPECIFIED)):
            details[ha.TYPE] = cfg.CONF.ha.default_ha_mechanism
        if details[ha.TYPE] in cfg.CONF.ha.disabled_ha_mechanisms:
            raise ha.HADisabledHAType(ha_type=details[ha.TYPE])
        if not is_attr_set(details.get(ha.REDUNDANCY_LEVEL,
                                       ATTR_NOT_SPECIFIED)):
            details[ha.REDUNDANCY_LEVEL] = (
                cfg.CONF.ha.default_ha_redundancy_level)
        if not is_attr_set(details.get(ha.PROBE_CONNECTIVITY,
                                       ATTR_NOT_SPECIFIED)):
            details[ha.PROBE_CONNECTIVITY] = (
                cfg.CONF.ha.connectivity_probing_enabled_by_default)
        if not is_attr_set(details.get(ha.PROBE_TARGET, ATTR_NOT_SPECIFIED)):
            details[ha.PROBE_TARGET] = cfg.CONF.ha.default_probe_target
        if not is_attr_set(details.get(ha.PROBE_INTERVAL, ATTR_NOT_SPECIFIED)):
            details[ha.PROBE_INTERVAL] = cfg.CONF.ha.default_ping_interval
        return res
1335878
def start (self):
        """"""
        values = self._defn.name, self.server_host, self.server_port
        log.info('Listening for %s telemetry on %s:%d (UDP)' % values)
        super(UdpTelemetryServer, self).start()
167362
def add(self, handler):
        ''' 

        '''
        self._handlers.append(handler)

        # make sure there is at most one static path
        static_paths = set(h.static_path() for h in self.handlers)
        static_paths.discard(None)
        if len(static_paths) > 1:
            raise RuntimeError("More than one static path requested for app: %r" % list(static_paths))
        elif len(static_paths) == 1:
            self._static_path = static_paths.pop()
        else:
            self._static_path = None
1366028
def add_service(self, service):
        
        if service.protocol in self._services:
            existing = self._services[service.protocol]
            if not existing.superseeded_by(service):
                return

        self._services[service.protocol] = service
999568
def router_added_to_hosting_device(self, context, router):
        """"""
        self._notification(context, 'router_added_to_hosting_device',
                           [router], operation=None, shuffle_agents=False)
15141
def add_middleware(middleware: EFBMiddleware):
    
    global middlewares
    if isinstance(middleware, EFBMiddleware):
        middlewares.append(middleware)
    else:
        raise TypeError("Middleware instance is expected")
1277223
def start(self):
        """"""
        # TODO (NM 2015-03-12) Some checking to prevent multiple calls to start()
        host, port = self.address
        ic = self._inspecting_client = self.inspecting_client_factory(
            host, port, self._ioloop_set_to)
        self.ioloop = ic.ioloop
        if self._preset_protocol_flags:
            ic.preset_protocol_flags(self._preset_protocol_flags)
        ic.katcp_client.auto_reconnect_delay = self.auto_reconnect_delay
        ic.set_state_callback(self._inspecting_client_state_callback)
        ic.request_factory = self._request_factory
        self._sensor_manager = KATCPClientResourceSensorsManager(
            ic, self.name, logger=self._logger)
        ic.handle_sensor_value()
        ic.sensor_factory = self._sensor_manager.sensor_factory

        # Steal some methods from _sensor_manager
        self.reapply_sampling_strategies = self._sensor_manager.reapply_sampling_strategies
        log_future_exceptions(self._logger, ic.connect())
179628
function(type, handler, one) {
			var sig = this.spirit.$contextid;
			if (one) {
				if (this._global) {
					gui.Tick.oneGlobal(type, handler);
				} else {
					gui.Tick.one(type, handler, sig);
				}
			} else {
				if (this._global) {
					gui.Tick.addGlobal(type, handler);
				} else {
					gui.Tick.add(type, handler, sig);
				}
			}
		}
187470
def monitor(name, callback):
    '''
     
    '''
    global _monitor 
    if not exists(name):
        raise ContainerNotExists("The container (%s) does not exist!" % name)
    if _monitor:
        if _monitor.is_monitored(name):
            raise Exception("You are already monitoring this container (%s)" % name)
    else:
        _monitor = _LXCMonitor()
        logging.info("Starting LXC Monitor")
        _monitor.start()
        def kill_handler(sg, fr):
            stop_monitor()
        signal.signal(signal.SIGTERM, kill_handler)
        signal.signal(signal.SIGINT, kill_handler)
    _monitor.add_monitor(name, callback)
716943
def addObserver(self, observer):
        
        with self._lock:
            self._weak_observers.append(weakref.ref(observer))
            if len(self._weak_observers) == 1:
                self.startThread()
507210
def add_detector(self, detector_cls):
        """"""
        if not issubclass(detector_cls, detectors.base.Detector):
            raise TypeError((
                '"%(detector_cls)s" is not a subclass of Detector'
            ) % locals())
        # TODO: should add tests to make sure filth_cls is actually a proper
        # filth_cls
        name = detector_cls.filth_cls.type
        if name in self._detectors:
            raise KeyError((
                'can not add Detector "%(name)s"---it already exists. '
                'Try removing it first.'
            ) % locals())
        self._detectors[name] = detector_cls()
1246853
def child_watch_add(*args, **kwargs):
    """"""
    priority, pid, function, data = _child_watch_add_get_args(*args, **kwargs)
    return GLib.
832891
public void updateServiceInstance(ProvidedServiceInstance instance, final RegistrationCallback cb, Object context){
        ProtocolHeader header = new ProtocolHeader();
        header.setType(ProtocolType.UpdateServiceInstance);

        UpdateServiceInstanceProtocol p = new UpdateServiceInstanceProtocol(instance);
        ProtocolCallback pcb = new ProtocolCallback(){

            @Override
            public void call(boolean result, Response response,
                    ErrorCode error, Object ctx) {
                cb.call(result, error, ctx);
            }

        };
        connection.submitCallbackRequest(header, p, pcb, context);
    }