<commit_before>/*
 * Copyright 2017 <NAME>
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.axway.ats.agent.webapp.restservice;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.log4j.Logger;

import com.axway.ats.agent.core.monitoring.AgentSystemMonitor;
import com.axway.ats.agent.core.monitoring.UserActionsMonitoringAgent;
import com.axway.ats.common.performance.monitor.beans.ReadingBean;
import com.axway.ats.core.monitoring.MonitorConfigurationException;
import com.axway.ats.core.monitoring.MonitoringException;
import com.axway.ats.core.monitoring.SystemMonitorDefinitions;
import com.axway.ats.core.threads.ThreadsPerCaller;
import com.axway.ats.core.utils.HostUtils;
import com.axway.ats.core.utils.StringUtils;
import com.axway.ats.core.validation.Validate;
import com.axway.ats.core.validation.ValidationType;
import com.axway.ats.core.validation.Validator;

public class RestSystemMonitor {

    public static final String  ATS_JVM_MONITOR_CLASS_FULL_NAME = "com.axway.ats.agent.core.monitoring.jvmmonitor.AtsJvmMonitor";

    private static final Logger log                             = Logger.getLogger( RestSystemMonitor.class );

    private boolean             isStarted                       = false;

    // whether we have to log user activity data
    private boolean             logUserActivity                 = false;

    // whether we have to log system statistics data
    private boolean             logSystemStatistics             = false;

    private Set<ReadingBean>    readingTypes;

    private AgentSystemMonitor  systemMonitor;

    public RestSystemMonitor() {
        readingTypes = new HashSet<>();
        systemMonitor = new AgentSystemMonitor();
    }

    public void initializeMonitoringContext(
                                             @Validate(name = "monitoredHost", type = ValidationType.STRING_SERVER_WITH_PORT) String monitoredHost ) {

        // validate input parameters
        monitoredHost = HostUtils.getAtsAgentIpAndPort( monitoredHost );
        new Validator().validateMethodParameters( "Could not schedule monitoring system statistics on '"
                                                  + monitoredHost + "'", new Object[]{ monitoredHost } );
        try {
            log.debug( "Initializing monitoring context..." );
            systemMonitor.initializeMonitoringContext();
            log.info( "Monotoring context initialized." );
        } catch( Exception e ) {
            log.error( "Could not initialize monitoring context.", e );
            throw new MonitorConfigurationException( "Could not initialize monitoring context", e );<commit_msg>Fix typo<commit_after>/*
 * Copyright 2017 Ax<NAME>
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.axway.ats.agent.webapp.restservice;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.log4j.Logger;

import com.axway.ats.agent.core.monitoring.AgentSystemMonitor;
import com.axway.ats.agent.core.monitoring.UserActionsMonitoringAgent;
import com.axway.ats.common.performance.monitor.beans.ReadingBean;
import com.axway.ats.core.monitoring.MonitorConfigurationException;
import com.axway.ats.core.monitoring.MonitoringException;
import com.axway.ats.core.monitoring.SystemMonitorDefinitions;
import com.axway.ats.core.threads.ThreadsPerCaller;
import com.axway.ats.core.utils.HostUtils;
import com.axway.ats.core.utils.StringUtils;
import com.axway.ats.core.validation.Validate;
import com.axway.ats.core.validation.ValidationType;
import com.axway.ats.core.validation.Validator;

public class RestSystemMonitor {

    public static final String  ATS_JVM_MONITOR_CLASS_FULL_NAME = "com.axway.ats.agent.core.monitoring.jvmmonitor.AtsJvmMonitor";

    private static final Logger log                             = Logger.getLogger( RestSystemMonitor.class );

    private boolean             isStarted                       = false;

    // whether we have to log user activity data
    private boolean             logUserActivity                 = false;

    // whether we have to log system statistics data
    private boolean             logSystemStatistics             = false;

    private Set<ReadingBean>    readingTypes;

    private AgentSystemMonitor  systemMonitor;

    public RestSystemMonitor() {
        readingTypes = new HashSet<>();
        systemMonitor = new AgentSystemMonitor();
    }

    public void initializeMonitoringContext(
                                             @Validate(name = "monitoredHost", type = ValidationType.STRING_SERVER_WITH_PORT) String monitoredHost ) {

        // validate input parameters
        monitoredHost = HostUtils.getAtsAgentIpAndPort( monitoredHost );
        new Validator().validateMethodParameters( "Could not schedule monitoring system statistics on '"
                                                  + monitoredHost + "'", new Object[]{ monitoredHost } );
        try {
            log.debug( "Initializing monitoring context..." );
            systemMonitor.initializeMonitoringContext();
            log.info( "Monitoring context initialized." );
        } catch( Exception e ) {
            log.error( "Could not initialize monitoring context.", e );
            throw new MonitorConfigurationException( "Could not initialize monitoring context", e );
{'fraction_non_alphanumeric': 0.08392239434501429, 'fraction_numerical': 0.0027071740111294933, 'mean_word_length': 3.0205562273276905, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '684971', 'n_tokens_mistral': 1721, 'n_tokens_neox': 1658, 'n_words': 483}