Friday 3 October 2014

The Basics Of Hadoop



Basically Hadoop is framework of tools. It is not a software that you will download on your computer and you will say that you have downloaded Hadoop. We use Hadoop to support running applications on big Data. And the best thing is that Hadoop is open source which is distributed under Apache Licence and you don't need to pay for it.So being open source guarantees that no particular company is controlling the direction of Hadoop and it is maintained by Apache. So we understand that Hadoop is a set of tools that supports running of Applications on Big Data. So the keyword behind Hadoop is Big Data. Big Data is creating Challenges that Hadoop is addressing. And all these challenges are created at three levels.
  1. Lot of Data is Coming at Very High Speed (Velocity)
  2. Big Volume of Data is being gathered and going on gathering (Volume)
  3. And Data is of all sorts of variety means its not an organized Data as it will contains Audios, Videos, Log Files etc. (Variety)
If we talk about Enterprise Approach of managing Big Data, An enterprise will get a very powerful Computer to Process the Big Data and this computer will do a good job but until a certain point. A point will come when this powerful computer will not be able to do the processing any more because this is not scale able and the Big Data is growing. So traditional Enterprise Approach does have its limitations when it comes to Big Data. Hadoop takes a very different approach than the enterprise approach. It breaks the data into smaller pieces and that's why its able to deal with the Big Data. Breaking the data into small pieces is a good idea but then depends on you that how you are going to perform the computation. It breaks the computation as well into smaller pieces. It sends each piece of computation to each piece of data. So the data is broken down into equal pieces. So the computations chunks can be performed in equal amounts of time and once all these computations are finished then their results are combined together and the combined result will be sent back to the application.
At a very High level Hadoop has a simple architecture. You can say Hadoop has two main components
  1. MapReduce
  2. File System (HDFS)
As we have discussed that Hadoop is a set of tools and those set of tools can be known as Projects. There are numerious projects that have been started and are managed by Apache under the umbrella of hadoop. The objective of these projects is to provide assistance in the tasks that are related to Hadoop. Beside above defined components there is also other component which is known as projects. On of the important characteristics of Hadoop is that it works on a ditributed model means we are not talking about super computer but about numerous low cost computers which are known as commodity hardware. Hadoop is a linux based set of tools so we will have linux on all Low cost numerous computers. All these computers will have two components.
  1. Task tracker (To process smaller piece of tasks)
  2. Data Node (To manage the piece of data that is given to the particular node)
There i want to list few companies which are using Hadoop so that you can get idea of what type of applications can use Hadoop. The Companies are Yahoo, Facebook, Amazon, Ebay, American Airlines, The New York Times, Federal Reserve Board, Chevron, IBM etc.

Thursday 2 October 2014

Generate Pdfs in Java using iText

Today we are going to see how we can generate PDFs using java. So lets move on with a simple PDF Generation Java Class.
Let me clarify one thing that to run this code there are few prerequisites
  1. iText (You can get it from here) else its included in the code.
  2. Java Development Kit
  3. Any Compiler (Eclipse , Netbeans etc)

package com.rc.generatepdf;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.Date;import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Chunk;
import com.itextpdf.text.Document;
import com.itextpdf.text.Element;
import com.itextpdf.text.Image;
import com.itextpdf.text.List;
import com.itextpdf.text.ListItem;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
public class GeneratePdf {public static void main(String[] args) {try {
OutputStream file = new FileOutputStream(new File("D:\\PDF_RoyalCyber.pdf"));
Document document = new Document();
PdfWriter.getInstance(document, file);
//Inserting Image in PDF
Image image = Image.getInstance ("Images/RC Logo.png");
image.scaleAbsolute(511f, 150f);//image width,height
//Inserting Table in PDF
PdfPTable table=new PdfPTable(3);
PdfPCell cell = new PdfPCell (new Paragraph ("www.royalcyber.com"));
cell.setColspan (3);
cell.setHorizontalAlignment (Element.ALIGN_CENTER);
cell.setPadding (10.0f);
cell.setBackgroundColor (new BaseColor (140, 221, 8));
table.addCell(cell);
table.addCell("Name");
table.addCell("Address");
table.addCell("Country");
table.addCell("Royal Cyber");
table.addCell("Chicago");
table.addCell("United States");
table.setSpacingBefore(30.0f); // Space Before table starts, like margin-top in CSS
table.setSpacingAfter(30.0f); // Space After table starts, like margin-Bottom in CSS
//Inserting List in PDF
List list=new List(true,30);
list.add(new ListItem("Java"));
list.add(new ListItem("Php"));
list.add(new ListItem("IBM Webspehere Commerce"));
//Now Insert Every Thing Into PDF Document
document.open();//PDF document opened........
document.add(image);
document.add(new Paragraph("Dear www.royalcyber.com"));
document.add(new Paragraph("Document Generated On - "+new Date().toString()));
document.add(table);
document.newPage(); //Opened new page
document.add(list); //In the new page we are going to add list
document.close();
file.close();
System.out.println("Pdf created successfully..");
} catch (Exception e) {
e.printStackTrace();
}
}
}
So Now its time to explain that how this code works and what will be the output we will get after running this code. The complete Code have info comments regarding each action.
At First Step we are defining a file name with complete location (Where ever you want to generate PDF file). Then getting Image from Location as image , so that we may insert it later in PDF. Creating Table and then adding cells and then populating those cells with data.
Creating List and adding List Items in List. Till now what we have done is just write these things inside code but haven't wrote them in PDF file So now lets move towards writing all previous defined data in PDF.
First of all we need to open PDF Document for writing the we have added data in this form
  1. Added image
  2. Added 2 new paragraphs
  3. Added table which consist cells with populated data.
  4. Created New page.
  5. Added List on that new page.
  6. Then closed the document
  7. Notified User in the console by printing Document has been generated.
I am also attaching the above given code as Exported project from Eclipse, Which consist all required images and Libs and i am also attaching PDF Output generated from this Code.
You can Get Code Here : GeneratePdf
You can get output File Here : PDF_RoyalCyber


Wednesday 1 October 2014

Android OS VS Firefox OS

Lets discuss something about both the operating systems and see how they are different from each other. First of all lets discuss about quality of Phones. The Firefox OS ZTE Mobile Device is itself of a low quality while any android is a bit better that Firefox ZTE Phone. We have similar type of screens in both the OS.


In the apps menu of Firefox OS there are circular icons while in android OS icons are in square form. Both OS have the drop Down Things From The Top. Both OS have the same bar with accessibility of quick icons like WLAN , GPS , Airplane Mode etc. Both OS have about to the same settings menu.
Lets Look at Firefox App Market And Android Play Store. As on Firefox App Market they don't have large market like Google Play but they have all apps like Facebook , Twitter , Sound-cloud etc. If we view same app on both the markets they have about to pretty similar format as well as UI.  Firefox OS have three buttons at the bottom (More/Multi-Task Button , Home , Back) While in ZTE Firefox OS Device they have only one button(Home) at the bottom-center like in iPhone.


Basically ZTE Firefox Device is following iPhone Approach so that they don't have many physical buttons. In ZTE Firefox Device you need SD Card other wise you will not be able to take photos , record videos ,and you can't download any apps. Even you can't open camera untill you don't have SD Card. You will not get the Memory card in the box as its in cheap price. Firefox OS do not have support for paid apps.
There are 3 current generation phones that run the Firefox mobile OS. You have the ZTE Open, LG Fireweb, and Alcatel One Touch Fire. All of these devices have 3.5 to 4.0 inch screens and 320 x 480 pixels for the resolution. Currently i will recommend that its not completely stable for use but you can buy the one for development purpose.

Pyramids Of Giza On Google Maps

Recently by today, Google pop up with a notification that you can now Explore the Pyramids Of Giza Via Google Maps. Day by day technology is moving and removing distances to observe the nature from anywhere. They have mentioned everything related to Pyramids of Giza
  1. History of Pyramids Of Giza.
  2. Location of Pyramids Of Giza.
  3. Purpose of Pyramids Of Giza.
  4. Materials of Pyramids Of Giza.
  5. Labor of Pyramids Of Giza.
You can view all these above mentioned points on this link.
 Along with this you can also explore other treks like Taj Mahal, Venice, Churchil, etc