Wednesday, October 9, 2013

All about premitive and characters...conversions...etc ************************

The Low level  discussion of primitive data types and Representations :


byte notation   bit notation                                                        combinations            range

1byte    = =      8bit    = =    pow(2,8)                                            256                -128 to +127
2byte    = =      16bit  = =    pow(2,8)*pow(2,8)                           65536          -32,768 to +32,767
4byte    = =      32bit  = =    pow(2,8)*pow(2,8)*pow(2,8)             xxxxxxx           xxxxxxxxxxxxxx
8byte    = =      64bit  = =    pow(2,8)*pow(2,8)*pow(2,8)*pow(2,8)  xxx              xxxxxxxxxxxxx


In java primitive

byte  - The byte data type is an 8-bit signed two's complement integer.
short - The short data type is a 16-bit signed two's complement integer.
int    -  The int data type is a 32-bit signed two's complement integer.
long - The long data type is a 64-bit signed two's complement integer.

float - The float data type is a single-precision 32-bit IEEE 754 floating point.
double - The double data type is a double-precision 64-bit IEEE 754 floating point.

char - The char data type is a single 16-bit Unicode character. It has a minimum value of '\u0000'  (or 0) and a maximum value of '\uffff' (or 65,535 inclusive).

here char is of 16 bit unicode so it's data representation will be in the form of hexadecimal like /uffff


here hexadecimal start with '0' and ends with 'f'

so numberin will be like below

0    - 0
1    - 1
2    - 2
3    - 3
4    - 4
5    - 5
6    - 6
7    - 7
8    - 8
9    - 9
10  -A
11  -B
12  -C
13  -D
14  -E
15  -F

TOTAL numbers from 0 to 15 are 16, means base 16.

char clarification :
    Literals of types char and String may contain any Unicode (UTF-16) characters. If your editor and file system allow it, you can use such characters directly in your code. If not, you can use a "Unicode escape" such as ' \u0061' ( Latin small letter A)

below code will give you clarity

code snippet:
char i= '\u0061';
char j= 97;
char k= 'a';

System.out.println(i);
System.out.println((int)i);
System.out.println((char)i);
System.out.println(j);
System.out.println((int)j);
System.out.println((char)j);
System.out.println(k);
System.out.println((int)k);
System.out.println((char)k);

output:
a
97
a
a
97
a
a
97
a



Value conversions: 

From the above code, let us discuss on char 'a'

\u0061  -  it is in hexa decimal notation  -- 16bit -- 2byte -- pow(2,8)*pow(2,8) -- combinations of 16 bits in binary representation.

0000000001100001   is the Binary representation of character 'a' ( total 16bits)  use this link1 or link2 to calculate the value of this binary code.

convert it into decimal like this

0*pow(16,3)+0*pow(16,2)+6*pow(16,1)+1*pow(16,0) =  0+0+6*16+1*1 = 0+0+96+1 =  97 

So, 97 is the decimal notation of character 'a'.


..
..
..
..
To be continued.......


sources:
http://www.binaryhexconverter.com/decimal-to-binary-converter
http://docs.oracle.com/javase/7/docs/api/java/io/DataInput.html
http://en.wikipedia.org/wiki/List_of_Unicode_characters
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
http://docs.oracle.com/javase/tutorial/i18n/text/string.html***


How to connect to any machine without password using SSH ? And how to configure ? 9/10

Hi All,

Here I am going to show you how to connect to any machine with the use of ssh.

Here we consider two machines  ( both are Linux here)
1) Master
2) Slave

Now the scenario is, I want to access Master machine from Slave Machine.

What to do:
Steps...

- Install openssh-server in both of these machines.
                       Use command 'sudo apt-get install openssh-server'
- ssh configuration files are created in the location ' ~/.ssh ' is a directory.
- Since Slave wants to connect to Master, Slave needs public key of Master machine in it.

Note: Think the machine name nagarjuna@nagarjuna-Aspire-4736 is a Master Machine.

pic1:


- Generate public key, using ssh-keygen command in Master machine

pic2:

- we get files like below, can see using tree command.

pic3:

- Here we need the file named ' id_rsa.pub ' to be copied to Slave machine.


Key Copying process to Slave Machine:

- Create a touch file with the name ' authorized_keys ' under the .ssh folder in the Slave machine.
- And now copy the Masters ' id_rsa.pub ' content to ' authorized_keys ' file using below command
  ' cat id_rsa.pub >>authorized_keys ' .
- Now connect to Master using the command ' ssh nagarjuna@nagarjuna-Aspire-4736 ' in the Slave Machine.


Troubleshooting :

- If you are unable to connect to master machine. Follow below steps
1) The above process will be successed only when domain is registered with an IP address.
2) Otherwise edit the public key - meaning - at the end of the public key, we will see domainname like
nagarjuna@nagarjuna-Aspire-4736.  Here you have to replace nagarjuna-Aspire-4736 with the IP address of Master machine.
3) Now try to connect.

If you want to know the IP address of Master machine, use the command ' ifconfig ' , You will IP.


If you still facing problems while connecting, then try to restart ssh server service in both Machines using
sudo /etc/init.d/ssh restart


sources:
https://help.ubuntu.com/10.04/serverguide/openssh-server.html
http://www.cyberciti.biz/faq/howto-start-stop-ssh-server/




Tuesday, October 8, 2013

Main configuration files in Hadoop pseudo distribution mode ..

Hadoop single node cluster configuration files and settings...:

In any Hadoop release like 1.0.4 or 1.2.0 or 1.2.1...etc, to configure for single node cluster, we have to configure main 4 files in hadoop.

They are

1) hadoop-env.sh
2) core-site.xml
3) hdfs-site.xml
4) mapred-site.xml

Note: Here commands or any file names in linux operating system is fully case sensitive, So be careful while typing or adding environment variables to .bashrc or .profiles

Below are the common content for the above files

For
1) uncomment  JAVA_HOME with correct javahome path

2) add property tag under configuration tag, and write name tag and then value tag..like
 
       <configuration>
                  <property>
                            <name>fs.default.name</name>
                            <value>hdfs://localhost:9000</value>
                 </property>
                 <property>
                            <name>hadoop.tmp.dir</name>
                            <value>/home/hadoop/tmp</value>
                 </property>
      </configuration>

3) same as in step 2

        <configuration>
                    <property>
                              <name>dfs.replication</name>
                              <value>1</value>
                    </property>
       </configuration>

4) lly

         <configuration>
                      <property>
                                <name>mapred.job.tracker</name>
                                <value>localhost:9001</value>
                     </property>
        </configuration>



These are the main configuration settings to run single node hadoop cluster.

1) JAVA_HOME
2) fs.default.name = hdfs://localhost:9000
    hadoop.tmp.dir = /home/hadoop/tmp    (This is custom location and must have sufficient permissions)
3) dfs.replication = 1
4) mapred.job.tracker = localhost:9001

Monday, October 7, 2013

namenode not getting started in hadoop1.2.1 ?

namenode not getting started in hadoop1.2.1 ?

Hi All,

Today I have faced one problem in configuring hadoop single node cluster using hadoop1.2.1 version.

I have just configured all xml files in conf directory and tried to run the hdfs using start-dfs.sh. But I am unable to start the namenode.

Solution:

Goto core-site.xml and change the property name "dfs.default.name" to "fs.default.name". And run the hdfs service using the same command start-dfs.sh  .

Check services using jps


http://stackoverflow.com/questions/8076439/namenode-not-getting-started/19227253#19227253