use of nl.nn.adapterframework.core.Adapter 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.Adapter in project iaf by ibissource.
the class ShowConfigurationStatus method getAdapters.
@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/adapters")
@Produces(MediaType.APPLICATION_JSON)
public Response getAdapters(@QueryParam("expanded") String expanded, @QueryParam("showPendingMsgCount") boolean showPendingMsgCount) throws ApiException {
initBase(servletConfig);
if (ibisManager == null) {
throw new ApiException("Config not found!");
}
Map<String, Object> adapterList = new HashMap<String, Object>();
List<IAdapter> registeredAdapters = ibisManager.getRegisteredAdapters();
for (Iterator<IAdapter> adapterIt = registeredAdapters.iterator(); adapterIt.hasNext(); ) {
Adapter adapter = (Adapter) adapterIt.next();
Map<String, Object> adapterInfo = mapAdapter(adapter);
if (expanded != null && !expanded.isEmpty()) {
if (expanded.equalsIgnoreCase("all")) {
adapterInfo.put("receivers", mapAdapterReceivers(adapter, showPendingMsgCount));
adapterInfo.put("pipes", mapAdapterPipes(adapter));
adapterInfo.put("messages", mapAdapterMessages(adapter));
} else if (expanded.equalsIgnoreCase("receivers")) {
adapterInfo.put("receivers", mapAdapterReceivers(adapter, showPendingMsgCount));
} else if (expanded.equalsIgnoreCase("pipes")) {
adapterInfo.put("pipes", mapAdapterPipes(adapter));
} else if (expanded.equalsIgnoreCase("messages")) {
adapterInfo.put("messages", mapAdapterMessages(adapter));
} else {
throw new ApiException("Invalid value [" + expanded + "] for parameter expanded supplied!");
}
}
adapterList.put((String) adapterInfo.get("name"), adapterInfo);
}
Response.ResponseBuilder response = null;
// Calculate the ETag on last modified date of user resource
EntityTag etag = new EntityTag(adapterList.hashCode() + "");
// Verify if it matched with etag available in http request
response = request.evaluatePreconditions(etag);
// If ETag matches the response will be non-null;
if (response != null) {
return response.tag(etag).build();
}
response = Response.status(Response.Status.CREATED).entity(adapterList).tag(etag);
return response.build();
}
use of nl.nn.adapterframework.core.Adapter in project iaf by ibissource.
the class ShowConfigurationStatus method getAdapterPipes.
@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/adapters/{name}/pipes")
@Produces(MediaType.APPLICATION_JSON)
public Response getAdapterPipes(@PathParam("name") String adapterName) throws ApiException {
initBase(servletConfig);
Adapter adapter = (Adapter) ibisManager.getRegisteredAdapter(adapterName);
if (adapter == null) {
throw new ApiException("Adapter not found!");
}
ArrayList<Object> adapterInfo = mapAdapterPipes(adapter);
if (adapterInfo == null)
throw new ApiException("Adapter not configured!");
return Response.status(Response.Status.CREATED).entity(adapterInfo).build();
}
use of nl.nn.adapterframework.core.Adapter in project iaf by ibissource.
the class SlotIdRecord method getSlotmap.
private Map<String, SlotIdRecord> getSlotmap() {
Map<String, SlotIdRecord> slotmap = new HashMap<String, SlotIdRecord>();
for (IAdapter iAdapter : ibisManager.getRegisteredAdapters()) {
Adapter adapter = (Adapter) iAdapter;
for (Iterator<?> receiverIt = adapter.getReceiverIterator(); receiverIt.hasNext(); ) {
ReceiverBase receiver = (ReceiverBase) receiverIt.next();
ITransactionalStorage errorStorage = receiver.getErrorStorage();
if (errorStorage != null) {
String slotId = errorStorage.getSlotId();
if (StringUtils.isNotEmpty(slotId)) {
SlotIdRecord sir = new SlotIdRecord(adapter.getName(), receiver.getName(), null);
String type = errorStorage.getType();
slotmap.put(type + "/" + slotId, sir);
}
}
ITransactionalStorage messageLog = receiver.getMessageLog();
if (messageLog != null) {
String slotId = messageLog.getSlotId();
if (StringUtils.isNotEmpty(slotId)) {
SlotIdRecord sir = new SlotIdRecord(adapter.getName(), receiver.getName(), null);
String type = messageLog.getType();
slotmap.put(type + "/" + slotId, sir);
}
}
}
PipeLine pipeline = adapter.getPipeLine();
if (pipeline != null) {
for (int i = 0; i < pipeline.getPipeLineSize(); i++) {
IPipe pipe = pipeline.getPipe(i);
if (pipe instanceof MessageSendingPipe) {
MessageSendingPipe msp = (MessageSendingPipe) pipe;
ITransactionalStorage messageLog = msp.getMessageLog();
if (messageLog != null) {
String slotId = messageLog.getSlotId();
if (StringUtils.isNotEmpty(slotId)) {
SlotIdRecord sir = new SlotIdRecord(adapter.getName(), null, msp.getName());
String type = messageLog.getType();
slotmap.put(type + "/" + slotId, sir);
slotmap.put(slotId, sir);
}
}
}
}
}
}
return slotmap;
}
use of nl.nn.adapterframework.core.Adapter 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();
}
Aggregations