All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opencms.monitor.CmsMemoryMonitorConfiguration Maven / Gradle / Ivy

Go to download

OpenCms is an enterprise-ready, easy to use website content management system based on Java and XML technology. Offering a complete set of features, OpenCms helps content managers worldwide to create and maintain beautiful websites fast and efficiently.

There is a newer version: 18.0
Show newest version
/*
 * This library is part of OpenCms -
 * the Open Source Content Management System
 *
 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * For further information about Alkacon Software GmbH & Co. KG, please see the
 * company website: http://www.alkacon.com
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package org.opencms.monitor;

import org.opencms.util.CmsStringUtil;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Memory Monitor configuration class.

* * @since 6.0.0 */ public class CmsMemoryMonitorConfiguration { /** The memory monitor class name. */ private String m_className; /** The interval to use for sending emails. */ private int m_emailInterval; /** Receivers for status emails. */ private List m_emailReceiver; /** Sender for status emails. */ private String m_emailSender; /** The interval to use for the logging. */ private int m_logInterval; /** Memory limit that triggers a warning. */ private int m_maxUsagePercent; /** The interval to use for warnings if status is disabled. */ private int m_warningInterval; /** * Constructor with default values.

*/ public CmsMemoryMonitorConfiguration() { m_emailReceiver = new ArrayList(); } /** * Sets the emailReceiver.

* * @param emailReceiver the emailReceiver to set */ public void addEmailReceiver(String emailReceiver) { m_emailReceiver.add(emailReceiver); } /** * Returns the name of the memory monitor class.

* * @return the name of the memory monitor class */ public String getClassName() { return m_className; } /** * Returns the intervalEmail.

* * @return the intervalEmail */ public int getEmailInterval() { return m_emailInterval; } /** * Returns a List of receiver.

* * @return a List of receiver */ public List getEmailReceiver() { Collections.sort(m_emailReceiver); return m_emailReceiver; } /** * Returns the emailSender.

* * @return the emailSender */ public String getEmailSender() { return m_emailSender; } /** * Returns the intervalLog.

* * @return the intervalLog */ public int getLogInterval() { return m_logInterval; } /** * Returns the maxUsagePercent.

* * @return the maxUsagePercent */ public int getMaxUsagePercent() { return m_maxUsagePercent; } /** * Returns the intervalWarning.

* * @return the intervalWarning */ public int getWarningInterval() { return m_warningInterval; } /** * Initializes the configuration with the required parameters.

* * @param className the name of the memory monitor class * @param maxUsagePercent the max usage percent value * @param logInterval the interval to log * @param emailInterval the interval to send email * @param warningInterval the interval to warn */ public void initialize( String className, String maxUsagePercent, String logInterval, String emailInterval, String warningInterval) { m_className = className; m_maxUsagePercent = Integer.parseInt(maxUsagePercent); m_logInterval = Integer.parseInt(logInterval); try { m_emailInterval = Integer.parseInt(emailInterval); } catch (NumberFormatException e) { // throw exception, when email interval is not null, or not an empty/whitespace string if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(emailInterval)) { throw new NumberFormatException(); } } m_warningInterval = Integer.parseInt(warningInterval); } /** * Sets the emailSender.

* * @param emailSender the emailSender to set */ public void setEmailSender(String emailSender) { m_emailSender = emailSender; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy