Search in sources :

Example 16 with StatisticsKeeper

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);
}
Also used : StatisticsKeeper(nl.nn.adapterframework.statistics.StatisticsKeeper)

Example 17 with StatisticsKeeper

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);
}
Also used : StatisticsKeeper(nl.nn.adapterframework.statistics.StatisticsKeeper)

Example 18 with StatisticsKeeper

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;
}
Also used : ISender(nl.nn.adapterframework.core.ISender) ISenderWithParameters(nl.nn.adapterframework.core.ISenderWithParameters) StatisticsKeeper(nl.nn.adapterframework.statistics.StatisticsKeeper)

Example 19 with StatisticsKeeper

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)));
}
Also used : StatisticsKeeper(nl.nn.adapterframework.statistics.StatisticsKeeper)

Example 20 with StatisticsKeeper

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"));
}
Also used : Adapter(nl.nn.adapterframework.core.Adapter) IReceiver(nl.nn.adapterframework.core.IReceiver) Iterator(java.util.Iterator) XmlBuilder(nl.nn.adapterframework.util.XmlBuilder) StatisticsKeeper(nl.nn.adapterframework.statistics.StatisticsKeeper) IReceiverStatistics(nl.nn.adapterframework.core.IReceiverStatistics) SenderException(nl.nn.adapterframework.core.SenderException)

Aggregations

StatisticsKeeper (nl.nn.adapterframework.statistics.StatisticsKeeper)20 PipeRunException (nl.nn.adapterframework.core.PipeRunException)5 PipeRunResult (nl.nn.adapterframework.core.PipeRunResult)5 AbstractPipe (nl.nn.adapterframework.pipes.AbstractPipe)5 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)4 SenderException (nl.nn.adapterframework.core.SenderException)4 HashMap (java.util.HashMap)3 Iterator (java.util.Iterator)3 PipeForward (nl.nn.adapterframework.core.PipeForward)3 SizeStatisticsKeeper (nl.nn.adapterframework.statistics.SizeStatisticsKeeper)3 XmlBuilder (nl.nn.adapterframework.util.XmlBuilder)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Adapter (nl.nn.adapterframework.core.Adapter)2 IExtendedPipe (nl.nn.adapterframework.core.IExtendedPipe)2 IPipe (nl.nn.adapterframework.core.IPipe)2 IReceiver (nl.nn.adapterframework.core.IReceiver)2 IReceiverStatistics (nl.nn.adapterframework.core.IReceiverStatistics)2 ISender (nl.nn.adapterframework.core.ISender)2