It6713 Grid Cloud Computing Lab
It6713 Grid Cloud Computing Lab
It6713 Grid Cloud Computing Lab
LIST OF EXPERIMENTS
Exp. Page
Date Name of The Experiments Sign.
No. No.
GRID COMPUTING LAB
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
3
Ex.No: 1.
IMPLEMENTATION OF CALCULATOR
Date:
PROCEDURE:
Step 1: Open NetBeans IDE 8.1
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
4
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
5
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
6
Step 3: Delete the index.html file in Web pages. Create the new file with .XHTML
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
7
Step 4: Delete the default content in index.xhtml of webpage and type the following code.
Index.xhtml
</center>
</form>
</h:body>
</html>
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
8
Step 5: Create a new jsp file and name it cal.jsp and type the following code in it.
cal.jsp
<html>
<head>
<title>Enter two numbers to add up</title>
</head>
<body>
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
9
Step 6: Delete the default content in web.xml of WEB-INF and type the following code.
web.xml
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
10
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
Step 7: Deploy and Run the Project by right click on the project name .
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
11
OUTPUT:
Result
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
12
Ex.No: 3.
IMPLEMENTATION OF GRID SERVICE
Date:
PROCEDURE:
Step 1: Open spring tool suite IDE from My Computer->E:/->Grid->grid computing software-
>spring tool suite release->spring source->sts -3.3.0 release->sts.exe
Step 2:Create a new Dynamic web project from File->new->Dynamic web project.
Enter the project name and change dynamic web module version to 2.5
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
13
Step 3: In the same window, click modify button in the configuration select Axis2 web service
and click on ok and then next and finally generate web xml must be checked and click finish.
Step 4:Create a system variable for apache axis by going by :right click on computer and select
properties select advanced system settings and click on environment variable and set the new
variable to the path:
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
14
Step 5.In spring suite click windows->preferences->webservices->Axis 2 preferences and check the
location of axis 2 .
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
15
Step 7: In E:/->grid->grid computing software->axis->copy the include folder and paste it in your
project under web content->WEB-INF.
Step 8:copy the jstl and xmlschema_core jar files in the same axis folder and paste it inside lib
folder.
Step 9:.Now go to conf->axis2.xml
Type the following code in the document
<transportReceiver name="http" class="org.apache.axis2.transport.http.Axis
ServletListener"/>
Save and close
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
16
Step 11:.Now create new package and give the name as “com.web.service” and click finish.
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
17
Step 12:.Now create a class under the package and type a small code and save it.
Step 13:. Type a small code by right click on AddOperationService.java and save it.
AddOperationService.java
package com.cloudnloud.service;
public class AddOpetationService {
public int sumValue(int a,int b)
{
return a+b;
}
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
18
Step 14:. Right click on your class name->webservice->create webservice->check publish web
service.
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
19
Step 15: In the same window click on webservice runtime apache:apache axis 2 and check apache
axis 2 and click finish.
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
20
Output:
Result:
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
21
Ex.No: 4.
IMPLEMENTATION OF GRID API
Date:
PROCEDURE:
Step 1: Create a new java application
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
22
import java.util.Scanner;
public class TempConverter{
public static void main(String [] args)
{
float f, c;
f = c = 0;
int a;
Scanner scan = new Scanner (System.in);
System.out.println("Press 1 for C->F or 2 for F->C");
a = scan.nextInt();
if (a == 1)
convertCtoFAndPrint();
else
convertFtoCAndPrint();
}
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
23
f = (int) scan.nextFloat();
System.out.println("enter degrees F"+f);
c = (f-32) * 5/9;
System.out.println(f + " degrees F is " + c + " degrees C.");
}
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
24
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
25
Output
Result:
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
26
Ex.No: 5.
IMPLEMENTATION OF SECURITY MECHANISM
Date:
PROCEDURE:
Step1 : Open spring tool suite and create a Dynamic web project
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
27
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
28
Step 4 : Type the corresponding code for all the classes. And add the required jar files in the web
content->web-inf->lib folder.
Step 5 : similarly create the following packages and class files as in the given order below
1.com.security.servlet
-LoginServlet.java
-LogoutServlet.java
-RegisterServlet.java
1.a.com.security.servlet.errohandlers
-AppErrorHandler.java
1.b.com.security.servlet.filters
-AuthenticationFilter.java
1.c.AppContextListener.java
-AppContextListener.java
2.com.security.util
-DBConnectionManager.java
-User.java
LoginServlet.java
package com.journaldev.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
29
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
import com.journaldev.util.User;
if(errorMsg != null){
RequestDispatcher rd =
getServletContext().getRequestDispatcher("/login.html");
PrintWriter out= response.getWriter();
out.println("<font color=red>"+errorMsg+"</font>");
rd.include(request, response);
}else{
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
30
if(rs != null){
rs.next();
User user = new User(rs.getString("name"), rs.getString("email"),
rs.getString("country"), rs.getInt("id"));
logger.info("User found with details="+user);
HttpSession session = request.getSession();
session.setAttribute("User", user);
response.sendRedirect("home.jsp");;
}else{
RequestDispatcher rd =
getServletContext().getRequestDispatcher("/login.html");
PrintWriter out= response.getWriter();
logger.error("User not found with email="+email);
out.println("<font color=red>No user found with given email id, please
register first.</font>");
rd.include(request, response);
}
} catch (SQLException e) {
e.printStackTrace();
logger.error("Database connection problem");
throw new ServletException("DB Connection problem.");
}finally{
try {
if(rs!=null)rs.close();
if(ps!=null)ps.close();
} catch (SQLException e) {
logger.error("SQLException in closing PreparedStatement or
ResultSet");;
}
}
}
}
}
LogoutServlet.java
package com.journaldev.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
31
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
}
RegisterServlet.java
package com.journaldev.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
32
import org.apache.log4j.Logger;
if(errorMsg != null){
RequestDispatcher rd =
getServletContext().getRequestDispatcher("/register.html");
PrintWriter out= response.getWriter();
out.println("<font color=red>"+errorMsg+"</font>");
rd.include(request, response);
}else{
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
33
ps.execute();
}
-AppErrorHandler.java
package com.journaldev.servlet.errorhandler;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/AppErrorHandler")
public class AppErrorHandler extends HttpServlet {
private static final long serialVersionUID = 1L;
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
34
processError(request, response);
}
out.write("<br><br>");
out.write("<a href=\"login.html\">Login Page</a>");
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
35
out.write("</body></html>");
}
}
-AuthenticationFilter.java
package com.journaldev.servlet.filters;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
@WebFilter("/AuthenticationFilter")
public class AuthenticationFilter implements Filter {
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
36
}
-AppContextListener.java
package com.journaldev.servlet.listeners;
import java.io.File;
import java.sql.Connection;
import java.sql.SQLException;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.xml.DOMConfigurator;
import com.journaldev.util.DBConnectionManager;
@WebListener
public class AppContextListener implements ServletContextListener {
//initialize DB Connection
String dbURL = ctx.getInitParameter("dbURL");
String user = ctx.getInitParameter("dbUser");
String pwd = ctx.getInitParameter("dbPassword");
try {
DBConnectionManager connectionManager = new
DBConnectionManager(dbURL, user, pwd);
ctx.setAttribute("DBConnection", connectionManager.getConnection());
System.out.println("DB Connection initialized successfully.");
} catch (ClassNotFoundException e) {
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
37
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
//initialize log4j
String log4jConfig = ctx.getInitParameter("log4j-config");
if(log4jConfig == null){
System.err.println("No log4j-config init param, initializing log4j with
BasicConfigurator");
BasicConfigurator.configure();
}else {
String webAppPath = ctx.getRealPath("/");
String log4jProp = webAppPath + log4jConfig;
File log4jConfigFile = new File(log4jProp);
if (log4jConfigFile.exists()) {
System.out.println("Initializing log4j with: " + log4jProp);
DOMConfigurator.configure(log4jProp);
} else {
System.err.println(log4jProp + " file not found, initializing log4j with
BasicConfigurator");
BasicConfigurator.configure();
}
}
System.out.println("log4j configured properly");
}
}
-DBConnectionManager.java
package com.journaldev.util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
38
import java.io.Serializable;
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
39
@Override
public String toString(){
return "Name="+this.name+", Email="+this.email+", Country="+this.country;
}
}
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
40
Step 6: Type the code for home.jsp, login.html and register.html in WEB-CONTENT.
home.jsp
<%@page import="com.journaldev.util.User"%>
<%@ page language="java" contentType="text/html; charset=US-ASCII"
pageEncoding="US-ASCII"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Home Page</title>
</head>
<body>
<%User user = (User) session.getAttribute("User"); %>
<h3>Hi <%=user.getName() %></h3>
<strong>Your Email</strong>: <%=user.getEmail() %><br>
<strong>Your Country</strong>: <%=user.getCountry() %><br>
<br>
<form action="Logout" method="post">
<input type="submit" value="Logout" >
</form>
</body>
</html>
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
41
login.html
<!DOCTYPE html>
<html>
<head>
<meta charset="US-ASCII">
<title>Login Page</title>
</head>
<body>
<h3>Login with email and password</h3>
<form action="Login" method="post">
<strong>User Email</strong>:<input type="text" name="email"><br>
<strong>Password</strong>:<input type="password" name="password"><br>
<input type="submit" value="Login">
</form>
<br>
If you are new user, please <a href="register.html">register</a>.
</body>
</html>
register.html
<!DOCTYPE html>
<html>
<head>
<meta charset="US-ASCII">
<title>Register Page</title>
</head>
<body>
<h3>Provide all the fields for registration.</h3>
<form action="Register" method="post">
<strong>Email ID</strong>:<input type="text" name="email"><br>
<strong>Password</strong>:<input type="password" name="password"><br>
<strong>Name</strong>:<input type="text" name="name"><br>
<strong>Country</strong>:<input type="text" name="country"><br>
<input type="submit" value="Register">
</form>
<br>
If you are registered user, please <a href="login.html">login</a>.
</body>
</html>
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
42
<welcome-file-list>
<welcome-file>login.html</welcome-file>
</welcome-file-list>
<context-param>
<param-name>dbUser</param-name>
<param-value>root</param-value>
</context-param>
<context-param>
<param-name>dbPassword</param-name>
<param-value>redhat</param-value>
</context-param>
<context-param>
<param-name>dbURL</param-name>
<param-value>jdbc:mysql://localhost:3306/UserDB</param-value>
</context-param>
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
43
<context-param>
<param-name>log4j-config</param-name>
<param-value>WEB-INF/log4j.xml</param-value>
</context-param>
<error-page>
<error-code>404</error-code>
<location>/AppErrorHandler</location>
</error-page>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/AppErrorHandler</location>
</error-page>
<filter>
<filter-name>AuthenticationFilter</filter-name>
<filter-class>com.journaldev.servlet.filters.AuthenticationFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>AuthenticationFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--
<servlet>
<servlet-name>Register</servlet-name>
<servlet-class>Register</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Register</servlet-name>
<url-pattern>/Register</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Logout</servlet-name>
<servlet-class>Logout</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Logout</servlet-name>
<url-pattern>/Logout</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Login</servlet-name>
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
44
<servlet-class>Login</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Login</servlet-name>
<url-pattern>/Login</url-pattern>
</servlet-mapping> -->
</web-app>
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
45
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
46
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
47
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
48
Step 11: Create a new table named users having the fields : id, name,email,country,password.
Query :
CREATE TABLE `Users` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL DEFAULT '',
`email` varchar(20) NOT NULL DEFAULT '',
`country` varchar(20) DEFAULT 'USA',
`password` varchar(20) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
49
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
50
Step12: Now ,Go to sts and run the project as Run on server
OUTPUT:
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
51
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
52
Result
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
53
Ex.No: 6.
IMPLEMENTATION OF GRID PORTAL
Date:
AIM: Develop a Grid portal, where user can submit a job and get the result
PROCEDRE:
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
54
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
55
Step 3: Create a new class within the newly created package named PieChartServlet and type its
corresponding code.
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
56
Step 4: In Web content Create a new HTML file and name it chart.html and write its corresponding
code
PieChartServlet.java
package com.cloudnloud.servlet;
import java.awt.Color;
import java.io.IOException;
import java.io.OutputStream;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
import org.jfree.chart.plot.PiePlot;
import org.jfree.data.general.DefaultPieDataset;
/* Code for the HTTP Servlet that will return the Pie Chart as a PNG image
back to the browser after generating it using JFreeChart API */
@WebServlet(name = "PieChartServlet", urlPatterns = { "/PieChartServlet" })
public class PieChartServlet extends HttpServlet {
public PieChartServlet() {
/* No code in the constructor for this demonstration */
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
OutputStream out = response.getOutputStream(); /* Get the output stream from the
response object */
try {
DefaultPieDataset myServletPieChart = new DefaultPieDataset();
/* We will now get the values posted to us from the HTML form, to generate a
dynamic pie chart */
/* to get the form values we use request.getParameter method. We have to convert
this to Double format to
pass this as an input to our pie chart*/
/* The NAME used in HTML form will serve as input to getParameter */
myServletPieChart.setValue("Servers",Double.parseDouble(request.getParameter("Servers")));
myServletPieChart.setValue("Monitor",
Double.parseDouble(request.getParameter("Monitor")));
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
57
myServletPieChart.setValue("CPU",
Double.parseDouble(request.getParameter("CPU")));
myServletPieChart.setValue("Keyboards",
Double.parseDouble(request.getParameter("Keyboards")));
myServletPieChart.setValue("Processor",Double.parseDouble(request.getParameter("Processor")));
JFreeChart mychart = ChartFactory.createPieChart("Dynamic Pie Chart
Example",myServletPieChart,true,true,false);
/* We use the configurator to define labels for the chart, which can be shown on
image also */
PiePlot ColorConfigurator = (PiePlot) mychart.getPlot();
ColorConfigurator.setLabelGenerator(new
StandardPieSectionLabelGenerator("{0}:{1}"));
ColorConfigurator.setLabelBackgroundPaint(new Color(220, 220, 220));
response.setContentType("image/png"); /* Set the HTTP Response Type */
/* Send a big chart back to the browser */
ChartUtilities.writeChartAsPNG(out, mychart, 640, 480);/* Write the data to the
output stream */
}
catch (Exception e) {
e.printStackTrace();
System.err.println(e.toString()); /* Throw exceptions to log files */
}
finally {
out.close();/* Close the output stream */
}
}
/* We write a doPost method which will be invoked when you post data to the servlet */
/* Inside doPost we invoke doGet to return a chart back to us depending on the input
parameters*/
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
58
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
59
chart.html .
<html>
<head>
<Title>Generate Dynamic Pie Chart </Title>
</head>
<body BGCOLOR="white">
<H2>Enter your no. to get a Pie Chart </H2>
<!-- We create a simple form to accept user inputs -->
<!-- The action for this form points to the servlet URL created in earlier posts -->
<FORM ACTION="PieChartServlet" METHOD="POST">
Servers:<INPUT TYPE="TEXT" NAME="Servers"><BR>
Monitor:<INPUT TYPE="TEXT" NAME="Monitor"><BR>
CPU:<INPUT TYPE="TEXT" NAME="CPU"><BR>
Keyboards:<INPUT TYPE="TEXT" NAME="Keyboards"><BR>
Processor:<INPUT TYPE="TEXT" NAME="Processor"><BR>
<INPUT TYPE="SUBMIT" VALUE="Submit">
</FORM>
</body>
</html>
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
60
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
61
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
62
Output:
Result:
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
63
AIM: Find procedure to run the virtual machine of different configuration. Check how many
virtual machines can be utilized at particular time.
Throughout the installation there are two separate roles: Frontend and Nodes.
The Frontend Server will execute the OpenNebula services, and the Nodes(KVM1)will be used to
execute virtual machines.
PROCEDURE:
Step 2: Power on Front end ,open the terminal type ip a and obtain the IPAdress: For
eg:192.168.159.131.Paste the IP Address in Putty Configuration and load frontend.
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
64
Step3:Login as root, type password as redhat, start the services of frontend as mentioned below
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
65
Step 4::Power on Kvm1 ,open the terminal type ip a and obtain the IP A dress: For
eg:192.168.159.132.Paste the IP Address in Putty Configuration and load kvm1.
Step5:Login as root, type password as redhat, start the services of Kvm1 as mentioned below
Start the required services:
Step6:On front end copy the key into the browser password field
The default password for the oneadmin user can be found in ~/.one/one_auth which is randomly
generated on every installation.
To interact with OpenNebula, you have to do it from the oneadmin account in the frontend. We will
assume all the following commands are performed from that account. To login
as oneadmin execute su - oneadmin.
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
66
$cat ~/.one/one_auth
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
67
Step 8: GotoOneadminDashboard
check for the status onwait for few minutes , if status err problem is due to services are not started
properly.
Step11:In Dash board select Image, + symbol will appear on Image dash board which indicates add
click on it.
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
68
* Now new Create Image will pop out to enter the details for Image, fill the details for
nameTTYLinux.-> Choose image location: Upload ->Choose file:browse for the ttylinux.img
which is stored in particular driver.
*Once image is uploaded click on create
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
69
Instantiate the template , Click Virtual Machine in Virtual Resources Menu and do the
following steps
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
70
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
71
OUTPUT:
Check the Status for Virtual Machine RUNNING
Result:
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
72
AIM: Find procedure to attach virtual block to the virtual machine and check whether it holds
the data even after the release of the virtual machine
PROCEDURE:
Step9:Go to Virtual Resource select Virtual Machine ->Select the VM which is Running
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
73
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
74
Step12:Select on option Volatile Disk->Size 10 MB(Do not Select GB)->Type Default FS-
>Format-SD, click on Attach
Note: When you click refresh the newly attach hdc disappears. Hence we reboot and restart the
services.
Step14:Restart the services of Frontend and KVM1and go to Virtual Machine Select the Storage
click on Attach Disk and follow the Step11.
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
75
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
76
OUTPUT:
Result:
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
77
Ex.No: 3.
PROCEDURE TO INSTALL C COMPLIER
Date:
AIM: Install a C compiler in the virtual machine and execute a sample Program.
PROCEDURE:
Step1:Log on Putty for KVM1.Once KVM1 on
[root@kvm1 ~]# 2 4
OUTPUT:
Result:
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
78
Ex.No: 4.
PROCEDURE TO MIGRATION VIRTUAL MACHINE
Date:
AIM: Show the virtual machine migration based on the certain condition from one node to the other
PROCEDURE:
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
79
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
80
OUTPUT:
Check the Virtual Machine which had Migrate(KVM1) Status is now in RUNNING(KVM2) status
Result:
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
81
Ex.No: 5.
PROCEDURE TO INSTALL CONTROLLER
Date:
PROCEDURE:
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
82
OUTPUT:
Result:
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
83
Ex.No: 6.
PROCEDURE TO SET UP ONE NODE HADOOP CLUSTER
Date:
Procedure:
Step 1: System Set up and Java Installation
Login in PUTTY
login as: root
[email protected]'s password:redhat
[root@localhost ~]# hostnamehadp
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
84
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
85
|. X |
| ..+= |
|..++ |
| ..oo |
+-----------------+
[hadoop@hadp ~]$ ssh-copy-idroot@hadp
The authenticity of host 'hadp (192.168.52.128)' can't be established.
ECDSA key fingerprint is 14:22:1a:ff:0d:dd:ec:48:fe:6d:f7:7b:bf:c8:09:df.
Are you sure you want to continue connecting (yes/no)? yes
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already
installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the
new keys
root@hadp'spassword:redhat
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
86
export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:9000</value>
</property>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.name.dir</name>
<value>file:///home/hadoop/hadoopdata/hdfs/namenode</value>
</property>
<property>
<name>dfs.data.dir</name>
<value>file:///home/hadoop/hadoopdata/hdfs/datanode</value>
</property>
[hadoop@hadphadoop]$ nanomapred-site.xml.template
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
87
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
4.3 Format Namenode
[hadoop@hadphadoop]$ hdfsnamenode -format
16/07/11 23:13:07 INFO namenode.NameNode: STARTUP_MSG:
/************************************************************
STARTUP_MSG: Starting NameNode
STARTUP_MSG: host = hadp.cnl.com/192.168.52.128
STARTUP_MSG: args = [-format]
STARTUP_MSG: version = 2.6.0
STARTUP_MSG: classpath =
.
.
.
16/07/11 23:13:09 INFO common.Storage: Storage directory
/home/hadoop/hadoopdata/hdfs/namenodehas been successfully formatted.
16/07/11 23:13:09 INFO namenode.NNStorageRetentionManager: Going to retain 1 images with
txid>= 0
16/07/11 23:13:09 INFO util.ExitUtil: Exiting with status 0
16/07/11 23:13:09 INFO namenode.NameNode: SHUTDOWN_MSG:
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at hadp.cnl.com/192.168.52.128
************************************************************/
Step 5:Start Hadoop Cluster
[hadoop@hadphadoop]$ cd $HADOOP_HOME/sbin/
[hadoop@hadpsbin]$ start-dfs.sh
Are you sure you want to continue connecting (yes/no)? yes
localhost: Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
hadoop@localhost'spassword:redhat
[hadoop@hadpsbin]$ start-yarn.sh
Access Hadoop Services on port 50070 with the IP_Address on web browser.
http://IP_Address:50070
Output:
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
88
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
89
Aim:
To mount one node Hadoop cluster using FUSE.
Procedure:
Step 2: Copy the input file in the input directory using the following command
[hadoop@hadp hadoop]$bin/hdfs dfs –put /home/hadoop/hadoop/file1.txt /user001/hadoop
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
90
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
91
Aim: To write a program to use the API’s of Hadoop to interact with it.
Program:
URLExpSimple.java:
importjava.io.InputStreamReader;
import java.net.URL;
importjava.net.URLConnection;
importjava.util.Scanner;
public class URLExpSimple {
public static void main(String[] args) {
try {
URL mySite = new URL("http://192.168.35.150:50070");
URLConnectionyc = mySite.openConnection();
Scanner in = new Scanner(new InputStreamReader(yc.getInputStream()));
int count = 0;
while (in.hasNext()) {
System.out.println(in.next());
count++;
}
System.out.println("Number of tokens: " + count);
in.close();
} catch (Exception e) {
e.printStackTrace();
}}}
Now compile and run the program
$javac URLExpSimple.java:
$java URLExpSimple
Output:
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
92
Result:
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
93
Procedure:
Step 2: Copy the input file in the input directory using the following command
[hadoop@hadp hadoop]$bin/hdfs dfs –put /home/hadoop/hadoop/file1.txt /user001/hadoop
Step 3: Run the application by taking the input files from the input directory using the following
command.
[hadoop@hadphadoop]$bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-
2.7.0.jar grep /user001/hadoop/file1.txt /output001 ‘(IT)’
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
94
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
95
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering
96
Result
Department of IT IT6713 – Grid & Cloud Computing Lab Jerusalem College of Engineering