Entity Framework – CodeFirst Approach

Assalamualaykum Wr Br..:)
Today we are going to discuss Entity Framework Code First approach with a simple console application demonstrating  School activities with two classes named as Student & Standard.
As we know student have attributes like StudentId, Name, Standard, Age & Date Of Birth hence we are going to create properties with same name in class Student.
student
Similarly, Standard class do have properties like StandardId, StandardName but this class can have multiple students hence we are using ICollections of type Student as shown below:
standard
Now I would create a new class with SchoolDBContext name where DBContext is mandatory for flexible default operations with built in libraries of Entity Framework. This DBContext have dataset hence its return type would be Dbset and its properties are classes with s appended atlast with name as shown below:
schoolcontext
Finally it is required to call the DBContext class in main method as shown below:
program
With this Execution of program, Entity Framework creates the New database with tables as designed with classes as shown below:
dbcontext

With this it is observed that based on the code design DB is being generated hence it is regarded as Code First Approach.

Thats it for today..:Jazakallah khair

 

Installing Hadoop Accumulo

Assalamualaykum..:)
Today we discuss about installing Apache Accumulo on Ubuntu machine.

Download the package from the following link:
$ wget http://www-eu.apache.org/dist/accumulo/1.8.0/accumulo-1.8.0-bin.tar.gz

Extract the package and add the home of $ACCUMULO_HOME in bashrc file as shown:
$ tar zxf accumulo-1.8.0-bin$ gedit ~/.bashrc

Add following lines in bashrc file:
#$ACCUMULO_HOME
export $ACCUMULO_HOME=<Installation location>
export PATH=$PATH:ACCUMULO_HOME/bin
#ACCUMULO_HOME_END

Verify the bashrc file from source ~/.bashrc

Thats it for today..:)

Jazakallah khair

Installing Hadoop HCatalog

Assalamualaykum..:)
Today we discuss about installation of HCatalog on Ubuntu.

Download the software package from the following link and using the command:
$ wget http://www-eu.apache.org/dist/hive/hive-1.2.1/apache-hive-1.2.1-bin.tar.gz

Extract the package using command
$ tar zxf apache-hive-1.2.1-bin.tar.gz

Add the HCAT_HOME parameters in bashrc file( copy and paste the following lines in bashrc file) as shown below:
$ gedit ~/.bashrc
#HCAT_HOME
export HCAT_HOME=/home/aejaaz/apache-hive-1.2.1-bin
export PATH=$PATH:HCAT_HOME/bin
#HCAT_HOME_END

Verify the added lines of code in bashrc file are valid using source as shown:
$ source ~/.bashrc

Thats it for today..:)

Jazakallah khair

 

Installing Hadoop HBase On Ubuntu

Assalamualaykum Wr Br..:)

Today we discuss about the installation steps of Hbase on Ubuntu OS.

Download the hbase software from the following link and using the command:
$ wget http://www-eu.apache.org/dist/hbase/0.98.23/hbase-0.98.23-hadoop1-bin.tar.gz

Extract the Package using the command:
$ tar xvf hbase-0.98.23.tar.gz

Edit the bashrc file by adding the HBASE_HOME parameters in it as shown below:
$ gedit ~/.bashrc#HBASE_HOME
export HBASE_HOME=<LOCATION OF INSTALLTION>
export PATH=$PATH:$HBASE_HOME/bin
#HBASE_HOME_END

verify the bashrc file using command
$ source ~/.bashrc

Thats it for today..:)

Happy Learning..Jazakallah khair

Installing Hadoop ZooKeeper

Assalamualaykum Wr Br..:)

Today we discuss about the required steps to install Zookeeper on Ubuntu.

  1. Open the terminal using Ctrl + Shift + T
  2. Download the Zoo Keeper package using wget command from the link:                             $ wget http://www-eu.apache.org/dist/zookeeper/zookeeper-3.4.8/   
  3. Unzip the downloaded package using command: $ tar -xvf zookeeper-3.4.8.tar.gz
  4. Open the bashrc file and update the file with zookeeper home location using the command $ gedit ~/.bashrc   add the following lines
  5. #zookeeper_home
    export ZOOKEEPER_HOME = /home/<system_name>/zookeeper-3.4.8

    export PATH=$PATH:$ZOOKEEPER_HOME/bin
    #zookeeper_home end
  6. To verify correctness of bashrc file, run the bashrc file using command
    $ source ~/.bashrc
  7. Finally close the terminal to refresh all the updates to affect then open new terminal and execute the following command:
    $  zkServer.sh start
    which displays the information as follows:
    Zookeeper JMX enabled by default..
    ……
    Starting Zookeeper….STARTED

Thats it..Thank for the day..:) enjoy Technology.

Jazakallah Khair.

Asp.Net Areas

Assalamualaykum Wr Br..:)

Today we explore the Asp.Net Area Concept with a small project. Lets look few theory points:

Areas provide a way to separate a large MVC Web application into smaller functional groupings. An area is effectively an MVC structure inside an application. An application could contain several MVC structures (areas).

To accommodate large projects, ASP.NET MVC lets you partition Web applications into smaller units that are referred to as areas.

For example, a single large e-commerce application might be divided into areas that represent the storefront, product reviews, user account administration, and the purchasing system. Each area represents a separate function of the overall application.

This walkthrough demonstrates how to implement areas in an ASP.NET MVC application. The walkthrough creates the functional framework for a blog site that has the following areas:

  • Main. This is entry point to the Web application. This area includes the landing page and a log-in feature.
  • Blog. This area is used to display blog posts and to search the archive.
  • Dashboard. This area is used to create and edit blog posts.

To keep this tutorial simple, the areas do not contain logic to perform the actual tasks for the blog.

Creating the Application Structure

To begin, you will create an ASP.NET MVC project and add the folder structure for two child areas (Blog and Dashboard).

To create the application structure

  1. In Visual Studio, in the File menu, and click New Project.
  2. In the Project types window, expand the Visual Basic node or the Visual C# node, and then select the Web node.
  3. In the Templates window, select ASP.NET MVC 2 Web Application.
  4. Name the project MvcAreasApplication, set the project location, and then select the Create directory for solution check box.
  5. Click OK.
  6. In Solution Explorer, right-click the project name, click Add, and then click Area.
  7. In Area Name, type Blog and then click Add.

    An Areas folder is added to the project. The Areas folder contains a folder structure that allows each child area to have its own models, views, and controllers.

  8. In Solution Explorer, right-click the project name, click Add, and then click Area.
  9. In Area Name, enter Dashboard and then click Add.

    When you are done, the Areas folder contains two child areas, Blog and Dashboard.

    Adding Area-Specific Controllers

     You will now add area-enabled controllers and action methods for each area.

    To add area controllers

    1. In Solution Explorer, right-click the Controllers subfolder for the Blog area, click Add, and then click Controller.
    2. Name the controller BlogController and then click Add.
    3. Add the following code to the BlogController class.

Installing Hadoop on Ubuntu

Assalamualaykum Wr Br..:)

Today we discuss about Installation of Hadoop on Ubuntu 14.4. The very first requirement of Hadoop Installation is availability of Java and SSH in your OS.

1.  To do Quick installation of java just type the below command.

$ sudo apt-get update

$ sudo apt-get install default-jdk

To Check successful install of java on machine, just type the command.

$ java -version

The above command gives you the version of java installed on system.

2. Create and Setup SSH Certificates

Hadoop uses SSH (to access its nodes) which would normally require the user to enter a password. However, this requirement can be eliminated by creating and setting up SSH certificates using the following commands:

ssh-keygen -t rsa -P ''
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

After executing the first of these two commands, you might be asked for a filename. Just leave it blank and press the enter key to continue. The second command adds the newly created key to the list of authorized keys so that Hadoop can use SSH without prompting for a password.

2

3. Fetch and Install Hadoop

First let’s fetch Hadoop from one of the mirrors using the following command:

wget http://www.motorlogy.com/apache/hadoop/common/current/hadoop-2.3.0.tar.gz

After downloading the Hadoop package, execute the following command to extract it:

tar xfz hadoop-2.3.0.tar.gz

This command will extract all the files in this package in a directory named hadoop-2.3.0.

4. Edit and Setup Configuration Files

To complete the setup of Hadoop, the following files will have to be modified:

  • ~/.bashrc
  • /usr/local/hadoop/etc/hadoop/hadoop-env.sh
  • /usr/local/hadoop/etc/hadoop/core-site.xml
  • /usr/local/hadoop/etc/hadoop/yarn-site.xml
  • /usr/local/hadoop/etc/hadoop/mapred-site.xml.template
  • /usr/local/hadoop/etc/hadoop/hdfs-site.xml

i. Editing ~/.bashrc

Before editing the .bashrc file in your home directory, we need to find the path where Java has been installed to set the JAVA_HOME environment variable. Let’s use the following command to do that:

update-alternatives --config java

This will display something like the following:

3

The value for JAVA_HOME is everything before /jre/bin/java in the above path – in this case, /usr/lib/jvm/java-7-openjdk-amd64. Make a note of this as we’ll be using this value in this step and in one other step.

Now use nano (or your favored editor) to edit ~/.bashrc using the following command:

nano ~/.bashrc

This will open the .bashrc file in a text editor. Go to the end of the file and paste/type the following content in it:

#HADOOP VARIABLES START
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export HADOOP_INSTALL=/usr/local/hadoop
export PATH=$PATH:$HADOOP_INSTALL/bin
export PATH=$PATH:$HADOOP_INSTALL/sbin
export HADOOP_MAPRED_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_HOME=$HADOOP_INSTALL
export HADOOP_HDFS_HOME=$HADOOP_INSTALL
export YARN_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_INSTALL/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_INSTALL/lib"
#HADOOP VARIABLES END

Note 1: If the value of JAVA_HOME is different on your VPS, make sure to alter the first export statement in the above content accordingly.

Note 2: Files opened and edited using nano can be saved using Ctrl + X. Upon the prompt to save changes, type Y. If you are asked for a filename, just press the enter key.

The end of the .bashrc file should look something like this:

.bashrc contents

After saving and closing the .bashrc file, execute the following command so that your system recognizes the newly created environment variables:

source ~/.bashrc

Putting the above content in the .bashrc file ensures that these variables are always available when your VPS starts up.

ii. Editing /usr/local/hadoop/etc/hadoop/hadoop-env.sh

Open the /usr/local/hadoop/etc/hadoop/hadoop-env.sh file with nano using the following command:

nano /usr/local/hadoop/etc/hadoop/hadoop-env.sh

In this file, locate the line that exports the JAVA_HOME variable. Change this line to the following:

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64

Note: If the value of JAVA_HOME is different on your VPS, make sure to alter this line accordingly.

The hadoop-env.sh file should look something like this:

hadoop-env.sh contents

Save and close this file. Adding the above statement in the hadoop-env.sh file ensures that the value of JAVA_HOME variable will be available to Hadoop whenever it is started up.

iii. Editing /usr/local/hadoop/etc/hadoop/core-site.xml

The /usr/local/hadoop/etc/hadoop/core-site.xml file contains configuration properties that Hadoop uses when starting up. This file can be used to override the default settings that Hadoop starts with.

Open this file with nano using the following command:

nano /usr/local/hadoop/etc/hadoop/core-site.xml

In this file, enter the following content in between the <configuration></configuration> tag:

<property>
   <name>fs.default.name</name>
   <value>hdfs://localhost:9000</value>
</property>

The core-site.xml file should look something like this:

core-site.xml contents

Save and close this file.

iv. Editing /usr/local/hadoop/etc/hadoop/yarn-site.xml

The /usr/local/hadoop/etc/hadoop/yarn-site.xml file contains configuration properties that MapReduce uses when starting up. This file can be used to override the default settings that MapReduce starts with.

Open this file with nano using the following command:

nano /usr/local/hadoop/etc/hadoop/yarn-site.xml

In this file, enter the following content in between the <configuration></configuration> tag:

<property>
   <name>yarn.nodemanager.aux-services</name>
   <value>mapreduce_shuffle</value>
</property>
<property>
   <name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name>
   <value>org.apache.hadoop.mapred.ShuffleHandler</value>
</property>

The yarn-site.xml file should look something like this:

yarn-site.xml contents

Save and close this file.

v. Creating and Editing /usr/local/hadoop/etc/hadoop/mapred-site.xml

By default, the /usr/local/hadoop/etc/hadoop/ folder contains the /usr/local/hadoop/etc/hadoop/mapred-site.xml.template file which has to be renamed/copied with the name mapred-site.xml. This file is used to specify which framework is being used for MapReduce.

This can be done using the following command:

cp /usr/local/hadoop/etc/hadoop/mapred-site.xml.template /usr/local/hadoop/etc/hadoop/mapred-site.xml

Once this is done, open the newly created file with nano using the following command:

nano /usr/local/hadoop/etc/hadoop/mapred-site.xml

In this file, enter the following content in between the <configuration></configuration> tag:

<property>
   <name>mapreduce.framework.name</name>
   <value>yarn</value>
</property>

The mapred-site.xml file should look something like this:

mapred-site.xml contents

Save and close this file.

vi. Editing /usr/local/hadoop/etc/hadoop/hdfs-site.xml

The /usr/local/hadoop/etc/hadoop/hdfs-site.xml has to be configured for each host in the cluster that is being used. It is used to specify the directories which will be used as the namenode and the datanode on that host.

Before editing this file, we need to create two directories which will contain the namenode and the datanode for this Hadoop installation. This can be done using the following commands:

mkdir -p /usr/local/hadoop_store/hdfs/namenode
mkdir -p /usr/local/hadoop_store/hdfs/datanode

Note: You can create these directories in different locations, but make sure to modify the contents of hdfs-site.xml accordingly.

Once this is done, open the /usr/local/hadoop/etc/hadoop/hdfs-site.xml file with nano using the following command:

nano /usr/local/hadoop/etc/hadoop/hdfs-site.xml

In this file, enter the following content in between the <configuration></configuration> tag:

<property>
   <name>dfs.replication</name>
   <value>1</value>
 </property>
 <property>
   <name>dfs.namenode.name.dir</name>
   <value>file:/usr/local/hadoop_store/hdfs/namenode</value>
 </property>
 <property>
   <name>dfs.datanode.data.dir</name>
   <value>file:/usr/local/hadoop_store/hdfs/datanode</value>
 </property>

The hdfs-site.xml file should look something like this:

hdfs-site.xml contents

Save and close this file.

Format the New Hadoop Filesystem

After completing all the configuration outlined in the above steps, the Hadoop filesystem needs to be formatted so that it can start being used. This is done by executing the following command:

$ hadoop namenode -format

Note: This only needs to be done once before you start using Hadoop. If this command is executed again after Hadoop has been used, it’ll destroy all the data on the Hadoop file system.

 Start Hadoop

All that remains to be done is starting the newly installed single node cluster:

start-dfs.sh

While executing this command, you’ll be prompted twice with a message similar to the following:

Are you sure you want to continue connecting (yes/no)?

Type in yes for both these prompts and press the enter key. Once this is done, execute the following command:

start-yarn.sh

Executing

the above two commands will get Hadoop up and running. You can verify this by typing in the following command:

jps

Executing this command should show you something similar to the following:

jps command

If you can see a result similar to the depicted in the screenshot above, it means that you now have a functional instance of Hadoop running on your VPS.

 

Alhamdulliah…Thats it..Enjoy Hadoop…:)