Cloud Computing Lab Manual
Cloud Computing Lab Manual
Manual
1. Introduction to cloud computing.
Cloud computing is a general term for the delivery of hosted services over the internet.
Cloud computing enables companies to consume a compute resource, such as a virtual machine
(VM), storage or an application, as a utility -- just like electricity -- rather than having to build and
maintain computing infrastructures in house.
2.
Next, fill in the form as follows to match this screen, then click Create:
Once the wizard finishes, click Go To My App, Start Tour, and follow along for a quick overview
of your app's user interface.
Tell Me More
The app you just created is very simple -- or is it? Look closely around the screen to see all of the
functionality available by default to your Warehouse app.
Every object in Force.com automatically has an attached "feed," called Chatter, that lets
authorized app users socialize about and collaborate on the object. Using Chatter, users can
post updates in an object's feed, comment on posts, and follow (subscribe to) the feed to get
pushed updates when they happen. For example, on a Merchandise record, one user might
post a question about the record, to which followers and other users can comment in reply.
Every DE org has a secure Chat window that lets users interact with one another.
You can also manage activities related to a record from the Open Activities and Activity
History related lists. Activities include tasks to perform (e.g., making phone calls or sending
email), calendar events, and requested meetings.
Every app has full-text search functionality for all text fields of an object and Chatter feeds.
Every DE org has a recycle bin that you can use to view and restore deleted records.
Every record in Force.com has an "owner," which serves as the basis for a powerful security
system that supports ownership-based record sharing scenarios.
3. Creating an Application in SalesForce.com using Apex programming Language.
Apex Code is designed explicitly for expressing business logic and manipulating data, rather than
generically supporting other programming tasks such as user interfaces and interaction. Apex Code
is therefore conceptually closer to the stored procedure languages common in traditional database
environments, such as PL/SQL and Transact-SQL. But unlike those languages, which due to their
heritage can be terse and difficult to use, Apex Code uses a Java-like syntax, making it
straightforward for most developers to understand. And like Java, Apex Code is strongly typed,
meaning that the code is compiled by the developer before it is executed, and that variables must be
associated with specific object types during this compile process. Control structures are also Java-
like, with for/while loops and iterators borrowing that syntax directly.
trigger
blockDuplic
ates_tgr on
Lead
bulk(before
insert,
before
update) {
/*
*
begin by
building
a map
which
stores
the
(unique)
list of
leads
*
being
inserted
/updated
, using
email
address
as the
key.
*
/
Ma
p<String
, Lead>
leadMap
= new
Map<Stri
ng,
Lead>();
fo
r (Lead
lead :
System.T
rigger.n
ew)
{
if
(lead.Em
ail !=
null)
{ //
skip
null
emails
/
* for
inserts
OR
*
updates
where
the
email
address
is
changing
* check
to see
if the
email is
a
duplicat
e of
another
in
* this
batch,
if
unique,
add this
lead to
the
leadMap
*/
i
f
( System
.Trigger
.isInser
t ||
(Sys
tem.Trig
ger.isUp
date &&
le
ad.Email
!=
System.T
rigger.o
ldMap.ge
t(lead.I
d).Email
)) {
if
(leadMap
.contain
sKey(lea
d.Email)
) {
lead.Em
ail.addE
rror('An
other
new lead
has the
same
email
address.
');
}
else {
leadMap
.put(lea
d.Email,
lead);
}
}
/*
Using
the lead
map,
make a
single
database
query,
*
find all
the
leads in
the
database
that
have the
same
email
address
as
*
any of
the
leads
being
inserted
/updated
.
*
/
fo
r (Lead
lead :
[select
Email
from Lead
where
Email
IN :leadM
ap.KeySe
t()]) {
Lead
newLead =
leadMap.
get(lead
.Email);
newLe
r('A
lead
with
this
email
address
already
exists.'
);
}
}
In addition, no Apex Code trigger would be complete without test coverage, this is done using a
class with a special testing method, the test code does not commit records to the database and so can
be run over and over without modifying your database. Here is a sample test method to verify the
above code works.
with:
[[WebMethod]
public int Add(int x, int y)
{
return x + y;
}
[WebMethod]
public int Subtract(int x, int y)
{
return x - y;
}
[WebMethod]
public int Multiply(int x, int y)
{
return x * y;
}
[WebMethod]
public int Division(int x, int y)
{
return x / y;
}
Note that [WebMethod] tag allows the methods to be accessible to external clients. Now replace
the code:
[WebService(Namespace = "http://tempuri.org/")]
with:
[WebService(Namespace="http://tempuri.org/",
Description="A Simple Web Calculator Service",
Name="CalculatorWebService")]
The Description attribute gives external clients a brief description of the service; the Name attribute
lets external clients refer to the service as CalculatorWebService rather than Service.
Expand the tree Sites, then right click on Default Web Site, and choose Add Virtual Directory.
Enter WebService in the Alias field, and C:\Project7\Server in the Physical path field.
Click on the WebService folder and then switch IIS to Content View in order to see the
Service.asmx and the web.config files.
Since we’ve manually created the Virtual Directory WebService without the help of Visual Studio
testing mode, you should right click the WebService folder and choose Convert to Application
followed by clicking OK.
Now open your browser and goto http://localhost/WebService/Service.asmx, you should see a
screen similar to this:
Testing the Web Service on the Server Side
On the CalculatorWebService page, you could see four links to the Add, Division, Multiply,
and Subtract methods that we’ve implemented in C#; clicking on any of those links will take
you to a new page where you could test your methods.
Creating the ASP.NET Web Client
Launch Visual Studio, and then go to File / New / Web Site...
Choose ASP.NET Web Site as the template and name your project Client.
Edit your Default.aspx.cs source to add the method GetResult that takes as an input two number
strings and an integer function which corresponds to the four basic calculator operations we need.
private string GetResult(string firstNumber, string secondNumber, int function)
{
ServiceReference.CalculatorWebServiceSoapClient client =
new ServiceReference.CalculatorWebServiceSoapClient();
int a, b;
string result = null;
erra.Text = "";
errb.Text = "";
if (!int.TryParse(firstNumber, out a))
{
erra.Text = "Must be a valid 32-bit integer!";
return "";
}
try
{
switch (function)
{
case 0:
result = firstNumber + " + " + secondNumber +
" = " + client.Add(a, b);
break;
case 1:
result = firstNumber + " - " + secondNumber + " = "
+ client.Subtract(a, b);
break;
case 2:
result = firstNumber + " * " + secondNumber + " =
" + client.Multiply(a, b);
break;
case 3:
result = firstNumber + " / " +
secondNumber + " = " + client.Division(a, b);
break;
}
}
catch (Exception e)
{
LabelResult.ForeColor = System.Drawing.Color.Red;
result = "Cannot Divide by Zero!";
}
return result;
}
ServiceReference.CalculatorWebServiceSoapClient client =
new ServiceReference.CalculatorWebServiceSoapClient();
which allows the client object to access the web service methods. ServiceReference is the
namespace of the web service you chose earlier. CalculatorWebServiceSoapClient
establishes the SOAP connection with client (i.e. sends requests and receives responses in the form
of SOAP XML messages between the proxy server and the proxy client).
Finally, add the Submit Button event handler with the following code to access the GetResult
method you created earlier.
protected void btnSubmit_Click(object sender, EventArgs e)
{
LabelResult.ForeColor = System.Drawing.Color.Black;
LabelResult.Text = GetResult(TextBoxFirstNumber.Text,
TextBoxSecondNumber.Text,
DropDownList.SelectedIndex);
}
#7) In the Next step you need to specify a Key or a serial number of operating system. If you are
using trial version then that part can be skipped.
#8) Enter the name for the virtual machine and specify a path to the directory where you want to
create your virtual machine. It is recommended that the drive you’re selecting to install virtual
machine should have sufficient space.
#9) Specify an amount of disk space you want to allocate for a virtual machine. Allocate disk space
according to the size of software you are going to install on the virtual machine.
#10) On the next screen it will show configuration you selected for a virtual machine.
#11) It will allocate Hardware according to the default settings but you can change it by using
Customize Hardware button in the above screen.
You can specify what amount of RAM, a processor has to be allocated for a virtual machine. Do not
allocate complete RAM or complete Processor for a virtual machine. Also, do not allocate very less
RAM or processor. Leave default settings or allocate in such way that your application should be
able to run on the virtual machine. Else it will result in a slow virtual machine.
#12) Click on the Finish button to create the virtual machine at the specified location and with
specified resources.
If you have specified a valid file (.iso, .rar., .nrg) for the operating system it will take standard time
to complete operating system set up on the virtual machine and then it will be ready to use your
regular OS.
Notes:
If you didn’t specify any operating system while creating the virtual machine, later you can
install it just like we do for your laptop or desktop machines. We can use CD/DVD or USB
devices like Pen Drive or even set up a file on the disk to install the operating system in the
VM.
If your CD/DVD drive is not working then also it is very simple to install the operating
system. Go to VM -> Settings – > select CD/DVD -> in the right half select radio button for
‘use ISO image from’ and specify the path on your hard disk where the .iso file is placed.
This location will be treated as CD/DVD drive of your machine.
Make sure correct boot order is specified in BIOS so installation will start while getting VM
power on (in this case guest OS is not installed).
Option #2. Using USB devices: When USB devices are plugged in those are default available for
host operating system and won’t show in the VM. To make them available in VM do:
VM -> Removable devices -> mouse hover USB device and click Connect (Disconnect from the
host). Now USB device will be available in the Guest OS (VM) but won’t be available in the host
machine. Do reverse action to make it available in the host machine.
Re-login as hduser_
Select Stable
Once download is complete, navigate to the directory containing the tar file
With
Next enter
sudo chmod +x /etc/profile.d/hadoop.sh
Exit the Terminal and restart again
Type echo $HADOOP_HOME. To verify the path
Step 7) Before we start Hadoop for the first time, format HDFS using below command
$HADOOP_HOME/bin/hdfs namenode -format
$HADOOP_HOME/sbin/start-yarn.sh
Using 'jps' tool/command, verify whether all the Hadoop related processes are running or not.
If Hadoop has started successfully then output of jps should show NameNode, NodeManager,
ResourceManager, SecondaryNameNode, DataNode.
Step 9) Stopping Hadoop
$HADOOP_HOME/sbin/stop-dfs.sh
$HADOOP_HOME/sbin/stop-yarn.sh
Explanation
The program consist of 3 classes:
Driver class (Public void static main- the entry point)
Map class which extends public class
Mapper<KEYIN,VALUEIN,KEYOUT,VALUEOUT> and implements the Map function.
Reduce class which extends public class
Reducer<KEYIN,VALUEIN,KEYOUT,VALUEOUT> and implements the Reduce
function.
Step 6. Make Jar File
Right Click on Project> Export> Select export destination as Jar File > next> Finish
Cloud Computing Case Study of Amazon Web Services for Ecommerce Websites
ECommerce enterprises are the major beneficiaries with the advent of Cloud Computing. These
businesses, mostly attract visitors and sales online. More than 60% of its resources used before
sales are available online. Other aspects of eCommerce is sourcing products from vendors, product
delivery to customers and managing the supply chain is offline. A typical eCommerce business
relies heavily on virtual transactions. These activities prompt the enterprise to build attractive and
heavily featured websites with database, high end applications (both web and mobile), high storage
and computing capacity for fast performance, 24 X 7 availability, accessibility on every mobile
device.
Cloud computing is the advanced form of on premise hosting and are designed to manage the
feature deficient in eCommerce sites. There are typical problem for eCommerce businesses like
website break down during peak hours or surge in traffic, sudden need for space due to increase in
product portfolio and built in apps, ERP (like inventory management or Customer Relationship
Management). Cloud Computing has auto scaling, load balancing features which automatically
adjusts with the sudden need for increased computing and increased storage thereby allowing
smooth functioning of the online resources.
Amazon Web Services is the leading cloud computing company and offer computing services for
eCommerce enterprises. We have discussed one of the cases to understand the benefits of using
Cloud Infrastructure and services.
Ice.com , an eCommerce enterprise into retailing jewelry migrated to Amazon Web Services Cloud.
It is based out of New York, United States. ICE was growing fast with its increasing need for IT
hardware and ,so, hosted on two servers located in Montreal, Canada. They were bearing a monthly
expense of $26,000 for managing the physical servers. Besides, they were running a risk for no
disaster recovery plan for the resources and also had plans to introduce many new web store
application, an enterprise resource planning (ERP), a content management system ( CMS) and a
business intelligence ( BI) platform for the smooth functioning of the business. ICE hired an AWS
partner for system development, remote administration, automation, deployment and scalability of
web applications on AWS Infrastructure.
AWS sets up ICE eCommerce sites, ERP, CMS, BI keeping in compliance with the PCI (Payment
Card Industry) standard and Cloud security best practices. ICE used all Amazon features like
Amazon EC2 (Elastic Cloud Computing), Amazon ELB (Elastic Load Balancing) and Amazon
EBS (Elastic Block Storage). Implemented Amazon VPC (Virtual Private Cloud ) to host the ERP
and BI platforms. Amazon S3 (Simple Storage Service) for storing html and static pages. AWS
IAM (Identity and Access Management) allowing secured authorized access to staffs and availing
instances at multiple zones like East and West US coast with a proper disaster recovery plan.
ICE reaped the benefit in fastest new application migration due to the presence of Cloud
Infrastructure, otherwise, which have not been possible. Overhead staff expense was reduced to half
wherein one database administrator and one IT professional replaced two administrators and three
IT professionals. Moreover, AWS helped ICE to save $250000 annually for migrating to Cloud
Infrastructure.