Update the counters for a given user agent

@param agent
User-Agent
492450
protected void genCounter(final String agent) {
        idsCounter.inc();
        if (!agentCounters.containsKey(agent)) {
            agentCounters.put(agent, registry.counter(MetricRegistry.name(
                    IdWorker.class, "ids_generated_" + agent)));
        }
        agentCounters.get(agent).inc();
    }
923030
protected Object checkUserAgent(ServerUserHandlerClass handler, ApiUser userAgent) {
        if(handler.getUserClass().isAssignableFrom(userAgent.getClass()))
            return userAgent;
        return UserAgentUtil.getGameUser(userAgent, handler.getUserClass());
    }
529628
public function setGlobalExcludedUserAgents($excludedUserAgents)
    {
        Piwik::checkUserHasSuperUserAccess();

        // update option
        $excludedUserAgents = $this->checkAndReturnCommaSeparatedStringList($excludedUserAgents);
        Option::set(self::OPTION_EXCLUDED_USER_AGENTS_GLOBAL, $excludedUserAgents);

        // make sure tracker cache will reflect change
        Cache::deleteTrackerCache();
    }
1281106
private void setUserAgentsRegEx(List<String> agents) {

        if ((agents == null) || (agents.size() == 0)) {
            setValidConfiguration(false);
            LOG.error(Messages.get().getBundle().key(Messages.LOG_NO_USER_AGENTS_0));
        }
        m_userAgentsRegEx = agents;
    }
686745
public void setUserAgent(String userAgent) {
        this.userAgent = userAgent.toLowerCase();

        // Re-order the set
        Set<UserAgentDirectives> replace = new TreeSet<UserAgentDirectives>(
            new UserAgentDirectives.UserAgentComparator(this.userAgent));
        replace.addAll(rules);
        rules = replace;
    }
735967
void reloadUserData() {

		if( Utils.isEmptyOrWhitespaces( this.parameters )) {
			this.logger.warning( "No parameters were specified in the agent configuration. No user data will be retrieved." );

		} else if( ! this.overrideProperties ) {
			this.logger.fine( "User data are NOT supposed to be used." );

		} else if( Constants.AGENT_RESET.equalsIgnoreCase( this.parameters )) {
			if( getMessagingClient() != null
					&& getMessagingClient().getMessageProcessor() != null )
				((AgentMessageProcessor) getMessagingClient().getMessageProcessor()).resetRequest();

		} else {

			// Retrieve the agent's configuration
			AgentProperties props = null;
			this.logger.fine( "User data are supposed to be used. Retrieving in progress..." );
			if( AgentConstants.PLATFORM_EC2.equalsIgnoreCase( this.parameters )
					|| AgentConstants.PLATFORM_OPENSTACK.equalsIgnoreCase( this.parameters ))
				props = this.userDataHelper.findParametersForAmazonOrOpenStack( this.logger );

			else if( AgentConstants.PLATFORM_AZURE.equalsIgnoreCase( this.parameters ))
				props = this.userDataHelper.findParametersForAzure( this.logger );

			else if( AgentConstants.PLATFORM_VMWARE.equalsIgnoreCase( this.parameters ))
				props = this.userDataHelper.findParametersForVmware( this.logger );

			else if( Constants.AGENT_RESET.equalsIgnoreCase( this.parameters ))
				props = new AgentProperties();

			else
				props = this.userDataHelper.findParametersFromUrl( this.parameters, this.logger );

			// If there was a configuration...
			if( props != null ) {

				// Error messages do not matter when we reset an agent
				String errorMessage = null;
				if( ! Constants.AGENT_RESET.equalsIgnoreCase( this.parameters )
						&& (errorMessage = props.validate()) != null ) {
					this.logger.severe( "An error was found in user data. " + errorMessage );
				}

				this.applicationName = props.getApplicationName();
				this.domain = props.getDomain();
				this.scopedInstancePath = props.getScopedInstancePath();
				if( ! Utils.isEmptyOrWhitespaces( props.getIpAddress())) {
					this.ipAddress = props.getIpAddress();
					this.logger.info( "The agent's address was overwritten from user data and set to " + this.ipAddress );
				}

				try {
					this.logger.info( "Reconfiguring the agent with user data." );
					this.userDataHelper.reconfigureMessaging(
						this.karafEtc,
						props.getMessagingConfiguration());

				} catch( Exception e ) {
					this.logger.severe("Error in messaging reconfiguration from user data: " + e);
				}
			}
		}
	}
411330
private void updateStatistics() {
        final PNCounterService service = getService();
        final LocalPNCounterStatsImpl stats = service.getLocalPNCounterStats(name);
        if (delta > 0) {
            stats.incrementIncrementOperationCount();
        } else if (delta < 0) {
            stats.incrementDecrementOperationCount();
        }
        stats.setValue(getBeforeUpdate ? (response.getValue() + delta) : response.getValue());
    }
571957
public function setUserAgent($userAgent)
    {
        $this->userAgent = $userAgent;
        $uaParser = new \vipnytt\UserAgentParser($this->userAgent);
        $this->userAgentMatch = $uaParser->getMostSpecific(array_keys($this->rules));
        if (!$this->userAgentMatch) {
            $this->userAgentMatch = '*';
        }
    }
323724
function counter(state = 0, action = {}) {
  switch (action.type) {
    case INCREMENT_COUNTER:
      return state + 1;
    case DECREMENT_COUNTER:
      return state - 1;
    default:
      return state;
  }
}
505587
private void updateCount() {
		if (scanStatus == null) {
			return;
		}

		long now = System.currentTimeMillis();
		if (now - this.lastUpdated > 200) {
			// Dont update too frequently, eg using the spider could hammer the UI unnecessarily
			this.lastUpdated = now;
			SwingUtilities.invokeLater(new Runnable(){
				@Override
				public void run() {
					scanStatus.setScanCount(nodeStack.size());
				}});
		}
	}
594483
function setUserAgent($userAgent)
    {
        if ($userAgent) {
            $this->userAgent = $userAgent;
        } else {
            $this->userAgent = $this->getDefaultUserAgent();
        }
    }
928613
def agent(agent_id):
    '''
    
    '''
    fields = [
        ('ID', 'id'),
        ('Status', 'status'),
        ('Region', 'region'),
        ('First Contact', 'first_contact'),
        ('CPU Usage (%)', 'cpu_cur_pct'),
        ('Used Memory (MiB)', 'mem_cur_bytes'),
        ('Total slots', 'available_slots'),
        ('Occupied slots', 'occupied_slots'),
    ]
    if is_legacy_server():
        del fields[9]
        del fields[6]
    q = 'query($agent_id:String!) {' \
        '  agent(agent_id:$agent_id) { $fields }' \
        '}'
    q = q.replace('$fields', ' '.join(item[1] for item in fields))
    v = {'agent_id': agent_id}
    with Session() as session:
        try:
            resp = session.Admin.query(q, v)
        except Exception as e:
            print_error(e)
            sys.exit(1)
        info = resp['agent']
        rows = []
        for name, key in fields:
            if key == 'mem_cur_bytes' and info[key] is not None:
                info[key] = round(info[key] / 2 ** 20, 1)
            if key in info:
                rows.append((name, info[key]))
        print(tabulate(rows, headers=('Field', 'Value')))
1095673
public void startAgent (AgentObject agent)
    {
        agent.setLocal(AgentData.class, new AgentData());

        Bureau bureau = _bureaus.get(agent.bureauId);
        if (bureau != null && bureau.ready()) {
            _omgr.registerObject(agent);

            log.info("Bureau ready, sending createAgent", "agent", agent.which());
            BureauSender.createAgent(bureau.clientObj, agent.getOid());
            bureau.agentStates.put(agent, AgentState.STARTED);
            bureau.summarize();
            return;
        }

        if (bureau == null) {
            LauncherEntry launcherEntry = _launchers.get(agent.bureauType);
            if (launcherEntry == null) {
                log.warning("Launcher not found", "agent", agent.which());
                return;
            }

            log.info("Creating new bureau", "bureauId", agent.bureauId, "launcher", launcherEntry);
            bureau = new Bureau();
            bureau.bureauId = agent.bureauId;
            bureau.token = generateToken(bureau.bureauId);
            bureau.launcherEntry = launcherEntry;
            _invoker.postUnit(new LauncherUnit(bureau, _omgr));
            _bureaus.put(agent.bureauId, bureau);
        }

        _omgr.registerObject(agent);
        bureau.agentStates.put(agent, AgentState.PENDING);

        log.info("Bureau not ready, pending agent", "agent", agent.which());
        bureau.summarize();
    }
386120
public function user_agent($user_agent = NULL)
	{
		if ($user_agent !== NULL)
		{
			\Request::$user_agent = $user_agent;
			return $this;
		}
		return \Request::$user_agent;
	}
1077239
public function setCounteragentStatus(\AgentSIB\Diadoc\Api\Proto\CounteragentStatus $value = null)
    {
        $this->CounteragentStatus = $value;
    }
450486
def applies_to (self, useragent):
        
        if not useragent:
            return True
        useragent = useragent.lower()
        for agent in self.useragents:
            if agent == '*':
                # we have the catch-all agent
                return True
            if agent.lower() in useragent:
                return True
        return False
816074
def update_agent(self, agent_id, **kwargs):
        """"""
        url = 'agents/%s' % agent_id
        agent = self._api._put(url, data=json.dumps(kwargs))
        return Agent(**agent)