<commit_before>/*
 * Copyright 2012 <NAME>, <NAME>, <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 de.joerghoh.cq5.healthcheck.impl;

import java.io.IOException;

import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
import org.apache.sling.commons.osgi.PropertiesUtil;
import org.apache.sling.jcr.api.SlingRepository;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.day.cq.jcrclustersupport.ClusterAware;

import de.joerghoh.cq5.healthcheck.StatusService;
import de.joerghoh.cq5.healthcheck.StatusCode;

/**
 * A servlet, which returns the actual status suitable for a loadbalancer.
 * 
 * Internally the HealthStatusService and the current clustering status is used
 * to determine the return code.
 * 
 * This code allows to specify a cluster strategy: * ActiveActive: All cluster
 * nodes are eligable to return "OK" * ActivePassive: Only the master is
 * eligable to return "OK", slaves always return "NoOK".
 * 
 * In any case also the OverallStatus of the HealthStatusService is used to
 * identify the status. If the status is != OK, then "notOK" is returned and the
 * return code of this request is set to 500 (internal server error).<commit_msg>updated comments for Loadbalancer servlet<commit_after>/*
 * Copyright 2012 <NAME>, <NAME>, <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 de.joerghoh.cq5.healthcheck.impl;

import java.io.IOException;

import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
import org.apache.sling.commons.osgi.PropertiesUtil;
import org.apache.sling.jcr.api.SlingRepository;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.day.cq.jcrclustersupport.ClusterAware;

import de.joerghoh.cq5.healthcheck.StatusService;
import de.joerghoh.cq5.healthcheck.StatusCode;

/**
 * A servlet, which returns the actual status suitable for a loadbalancer.
 * 
 * Internally the HealthStatusService and the current clustering status is used
 * to determine the return code.
 * 
 * This code allows to specify a cluster strategy: 
 * * ActiveActive: All cluster nodes are eligable to return "OK" 
 * * ActivePassive: Only the master is eligable to return "OK", slaves always return "WARN".
 * 
 * In any case also the OverallStatus of the HealthStatusService is used to
 * identify the status. If the status is != OK, then "WARN" is returned and the
 * return code of this request is set to 500 (internal server error).
{'fraction_non_alphanumeric': 0.08630479218714512, 'fraction_numerical': 0.0072677719736543266, 'mean_word_length': 4.56763590391909, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3635783', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1263, 'n_words': 435}