use of org.apache.camel.management.event.ExchangeCreatedEvent in project camel by apache.
the class DefaultRuntimeEndpointRegistry method notify.
@Override
public void notify(EventObject event) throws Exception {
if (event instanceof RouteAddedEvent) {
RouteAddedEvent rse = (RouteAddedEvent) event;
Endpoint endpoint = rse.getRoute().getEndpoint();
String routeId = rse.getRoute().getId();
// a HashSet is fine for inputs as we only have a limited number of those
Set<String> uris = new HashSet<String>();
uris.add(endpoint.getEndpointUri());
inputs.put(routeId, uris);
// use a LRUCache for outputs as we could potential have unlimited uris if dynamic routing is in use
// and therefore need to have the limit in use
outputs.put(routeId, new LRUCache<String, String>(limit));
} else if (event instanceof RouteRemovedEvent) {
RouteRemovedEvent rse = (RouteRemovedEvent) event;
String routeId = rse.getRoute().getId();
inputs.remove(routeId);
outputs.remove(routeId);
if (extended) {
String uri = rse.getRoute().getEndpoint().getEndpointUri();
String key = asUtilizationKey(routeId, uri);
if (key != null) {
inputUtilization.remove(key);
}
}
} else if (extended && event instanceof ExchangeCreatedEvent) {
// we only capture details in extended mode
ExchangeCreatedEvent ece = (ExchangeCreatedEvent) event;
Endpoint endpoint = ece.getExchange().getFromEndpoint();
if (endpoint != null) {
String routeId = ece.getExchange().getFromRouteId();
String uri = endpoint.getEndpointUri();
String key = asUtilizationKey(routeId, uri);
if (key != null) {
inputUtilization.onHit(key);
}
}
} else if (event instanceof ExchangeSendingEvent) {
ExchangeSendingEvent ese = (ExchangeSendingEvent) event;
Endpoint endpoint = ese.getEndpoint();
String routeId = getRouteId(ese.getExchange());
String uri = endpoint.getEndpointUri();
Map<String, String> uris = outputs.get(routeId);
if (uris != null && !uris.containsKey(uri)) {
uris.put(uri, uri);
}
if (extended) {
String key = asUtilizationKey(routeId, uri);
if (key != null) {
outputUtilization.onHit(key);
}
}
}
}
use of org.apache.camel.management.event.ExchangeCreatedEvent in project camel by apache.
the class DefaultDebugger method addSingleStepBreakpoint.
@Override
public void addSingleStepBreakpoint(final Breakpoint breakpoint, Condition... conditions) {
// wrap the breakpoint into single step breakpoint so we can automatic enable/disable the single step mode
Breakpoint singlestep = new Breakpoint() {
@Override
public State getState() {
return breakpoint.getState();
}
@Override
public void suspend() {
breakpoint.suspend();
}
@Override
public void activate() {
breakpoint.activate();
}
@Override
public void beforeProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition) {
breakpoint.beforeProcess(exchange, processor, definition);
}
@Override
public void afterProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition, long timeTaken) {
breakpoint.afterProcess(exchange, processor, definition, timeTaken);
}
@Override
public void onEvent(Exchange exchange, EventObject event, ProcessorDefinition<?> definition) {
if (event instanceof ExchangeCreatedEvent) {
exchange.getContext().getDebugger().startSingleStepExchange(exchange.getExchangeId(), this);
} else if (event instanceof ExchangeCompletedEvent) {
exchange.getContext().getDebugger().stopSingleStepExchange(exchange.getExchangeId());
}
breakpoint.onEvent(exchange, event, definition);
}
@Override
public String toString() {
return breakpoint.toString();
}
};
addBreakpoint(singlestep, conditions);
}
Aggregations