本文整理汇总了Java中org.rrd4j.core.FetchRequest类的典型用法代码示例。如果您正苦于以下问题:Java FetchRequest类的具体用法?Java FetchRequest怎么用?Java FetchRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FetchRequest类属于org.rrd4j.core包,在下文中一共展示了FetchRequest类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: recentMetrics
import org.rrd4j.core.FetchRequest; //导入依赖的package包/类
@Override
public double[] recentMetrics(String metricType, int duration, TimeUnit unit) {
try {
checkArgument(rrdDb.containsDs(metricType), NON_EXIST_METRIC);
long endTime = rrdDb.getLastUpdateTime();
long startTime = endTime - TimeUnit.SECONDS.convert(duration, unit);
if (checkTimeRange(startTime, endTime)) {
FetchRequest fr = rrdDb.createFetchRequest(CONSOL_FUNCTION, startTime, endTime);
return arrangeDataPoints(fr.fetchData().getValues(metricType));
} else {
log.warn("Data projection is out-of-range");
return new double[0];
}
} catch (IOException e) {
log.error("Failed to obtain metric values due to {}", e);
return new double[0];
}
}
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:DefaultMetricsDatabase.java
示例2: metrics
import org.rrd4j.core.FetchRequest; //导入依赖的package包/类
@Override
public double[] metrics(String metricType, long startTime, long endTime) {
try {
checkArgument(rrdDb.containsDs(metricType), NON_EXIST_METRIC);
if (checkTimeRange(startTime, endTime)) {
FetchRequest fr = rrdDb.createFetchRequest(CONSOL_FUNCTION, startTime, endTime);
return arrangeDataPoints(fr.fetchData().getValues(metricType));
} else {
log.warn("Data projection is out-of-range");
return new double[0];
}
} catch (IOException e) {
log.error("Failed to obtain metric values due to {}", e);
return new double[0];
}
}
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:DefaultMetricsDatabase.java
示例3: query
import org.rrd4j.core.FetchRequest; //导入依赖的package包/类
public double query(String dsName, long startTimestamp, long endTimestamp, ConsolFun consolidationFunction) {
long tStart = convertToUnixTimestamp(startTimestamp);
long tEnd = convertToUnixTimestamp(endTimestamp);
if (tStart == tEnd) {
this.logger.warn("Shifting end time by 1 second because it is identical with the start time.");
tEnd++;
}
try {
final FetchRequest request = this.rrdDb.createFetchRequest(consolidationFunction, tStart, tEnd);
final FetchData fetchData = request.fetchData();
return fetchData.getAggregate(dsName, consolidationFunction);
} catch (IOException e) {
e.printStackTrace();
return Double.NaN;
}
}
开发者ID:daqcri,项目名称:rheem,代码行数:17,代码来源:RrdAccessor.java
示例4: addRrdData
import org.rrd4j.core.FetchRequest; //导入依赖的package包/类
private Map<Long, ArrayList<String>> addRrdData(
Map<Long, ArrayList<String>> data, String itemName,
ConsolFun consilidationFunction, Date timeBegin, Date timeEnd,
long resolution) throws IOException {
RrdDb rrdDb = new RrdDb(RRD_FOLDER + File.separator + itemName + ".rrd");
FetchRequest fetchRequest = rrdDb.createFetchRequest(
consilidationFunction, Util.getTimestamp(timeBegin),
Util.getTimestamp(timeEnd), resolution);
FetchData fetchData = fetchRequest.fetchData();
// logger.info(fetchData.toString());
long[] timestamps = fetchData.getTimestamps();
double[][] values = fetchData.getValues();
logger.debug("RRD fetch returned '{}' rows and '{}' columns",
fetchData.getRowCount(), fetchData.getColumnCount());
for (int row = 0; row < fetchData.getRowCount(); row++) {
// change to microseconds
long time = timestamps[row] * 1000L;
if (!data.containsKey(time)) {
data.put(time, new ArrayList<String>());
}
ArrayList<String> vals = data.get(time);
int indexOffset = vals.size();
for (int dsIndex = 0; dsIndex < fetchData.getColumnCount(); dsIndex++) {
vals.add(dsIndex + indexOffset,
formatDouble(values[dsIndex][row], "null", true));
}
}
rrdDb.close();
return data;
}
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:35,代码来源:RrdResource.java
示例5: addRrdData
import org.rrd4j.core.FetchRequest; //导入依赖的package包/类
private Map<Long, ArrayList<String>> addRrdData(Map<Long, ArrayList<String>> data, String itemName,
ConsolFun consilidationFunction, Date timeBegin, Date timeEnd, long resolution) throws IOException {
RrdDb rrdDb = new RrdDb(RRD_FOLDER + File.separator + itemName + ".rrd");
FetchRequest fetchRequest = rrdDb.createFetchRequest(consilidationFunction, Util.getTimestamp(timeBegin),
Util.getTimestamp(timeEnd), resolution);
FetchData fetchData = fetchRequest.fetchData();
// logger.info(fetchData.toString());
long[] timestamps = fetchData.getTimestamps();
double[][] values = fetchData.getValues();
logger.debug("RRD fetch returned '{}' rows and '{}' columns", fetchData.getRowCount(),
fetchData.getColumnCount());
for (int row = 0; row < fetchData.getRowCount(); row++) {
// change to microseconds
long time = timestamps[row] * 1000;
if (!data.containsKey(time)) {
data.put(time, new ArrayList<String>());
}
ArrayList<String> vals = data.get(time);
int indexOffset = vals.size();
for (int dsIndex = 0; dsIndex < fetchData.getColumnCount(); dsIndex++) {
vals.add(dsIndex + indexOffset, formatDouble(values[dsIndex][row], "null", true));
}
}
rrdDb.close();
return data;
}
开发者ID:openhab,项目名称:openhab2-addons,代码行数:31,代码来源:ChartResource.java
示例6: addPulseValue
import org.rrd4j.core.FetchRequest; //导入依赖的package包/类
/**
* Synchronized method to add a pulse value to the database.
*
* @param aPulseValue
* the pulse value
* @return true on success, false otherwise.
*/
public synchronized Boolean addPulseValue(int aPulseValue) {
Pulse pulse = new Pulse();
pulse.setTime(new Date().getTime());
pulse.setValue(aPulseValue);
Boolean success = root.pulses.add(pulse);
/* TODO-tof: necessary for every pulse value? */
db.commit();
Log.d(TAG, "Saved pulse " + success);
long date = new Date().getTime();
String rrdValue = date + ":" + aPulseValue;
Log.i(TAG, "RRD Value: " + rrdValue);
try {
rrdSample.setAndUpdate(rrdValue);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
long startTime = date - (12 * 60 * 60L);
FetchRequest fetchRequest = rrdDb.createFetchRequest(ConsolFun.MAX,
startTime, date);
Log.d(TAG, fetchRequest.dump());
return success;
}
开发者ID:moguai2k,项目名称:ProjektWerkstatt13,代码行数:36,代码来源:PerstStorage.java
示例7: getAttributesHistory
import org.rrd4j.core.FetchRequest; //导入依赖的package包/类
@Override
public String getAttributesHistory(String objectName, String[] attrs, String range) throws IOException {
RrdDb db = new RrdDb(statBaseName, true);
long timeEnd = db.getLastUpdateTime();
// force float separator for JSON parsing
DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols(Locale.US);
otherSymbols.setDecimalSeparator('.');
// formatting will greatly reduce response size
DecimalFormat formatter = new DecimalFormat("###.###", otherSymbols);
// construct the JSON response directly in a String
StringBuilder result = new StringBuilder();
result.append("{");
for (int i = 0; i < attrs.length; i++) {
String dataSource = RRDSigarDataStore.toDataStoreName(attrs[i] + "-" + objectName);
char zone = range.charAt(0);
long timeStart;
switch (zone) {
default:
case 'a': // 1 minute
timeStart = timeEnd - 60;
break;
case 'm': // 10 minute
timeStart = timeEnd - 60 * 10;
break;
case 'h': // 1 hours
timeStart = timeEnd - 60 * 60;
break;
case 'H': // 8 hours
timeStart = timeEnd - 60 * 60 * 8;
break;
case 'd': // 1 day
timeStart = timeEnd - 60 * 60 * 24;
break;
case 'w': // 1 week
timeStart = timeEnd - 60 * 60 * 24 * 7;
break;
case 'M': // 1 month
timeStart = timeEnd - 60 * 60 * 24 * 28;
break;
case 'y': // 1 year
timeStart = timeEnd - 60 * 60 * 24 * 365;
break;
}
FetchRequest req = db.createFetchRequest(ConsolFun.AVERAGE, timeStart, timeEnd);
req.setFilter(dataSource);
FetchData fetchData = req.fetchData();
result.append("\"").append(dataSource).append("\":[");
double[] values = fetchData.getValues(dataSource);
for (int j = 0; j < values.length - 1; j++) {
if (Double.compare(Double.NaN, values[j]) == 0) {
result.append("null");
} else {
result.append(formatter.format(values[j]));
}
if (j < values.length - 2)
result.append(',');
}
result.append(']');
if (i < attrs.length - 1)
result.append(',');
}
result.append("}");
db.close();
return result.toString();
}
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:77,代码来源:SigarProcesses.java
注:本文中的org.rrd4j.core.FetchRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论