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


Java DsType类代码示例

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


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

示例1: createUnitDb

import org.rrd4j.DsType; //导入依赖的package包/类
public static RrdDb createUnitDb(int cores, int clusterId, int unitId) throws IOException {
	Logger.getLogger(RrdDbFactory.class.getName()).info("Creating new RRD file: "
			+ RrdHelper.getDbPath(clusterId, unitId));
	RrdDef rrdDef = new RrdDef(RrdHelper.getDbPath(clusterId, unitId));
	rrdDef.setStep(STEP);
	rrdDef.addDatasource(new MonitoredEntity(MonitoredEntityType.CPU_SPEED).getStringId(),
			DsType.GAUGE, TIMEOUT, Double.NaN, Double.NaN);
	for (int i = 0; i < cores; i++) {
		rrdDef.addDatasource(new MonitoredEntity(MonitoredEntityType.CPU_USAGE, i).getStringId(),
				DsType.GAUGE, TIMEOUT, Double.NaN, Double.NaN);
	}
	rrdDef.addDatasource(new MonitoredEntity(MonitoredEntityType.MEMORY).getStringId(),
			DsType.GAUGE, TIMEOUT, Double.NaN, Double.NaN);

	rrdDef.addArchive(ConsolFun.AVERAGE, 0.5,
			RrdHelper.getSampleSize(RrdDbResolution.EXACT),
			RrdHelper.getSampleWindow(RrdDbResolution.EXACT));
	rrdDef.addArchive(ConsolFun.AVERAGE, 0.5,
			RrdHelper.getSampleSize(RrdDbResolution.LOW),
			RrdHelper.getSampleWindow(RrdDbResolution.LOW));

	RrdDb rrdDb = new RrdDb(rrdDef);
	return rrdDb;
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:25,代码来源:RrdDbFactory.java

示例2: createGpuDb

import org.rrd4j.DsType; //导入依赖的package包/类
public static RrdDb createGpuDb(int clusterId, int unitId, int deviceId) throws IOException {
	Logger.getLogger(RrdDbFactory.class.getName()).info("Creating new GPU RRD file: "
			+ RrdHelper.getDbPath(clusterId, unitId, deviceId));
	RrdDef rrdDef = new RrdDef(RrdHelper.getDbPath(clusterId, unitId, deviceId));
	rrdDef.setStep(STEP);
	rrdDef.addDatasource(new MonitoredEntity(MonitoredEntityType.GPU_USAGE).getStringId(),
			DsType.GAUGE, TIMEOUT, Double.NaN, Double.NaN);
	rrdDef.addDatasource(new MonitoredEntity(MonitoredEntityType.GPU_GLOBAL_MEMORY).getStringId(),
			DsType.GAUGE, TIMEOUT, Double.NaN, Double.NaN);
	rrdDef.addDatasource(new MonitoredEntity(MonitoredEntityType.FAN).getStringId(),
			DsType.GAUGE, TIMEOUT, 0, 100);
	rrdDef.addArchive(ConsolFun.AVERAGE, 0.5,
			RrdHelper.getSampleSize(RrdDbResolution.EXACT),
			RrdHelper.getSampleWindow(RrdDbResolution.EXACT));
	rrdDef.addArchive(ConsolFun.AVERAGE, 0.5,
			RrdHelper.getSampleSize(RrdDbResolution.LOW),
			RrdHelper.getSampleWindow(RrdDbResolution.LOW));

	RrdDb rrdDb = new RrdDb(rrdDef);
	return rrdDb;
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:22,代码来源:RrdDbFactory.java

示例3: setDef

import org.rrd4j.DsType; //导入依赖的package包/类
public void setDef(String defString) {
	String[] opts = defString.split(",");
	if (opts.length != 5) { // check if correct number of parameters
		logger.warn("invalid number of parameters {}: {}", name, defString);
		return;
	}

	if (opts[0].equals("ABSOLUTE")) { // dsType
		dsType = DsType.ABSOLUTE;
	} else if (opts[0].equals("COUNTER")) {
		dsType = DsType.COUNTER;
	} else if (opts[0].equals("DERIVE")) {
		dsType = DsType.DERIVE;
	} else if (opts[0].equals("GAUGE")) {
		dsType = DsType.GAUGE;
	} else {
		logger.warn("{}: dsType {} not supported", name, opts[0]);
	}

	heartbeat = Integer.parseInt(opts[1]);

	if (opts[2].equals("U")) {
		min = Double.NaN;
	} else {
		min = Double.parseDouble(opts[2]);
	}

	if (opts[3].equals("U")) {
		max = Double.NaN;
	} else {
		max = Double.parseDouble(opts[3]);
	}

	step = Integer.parseInt(opts[4]);

	isInitialized = true; // successfully initialized

	return;
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:40,代码来源:RRD4jService.java

示例4: RRD

import org.rrd4j.DsType; //导入依赖的package包/类
/**
 * Constructs the RRD logger object with a name and a physical quantity.
 * 
 * @param name
 *            the name of the data series to be logged and displayed in the
 *            PNG.
 * @param physicalQuantity
 *            the physical quanitity of the data.
 * @throws IOException
 */
public RRD(String name, PhysicalQuantity physicalQuantity) throws IOException {
	this.name = name;
	this.physicalQuantity = physicalQuantity;
	rrdPath = name + ".rrd";
	RrdDef rrdDef = new RrdDef(rrdPath, 1);
	rrdDef.addDatasource(name, DsType.GAUGE, 60, 0D, 110D);
	rrdDef.addArchive(ConsolFun.MAX, 0.5, 1, 60 * 60 * 12);
	RrdDb rrdDb = new RrdDb(rrdDef);
	startTime = Util.getTimestamp();
	log.info("Created RRD database in " + rrdPath + ".");
	rrdDb.close();
}
 
开发者ID:SebiGo,项目名称:BrewControlServer,代码行数:23,代码来源:RRD.java

示例5: startSampling

import org.rrd4j.DsType; //导入依赖的package包/类
public void startSampling() {
    log.info("statistics gathering enabled; starting statistics database");

    this.start = System.currentTimeMillis();
    this.previous = System.currentTimeMillis();

    try {
        statFile = Files.createTempFile("kiwiloader.", ".rrd");
        Path gFile;
        if (configuration.containsKey(LoaderOptions.STATISTICS_GRAPH)) {
            gFile = Paths.get(configuration.getString(LoaderOptions.STATISTICS_GRAPH));
        } else {
            gFile = Files.createTempFile("marmotta-loader.", ".png");
        }


        RrdDef stCfg = new RrdDef(statFile.toString());
        stCfg.setStep(SAMPLE_INTERVAL);
        stCfg.addDatasource("triples", DsType.COUNTER, 600, Double.NaN, Double.NaN);
        stCfg.addArchive(ConsolFun.AVERAGE, 0.5, 1, 1440);  // every five seconds for 2 hours
        stCfg.addArchive(ConsolFun.AVERAGE, 0.5, 12, 1440); // every minute for 1 day
        stCfg.addArchive(ConsolFun.AVERAGE, 0.5, 60, 1440); // every five minutes for five days

        statDB = new RrdDb(stCfg);
        statSample = statDB.createSample();
        statLastDump = System.currentTimeMillis();

        // start a sampler thread to run at the SAMPLE_INTERVAL
        statSampler = Executors.newScheduledThreadPool(2);
        statSampler.scheduleAtFixedRate(new StatisticsUpdater(),0, SAMPLE_INTERVAL, TimeUnit.SECONDS);

        // create a statistics diagram every 5 minutes
        diagramUpdater = new DiagramUpdater(gFile);
        statSampler.scheduleAtFixedRate(diagramUpdater,DIAGRAM_INTERVAL,DIAGRAM_INTERVAL,TimeUnit.SECONDS);
    } catch (IOException e) {
        log.warn("could not initialize statistics database: {}",e.getMessage());
    }

}
 
开发者ID:apache,项目名称:marmotta,代码行数:40,代码来源:Statistics.java

示例6: setDef

import org.rrd4j.DsType; //导入依赖的package包/类
public void setDef(String defString) {
    String[] opts = defString.split(",");
    if (opts.length != 5) { // check if correct number of parameters
        logger.warn("invalid number of parameters {}: {}", name, defString);
        return;
    }

    if (opts[0].equals("ABSOLUTE")) { // dsType
        dsType = DsType.ABSOLUTE;
    } else if (opts[0].equals("COUNTER")) {
        dsType = DsType.COUNTER;
    } else if (opts[0].equals("DERIVE")) {
        dsType = DsType.DERIVE;
    } else if (opts[0].equals("GAUGE")) {
        dsType = DsType.GAUGE;
    } else {
        logger.warn("{}: dsType {} not supported", name, opts[0]);
    }

    heartbeat = Integer.parseInt(opts[1]);

    if (opts[2].equals("U")) {
        min = Double.NaN;
    } else {
        min = Double.parseDouble(opts[2]);
    }

    if (opts[3].equals("U")) {
        max = Double.NaN;
    } else {
        max = Double.parseDouble(opts[3]);
    }

    step = Integer.parseInt(opts[4]);

    isInitialized = true; // successfully initialized

    return;
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:40,代码来源:RRD4jService.java

示例7: initDatabase

import org.rrd4j.DsType; //导入依赖的package包/类
protected void initDatabase() throws IOException {
    if (!new File(dataBaseFile).exists()) {
        if (step <= 0) {
            logger.debug("Provided step is invalid, forcing it to " + DEFAULT_STEP_IN_SECONDS);
            step = DEFAULT_STEP_IN_SECONDS;
        }
        logger.info("Node's statistics are saved in " + dataBaseFile);

        RrdDef rrdDef = new RrdDef(dataBaseFile, System.currentTimeMillis() / 1000, step);

        for (String dataSource : dataSources.keySet()) {
            rrdDef.addDatasource(dataSource, DsType.GAUGE, 600, 0, Double.NaN);
        }

        // for step equals 4 seconds
        // Archive of 10 minutes = 600 seconds (4 * 1 * 150) of completely detailed data
        rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, 1, 150);

        // An archive of 1 hour = 3600 seconds (4 * 5 * 180) i.e. 180 averages of 5 steps
        rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, 5, 180);

        // An archive of 4 hours = 14400 seconds (4 * 10 * 360) i.e. 360 averages of 10 steps
        rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, 10, 360);

        // An archive of 8 hours = 28800 seconds (4 * 20 * 360) i.e. 360 averages of 20 steps
        rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, 20, 360);

        // An archive of 24 hours = 86400 seconds (4 * 30 * 720) i.e. 720 averages of 30 steps
        rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, 30, 720);

        // An archive of 1 week = 604800 seconds (4 * 210 * 720) i.e. 720 averages of 210 steps
        rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, 210, 720);

        // An archive of 1 month ~= 28 days = 604800 seconds (4 * 840 * 720) i.e. 720 averages of 840 steps
        rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, 840, 720);

        // An archive of 1 year = 364 days = 31449600 seconds (4 * 10920 * 720) i.e. 720 averages of 10920 steps
        rrdDef.addArchive(ConsolFun.AVERAGE, 0.5, 10920, 720);

        RrdDb dataBase = new RrdDb(rrdDef);
        dataBase.close();
    } else {
        logger.info("Using existing RRD database: " + new File(dataBaseFile).getAbsolutePath());
    }
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:46,代码来源:RRDDataStore.java

示例8: testRrdDb

import org.rrd4j.DsType; //导入依赖的package包/类
public static final void testRrdDb(RrdDb db) throws IOException {
    double value;

    Assert.assertEquals("Invalid date", 920808900L, db.getLastUpdateTime());
    Assert.assertEquals("Invalid step", 300L, db.getHeader().getStep());

    Assert.assertEquals("Invalid number of datasources", 2, db.getDsCount());

    Assert.assertEquals("Invalid name for first data source", "speed", db.getDatasource(0).getName());
    Assert.assertEquals("Invalid dsType for first data source", DsType.COUNTER, db.getDatasource(0).getType());
    Assert.assertEquals("Invalid hearthbeat for first data source", 600, db.getDatasource(0).getHeartbeat());
    Assert.assertTrue("Invalid max value for first data source", Double.isNaN(db.getDatasource(0).getMaxValue()));
    Assert.assertTrue("Invalid min value for first data source", Double.isNaN(db.getDatasource(0).getMinValue()));
    Assert.assertEquals("Invalid last value for first data source", 12405, db.getDatasource(0).getLastValue(), 1e-7);
    Assert.assertEquals("Invalid nan secondes for first data source", 0, db.getDatasource(0).getNanSeconds(), 1e-7);

    Assert.assertEquals("Invalid name for second data source", "weight", db.getDatasource(1).getName());
    Assert.assertEquals("Invalid dsType for second data source", DsType.GAUGE, db.getDatasource(1).getType());
    Assert.assertEquals("Invalid hearthbeat for second data source", 600, db.getDatasource(1).getHeartbeat());
    Assert.assertTrue("Invalid max value for second data source", Double.isNaN(db.getDatasource(1).getMaxValue()));
    Assert.assertTrue("Invalid min value for second data source", Double.isNaN(db.getDatasource(1).getMinValue()));
    value = db.getDatasource(1).getLastValue();
    Assert.assertTrue("Invalid last value for second data source", value == 3.0 || Double.isNaN(value));
    Assert.assertEquals("Invalid nan secondes for second data source", 0, db.getDatasource(1).getNanSeconds(), 1e-7);

    Assert.assertEquals("Invalid number of archives", 2, db.getArcCount());

    Assert.assertEquals("Invalid consolidation function for first archive", ConsolFun.AVERAGE, db.getArchive(0).getConsolFun());
    Assert.assertEquals("Invalid number of steps for first archive", 1, db.getArchive(0).getSteps());
    Assert.assertEquals("Invalid number of row for first archive", 24, db.getArchive(0).getRows());
    Assert.assertEquals("Invalid XFF for first archive", 0.5, db.getArchive(0).getXff(), 1e-7);
    Assert.assertEquals("Invalid start time for first archive", 920802000, db.getArchive(0).getStartTime());
    Assert.assertEquals("Invalid end time for first archive", 920808900, db.getArchive(0).getEndTime());
    value = db.getArchive(0).getArcState(0).getAccumValue();
    Assert.assertTrue("Invalid value for first ds in first archive: " + value, Double.isNaN(value));
    value = db.getArchive(0).getArcState(1).getAccumValue();
    Assert.assertTrue("Invalid value for second ds in first archive: " + value, Double.isNaN(value));

    Assert.assertEquals("Invalid consolidation function for second archive", ConsolFun.AVERAGE, db.getArchive(1).getConsolFun());
    Assert.assertEquals("Invalid number of steps for second archive", 6, db.getArchive(1).getSteps());
    Assert.assertEquals("Invalid number of row for seconde archive", 10, db.getArchive(1).getRows());
    Assert.assertEquals("Invalid XFF for second archive", 0.5, db.getArchive(1).getXff(), 1e-7);
    Assert.assertEquals("Invalid start time for second archive", 920791800, db.getArchive(1).getStartTime());
    Assert.assertEquals("Invalid end time for second archive", 920808000, db.getArchive(1).getEndTime());
    value = db.getArchive(1).getArcState(0).getAccumValue();
    Assert.assertEquals("Invalid value for first ds in second archive: " + value, 1.4316557620e+07, value, 1e-5);
    value = db.getArchive(1).getArcState(1).getAccumValue();
    Assert.assertEquals("Invalid value for second ds in second archive: " + value, 6.0, value, 1e-5);
}
 
开发者ID:ChaosXu,项目名称:rrd4j-cassandra,代码行数:50,代码来源:TestsUtils.java


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