Search in sources :

Example 1 with ManagedTracer

use of org.apache.camel.management.mbean.ManagedTracer in project camel by apache.

the class ManagedManagementStrategy method getManagedObjectName.

public <T> T getManagedObjectName(Object managedObject, String customName, Class<T> nameType) throws Exception {
    if (managedObject == null) {
        return null;
    }
    ObjectName objectName = null;
    if (managedObject instanceof ManagedCamelContext) {
        ManagedCamelContext mcc = (ManagedCamelContext) managedObject;
        objectName = getManagementNamingStrategy().getObjectNameForCamelContext(mcc.getContext());
    } else if (managedObject instanceof ManagedComponent) {
        ManagedComponent mc = (ManagedComponent) managedObject;
        objectName = getManagementNamingStrategy().getObjectNameForComponent(mc.getComponent(), mc.getComponentName());
    } else if (managedObject instanceof ManagedDataFormat) {
        ManagedDataFormat md = (ManagedDataFormat) managedObject;
        objectName = getManagementNamingStrategy().getObjectNameForDataFormat(md.getContext(), md.getDataFormat());
    } else if (managedObject instanceof ManagedEndpoint) {
        ManagedEndpoint me = (ManagedEndpoint) managedObject;
        objectName = getManagementNamingStrategy().getObjectNameForEndpoint(me.getEndpoint());
    } else if (managedObject instanceof Endpoint) {
        objectName = getManagementNamingStrategy().getObjectNameForEndpoint((Endpoint) managedObject);
    } else if (managedObject instanceof ManagedRoute) {
        ManagedRoute mr = (ManagedRoute) managedObject;
        objectName = getManagementNamingStrategy().getObjectNameForRoute(mr.getRoute());
    } else if (managedObject instanceof ManagedErrorHandler) {
        ManagedErrorHandler meh = (ManagedErrorHandler) managedObject;
        objectName = getManagementNamingStrategy().getObjectNameForErrorHandler(meh.getRouteContext(), meh.getErrorHandler(), meh.getErrorHandlerBuilder());
    } else if (managedObject instanceof ManagedProcessor) {
        ManagedProcessor mp = (ManagedProcessor) managedObject;
        objectName = getManagementNamingStrategy().getObjectNameForProcessor(mp.getContext(), mp.getProcessor(), mp.getDefinition());
    } else if (managedObject instanceof ManagedConsumer) {
        ManagedConsumer ms = (ManagedConsumer) managedObject;
        objectName = getManagementNamingStrategy().getObjectNameForConsumer(ms.getContext(), ms.getConsumer());
    } else if (managedObject instanceof ManagedProducer) {
        ManagedProducer ms = (ManagedProducer) managedObject;
        objectName = getManagementNamingStrategy().getObjectNameForProducer(ms.getContext(), ms.getProducer());
    } else if (managedObject instanceof ManagedTracer) {
        ManagedTracer mt = (ManagedTracer) managedObject;
        objectName = getManagementNamingStrategy().getObjectNameForTracer(mt.getContext(), mt.getTracer());
    } else if (managedObject instanceof ManagedBacklogTracer) {
        ManagedBacklogTracer mt = (ManagedBacklogTracer) managedObject;
        objectName = getManagementNamingStrategy().getObjectNameForTracer(mt.getContext(), mt.getBacklogTracer());
    } else if (managedObject instanceof ManagedBacklogDebugger) {
        ManagedBacklogDebugger md = (ManagedBacklogDebugger) managedObject;
        objectName = getManagementNamingStrategy().getObjectNameForTracer(md.getContext(), md.getBacklogDebugger());
    } else if (managedObject instanceof ManagedEventNotifier) {
        ManagedEventNotifier men = (ManagedEventNotifier) managedObject;
        objectName = getManagementNamingStrategy().getObjectNameForEventNotifier(men.getContext(), men.getEventNotifier());
    } else if (managedObject instanceof ManagedThreadPool) {
        ManagedThreadPool mes = (ManagedThreadPool) managedObject;
        objectName = getManagementNamingStrategy().getObjectNameForThreadPool(mes.getContext(), mes.getThreadPool(), mes.getId(), mes.getSourceId());
    } else if (managedObject instanceof ManagedService) {
        // check for managed service should be last
        ManagedService ms = (ManagedService) managedObject;
        // skip endpoints as they are already managed
        if (ms.getService() instanceof Endpoint) {
            return null;
        }
        objectName = getManagementNamingStrategy().getObjectNameForService(ms.getContext(), ms.getService());
    }
    return nameType.cast(objectName);
}
Also used : ManagedService(org.apache.camel.management.mbean.ManagedService) ManagedCamelContext(org.apache.camel.management.mbean.ManagedCamelContext) ManagedErrorHandler(org.apache.camel.management.mbean.ManagedErrorHandler) ManagedBacklogDebugger(org.apache.camel.management.mbean.ManagedBacklogDebugger) ManagedComponent(org.apache.camel.management.mbean.ManagedComponent) ManagedEventNotifier(org.apache.camel.management.mbean.ManagedEventNotifier) ManagedThreadPool(org.apache.camel.management.mbean.ManagedThreadPool) ManagedTracer(org.apache.camel.management.mbean.ManagedTracer) ManagedDataFormat(org.apache.camel.management.mbean.ManagedDataFormat) ManagedEndpoint(org.apache.camel.management.mbean.ManagedEndpoint) ObjectName(javax.management.ObjectName) ManagedProducer(org.apache.camel.management.mbean.ManagedProducer) Endpoint(org.apache.camel.Endpoint) ManagedEndpoint(org.apache.camel.management.mbean.ManagedEndpoint) ManagedConsumer(org.apache.camel.management.mbean.ManagedConsumer) ManagedRoute(org.apache.camel.management.mbean.ManagedRoute) ManagedProcessor(org.apache.camel.management.mbean.ManagedProcessor) ManagedBacklogTracer(org.apache.camel.management.mbean.ManagedBacklogTracer)

Example 2 with ManagedTracer

use of org.apache.camel.management.mbean.ManagedTracer in project camel by apache.

the class DefaultManagementLifecycleStrategy method getManagedObjectForService.

@SuppressWarnings("unchecked")
private Object getManagedObjectForService(CamelContext context, Service service, Route route) {
    // skip channel, UoW and dont double wrap instrumentation
    if (service instanceof Channel || service instanceof UnitOfWork || service instanceof InstrumentationProcessor) {
        return null;
    }
    // skip non managed services
    if (service instanceof NonManagedService) {
        return null;
    }
    Object answer = null;
    if (service instanceof ManagementAware) {
        return ((ManagementAware<Service>) service).getManagedObject(service);
    } else if (service instanceof Tracer) {
        // special for tracer
        Tracer tracer = (Tracer) service;
        ManagedTracer mt = managedTracers.get(tracer);
        if (mt == null) {
            mt = new ManagedTracer(context, tracer);
            mt.init(getManagementStrategy());
            managedTracers.put(tracer, mt);
        }
        return mt;
    } else if (service instanceof BacklogTracer) {
        // special for backlog tracer
        BacklogTracer backlogTracer = (BacklogTracer) service;
        ManagedBacklogTracer mt = managedBacklogTracers.get(backlogTracer);
        if (mt == null) {
            mt = new ManagedBacklogTracer(context, backlogTracer);
            mt.init(getManagementStrategy());
            managedBacklogTracers.put(backlogTracer, mt);
        }
        return mt;
    } else if (service instanceof BacklogDebugger) {
        // special for backlog debugger
        BacklogDebugger backlogDebugger = (BacklogDebugger) service;
        ManagedBacklogDebugger md = managedBacklogDebuggers.get(backlogDebugger);
        if (md == null) {
            md = new ManagedBacklogDebugger(context, backlogDebugger);
            md.init(getManagementStrategy());
            managedBacklogDebuggers.put(backlogDebugger, md);
        }
        return md;
    } else if (service instanceof DataFormat) {
        answer = getManagementObjectStrategy().getManagedObjectForDataFormat(context, (DataFormat) service);
    } else if (service instanceof Producer) {
        answer = getManagementObjectStrategy().getManagedObjectForProducer(context, (Producer) service);
    } else if (service instanceof Consumer) {
        answer = getManagementObjectStrategy().getManagedObjectForConsumer(context, (Consumer) service);
    } else if (service instanceof Processor) {
        // special for processors as we need to do some extra work
        return getManagedObjectForProcessor(context, (Processor) service, route);
    } else if (service instanceof ThrottlingInflightRoutePolicy) {
        answer = new ManagedThrottlingInflightRoutePolicy(context, (ThrottlingInflightRoutePolicy) service);
    } else if (service instanceof ThrottlingExceptionRoutePolicy) {
        answer = new ManagedThrottlingExceptionRoutePolicy(context, (ThrottlingExceptionRoutePolicy) service);
    } else if (service instanceof ConsumerCache) {
        answer = new ManagedConsumerCache(context, (ConsumerCache) service);
    } else if (service instanceof ProducerCache) {
        answer = new ManagedProducerCache(context, (ProducerCache) service);
    } else if (service instanceof DefaultEndpointRegistry) {
        answer = new ManagedEndpointRegistry(context, (DefaultEndpointRegistry) service);
    } else if (service instanceof TypeConverterRegistry) {
        answer = new ManagedTypeConverterRegistry(context, (TypeConverterRegistry) service);
    } else if (service instanceof RestRegistry) {
        answer = new ManagedRestRegistry(context, (RestRegistry) service);
    } else if (service instanceof InflightRepository) {
        answer = new ManagedInflightRepository(context, (InflightRepository) service);
    } else if (service instanceof AsyncProcessorAwaitManager) {
        answer = new ManagedAsyncProcessorAwaitManager(context, (AsyncProcessorAwaitManager) service);
    } else if (service instanceof RuntimeEndpointRegistry) {
        answer = new ManagedRuntimeEndpointRegistry(context, (RuntimeEndpointRegistry) service);
    } else if (service instanceof StreamCachingStrategy) {
        answer = new ManagedStreamCachingStrategy(context, (StreamCachingStrategy) service);
    } else if (service instanceof EventNotifier) {
        answer = getManagementObjectStrategy().getManagedObjectForEventNotifier(context, (EventNotifier) service);
    } else if (service instanceof TransformerRegistry) {
        answer = new ManagedTransformerRegistry(context, (TransformerRegistry) service);
    } else if (service instanceof ValidatorRegistry) {
        answer = new ManagedValidatorRegistry(context, (ValidatorRegistry) service);
    } else if (service instanceof RuntimeCamelCatalog) {
        answer = new ManagedRuntimeCamelCatalog(context, (RuntimeCamelCatalog) service);
    } else if (service != null) {
        // fallback as generic service
        answer = getManagementObjectStrategy().getManagedObjectForService(context, service);
    }
    if (answer != null && answer instanceof ManagedService) {
        ManagedService ms = (ManagedService) answer;
        ms.setRoute(route);
        ms.init(getManagementStrategy());
    }
    return answer;
}
Also used : ManagedAsyncProcessorAwaitManager(org.apache.camel.management.mbean.ManagedAsyncProcessorAwaitManager) UnitOfWork(org.apache.camel.spi.UnitOfWork) CamelInternalProcessor(org.apache.camel.processor.CamelInternalProcessor) Processor(org.apache.camel.Processor) InflightRepository(org.apache.camel.spi.InflightRepository) ManagedInflightRepository(org.apache.camel.management.mbean.ManagedInflightRepository) ManagedTracer(org.apache.camel.management.mbean.ManagedTracer) ManagedRestRegistry(org.apache.camel.management.mbean.ManagedRestRegistry) ManagedThrottlingInflightRoutePolicy(org.apache.camel.management.mbean.ManagedThrottlingInflightRoutePolicy) RestRegistry(org.apache.camel.spi.RestRegistry) ManagedRestRegistry(org.apache.camel.management.mbean.ManagedRestRegistry) ManagedValidatorRegistry(org.apache.camel.management.mbean.ManagedValidatorRegistry) DefaultValidatorRegistry(org.apache.camel.impl.DefaultValidatorRegistry) ValidatorRegistry(org.apache.camel.spi.ValidatorRegistry) ManagedRuntimeCamelCatalog(org.apache.camel.management.mbean.ManagedRuntimeCamelCatalog) DefaultEndpointRegistry(org.apache.camel.impl.DefaultEndpointRegistry) ManagedConsumerCache(org.apache.camel.management.mbean.ManagedConsumerCache) ManagedProducerCache(org.apache.camel.management.mbean.ManagedProducerCache) ProducerCache(org.apache.camel.impl.ProducerCache) ManagedStreamCachingStrategy(org.apache.camel.management.mbean.ManagedStreamCachingStrategy) ThrottlingInflightRoutePolicy(org.apache.camel.impl.ThrottlingInflightRoutePolicy) ManagedThrottlingInflightRoutePolicy(org.apache.camel.management.mbean.ManagedThrottlingInflightRoutePolicy) ManagedEndpointRegistry(org.apache.camel.management.mbean.ManagedEndpointRegistry) Consumer(org.apache.camel.Consumer) ManagedTypeConverterRegistry(org.apache.camel.management.mbean.ManagedTypeConverterRegistry) TypeConverterRegistry(org.apache.camel.spi.TypeConverterRegistry) EventNotifier(org.apache.camel.spi.EventNotifier) DataFormat(org.apache.camel.spi.DataFormat) ManagedThrottlingExceptionRoutePolicy(org.apache.camel.management.mbean.ManagedThrottlingExceptionRoutePolicy) DefaultTransformerRegistry(org.apache.camel.impl.DefaultTransformerRegistry) ManagedTransformerRegistry(org.apache.camel.management.mbean.ManagedTransformerRegistry) TransformerRegistry(org.apache.camel.spi.TransformerRegistry) ManagedService(org.apache.camel.management.mbean.ManagedService) NonManagedService(org.apache.camel.NonManagedService) ManagedBacklogTracer(org.apache.camel.management.mbean.ManagedBacklogTracer) BacklogTracer(org.apache.camel.processor.interceptor.BacklogTracer) ManagedBacklogDebugger(org.apache.camel.management.mbean.ManagedBacklogDebugger) ManagedBacklogTracer(org.apache.camel.management.mbean.ManagedBacklogTracer) Tracer(org.apache.camel.processor.interceptor.Tracer) BacklogTracer(org.apache.camel.processor.interceptor.BacklogTracer) ManagedTracer(org.apache.camel.management.mbean.ManagedTracer) Channel(org.apache.camel.Channel) ManagedAsyncProcessorAwaitManager(org.apache.camel.management.mbean.ManagedAsyncProcessorAwaitManager) AsyncProcessorAwaitManager(org.apache.camel.spi.AsyncProcessorAwaitManager) ManagedRuntimeCamelCatalog(org.apache.camel.management.mbean.ManagedRuntimeCamelCatalog) RuntimeCamelCatalog(org.apache.camel.catalog.RuntimeCamelCatalog) ManagedTypeConverterRegistry(org.apache.camel.management.mbean.ManagedTypeConverterRegistry) Producer(org.apache.camel.Producer) ManagedValidatorRegistry(org.apache.camel.management.mbean.ManagedValidatorRegistry) ManagedRuntimeEndpointRegistry(org.apache.camel.management.mbean.ManagedRuntimeEndpointRegistry) RuntimeEndpointRegistry(org.apache.camel.spi.RuntimeEndpointRegistry) ManagedInflightRepository(org.apache.camel.management.mbean.ManagedInflightRepository) ConsumerCache(org.apache.camel.impl.ConsumerCache) ManagedConsumerCache(org.apache.camel.management.mbean.ManagedConsumerCache) ManagedTransformerRegistry(org.apache.camel.management.mbean.ManagedTransformerRegistry) ManagedProducerCache(org.apache.camel.management.mbean.ManagedProducerCache) ManagementAware(org.apache.camel.spi.ManagementAware) StreamCachingStrategy(org.apache.camel.spi.StreamCachingStrategy) ManagedStreamCachingStrategy(org.apache.camel.management.mbean.ManagedStreamCachingStrategy) NonManagedService(org.apache.camel.NonManagedService) ManagedBacklogDebugger(org.apache.camel.management.mbean.ManagedBacklogDebugger) BacklogDebugger(org.apache.camel.processor.interceptor.BacklogDebugger) ManagedBacklogTracer(org.apache.camel.management.mbean.ManagedBacklogTracer) ManagedRuntimeEndpointRegistry(org.apache.camel.management.mbean.ManagedRuntimeEndpointRegistry) ThrottlingExceptionRoutePolicy(org.apache.camel.impl.ThrottlingExceptionRoutePolicy) ManagedThrottlingExceptionRoutePolicy(org.apache.camel.management.mbean.ManagedThrottlingExceptionRoutePolicy)

Aggregations

ManagedBacklogDebugger (org.apache.camel.management.mbean.ManagedBacklogDebugger)2 ManagedBacklogTracer (org.apache.camel.management.mbean.ManagedBacklogTracer)2 ManagedService (org.apache.camel.management.mbean.ManagedService)2 ManagedTracer (org.apache.camel.management.mbean.ManagedTracer)2 ObjectName (javax.management.ObjectName)1 Channel (org.apache.camel.Channel)1 Consumer (org.apache.camel.Consumer)1 Endpoint (org.apache.camel.Endpoint)1 NonManagedService (org.apache.camel.NonManagedService)1 Processor (org.apache.camel.Processor)1 Producer (org.apache.camel.Producer)1 RuntimeCamelCatalog (org.apache.camel.catalog.RuntimeCamelCatalog)1 ConsumerCache (org.apache.camel.impl.ConsumerCache)1 DefaultEndpointRegistry (org.apache.camel.impl.DefaultEndpointRegistry)1 DefaultTransformerRegistry (org.apache.camel.impl.DefaultTransformerRegistry)1 DefaultValidatorRegistry (org.apache.camel.impl.DefaultValidatorRegistry)1 ProducerCache (org.apache.camel.impl.ProducerCache)1 ThrottlingExceptionRoutePolicy (org.apache.camel.impl.ThrottlingExceptionRoutePolicy)1 ThrottlingInflightRoutePolicy (org.apache.camel.impl.ThrottlingInflightRoutePolicy)1 ManagedAsyncProcessorAwaitManager (org.apache.camel.management.mbean.ManagedAsyncProcessorAwaitManager)1