Thursday, April 9, 2009

Failed to connect to remote VM. Connection refused. Connection refused: connect

A lot of time was wasted to resolve the above mentioned error, while I was trying to connect to a remote server using my eclipse IDE in debug mode. Here is the solution;

  1. Compile your application using '-g' option. This will generate all the debugging related information, including local variables. By default, only line number and source file information is generated.
  2. Launch a new Java Virtual Machine (VM) with the main class of the application to be debugged. For e.g. Launch a new Java Virtual Machine (VM) with the main class of the application to be debugged. For e.g. $> gt; java -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket, server=y, suspend=n, address=8000
Hope that helps.

Sunday, March 22, 2009

Are YOU Game?

... and the Lord said, 'let their be light...' yeah and in that moment of enlightenment I could now very clearly see some anti-patterns in my behavior. Let us try and understand the same. Let's say you are pretty very well educated, you have a decent job, you are considered a 'potential' candidate to handle most challenging assignments in your organization and you dream big. But.. and a big one there to be precise, more often than not, you hit a big wall somewhere along the way. You can get something going, but it does not go very far. We have no idea how many times we end up stuck in second gear for the rest of our lives. While we may be “good enough” we could be so much better.

Yes, I wanted to talk about 'Scalability' as much as this concept is borrowed from Software Engineering I plan to adopt it in my day to day life.

"Scalability is a desirable property of a system, a network, or a process, which indicates its ability to either handle growing amounts of work in a graceful manner, or to be readily enlarged.[1] For example, it can refer to the capability of a system to increase total throughput under an increased load when resources (typically hardware) are added. An analogous meaning is implied when the word is used in a commercial context, where scalability of a company implies that the underlying business model offers the potential for economic growth within the company.

An algorithm, design, networking protocol, program, or other system is said to scale if it is suitably efficient and practical when applied to large situations (e.g. a large input data set or large number of participating nodes in the case of a distributed system). If the design fails when the quantity increases then it does not scale." - Source: wikipedia

Now scalability has multiple facets to understand;
  • 'Scale Out' - Diversify your horizon of understanding, often I have observed that concepts from seemingly unrelated subjects, an example in case the recent rage with Web 2.0 where concepts from Sociology and Technology is gainfully employed to conduct 'Viral Marketing' for businesses. "Tell-A-Friend" widget from Pramati which you see on my blog is niche area platform product operating in this space. It definitely helps to find/create new opportunities if you can apply your diverse knowledge to add value to the society at large. Another way to scale out is to play multiple roles in your team to gain first hand understanding of issues at hand. It may be an enriching experience if you can mix-match-employ your experience with solving engineering problems and handling customer situations.
  • 'Scale Up' - Based upon your analysis of the situation you feel it just right to add extra effort.. walk that extra mile to achieve 'customer delight'. [here, customer is overloaded for both the internal and external customer behavior]
  • 'Scale Down' - Last but not the least, it is important for us to identify and 'scale down' things which are not working. Things which might become too big a problem while one is trying to scale...
With that understanding of issues with me.. I want to ask myself if I'm Game enough to leave my footprint on the third rock from Sun? Game enough to tackle the challenging technology? Game enough to get my game on the planet. I believe I can.. Come on! double up now... faster, higher, stronger.. be a sport :)

Thursday, March 12, 2009

Why slow?

Hmm.. so good that you are able to monitor response times of the application components but then how does that helps tuning the application... do not count activity.. show me the productivity.. so here I'm able to monitor my code and generate some couple of reports.. but then they didn't really helped me understand performance bottlenecks.. I would run them again and again to aggregate more reports!! No amount of diligence seemed to work.. imagine I was not able to find problems.. that reminds me of the adage 'bin mange moti mile aur mange mile na bheekh' ... I had understood there is sure shot knowledge gap from technical and business perspective... after all we are still far from creating tools which would scan and identify and fix code on their own. There are just so many options for every refactoring which one intends o make in the code.. one needs to weigh your options before making code change les it should fall under its own weight... Ok, I digressed because even while conducting my own research I chanced to read interesing articles which would give me a peek ino the future about gainfully utlizing concepts from autonomic computing to application monitoring as an aid to debugging applications... but 'Show me the results' was driving me crazy.. but then as the luck would have it a visit to the the local book shop helped me discover "Bitter Java" and as prophecized by "The Alchemist" when you one truly starts liking something the entire universe conspires to make it happen.. seemed so much true .. he "bitter ejb" chapter seems to have been written just for me a quick read with reports immediately helped me identify the 'chatty' interface between our application and the database.. the server frequent roundtrips are consuming far more time over the wire than conducting any productive work... steriotypically such problems occur when we make far more granular requests than is required or may be executing queries in loops... it helps to find initial symptoms of the problem at the macro level.. such an information can be suitably used in other low performing use cases.. bugs come and go, but I'm accumulating debugging skills ... I'm already feeling the need to study "Refactoring: Martin Fowler".. may be I should get back to reading.. more later

Wednesday, March 4, 2009

I love Johnny Walker...

I love it for the simple reason that it provides me with one of the very core ideology I have decided to follow in my life. It helps me take rough with the smooth and always keeps me brimming with confidence. It helps me overcome difficulties and avoid my indulgence with petty attractions. It helps me take change in my stride. It helps me keep walking...

Tuesday, March 3, 2009

Performance Monitoring Utility

My current assignment required me to create a light weight utility to conduct application monitoring during production and development phases to identify potential performance bottlenecks. The utility which I created is now ready and is under Beta. Key rationale to create this utility were;
  1. Create an unobtrusive (or minimal) way of monitoring the application, although in its current state it does not uses aspect technologies and thus requires us to manually inject code to those applicaion components which we want to instrument.
  2. The utility should be real lightweight so that it could be used at all times to monitor application performance and system health.
  3. Simple to use. Client code should be able to use the utility in an easy to use way. Figuratively speaking, just place your probes and desired parts of your application and assign a logically comprehend able name to it, that's all!
  4. User should be able set monitoring preferences.
  5. Reporting monitoring results.
  6. Currently the utility monitors the execution times alone but can easily be extended to monitor other metrics like memory, cpu etc.
Design Considerations:

To improve simplicity, reduce verbosity and hide inner working of the monitor code a facade to the monitor library is provided so all hat client code needs to do is;

public SomeObject theMethodUnderInstrumentation(){
try{
MonitorFacade facade = MonitorFactory.getFacade();
if(facade.isMonitorEnabled()){
facade.recordExecutionStart("someLogicalContextName");
}
// do some time consuming task here
}finally{
if(facade.isMonitorEnabled()){
facade.recordExecutionStop("someLogicalContextName");
}
}
}
This is all that is required by the developer to instrument it's code. Simple isn't it!! The above becomes transparent to the developer in case we use aspects to define our pointcuts to inject a similar code as above.

It is a common observation that application performance tuning exercise requires an inter disciplinary approach and much is needed to understand the system performance in the right context. It was therefore important to understand the complete execution path under observation. To make this possible Composite pattern is implemented. The intent of composite is to compose objects into tree structures to represent part-whole hierarchies. The call tree is captured which displays the function execution paths that were traversed in the profiled application. The root of the tree is the entry point into the application or the component. Each function node lists all the functions it called and performance data about those function calls. So to put it crudely composite pattern helped me create the tree structure of application components under observation.

Now that we are ready with the basic infrastructure needed to monitor he code performance at all times the next piece of challenge is to create automated load test and as any one with similar experience will immediately identify that creating automated test cases is not that big a deal but maintaining them over a period of time is.. my next task involves around ways to put intelligence into our load test scripts... I woke up pretty early today .... ;)

Friday, February 20, 2009

Tip: Sort a map by values

A handy tip to sort map by values.

//:~
package samples.core.java;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

public class SortMapByValueExample {
public static void main(String[] args) {
Map map = new TreeMap();
map.put("1", "100");
map.put("10", "50");
map.put("100", "40");
map.put("1000", "10000");

List keys = new ArrayList(map.keySet());
ByValueComparator bvc = new SortMapByValueExample().new ByValueComparator(
map);
Collections.sort(keys, bvc);
Iterator iterator = keys.iterator();
while (iterator.hasNext()) {
String key = (String) iterator.next();
System.out.println(key + "-" + map.get(key));
}
}

private class ByValueComparator implements Comparator {
private Map map;

public ByValueComparator(Map map) {
this.map = map;
}

public int compare(Object o1, Object o2) {
int integer = Integer.parseInt((String) this.map.get((String) o1));
int otherInteger = Integer.parseInt((String) this.map
.get((String) o2));
return -1
* (new Integer(integer)
.compareTo(new Integer(otherInteger)));
}
}
}


Sunday, February 8, 2009

Performance monitoring - creating home grown utilities

One of my current focus area is performance engineering, which although is an umbrella concept in itself pretty much sums the need to achieve the non-funcional requirement defined for the software solution. You may find a neat introduction the concept here. As much as it is important from software engineering perspective, talking of it during design session is looked upon as 'over-engineering' and is grossly ignored saying 'It will be one nice problem to solve, but we are not there yet...' probably, I understand the product manager's need to hit the market ASAP.

As they say, 'Dates in the calendar are closer than they appear', we normally start receiving complaints in form of poor user experience, loss of revenue to the competition blah, blah.. so now we have the 'nice' problem actually waiting for us to solve. Frankly, to start with there are no straight answers or atleast I do not have one. What do we do now? Where do we start? Which are the ideal candidates for performance tuning exercise? Here, is what I would do to track the problem. Place an extremely light weight activity monitoring utility in production at all times because I deem it necessary to even capture the usage of the application by the real life users and not us software engineers enmasked as pseudo users [During one of my earlier assignments, the users of the application would simply close the browser window wih out logging out, because the application didn't contained his private data and just that the users didn' like to wait for the application to log out... resulting in numerous open sessions...]

There are plenty of open source and commercially available tools in the market, still if you feel the need to create a home grown solution for some reason, here is the simple idea that I'm working on now to collect metrics from different parts of the application performance and use it for the quantitative analysis of the application.

Provide a ThreadLocal storage to 'StatisticsCollector' which would provide probes to be kept at key parts of the application to record statistics, to start with I'm only collecting execution times. Create a new object each time a new thread is spawned and keep adding metrics for the components with their metrics at collection points and them to the tree data structure which represents the call hierarchy. Finally, once the response is committed for the thread persist the data and reset thread local variables. I have primarily identified following collection points viz. the servlet filter, servlet do*(), JSPs, transactions, cache hits, jdbc layer while they are less in number they can pretty much indicate the slowest moving layer in my application. This information will form the input o iterative process of profiling-tuning-monitoring to gain performance improvement upon completion of each cycle.

Wednesday, January 14, 2009

Buckle up - Enterprise Edition

Time and again people ask me, if I still think I made the right decision to cut short my 'coveted' foreign assignment to return India because I felt it 'did not add value'... well let time keep tab on that. My story is that... whatever role life gives you play it big [this one is lifted from Smirnoff's ad, we can even learn from a Daru company ;)].

We[Indian IT industry] started real small with back office support work but soon gained confidence of the world to provide medium to large scale system enhancements from where we incrementally we created value to achieve customer delight through our efficiency and professionalism. It is no wonder that today IT captains are trusted partners for very large scale system transformation exercises. In essence, we have incrementally moved up the value chain.

Now, it is important for us to move up to the next step where in we need to conceptualize and develop 'product(s)'. Definitely, this would be a much riskier business. But, then are there any options for us but to grow better. The world will truly respect our technical prowess if we 'create' new concepts and 'implement' them... and can there be better times than these. Here is why I think these are the best of time to go deep...
  • Under the current scheme of affairs techies prefer to stay home because much of the quality work will be done off-shore and more importantly an increased focus on domestic projects gives them an opportunity to solve 'their' own problems. This tends to improve employee job satisfaction as it allows them to play 'lead' roles.
  • Working on domestic projects will create more avenues where we can find generic 'patterns' to be created as 'products'.
  • Investing into products will make employee confident about the longevity of vision of the organization leaders.
  • Confidence breeds success.
NASSCOM is equally exhilarated to display the abounding capacity of Indian software companies representing products conceptualized, designed and made in India. It has come up with a logo as displayed above. You may wish to read more here

It is all in mind and we can definitely make a difference by shaping our reactions to the events in life.

Friday, January 9, 2009

Buckle up!

Way back in the year 2002, I witnessed the placements of my super seniors. I remember it took some one month of time for its completion... compare that with ours which got over in a matter of a day or two. In my observation it made them a better human being. I really thought if God could grant me those challenges to me too.

Everyone would agree these are tough times, but then I have a difference of opinion about the way we react to the current state of affairs. There is wide spread fear of failure and confidence index is diving south. Here, is how I plan to handle the situation at hand.
  • First earn and then spend.
  • Innovate at work.
  • Remain competitive.
  • Retain your enthusiasm.
  • Protect your vision of the future.
  • Protect your humor, always.

Thursday, December 18, 2008

ek khayal ye bhi

Courtsey- Rahul Mishra

जिन्दगी ये किस मोड पे ले आयी है ,

ना मा, बाप, बहन , ना यहा कोई भाई है .

हर लडकी का है Boy Friend, हर लडके ने Girl Friend पायी है ,

चंद दिनो के है ये रिश्ते , फिर वही रुसवायी है .



घर जाना Home Sickness कहलाता है ,

पर Girl Friend से मिलने को टाईम रोज मिल जाता है .

दो दिन से नही पुछा मां की तबीयत का हाल ,

Girl Friend से पल - पल की खबर पायी है,

जिन्दगी ये किस मोड पे ले आयी है …..



कभी खुली हवा मे घुमते थे ,

अब AC की आदत लगायी है .

धुप हमसे सहन नही होती ,

हर कोई देता यही दुहाई है .



मेहनत के काम हम करते नही ,

इसीलिये Gym जाने की नौबत आयी है .

McDonalds, PizaaHut जाने लगे,

दाल- रोटी तो मुश्कील से खायी है .

जिन्दगी ये किस मोड पे ले आयी है …..



Work Relation हमने बडाये ,

पर दोस्तो की संख्या घटायी है .

Professional ने की है तरक्की ,

Social ने मुंह की खायी है.

जिन्दगी ये किस मोड पे ले आयी

Saturday, December 13, 2008

haath chute bhi to rishte nahin tuta karte...

... just watched 'Dasvidaniya' which is based upon the basic premise that 'live like this is your last day' but then it is ironical that one makes an attempt to live life at its fullest only when one realizes this is going to be his last day... why? why do we hold grudges? why can't we just forgive and forget? why can't we instead part ways before making things worse leaving behind a scope for a welcome greeting till we meet again? It is our indulgence over the small picture rather than our involvement in a larger vision which makes all the difference... may be I need to learn much more... practice abstinance.

Tuesday, December 9, 2008

Travelogue: Bidar Fort, Karnataka

Do u mind coming with us for watching 'Transporter 3'?! O.K, I'll pick you up in 15 minutes... was all that I heard... 2115 hrs, I told myself there is no time for cooking, we shall have dinner somewhere... later we reached IMax theater to discover a big group of boys inquiring at the box office about tickets.. as luck would have it we missed the movie.. boys had a bad mood and were wondering what to do next.. someone said 'hands up for ice cream on Necklace road?' and all were ready... I have started believing that water bodies have some great healing power they seem to absorb your negativity and a big scoop of ice-cream induces the much needed positive energy in you.. so it was one gr8 combo!! Cruising past midnight on Necklace road.. cool breeze, silent lake and shimmer on the water surface is just bliss... here our gang just sat there on the lawns next to the lake talking about life and things like terrorism and petty politics and things which are taking its toll on our lives.. when Ani said ... all I need is one long bike ride.. pat came the reply, lets go Bidar.. MP said 0500 Hrs sharp and immediately some one cribbed about the timing ... come on guys its Sunday!! said Sindwani.. it is too early.. after litle ping-ponging upon he issue everyone agreed to 'go'... nevermind, in the morning finally 14 of us were ready for the trip, we started at 0930 hrs from Karkhana road and hit NH9 at Miyapur and we made our first pit stop at Sadashivpet next to a Dhaba. We ordered Aaloo paratha as we can get them fast and were hungry like dog. I muss say the food was good as each one us 'overate'... hehehe.. after a cup of tea we hit the road again with standing order to meet again at Zafirabad to leave NH and move to SH-4. The road stretch from Zafirabad o Bidar owan goes through state borders and is very peaceful to drive through the jungles on both sides... on your we found several cart loads of sugarcane ... those farmers were graceful enough to give us a cane to each one of us... and quite naturally each one of us had a childhood story to share.. I was wondering when was the last time I visited my nanihal, I stopped counting years.. I felt bad.

Upon reaching the town area we were welcomed by a giant sign-board displaying distance and directions for the places of interest in the dusty town. We decided to start from Narsimha Jherni and believe me not once for religious reasons but to explore the cave with chest-high water levels with bats on the roof top it sounded so exciting... after the holy dip into the water we had a good bath at the natural spring in the temple campus.

We then decided to go for Gurudwara famous for its linkages with Guru Nanak Sahib and this time again the primary reason was the 'Langar', I actually could imagine hot-tasty halwa in my mouth... remembering 'Bangla Sahib' at Delhi... Legend has it that the areas has its only sweet water lake thanks to Guru sahib.

'Enuff of pligrimage!!' frowned one said after we had stomach full of food at the 'langar' and we now decided to exploit the photographic opportunity at the fort taking advantage of the sun. But, before we could go there I decided to check out some Bidri craft work, which is special to the area, try googling for the same and you might like it as well.

Here, again the place is very beautiful and really really provides ample of photo opportunities which our paltan consumed to its maximum. We had some great fun here. Some of the excitement is captured here.

Saturday, November 1, 2008

SOA-Reference Model

Read SOA-RM from OASIS

If you are the one who likes to understand the very basics and the core concepts associated with the Service Oriented Architecture you will find the above document one real treat to read, rest assured you can go with absolute clean slate, you actually learn a lot.