Examples of CounterRepository


Examples of org.apache.cxf.management.counters.CounterRepository

            bus = BusFactory.getThreadDefaultBus();
        }
       
        Message message = ex.getOutMessage();
       
        CounterRepository cr = bus.getExtension(CounterRepository.class);
       
        if (null == cr) {
            LOG.log(Level.WARNING, "NO_COUNTER_REPOSITORY");
            return;
        } else {
            Service service = ex.get(Service.class);           
            Endpoint endpoint = ex.get(Endpoint.class);
           
            String serviceName = "\"" + escapePatternChars(service.getName().toString()) + "\"";           
            String portName = "\"" + endpoint.getEndpointInfo().getName().getLocalPart() + "\"";
           
            OperationInfo opInfo = ex.get(OperationInfo.class);
            String operationName = opInfo == null ? null : "\"" + opInfo.getName().getLocalPart() + "\"";
           
            if (operationName == null) {
                Object nameProperty = ex.get("org.apache.cxf.resource.operation.name");
                if (nameProperty != null) {
                    operationName = "\"" + escapePatternChars(nameProperty.toString()) + "\"";
                }
            }
           
            StringBuilder buffer = new StringBuilder();
            buffer.append(ManagementConstants.DEFAULT_DOMAIN_NAME + ":");
            buffer.append(ManagementConstants.BUS_ID_PROP + "=" + bus.getId() + ",");
            if (isClient(message)) {
                buffer.append(ManagementConstants.TYPE_PROP + "=" + Counter.PERFORMANCE_COUNTER + ".Client,");
            } else {
                buffer.append(ManagementConstants.TYPE_PROP + "=" + Counter.PERFORMANCE_COUNTER + ".Server,");
            }
            buffer.append(ManagementConstants.SERVICE_NAME_PROP + "=" + serviceName + ",");
          
            buffer.append(ManagementConstants.PORT_NAME_PROP + "=" + portName);
            String serviceCounterName = buffer.toString();
           
            try {          
                ObjectName serviceCounter =
                    new ObjectName(serviceCounterName);               
                cr.increaseCounter(serviceCounter, mhtr);
                if (operationName != null) {
                    buffer.append("," + ManagementConstants.OPERATION_NAME_PROP + "=" + operationName);
                    String operationCounterName = buffer.toString();
                    ObjectName operationCounter = new ObjectName(operationCounterName);
                    cr.increaseCounter(operationCounter, mhtr);               
                }
            } catch (Exception exception) {
                LOG.log(Level.WARNING, "CREATE_COUNTER_OBJECTNAME_FAILED", exception);
            }
        }
View Full Code Here

Examples of org.apache.cxf.management.counters.CounterRepository

        Bus bus = ex.get(Bus.class);
        if (null == bus) {
            LOG.log(Level.INFO, "CAN_NOT_GET_BUS_FROM_EXCHANGE");
            bus = BusFactory.getThreadDefaultBus();
        }
        CounterRepository cr = bus.getExtension(CounterRepository.class);

        if (null == cr) {
            LOG.log(Level.WARNING, "NO_COUNTER_REPOSITORY");
            return;
        } else {
            ObjectName serviceCountername = this.getServiceCounterName(ex);
            cr.increaseCounter(serviceCountername, mhtr);

            ObjectName operationCounter = this.getOperationCounterName(ex, serviceCountername);
            cr.increaseCounter(operationCounter, mhtr);
        }
    }
View Full Code Here

Examples of org.apache.cxf.management.counters.CounterRepository

       
    }
 
    protected boolean isServiceCounterEnabled(Exchange ex) {
        Bus bus = ex.get(Bus.class);
        CounterRepository counterRepo = bus.getExtension(CounterRepository.class);
        if (counterRepo == null) {
            return false;
        }
        ObjectName serviceCounterName = getServiceCounterName(ex);
        ResponseTimeCounter serviceCounter = (ResponseTimeCounter)counterRepo.getCounter(serviceCounterName);
        //If serviceCounter is null, we need to wait ResponseTimeOutInterceptor to create it , hence set to true
        if (serviceCounter == null || serviceCounter.isEnabled()) {
            return true;
        }
        return false;  
View Full Code Here

Examples of org.apache.cxf.management.counters.CounterRepository

            BusFactory.getThreadDefaultBus();
        }
       
        Message message = ex.getOutMessage();
       
        CounterRepository cr = bus.getExtension(CounterRepository.class);
       
        if (null == cr) {
            LOG.log(Level.WARNING, "NO_COUNTER_REPOSITORY");
            return;
        } else {           
            Service service = ex.get(Service.class);           
            OperationInfo opInfo = ex.get(OperationInfo.class);
            Endpoint endpoint = ex.get(Endpoint.class);
           
            String serviceName = "\"" + service.getName() + "\"";           
            String portName = "\"" + endpoint.getEndpointInfo().getName().getLocalPart() + "\"";
            String operationName = opInfo == null ? null : "\"" + opInfo.getName().getLocalPart() + "\"";
           
            StringBuilder buffer = new StringBuilder();
            buffer.append(ManagementConstants.DEFAULT_DOMAIN_NAME + ":");
            buffer.append(ManagementConstants.BUS_ID_PROP + "=" + bus.getId() + ",");
            if (isClient(message)) {
                buffer.append(ManagementConstants.TYPE_PROP + "=" + Counter.PERFORMANCE_COUNTER + ".Client,");
            } else {
                buffer.append(ManagementConstants.TYPE_PROP + "=" + Counter.PERFORMANCE_COUNTER + ".Server,");
            }
            buffer.append(ManagementConstants.SERVICE_NAME_PROP + "=" + serviceName + ",");
          
            buffer.append(ManagementConstants.PORT_NAME_PROP + "=" + portName);
            String serviceCounterName = buffer.toString();
           
            try {          
                ObjectName serviceCounter =
                    new ObjectName(serviceCounterName);               
                cr.increaseCounter(serviceCounter, mhtr);
                if (operationName != null) {
                    buffer.append("," + ManagementConstants.OPERATION_NAME_PROP + "=" + operationName);
                    String operationCounterName = buffer.toString();
                    ObjectName operationCounter = new ObjectName(operationCounterName);
                    cr.increaseCounter(operationCounter, mhtr);               
                }
            } catch (Exception exception) {
                LOG.log(Level.WARNING, "CREATE_COUNTER_OBJECTNAME_FAILED", exception);
            }
        }
View Full Code Here

Examples of org.apache.cxf.management.counters.CounterRepository

            context = new ClassPathXmlApplicationContext("managed-spring-twobuses.xml");

            cxf1 = (Bus)context.getBean("cxf1");
            InstrumentationManager im1 = cxf1.getExtension(InstrumentationManager.class);
            assertNotNull("Instrumentation Manager of cxf1 should not be null", im1);
            CounterRepository cr1 = cxf1.getExtension(CounterRepository.class);
            assertNotNull("CounterRepository of cxf1 should not be null", cr1);
            assertEquals("CounterRepository of cxf1 has the wrong bus", cxf1, cr1.getBus());
           
            cxf2 = (Bus)context.getBean("cxf2");
            InstrumentationManager im2 = cxf2.getExtension(InstrumentationManager.class);
            assertNotNull("Instrumentation Manager of cxf2 should not be null", im2);
            CounterRepository cr2 = cxf2.getExtension(CounterRepository.class);
            assertNotNull("CounterRepository of cxf2 should not be null", cr2);
            assertEquals("CounterRepository of cxf2 has the wrong bus", cxf2, cr2.getBus());

        } finally {
            if (cxf1 != null) {
                cxf1.shutdown(true);
            }
View Full Code Here

Examples of org.apache.cxf.management.counters.CounterRepository

            BusFactory.getThreadDefaultBus();
        }
       
        Message message = ex.getOutMessage();
       
        CounterRepository cr = bus.getExtension(CounterRepository.class);
       
        if (null == cr) {
            LOG.log(Level.WARNING, "NO_COUNTER_REPOSITORY");
            return;
        } else {
            Service service = ex.get(Service.class);           
            Endpoint endpoint = ex.get(Endpoint.class);
           
            String serviceName = "\"" + service.getName() + "\"";           
            String portName = "\"" + endpoint.getEndpointInfo().getName().getLocalPart() + "\"";
           
            OperationInfo opInfo = ex.get(OperationInfo.class);
            String operationName = opInfo == null ? null : "\"" + opInfo.getName().getLocalPart() + "\"";
           
            if (operationName == null) {
                Object nameProperty = ex.get("org.apache.cxf.resource.operation.name");
                if (nameProperty != null) {
                    operationName = "\"" + nameProperty.toString() + "\"";
                }
            }
           
            StringBuilder buffer = new StringBuilder();
            buffer.append(ManagementConstants.DEFAULT_DOMAIN_NAME + ":");
            buffer.append(ManagementConstants.BUS_ID_PROP + "=" + bus.getId() + ",");
            if (isClient(message)) {
                buffer.append(ManagementConstants.TYPE_PROP + "=" + Counter.PERFORMANCE_COUNTER + ".Client,");
            } else {
                buffer.append(ManagementConstants.TYPE_PROP + "=" + Counter.PERFORMANCE_COUNTER + ".Server,");
            }
            buffer.append(ManagementConstants.SERVICE_NAME_PROP + "=" + serviceName + ",");
          
            buffer.append(ManagementConstants.PORT_NAME_PROP + "=" + portName);
            String serviceCounterName = buffer.toString();
           
            try {          
                ObjectName serviceCounter =
                    new ObjectName(serviceCounterName);               
                cr.increaseCounter(serviceCounter, mhtr);
                if (operationName != null) {
                    buffer.append("," + ManagementConstants.OPERATION_NAME_PROP + "=" + operationName);
                    String operationCounterName = buffer.toString();
                    ObjectName operationCounter = new ObjectName(operationCounterName);
                    cr.increaseCounter(operationCounter, mhtr);               
                }
            } catch (Exception exception) {
                LOG.log(Level.WARNING, "CREATE_COUNTER_OBJECTNAME_FAILED", exception);
            }
        }
View Full Code Here

Examples of org.apache.cxf.management.counters.CounterRepository

    public void testCountersWithInstrumentationManager() throws Exception {
        // create Client with other bus
        Bus bus = BusFactory.getDefaultBus();
        bus.getExtension(WorkQueueManager.class);
                               
        CounterRepository cr = bus.getExtension(CounterRepository.class);
        InstrumentationManager im = bus.getExtension(InstrumentationManager.class);
        assertNotNull(im);
        InstrumentationManagerImpl impl = (InstrumentationManagerImpl)im;
        assertTrue(impl.isEnabled());
        assertNotNull(impl.getMBeanServer());
       
        MBeanServer mbs = im.getMBeanServer();
        ObjectName name = new ObjectName(ManagementConstants.DEFAULT_DOMAIN_NAME
            + ":" + ManagementConstants.BUS_ID_PROP + "=cxf" + bus.hashCode() + ",*");       
       
        SOAPService service = new SOAPService();
        assertNotNull(service);       
       
        Greeter greeter = service.getPort(portName, Greeter.class);
        updateAddressPort(greeter, PORT);
       
        String response = new String("Bonjour");
        String reply = greeter.sayHi();
       
        //assertNotNull("no response received from service", reply);
        //assertEquals(response, reply); 
       
        assertEquals("The Counters are not create yet", 4, cr.getCounters().size());
        Set counterNames = mbs.queryNames(name, null);
        assertEquals("The Counters are not export to JMX: " + counterNames,
                     4 + 3 , counterNames.size());
      
        ObjectName sayHiCounter =  new ObjectName(
            ManagementConstants.DEFAULT_DOMAIN_NAME + ":operation=\"sayHi\",*");
       
        Set s = mbs.queryNames(sayHiCounter, null);       
        Iterator it = s.iterator();
       
        while (it.hasNext()) {
            ObjectName counterName = (ObjectName)it.next();
            Object val = mbs.getAttribute(counterName, "NumInvocations");   
            assertEquals("Wrong Counters Number of Invocations", val, 1);
        }
               
        reply = greeter.sayHi();
        assertNotNull("no response received from service", reply);
        assertEquals(response, reply);
       
        s = mbs.queryNames(sayHiCounter, null);       
        it = s.iterator();
       
        while (it.hasNext()) {
            ObjectName counterName = (ObjectName)it.next();
            Object val = mbs.getAttribute(counterName, "NumInvocations");   
            assertEquals("Wrong Counters Number of Invocations", val, 2);
        }
       
        greeter.greetMeOneWay("hello");
        for (int count = 0; count < 10; count++) {
            if (6 != cr.getCounters().size()) {
                Thread.sleep(100);
            } else {
                break;
            }
        }
        assertEquals("The Counters are not create yet", 6, cr.getCounters().size());
        for (int count = 0; count < 10; count++) {
            if (10 > mbs.queryNames(name, null).size()) {
                Thread.sleep(100);
            } else {
                break;
View Full Code Here

Examples of org.apache.cxf.management.counters.CounterRepository

            context = new ClassPathXmlApplicationContext("managed-spring-twobuses.xml");

            cxf1 = (Bus)context.getBean("cxf1");
            InstrumentationManager im1 = cxf1.getExtension(InstrumentationManager.class);
            assertNotNull("Instrumentation Manager of cxf1 should not be null", im1);
            CounterRepository cr1 = cxf1.getExtension(CounterRepository.class);
            assertNotNull("CounterRepository of cxf1 should not be null", cr1);
            assertEquals("CounterRepository of cxf1 has the wrong bus", cxf1, cr1.getBus());
           
            cxf2 = (Bus)context.getBean("cxf2");
            InstrumentationManager im2 = cxf2.getExtension(InstrumentationManager.class);
            assertNotNull("Instrumentation Manager of cxf2 should not be null", im2);
            CounterRepository cr2 = cxf2.getExtension(CounterRepository.class);
            assertNotNull("CounterRepository of cxf2 should not be null", cr2);
            assertEquals("CounterRepository of cxf2 has the wrong bus", cxf2, cr2.getBus());

        } finally {
            if (cxf1 != null) {
                cxf1.shutdown(true);
            }
View Full Code Here

Examples of org.apache.cxf.management.counters.CounterRepository

    public void testCountersWithInstrumentationManager() throws Exception {
        // create Client with other bus
        Bus bus = BusFactory.getDefaultBus();
        bus.getExtension(WorkQueueManager.class);
                               
        CounterRepository cr = bus.getExtension(CounterRepository.class);
        InstrumentationManager im = bus.getExtension(InstrumentationManager.class);
        assertNotNull(im);
        InstrumentationManagerImpl impl = (InstrumentationManagerImpl)im;
        assertTrue(impl.isEnabled());
        assertNotNull(impl.getMBeanServer());
       
        MBeanServer mbs = im.getMBeanServer();
        ObjectName name = new ObjectName(ManagementConstants.DEFAULT_DOMAIN_NAME
            + ":" + ManagementConstants.BUS_ID_PROP + "=cxf" + bus.hashCode() + ",*");       
       
        SOAPService service = new SOAPService();
        assertNotNull(service);       
       
        Greeter greeter = service.getPort(portName, Greeter.class);
        updateAddressPort(greeter, PORT);
       
        String response = new String("Bonjour");
        String reply = greeter.sayHi();
       
        //assertNotNull("no response received from service", reply);
        //assertEquals(response, reply); 
       
        assertEquals("The Counters are not create yet", 4, cr.getCounters().size());
        Set<?> counterNames = mbs.queryNames(name, null);
        assertEquals("The Counters are not export to JMX: " + counterNames,
                     4 + 3 , counterNames.size());
      
        ObjectName sayHiCounter =  new ObjectName(
            ManagementConstants.DEFAULT_DOMAIN_NAME + ":operation=\"sayHi\",*");
       
        Set<?> s = mbs.queryNames(sayHiCounter, null);       
        Iterator<?> it = s.iterator();
       
        while (it.hasNext()) {
            ObjectName counterName = (ObjectName)it.next();
            Object val = mbs.getAttribute(counterName, "NumInvocations");   
            assertEquals("Wrong Counters Number of Invocations", val, 1);
        }
               
        reply = greeter.sayHi();
        assertNotNull("no response received from service", reply);
        assertEquals(response, reply);
       
        s = mbs.queryNames(sayHiCounter, null);       
        it = s.iterator();
       
        while (it.hasNext()) {
            ObjectName counterName = (ObjectName)it.next();
            Object val = mbs.getAttribute(counterName, "NumInvocations");   
            assertEquals("Wrong Counters Number of Invocations", val, 2);
        }
       
        greeter.greetMeOneWay("hello");
        for (int count = 0; count < 10; count++) {
            if (6 != cr.getCounters().size()) {
                Thread.sleep(100);
            } else {
                break;
            }
        }
        assertEquals("The Counters are not create yet", 6, cr.getCounters().size());
        for (int count = 0; count < 10; count++) {
            if (10 > mbs.queryNames(name, null).size()) {
                Thread.sleep(100);
            } else {
                break;
View Full Code Here

Examples of org.apache.cxf.management.counters.CounterRepository

            BusFactory.getThreadDefaultBus();
        }
       
        Message message = ex.getOutMessage();
       
        CounterRepository cr = bus.getExtension(CounterRepository.class);
       
        if (null == cr) {
            LOG.log(Level.WARNING, "NO_COUNTER_REPOSITORY");
            return;
        } else {
            Service service = ex.get(Service.class);           
            Endpoint endpoint = ex.get(Endpoint.class);
           
            String serviceName = "\"" + escapePatternChars(service.getName().toString()) + "\"";           
            String portName = "\"" + endpoint.getEndpointInfo().getName().getLocalPart() + "\"";
           
            OperationInfo opInfo = ex.get(OperationInfo.class);
            String operationName = opInfo == null ? null : "\"" + opInfo.getName().getLocalPart() + "\"";
           
            if (operationName == null) {
                Object nameProperty = ex.get("org.apache.cxf.resource.operation.name");
                if (nameProperty != null) {
                    operationName = "\"" + escapePatternChars(nameProperty.toString()) + "\"";
                }
            }
           
            StringBuilder buffer = new StringBuilder();
            buffer.append(ManagementConstants.DEFAULT_DOMAIN_NAME + ":");
            buffer.append(ManagementConstants.BUS_ID_PROP + "=" + bus.getId() + ",");
            if (isClient(message)) {
                buffer.append(ManagementConstants.TYPE_PROP + "=" + Counter.PERFORMANCE_COUNTER + ".Client,");
            } else {
                buffer.append(ManagementConstants.TYPE_PROP + "=" + Counter.PERFORMANCE_COUNTER + ".Server,");
            }
            buffer.append(ManagementConstants.SERVICE_NAME_PROP + "=" + serviceName + ",");
          
            buffer.append(ManagementConstants.PORT_NAME_PROP + "=" + portName);
            String serviceCounterName = buffer.toString();
           
            try {          
                ObjectName serviceCounter =
                    new ObjectName(serviceCounterName);               
                cr.increaseCounter(serviceCounter, mhtr);
                if (operationName != null) {
                    buffer.append("," + ManagementConstants.OPERATION_NAME_PROP + "=" + operationName);
                    String operationCounterName = buffer.toString();
                    ObjectName operationCounter = new ObjectName(operationCounterName);
                    cr.increaseCounter(operationCounter, mhtr);               
                }
            } catch (Exception exception) {
                LOG.log(Level.WARNING, "CREATE_COUNTER_OBJECTNAME_FAILED", exception);
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.