0% found this document useful (0 votes)
6 views34 pages

VI CSE CS3926 CC Labmanual

The document is a lab manual for the Cloud Computing Laboratory at Chendhuran College of Engineering and Technology, detailing procedures for installing VirtualBox with Linux, setting up a C compiler, and creating web applications using Google App Engine with Java and Python. It includes step-by-step instructions for various exercises, including setting up a virtual machine, compiling C programs, and developing web applications. The manual serves as a practical guide for students in the Computer Science and Engineering department under Anna University Regulation 2021.

Uploaded by

rguru160706
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views34 pages

VI CSE CS3926 CC Labmanual

The document is a lab manual for the Cloud Computing Laboratory at Chendhuran College of Engineering and Technology, detailing procedures for installing VirtualBox with Linux, setting up a C compiler, and creating web applications using Google App Engine with Java and Python. It includes step-by-step instructions for various exercises, including setting up a virtual machine, compiling C programs, and developing web applications. The manual serves as a practical guide for students in the Computer Science and Engineering department under Anna University Regulation 2021.

Uploaded by

rguru160706
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CHENDHURAN

College Of Engineering and Technology , Pudukkottai

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

BE- Computer Science and Engineering

Anna University Regulation: 2021

CCS335- Cloud Computing Laboratory

III Year/VI Semester

LAB MANUAL

Prepared By,

Mrs P. Rohini M.E. AP/CSE


3926_Chendhuran College of Engineering, Pudukkottai.

EX NO: 1
Date:
INSTALL VIRTUALBOX WITH LINUX OS ON TOP OF WINDOWS

AIM:

PROCEDURE:
Steps to install VirtualBox:
1. Download VirtualBox installer for windows.
2. The installer can be downloaded from the link : [Link]
3. Click “Windows host” to download the binary version for windows host.
4. The installer file downloaded will have the file name format like “VirtualBox-VersionNumber-BuildNumber-
[Link]”. Example: [Link].
5. Double click on the installer to launch the setup Wizard. Click on Next to continue.
6. Custom setup dialog box will be opened. Accept the default settings and click next.
7. Select the way you want the features to be installed. You can accept the default and click next.
8. A dialog box opens with Network Interfaces warning. Click Yes to proceed.
9. Click install to begin the installation process.
10. When prompted with a message to install (Trust) Oracle Universal Serial Bus, click Install to continue.
11. After the installation completes, click finish to exit the setup wizard.
12. Launch the Oracle VM VirtualBox.

Steps to create a virtual machine [Ubuntu] in VirtualBox:


1. Open the Oracle VM VirtualBox.
2. Click New icon or “Ctrl + N” to create a new virtual machine.
3. Enter a name for the new virtual machine. Choose the Type and Version. Note that
VirtualBox automatically changes ‘Type’ to Linux and ‘Version’ to ‘Ubuntu (64 bit)’ if the
name is given as ‘Ubuntu’. Click Next.
4. Select the amount of RAM to use. The ideal amount of RAM will automatically be selected.
Do not increase the RAM into the red section of the slider; keep the slider in the green
section.
5. Accept the default 'Create a virtual hard drive now' and click 'Create' button.
6. Choose the hard disk file type as VDI (VirtualBox Disk Image). Click Next.
7. Click Next to accept the default option ‘Dynamically allocated’ for storage on physical hard
drive.
8. Select the size of the virtual hard disk and click create.
9. The newly created virtual machine will be displayed in the dashboard.
10. Download the ISO file [Ubuntu disk image file]. Latest version of Ubuntu iso file can be
downloaded from the link [Link] . Click Download button.
11. For previous versions, goto [Link] . Choose the preferred version of
Ubuntu and download the iso file.
12. To setup the Ubuntu disk image file (iso file) goto settings.
13. Click Storage. Under “Storage Devices” section click “Empty”.
14. In Attributes section, click the disk image and then "Choose Virtual Optical Disk File".
15. Browse and select the downloaded iso file. Click ok.
16. Select the newly created virtual machine in the dashboard and click start button.
17. In the welcome screen, click “Install Ubuntu” button.
3926_Chendhuran College of Engineering, Pudukkottai.
3926_Chendhuran College of Engineering, Pudukkottai.

18. Click 'Continue' button.


19. Make sure 'Erase disk and install Ubuntu' option is selected and click 'Install Now' button.
20. Choose the default and click continue.
21. Setup up your profile by creating username and password.
22. After installation is complete, click 'Restart Now' button and follow the instructions.
23. The Ubuntu OS is ready to use. Login with the username and password.

OUTPUT:

Result:
3926_Chendhuran College of Engineering, Pudukkottai.

EX NO: 2
Date:
INSTALL A C COMPILER IN THE VIRTUAL MACHINE

AIM:

PROCEDURE:
[Link] the virtual box and open the virtual machine (Ubuntu).
2. Run the following command in the virtual machine terminal.
$ sudo apt-get update
$ sudo apt-get install gcc
It will install all the necessary packages for gcc complier.
3. Type the C program in the text editor and save the file with .c extention.
//fact.c
#include<stdio.h>
void main()
{
int n,fact=1;
int i=1;
printf("Enter a positive integer:");
scanf("%d",&n);
if(n==0)
{
fact=1;
}
else
{
while(i<=n)
{
fact*=i;
i++;
}
printf("The factorial of %d is %d ",n,fact);
}}
4. Compile and Run the C Program
cc fact.c
./[Link]
3926_Chendhuran College of Engineering, Pudukkottai.

OUTPUT:

RESULT:
3926_Chendhuran College of Engineering, Pudukkottai.

EX NO: 3 INSTALL GOOGLE APP ENGINE AND CREATE A WEB


Date: APPLICATIONS USING JAVA

AIM:

PROCEDURE:
Google App Engine SDK Installation:
1. Download the Google Cloud SDK installer using the link [Link]
2. Select the standard environment as Java.
3. Click „Download and Install the Cloud SDK‟. Launch the installer and follow the prompts.
4. After installation has completed, the installer presents severaloptions:
Make sure that the following are selected:
• Start Google Cloud SDKShell.
• Run 'gcloudinit' .The installer then starts a terminal window and runs the gcloudinit command.
5. Run the following command in your terminal to install the gcloud component that includes the App Engine
extension for Java11:
gcloudcomponentsinstallapp-engine-java
Creating a new App Engine standard project in Eclipse:
6. Eclipse with the cloud tools is used to create App Engine standard project.
7. To install the Cloud Tools in Eclipse, select Help > Eclipse Marketplace... and search for “Google Cloud Tools for
Eclipse” and click install.
8. After installation restart eclipse when prompted.
9. Click the Google Cloud Platform toolbar button.
10. Select Create New Project >Google App Engine Standard Java Project.

11. Enter the project name and package name.


12. Click Next. Select the libraries required for the project.
13. Click Finish.
14. The wizard generates a native Eclipse project, with a simple servlet, that you can run and deploy from the IDE.
15. App Engine Java applications use the Java Servlet API to interact with the web server. Modify the
[Link] file with your application code.
3926_Chendhuran College of Engineering, Pudukkottai.

16. [Link] is a Google App Engine specific configuration file.

17. [Link] is a standard web application configuration file.

18. Right click the project in the Package Explorer, select Run As > App Engine.

19. Eclipse opens its internal web browser to your application.

You can also open an external browser and navigate to [Link]

Either way, you'll see a static HTML page with a link to the servlet.
[Link]
<!DOCTYPE html>
<html xmlns="[Link] lang="en">
<head>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF -8" />
<title>Hello App Engine</title>
</head>
<body>
<h1>Hello App Engine!</h1>
<table>
<tr>
<td colspan="2" style="font-weight:bold;">Available Servlets:</td>
</tr>
<tr>
<td><a href='/hello'>The servlet</a></td>
</tr>
</table>
</body>
</html>
3926_Chendhuran College of Engineering, Pudukkottai.

[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@WebServlet(
name = "HelloAppEngine",
urlPatterns = {"/hello"}
)
public class HelloAppEngine extends HttpServlet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException {
[Link]("=text/plain");
[Link]("UTF-8");
[Link]().print("Hello App Engine!\r\n");
}
}

RESULT:
3926_Chendhuran College of Engineering, Pudukkottai.

EX NO: 4 Install Google App Engine and create a simple web applications
Date: using python

AIM:

PROCEDURE:
1. Download the python from [Link] and install it in the system.
2. Download the SDK for python from [Link] .
3. Login into Cloud SDK with the Google account .
4. Create a python file and save it as [Link]
5. Create a YAML file for configuration and name it as [Link]
6. Open the Cloud SDK window and type the comment Google -cloud-sdk\bin\[Link] “<>”
7. In web browser obtain the result from address localhost:8080.

PROGRAM:
[Link]
runtime: python27
threadsafe: true
handlers:
- url: /
script: [Link]

[Link]
import os
import json
import urllib
import webapp2
from [Link] import template

class MainPage([Link]):
def get(self):
template_values = {}
path = [Link]([Link](__file__), '[Link]')
[Link]([Link](path, template_values))

def post(self):
pincode = [Link]('zipCode')
if not [Link]() or not len(pincode) == 6:
template_values = {
"error": "Incorrect Pin Code (String / False Code entered)"
}
path = [Link]([Link](__file__), '[Link]')
return [Link]([Link](path, template_values))
url = "[Link] + pincode
data = [Link](url).read()
data = [Link](data)
if(data[0]['Status'] == 'Success'):
post_office = data[0]['PostOffice'][0]['State']
3926_Chendhuran College of Engineering, Pudukkottai.

OUTPUT:
3926_Chendhuran College of Engineering, Pudukkottai.

name = data[0]['PostOffice'][0]['Name']
block = data[0]['PostOffice'][0]['Block']
district = data[0]['PostOffice'][0]['District']
template_values = {
"post_office": post_office,
"name": name,
"block": block,
"district": district
}
path = [Link]([Link](__file__), '[Link]')
[Link]([Link](path, template_values))
else:
template_values = {}
path = [Link]([Link](__file__), '[Link]')
[Link]([Link](path, template_values))

app = [Link]([('/', MainPage)], debug=True)

[Link]
<html>
<style>
.weatherText {
font-family: 'Lato', 'sans-serif';
font-size: 24px;
text-align: center;
}

#weatherForm {
padding: 20px;
}

#weatherSubmit {
color: white;
background-color: #083375;
padding: 5px 20px;
border-radius: 5px;
margin-top: 20px;
}

#weatherSubmit:hover {
cursor: pointer;
}
body {
display: flex;
justify-content: center;
align-items: center;
}
.card {
border: 2px solid black;
width: 50%;

justify-content: center;
align-items: center;
}
</style>
<head>
<title class="alignct">Post Office Finder</title>
3926_Chendhuran College of Engineering, Pudukkottai.

<link href=[Link] rel="stylesheet" />


</head>
<body>
<div class="card">
<h2 class="weatherText">Post Office Finder Using WebApp</h2>
<h1 id="error_head" style="display: none" value="{{error}}">{{error}}</h1>
<form class="weatherText" id="weatherForm" action="/" method="post">
Location Zip Code:
<input class="weatherText" id="weatherInput" type="text" name="zipCode"/><br />
<input class="weatherText" id="weatherSubmit" type="submit value="Submit"/>
<button id="weatherSubmit" class="weatherText" onclick="[Link]('weatherInput').value = ''">
Clear</button>
</form>
</div>
<script>
let err = [Link]('error_head');
function myFunction() {
alert('Please Enter the Valid Pin Code!');
}
if (err) {
myFunction();
}
</script>
</body>
</html>

[Link]
<!DOCTYPE html>
<html lang="en">
<style>
body {
display: flex;
justify-content: center;
align-items: center;
}
#weatherResults {
background-color: #83e9c2;
font-family: 'Lato', sans-serif;
font-size: 24px;
padding: 30px;
display: inline-block;
text-align: center;
margin: 20px;
margin-top: 10%;
border: 2px solid black;
border-radius: 5px;
}
</style>
<head>
<meta charset="UTF-8" />
<title>Post Office Information</title>
<link href=[Link] rel="stylesheet"/>
</head>
<body>
<div id="weatherResults">
<table>
<tr>
<th>
<h3>State of Post Office :</h3>
</th>
<th>
<h3>{{ post_office }}</h3>
</th>
</tr>
3926_Chendhuran College of Engineering, Pudukkottai.

<tr>
<th>
<h3>Name of Post Office :</h3>
</th>
<th>
<h3>{{ name }}</h3>
</th>
</tr>
<tr>
<th>
<h3>Block of Post Office:</h3>
</th>
<th>
<h3>{{ block }}</h3>
</th>
</tr>
<tr>
<th>
<h3>District of Post Office:</h3>
</th>
<th>
<h3>{{ district }}</h3>
</th>
</tr>
</table>
<a href="[Link] to the Home page</h4></a>
</div>
</body>
</html>
[Link]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Error page</title>
<link href=[Link] rel="stylesheet"/>
</head>
<body>
<div style="text-align: center">
<h2>No such pin exists</h2>
<a href="[Link] to the Home page</h3></a>
</div>
</body>
</html>

RESULT:
3926_Chendhuran College of Engineering, Pudukkottai.

EX NO: 5 SIMULATE A CLOUD SCENARIO USING CLOUDSIM AN RUN A


Date: SCHEDULING ALGORITHM
AIM:

PROCEDURE:
What is Cloudsim?
CloudSim is a simulation toolkit that supports the modeling and simulation of the core functionality of cloud, like
job/task queue, processing of events, creation of cloud entities(datacenter, datacenter brokers, etc), communication
between different entities, implementation of broker policies, etc.
This toolkit allows to:
• Test application services in a repeatable and controllable environment.
• Tune the system bottlenecks before deploying apps in an actual cloud.
• Experiment with different workload mix and resource performance scenarios on simulated infrastructure for
developing and testing adaptive application provisioning techniques.
Core features of CloudSim are:
• The Support of modeling and simulation of large scale computing environment as federated cloud data
centers, virtualized server hosts, with customizable policies for provisioning host resources to virtual
machines and energy-aware computational resources.
• It is a self-contained platform for modeling cloud‟s service brokers, provisioning, and allocation policies.
• It supports the simulation of network connections among simulated system elements.
• Support for simulation of federated cloud environment, that inter-networks resources from both private and
public domains.
• Availability of a virtualization engine that aids in the creation and management of multiple independent and
co-hosted virtual services on a data center node.
• Flexibility to switch between space shared and time shared allocation of processing cores to virtualized
services.
How to use CloudSim in Eclipse:
CloudSim is written in Java. The knowledge you need to use CloudSim is basic Java programming and some basics
about cloud computing. Knowledge of programming IDEs such as Eclipse or NetBeans is also helpful. It is a library
and, hence, CloudSim does not have to be installed. Normally, you can unpack the downloaded package in any
directory, add it to the Java classpath and it is ready to be used. Please verify whether Java is available on your
system.

To use Cloudsim in eclipse:

1. Download CloudSim installable files from [Link] and unzip

2. Open Eclipse

3. Create a new Java Project: File -> New

4. Import an unpacked CloudSim project into the new Java Project

5. The first step is to initialise the CloudSim package by initialising the CloudSim library, as follows:

[Link](num_user, calendar, trace_flag)


3926_Chendhuran College of Engineering, Pudukkottai.

6. Data centres are the resource providers in CloudSim; hence, creation of data centres is a second step. To create
Datacenter, you need the DatacenterCharacteristics object that stores the properties of a data centre such as
architecture, OS, list of machines, allocation policy that covers the time or spaceshared, the time zone and its price:

Datacenter datacenter9883 = new Datacenter(name, characteristics, new VmAllocationPolicySimple(hostList)

7. The third step is to create a broker: DatacenterBroker broker = createBroker();

8. The fourth step is to create one virtual machine unique ID of the VM, userId ID of the VM‟s owner, mips, number
Of Pes amount of CPUs, amount of RAM, amount of bandwidth, amount of storage, virtual machine monitor, and
cloudletScheduler policy for cloudlets:

Vm vm = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared())

9. Submit the VM list to the broker: [Link](vmlist)

10. Create a cloudlet with length, file size, output size, and utilisation model:

Cloudlet cloudlet = new Cloudlet(id, length, pesNumber, fileSize, outputSize, utilizationModel, utilizationModel )

11. Submit the cloudlet list to the broker: [Link](cloudletList)

12. Start the simulation: [Link]().

PROGRAM:
SJF_Scheduler.java

package [Link];
import [Link].*;
import [Link];
import [Link] ;
import [Link] ;
import [Link] ;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

public class SJF_Scheduler {

private static List<Cloudlet> cloudletList;


private static List<Vm> vmList;
private static Datacenter[] datacenter;
private static double[][] commMatrix;
private static double[][] execMatrix;

private static List<Vm> createVM(int userId, int vms) {


//Creates a container to store VMs. This list is passed to the broker later
LinkedList<Vm> list = new LinkedList<Vm>();

//VM Parameters
long size = 10000; //image size (MB)
int ram = 512; //vm memory (MB)
int mips = 250;
long bw = 1000;
int pesNumber = 1; //number of cpus
3926_Chendhuran College of Engineering, Pudukkottai.

String vmm = "Xen"; //VMM name

//create VMs
Vm[] vm = new Vm[vms];

for (int i = 0; i < vms; i++) {


vm[i] = new Vm(datacenter[i].getId(), userId, mips, pesNumber, ram, bw, size, vmm, new
CloudletSchedulerSpaceShared());
[Link](vm[i]);
}

return list;
}

private static List<Cloudlet> createCloudlet(int userId, int cloudlets, int idShift) {


// Creates a container to store Cloudlets
LinkedList<Cloudlet> list = new LinkedList<Cloudlet>();

//cloudlet parameters
long fileSize = 300;
long outputSize = 300;
int pesNumber = 1;
UtilizationModel utilizationModel = new UtilizationModelFull();

Cloudlet[] cloudlet = new Cloudlet[cloudlets];

for (int i = 0; i < cloudlets; i++) {


int dcId = (int) ([Link]() * Constants.NO_OF_DATA_CENTERS);
long length = (long) (1e3 * (commMatrix[i][dcId] + execMatrix[i][dcId]));
cloudlet[i] = new Cloudlet(idShift + i, length, pesNumber, fileSize, outputSize, utilizationModel,
utilizationModel, utilizationModel);
// setting the owner of these Cloudlets
cloudlet[i].setUserId(userId);
cloudlet[i].setVmId(dcId + 2);
[Link](cloudlet[i]);
}
return list;
}

public static void main(String[] args) {


[Link]("Starting SJF Scheduler...");

new GenerateMatrices();
execMatrix = [Link]();
commMatrix = [Link]();

try {
int num_user = 1; // number of grid users
Calendar calendar = [Link]();
boolean trace_flag = false; // mean trace events

[Link](num_user, calendar, trace_flag);

// Second step: Create Datacenters


datacenter = new Datacenter[Constants.NO_OF_DATA_CENTERS];
for (int i = 0; i < Constants.NO_OF_DATA_CENTERS; i++) {
3926_Chendhuran College of Engineering, Pudukkottai.

OUTPUT:
3926_Chendhuran College of Engineering, Pudukkottai.

datacenter[i] = [Link]("Datacenter_" + i);


}

//Third step: Create Broker


SJFDatacenterBroker broker = createBroker("Broker_0");
int brokerId = [Link]();

//Fourth step: Create VMs and Cloudlets and send them to broker
vmList = createVM(brokerId, Constants.NO_OF_DATA_CENTERS);
cloudletList = createCloudlet(brokerId, Constants.NO_OF_TASKS, 0);

[Link](vmList);
[Link](cloudletList);

// Fifth step: Starts the simulation


[Link]();

// Final step: Print results when simulation is over


List<Cloudlet> newList = [Link]();
//[Link]([Link]().getCloudletReceivedList());

[Link]();

printCloudletList(newList);

[Link](SJF_Scheduler.[Link]() + " finished!");


} catch (Exception e) {
[Link]();
[Link]("The simulation has been terminated due to an unexpected error");
}
}

private static SJFDatacenterBroker createBroker(String name) throws Exception {


return new SJFDatacenterBroker(name);
}

/**
* Prints the Cloudlet objects
*
* @param list list of Cloudlets
*/
private static void printCloudletList(List<Cloudlet> list) {
int size = [Link]();
Cloudlet cloudlet;

String indent = " ";


[Link]();
[Link]("========== OUTPUT ==========");
[Link]("Cloudlet ID" + indent + "STATUS" +
indent + "Data center ID" +
indent + "VM ID" +
indent + indent + "Time" +
indent + "Start Time" +
indent + "Finish Time");

DecimalFormat dft = new DecimalFormat("###.##");


[Link](2);
3926_Chendhuran College of Engineering, Pudukkottai.
3926_Chendhuran College of Engineering, Pudukkottai.

for (int i = 0; i < size; i++) {


cloudlet = [Link](i);
[Link](indent + [Link]([Link]()) + indent + indent);

if ([Link]() == [Link]) {
[Link]("SUCCESS");

[Link](indent + indent + [Link]([Link]()) +


indent + indent + indent + [Link]([Link]()) +
indent + indent + [Link]([Link]()) +
indent + indent + [Link]([Link]()) +
indent + indent + indent + [Link]([Link]()));
}
}
double makespan = calcMakespan(list);
[Link]("Makespan using SJF: " + makespan);
}

private static double calcMakespan(List<Cloudlet> list) {


double makespan = 0;
double[] dcWorkingTime = new double[Constants.NO_OF_DATA_CENTERS];

for (int i = 0; i < Constants.NO_OF_TASKS; i++) {


int dcId = [Link](i).getVmId() % Constants.NO_OF_DATA_CENTERS;
if (dcWorkingTime[dcId] != 0) --dcWorkingTime[dcId];
dcWorkingTime[dcId] += execMatrix[i][dcId] + commMatrix[i][dcId];
makespan = [Link](makespan, dcWorkingTime[dcId]);
}
return makespan;
}
}

[Link]

package [Link];

import [Link].*;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

public class SJFDatacenterBroker extends DatacenterBroker {

SJFDatacenterBroker(String name) throws Exception {


super(name);
}

public void scheduleTaskstoVms() {


int reqTasks = [Link]();
int reqVms = [Link]();
Vm vm = [Link](0);

for (int i = 0; i < reqTasks; i++) {


bindCloudletToVm(i, (i % reqVms));
3926_Chendhuran College of Engineering, Pudukkottai.

[Link]("Task" + [Link](i).getCloudletId() + " is bound with VM" + [Link](i %


reqVms).getId());
}

//[Link]("reqTasks: "+ reqTasks);

ArrayList<Cloudlet> list = new ArrayList<Cloudlet>();


for (Cloudlet cloudlet : getCloudletReceivedList()) {
[Link](cloudlet);
}

//setCloudletReceivedList(null);

Cloudlet[] list2 = [Link](new Cloudlet[[Link]()]);

//[Link]("size :"+[Link]());

Cloudlet temp = null;

int n = [Link]();

for (int i = 0; i < n; i++) {


for (int j = 1; j < (n - i); j++) {
if (list2[j - 1].getCloudletLength() / ([Link]() * [Link]()) > list2[j].getCloudletLength() /
([Link]() * [Link]())) {
//swap the elements!
//swap(list2[j-1], list2[j]);
temp = list2[j - 1];
list2[j - 1] = list2[j];
list2[j] = temp;
}
// printNumbers(list2);
}
}

ArrayList<Cloudlet> list3 = new ArrayList<Cloudlet>();

for (int i = 0; i < [Link]; i++) {


[Link](list2[i]);
}
//printNumbers(list);

setCloudletReceivedList(list);

//[Link]("\n\tSJFS Broker Schedules\n");


//[Link]("\n");
}

public void printNumber(Cloudlet[] list) {


for (int i = 0; i < [Link]; i++) {
[Link](" " + list[i].getCloudletId());
[Link](list[i].getCloudletStatusString());
}
[Link]();
}
3926_Chendhuran College of Engineering, Pudukkottai.

public void printNumbers(ArrayList<Cloudlet> list) {

for (int i = 0; i < [Link](); i++) {


[Link](" " + [Link](i).getCloudletId());
}
[Link]();
}

@Override
protected void processCloudletReturn(SimEvent ev) {
Cloudlet cloudlet = (Cloudlet) [Link]();
getCloudletReceivedList().add(cloudlet);
[Link]([Link]() + ": " + getName() + ": Cloudlet " + [Link]()
+ " received");
cloudletsSubmitted--;
if (getCloudletList().size() == 0 && cloudletsSubmitted == 0) {
scheduleTaskstoVms();
cloudletExecution(cloudlet);
}
}

protected void cloudletExecution(Cloudlet cloudlet) {

if (getCloudletList().size() == 0 && cloudletsSubmitted == 0) { // all cloudlets executed


[Link]([Link]() + ": " + getName() + ": All Cloudlets executed. Finishing...");
clearDatacenters();
finishExecution();
} else { // some cloudlets haven't finished yet
if (getCloudletList().size() > 0 && cloudletsSubmitted == 0) {
// all the cloudlets sent finished. It means that some bount
// cloudlet is waiting its VM be created
clearDatacenters();
createVmsInDatacenter(0);
}
}
}

@Override
protected void processResourceCharacteristics(SimEvent ev) {
DatacenterCharacteristics characteristics = (DatacenterCharacteristics) [Link]();
getDatacenterCharacteristicsList().put([Link](), characteristics);

if (getDatacenterCharacteristicsList().size() == getDatacenterIdsList().size()) {
distributeRequestsForNewVmsAcrossDatacenters();
}
}

protected void distributeRequestsForNewVmsAcrossDatacenters() {


int numberOfVmsAllocated = 0;
int i = 0;

final List<Integer> availableDatacenters = getDatacenterIdsList();

for (Vm vm : getVmList()) {


int datacenterId = [Link](i++ % [Link]());
String datacenterName = [Link](datacenterId);
3926_Chendhuran College of Engineering, Pudukkottai.

if (!getVmsToDatacentersMap().containsKey([Link]())) {

[Link]([Link]() + ": " + getName() + ": Trying to Create VM #" + [Link]() + " in " +
datacenterName);
sendNow(datacenterId, CloudSimTags.VM_CREATE_ACK, vm);
numberOfVmsAllocated++;
}
}

setVmsRequested(numberOfVmsAllocated);
setVmsAcks(0);
}
}

RESULT:
3926_Chendhuran College of Engineering, Pudukkottai.

EX NO: 6
Date:
COPY FILES FROM ONE VIRTUAL MACHINE TO ANOTHER

AIM:

PROCEDURE:
1. .Create one shared folder in virtual box.
2. VirtualBox’s Shared Folders feature works with both Windows and Linux guest operating systems.
3. To use the feature, you first need to install VirtualBox’s Guest Additions in the guest virtual machine.
4. With the virtual machine running, click the “Devices” menu and choose the “Insert Guest Additions CD
image” option.
5. This inserts a virtual CD that you can use within the guest operating system to install the Guest Additions.
6. After the Guest Additions are installed, open the “Machine” menu and click the “Settings” option.

7. In the “Settings” window, switch to the “Shared Folders” tab.


8. Here you can see any shared folders you‟ve set up.
9. There are two types of shared folders.
10. Machine Folders are permanent folders that are shared until you remove them.
11. Transient Folders are temporary and are automatically removed when you restart or shut down the virtual
machine.
12. Click the “Add” button (the folder with a plus on it) to create a new shared folder.
3926_Chendhuran College of Engineering, Pudukkottai.

OUTPUT:

In the “Add Share” window, you can specify the following:


• Folder Path: This is the location of the shared folder on your host operating system (your real PC).
• Folder Name: This is how the shared folder will appear inside the guest operating system.
• Read-only: By default, the virtual machine has full read-write access to the shared folder.
• Enable the “Read-only” checkbox if you want the virtual machine only to be able to read files from the
shared folder, but not modify them.
• Auto-mount: This option makes the guest operating system attempt to automatically mount the folder
when it boots.
• Make Permanent: This option makes the shared folder a Machine Folder. If you don‟t select this option, it
becomes a transient folder that is removed with the virtual machine restarts.

Make all your choices and then hit the “OK” button.

RESULT:
3926_Chendhuran College of Engineering, Pudukkottai.

EX NO: 7
Date:
INSTALL HADOOP SINGLE NODE CLUSTER

AIM:

PROCEDURE:
1. Download Hadoop 2.8.0
2. Check either Java 1.8.0 is already installed on your system or not, use “Javac - version" to check Java version
3. If Java is not installed on your system then first install java under "C:\JAVA" Java setup
4. Extract files Hadoop [Link] or [Link] and place under "C:\Hadoop-2.8.0" hadoop
5. Set the path HADOOP_HOME Environment variable.
6. Set the path JAVA_HOME Environment variable.
7. Next we set the Hadoop bin directory path and JAVA bin directory path.
HADOOP CONFIGURATION:
a) File C:/Hadoop-2.8.0/etc/hadoop/[Link], paste below xml paragraph and save this file.
<configuration>
<property>
<name>[Link]</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
b) Rename [Link]" to "[Link]" and edit this file
C:/Hadoop2.8.0/etc/hadoop/[Link], paste below xml paragraph and save this file.
<configuration>
<property>
<name>[Link]</name>
<value>yarn</value>
</property>
</configuration>
c) Create folder "data" under "C:\Hadoop-2.8.0"
• Create folder "datanode" under "C:\Hadoop-2.8.0\data"
• Create folder "namenode" under "C:\Hadoop-2.8.0\data" data
d) Edit file C:\Hadoop-2.8.0/etc/hadoop/[Link], paste below xml paragraph and save this file.
<configuration>
<property>
<name>[Link]</name>
<value>1</value>
</property>
<property>
<name>[Link]</name>
<value>C:\hadoop-2.8.0\data\namenode</value>
</property>
<property>
<name>[Link]</name>
<value>C:\hadoop-2.8.0\data\datanode</value>
</property>
</configuration>
3926_Chendhuran College of Engineering, Pudukkottai.
3926_Chendhuran College of Engineering, Pudukkottai.

e) Edit file C:/Hadoop-2.8.0/etc/hadoop/[Link], paste below xml paragraph and save this file.
<configuration>
<property>
<name>[Link]-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>[Link]</name>
<value>[Link]</value>
</property>
</configuration>
f) Edit file C:/Hadoop-2.8.0/etc/hadoop/[Link], paste below xml paragraph and save this file.
<configuration>
<property>
<name>[Link]-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>[Link]</name>
<value>[Link]</value>
</property>
</configuration>
g) Edit file C:/Hadoop-2.8.0/etc/hadoop/[Link] by closing the command line
"JAVA_HOME=%JAVA_HOME%" instead of set "JAVA_HOME=C:\Java"

Hadoop Configuration:
1) Download file Hadoop [Link]
2) Delete file bin on C:\Hadoop-2.8.0\bin, replaced by file bin on file just download (from Hadoop
[Link]).
3) Open cmd and typing command "hdfs namenode –format" .You will see hdfs namenode –format Testing.
4) Open cmd and change directory to "C:\Hadoop-2.8.0\sbin" and type "start- [Link]" to start apache.
5) Make sure these apps are running.
a) Name node
b)Hadoop data node
c) YARN Resource Manager
d)YARN Node Manager hadoop nodes .
6) Open: [Link] .

Open cmd in Administrative mode and move to "C:/Hadoop-2.8.0/sbin" and start cluster
1. Create an input directory in HDFS.
hadoop fs –mkdir/input_dir
2. Copy the input text file named input_file.txt in the input directory (input_dir) of HDFS.
hadoop fs –put C:/input_file.txt/input_dir
3. Verify input_file.txt available in HDFS input directory (input_dir).
hadoop fs –ls/input_dir/
4. Verify content of the copied file.
hadoop dfs –cat/input_dir/input_file.txt
5. Run [Link] and also provide input and out directories.
hadoop jar C:/[Link] wordcount /input_dir /output_dir
6. Verify content for generated output file.
hadoop dfs -cat /output_dir/*
3926_Chendhuran College of Engineering, Pudukkottai.

RESULT:
8. Creating And Executing Your First Container Using Docker.

AIM:

To create and execute a container using docker..

STEP:1 Installing Docker on the System

To begin, you will need to install Docker on your system.


Docker provides installers for Windows, macOS, and various flavors of Linux, making it accessible to a
wide range of users.
Below are the commands you can use to install Docker on Ubuntu:

[Link] apt update

[Link] apt install apt-transport-https ca-certificates curl software-properties-common

[Link] -fsSL [Link] | sudo apt-key add -

[Link] add-apt-repository "deb [arch=amd64] [Link] $(lsb_release -cs) st


able"

[Link] apt update

[Link] apt install docker-ce

Once the installation is complete, you can verify it by checking the Docker version and making sure the
Docker daemon is running.

STEP:2 Verifying the Installation and Accessing the Docker CLI

For those using the Ubuntu operating system, you can verify the Docker installation by running the following
command:

[Link] --version

[Link] systemctl status docker

With Docker successfully installed, you can now access the Docker command-line interface (CLI) to start
creating and managing containers.
The CLI provides a set of commands for interacting with Docker, allowing you to build, run, and manage
containers with ease.

STEP:3 Crafting Your First Dockerfile

Some of the key concepts in Docker revolve around creating a Dockerfile, which is a text document that
contains all the commands a user could call on the command line to assemble an image.
The Dockerfile contains all the information Docker needs to build the image. Let’s take a look at how to
define a simple Dockerfile and some best practices for writing it.
STEP:4 Defining a Simple Dockerfile

First, let’s start by creating a basic Dockerfile.


In this example, we’ll create a Dockerfile that simply prints “Hello, World!” when run as a container.

[Link] alpine

[Link] echo "Hello, World!"

When defining a simple Dockerfile, it’s important to keep it as minimal as possible.


Only include the necessary dependencies and commands required for your application to run within the
container.
This helps to keep the image size small and reduces the attack surface, making it more secure.

STEP:5 Best Practices for Writing Dockerfiles

Dockerfiles should follow best practices to ensure consistency, maintainability, and reusability.
One of the best practices is to use the official base images from Docker Hub, as they are well-maintained and
regularly updated. It’s also important to use specific versions of the base images to avoid unexpected changes.

[Link] node:14

[Link] . /app

[Link] /app

[Link] npm install

[Link] ["npm", "start"]

Best practices for writing Dockerfiles also include using a .dockerignore file to specify files and directories to
exclude from the context when building the image.
This helps to reduce the build context and improve build performance.

Some additional best practices for writing Dockerfiles include avoiding running commands as root, using
multi-stage builds for smaller images, and using environment variables for configuration.

STEP6: Building and Running Your Container

To build and run your Docker container, you will need to follow a few simple steps.
First, you will need to build the Docker image from your Dockerfile.
Once the image is built, you can run your container using the Docker run command. In this section, we will
walk through each step in detail.

Building the Docker Image from Your Dockerfile

To build the Docker image from your Dockerfile, you will need to navigate to the directory where your
Dockerfile is located and run the following command:
docker build -t your-image-name .

This command will build the Docker image using the instructions specified in your Dockerfile.
Once the build process is complete, you will have a new Docker image ready for use.

Running Your Docker Container

To run your Docker container, you will need to use the Docker run command followed by the name of the
image you want to run.
For example:

docker run your-image-name


Running this command will start a new container based on the specified image.
Depending on your application, you may need to specify additional options for the docker run command,
such as port bindings or environment variables.
docker run -p 8080:80 your-image-name

Your Docker container is now up and running, ready to serve your application to the world.

Managing Your Docker Container

Unlike traditional virtual machines, where you need to manually install and configure software, Docker
containers are designed to be easily managed and manipulated.
Let’s take a look at some key ways to manage your Docker containers.

Monitoring Container Performance

With Docker, you can easily monitor the performance of your containers using built-in commands.
By running docker stats , you can view real-time CPU, memory, and network usage for all running
containers.
This can help you identify any resource bottlenecks and optimize your container performance.

Stopping, Starting, and Removing Containers

The Docker CLI provides simple commands for stopping, starting, and removing containers.
The command

docker stop [container_name]

will gracefully stop a running container, while

docker start [container_name]

will restart a stopped container.

To remove a container entirely, use the command


docker rm [container_name]

Additionally, you can use the docker ps command to list all running containers, and docker ps -a to see all
containers, including those that are stopped.
This gives you full visibility and control over your containers.

RESULT:

Thus a container is created and executed in a docker successfully.

You might also like