Thursday, October 29, 2009

Great day

I worked with MS Power Point the whole day today. This is how I feel now.



Isn't it funny? Even solving the most complex Java class loader and reflection related software bugs does not bring me to this state as fast as MS Office does. I have nothing against Power Point, it's probably just me. After a day spend on preparing a presentation I feel like I wasted 7 hours of my precious life!

Wednesday, October 7, 2009

Installing and using OSGi Deployment Admin Service

This is my first tutorial published on this blog. I hope you'll find it helpful and interesting.

In this tutorial you will:

  • Learn where to find and how to build and install an OSGi Deployment Admin Service implementation (well, at least partial implementation, but I guess you are welcome to contibute to it)

  • Get to know the structure of a standard "Deployment Package"

  • Learn how to use the Felix Web Console together with Deployment Admin to install and run a full OSGi based application (consisting of multiple bundles)



I assume that you are familiar with OSGi Service Compendium Release 4 specification (particularly section 114) so I will simply skip the introduction part to save myself some typing.

In this tutorial I will concentrate on one of the most essential responsibilities of a Deployment Admin Service. As described in Service Compendium the Deployment Admin "provides a Deployment Package concept to install and uninstall bundles and related resources on an OSGi Service Platform as an atomic unit"

Isn't it cool? We can package all our bundles (together with their configuration and permission information) into a single archive and then deploy it at once! Great!

Let's check it all out then.

Step 1: Starting the OSGi Container


In this tutorial I will use "Equinox 3.4". On the downloads page select the "eclipse-equinox-3.4.zip" and save it on your hard drive. While you're on the equinox downloads web site, take a look at the "Add-on Bundles"... do you see Deployment Admin there? No. Me neither :-) But don't worry, we will take care about it later.

Unpack Equinox (stuff inside the "eclipse" directory) to some meaningful directory (e.g. /opt/equinox or C:\Software\equinox). After you are done, cd to the instalation folder and start the container by issuing this command:

$ java -jar plugins/org.eclipse.osgi_3.4.0.v20080605-1900.jar -console


Great! It works. Now we need to customize the initial configuration a little bit to make sure that all required services are there before we begin with Deployment Admin and Felix Web Console.

Exit OSGi console (type "exit"). Go to you equinox/plugins/configuration directory. Create new file called "config.ini" and fill it with the following content:

osgi.bundles=org.eclipse.equinox.common_3.4.0.v20080421-2006@2:start,\
org.eclipse.osgi.util_3.1.300.v20080303.jar@2:start,\
org.eclipse.osgi.services_3.1.200.v20071203@2:start,\
org.eclipse.equinox.event_1.1.0.v20080225@2:start,\
org.eclipse.equinox.util_1.0.0.v20080414@2:start,\
org.eclipse.equinox.cm_1.0.0.v20080509-1800@2:start,\
org.eclipse.equinox.ds_1.0.0.v20080427-0830@2:start,\
org.eclipse.equinox.log_1.1.0.v20080414@2:start,\
javax.servlet_2.4.0.v200806031604@2:start,\
org.eclipse.equinox.http.servlet_1.0.100.v20080427-0830@2:start,\
org.apache.commons.logging_1.0.4.v20080605-1930@2:start,\
org.mortbay.jetty_5.1.14.v200806031611@2:start,\
org.eclipse.equinox.http.jetty_1.1.0.v20080425@2:start


Start the equinox again and type "ss" for status information. You should see this:



Great. Now lets play with the new stuff...

Step 2: Getting the Deployment Agent Implementation


I've spend some time googling to actually find a "half-functional" implementation of this service. I don't know, maybe the implementors thought that this service is kind of unimportant, but I find it quite useful... whatever. The only existing implementation (that I know to this point of time) comes from Apache Felix project. It is however not available yet in form of a stable, binary distribution. To use it you will need to download the sources and build it yourself. The good part of the story is that Apache guys used Maven as their "build tool" so getting the jar is just the matter of typing one simple command.

Here's what you do:

  1. Get the sources from the Felix SVN repository

  2. Build the project with "mvn clean install"

  3. Copy the newly created jars (org.apache.felix.deploymentadmin-0.9.0-SNAPSHOT.jar, and org.apache.felix.deployment.rp.autoconf-0.1.0-SNAPSHOT.jar) to your equinox/plugins directory.

  4. From the Felix downloads website get the Dependency Manager (version 2.0.1 and copy it to the equinox/plugins directory (required by Deployment Admin Service)

  5. Update the equinox/plugins/configuration/config.ini file adding the new bundles to the end of the list

    ...
    org.apache.felix.dependencymanager-2.0.1@2:start,\
    org.apache.felix.deployment.rp.autoconf-0.1.0-SNAPSHOT@2:start,\
    org.apache.felix.deploymentadmin-0.9.0-SNAPSHOT@2:start



Start Equinox. Type "ss". You should see all services as "ACTIVE".

Step 3: Creating the Deployment Package


Nice. The Deployment Admin seems to run just fine. It would be good to check out how it deals with a standard "Deployment Package".

What is a deployment package? Well, according to spec - "A Deployment Package is a set of related resources that need to be managed
as a unit rather than individual pieces. For example, a Deployment Package
can contain both a bundle and its configuration data. The resources of a
Deployment Package are tightly coupled to the Deployment Package and
cannot be shared with other Deployment Packages."


Let's create one then, a really simple one. First, lets take a look at the basic structure of a *.dp file (MIME type: application/vnd.osgi.dp).


deploymentpackage-0.0.1.dp
|
- org.nowaqblog.bundle1-0.0.1.jar
- org.nowaqblog.bundle2-0.0.1.jar
- META-INF
|- MANIFEST.MF


As you can see our deployment package is a simple jar/zip file (having "dp" extension) which consists of two bundles and a MANIFEST.MF file. The bundles are the complete application that we want to deploy using Deployment Agent. The MANIFEST.MF consists of specialy defined sections. The "global section" and multiple "name sections". The content of these sections is well described in OSGi Sevice Compendium (114.3.3).

For the purpose of this tutorial I created a simple deployment package MANIFEST.MF file like this:

Manifest-Version: 1.0
Created-By: 1.6.0_13 (Sun Microsystems Inc.)
Created-At: 1254918423406
DeploymentPackage-ManifestVersion: 1
Content-Type: application/vnd.osgi.dp
DeploymentPackage-SymbolicName: org.nowaqblog.deploymnetpackage
DeploymentPackage-Version: 0.0.1
DeploymentPackage-Copyright: Nowaq (c) 2009
DeploymentPackage-ContactAddress: mailto:your.email@host
DeploymentPackage-DocURL: http://host/doc

Name: org.nowaqblog.bundle1-0.0.1.jar
Bundle-SymbolicName: org.nowaqblog.bundle1
Bundle-Version: 0.0.1

Name: org.nowaqblog.bundle2-0.0.1.jar
Bundle-SymbolicName: org.nowaqblog.bundle2
Bundle-Version: 0.0.1


So, your job is simply to package all the bundles being the part of your application into dp file and add appropriate description in the MANIFEST.MF file. Simple, isn't it?

Step 4: Installing deployment packages via Deployment Admin Web UI (Felix Web Console)


Ok. Now we have all that we need. The deployment admin and the deployment package are ready to be used. How to do it then? Well, two options come to my mind. We could either extend the Equinox Management Console with a new command or use the Felix Web Console and deploy our package using web interface. You may find the first approach cooler (you learn how to use Deployment Agent API), but for the sake of simplicity I will stick with the second approach in this tutorial.

First we need the web console installed. Go ahead and download it from Felix web site (http://mirror.uoregon.edu/apache/felix/org.apache.felix.webconsole-1.2.10.jar).

Add this new bundle to your equinox startup configuration. (Add new entry in the config.ini file.)

...
org.apache.felix.webconsole-1.2.10@2:start


Start equinox and type "ss". All bundles should be "ACTIVE".

You may now check out the Felix Web Console at http://localhost/system/console. You will need to authenticate with "admin/admin". Play around a bit and go to the "Deployment packages" tab. This is the one of particular interest for us.



Step 5: Deploying the application to the OSGi Container


This is the easiest part of the story :-) In the Deployment Admn view of the Felix Web Management Console browse for your "dp" file and click on Install/Update button. Your package should deploy in a few seconds. The web interface will provide you will all the information you need.



Check out equinox console. The packages should be there indicating the "ACTIVE" state. Yeah! You just deployed your first "Deployment Package" using a "Deployment Admin Service". Congratulations!

Monday, September 28, 2009

Toshiba Satellite P100-102 - for Windows XP users only

Three years ago my girlfriend bought herself a notebook - The Toshiba P100-102. We've chosen it together as it's always better to have more critical points of view when it comes to buying such stuff. Our decision was based on multiple aspects. The critical ones were quality, performance and display size. My girlfriend upgraded this list with the additional one - "the looks". This notebook really rocked. Even today, after three years its performance would be totally satisfactory if not... the BIOS and the "f***n" graphic card cooling issue!

Toshiba mounted the "NVIDIA GeForce Go 7600" card into this great and whatsoever beautiful box. This was the largest mistake the company could ever make! Why? This chip has to be cooled down with a fan. After three years of what I would call "normal usage" the card simply DIED! And as you would expect, without the card the rest may be considered DEAD too!!! The funny part is, my girlfriend did not play any games, the chip did never work under extreme pressure. So how can that be?

Well, I always trusted Toshiba and believed that what they build will run for at least next 10-15 years (this was the case of my first notebook with Celeron 650MHz - it still simply runs!). What the hell did you guys do? Did you change your strategy from building quality products to building shit and forcing people to change their boxes every year?? I hope not, because if you did, I'll never buy a Toshiba again!!!

So what happened with the card? Did it overheat? Oh YES it did! Why? Well, this is what I found on nvidia Linux support forum after doing some research on "fan problems + P100 + geforce go". The guys explain how Toshiba controls the fan cooling the GPU. Here's what some said:

"... The modified Toshiba nvidia driver is constantly polling the MAX6659 sensor and then writing something into it's own embedded controller that is controlling the fan. So, I don't think it's a problem with the nvidia drivers but instead with Toshiba simply not telling nvidia how to control the fans they are using on their nvidia based laptops..."

This means:

  • you're stuck with old XP (note: not only windows! you are stuck with XP!)

  • you're stuck with old Toshiba modified NVIDIA drivers

  • you're possibly stuck with specific BIOS version too (at least you may hack it easily)

  • well... in other words, this notebook SUCKS!!! (as well as many other based on same idea and GeForce Go GPUs)

The whole cooling system story sounds a bit like a "big hack", immaturity and incompetence of the notebook manufacturer! So how do I see the Toshiba notebooks now? I will say just one thing. I am an OpenSource software fan... I don't like to be limited... and I absolutely HATE low quality components (including software of course) in my notebook!

So what am I going to buy now (apart from new, old GeForce 7600)?

Thursday, September 24, 2009

When should you reinvent the wheel?

You will be warned by so many software developers to not make this big mistake and reinvent the wheel again. They will say that this is purely just a waste of time. Your solution will be new, not properly tested and probably not efficient too. In other words "it will suck anyway!" Well... they are totally right! Well.. at least in most of the cases. There are however some buts... and this is going to be the subject of this short blog post.

There are cases when reinventing the wheel is exactly the thing that you want to do! This is connected with two very important subjects: education and evolution. Let's take Intel as an example. What would it be if they stuck with their i386 processor implementation and not reinvent it again in form of i486, then Pentium and finally Core 2? The technology changes... did you ask yourself why? Because people invent new things, often by reinventing the wheel. Those changes allow other people to go further by getting rid of old limitations (e.g. performance, functionalities, etc.). This leads us towards optimization of our existing solutions ("the old wheel") and creating new ones ("rocket powered multi-road moon wheel" - which is still a wheel, but a better one).



Also, if you are newbie in the IT world willing to become a "guru" in the future. How the hell will you get to know how stuff works if you have never looked inside of it? How can you make it better if you are not allowed to change the hearts of it?

If you have time and creative mind then go ahead and do it. Please, reinvent the wheel so that I can use it in my next large, time intensive project allowing me to make a lot of money ;-)

Wednesday, September 16, 2009

The wisdom of "Döner Kebab" consumers

I was pretty hungry yesterday in the evening so I decided to go to the city center to get me a "Döner". The plan was good, the only problem I had was that I didn't know which place to choose. The city of Munich has hundreds (or rather thousands) of them! Each place offers very similar product for the similar price. How do I choose the one offering a good quality and won't cause me stomach aches at night?

So what did I do? Well... I just relied on the instinct :-) Sounds easy, but as soon as I got what I wanted (a nice, fresh and tasty "Döner") I realized how complex and logical my decision making process was. (Tip: It has something to do with groups.)

Once I got to the city center I walked along the street for a while passing "Döner" bars. I didn't go to the first one, not even to the second one or third one. The one I've chosen was somewhere in the middle of the street. Just a typical "Döner" place (small and a bit dirty looking). There was however one significant difference if you compared this place to the other ones. In this bar there were people, many people. What's more, people who were waiting in a queue for their food to get prepared. Why did my brain told me to go there and wait with those guys? Illogical, isn't it?

No, it's not. It's rather really cool! This group actually "told" me which place to choose by simply being there and my instinct convinced me that I should rely on their wisdom.

The choice was perfect. I got myself a "Döner" having a very good "price/quality" ratio... just because I was relying on my instinct.



Interestingly, in my city I do not rely on the instinct anymore. I simply know where to go. I guess I learned which bars are the best from some other groups ;-)

Tuesday, September 15, 2009

Better controlling the Cloud

This is what I found on the web. Check it out:

http://link.brightcove.com/services/player/bcpid1753162278?bctid=17374112001

Seems to be an interesting idea. Waiting for some opensource product going this way.

Monday, September 14, 2009

I hate Mondays!

Last week I've booked my hotel and tickets to Munchen. I originally planed to stay there for three days (read two nights) and then come back to Erlangen and work remotely. Everything was great until today when I realized that I've made appointment for Thursday with a guy who substitutes my boss and comes to get some feedback info about me and my work. This fu... totally sucks! Booking another hotel just for one night in Munchen (it won't be cheap), re-booking the ticket (those guys at DB really know how to piss somebody off), etc. My girlfriend will be pissed of too (I promised to give her a ride to Nuernberg to the dentist on Thursday.) Why didn't I look at the calendar last week? It was all written there!! I don't get it! Oh.. I am such a... oh... no... I just hate these fu... Mondays!!!