use of nl.nn.adapterframework.statistics.StatisticsKeeper in project iaf by ibissource.
the class ReceiverBase method getProcessStatistics.
protected synchronized StatisticsKeeper getProcessStatistics(int threadsProcessing) {
StatisticsKeeper result;
try {
result = ((StatisticsKeeper) processStatistics.get(threadsProcessing));
} catch (IndexOutOfBoundsException e) {
result = null;
}
if (result == null) {
while (processStatistics.size() < threadsProcessing + 1) {
result = new StatisticsKeeper((processStatistics.size() + 1) + " threads processing");
processStatistics.add(processStatistics.size(), result);
}
}
return (StatisticsKeeper) processStatistics.get(threadsProcessing);
}
use of nl.nn.adapterframework.statistics.StatisticsKeeper in project iaf by ibissource.
the class ReceiverBase method getIdleStatistics.
protected synchronized StatisticsKeeper getIdleStatistics(int threadsProcessing) {
StatisticsKeeper result;
try {
result = ((StatisticsKeeper) idleStatistics.get(threadsProcessing));
} catch (IndexOutOfBoundsException e) {
result = null;
}
if (result == null) {
while (idleStatistics.size() < threadsProcessing + 1) {
result = new StatisticsKeeper((idleStatistics.size()) + " threads processing");
idleStatistics.add(idleStatistics.size(), result);
}
}
return (StatisticsKeeper) idleStatistics.get(threadsProcessing);
}
use of nl.nn.adapterframework.statistics.StatisticsKeeper in project iaf by ibissource.
the class SenderSeries method doSendMessage.
public String doSendMessage(String correlationID, String message, ParameterResolutionContext prc) throws SenderException, TimeOutException {
long t1 = System.currentTimeMillis();
for (Iterator<ISender> it = getSenderIterator(); it.hasNext(); ) {
ISender sender = it.next();
if (log.isDebugEnabled())
log.debug(getLogPrefix() + "sending correlationID [" + correlationID + "] message [" + message + "] to sender [" + sender.getName() + "]");
if (sender instanceof ISenderWithParameters) {
message = ((ISenderWithParameters) sender).sendMessage(correlationID, message, prc);
} else {
message = sender.sendMessage(correlationID, message);
}
long t2 = System.currentTimeMillis();
StatisticsKeeper sk = getStatisticsKeeper(sender);
sk.addValue(t2 - t1);
t1 = t2;
}
return message;
}
use of nl.nn.adapterframework.statistics.StatisticsKeeper in project iaf by ibissource.
the class SenderSeries method setSender.
public void setSender(ISender sender) {
senderList.add(sender);
// set synchronous to isSynchronous of the last Sender added
setSynchronous(sender.isSynchronous());
statisticsMap.put(sender, new StatisticsKeeper("-> " + ClassUtils.nameOf(sender)));
}
use of nl.nn.adapterframework.statistics.StatisticsKeeper in project iaf by ibissource.
the class ShowAdapterStatistics method executeSub.
public ActionForward executeSub(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
// Initialize action
initAction(request);
String adapterName = request.getParameter("adapterName");
String deepString = request.getParameter("deep");
boolean deep = "true".equals(deepString);
Adapter adapter = (Adapter) ibisManager.getRegisteredAdapter(adapterName);
XmlBuilder adapterXML = new XmlBuilder("adapterStatistics");
adapterXML.addAttribute("name", adapter.getName());
adapterXML.addAttribute("state", adapter.getRunState().toString());
adapterXML.addAttribute("upSince", adapter.getStatsUpSince());
adapterXML.addAttribute("lastMessageDate", adapter.getLastMessageDate());
adapterXML.addAttribute("messagesInProcess", "" + adapter.getNumOfMessagesInProcess());
adapterXML.addAttribute("messagesProcessed", "" + adapter.getNumOfMessagesProcessed());
adapterXML.addAttribute("messagesInError", "" + adapter.getNumOfMessagesInError());
StatisticsKeeper st = adapter.getStatsMessageProcessingDuration();
adapterXML.addSubElement(statisticsKeeperToXmlBuilder(st, "messageProcessingDuration", deep));
XmlBuilder messagesReceivedByHour = new XmlBuilder("messagesStartProcessingByHour");
adapterXML.addSubElement(messagesReceivedByHour);
long[] numOfMessagesStartProcessingByHour = adapter.getNumOfMessagesStartProcessingByHour();
for (int i = 0; i < numOfMessagesStartProcessingByHour.length; i++) {
XmlBuilder item = new XmlBuilder("item");
messagesReceivedByHour.addSubElement(item);
String startTime;
if (i < 10) {
startTime = "0" + i + ":00";
} else {
startTime = i + ":00";
}
item.addAttribute("startTime", startTime);
item.addAttribute("count", numOfMessagesStartProcessingByHour[i]);
}
Iterator recIt = adapter.getReceiverIterator();
if (recIt.hasNext()) {
XmlBuilder receiversXML = new XmlBuilder("receivers");
while (recIt.hasNext()) {
IReceiver receiver = (IReceiver) recIt.next();
XmlBuilder receiverXML = new XmlBuilder("receiver");
receiversXML.addSubElement(receiverXML);
receiverXML.addAttribute("name", receiver.getName());
receiverXML.addAttribute("class", receiver.getClass().getName());
receiverXML.addAttribute("messagesReceived", "" + receiver.getMessagesReceived());
receiverXML.addAttribute("messagesRetried", "" + receiver.getMessagesRetried());
/*
if (receiver instanceof HasSender) {
ISender sender = ((HasSender) receiver).getSender();
if (sender != null)
receiverXML.addAttribute("senderName", sender.getName());
}
*/
if (receiver instanceof IReceiverStatistics) {
IReceiverStatistics statReceiver = (IReceiverStatistics) receiver;
Iterator statsIter;
statsIter = statReceiver.getProcessStatisticsIterator();
if (statsIter != null) {
XmlBuilder procStatsXML = new XmlBuilder("procStats");
// procStatsXML.addSubElement(statisticsKeeperToXmlBuilder(statReceiver.getResponseSizeStatistics(), "stat"));
while (statsIter.hasNext()) {
StatisticsKeeper pstat = (StatisticsKeeper) statsIter.next();
procStatsXML.addSubElement(statisticsKeeperToXmlBuilder(pstat, "stat", deep));
}
receiverXML.addSubElement(procStatsXML);
}
statsIter = statReceiver.getIdleStatisticsIterator();
if (statsIter != null) {
XmlBuilder procStatsXML = new XmlBuilder("idleStats");
while (statsIter.hasNext()) {
StatisticsKeeper pstat = (StatisticsKeeper) statsIter.next();
procStatsXML.addSubElement(statisticsKeeperToXmlBuilder(pstat, "stat", deep));
}
receiverXML.addSubElement(procStatsXML);
}
}
}
adapterXML.addSubElement(receiversXML);
}
StatisticsKeeperToXml handler = new StatisticsKeeperToXml(adapterXML, deep);
handler.configure();
Object handle = handler.start(null, null, null);
try {
Object pipelineData = handler.openGroup(handle, null, "pipeline");
adapter.getPipeLine().iterateOverStatistics(handler, pipelineData, HasStatistics.STATISTICS_ACTION_FULL);
} catch (SenderException e) {
log.error(e);
} finally {
handler.end(handle);
}
if (log.isDebugEnabled()) {
log.debug("about to set adapterStatistics [" + adapterXML.toXML() + "]");
// XmlBuilder alt = new XmlBuilder("alt");
// StatisticsKeeperToXml hh = new StatisticsKeeperToXml(alt);
// adapter.forEachStatisticsKeeper(hh,HasStatistics.STATISTICS_ACTION_NONE);
// log.debug("alternative ["+alt.toXML()+"]");
}
request.setAttribute("adapterStatistics", adapterXML.toXML());
// Forward control to the specified success URI
log.debug("forward to success");
return (mapping.findForward("success"));
}
Aggregations