<commit_before>/*
 * Copyright 2006-2007 the original author or authors.
 *
 * 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 org.openspaces.admin.alert;

import org.openspaces.admin.AdminAware;
import org.openspaces.admin.alert.config.AlertConfiguration;
import org.openspaces.admin.alert.config.parser.AlertConfigurationParser;
import org.openspaces.admin.alert.config.parser.XmlAlertConfigurationParser;
import org.openspaces.admin.alert.events.AlertTriggeredEventListener;
import org.openspaces.admin.alert.events.AlertTriggeredEventManager;

/**
 * The <tt>AlertManager</tt> is a manager for configuring of alerts, firing of alerts, and
 * registering for alert events.
 * <p>
 * The alert manager provides two options for configuration of alert configurations - as bulk or one
 * by one. The {@link AlertConfiguration} is the main interface of an alert configuration - a
 * configuration based on String key-value property pairs.
 * <p>
 * To configure with a bulk of alert configurations, the {@link #configure(AlertConfiguration[])}
 * method can be used. These configurations can be extracted from a resource using an
 * {@link AlertConfigurationParser}. The parser {@link AlertConfigurationParser#parse()} returns an
 * array of {@link AlertConfiguration}. The {@link XmlAlertConfigurationParser} can be used to parse
 * the <tt>alerts.xml</tt> configuration file located under <tt>config/alerts</tt>.
 * <p>
 * To Register/Unregister for alert events (of all types), use the {@link AlertTriggeredEventManager} to
 * add/remove {@link AlertTriggeredEventListener}s.
 * <p>
 * The {@link #triggerAlert(Alert)} method call allows <tt>alert triggers</tt> to 'fire' an alert and
 * trigger an event to be sent to all registered alert event listeners.
 * 
 * @author <NAME>
 * @since 8.0
 */
public interface AlertManager extends AdminAware {

    /**
     * Define an alert configuration for a 'bulk' of configurations. Overrides all previously set
     * properties for any of the alerts.
     * <p>
     * See the {@link XmlAlertConfigurationParser} which can be used to parse the default
     * <tt>alerts.xml</tt> configuration file located under <tt>config/alerts</tt>.
     * <p>
     * If {@link AlertConfiguration#isEnabled()} returns <code>true</code> it is equivalent to
     * calling {@link #setConfig(AlertConfiguration)} followed by {@link #enableAlert(Class)}. If it
     * returns <code>false</code> it is equivalent to calling {@link #setConfig(AlertConfiguration)}
     * followed by {@link #disableAlert(Class)}.
     * <p>
     * An exception is raised if an alert is already enabled.
     * 
     * @param configurations
     *            the alert configurations.
     * @throws AlertConfigurationException
     *             if the alert is already enabled (need to disable it first).
     * @see AlertConfigurationParser
     */
    void configure(AlertConfiguration[] configurations) throws AlertConfigurationException;

    /**
     * Defines an alert configuration. Overrides all previously set properties for this alert.
     * <p>
     * The {@link AlertConfiguration#isEnabled()} is ignored. To enable, call {@link #enableAlert(Class)}.
     * To perform both operations in a single call, use {@link #configure(AlertConfiguration[])}.
     * <p>
     * An exception is raised if the alert is already enabled.
     * 
     * @param config
     *            the alert configuration
     * 
     * @throws AlertConfigurationException
     *             if the alert is already enabled (need to disable it first).
     */
    void setConfig(AlertConfiguration config) throws AlertConfigurationException;

    /**
     * Enable a previously set alert configuration. From this point, alerts will be triggered.<commit_msg>GS-8403: Allow varargs to be passed instead of a new array.<commit_after>/*
 * Copyright 2006-2007 the original author or authors.
 *
 * 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 org.openspaces.admin.alert;

import org.openspaces.admin.AdminAware;
import org.openspaces.admin.alert.config.AlertConfiguration;
import org.openspaces.admin.alert.config.parser.AlertConfigurationParser;
import org.openspaces.admin.alert.config.parser.XmlAlertConfigurationParser;
import org.openspaces.admin.alert.events.AlertTriggeredEventListener;
import org.openspaces.admin.alert.events.AlertTriggeredEventManager;

/**
 * The <tt>AlertManager</tt> is a manager for configuring of alerts, firing of alerts, and
 * registering for alert events.
 * <p>
 * The alert manager provides two options for configuration of alert configurations - as bulk or one
 * by one. The {@link AlertConfiguration} is the main interface of an alert configuration - a
 * configuration based on String key-value property pairs.
 * <p>
 * To configure with a bulk of alert configurations, the {@link #configure(AlertConfiguration[])}
 * method can be used. These configurations can be extracted from a resource using an
 * {@link AlertConfigurationParser}. The parser {@link AlertConfigurationParser#parse()} returns an
 * array of {@link AlertConfiguration}. The {@link XmlAlertConfigurationParser} can be used to parse
 * the <tt>alerts.xml</tt> configuration file located under <tt>config/alerts</tt>.
 * <p>
 * To Register/Unregister for alert events (of all types), use the {@link AlertTriggeredEventManager} to
 * add/remove {@link AlertTriggeredEventListener}s.
 * <p>
 * The {@link #triggerAlert(Alert)} method call allows <tt>alert triggers</tt> to 'fire' an alert and
 * trigger an event to be sent to all registered alert event listeners.
 * 
 * @author <NAME>
 * @since 8.0
 */
public interface AlertManager extends AdminAware {

    /**
     * Define an alert configuration for a 'bulk' of configurations. Overrides all previously set
     * properties for any of the alerts.
     * <p>
     * See the {@link XmlAlertConfigurationParser} which can be used to parse the default
     * <tt>alerts.xml</tt> configuration file located under <tt>config/alerts</tt>.
     * <p>
     * If {@link AlertConfiguration#isEnabled()} returns <code>true</code> it is equivalent to
     * calling {@link #setConfig(AlertConfiguration)} followed by {@link #enableAlert(Class)}. If it
     * returns <code>false</code> it is equivalent to calling {@link #setConfig(AlertConfiguration)}
     * followed by {@link #disableAlert(Class)}.
     * <p>
     * An exception is raised if an alert is already enabled.
     * 
     * @param configurations
     *            the alert configurations (as varargs).
     * @throws AlertConfigurationException
     *             if the alert is already enabled (need to disable it first).
     * @see AlertConfigurationParser
     */
    void configure(AlertConfiguration... configurations) throws AlertConfigurationException;

    /**
     * Defines an alert configuration. Overrides all previously set properties for this alert.
     * <p>
     * The {@link AlertConfiguration#isEnabled()} is ignored. To enable, call {@link #enableAlert(Class)}.
     * To perform both operations in a single call, use {@link #configure(AlertConfiguration[])}.
     * <p>
     * An exception is raised if the alert is already enabled.
     * 
     * @param config
     *            the alert configuration
     * 
     * @throws AlertConfigurationException
     *             if the alert is already enabled (need to disable it first).
     */
    void setConfig(AlertConfiguration config) throws AlertConfigurationException;

    /**
     * Enable a previously set alert configuration. From this point, alerts will be triggered.
{'fraction_non_alphanumeric': 0.08816003721795766, 'fraction_numerical': 0.0037217957664573155, 'mean_word_length': 3.71953896816685, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, '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': '6886327', 'n_tokens_mistral': 2193, 'n_tokens_neox': 2134, 'n_words': 903}