Setup the RPC client for the current agent.
17756
def _setup_rpc(self):
        """"""
        self._state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS)
        report_interval = CONF.AGENT.report_interval
        if report_interval:
            heartbeat = loopingcall.FixedIntervalLoopingCall(
                self._report_state)
            heartbeat.start(interval=report_interval)
1179801
def _setup_sentry_client(context):
    """"""

    # get_secret will be deprecated soon
    dsn = os.environ.get("SENTRY_DSN")
    try:
        client = raven.Client(dsn, sample_rate=SENTRY_SAMPLE_RATE)
        client.user_context(_sentry_context_dict(context))
        return client
    except:
        rlogger.error("Raven client error", exc_info=True)
        return None
129543
def current_client(self, quiet, bootstrap_server, create_client):
        """"""
        current_file = self._vim.current.buffer.name
        config_path = ProjectConfig.find_from(current_file)
        if config_path:
            return self.client_for(
                config_path,
                quiet=quiet,
                bootstrap_server=bootstrap_server,
                create_client=create_client)
653580
def setup(addr, user, remote_path, local_key=None):
    """"""
    port = find_port(addr, user)

    if not port or not is_alive(addr, user):
        port = new_port()

        scp(addr, user, __file__, '~/unixpipe', local_key)

        ssh_call = ['ssh', '-fL%d:127.0.0.1:12042' % port,
                    '-o', 'ExitOnForwardFailure=yes',
                    '-o', 'ControlPath=~/.ssh/unixpipe_%%r@%%h_%d' % port,
                    '-o', 'ControlMaster=auto',
                    '%s@%s' % (user, addr,), 'python', '~/unixpipe',
                    'server', remote_path]
        if local_key:
            ssh_call.insert(1, local_key)
            ssh_call.insert(1, '-i')

        subprocess.call(ssh_call)
        # XXX Sleep is a bad way to wait for the tunnel endpoint
        time.sleep(1)

    return port
953016
def reset(self):
        ""
        log.info("resetting client")
        rpc_client = self._rpc_client
        self._addrs.append(self._peer.addr)
        self.__init__(self._addrs)
        self._rpc_client = rpc_client
        self._dispatcher.rpc_client = rpc_client
        rpc_client._client = weakref.ref(self)
789526
async def SetTools(self, agent_tools):
        '''
        
        '''
        # map input types to rpc msg
        _params = dict()
        msg = dict(type='Upgrader',
                   request='SetTools',
                   version=1,
                   params=_params)
        _params['agent-tools'] = agent_tools
        reply = await self.rpc(msg)
        return reply
630430
def hosting_devices_assigned_to_cfg_agent(self, context, payload):
        """"""
        LOG.debug("Got hosting device assigned, payload: %s" % payload)
        try:
            if payload['hosting_device_ids']:
                #TODO(hareeshp): implement assignment of hosting devices
                self.routing_service_helper.fullsync = True
        except KeyError as e:
            LOG.error("Invalid payload format for received RPC message "
                      "`hosting_devices_assigned_to_cfg_agent`. Error is "
                      "%(error)s. Payload is %(payload)s",
                      {'error': e, 'payload': payload})
421871
def _start_event_client(self):
        """"""
        event_client = SnippetClient(package=self.package, ad=self._ad)
        event_client.host_port = self.host_port
        event_client.device_port = self.device_port
        event_client.connect(self.uid,
                             jsonrpc_client_base.JsonRpcCommand.CONTINUE)
        return event_client
968373
function subscribe() {
    console.log(' > ', 'init', ['xmlrpc_bin://' + thisHost + ':2031', 'test123']);
    rpcClient.methodCall('init', ['xmlrpc_bin://' + thisHost + ':2031', 'test123'], function (err, res) {
        console.log(err, res);
    });
}
178952
def _setup_ipc(self):
        '''
        
        '''
        self.ctx = zmq.Context()
        log.debug('Setting up the %s publisher subscriber #%d', self._transport_type, self.pub_id)
        self.sub = self.ctx.socket(zmq.SUB)
        self.sub.connect(PUB_IPC_URL)
        self.sub.setsockopt(zmq.SUBSCRIBE, b'')
        try:
            self.sub.setsockopt(zmq.HWM, self.opts['hwm'])
            # zmq 2
        except AttributeError:
            # zmq 3
            self.sub.setsockopt(zmq.RCVHWM, self.opts['hwm'])
221669
def start(self):
        """"""
        # observers for this channel only need to wait for one value
        self._observer_params.update(dict(once=True))
        super(CurrentResourceValue, self).start()
        self._api.ensure_notifications_thread()
        self._api._mds_rpc_post(
            device_id=self.device_id,
            method='GET',
            uri=self.resource_path,
            async_id=self.async_id,
            _wrap_with_consumer=False,
        )
701145
def set_agent(self, agent):
        
        self.agent = agent
        self.queue = asyncio.Queue(loop=self.agent.loop)
        self.presence = agent.presence
        self.web = agent.web
1312528
function Agent(options) {
  if (!(this instanceof Agent)) return new Agent(options);

  EventEmitter.call(this);

  this.defaultPort = 80;
  this.protocol    = 'http:';

  this.options = util._extend({}, options);
  // don't confuse net and make it think that we're connecting to a pipe
  this.options.path = null;

  this.requests    = {};
  this.sockets     = {};
  this.freeSockets = {};

  this.keepAliveMsecs = this.options.keepAliveMsecs || 1000;
  this.keepAlive      = this.options.keepAlive || false;

  this.maxSockets     = this.options.maxSockets || Agent.defaultMaxSockets;
  this.maxFreeSockets = this.options.maxFreeSockets || 256;

  var self = this;
  this.on('free', function(socket, options) {
    var name = self.getName(options);
    debug('agent.on(free)', name);

    if (!self.isSocketDestroyed(socket) && self.requests[name] && self.requests[name].length) {
      self.requests[name].shift().onSocket(socket);
      if (self.requests[name].length === 0) {
        // don't leak
        delete self.requests[name];
      }
    }
    else {
      // If there are no pending requests, then put it in
      // the freeSockets pool, but only if we're allowed to do so.
      var req = socket._httpMessage;
      if (req && req.shouldKeepAlive && !self.isSocketDestroyed(socket) && self.options.keepAlive) {
        var freeSockets = self.freeSockets[name];
        var freeLen     = freeSockets ? freeSockets.length : 0;
        var count       = freeLen;

        if (self.sockets[name]) count += self.sockets[name].length;

        debug('potentially pooling', freeLen, count);

        if (count > self.maxSockets || freeLen >= self.maxFreeSockets) {
          debug('destroying socket', name);
          self.removeSocket(socket, options);
          socket.destroy();
        } else {
          debug('pooling socket', name);
          freeSockets = freeSockets || [];
          self.freeSockets[name] = freeSockets;
          socket.setKeepAlive(true, self.keepAliveMsecs);

          if (socket.unref) {
            socket.unref();
          }
          else if (socket.socket &&
                   socket.socket._handle &&
                   socket.socket._handle.unref) {
            socket.socket._handle.unref();
          }

          socket._httpMessage = null;
          self.removeSocket(socket, options);
          freeSockets.push(socket);

          // set timeout on idle sockets
          if (options.keepAliveTimeoutMsecs !== undefined) {
            socket._yakaa_timeout = setTimeout(function () {
              self.emit('yakaa_destroy');
              socket.destroySoon();
            }, options.keepAliveTimeoutMsecs);
          }

        }
      } else {
        self.removeSocket(socket, options);
        socket.destroy();
      }
    }
  });
}
219581
public void setup() {
		this.myIntrospector = JadeAgentIntrospector.getMyInstance((Agent) this);
		LogActivator.logToFile(logger, this.getName(), Level.ALL);
		// Register the service
		try {
			DFAgentDescription dfd = new DFAgentDescription();
			ServiceDescription sd = new ServiceDescription();
	        
	        sd.setType("server");
	        sd.setName("report-service");
	        // Sets the agent description
	        dfd.setName(this.getAID());
	        dfd.addServices(sd);
	        
	        // Register the agent
	        DFService.register(this, dfd);
			
		} catch (Exception e) {
			logger.severe("Exception registering agent in DF. Agent: " + this.getName());
		}

		MessageTemplate t = MessageTemplate.MatchPerformative(ACLMessage.INFORM);
		addBehaviour(new ReportServer(this,t));
	}
1101242
def agent(state, host, server=None, port=None):
    

    args = []

    if server:
        args.append('--server=%s' % server)
    if port:
        args.append('--masterport=%s' % port)

    yield 'puppet agent -t %s' % ' '.join(args)
1005544
def buildProtocol(self, addr):
        
        self.resetDelay()
        self.client = self.protocol(self._parameters)
        self.client.factory = self
        self.client.ready.addCallback(lambda _: self._on_client_ready())
        return self.client
1218276
function Agent(options) {
  EventEmitter.call(this);
  this.setMaxListeners(0);

  options = assign({}, options);

  this._settings = options.settings;
  this._log = (options.log || defaultLogger).child({ component: 'http' });
  this.endpoints = {};

  // * Using an own HTTPS agent, because the global agent does not look at `NPN/ALPNProtocols` when
  //   generating the key identifying the connection, so we may get useless non-negotiated TLS
  //   channels even if we ask for a negotiated one. This agent will contain only negotiated
  //   channels.
  options.ALPNProtocols = supportedProtocols;
  options.NPNProtocols = supportedProtocols;
  this._httpsAgent = new https.Agent(options);

  this.sockets = this._httpsAgent.sockets;
  this.requests = this._httpsAgent.requests;
}