use of nl.nn.adapterframework.core.IReceiver in project iaf by ibissource.
the class ShowAdapterStatistics method getStatistics.
@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/adapters/{adapterName}/statistics")
@Relation("statistics")
@Produces(MediaType.APPLICATION_JSON)
public Response getStatistics(@PathParam("adapterName") String adapterName) throws ApiException {
initBase(servletConfig);
Map<String, Object> statisticsMap = new HashMap<String, Object>();
Adapter adapter = (Adapter) ibisManager.getRegisteredAdapter(adapterName);
if (adapter == null) {
throw new ApiException("Adapter not found!");
}
StatisticsKeeper sk = adapter.getStatsMessageProcessingDuration();
statisticsMap.put("totalMessageProccessingTime", statisticsKeeperToMapBuilder(sk));
long[] numOfMessagesStartProcessingByHour = adapter.getNumOfMessagesStartProcessingByHour();
List<Map<String, Object>> hourslyStatistics = new ArrayList<Map<String, Object>>();
for (int i = 0; i < numOfMessagesStartProcessingByHour.length; i++) {
Map<String, Object> item = new HashMap<String, Object>(2);
String startTime;
if (i < 10) {
startTime = "0" + i + ":00";
} else {
startTime = i + ":00";
}
item.put("time", startTime);
item.put("count", numOfMessagesStartProcessingByHour[i]);
hourslyStatistics.add(item);
}
statisticsMap.put("hourly", hourslyStatistics);
List<Map<String, Object>> receivers = new ArrayList<Map<String, Object>>();
Iterator<?> recIt = adapter.getReceiverIterator();
if (recIt.hasNext()) {
while (recIt.hasNext()) {
IReceiver receiver = (IReceiver) recIt.next();
Map<String, Object> receiverMap = new HashMap<String, Object>();
receiverMap.put("name", receiver.getName());
receiverMap.put("class", receiver.getClass().getName());
receiverMap.put("messagesReceived", receiver.getMessagesReceived());
receiverMap.put("messagesRetried", receiver.getMessagesRetried());
if (receiver instanceof IReceiverStatistics) {
IReceiverStatistics statReceiver = (IReceiverStatistics) receiver;
Iterator<?> statsIter;
statsIter = statReceiver.getProcessStatisticsIterator();
if (statsIter != null) {
ArrayList<Map<String, Object>> procStatsMap = new ArrayList<Map<String, Object>>();
// procStatsXML.addSubElement(statisticsKeeperToXmlBuilder(statReceiver.getResponseSizeStatistics(), "stat"));
while (statsIter.hasNext()) {
StatisticsKeeper pstat = (StatisticsKeeper) statsIter.next();
procStatsMap.add(statisticsKeeperToMapBuilder(pstat));
}
receiverMap.put("processing", procStatsMap);
}
statsIter = statReceiver.getIdleStatisticsIterator();
if (statsIter != null) {
ArrayList<Map<String, Object>> idleStatsMap = new ArrayList<Map<String, Object>>();
while (statsIter.hasNext()) {
StatisticsKeeper pstat = (StatisticsKeeper) statsIter.next();
idleStatsMap.add(statisticsKeeperToMapBuilder(pstat));
}
receiverMap.put("idle", idleStatsMap);
}
receivers.add(receiverMap);
}
}
}
statisticsMap.put("receivers", receivers);
Map<String, Object> tmp = new HashMap<String, Object>();
StatisticsKeeperToXml handler = new StatisticsKeeperToXml(tmp);
handler.configure();
Object handle = handler.start(null, null, null);
try {
adapter.getPipeLine().iterateOverStatistics(handler, tmp, HasStatistics.STATISTICS_ACTION_FULL);
statisticsMap.put("durationPerPipe", tmp.get("pipeStats"));
statisticsMap.put("sizePerPipe", tmp.get("sizeStats"));
} catch (SenderException e) {
log.error(e);
} finally {
handler.end(handle);
}
return Response.status(Response.Status.CREATED).entity(statisticsMap).build();
}
use of nl.nn.adapterframework.core.IReceiver in project iaf by ibissource.
the class Webservices method getLogDirectory.
@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/webservices")
@Relation("webservices")
@Produces(MediaType.APPLICATION_JSON)
public Response getLogDirectory() throws ApiException {
initBase(servletConfig);
Map<String, Object> returnMap = new HashMap<String, Object>();
List<Map<String, Object>> webServices = new ArrayList<Map<String, Object>>();
for (IAdapter a : ibisManager.getRegisteredAdapters()) {
Adapter adapter = (Adapter) a;
Iterator<IReceiver> recIt = adapter.getReceiverIterator();
while (recIt.hasNext()) {
IReceiver receiver = recIt.next();
if (receiver instanceof ReceiverBase) {
ReceiverBase rb = (ReceiverBase) receiver;
IListener listener = rb.getListener();
if (listener instanceof RestListener) {
RestListener rl = (RestListener) listener;
if (rl.isView()) {
Map<String, Object> service = new HashMap<String, Object>(2);
service.put("name", rb.getName());
service.put("uriPattern", rl.getUriPattern());
webServices.add(service);
}
}
}
}
}
returnMap.put("services", webServices);
List<Map<String, Object>> wsdls = new ArrayList<Map<String, Object>>();
for (IAdapter a : ibisManager.getRegisteredAdapters()) {
Map<String, Object> wsdlMap = new HashMap<String, Object>(2);
try {
Adapter adapter = (Adapter) a;
Wsdl wsdl = new Wsdl(adapter.getPipeLine());
wsdlMap.put("name", wsdl.getName());
wsdlMap.put("extention", getWsdlExtention());
} catch (Exception e) {
wsdlMap.put("name", a.getName());
if (e.getMessage() != null) {
wsdlMap.put("error", e.getMessage());
} else {
wsdlMap.put("error", e.toString());
}
}
wsdls.add(wsdlMap);
}
returnMap.put("wsdls", wsdls);
return Response.status(Response.Status.OK).entity(returnMap).build();
}
use of nl.nn.adapterframework.core.IReceiver in project iaf by ibissource.
the class ShowSecurityItems method addRegisteredAdapters.
private void addRegisteredAdapters(XmlBuilder securityItems) {
XmlBuilder registeredAdapters = new XmlBuilder("registeredAdapters");
securityItems.addSubElement(registeredAdapters);
for (IAdapter iAdapter : ibisManager.getRegisteredAdapters()) {
Adapter adapter = (Adapter) iAdapter;
XmlBuilder adapterXML = new XmlBuilder("adapter");
registeredAdapters.addSubElement(adapterXML);
adapterXML.addAttribute("name", adapter.getName());
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());
if (receiver instanceof HasSender) {
ISender sender = ((HasSender) receiver).getSender();
if (sender != null) {
receiverXML.addAttribute("senderName", sender.getName());
}
}
}
adapterXML.addSubElement(receiversXML);
}
// make list of pipes to be displayed in configuration status
XmlBuilder pipesElem = new XmlBuilder("pipes");
adapterXML.addSubElement(pipesElem);
PipeLine pipeline = adapter.getPipeLine();
for (int i = 0; i < pipeline.getPipes().size(); i++) {
IPipe pipe = pipeline.getPipe(i);
String pipename = pipe.getName();
if (pipe instanceof MessageSendingPipe) {
MessageSendingPipe msp = (MessageSendingPipe) pipe;
XmlBuilder pipeElem = new XmlBuilder("pipe");
pipeElem.addAttribute("name", pipename);
ISender sender = msp.getSender();
pipeElem.addAttribute("sender", ClassUtils.nameOf(sender));
pipesElem.addSubElement(pipeElem);
if (sender instanceof WebServiceSender) {
WebServiceSender s = (WebServiceSender) sender;
String certificate = s.getCertificate();
if (StringUtils.isNotEmpty(certificate)) {
XmlBuilder certElem = new XmlBuilder("certificate");
certElem.addAttribute("name", certificate);
String certificateAuthAlias = s.getCertificateAuthAlias();
certElem.addAttribute("authAlias", certificateAuthAlias);
URL certificateUrl = ClassUtils.getResourceURL(this, certificate);
if (certificateUrl == null) {
certElem.addAttribute("url", "");
pipeElem.addSubElement(certElem);
XmlBuilder infoElem = new XmlBuilder("info");
infoElem.setCdataValue("*** ERROR ***");
certElem.addSubElement(infoElem);
} else {
certElem.addAttribute("url", certificateUrl.toString());
pipeElem.addSubElement(certElem);
String certificatePassword = s.getCertificatePassword();
CredentialFactory certificateCf = new CredentialFactory(certificateAuthAlias, null, certificatePassword);
String keystoreType = s.getKeystoreType();
addCertificateInfo(certElem, certificateUrl, certificateCf.getPassword(), keystoreType, "Certificate chain");
}
}
} else {
if (sender instanceof HttpSender) {
HttpSender s = (HttpSender) sender;
String certificate = s.getCertificate();
if (StringUtils.isNotEmpty(certificate)) {
XmlBuilder certElem = new XmlBuilder("certificate");
certElem.addAttribute("name", certificate);
String certificateAuthAlias = s.getCertificateAuthAlias();
certElem.addAttribute("authAlias", certificateAuthAlias);
URL certificateUrl = ClassUtils.getResourceURL(this, certificate);
if (certificateUrl == null) {
certElem.addAttribute("url", "");
pipeElem.addSubElement(certElem);
XmlBuilder infoElem = new XmlBuilder("info");
infoElem.setCdataValue("*** ERROR ***");
certElem.addSubElement(infoElem);
} else {
certElem.addAttribute("url", certificateUrl.toString());
pipeElem.addSubElement(certElem);
String certificatePassword = s.getCertificatePassword();
CredentialFactory certificateCf = new CredentialFactory(certificateAuthAlias, null, certificatePassword);
String keystoreType = s.getKeystoreType();
addCertificateInfo(certElem, certificateUrl, certificateCf.getPassword(), keystoreType, "Certificate chain");
}
}
} else {
if (sender instanceof FtpSender) {
FtpSender s = (FtpSender) sender;
String certificate = s.getCertificate();
if (StringUtils.isNotEmpty(certificate)) {
XmlBuilder certElem = new XmlBuilder("certificate");
certElem.addAttribute("name", certificate);
String certificateAuthAlias = s.getCertificateAuthAlias();
certElem.addAttribute("authAlias", certificateAuthAlias);
URL certificateUrl = ClassUtils.getResourceURL(this, certificate);
if (certificateUrl == null) {
certElem.addAttribute("url", "");
pipeElem.addSubElement(certElem);
XmlBuilder infoElem = new XmlBuilder("info");
infoElem.setCdataValue("*** ERROR ***");
certElem.addSubElement(infoElem);
} else {
certElem.addAttribute("url", certificateUrl.toString());
pipeElem.addSubElement(certElem);
String certificatePassword = s.getCertificatePassword();
CredentialFactory certificateCf = new CredentialFactory(certificateAuthAlias, null, certificatePassword);
String keystoreType = s.getCertificateType();
addCertificateInfo(certElem, certificateUrl, certificateCf.getPassword(), keystoreType, "Certificate chain");
}
}
}
}
}
}
}
}
}
use of nl.nn.adapterframework.core.IReceiver in project iaf by ibissource.
the class EjbListenerPortConnector method getListenerPortName.
/**
* Get the name of the ListenerPort to look up as WebSphere MBean.
*
* Construct the name of the WebSphere listenerport according to the
* following logic:
* <ol>
* <li>If the property 'listenerPort' is set in the configuration, then use that</li>
* <li>Otherwise, concatenate the configuration-name with the receiver-name, replaces all spaces with minus-signs, and append 'ListenerPort'
* </ol>
*/
protected String getListenerPortName(IPortConnectedListener listener) {
String name = listener.getListenerPort();
if (name == null) {
IReceiver receiver = listener.getReceiver();
name = configuration.getConfigurationName() + '-' + receiver.getName() + LISTENER_PORTNAME_SUFFIX;
name = name.replace(' ', '-').replaceAll("(:|\\(|\\)|\\\\|/|\\||<|>|&|\\^|%)", "");
}
return name;
}
use of nl.nn.adapterframework.core.IReceiver in project iaf by ibissource.
the class FxfListener method warn.
private void warn(String msg, Throwable t) {
log.warn(msg, t);
IReceiver iReceiver = getReceiver();
if (iReceiver != null && iReceiver instanceof ReceiverBase) {
ReceiverBase rb = (ReceiverBase) iReceiver;
IAdapter iAdapter = rb.getAdapter();
if (iAdapter != null) {
iAdapter.getMessageKeeper().add("WARNING: " + msg + (t != null ? ": " + t.getMessage() : ""), MessageKeeperMessage.WARN_LEVEL);
}
}
}
Aggregations