当前位置: 首页>>代码示例>>Java>>正文


Java RrdException类代码示例

本文整理汇总了Java中org.jrobin.core.RrdException的典型用法代码示例。如果您正苦于以下问题:Java RrdException类的具体用法?Java RrdException怎么用?Java RrdException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RrdException类属于org.jrobin.core包,在下文中一共展示了RrdException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: JRobin

import org.jrobin.core.RrdException; //导入依赖的package包/类
private JRobin(String application, String name, File rrdFile, int step, String requestName)
		throws RrdException, IOException {
	super();
	assert application != null;
	assert name != null;
	assert rrdFile != null;
	assert step > 0;
	// requestName est null pour un compteur

	this.application = application;
	this.name = name;
	this.rrdFileName = rrdFile.getPath();
	this.step = step;
	this.requestName = requestName;

	init();
}
 
开发者ID:javamelody,项目名称:javamelody,代码行数:18,代码来源:JRobin.java

示例2: createRrdDef

import org.jrobin.core.RrdException; //导入依赖的package包/类
private RrdDef createRrdDef() throws RrdException {
  RrdDef rrdDef = new RrdDef(_rrdPath, _resolutionSeconds);
  rrdDef.setStartTime(Util.getTime() - _resolutionSeconds); // Matches more or less as collect is called right after init
  rrdDef.addDatasource(_name, "GAUGE", _resolutionSeconds * 2, 0, Double.NaN); // Single gauge

  // Archives for average/max for each supported period:
  // 1 second for 1 hour periods:
  rrdDef.addArchive(FUNCTION_AVG, 0.25, 1, DAY / _resolutionSeconds);
  rrdDef.addArchive(FUNCTION_MAX, 0.25, 1, DAY / _resolutionSeconds);
  // 1 hour for 1 week periods:
  rrdDef.addArchive(FUNCTION_AVG, 0.25, HOUR / _resolutionSeconds, 7 * 24);
  rrdDef.addArchive(FUNCTION_MAX, 0.25, HOUR / _resolutionSeconds, 7 * 24);
  // 6 hours for 1 Month periods:
  rrdDef.addArchive(FUNCTION_AVG, 0.25, 6 * HOUR / _resolutionSeconds, 31 * 4);
  rrdDef.addArchive(FUNCTION_MAX, 0.25, 6 * HOUR / _resolutionSeconds, 31 * 4);
  // 2 days for year/all periods:
  rrdDef.addArchive(FUNCTION_AVG, 0.25, 2 * DAY / _resolutionSeconds, 2 * 12 * 15);
  rrdDef.addArchive(FUNCTION_MAX, 0.25, 2 * DAY / _resolutionSeconds, 2 * 12 * 15);

  return rrdDef;
}
 
开发者ID:purej,项目名称:purej-vminspect,代码行数:22,代码来源:Statistics.java

示例3: addValue

import org.jrobin.core.RrdException; //导入依赖的package包/类
private void addValue(double value) throws IOException {
  try {
    // Open the existing file in r/w mode:
    RrdDb rrdDb = new RrdDb(_rrdPath, false, _rrdBackendFactory);
    try {
      // Create sample with the current timestamp:
      Sample sample = rrdDb.createSample();
      if (sample.getTime() > rrdDb.getLastUpdateTime()) {
        sample.setValue(_name, value);
        sample.update();
      }
    }
    finally {
      rrdDb.close();
    }
  }
  catch (RrdException e) {
    String msg = "Accessing JRobin statistics file '" + _rrdPath + "' failed! If the problem persists, delete the file so it will be recreated.";
    LOG.error(msg, e);
    throw new IOException(msg, e);
  }
}
 
开发者ID:purej,项目名称:purej-vminspect,代码行数:23,代码来源:Statistics.java

示例4: stopListening

import org.jrobin.core.RrdException; //导入依赖的package包/类
public void stopListening() {
    if (_db == null) return;
    try {
        _db.close();
    } catch (IOException ioe) {
        _log.error("Error closing", ioe);
    }
    _rate.setSummaryListener(null);
    if (!_isPersistent) {
        // close() does not release resources for memory backend
        try {
            ((RrdMemoryBackendFactory)RrdBackendFactory.getFactory(RrdMemoryBackendFactory.NAME)).delete(_db.getPath());
        } catch (RrdException re) {}
    }
    _db = null;
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:17,代码来源:SummaryListener.java

示例5: setConfigurationProperties

import org.jrobin.core.RrdException; //导入依赖的package包/类
/** {@inheritDoc} */
public void setConfigurationProperties(final Properties configurationParameters) {
    m_configurationProperties = configurationParameters;
    if(!s_initialized) {
        String factory = null;
        if (m_configurationProperties == null) {
            factory = DEFAULT_BACKEND_FACTORY;
        } else {
            factory = (String)m_configurationProperties.get(BACKEND_FACTORY_PROPERTY);
        }
        try {
            RrdDb.setDefaultFactory(factory);
            s_initialized=true;
        } catch (RrdException e) {
            log().error("Could not set default JRobin RRD factory: " + e.getMessage(), e);
        }
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:19,代码来源:JRobinRrdStrategy.java

示例6: addVdefDs

import org.jrobin.core.RrdException; //导入依赖的package包/类
protected void addVdefDs(RrdGraphDef graphDef, String sourceName, String[] rhs, double start, double end, Map<String,List<String>> defs) throws RrdException {
    if (rhs.length == 2) {
        graphDef.datasource(sourceName, rhs[0], rhs[1]);
    } else if (rhs.length == 3 && "PERCENT".equals(rhs[2])) {
        // Is there a better way to do this than with a separate DataProcessor?
        double pctRank = Double.valueOf(rhs[1]);
        DataProcessor dataProcessor = new DataProcessor((int)start, (int)end);
        for (String dsName : defs.keySet()) {
            List<String> thisDef = defs.get(dsName);
            if (thisDef.size() == 3) {
                dataProcessor.addDatasource(dsName, thisDef.get(0), thisDef.get(1), thisDef.get(2));
            } else if (thisDef.size() == 1) {
                dataProcessor.addDatasource(dsName, thisDef.get(0));
            }
        }
        try {
            dataProcessor.processData();
        } catch (IOException e) {
            throw new RrdException("Caught IOException: " + e.getMessage());
        }
        
        double result = dataProcessor.getPercentile(rhs[0], pctRank);
        ConstantStaticDef csDef = new ConstantStaticDef((long)start, (long)end, result);
        graphDef.datasource(sourceName, csDef);
    } 
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:27,代码来源:JRobinRrdStrategy.java

示例7: dumpRrd

import org.jrobin.core.RrdException; //导入依赖的package包/类
/**
 * Dumps a RRD.
 *
 * @param sourceFile the source file
 * @return the RRD Object
 * @throws IOException Signals that an I/O exception has occurred.
 * @throws RrdException the RRD exception
 */
public static RRDv3 dumpRrd(File sourceFile) throws IOException, RrdException {
    String rrdBinary = System.getProperty("rrd.binary");
    if (rrdBinary == null) {
        throw new IllegalArgumentException("rrd.binary property must be set");
    }
    try {
        XMLReader xmlReader = XMLReaderFactory.createXMLReader();
        xmlReader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
        Process process = Runtime.getRuntime().exec(new String[] {rrdBinary, "dump", sourceFile.getAbsolutePath()});
        SAXSource source = new SAXSource(xmlReader, new InputSource(new InputStreamReader(process.getInputStream())));
        JAXBContext jc = JAXBContext.newInstance(RRDv3.class);
        Unmarshaller u = jc.createUnmarshaller();
        return (RRDv3) u.unmarshal(source);
    } catch (Exception e) {
        throw new RrdException("Can't parse RRD Dump", e);
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:26,代码来源:RrdConvertUtils.java

示例8: restoreRrd

import org.jrobin.core.RrdException; //导入依赖的package包/类
/**
 * Restores a RRD.
 *
 * @param rrd the RRD object
 * @param targetFile the target file
 * @throws IOException Signals that an I/O exception has occurred.
 * @throws RrdException the RRD exception
 */
public static void restoreRrd(RRDv3 rrd, File targetFile) throws IOException, RrdException {
    String rrdBinary = System.getProperty("rrd.binary");
    if (rrdBinary == null) {
        throw new IllegalArgumentException("rrd.binary property must be set");
    }
    try {
        File xmlDest = new File(targetFile + ".xml");
        JaxbUtils.marshal(rrd, new FileWriter(xmlDest));
        Process process = Runtime.getRuntime().exec(new String[]{ rrdBinary, "restore", xmlDest.getAbsolutePath(), targetFile.getAbsolutePath() });
        process.waitFor();
        xmlDest.delete();
    } catch (Exception e) {
        throw new RrdException("Can't restore RRD", e);
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:24,代码来源:RrdConvertUtils.java

示例9: main

import org.jrobin.core.RrdException; //导入依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
	m_out = System.out;
	try {
		parseCmdLine(args);
	} catch (Throwable e) {
		System.out.println("Error parsing command line arguments: " + e.getMessage());
	}
	try {
		m_rrdFile = openRrd();
	} catch (IOException ioe) {
		System.out.println("IO Exception trying to open RRD file: " + ioe.getMessage());
		System.exit(-1);
	} catch (RrdException rrde) {
		System.out.println("RRD Exception trying to open RRD file: " + rrde.getMessage());
		System.exit(-1);
	}
	if (m_dumpContents) {
		dumpContents();
		System.exit(0);
	}
	doReplacement();
	closeRrd();
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:27,代码来源:SpikeHunter.java

示例10: replaceInDs

import org.jrobin.core.RrdException; //导入依赖的package包/类
private static void replaceInDs(Archive arc, FetchData data, String dsName) {
	printToUser(" Operating on DS " + dsName);
	double[] origValues = null;
	try {
		origValues = data.getValues(dsName);
	} catch (RrdException e) {
		System.out.println("RRD Exception trying to get values from RRD file: " + e.getMessage());
		System.exit(-1);
	}
	DataAnalyzer analyzer = getDataAnalyzer();
	analyzer.setVerbose(m_verbose);
	List<Integer> violatorIndices = analyzer.findSamplesInViolation(origValues);
	if (m_verbose) {
		printToUser(" Number of values: " + origValues.length);
		printToUser(" Data analyzer: " + analyzer);
		printToUser(" Samples found in violation: " + violatorIndices.size());
	}
	DataReplacer replacer = getDataReplacer();
	double[] newValues = replacer.replaceValues(origValues, violatorIndices);
	printReplacementsToUser(data, dsName, newValues, violatorIndices);
	if (!m_dryRun) {
		replaceInFile(arc, data, dsName, newValues, violatorIndices);
	}
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:25,代码来源:SpikeHunter.java

示例11: replaceInFile

import org.jrobin.core.RrdException; //导入依赖的package包/类
private static void replaceInFile(Archive arc, FetchData data, String dsName, double[] newValues, List<Integer> violatorIndices) {
	Robin robin = null;
	try {
		robin = arc.getRobin(m_rrdFile.getDsIndex(dsName));
	} catch (RrdException rrde) {
		System.out.println("RRD Exception trying to retrieve Robin from RRD file: " + rrde.getMessage());
		System.exit(-1);
	} catch (IOException ioe) {
		System.out.println("RRD Exception trying to retrieve Robin from RRD file: " + ioe.getMessage());
		System.exit(-1);
	}
	//m_rrdFile.getArchive(int arcIndex)
	//m_rrdFile.getArchive(String consolFun, int steps)
	for (int i : violatorIndices) {
		try {
			robin.setValue(i, newValues[i]);
		} catch (IOException e) {
			System.out.println("IO Exception trying to set value for index " + i + " to " + newValues[i]);
		}
	}
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:22,代码来源:SpikeHunter.java

示例12: consolidateRrdFile

import org.jrobin.core.RrdException; //导入依赖的package包/类
public void consolidateRrdFile(final File groupFile, final File outputFile) throws IOException, RrdException, ConverterException {
    final List<RrdDatabase> rrds = new ArrayList<RrdDatabase>();
    rrds.add(new RrdDatabase(new RrdDb(groupFile, true)));
    for (final File individualFile : getMatchingGroupRrds(groupFile)) {
        final RrdDb individualRrd = new RrdDb(individualFile, true);
        rrds.add(new RrdDatabase(individualRrd));
    }
    final TimeSeriesDataSource dataSource = new AggregateTimeSeriesDataSource(rrds);

    final RrdDb outputRrd = new RrdDb(outputFile);
    final RrdDatabaseWriter writer = new RrdDatabaseWriter(outputRrd);

    final long endTime = dataSource.getEndTime();
    // 1 year
    final long startTime = endTime - ONE_YEAR_IN_SECONDS;
    for (long time = startTime; time <= endTime; time += dataSource.getNativeStep()) {
        final RrdEntry entry = dataSource.getDataAt(time);
        writer.write(entry);
    }
    dataSource.close();
    outputRrd.close();
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:23,代码来源:JRobinConverter.java

示例13: initializeRrd

import org.jrobin.core.RrdException; //导入依赖的package包/类
private void initializeRrd(final File fileName, final String[] dsNames, final String[] archives) throws RrdException, IOException {
    final RrdDef rrdDef = new RrdDef(fileName.getAbsolutePath());
    rrdDef.setStartTime(0);
    final DsDef[] dsDefs = new DsDef[dsNames.length];
    for (int i = 0; i < dsNames.length; i++) {
        dsDefs[i] = new DsDef(dsNames[i], "COUNTER", 600, 0, Double.NaN);
    }
    rrdDef.addDatasource(dsDefs);
    final ArcDef[] arcDefs = new ArcDef[archives.length];
    for (int i = 0; i < archives.length; i++) {
        String[] entry = archives[i].split(":");
        Integer steps = Integer.valueOf(entry[0]);
        Integer rows = Integer.valueOf(entry[1]);
        arcDefs[i] = new ArcDef("AVERAGE", 0.5D, steps, rows);
    }
    rrdDef.addArchive(arcDefs);
    final RrdDb db = new RrdDb(rrdDef);
    db.close();
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:20,代码来源:JRobinConverterTest.java

示例14: testReadInt64BitBigEndian

import org.jrobin.core.RrdException; //导入依赖的package包/类
@Test
public void testReadInt64BitBigEndian() throws IOException, RrdException {
	File tempFile=new File("target/test-read-int.rrd");
	FileOutputStream outputStream = new FileOutputStream(tempFile);
	write64BitBigEndianHeaderToFloatCookie(outputStream);

	//Write out 3 integers (the rest of the normal header), each 64 bits, in little endian format.
	//However, we're expecting only an int (32-bits) back, so the value we're expecting from a
	// big-endian file is the *last* four bytes only.  The first four bytes are ignored.
	//We write them with real possibly mis-interpretable numbers though, to double check
	//that it's reading correctly
	byte int1[] = { 0x77, 0x66, 0x55, 0x44, 0x78, 0x56, 0x34, 0x12};
	byte int2[] = { 0x77, 0x66, 0x55, 0x44, 0x12, 0x34, 0x56, 0x78};
	byte int3[] = { 0x77, 0x66, 0x55, 0x44, 0x78, 0x12, 0x56, 0x34};

	outputStream.write(int1);
	outputStream.write(int2);
	outputStream.write(int3);
	outputStream.close();

	RRDFile rrdFile = new RRDFile(tempFile);
	rrdFile.skipBytes(24); //Skip the string cookie, version, padding, and float cookie
	Assert.assertEquals(0x78563412, rrdFile.readInt());
	Assert.assertEquals(0x12345678, rrdFile.readInt());
	Assert.assertEquals(0x78125634, rrdFile.readInt());
}
 
开发者ID:OpenNMS,项目名称:jrobin,代码行数:27,代码来源:RRDFileTest.java

示例15: parseVDef

import org.jrobin.core.RrdException; //导入依赖的package包/类
private void parseVDef(String word) throws RrdException {
	String[] tokens1 = new ColonSplitter(word).split();
	if (tokens1.length != 2) {
		throw new RrdException("Invalid VDEF specification: " + word);
	}
	String[] tokens2 = tokens1[1].split("=");
	if (tokens2.length != 2) {
		throw new RrdException("Invalid DEF specification: " + word);
	}
               String[] tokens3 = tokens2[1].split(",");
               if (tokens3.length == 2)  {
                   dproc.addDatasource(tokens2[0], tokens3[0], tokens3[1]);
               } else {
                   dproc.addDatasource(tokens2[0], tokens3[0], Double.parseDouble(tokens3[1]), tokens3[2].equals("PERCENT"));
               }
}
 
开发者ID:OpenNMS,项目名称:jrobin,代码行数:17,代码来源:RrdXportCmd.java


注:本文中的org.jrobin.core.RrdException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。