Moving discussion to public dev list


-------- Original Message --------
Subject: EndpointMetrics Refactor
Date: Tue, 01 Jul 2014 15:58:46 +0800
From: Jim Ma <ema@redhat.com>
To: Alessio Soldano <asoldano@redhat.com>, Rebecca Searls <rsearls@redhat.com>


Hi Alessio & Rebecca,

After discussed on IRC last week, looked at cxf's management code in 
more depth
and wrote something to verify yesterday, it's time to sum up what can we 
do to refactor
the current EndpointMetrics as I promised to make it better work with 
cxf's management
implementation.

At the beginning,  I'd like to quickly list the cons of the current 
EndpointMetrics
implementation.
- Because the statistics is fulfilled in RequestHandlerImpl , after the 
response is successfully
    returned to receiver. The response related metric value could not 
be updated in time, more
    details pleas see JBWS-3808
- It doesn't count the one way fault correctly.
- It doesn't expose all the attribute in jmx.
- If the cxf's management is enabled, user will get two different 
statistics value. One is
    calculated  with jbossws-cxf's endpointmetrics which happens in 
RequestHandler(servlet),
    and another one is calculated with ResponseTimeInterceptor(cxf's 
interceptor).
The pros of current implementation :
 - It gives more accurate start time for each request.
 - It is simple and doesn't need to add more interceptor/extra code in 
the runtime to collect
     the data.

>From the above analysis, one important thing we need to do is make the 
EndpintMetrics seamlessly
work with cxf's management intercetptor and get statistics from one 
place instead of generate two
copies from different implementation.
There is CounterRepostiry extension in cxf  which responsible for 
creating ResponseTimeCounter
for each endpoint,  It can be the only source we get statistics for each 
endpoint.
To get metric value from this class, we need to change following things:
1. Each ResponseTImeCounter(something similar to EndpointMetrics) is 
lazily created in
    message interceptor and put in CounterReposiory with a long 
ObjectName at the moment. We
    need to change it and add the ResponseTimeCounter for each jbossws 
endpoint , then put it in
    CounterRepostiry with key name of endpoint name.
2. Change EndpointMetricsFactory abstract class to create with 
EndpointMetric with endpoint
    parameter so the endpoint name can be used to create 
ResponseTimeCounter.
3. Create new EndpointMetricImpl in jbossws-cxf and get metric value 
from ResponseCounter
   which is created for each endpoint.
4. Change the ResponseTimeInterceptor and allow for define the counter 
object name.

Besides this , I also need to refactor the ResponseTimeInterceptor to 
make it log the process time
more accurate(by move ResponseTimeInInterceptor before several 
interceptors ?). And also refactor
the ResponseTimeInterceptor a bit to handle the fault message correctly.

If you have any question and comments about this change , please let me 
know.

Thanks,
Jim