Wednesday, February 23, 2011

MapReduce

MapReduce is a programming model and an associated implementation for processing and generating large data sets. It is inspired by Map and Reduce functions which are used in functional programming.

The basic computation can be expressed a set of input key/value pairs and produces a set of output key value pairs. All this computing is done in two steps Map and Reduce. Map takes an input pair and produces a set of intermediate key/value pairs. MapReduce library groups together all intermediate values associated with the same intermediate key and passes to Reduce. Reduce takes intermediate key and a set of values for that key as input. Reduce merges these to form a possibly smaller set of values.Typically just zero or one output value is produced per Reduce invocation. Actually the MapReduce framework is a large distributed sort which comprises of Input Reader, Map Function, Partition Function, Compare Function, Reduce Function, and Output Writer. The diagram shows how the data flows between these functions.

For example consider the problem of counting the number of occurrences of each word in a large collection of documents. Map and Reduce functions would have the pseudo-code as:
map(String key, String value):
    for each word w in value:
        emitIntermidiate(w,"1");
reduce(String key, Iterator values):
    int result = 0;
    for each v in values:
        result+= ParseInt(v);

Few more examples that can be expressed as MapReduce computations. Count of URL Access Frequency for which map function will process logs of web page requests and output (URL, 1) and reduce function will add all together for same url and will result (URL, total count). In Reverse Web-link Graph problem map function will output (target, source) pairs for each link to a target url found in page named source. Reduce will then concatenate the list and will emit (target, list(source)).

MapReduce is easy to use even for programmers without experience with parallel and distributed systems, since it hides the details of parallelization, fault tolerance, locally optimization and load balancing. A large set of real world problems are easily expressible as MapReduce computations.
MapReduce has been used at Google for different purposes such as web search service, sorting, data mining, machine learning etc. Google has developed an implementation of MapReduce that scales to large clusters of machines comprising thousands of machines.


Friday, February 11, 2011

Ajax Portlet using JQuery : AjaxJQueryPortlet

Hello friends,

This is a sample Ajax Portlet using JQuery. In this we are getting name and company from a java class which is called in jsp.

Check it out on Sourceforge : AjaxJQueryPortlet
And the Liferay page: AjaxJQueryPortlet

Cheers!!!
Ravi Kumar Gupta -aka- D'Maverick

Setting up wireless in Ubuntu

Hello Frnds,

This I could not post before.. found this in drafts.. :) consider this as a post of 2 years back.. :)

so, Finally i got time.. i got time to write again... this is totally new for me.. b'coz its first time i m using a laptop so it is obvious to get problems during setup.. and this happend.. mot only me.. most of us face problems during installation of wireless network while we are working on a linux... yep, u got it.. its drivers problem... :) ok, then i m gonna help with this issue... on Ubuntu.. and i hope the same will work for any linux..

so here we go with the first post (strictly written ) for wireless laptops

drivers can be downloaded from drivers repositories..

first step :
Installing ndiswrapper -
Download these pkgs for ubuntu... and install by simple double click.

Second :
Get the vendor and suitable driver for it.
run lspci

now run the following command...
>>>>>sudo ndiswrapper -i xxxxxxx.inf
this will install the driver file form "*.inf" file..
>>>>>sudo ndiswrapper -mi && sudo ndiswrapper -ma

now just reboot the computer and ur wireless configuration is done...
enjoy..
Ravi Kumar Gupta ~aka~ "D'Maverick"

Thursday, February 10, 2011

Piwik : An Open Source Web Analytics alternative to Google Analytics

Hello Friends,

Since Google Analytics can not be used on intranet website, we needed to find something similar in open source. And we have Piwik which provides similar functionalities. Piwik is open source, under GPL license Piwik also provides development options for developers.

To know more have a look here at the http://piwik.org/

Cheers!!!
Ravi Kumar Gupta -aka- D'Maverick

Setting Up Mail Server on Linux [Postfix + Dovecot]

Hello Friends,

Here are the steps to configure a basic mail server using Postfix and Dovecot.
For the basics of Mail server you can refer Wikipedia. We need to download Postfix and dovecot. Generally with any Linux these packages are distributed by default but if not available can be downloaded and installed.

This document assumes that all commands are run using super user or root.

For Redhat/Fedora/Mandriva/Suse etc Linux flavours  
  • rpm -ivh postfix-Xx.XX.rpm
  • rpm -ivh dovecot-xx.xx.rpm

For Ubuntu/Debian
  • apt-get install postfix
  • apt-get install dovecot 

Configure your domain name.
  • If you are running on any system which is directly visible to Internet i.e. you have your domain name then use your domain.
  • My system is running on intranet/LAN so I have to configure a domain name in hosts file
    • Add this line to /etc/hosts
      • 127.0.0.1    rkg.test
    • You can choose the domain name according to you. I use .test because that is not gonna conflict with any website I open. 

Configure SMTP which runs on port 25 by default
  • Using your favorite editor edit /etc/postfix/main.cf file 
    • vi  /etc/postfix/main.cf
  • Add these lines at the end
    • myhostname = rkg.test
    • mydomain = rkg.test
    • inet_interfaces = all
    • mynetworks = 172.0.0.0/8 
  • These are the basic configurations. If you want to get into details just read main.cf file accordingly.
  • mynetworks should be configured accordingly. For basics like > My system is in intranet with private LAN with IPs starting from 172.0.0.0 so I put it like that. Choose according to your network.

Configure Dovecot for mail receiving protocols- imap imaps pop3 pop3s
  • Edit the /etc/dovecot.conf or sometimes at /etc/dovecot/dovecot.conf
    • vi /etc/dovecot.conf
  • add this line
    • protocols = imap imaps pop3 pop3s 
  • For advanced configurations modify dovecot.conf file.

Now we need to configure accounts. 

Add some system accounts like a, b, c etc.
  • useradd a
  • passwd a 
  • useradd b
  • passwd b
For these accounts emails will be a@rkg.test, b@rkg.test etc.

Now we need to start the servers -
  • service dovecot start 
  • service postfix start

To automatically start the servers at startup
  • chkconfig dovecot on
  • chkconfig postfix on
 
Now the mail server is up. You can now use it for your integration purposes. In next post we will see how Evolution can be used as mail client to verify what we just did. :)

Cheers!!!
Ravi Kumar Gupta -aka- D'Maverick

Saturday, February 5, 2011

[Ubuntu] Broadcom Wireless STA Driver Activated But Not Currently In Use

Hello Friends,

I am using Ubuntu 10.04 LTS - the Lucid Lynx. I was using Wireless daily with no problem but one week back something happened and my wireless stopped working suddenly. I figured with System > Administration > Hardware Drivers.. that my wireless driver was not in use. I thought of removing it, reinstalling and then re-activate it.. it worked.. but whenever I rebooted my system I had to do the same process everytime.. :(

Tried google and found this blog.. thanks a lot to the writer..

I will just rewrite the steps here for my reference.. :D

All this we are going to do on a terminal.. just press Alt+F2 and type gnome-terminal and press enter..

1. Optionally u can try these commands first.. just to check the connection
lspci -nn
lshw -C Network
lsusb
ifconfig
iwconfig
sudo iwlist scan

Now run the following commands..
sudo modprobe -r b43 ssb wl
sudo modprobe wl
sudo ifconfig eth1 up
sudo iwlist scan
 
2. Blacklist ssb. Run the following command 
echo blacklist ssb | sudo tee -a /etc/modprobe.d/blacklist.conf
 
3. Edit rc.local and add the following code at the end.
sudo vi /etc/rc.local
and add this just before "exit 0"
modprobe wl



Now just reboot... the problem should be gone :)

P.S. I am running ubuntu on Dell 1440.

Cheers!!!

Ravi Kumar Gupta -aka D'Maverick