View Javadoc

1   /* ============================================================
2    * JRobin : Pure java implementation of RRDTool's functionality
3    * ============================================================
4    *
5    * Project Info:  http://www.jrobin.org
6    * Project Lead:  Sasa Markovic (saxon@jrobin.org);
7    *
8    * (C) Copyright 2003-2005, by Sasa Markovic.
9    *
10   * Developers:    Sasa Markovic (saxon@jrobin.org)
11   *
12   *
13   * This library is free software; you can redistribute it and/or modify it under the terms
14   * of the GNU Lesser General Public License as published by the Free Software Foundation;
15   * either version 2.1 of the License, or (at your option) any later version.
16   *
17   * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
18   * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19   * See the GNU Lesser General Public License for more details.
20   *
21   * You should have received a copy of the GNU Lesser General Public License along with this
22   * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
23   * Boston, MA 02111-1307, USA.
24   */
25  
26  package org.jrobin.core;
27  
28  import java.io.IOException;
29  
30  abstract class DataImporter {
31  
32  	// header
33  	abstract String getVersion() throws RrdException, IOException;
34  
35  	abstract long getLastUpdateTime() throws RrdException, IOException;
36  
37  	abstract long getStep() throws RrdException, IOException;
38  
39  	abstract int getDsCount() throws RrdException, IOException;
40  
41  	abstract int getArcCount() throws RrdException, IOException;
42  
43  	// datasource
44  	abstract String getDsName(int dsIndex) throws RrdException, IOException;
45  
46  	abstract String getDsType(int dsIndex) throws RrdException, IOException;
47  
48  	abstract long getHeartbeat(int dsIndex) throws RrdException, IOException;
49  
50  	abstract double getMinValue(int dsIndex) throws RrdException, IOException;
51  
52  	abstract double getMaxValue(int dsIndex) throws RrdException, IOException;
53  
54  	// datasource state
55  	abstract double getLastValue(int dsIndex) throws RrdException, IOException;
56  
57  	abstract double getAccumValue(int dsIndex) throws RrdException, IOException;
58  
59  	abstract long getNanSeconds(int dsIndex) throws RrdException, IOException;
60  
61  	// archive
62  	abstract String getConsolFun(int arcIndex) throws RrdException, IOException;
63  
64  	abstract double getXff(int arcIndex) throws RrdException, IOException;
65  
66  	abstract int getSteps(int arcIndex) throws RrdException, IOException;
67  
68  	abstract int getRows(int arcIndex) throws RrdException, IOException;
69  
70  	// archive state
71  	abstract double getStateAccumValue(int arcIndex, int dsIndex) throws RrdException, IOException;
72  
73  	abstract int getStateNanSteps(int arcIndex, int dsIndex) throws RrdException, IOException;
74  
75  	abstract double[] getValues(int arcIndex, int dsIndex) throws RrdException, IOException;
76  
77  	long getEstimatedSize() throws RrdException, IOException {
78  		int dsCount = getDsCount();
79  		int arcCount = getArcCount();
80  		int rowCount = 0;
81  		for (int i = 0; i < arcCount; i++) {
82  			rowCount += getRows(i);
83  		}
84  		return RrdDef.calculateSize(dsCount, arcCount, rowCount);
85  	}
86  
87  	void release() throws RrdException, IOException {
88  		// NOP
89  	}
90  
91  }