001/*
002 *  Copyright 2012 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.runtime.plugins.admin.jvmstatus.monitoring;
017
018import java.io.IOException;
019import java.util.Map;
020
021import org.rrd4j.core.RrdDef;
022import org.rrd4j.core.Sample;
023
024import org.ametys.runtime.i18n.I18nizableText;
025
026/**
027 * Interface to be implemented for monitoring samples of data.
028 */
029public interface SampleManager
030{
031    /**
032     * Provides the id of this manager.<br>
033     * Must be unique in the application.
034     * @return the id.
035     */
036    String getId();
037    
038    /**
039     * Provides the human readable name to use.<br>
040     * @return the human readable name.
041     */
042    I18nizableText getLabel();
043    
044    /**
045     * Provides the human readable description.<br>
046     * @return the human readable description.
047     */
048    I18nizableText getDescription();
049    
050    /**
051     * Provides the definition to use for this RRD file.
052     * Called only when the RRD file is about to be
053     * created.
054     * @param rrdDef the Round Robin Database definition.
055     */
056    void configureRRDDef(RrdDef rrdDef);
057    
058    /**
059     * Collect data into the Round Robin Database.
060     * @param sample the sample to collect.
061     * @return The collected values for each datasource name.
062     * @throws IOException thrown in case of I/O error.
063     */
064    Map<String, Object> collect(Sample sample) throws IOException;
065}