<commit_before>//
// This file is part of the OpenNMS(R) Application.
//
// OpenNMS(R) is Copyright (C) 2002-2005 The OpenNMS Group, Inc.  All rights reserved.
// OpenNMS(R) is a derivative work, containing both original code, included code and modified
// code that was published under the GNU General Public License. Copyrights for modified 
// and included code are below.
//
// OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
//
// Modifications:
//
// Jul 8, 2004: Created this file.
//
// Original code base Copyright (C) 1999-2001 Oculan Corp.  All rights reserved.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program 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 General Public License for more details.                                                            
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//       
// For more information contact: 
//      OpenNMS Licensing       <<EMAIL>>
//      http://www.opennms.org/
//      http://www.opennms.com/
//
// Tab Size = 8
//

package org.opennms.netmgt.rrd;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * Defines an abstract strategy for manipulating round robin database file. This
 * is used by the RrdUtils to implement the appropriate behaviour
 */
public interface RrdStrategy {

    /**
     * Initialize the appropriate round robin system
     * 
     * @throws Exception
     *             if an Error occurs
     */
    void initialize() throws Exception;

    /**
     * This Initializes the graphics subsystem only. This is used by the web
     * application to avoid the need for the JNI infrastructure in the webapp.
     */
    void graphicsInitialize() throws Exception;
    
    /**
     * Get the file extension appropriate for files of this type
     */
    String getDefaultFileExtension();

    /**
     * Create a round robin database definition from the supplied parameters.
     * This definition is used in the createFile call to create the actual file.
     * 
     * @param creator -
     *            A string representing who is creating this file for use in log
     *            msgs
     * @param directory -
     *            The directory to create the file in
     * @param rrdName -
     *            The name to use for the round robin database
     * @param step -
     *            the step for the database
     * @param dataSources -
     *            the datasources to use for round robin database
     * @param rraList -
     *            a List of the round robin archives to create in the database
     * @return an object representing the definition of an round robin database
     * @throws Exception
     *             If an error occurs while creating the definition
     */
    Object createDefinition(String creator, String directory, String rrdName, int step, List dataSources, List rraList) throws Exception;

    /**
     * Creates the round robin database defined by the supplied definition.
     * 
     * @param rrdDef
     *            an round robin database definition created using the
     *            createDefinition call.
     * @throws Exception
     *             if an error occurs create the file
     */
    void createFile(Object rrdDef) throws Exception;

    /**
     * Opens the round robin database with the supplied name. It is assumed the
     * name refers to a round robin database appropriate for this strategy
     * implementation
     * 
     * @param fileName
     *            the name of the associated rrd file
     * @return an open rrd reference that can by used in calls to updateFile and
     *         closeFile
     * @throws Exception
     *             if an error occurs opening the file
     */
    Object openFile(String fileName) throws Exception;

    /**
     * Updates the supplied round robin database with the given timestamp:value
     * point
     * 
     * @param rrd
     *            an rrd object created using openFile
     * @param owner
     *            the owner of the rrd
     * @param data
     *            a string of the form <timestamp>: <datavalue>
     * @throws Exception
     *             if an error occurs updating the file
     */
    void updateFile(Object rrd, String owner, String data) throws Exception;

    /**
     * This closes the supplied round robin database
     * 
     * @param rrd
     *            an rrd object created using openFile
     * @throws Exception
     *             if an error occurs closing the file
     */
    void closeFile(Object rrd) throws Exception;

    /**
     * Fetches the last value from the round robin database with the given name.
     * The interval passed in should be the interval associated with the round
     * robin database.
     * 
     * @param rrdFile
     *            a name the represents a round robin database
     * @param interval
     *            a step interval of the round robin database
     * @return The last value as a Double (if the last value didn't exist
     *         returns a Double.NaN)
     * @throws NumberFormatException
     * @throws RrdException
     */
    public Double fetchLastValue(String rrdFile, int interval) throws NumberFormatException, RrdException;

    /**
     * Fetches the last value from the round robin database with the given name
     * within a time range. The interval passed in should be the interval 
     * associated with the round robin database. The range should be the amount of
     * "lag" acceptable for an update to be considered valid. Range must be a 
     * multiple of the RRD interval.
     * 
     * @param rrdFile
     *            a name the represents a round robin database
     * @param interval
     *            a step interval of the round robin database
     * @param range
     *            an acceptable range for which the last value will be returned<commit_msg>Mark everything public that wasn't already marked public.<commit_after>//
// This file is part of the OpenNMS(R) Application.
//
// OpenNMS(R) is Copyright (C) 2002-2005 The OpenNMS Group, Inc.  All rights reserved.
// OpenNMS(R) is a derivative work, containing both original code, included code and modified
// code that was published under the GNU General Public License. Copyrights for modified 
// and included code are below.
//
// OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
//
// Modifications:
//
// Jul 8, 2004: Created this file.
//
// Original code base Copyright (C) 1999-2001 Oculan Corp.  All rights reserved.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program 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 General Public License for more details.                                                            
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//       
// For more information contact: 
//      OpenNMS Licensing       <<EMAIL>>
//      http://www.opennms.org/
//      http://www.opennms.com/
//
// Tab Size = 8
//

package org.opennms.netmgt.rrd;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * Defines an abstract strategy for manipulating round robin database file. This
 * is used by the RrdUtils to implement the appropriate behaviour
 */
public interface RrdStrategy {

    /**
     * Initialize the appropriate round robin system
     * 
     * @throws Exception
     *             if an Error occurs
     */
    public void initialize() throws Exception;

    /**
     * This Initializes the graphics subsystem only. This is used by the web
     * application to avoid the need for the JNI infrastructure in the webapp.
     */
    public void graphicsInitialize() throws Exception;
    
    /**
     * Get the file extension appropriate for files of this type
     */
    public String getDefaultFileExtension();

    /**
     * Create a round robin database definition from the supplied parameters.
     * This definition is used in the createFile call to create the actual file.
     * 
     * @param creator -
     *            A string representing who is creating this file for use in log
     *            msgs
     * @param directory -
     *            The directory to create the file in
     * @param rrdName -
     *            The name to use for the round robin database
     * @param step -
     *            the step for the database
     * @param dataSources -
     *            the datasources to use for round robin database
     * @param rraList -
     *            a List of the round robin archives to create in the database
     * @return an object representing the definition of an round robin database
     * @throws Exception
     *             If an error occurs while creating the definition
     */
    public Object createDefinition(String creator, String directory, String rrdName, int step, List dataSources, List rraList) throws Exception;

    /**
     * Creates the round robin database defined by the supplied definition.
     * 
     * @param rrdDef
     *            an round robin database definition created using the
     *            createDefinition call.
     * @throws Exception
     *             if an error occurs create the file
     */
    public void createFile(Object rrdDef) throws Exception;

    /**
     * Opens the round robin database with the supplied name. It is assumed the
     * name refers to a round robin database appropriate for this strategy
     * implementation
     * 
     * @param fileName
     *            the name of the associated rrd file
     * @return an open rrd reference that can by used in calls to updateFile and
     *         closeFile
     * @throws Exception
     *             if an error occurs opening the file
     */
    public Object openFile(String fileName) throws Exception;

    /**
     * Updates the supplied round robin database with the given timestamp:value
     * point
     * 
     * @param rrd
     *            an rrd object created using openFile
     * @param owner
     *            the owner of the rrd
     * @param data
     *            a string of the form <timestamp>: <datavalue>
     * @throws Exception
     *             if an error occurs updating the file
     */
    public void updateFile(Object rrd, String owner, String data) throws Exception;

    /**
     * This closes the supplied round robin database
     * 
     * @param rrd
     *            an rrd object created using openFile
     * @throws Exception
     *             if an error occurs closing the file
     */
    public void closeFile(Object rrd) throws Exception;

    /**
     * Fetches the last value from the round robin database with the given name.
     * The interval passed in should be the interval associated with the round
     * robin database.
     * 
     * @param rrdFile
     *            a name the represents a round robin database
     * @param interval
     *            a step interval of the round robin database
     * @return The last value as a Double (if the last value didn't exist
     *         returns a Double.NaN)
     * @throws NumberFormatException
     * @throws RrdException
     */
    public Double fetchLastValue(String rrdFile, int interval) throws NumberFormatException, RrdException;

    /**
     * Fetches the last value from the round robin database with the given name
     * within a time range. The interval passed in should be the interval 
     * associated with the round robin database. The range should be the amount of
     * "lag" acceptable for an update to be considered valid. Range must be a 
     * multiple of the RRD interval.
     * 
     * @param rrdFile
     *            a name the represents a round robin database
     * @param interval
     *            a step interval of the round robin database
     * @param range
     *            an acceptable range for which the last value will be returned
{'fraction_non_alphanumeric': 0.06194827319188478, 'fraction_numerical': 0.0057302152702493414, 'mean_word_length': 2.1615667074663403, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7395193', 'n_tokens_mistral': 3254, 'n_tokens_neox': 3140, 'n_words': 1546}