Sunday, May 19, 2013

Programatically finding the Hadoop version code is using


In porting a program from Hadoop 0.2 to 1.0 I had the problem that the code might
care about the current Hadoop version and there was minimal documentation on
how this might be accomplished
 The package org.apache.hadoop has an annotation shiowing the version but I had nver worked with
package annotations before -
The following code creates an enum with Hadoop major versions and determines which one is in use

================================================================

package org.systemsbiology.hadoop;

import org.apache.hadoop.*;

/**
 * org.systemsbiology.hadoop.HadoopMajorVersion
 *   enumeration of major Hadoop versions
 * @author Steve Lewis
 * @date 19/05/13
 */
public enum HadoopMajorVersion {
    Version0("0.2"), Version1("1."), Version2("2.");

    private final String m_StartText;

    private HadoopMajorVersion(String startText) {
        m_StartText = startText;
    }

    public String getStartText() {
        return m_StartText;
    }

    /**
     * figure out the major hadoop version by looking at     HadoopVersionAnnotation in
     * package
     * @return !null majoe version
     * @throws  IllegalStateException if presented with a version it does not understand
     */
    public static HadoopMajorVersion getHadoopVersion() {
        // force the class loader to load a class in the package so we can read the package
        Class hadoopVersionAnnotation = HadoopVersionAnnotation.class; // make cure the class loader know about packages
        Package aPackage = Package.getPackage("org.apache.hadoop");
        HadoopVersionAnnotation annotation = (HadoopVersionAnnotation) aPackage.getAnnotation(HadoopVersionAnnotation.class);
        String version = annotation.version();
        HadoopMajorVersion[] versions = values();
        for (HadoopMajorVersion v : versions) {
             if(version.startsWith(v.getStartText()))
                 return v;
        }
        throw new IllegalStateException("Unknown Hadoop version " + version);
    }
}

Thursday, January 17, 2013

Window 8 Metro DOES Suck


In my last post I described how I had installed Windows 8 on several of my systems and I really like the way the desktop behaved. I had heard a lot of bad things about this operating system and I realized after playing with it that all the bad things had to do with the Metro interface. Technically, since Microsoft has decided that Metro is not the real name for this interface and has yet to supply an alternative, we should call this "the interface formerly known as Metro" but I will simply call it Metro.

Metro is version 1 from Microsoft and as all version 1 products, particularly from Microsoft it is very bad. Many of the bad behaviors have been described in great detail by others so I will not go into them. There are many little things like when you scroll the mouse you expect things to scroll vertically but in Metro they scroll horizontally. Why, who can say but presumably you are supposed to use a touch interface which most existing computers don't have. Metro has no concept of a right-click and many places where you would reasonably expect a menu to pop up for you click in fact the menu pops up somewhere else on the screen forcing you to click and then moved to deal with it. The icons on the Metro interfaces come in only two sizes: square and roughly twice the width of a square at the same height. The number of rows of icons seems to be independent of screen size. Having a fixed size is only one of many limitations for Metro apps which end up making them essentially toys on a system like my desktop.

 Metro is a response to a problem that Microsoft has. Microsoft has no presence in the huge and rapidly growing phone and tablet market. Virtually all of the phones and tablets being sold in this country either run Apple's operating system will Google's. Microsoft is coming to the party about five years too late and is desperately playing catch-up.  The only way that Microsoft can establish a credible presence in the phone and tablet market is by exploiting its virtual monopoly on the desktop in order to cause developers to write applications that will work well on phones and tablets. If developers see a huge Windows market and develop cool applications that will also run on Windows tablets and phones then Microsoft can establish itself as a major presence in this market. The conclusion is that it is a good thing for Microsoft to have your computer behaved like a tablet.

The problem is that consumers do not want their computer to behave like a tablet, they want their tablet to behave like a computer. I recently took a five-week trip to Europe in which my only computer was a very sophisticated android tablet, the Asus transformer. The transformer looks a lot like a laptop with an attached keyboard loaded with batteries. What I discovered in using this as my only system for five weeks is that a tablet in many cases thinks more like a phone than a computer. Selecting text if you were typing or simply wanting to copy a string in Polish from a webpage into a search engine is extremely difficult with touch but totally trivial with a mouse. My tablet would not let me select multiple files to include in an email message with a single multiple selection nor would it let me send an email to a group of users. There is no good reason why either of these operations is not supported except that the tablet software was originally written for a phone.

Many websites treat a tablet as if it were a phone rather than a laptop even though the space available is similar and the experience can be quite disappointing. My conclusion at the end of this was that I wanted my tablet to behave more like a computer and not the other way around. Metro's view of the world is very very different.
   Others have described metro as a train wreck.

Windows 8 Does NOT Suck


This is going to be a very short blog and I am going to continue it later on when I have more time. My project over the past week was to install and play with Windows 8. I had expected to be very disappointed because I have heard many stories about how confusing Windows 8 was and indeed had participated in some of the events which led me to have low expectations for this product.

I distrusted Windows 8 so much that I did not even attempted to install it on one of my real machines. I created a virtual machine on my laptop and installed Windows 8 there. This turned out to be a huge mistake. My laptop is old, it has only 3 GB of memory and two processors. This is enough to run Windows 8 but not enough to run Windows 7 together with a virtual machine running Windows 8. The performance was dreadful but it did give me a chance to play with the product. I learned enough during a couple of days to decide, especially since the performance was so terrible that I ought to give it a chance on my desktop machine.

Before I came to this decision I had learned enough about the product to be comfortable using it. I installed a product that I had been using in the past on Windows 7 called classic shell which restores a start menu similar to that found in XP. I have no idea why Microsoft decided to remove the start menu and have never been happy with the changes that they made since Windows 2000 so the classic start menu fit my needs perfectly. As a nice addition there is an option to cause Windows 8 to boot directly to the desktop without stopping at the Metro interface. This meant that I never had to deal with Metro and in my opinion that was a good thing since everything that people complain about with Windows 8 is really a complaint about Metro. I will say a lot more about Metro in my next blog posting but this posting is really about how Windows 8 does not suck..

I gave the system a real chance. I installed it on my desktop machine, a system that I have been using with various modifications for the past 10 years. In its latest incarnation the machine has three screens, six processors and 16 GB of memory. This is not a small system and there are literally hundreds of applications that have been installed over the years. I had no intention on reinstalling them.

I gave Windows 8 a partition on a drive different from the one that I had been using. I made a copy of my Windows 7 partition on the new drive. I then unplugged all other drives so that the Windows 8 installation would not have any opportunity to make changes on my production system. I made sure that the drive booted and ran properly and then I installed Windows 8.

I then installed classic shell and said it so that on boot you went straight to the desktop. I was very pleasantly surprised. Windows 8 recognized my three screens and use them immediately when the installation booted up. All my applications where there and my desktop look just like it did before the installation. Classic start menu was even smart enough to copy everything that I was doing in Windows 7. Every single application that I used in Windows 8 on the desktop has run properly. This includes things like Dragon NaturallySpeaking, Chaneru a video file server. VLC Player a good open source video player, of course Visual Studio and Microsoft Office, IntelliJ is a good job the development environment all work properly, the first time and right out of the box.

My original plan was to install Windows 8 and to play with it and go back to Windows 7. After playing with it for a couple of days I decided that it was worth keeping and would become my main production environment. I was surprised by this decision because I have heard a huge number of complaints about Windows 8 but my conclusion was that these were not really complaints about the operating system itself and its desktop but rather complaints about the Metro interface and a poorly conceived attempt to make your PC behave like a laptop. I will cover this more in the next posting