use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.
the class StatisticsKeeperXmlBuilder method handleScalar.
public void handleScalar(Object data, String scalarName, String value) {
XmlBuilder context = (XmlBuilder) data;
addNumber(context, scalarName, value);
}
use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.
the class StatisticsKeeperXmlBuilder method openGroup.
public Object openGroup(Object parentData, String name, String type) {
XmlBuilder context = (XmlBuilder) parentData;
XmlBuilder group = new XmlBuilder(GROUP_ELEMENT);
group.addAttribute("name", name);
group.addAttribute("type", type);
context.addSubElement(group);
return group;
}
use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.
the class StatisticsKeeperXmlBuilder method statisticsKeeperToXmlBuilder.
public XmlBuilder statisticsKeeperToXmlBuilder(StatisticsKeeper sk, String elementName) {
if (sk == null) {
return null;
}
String name = sk.getName();
XmlBuilder container = new XmlBuilder(elementName);
if (name != null)
container.addAttribute("name", name);
XmlBuilder cumulativeStats = new XmlBuilder(STATKEEPER_SUMMARY_ELEMENT);
for (int i = 0; i < sk.getItemCount(); i++) {
Object item = sk.getItemValue(i);
if (item == null) {
addNumber(cumulativeStats, sk.getItemName(i), "-");
} else {
switch(sk.getItemType(i)) {
case StatisticsKeeper.ITEM_TYPE_INTEGER:
addNumber(cumulativeStats, sk.getItemName(i), "" + (Long) item);
break;
case StatisticsKeeper.ITEM_TYPE_TIME:
addNumber(cumulativeStats, sk.getItemName(i), df.format(item));
break;
case StatisticsKeeper.ITEM_TYPE_FRACTION:
addNumber(cumulativeStats, sk.getItemName(i), "" + pf.format(((Double) item).doubleValue() * 100) + "%");
break;
}
}
}
container.addSubElement(cumulativeStats);
XmlBuilder intervalStats = new XmlBuilder(STATKEEPER_INTERVAL_ELEMENT);
for (int i = 0; i < sk.getIntervalItemCount(); i++) {
Object item = sk.getIntervalItemValue(i);
if (item == null) {
addNumber(intervalStats, sk.getIntervalItemName(i), "-");
} else {
switch(sk.getIntervalItemType(i)) {
case StatisticsKeeper.ITEM_TYPE_INTEGER:
addNumber(intervalStats, sk.getIntervalItemName(i), "" + (Long) item);
break;
case StatisticsKeeper.ITEM_TYPE_TIME:
addNumber(intervalStats, sk.getIntervalItemName(i), df.format(item));
break;
case StatisticsKeeper.ITEM_TYPE_FRACTION:
addNumber(intervalStats, sk.getIntervalItemName(i), "" + pf.format(((Double) item).doubleValue() * 100) + "%");
break;
}
}
}
container.addSubElement(intervalStats);
return container;
}
use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.
the class StatisticsKeeperXmlBuilder method start.
public Object start(Date now, Date mainMark, Date detailMark) {
log.debug("StatisticsKeeperXmlBuilder.start()");
long freeMem = Runtime.getRuntime().freeMemory();
long totalMem = Runtime.getRuntime().totalMemory();
XmlBuilder root = new XmlBuilder(ROOT_ELEMENT);
root.addAttribute("version", STATISTICS_XML_VERSION);
root.addAttribute("heapSize", Long.toString(totalMem - freeMem));
root.addAttribute("totalMemory", Long.toString(totalMem));
root.addAttribute("timestamp", DateUtils.format(now, DateUtils.FORMAT_GENERICDATETIME));
root.addAttribute("intervalStart", DateUtils.format(mainMark, DateUtils.FORMAT_GENERICDATETIME));
root.addAttribute("host", Misc.getHostname());
root.addAttribute("instance", AppConstants.getInstance().getProperty("instance.name"));
addPeriodIndicator(root, now, new String[][] { PERIOD_FORMAT_HOUR, PERIOD_FORMAT_DATEHOUR }, PERIOD_ALLOWED_LENGTH_HOUR, "", mainMark);
addPeriodIndicator(root, now, new String[][] { PERIOD_FORMAT_DAY, PERIOD_FORMAT_DATE, PERIOD_FORMAT_WEEKDAY }, PERIOD_ALLOWED_LENGTH_DAY, "", mainMark);
addPeriodIndicator(root, now, new String[][] { PERIOD_FORMAT_WEEK, PERIOD_FORMAT_YEARWEEK }, PERIOD_ALLOWED_LENGTH_WEEK, "", mainMark);
addPeriodIndicator(root, now, new String[][] { PERIOD_FORMAT_MONTH, PERIOD_FORMAT_YEARMONTH }, PERIOD_ALLOWED_LENGTH_MONTH, "", mainMark);
addPeriodIndicator(root, now, new String[][] { PERIOD_FORMAT_YEAR }, PERIOD_ALLOWED_LENGTH_YEAR, "", mainMark);
if (detailMark != null) {
root.addAttribute("intervalStartDetail", DateUtils.format(detailMark, DateUtils.FORMAT_GENERICDATETIME));
addPeriodIndicator(root, now, new String[][] { PERIOD_FORMAT_HOUR, PERIOD_FORMAT_DATEHOUR }, PERIOD_ALLOWED_LENGTH_HOUR, "Detail", detailMark);
addPeriodIndicator(root, now, new String[][] { PERIOD_FORMAT_DAY, PERIOD_FORMAT_DATE, PERIOD_FORMAT_WEEKDAY }, PERIOD_ALLOWED_LENGTH_DAY, "Detail", detailMark);
addPeriodIndicator(root, now, new String[][] { PERIOD_FORMAT_WEEK, PERIOD_FORMAT_YEARWEEK }, PERIOD_ALLOWED_LENGTH_WEEK, "Detail", detailMark);
addPeriodIndicator(root, now, new String[][] { PERIOD_FORMAT_MONTH, PERIOD_FORMAT_YEARMONTH }, PERIOD_ALLOWED_LENGTH_MONTH, "Detail", detailMark);
addPeriodIndicator(root, now, new String[][] { PERIOD_FORMAT_YEAR }, PERIOD_ALLOWED_LENGTH_YEAR, "Detail", detailMark);
}
return root;
}
use of nl.nn.adapterframework.util.XmlBuilder in project iaf by ibissource.
the class StatisticsKeeperXmlBuilder method handleStatisticsKeeper.
public void handleStatisticsKeeper(Object data, StatisticsKeeper sk) {
XmlBuilder context = (XmlBuilder) data;
XmlBuilder item = statisticsKeeperToXmlBuilder(sk, STATKEEPER_ELEMENT);
if (item != null) {
context.addSubElement(item);
}
}
Aggregations