<commit_before>/*
*  Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
*  WSO2 Inc. licenses this file to you 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 org.wso2.carbon.analytics.spark.core;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.analytics.spark.core.exception.AnalyticsExecutionException;
import org.wso2.carbon.analytics.spark.core.exception.AnalyticsPersistenceException;
import org.wso2.carbon.analytics.spark.core.internal.ServiceHolder;
import org.wso2.carbon.analytics.spark.core.util.AnalyticsConstants;
import org.wso2.carbon.ntask.core.Task;

import java.util.Map;

/**
 * This is the task implementation to execute the tasks registered
 * to trigger the spark script execution.
 */

public class AnalyticsTask implements Task {
    private static final Log log = LogFactory.getLog(AnalyticsTask.class);

    private int tenantId;
    private String scriptName;

    @Override
    public void setProperties(Map<String, String> properties) {
        this.tenantId = Integer.parseInt(properties.get(AnalyticsConstants.TASK_TENANT_ID_PROPERTY));
        this.scriptName = properties.get(AnalyticsConstants.TASK_SCRIPT_NAME_PROPERTY);
    }

    @Override
    public void init() {

    }

    @Override
    public void execute() {
        if (ServiceHolder.isAnalyticsExecutionEnabled()) {
            try {
                log.info("Executing the schedule task for :" + scriptName + " for tenant id :" + tenantId);
                if (ServiceHolder.getAnalyticsProcessorService() != null) {
                    ServiceHolder.getAnalyticsProcessorService().executeScript(tenantId, this.scriptName);
                } else {
                    log.warn("Analytics Processor inactive now, and hence ignoring the triggered execution");
                }
            } catch (AnalyticsExecutionException | AnalyticsPersistenceException e) {
                log.error("Error while executing the scheduled task for the script : " + scriptName, e);
            }
        }else {
            log.warn("Analytics is disabled in this node, therefore ignoring the triggered execution.");
        }
    }
}<commit_msg>Cleanup in log messages<commit_after>/*
*  Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
*  WSO2 Inc. licenses this file to you 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 org.wso2.carbon.analytics.spark.core;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.analytics.spark.core.exception.AnalyticsExecutionException;
import org.wso2.carbon.analytics.spark.core.exception.AnalyticsPersistenceException;
import org.wso2.carbon.analytics.spark.core.internal.ServiceHolder;
import org.wso2.carbon.analytics.spark.core.util.AnalyticsConstants;
import org.wso2.carbon.ntask.core.Task;

import java.util.Map;

/**
 * This is the task implementation to execute the tasks registered
 * to trigger the spark script execution.
 */
public class AnalyticsTask implements Task {

    private static final Log log = LogFactory.getLog(AnalyticsTask.class);

    private int tenantId;
    private String scriptName;

    @Override
    public void setProperties(Map<String, String> properties) {
        this.tenantId = Integer.parseInt(properties.get(AnalyticsConstants.TASK_TENANT_ID_PROPERTY));
        this.scriptName = properties.get(AnalyticsConstants.TASK_SCRIPT_NAME_PROPERTY);
    }

    @Override
    public void init() {
    }

    @Override
    public void execute() {
        if (ServiceHolder.isAnalyticsExecutionEnabled()) {
            try {
                log.info("Executing the schedule task for: " + scriptName + " for tenant id: " + tenantId);
                if (ServiceHolder.getAnalyticsProcessorService() != null) {
                    ServiceHolder.getAnalyticsProcessorService().executeScript(tenantId, this.scriptName);
                } else {
                    log.warn("Analytics Processor inactive now, and hence ignoring the triggered execution");
                }
            } catch (AnalyticsExecutionException | AnalyticsPersistenceException e) {
                log.error("Error while executing the scheduled task for the script: " + scriptName, e);
            }
        } else {
            log.warn("Analytics is disabled in this node, therefore ignoring the triggered execution.");
        }
    }

}
{'fraction_non_alphanumeric': 0.08893789048144064, 'fraction_numerical': 0.006247703050349137, 'mean_word_length': 3.2457098283931356, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5569507', 'n_tokens_mistral': 1497, 'n_tokens_neox': 1439, 'n_words': 441}