6.
Java ThreadMXBean to rescue..● The management interface for the thread system of the JVM.● Java virtual machine implementation supports measuring the CPU time for the current thread or for any thread.● getCurrentThreadCpuTime() Returns the total CPU time for the current thread in nanoseconds.● Does not account for thread sleep/idle time.

15.
Solution✔ Specifically capture the CPU time for the products which has above constraints.✔ Separate Component to retrieve product specific CPU Usage Statistics and send them to Stratos Usage Agent Component.✔ Should add CPU Statistics to the same Usage Agent instance, once it is registered as an OSGI Service.

16.
How to use tenant CPU usage Statistics Metered CPU Statistics will be summarized in BAM. Data will be used for billing and throttling. Tenants will be throttled and billed at the end of the month according to their CPU usage. Summarized Data in BAM using a Hive Script

21.
Problems[1] Products are different  Thread handling is done differently in some products. Had to remotely debug each an every products dependent apache code (ode/synapse/hive/hadoop) and find the thread execution part and capture the CPU time of each request  Usually tenant information is not associated with each request/response in apache code. I had to send the tenant domain/id in certain cases as a parameter in the invoke method from the particular component or set it as a property so that I could find which request comes from which tenant.

22.
Problems Continued ..[2] Retrieving data from different dependencies  Cannot add direct dependencies to ode/synapse in Stratos usage agent component since it is not used in every WSO2 product. I had to write new component to do the data retrieval/persistence tasks for each product, where I had to capture CPU time, except for Tomcat.ext  Had to register UsageDataPersistenceManager in usage agent as an OSGI service, so that ESB/BPS components can add the CPU usage data to the same instance that is used by the org.wso2.carbon.usage.agent components persistence queue.

23.
Problems Continued ..[3] Accurate CPU Usage data ..??  Request execution live time and CPU time are very close values, but CPU time is less than the live time.  Thread sleep time is not captured as CPU time.  Thread CPU time is aggregated in ThreadMXBean. Had to take the difference of thread CPU time always for a particular request.

24.
Problems Continued ..[4] Performance Hit ...??  EnableMetring is set to false by default in carbon.xml. CPU time measuring code is executed only if metering is enabled.  Tested for Tomcat.ext after metering is enabled. No noticeable change in SOAPUI for a of web service call burst.  Tested for several types of ESB proxy services with and without code from Apache Jmeter and there is no sign of change in TPS.

30.
Automation Hackathon With GREG team for almost 2 months. Wrote a lot of test cases and ported old tests to Clarity framework. Learnt on Greg LCs, Rxts, APIs, URIs, Handlers, Permissions etc. Learnt to writie axis2 clients to test CRUD Operation support and Discovery Proxy for GREG. Automated several Support Patches.

32.
Above them all ... Obviously learnt a load of technical things. How to take important architectural decisions and flexibility of carbon architecture. How to Communicate ideas with others and get the necessary help. Was able to get the help of lot of people and work in several products Carbon, AS, ESB, BPS, GREG, BAM, DSS, Stratos etc. Learnt best practices in software engineering and coding conventions.

33.
Above them all ... How to test software, automate the functionality and how QA functions. How to use mailing lists effectively. How to manage time and meet deadlines. How does a company function and how a company prepares for a release. Got to know a bunch of good friends/people. Enjoyed every minute of it.