Tuesday, August 9, 2011

Linux/Ubuntu - Sharing/Downloading same Torrent on dual boot

After thinking for many years recently I boarded the Linux Bandwagon. (Ya previously I either didn’t have time or courage to try it ?)
But now with so many user friendly options from Ubuntu like ‘Live CD’, ‘WUBI’ the transition is with less panic.
I know many people will use Ubuntu with dual boot with Windows.  Here in a series of blog I will be discussing few problems or settings that I did.
By the way dual boot install is really simple and there are many blogs already out there to help out, though some time finding the right one is an issue. So in case you are finding it difficult then leave a comment.
Anyways, getting on to the point for this blog, like many people I wanted to share the uTorrent between both the OS – in other words  - to continue downloading the torrents in one OS which was added / started in another OS.
This on high level requires the following: uTorrent download location should be same for both installation (drive letter should not change)
I had this setting on Win7/WinXP dual boot, which simply required following:
1.    Don’t auto-install uTorrent; it will put itself to your user directory which will be different in both OS. Simply unzip it to a drive whose drive letter remains the same on both OS.
2.    Make sure the download location is also the same (including the drive letter)
3.    Best way to achieve this, manually change the drive letter for one of the drive to a higher alphabet like L, or T in both OS.
4.    Put uTorrent directory and download location on this drive.
5.    You are done.
But for Ubuntu this is bit of issue, reason -  if you are uTorrent fan like me, you will try to get uTorrent for Ubuntu/Linux, which is there, but with no Desktop UI like windows. (Though there is a web UI)  and also the installation requires starting the utorrent server from command prompt, which can be bit geeky for some users.
So I tried different options which are given below and their Pros and Cons

uTorrent for Linux
Pros:
•    We love uTorrent for Windows
Cons:
•    Few issues given above
•    In Web GUI, you cannot yet provide the download location per torrent, everything goes to default directory. May be in coming version they will do that.
•    To auto start on OS start, again some geeky stuff is required.

uTorrent using Wine: U can install wine and install uTorrent for windows. But like the way many other people think, what’s the use of having non-widows OS if you are using everything using windows emulation layer

Transmission - Default Torrent Client for Ubuntu: The interface is very different for uTorrent so you may not like it. As far as I remember doesn’t provide a custom download folder name. But as UI was very different I didn’t check too much.

Deluge:
Pros:
•    Interface is very similar to uTorrent in widows
•    Come with its own UI, and no web UI issue.
•    Shows an indicator applet (system tray icon) and also minimizes/close to it. (for people alien to Ubuntu, this obvious feature is not possible for most of the software or requires some more geeky stuff)
Cons:
•    Though you can have download location per folder, you cannot change the final folder name. For example if you are downloading a torrent and provide a download location as \\home\media\download. IT will create a folder inside it with a default name in the torrent file.

qtTorrent
•    Very similar to deluge but again no custom folder name per torrent
•    No system tray applet.
So I went ahead with Deluge because there is just one folder name issue and it provides many feature out of the box which are either not available in other clients or require some workaround / hacks to get them.

Steps for Deluge
1.    Simply install and access from the Applications > Internet menu.
2.    Before you add any existing torrent: There is one irritating behavior of Deluge, if you add any existing torrent, it will move the torrent file to its ‘.config’ folder and will also rename it to its hash code. Wow… But there is a small setting to fix this, in the Deluge preferences, enable the “Copy torrent file to folder” option. And provide the location of folder which is used by your windows uTorrent client
3.    Once you have done this setting add any new / existing torrent and give the base folder location path.
4.    While adding a torrent from Windows client, make sure you just provide the base folder and don’t change the default folder name else deluge will download to the default folder and hence different location.
5.    In case you have existing torrents with custom folder name,
   •    add torrent to deluge
   •    it will create the default folder name
   •    Stop deluge
   •    Move the partially downloaded files to the default folder created by deluge
   •    ‘Force recheck’ in deluge. If it shows correct download percentage, start it
   •    In widows client move the download location to the default folder created by deluge. Force recheck.

I know it can be lot of work if you have lots of existing torrents with custom folder name, but once you follow the process for new torrents its seem less. Till the time deluge adds the functionality for custom folder or uTorrent comes up with default UI for Linux, you will have to live with this.

Disclaimer: I did it my way, may or may not work for you. Try at your discretion :)


Thursday, June 30, 2011

Get/Analyze the IBM JDK Heap DUMP

Was recently trying to do something that's suppose to be really simple but again was not... Looks like another case of set of engineers having strong "I did it my way.." syndrome. + The great IBM tools which are really strong but its easier to find your kid in a local fest than finding the help for IBM products. After looking through several web pages and sites (some of them even gave wrong/outdated information) I was able to do it. At one point I felt like I am getting clue from one page just to get redirected to another :), anyways enough of my frustration and required steps are given below:

1.     Get the DUMP for IBM JDK
Use the -Xdump argument on the command line or in the Eclipse run configuration. You can have multiple -Xdump stanzas on the command line and also multiple dump types driven by one or multiple events. Thus, -Xdump:heap+java:events=vmstart+vmstop would create a dump agent that would drive both heap and Java™ dump production when either a vmstart or vmstop event was encountered.

a)  Execute the program with the argument -Xdump:heap:events=vmstop
b)  Once the program starts stop/close  it. On Eclipse/Windows Console you will see something like this:

JVMDUMP006I Processing dump event "vmstop", detail "#00000000" - please wait.
JVMDUMP032I JVM requested Heap dump using 'C:\Program Files\MyProduct\heapdump.20110630.133125.776.0001.phd' in response to an event
JVMDUMP010I Heap dump written to C:\Program Files\MyProduct\heapdump.20110630.133125.776.0001.phd
JVMDUMP013I Processed dump event "vmstop", detail "#00000000".

2.     Install the Heap dump analysis tool
a)      If you don't already have the Support Assistant Workbench, download and install the IBM Support Assistant Workbench.
b)      From the Support Assistant Workbench, click Update > Find New... > Tools Add-ons.
c)       In the window that pops up, select the tools that you would like to install and follow the on-screen instructions to complete the installation. When the installation is completed, the Workbench will restart.
List of tools that you can install are given below, but I couldn’t find any so I installed the one which looked familiar. Important one that I think will do the job is HeapAnalyzer
§ IBM Monitoring and Diagnostic Tools for Java - Dump Analyzer
§ IBM Monitoring and Diagnostic Tools for Java - Garbage Collection and Memory Visualizer (GCMV)
§ IBM Monitoring and Diagnostic Tools for Java - Memory Analyzer
§ IBM Monitoring and Diagnostic Tools for Java - Health Center
§ IBM Thread and Monitor Dump Analyzer for Java (TMDA)
§ Multicore Software Development Kit for Java (MSDK)
§ HeapAnalyzer
§ IBM Pattern Modeling and Analysis Tool for Java Garbage Collector (PMAT)
§ Performance Analysis Tool for Java

3.     Starting Heap Analyzer
ISA Version 4:
  1. Select Analyze Problem from the Welcome tab on the home page.
  2. Open the Tools tab.
  3. Select HeapAnalyzer
  4. Once started Open the dump file created in first step
Another tool that’s mentioned on the site is Memory Dump Diagnostic for Java (MDD4J) but couldn’t find it

Sunday, June 19, 2011

more tools, less work

Recently read the article Are Java and .Net becoming legacy platforms?. Though don’t agree to the title of the article but I do agree with the discussion that the author brings up. With so many new languages sprawling up you kind of feel that Java is one of the older members.

Also with recent ‘Oracle Java mess’ I can understand why companies like Google are coming up with their own development platform.

But beside that, in terms of features does the world need so many dev tools. One of the discussion points in the article was the absence of closures in Java. But, come on; are these so important to make Java incomplete? And the security updates, which software does not have those. There can be reasons surrounding the politics but not the overall features. You can hate the process (aka JCP) but don’t hate the language and at-least not for the wrong reasons.

Java is fulfilling the purpose since so many years; I haven’t seen any practical situation where Java was a blocker in any software project I worked on. And how many new languages can you remember have actually made their mark in last 15 years - Ruby, even with a wild guess you will realize that hundreds of other attempts ate dust and god knows what happened to the product managers who started writing their code using those new tools.

I think the problem with so many new upcoming languages is more to do with “I want to do it my way”. This is very simmilar to ‘teenage mindset’ where you just want to show off your new language skills just like a new Apple gadget. And this mindset is somehow encroaching into the head of some senior developers. Learning new things is not bad but when you are working on Enterprise software, it’s all about developing new features and develop fast. You can’t simply put that limited time in trying out new things especially when the existing ones are working fine. And why not simply use that extra time in making existing things better. Say, checking out the existing code for anomalies creeping into your product since 10+ year.  Refer my previous blog:  Mumbai Vs Software architecture ...

In nut shell, at the end of the day I will like to see 95 products in 5 languages rather than 5 products in 95 languages.


Saturday, February 12, 2011

Please Sir, don’t apply that Design pattern here…

Not sure how to start on this, but since many years I have seen a disturbing trend in Software industry - Being obsessed with technology, being obsessed with new things and having those inner fetish towards the tools rather than the work itself.
What I mean is sometimes developers/architects use certain technologies not because there is a need in the current architecture but because either it’s an ‘in thing’ everyone is using or it’s something new they recently learned or may be got a free book on it.
For instance, I worked with some highly techie guys who created a very robust multi-tier system which use to communicate with many third party data stores (including mainframes). And for each system the folks used different set of middle wares. Somewhere they were using MSMQ, somewhere IBM MQ and what else. You name the middleware and they had used it.   
I talked to one of the guy to understand why it was done, and he clarified “we were bunch of young guys mad about new things with lot of zeal to try them”.  End result, when the whole big application was transferred to a new team, they had no clue what was going on, and even the previous guys were not having the complete information to give a good KT (quite obviously there was no documentation what so ever)
Being a techy guy I myself get interested in new tools, but that’s my leisure time work and not when I am doing official project. Software folks need to understand that learning is a good thing but should be tried on a personal level, may be a PoC. Just because you have learned new things doesn’t mean you should simply apply it everywhere.
(just to list few of the other over used things - Design patterns, XMLs, and now every manager is talking about Cloud :). In a recent meeting, few managers kept using Cloud and SaaS interchangeably, and even after lot of argument I was not able to convince them that both the things are different)

Edit: Recently came across two articles on the same lines, good read:-
The Duct Tape Programmer
The 7 deadly sins of software development

Wednesday, February 9, 2011

Eclipse plugin editor > Extension tab Issues

While adding / updating any extension in Eclipse Plug-in Editor, many times you may have seen that you add an extension point and right click on it > New > Shows only “Generic”.
For example, in tutorials available on web you will see something like this: 
But in your IDE you will only get the Generic option. Also many other extension options are missing.
Solution: Get the source for the corresponding plugins. One way is to download the eclipse with source included. But that can be too length process. Another quick fix is using Eclipse 'Install new Software' wizard:
  1. Go to Help - Install new Software
  2. Select the helios (corresponding) site
  3. In the filter box type: Eclipse RCP Plug-in Developer Resources 
  4. Select the filtered option displayed and install. 
  5. Restart Eclipse and you should get the proper options while working with Extensions

Friday, February 4, 2011

Equinox: Reading External File

I was looking for a way to read a file from the current directory. The business scenario is: We are opening a socket connection from an equinox bundle.
Currently the port for the socket communication is hard coded. In a rare scenario it’s possible that the port will be already in use. We should be able to provide the port from outside the execution environment. 

One way is to pass it through the launch arguments. But sometimes getting hold of config.ini or starting the application from console may not be possible. (In case of custom launchers)

Second option is to read the port from an external file. We can use following to pick the file:

this.getClass().getProtectionDomain().getCodeSource().getLocation() - Gets the current location of the bundle.

If we have kept the file with port at the same location then read the file using:
URL url = new URL(this.getClass().getProtectionDomain().getCodeSource().getLocation()
+ "/../messages.properties");
InputStream inputStream = url.openStream();
Properties properties = new Properties();
try {
properties.load(inputStream);
} catch (IOException e) {
e.printStackTrace(); 
}
socketport=properties.getProperty("SocketPort"));

Not sure if that's the best way. But surprisingly I didn't find any other way to read a file from the current path kept outside the bundle; and even this is specific to Equinox and not available in other OSGi implementations. If anyone is aware of any other way then do let me know

Friday, January 28, 2011

Configure embedded Jetty in OSGi enviroment

As mentioned earlier, recently was working on using embedded Jetty server in an OSGi environment. Though the information is available on web, but quite scattered. Especially how to configure or debug jetty. So, below is the collated information:
Once you have the up and running servlet as per the steps at:
http://bryanhunt.wordpress.com/2010/05/14/osgi-as-a-web-application-server/
You can do away with auto start of bundles in the launch configuration, use the following code in the activator of your bundle
Bundle bundle = Platform.getBundle("org.eclipse.equinox.http.registry");
if (bundle.getState() == Bundle.RESOLVED) {
 bundle.start(Bundle.START_TRANSIENT);
} 

To make sure your bundle auto starts, implement the startup extension. In your plugin.xml put this:  

    <extension point="org.eclipse.ui.startup">  </extension>

Configure Jetty:  
Now, many times you will not have the option to change the config.ini to provide the port, or you want to configure the Jetty from within your application, there you will need to use the JettyConfigurator class. Use the following code in the activator of your bundle
Dictionary settings = new Hashtable();
settings.put("http.enabled", Boolean.TRUE);
settings.put("http.port", 8080);
settings.put("http.host", "0.0.0.0");
settings.put("https.enabled", Boolean.FALSE);
try {
     JettyConfigurator.startServer("my.jetty", settings);
} catch (Exception e) {
   e.printStackTrace();
} 
You can configure many other settings using the JettyConfigurator as mentioned above. 

Friday, January 14, 2011

Thank you for the computers, Microsoft

Ok, many people will raise their eye brows and many would have already started writing a hate mail … but yes if there is one company I will give credit for the popularity of computers then it would be M$.

Just to clarify I am not one of this die hard Visual Basic fans, I am totally into open source, and have my own reason to hate M$ (notice the dollar sign)

But if it would not have been M$, the computers would have been still a luxury item for the geeks; people who will give confusing commands to open a vi editor and type Hello world, save the file with Esc : wq  and then dance around in the room for what they have accomplished.

Microsoft was one company which made the things easy, made the computers accessible to the common man and continues to do so.

When I was in college learning computers, Unix was part of semester curriculum, we were told that Unix was such a stable system that no change was required in it for almost 16 years. (ok, sound like another urban legend). But even in practical terms why not make things better, why I should type Esc+a, just to start typing, and Esc+x to delete, when that delete key is right there in front of me. I know many geeks and vi editor lovers are already up in arms against me,  but dude, no one is taking away your geeky things, but please evolve …

Thank god, MS understood and made better useable systems (I do understand the it was Apple which brought in the good looking GUI interface and tried to break the monopoly of IBM, but a PC with almost negligible applications available priced at 2500$ in 1984 was bit too much for common man, and then chain of wrong decisions simply ruined the company… )

Love it … hate it… but M$ is one company because of which you are able to do most of things that you currently do on your computer… (of-course apart from your geeky stuff)

Monday, January 10, 2011

OSGi/Equinox: Remote Debug embedded Jetty Server

Today got stuck in one of those famous Java issues – Things not working and there are no errors and no exceptions. Grrrrrrrrrrrrr, whyyyyyyyyyyyy…………

Resorted to one of my oldest friend - remote debugging.
But this time the situation was different. The servlet was running as an Extension to Eclipse Application published on embedded Jetty server.
Looked around how to start the embedded server in debug mode and specify the debug port. But most of the articles talked about some Maven configuration. I know, open source community is big fan of Maven but I haven’t worked much on that. And I just want to start the server in debug mode, why all pom.xml and other stuff. (can’t really understand why the documentation of even the most popular open source products is so bad, will talk about this some other day)

Anyways after lot of wild goose chase realized that as its embedded, I need to just remote debug the JVM. So did what you do to remote debug any java application:

In Eclipse IDE, added the following in the VM Arguments in my Eclipse Application launch configuration dialog:
-Xdebug -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n
Where 4000 is the debug port we need to connect.


Started the application from Eclipse itself and then start remote debug like any other application server:

Microsoft: Late Again

Read the news.  Today read an article on how Apple has very silently inched towards being an enterprise company. A company very popularly known as the toy maker is no longer just a toy maker. First there was news on how iPads were being introduced in the schools in USA, and now the big one: JP Morgan Chase, company with one of the most complex procedures in terms of security, embraces the iPad. 
Though most people are talking about how it’s clear and present danger for RIM Blackberry, but I feel, in long term, it’s a clear competition to Microsoft.
First Microsoft was slow in catching up the Internet boom (which it publicly accepted few years back) and Google, quite aptly, won the battle in big way. MSN Search,  Live Search and now Bing, Microsoft is still lagging even after so many make overs.
But now the mobility boom, why Microsoft is still trying to sell desktops when whole world is moving towards internet and mobile gadgets. Though there was a recent launch of Windows 7 mobile, but if you see the other happenings around the world, it looks like a drop in the Indian Ocean.
A company with such a nice hold in IT Market is again late in catching up on Mobility enterprise solutions. The day will not be far when M$ cash cow ‘Windows’ will be just another redundant product.  M$ needs to check what their product managers are busy in and more importantly are they still paying millions of dollars them …  :)

Edit:  Like everyone else I Love the moments, when I get the chance to say "I told you so". A recent news gave me that moment.

Sunday, January 9, 2011

Mumbai Vs Software architecture ...

Yesterday I was watching discovery channel (ya, sometimes I do that also), while checking on one of my favorite series “Big” , found that the episode was actually talking about one of the Indian cities “Mumbai”. The name itself brings so many pictures. For the people in other part of the world, this city is business capital of India. The reason for the episode and for this blog is “this relatively small city is one of the most populated cities in the World (in-fact second most populous city in the world)”.

The episode talked about two of the major infrastructure projects currently in progress: Bandra–Worli Sea Link (Part of Western Freeway) and Eastern Freeway. Not going in too many details as you can check the Wikipedia links I have given above, one of the projects is a road link over the sea and another one is mostly elevated road link. Reason for this, as correctly mentioned in the episode, there is no space left in Mumbai so only option is to either build the road in the sea or in the air.


Though I am not against the new infrastructure projects but in the City like Mumbai and country like India where these costly projects are no easy tasks, isn’t this a Gold carpet to cover the previous mistakes. Mumbai is already packed to the brim; instead of making things seemingly better for more people to pour in, shouldn’t we rather think of better planning. One option is to make sure that apart from the important businesses which should stay in Mumbai (Mumbai is one of the busiest port in the world) other companies should be asked to move out slowly or at-least a complete stop of any new businesses until the infrastructure is capable of supporting the existing bulk.


Coming back to the title of the blog, I have seen a similar situation in many software projects. The amount of code that pours in rises exponentially in years and no one even looking into what’s already existing and if the current architecture can support the new functionality.
To mentioned some of the rather funny and worry some cases , in one project we completed the i18n of 100s of files; later to find that it was all dead code no longer used in the product.  (all getting build, packaged and published to all customers). In another instance, we did lengthy investigation to implement a long awaited feature, created the design and at the time of implementation found that it was already available in the code. No one cared to document or use it.
 

Why so much effort wastage on solving the wrong problems. How much time it takes to create at-least the architecture document of a software product? How much time does it take to understand the current architecture, clean up things before putting in more stuff. Since many years I continue to get amazed. And just for information, its 8 months since we informed the client about that dead code, it’s still there (build, packaged and ….)