Cloud Computing
Cloud Computing
T.Y.B.Sc (IT)
Cloud Computing Lab Manual
A.Y. 2023-24
(SEMESTER VI)
Name : Simran Sabat Roll no:FIT2146
CERTIFICATE
This is to certify that Mr. / Miss. Simran Shrikant Sabat having Exam
Seat No./Roll No. FIT2146 of T.Y.BSc.IT (Semester VI) has completed the
Practical work in the subject of Cloud Computing during the academic
Year 2023-24 under the guidance of Asst.Prof. Sneha Jadhav being the partial
requirement for the fulfillment of the curriculum of Degree of Bachelor of Science in
Information Technology, Elphinstone College, Dr. Homi Bhabha State University.
INDEX
Sr No Name Date Page Sign
Practical No: 01
Code:
import java.net.*;
import java.io.*;
{
public static void main(String args[]) throws Exception
{
ServerSocket ss=new
ServerSocket(2000); Socket
sk=ss.accept();
BufferedReadercin=new
BufferedReader(new
InputStreamReader(sk.getInputStream()));
PrintStreamcout=new PrintStream(sk.getOutputStream());
BufferedReader stdin=new BufferedReader(new
InputStreamReader(System.in)); String s;
while ( true )
{
s=cin.readLine();
if (s.equalsIgnoreCase("END"))
Name : Simran Sabat Roll no:FIT2146
{
cout.println("BYE");
break;
}
System. out.print("Client :
"+s+"\n"); System.out.print("Server
: "); s=stdin.readLine();
cout.println(s);
}
ss.close();
sk.close();
cin.close();
cout.close(); stdin.close();
}
Chatclient.java
import java.net.*;
class chatclient
{
public static void main(String args[]) throws Exception
{
Name : Simran Sabat Roll no:FIT2146
InputStreamReader(System.in)); String s;
while ( true )
{
System.out.print("Client : ");
s=stdin.readLine();
sout.println(s);
s=sin.readLine();
System.out.print("Server :
"+s+"\n"); if (
s.equalsIgnoreCase("BYE") )
break;
}
sk.close();
sin.close();
sout.close(); stdin.close();
}
Name : Simran Sabat Roll no:FIT2146
Output:
Server:
Client:
Practical No: 02
Practical 2A: A client server based program using UDP to find if the
number entered is even or odd.
Code:
1. udpServerEO.java
/*Program which finds entered number is even or odd */
import java.io.*;
import java.net.*;
{
try
{
DatagramSocket ds = new DatagramSocket(2000);
Name : Simran Sabat Roll no:FIT2146
2. udpClientEO.java
/*Program which finds entered number is even or odd*/
import java.io.*;
import java.net.*;
public class udpClientEO
{
public static void main(String args[])
{
try
{
ds.send(dp);
byte b1[] = new byte[1024];
DatagramPacket dp1 = new
DatagramPacket(b1,b1.length); ds.receive(dp1);
String str = new
String(dp1.getData(),0,dp1.getLength());
System.out.println(str);
}
catch(Exception e)
{
e.printStackTrace();
}
}
} Output:
Name : Simran Sabat Roll no:FIT2146
Practical 2B:A client server based program using UDP to find the
factorial of the entered number.
Code:
1. udpServerFact.java
/*Program which calculate factorial of a number*/
import java.io.*;
import java.net.*;
public class udpServerFact
{
public static void main(String args[])
{
try
{
DatagramSocket ds = new DatagramSocket(2000);
byte b[] = new byte[1024];
DatagramPacketdp = new DatagramPacket(b,b.length);
ds.receive(dp);
String str = new
String(dp.getData(),0,dp.getLength());
System.out.println(str);
int a= Integer.parseInt(str);
int f = 1, i;
String s= new String();
for(i=1;i<=a;i++)
{
f=f*i;
}
s=Integer.toString(f);
String str1 = "The Factorial of " + str + " is : " +
f; byte b1[] = new byte[1024]; b1 =
str1.getBytes();
DatagramPacket dp1 = new
DatagramPacket(b1,b1.length,InetAddress.getLocal
Host(),1000); ds.send(dp1);
Name : Simran Sabat Roll no:FIT2146
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
2. udpClientFact.java
/*Program which calculate factorial of a number*/
import java.io.*;
import java.net.*;
public class udpClientFact
{
public static void main(String args[])
{
try
{
DatagramSocket ds = new DatagramSocket(1000);
BufferedReaderbr = new BufferedReader(new
InputStreamReader(System.in));
System.out.println("Enter a number : ");
String num = br.readLine();
byte b[] = new byte[1024];
b=num.getBytes();
DatagramPacketdp = new
DatagramPacket(b,b.length,InetAddress.getLocalHost(),2000);
ds.send(dp);
byte b1[] = new byte[1024];
DatagramPacket dp1 = new DatagramPacket(b1,b1.length);
ds.receive(dp1);
String str = new
String(dp1.getData(),0,dp1.getLength());
System.out.println(str);
Name : Simran Sabat Roll no:FIT2146
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
Output:
Code:
1. RPCServer.java
import java.util.*;
import java.net.*;
class RPCServer
{
DatagramSocket ds;
DatagramPacketdp;
String str,methodName,result;
int val1,val2;
RPCServer()
Name : Simran Sabat Roll no:FIT2146
{
try
{
ds=new DatagramSocket(1200);
byte b[]=new byte[4096];
while(true)
{
dp=new DatagramPacket(b,b.length);
ds.receive(dp);
str=new String(dp.getData(),0,dp.getLength());
if(str.equalsIgnoreCase("q"))
{
System.exit(1);
}
else
{
StringTokenizerst = new StringTokenizer(str,"
"); int i=0;
while(st.hasMoreTokens())
{
String token=st.nextToken();
methodName=token;
val1 = Integer.parseInt(st.nextToken());
val2 = Integer.parseInt(st.nextToken());
}
}
System.out.println(str);
InetAddressia = InetAddress.getLocalHost();
if(methodName.equalsIgnoreCase("add"))
{
result= "" + add(val1,val2);
}
else if(methodName.equalsIgnoreCase("sub"))
{
result= "" + sub(val1,val2);
}
else if(methodName.equalsIgnoreCase("mul"))
Name : Simran Sabat Roll no:FIT2146
{
result= "" + mul(val1,val2);
}
else if(methodName.equalsIgnoreCase("div"))
{
result= "" + div(val1,val2);
}
byte b1[]=result.getBytes();
DatagramSocket ds1 = new DatagramSocket();
DatagramPacket dp1 = new
DatagramPacket(b1,b1.length,InetAddress.getLocalH
ost(), 1300);
System.out.println("result :
"+result+"\n"); ds1.send(dp1);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public int add(int val1, int val2)
{
return val1+val2;
}
public int sub(int val3, int val4)
{
return val3-val4;
}
public int mul(int val3, int val4)
{
return val3*val4;
}
public int div(int val3, int val4)
{
return val3/val4;
}
Name : Simran Sabat Roll no:FIT2146
e.printStackTrace();
}
}
public static void main(String[] args)
{
new RPCClient();
}
}
Output:
Practical 2D: A program that finds the square, square root, cube and cube
root of the entered number.
Code:
1. RPCNumServer.java
import java.util.*;
import java.net.*;
import java.io.*;
class RPCNumServer
{
DatagramSocket ds;
Name : Simran Sabat Roll no:FIT2146
DatagramPacketdp;
String str,methodName,result;
int val;
RPCNumServer()
{
try
{
ds=new DatagramSocket(1200);
byte b[]=new byte[4096];
while(true)
{
dp=new DatagramPacket(b,b.length);
ds.receive(dp);
str=new
String(dp.getData(),0,dp.getLength());
if(str.equalsIgnoreCase("q")) {
System.exit(1);
}
else
{
StringTokenizerst = new StringTokenizer(str," ");
int i=0;
while(st.hasMoreTokens())
{
String token=st.nextToken();
methodName=token;
val = Integer.parseInt(st.nextToken());
}
}
System.out.println(str);
InetAddressia = InetAddress.getLocalHost();
if(methodName.equalsIgnoreCase("square"))
{
result= "" + square(val);
}
else if(methodName.equalsIgnoreCase("squareroot"))
{
result= "" + squareroot(val);
}
else if(methodName.equalsIgnoreCase("cube"))
{
Name : Simran Sabat Roll no:FIT2146
}
public double cuberoot(int a) throws Exception
{
double ans;
ans = Math.cbrt(a);
return ans;
}
public static void main(String[] args)
{
new RPCNumServer();
}
}
2. RPCNumClient.java
import java.io.*;
import java.net.*;
class RPCNumClient
{
RPCNumClient()
{
try
{
InetAddressia = InetAddress.getLocalHost();
DatagramSocket ds = new DatagramSocket();
DatagramSocket ds1 = new DatagramSocket(1300);
System.out.println("\nRPC Client\n");
System.out.println("1. Square of the number -
square\n2. Square root of the number - squareroot\n3. Cube of the number
- cube\n4. Cube root of the number - cuberoot");
System.out.println("Enter method name and the number\n");
while (true)
{
BufferedReaderbr = new
BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
byte b[] = str.getBytes();
Name : Simran Sabat Roll no:FIT2146
DatagramPacketdp = new
DatagramPacket(b,b.length,ia,1200);
ds.send(dp);
dp = new DatagramPacket(b,b.length);
ds1.receive(dp);
String s = new String(dp.getData(),0,dp.getLength());
System.out.println("\nResult = " + s + "\n");
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
new RPCNumClient();
}
}
Output:
Name : Simran Sabat Roll no:FIT2146
Practical No: 03
Code:
1. BroadcastServer.java
import java.net.*;
import java.io.*;
import java.util.*;
public class BroadcastServer
{
public static final int PORT = 1234;
public static void main(String args[])throws
Exception {
MulticastSocket socket;
DatagramPacket packet;
InetAddress address;
// set the multicast address to your local subnet
address = InetAddress.getByName("239.1.2.3");
socket = new MulticastSocket();
byte[] data =
null; for(;;)
Thread.sleep(10000);
System.out.println("Sending "); String
str = ("This is Neha Calling...."); data
= str.getBytes();
packet = new DatagramPacket(data, str.length(),address,PORT);
// Sends the packet
socket.send(packet);
} // end for
} // end main
Name : Simran Sabat Roll no:FIT2146
2. BroadcastClient.java
import java.net.*;
import java.io.*;
public class BroadcastClient
{
public static final int PORT = 1234;
Practical No: 04
Aim: Write a program to show the object communication using RMI.
1. InterDate.java
import java.rmi.*;
public interface InterDate extends Remote
{
public String display() throws Exception;
}
2. ServerDate.java
import java.rmi.*;
import java.rmi.server.*;
import java.util.*;
public class ServerDate extends
UnicastRemoteObjectimplements InterDate {
public ServerDate() throws Exception
{
}
public String display() throws Exception
{
String str = "";
Date d = new Date();
str = d.toString();
return str;
}
public static void main(String args[]) throws
Exception {
Name : Simran Sabat Roll no:FIT2146
Code:
1. InterConvert.java
import java.rmi.*;
public interface InterConvert extends Remote
{
public String convertDigit(String no) throws Exception;
}
2. ServerConvert.java
import java.rmi.*;
import java.rmi.server.*;
public class ServerConvert extends
UnicastRemoteObjectimplements InterConvert {
public ServerConvert() throws Exception
{
}
public String convertDigit(String no) throws
Exception {
String str = "";
for(int i = 0; i<no.length(); i++)
{
int p = no.charAt(i);
if( p == 48)
{
str += "zero ";
}
if( p == 49)
{
str += "one ";
}
Name : Simran Sabat Roll no:FIT2146
if( p == 50)
{
str += "two ";
}
if( p == 51)
{
str += "three ";
}
if( p == 52)
{
str += "four ";
}
if( p == 53)
{
str += "five ";
}
if( p == 54)
{
str += "six ";
}
if( p == 55)
{
Output
Name : Simran Sabat Roll no:FIT2146
:
Name : Simran Sabat Roll no:FIT2146
Practical No: 05
Web services are client and server applications that communicate over
the World Wide Web’s (WWW) HyperText Transfer Protocol (HTTP). As
described by the World Wide Web Consortium (W3C), web services provide
a standard means of interoperating between software applications running on
a variety of platforms and frameworks. Web services are characterized by
their great interoperability and extensibility, as well as their machine-
processable descriptions, thanks to the use of XML. Web services can be
combined in a loosely coupled way to achieve complex operations. Programs
providing simple services can interact with each other to deliver
sophisticated added-value services.
Basically, you would want to use RESTful web services for integration
over the web and use big web services in enterprise application integration
scenarios that have advanced quality of service (QoS) requirements.
JAX-WS: addresses advanced QoS requirements commonly occurring
in enterprise computing. When compared to JAX-RS, JAX-WS makes it
easier to support the WS-* set of protocols, which provide standards for
security and reliability, among other things, and interoperate with other
WS-* conforming clients and servers.
Name : Simran Sabat Roll no:FIT2146
JAX-RS: makes it easier to write web applications that apply some or all
of the constraints of the REST style to induce desirable properties in the
application, such as loose coupling (evolving the server is easier without
breaking existing clients), scalability (start small and grow), and
architectural simplicity (use off-the-shelf components, such as proxies or
HTTP routers). You would choose to use JAX-RS for your web
application because it is easier for many types of clients to consume
RESTful web services while enabling the server side to evolve and scale.
Clients can choose to consume some or all aspects of the service and
mash it up with other web-based services.
Practical 5A: Implementing “Big” Web Service.
Service.
3. Click Finish. The Projects window displays the structure of the new
web service and the source code is shown in the editor area.
two numbers received from a client. The NetBeans IDE provides a dialog for
adding an operation to a web service. You can open this dialog either in the
web service visual designer or in the web service context menu.
3. In the upper part of the Add Operation dialog box, type add in Name
and type int in the Return Type drop-down list.
4. In the lower part of the Add Operation dialog box, click Add and
create a parameter of type int named i.
1. Right-click the project and choose Deploy. The IDE starts the
application server, builds the application, and deploys the application
Name : Simran Sabat Roll no:FIT2146
to the server
2. In the IDE's Projects tab, expand the Web Services node of the
CalculatorWSApplication project. Right-click the CalculatorWS node,
and choose Test Web Service.
3. The IDE opens the tester page in your browser, if you deployed a web
application to theGlassFish server.
4. If you deployed to the GlassFish server, type two numbers in the tester page,
as shown below:
5. Leave the other settings at default and click Finish. The Projects window
displays the new web service client, with a node for the add method that you
created:
6. Double-click your main class so that it opens in the Source Editor. Drag the
add node below the main() method.
Name : Simran Sabat Roll no:FIT2146
JAX-WS simplifies the task of developing Web services using Java technology.
It provides support for multiple protocols such as SOAP, XML and by providing a
facility for supporting additional protocols along with HTTP.
With its support for annotations, JAX-WS simplifies Web service development and
reduces the size of runtime files.
Here basic demonstration of using IDE to develop a JAX-WS Web Service is given.
After creating the web service, create web service clients that use the Web service over a
network which is called consuming a web service.
Let’s build a Web Service that returns the book name along with its cost for a particular ISBN.
To begin building this service, create the data store. The server will access the data
stored in a MySQL table to serve the client.
Create a table named Books that will store valid books information
i. Choosing a container
Click –Finish
Right-click the BookWS project and select New -> Web Service as
shown indiagram.
Name : Simran Sabat Roll no:FIT2146
New Web Service dialog box appears. Enter the name BookWS in the Web
Service Name textbox, webservice in the Package textbox, select the
option Create Web Service from scratch and also select the option
implement web service as a stateless session bean as shown in the diagram.
Click Finish.
The web service in the form of java class is ready.
3) Designing the web service
Now add an operation which will accept the ISBN number from the
client to the web service.
In Add Operation dialog box, click Add and create a parameter of the
type String namedisbn as shown in the diagram.
Click Ok. The design view displays the operation added as shown in the
diagram.
Click Source. The code spec expands due to the operation added to the
web service as shown in the diagram.
Modify the code spec of the web service
package webservice;
import java.sql.*;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
Name : Simran Sabat Roll no:FIT2146
import javax.ejb.Stateless;
@WebService()
@Stateless()
public class BookWS {
/**
* Web service
operation */
@WebMethod(operationName =
"getBookDetails") public String
getBookDetails(@WebParam(name = "isbn")
String isbn) {
dbcon=
DriverManager.getConnection("jdbc:mysql://localhost/bookshop","root","123
");
stmt = dbcon.createStatement();
query = "select * from books where isbn = '" +isbn+
"'"; rs = stmt.executeQuery(query); rs.next();
return bookDetails;
Name : Simran Sabat Roll no:FIT2146
}
catch(Exception e)
{
System.out.println("Sorry failed to connect to the database.." +
e.getMessage()); }
return null;
}
}
Explanation
Right click on the libraries and select Add JAR/Folder as shown in the
diagram.
When a web service is deployed to a web container, the IDE allows testing
the web service to see if it functions as expected.
Name : Simran Sabat Roll
no:FIT2146
The tester application provided by GlassFish, is integrated into the IDE for
this purpose as it allows the developer to enter values and test them.
To test the BookWS application, right click the BookWS project and select
Deploy as shown in the diagram.
The IDE starts the server, builds the application and deploys the application
to the server.
Follow the progress of these operations in the BookWS (run-deploy) and
GlassFish v3 Domain tabs in the Output view.
Now expand the web services directory of the BookWS project, right-click the
BookWS Web service and select Test web service as shown in the diagram.
The IDE opens the tester page in the web browser, if the web application is
deployed using GlassFish server as shown in the figure.
Enter the ISBN number as shown in the diagram.
Click getBookDetails. The book name and its cost are displayed as shown
in the diagram.
Once the web service is deployed, the next most logical step is to create a
client to make use of the web service’s getBookDetails() method.
Click Next. Server and settings section of the new web application, dialog
box appears. Choose the default i.e. GlassFish v3 Domain as the web serevr,
the Java EE 6 web as the Java EE version and the context path.
Click Finish.
Name : Simran Sabat Roll
no:FIT2146
The web application named BookWSServletClient is created.
ii. Adding the web service to the client application
Right-click the BookWSServletClient project and select New -> Web
Service Client as shown in the diagram.
New Web Service Client dialog box appears. In the Project section, click
Browse and browse through the web service which needs to be consumed.
Click ok. The name of the web service appears in the New Web Service Client
as shown in the diagram.
Leave the other settings as it is. Click Finish
The Web Service Reference directory is added to the BookWSServletClient
application as shown in the diagram. It displays the structure of the newly
created client including the getBookDetails() method created earlier.
Click Next. Configure Servlet Deployment section of the New Servlet dialog
box appears. Keep the defaults.
Click Finish.
This creates the servlet named retreiveBookDetails.java in the servlet
package.
retreiveBookDetails.java is available with the default skeleton created by the
NetBeans IDE which needs to be modified to hold the application logic.
With the code spec of the getBookDetails() operation of the web service by
dragging and dropping the getBookDetails operation as shown in the diagram.
The Servlet code spec changes as shown in the diagram
Name : Simran Sabat Roll
no:FIT2146
Once the web service is added and the servlet is created, the form to accept
ISBN from the user needs to be coded.
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
</head>
<body bgcolor="pink">
</body>
</html>
Name : Simran Sabat Roll
no:FIT2146
v. Building the Web Application
Build the web application.
Right click BookWSServletClient project and select Build.
Once the Build menu item is clicked the details about the compilation and
building of the BookWSServletClient Web application appears in the output –
BookWSServletClient (dist) window.
Once the compilation and building of the web application is done run the
application. Right click the BookWSServerCleint project and select run.
Once the run processing completes in NetBeans IDE a web browser is
automatically launched and the BookWSServletCleint application is executed
as shown in the diagram.
Click Submit. The book name and its cost are displayed as shown in the
diagram.
Name : Simran Sabat Roll
no:FIT2146
Practical: 06
Aim:Implement Xen virtualization and manage with Xen Center
Installation is successful and virtual node has been created if we get below
Welcome screen of Windows XP machine.
Name : Simran Sabat Roll
no:FIT2146
Practical: 07
1. Aim: Implement virtualization using VMWare ESXi Server and managing
In vSphere create new Virtual Machine. Install Windows XP iso file and open
it.
Name : Simran Sabat Roll
no:FIT2146
Practical: 08
Aim:Implement Windows Hyper V virtualization
After Restart Search for hyper-v manager in search box and click on that.
Run Project