[go: up one dir, main page]

0% found this document useful (0 votes)
50 views90 pages

Chapter 1

Distributed computing involves performing computing tasks across a network of independent computers. Mei-Ling Liu's document discusses distributed computing and provides examples of distributed systems like networks of workstations, the Internet, and intranets. It also summarizes statistics that demonstrate the power and growth of the Internet as a large-scale distributed system.

Uploaded by

Marina
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)
50 views90 pages

Chapter 1

Distributed computing involves performing computing tasks across a network of independent computers. Mei-Ling Liu's document discusses distributed computing and provides examples of distributed systems like networks of workstations, the Internet, and intranets. It also summarizes statistics that demonstrate the power and growth of the Internet as a large-scale distributed system.

Uploaded by

Marina
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
You are on page 1/ 90

Distributed computing

Mei-Ling Liu

Distributed Computing
09/30/22 Introduction, M. Liu 1
Distributed system, distributed computing
 Early computing was performed on a single
processor. Uni-processor computing can be
called centralized computing.
 A distributed system is a collection of
independent computers, interconnected via a
network, capable of collaborating on a task.
 Distributed computing is computing
performed in a distributed system.

Distributed Computing Introduction,


09/30/22 2
M. Liu
Distributed Systems
w ork
s tatio n s a lo c al n etw o r k

T h e I n ter n et

a n etw o r k h o s t

Distributed Computing Introduction,


09/30/22 3
M. Liu
Examples of Distributed systems
 Network of workstations (NOW): a group of
networked personal workstations connected to
one or more server machines.
 The Internet
 An intranet: a network of computers and
workstations within an organization,
segregated from the Internet via a protective
device (a firewall).

Distributed Computing Introduction,


09/30/22 4
M. Liu
Example of a large-scale distributed system
– eBay (Source: Los Angeles Times.)

Distributed Computing Introduction,


09/30/22 5
M. Liu
An example small-scale distributed system
(Source: Los Angeles Times.)

Distributed Computing Introduction,


09/30/22 6
M. Liu
Computers in a Distributed System

 Workstations: computers used by end-users to


perform computing
 Server machines: computers which provide
resources and services
 Personal Assistance Devices: handheld
computers connected to the system via a
wireless communication link.

Distributed Computing Introduction,


09/30/22 7
M. Liu
The power of the Internet
(Source: the Usability Professional Association’s site.)

 60 million American households use


computers.(The New York Times, 5/28/98)
 The number of computer users in the
workplace has increased from 600,000 in
1976 to 80 million today. (San Francisco
Examiner, 3/29/98)
 84% of Internet users say that the Web is
indispensable. Nearly the same
percentage find e-mail indispensable.
85% use the Internet every day. (GVU,
1997)
Distributed Computing Introduction,
09/30/22 8
M. Liu
The Power of the Internet – 2
(Source: www.cisco.com)

 BACKBONE CAPACITY: The capacity of the Internet


backbone to carry information is doubling every 100 days. (
U.S. Internet Council, Apr. 1999).
 DATA TRAFFIC SURPASSING VOICE: Voice traffic is
growing at 10% per year or less, while data traffic is
conservatively estimated to be growing at 125% per year,
meaning voice will be less than 1% of the total traffic by
2007. (Technology Futures, Inc March 2000).
 DOMAIN NAMES: There are 12,844,877 unique domain
names (e.g. Cisco.com) registered worldwide, with 428,023
new domain names registered each week. (
NetNames Statistics 12/28/1999).

Distributed Computing Introduction,


09/30/22 9
M. Liu
The Power of the Internet – 3
(Source: www.cisco.com)

 DOMAIN NAMES: There are 12,844,877 unique domain


names (e.g. Cisco.com) registered worldwide, with 428,023
new domain names registered each week. (
NetNames Statistics 12/28/1999).
 HOST COMPUTERS: In July 1999 there were 56.2 million
"host" computers supporting web pages. In July 1997 there
were 19.5 million host computers, with 3.2 million hosts in
July 1994, and a mere 80,000 in July 1989. (
Internet Software Consortium – Internet Domain Survey).
 TOTAL AMOUNT OF DATA: 1,570,000,000 pages,
29,400,000,000,000 bytes of text, 353,000,000 images, and
5,880,000,000,000 bytes of image data. (
The Censorware Project, Jan. 26, 1999).

Distributed Computing Introduction,


09/30/22 10
M. Liu
The Power of the Internet – 4
(Source: www.cisco.com)

 EMAIL VOLUME: Average U.S. consumer will receive


1,600 commercial email messages in 2005, up from 40 in
1999, while non-marketing and personal correspondence will
more than double from approximately 1,750 emails per year
in 1999 to almost 4,000 in 2005 (Jupiter Communications,
May 2000).
 159 million computers in the U.S., 135 million in EU, and
116 million in Asia Pacific (as of April 2000).
 WEB HITS/DAY: U.S. web pages averaged one billion hits
per day (aggregate) in October 1999. (eMarketer/Media
Metrix, Nov. 1999).

Distributed Computing Introduction,


09/30/22 11
M. Liu
NUMBER OF AMERICANS ONLINE –
HISTORICAL
(Source: www.cisco.com)

 1993 – 90,000 (U.S. Internet Council, Apr. 1999).


 1997 – 19 million (Stratis Group, Apr. 1999).
 1998 – 68 million in 1998. (Strategis Group, Nov. 1999).
 1998 – 84 million from home or work (Stratis Group, Apr.
1999).
 1998 – 37 million DAILY (Stratis Group, Apr. 1999).
 1999, Nov. – 118.4 million (Cyberatlas/Nielsen Net Ratings,
Dec. 1999).
 1999, Nov. – 74 million actually went online
(Cyberatlas/Nielsen Net Ratings, Dec. 1999).

Distributed Computing Introduction,


09/30/22 12
M. Liu
PERCENTAGE OF AMERICANS ONLINE
(Source: www.cisco.com)

 1998 – 28% (IDC, Oct. 1999).


 1998 – 42% of the U.S. adult population.
(Stratis Group, Apr. 1999)
 2003 – 62% (IDC, Oct. 1999).
 2003 – 67% (Yankee Group, 1999).
 2005 – 91% (Strategy Analytics, Dec. 1999).

Distributed Computing Introduction,


09/30/22 13
M. Liu
The Power of the Internet – 5
(Source: www.cisco.com)

 NEW USERS Q1 2000: More than 5 million


Americans joined the online world in the first quarter
of 2000, which averages to roughly 55,000 new
users each day, 2,289 new users each hour, or 38
new users each minute. (CyberAtlas /
Telecommunications Reports International, May
2000).
 US INTERNET USAGE: Average US Internet user
went online 18 sessions, spent a total of 9 hours, 5
minutes and 24 seconds online and visited 10 unique
sites per month. (Nielsen NetRatings, June 2000).

Distributed Computing Introduction,


09/30/22 14
M. Liu
The Power of the Internet – 6
(Source: www.cisco.com)

 E-MAIL 1998: The U.S. Postal Service delivered 101 billion


pieces of paper mail in 1998. Estimates for e-mail messages
sent in 1998 range from 618 billion to 4 trillion. (U.S.
Internet Council, Apr. 1999).
 E-MAIL 1999: There are 270 million e-mailboxes in the U.S.
-- roughly 2.5 per user. (eMarketer/ Messaging Online, Nov.
1999).
 HOURS ONLINE (Veronis, Suhler & Associates, Nov.
1999):
1997 – 28 hours per capita
1998 – 74 hours per capita
2003 – 192 hours per capita

Distributed Computing Introduction,


09/30/22 15
M. Liu
ONLINE WORLDWIDE
(Source: www.cisco.com)

 1998 – 95.43 million people. (eMarketer eStats


1999).
 1998, Dec. – 144 million (IDC, Dec. 1999).
 1999, Dec. – 240 million (IDC, Dec. 1999).
 2002 – over 490 million (Computer Industry
Almanac, Nov. 1999).
 2005 – over 765 million (Computer Industry
Almanac, Nov. 1999
 U.S. -- 136 million (36% of world’s total)
(eMarketer, May 2000) – followed by Japan (27 M),
UK (18M), and China (16 M).
Distributed Computing Introduction,
09/30/22 16
M. Liu
Wireless access to the Internet
(Source: www.cisco.com)

 U.S. WIRELESS USERS: 61.5 million Americans will be


using wireless devices to access the Internet in 2003, up from
7.4 million in the US today (728% increase). (IDC Research,
Feb. 2000).
 MOBILE DATA: Almost 80% of the US Internet population
will access data from mobile phones in a year’s time, up from
the current figure of 3%. (Corechange, Inc & Cap Gemini
USA, Apr. 2000).

Distributed Computing Introduction,


09/30/22 17
M. Liu
“The network really is the computer.”
Tim O’Reilly, in an address at 6/2000 Java One:
“By now, it's a truism that the Internet runs on open source. Bind, the
Berkeley Internet Name Daemon, is the single most mission critical
program on the Internet, followed closely by Sendmail and Apache, open
source servers for two of the Internet's most widely used application
protocols, SMTP and HTTP.”
Early “killer apps”:
- usenet: distributed bulletin board
- email
- talk
Recent “killer apps”:
- the web
- collaborative computing

Distributed Computing Introduction,


09/30/22 18
M. Liu
Centralized vs. Distributed Computing

term in al
m ain fram e c o m pu ter
w o rk s tatio n

n etw o rk link

n etw o rk h o s t
ce n tralize d com pu tin g
dis tribu te d com pu tin g

Distributed Computing Introduction,


09/30/22 19
M. Liu
Monolithic mainframe applications vs. distributed
applicationsbased on http://www.inprise.com/visibroker/papers/distributed/wp.html

 The monolithic mainframe application architecture:


 Separate, single-function applications, such as order-entry or billing
 Applications cannot share data or other resources
 Developers must create multiple instances of the same functionality
(service).
 Proprietary (user) interfaces
 The distributed application architecture:
 Integrated applications
 Applications can share resources
 A single instance of functionality (service) can be reused.
 Common user interfaces

Distributed Computing Introduction,


09/30/22 20
M. Liu
Evolution of pardigms
 Client-server: Socket API, remote method invocation
 Distributed objects
 Object broker: CORBA
 Network service: Jini
 Object space: JavaSpaces
 Mobile agents
 Message oriented middleware (MOM): Java Message Service
 Collaborative applications

Distributed Computing Introduction,


09/30/22 21
M. Liu
Cooperative distributed computing projects
Cooperative distributed computing projects
(also called distributed computing in some
literature): these are projects that parcel out
large-scale computing to workstations, often
making use of surplus CPU cycles. Example:
seti@home: project to scan data retrieved by a
radio telescope to search for radio signals
from another world.

Distributed Computing Introduction,


09/30/22 22
M. Liu
Why distributed computing?
 Economics: distributed systems allow the
pooling of resources, including CPU cycles,
data storage, input/output devices, and
services.
 Reliability: a distributed system allow
replication of resources and/or services, thus
reducing service outage due to failures.
 The Internet has become a universal platform
for distributed computing.
Distributed Computing Introduction,
09/30/22 23
M. Liu
The Weaknesses and Strengths of Distributed
Computing
In any form of computing, there is always a
tradeoff in advantages and disadvantages
Some of the reasons for the popularity of
distributed computing :
 The affordability of computers and
availability of network access
 Resource sharing
 Scalability
 Fault Tolerance

Distributed Computing Introduction,


09/30/22 24
M. Liu
The Weaknesses and Strengths of
Distributed Computing
The disadvantages of distributed computing:
 Multiple Points of Failures: the failure of
one or more participating computers, or one
or more network links, can spell trouble.
 Security Concerns: In a distributed system,
there are more opportunities for unauthorized
attack.

Distributed Computing Introduction,


09/30/22 25
M. Liu
Introductory Basics

M. L. Liu

Distributed Computing
09/30/22 Introduction, M. Liu 26
Basics in three areas
Some of the notations and concepts from
these areas will be employed from time to
time in the presentations for this course:
 Software engineering
 Operating systems

 Networks.

Distributed Computing Introduction,


09/30/22 27
M. Liu
Software Engineering Basics

Distributed Computing
09/30/22 Introduction, M. Liu 28
Procedural versus Object-oriented Programming

In building network applications, there are two


main classes of programming languages:
procedural language and object-oriented
language.
 Procedural languages, with the C language being
the primary example, use procedures (functions) to
break down the complexity of the tasks that an
application entails.
 Object-oriented languages, exemplified by Java, use
objects to encapsulate the details. Each object
simulates an object in real life, carrying state data as
well as behaviors. State data are represented as
instance data. Behaviors are represented as
methods.

Distributed Computing Introduction,


09/30/22 29
M. Liu
UML Class Diagram Notations

B a s ic U M L C la s s D ia g ra m N o ta tio n s
A cla s s /in t e rf a ce is re pre s e n t e d a s fo llo ws :

in t e rf a ce /cla s s
nam e
a t tribu te s
a t tribu t e s a re s t a tic/ in s ta n ce v a ria ble s /co n s t a n t s
(n a m e : t y pe )

o pe ra t io n s
o pe ra tio n s a re s ta t ic o r in s t a n ce m e th o ds .
(m e th o d n a m e s )

NOTE: The shape, the style of the line (dashed or


solid), the direction of the arrow, and the shape of the
arrowheads (pointed, hollow, or solid) are significant.

Distributed Computing Introduction,


09/30/22 30
M. Liu
UML Class Diagram Notations

clas s A clas s B
clas s B de pe n ds o n (u s e s )
a ttribu te s a ttribu te s
clas s A

o pe ra tion s o pe ra tio n s

clas s C
clas s C im ple m e n ts
a ttribu te s
J av a in t e rface s o m e I n te rfa ce
s om e I n te rfa ce
o pe ra tion s

Distributed Computing Introduction,


09/30/22 31
M. Liu
UML Class Diagram Notations

in te rfa ce D cla s s E
cla s s E im ple m e n ts
a ttribu te s a ttribu te s
pro g ra m m e r-pro v ide d in te rfa ce D

o pe ra tio n s o pe ra tio n s

in te rfa ce F cla s s G
cla s s G in h e rits fro m cla s s F
a ttribu te s a ttribu te s

o pe ra tio n s o pe ra tio n s

Distributed Computing Introduction,


09/30/22 32
M. Liu
The Architecture of Distributed Applications

Pre s e n tation
A pplication (B u s in e s s ) logic

S e rvice s

Distributed Computing Introduction,


09/30/22 33
M. Liu
Operating Systems Basics

Distributed Computing
09/30/22 Introduction, M. Liu 34
Operating systems basics
 A process consists of an executing program,
its current values, state information, and the
resources used by the operating system to
manage its execution.
 A program is an artifact constructed by a
software developer; a process is a dynamic
entity which exists only when a program is
run.

Distributed Computing Introduction,


09/30/22 35
M. Liu
Process State Transition Diagram

te rm in ate d
s tart
queued
exit
dis p atc h ru n n in g
re ady

event c om pletion w aiting


for event
block e d

S im plife d fin ite s tate diagram for a proce s s 's life tim e
Distributed Computing Introduction,
09/30/22 36
M. Liu
Java processes
 There are three types of Java program: applications,
applets, and servlets, all are written as a class.
 A Java application program has a main method, and is
run as an independent(standalone) process.
 An applet does not have a main method, and is run
using a browser or the appletviewer.
 A servlet does not have a main method, and is run in the
context of a web server.
 A Java program is compiled into bytecode, a
universal object code. When run, the bytecode is
interpreted by the Java Virtual Machine (JVM).
Distributed Computing Introduction,
09/30/22 37
M. Liu
Three Types of Java programs
 Applications
a program whose byte code can be run on any system which
has a Java Virtual Machine. An application may be
standalone (monolithic) or distributed (if it interacts with
another process).
 Applets
A program whose byte code is downloaded from a remote
machine and is run in the browser’s Java Virtual Machine.
 Servlets
A program whose byte code resides on a remote machine
and is run at the request of an HTTP client (a browser).

Distributed Computing Introduction,


09/30/22 38
M. Liu
Three Types of Java programs
A standal o ne J ava appl i c ati o n i s r un o n a l o c al m ac hi ne
co m pu te r

J a v a o bje ct

Ja v a V irtu a l M a ch in e

An appl e t i s an o bje c t do w nl o ade d (tr ansfe r r e d) fr o m a r e m o te m ac hi ne ,


the n r un o n a l o c al m ac hi ne .

a n a pple t J a v a o bje ct

J a v a V irtu a l M a ch in e

A se r vl e t i s an o bje c t that r uns o n a r e m o te m ac hi ne and


i nte r ac ts w i th a l o c al pr o g r am us i ng a r e que st-r e spo nse pr o to c o l

a s e rv le t
re qu e s t a pro ce s s

re s po n s e

Distributed Computing Introduction,


09/30/22 39
M. Liu
A sample Java application
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* A s a m ple o f a s im ple J a v a a pplica tio n .
* M . L iu 1 /8 /0 2
******************************************************/

im po rt ja v a .io . * ;

clas s M y Pro g ra m {

pu blic s ta tic v o id m a in (S trin g [ ] a rg s )


th ro ws I O Ex ce ptio n {

B u f fe re dR e a de r k e y bo a rd = n e w
B u ffe re dR e a de r(n e w I n pu tS tre a m R e a de r(S y s te m .in ));
S trin g th e Na m e ;
S y s te m .o u t.prin tln (" W h a t is y o u r n a m e ? " );
th e Na m e = k e y bo a rd.re a dL in e ( );
S y s te m .o u t.prin t (" H e llo " + th e Na m e );
S y s te m .o u t.prin tln (" - we lco m e to C S C 3 6 9 .\n " );

} // e n d m a in

} //e n d cla s s

Distributed Computing Introduction,


09/30/22 40
M. Liu
A Sample Java Applet

/** ** ** ** ** * * * ** ** ** ** ** ** ** * *** * ** ** ** * * * * * ** * * ** * *
* A s a m ple o f a s im ple apple t.
* M . L iu 1 /8 /0 2
** ** ** ** ** * * * ** ** ** ** ** ** ** * *** * ** ** ** * * * * * ** * * ** * * /
< !-- A we b pa g e wh ich , wh e n bro ws e d, will ru n >
im po rt jav a.a pple t.A pple t; < !-- th e M yA pple t apple t>
im po rt jav a.a wt.*; < !-- M . L iu 1 /8 /0 2 >

pu blic clas s M y A pple t e x te n ds A pple t{ < title > S a m ple A pple t < /title >
< h r>
pu blic vo id pa in t(G raph ics g ){
s e tB a ck g rou n d(C olo r.blu e ); < apple t co de = " M yA pple t.cla s s " width = 5 00 h e igh t= 50 0>
< /apple t>
Fon t C la u de = n e w Fon t(" A rial" , Fon t.B O L D , 40 );
g .s e tFo n t (C la u de ); < h r>
g .s e tC o lor(C o lor.y e llo w); < a h re f= " H e llo .ja v a " > Th e s o u rce .< /a>
g .dra wS trin g (" H e llo W o rld!" , 1 0 0, 1 00 );
} // e n d pa in t

} //e n d clas s

Distributed Computing Introduction,


09/30/22 41
M. Liu
A Sample Java Servlet
/** * ** ** * *** *** *** ** *** **** ** ** * *** *** * ** * ** ** **** *** * * *
* A s am ple of a s im ple J ava s e rvle t.
* M . L iu 1/8/02
** * ** ** * *** *** *** ** *** **** ** ** * *** *** * ** * ** ** **** *** * * /
im po rt ja v a.io. *;
im po rt ja v a.t e x t. * ;
im po rt ja v a.u til.* ;
im po rt ja v ax.s e rvle t.* ;
im po rt ja v ax.s e rvle t.h ttp. *;

pu blic clas s M yS e rv le t e xt e n ds H ttpS e rv le t {

pu blic v o id doG e t ( Ht tpS e rv le tR e qu e s t re qu e s t,


Ht tpS e rv le tR e s pon s e re s po n s e )
th ro ws S e rv le tExce pt io n , I O Ex ce ption {

Prin tW rite r ou t ;
S trin g title = " M y S e rv le t O u t pu t" ;
// s e t co n te n t t ype a n d o th e r re s pon s e h e ade r
// fie lds firs t
re s po n s e .s e tC on te n tType (" te x t/h tm l" );
// th e n writ e th e da ta of t h e re s po n s e
ou t = re s pon s e .ge tW rite r();
ou t.prin tln (" < HTM L > < H EA D > < TI TL E> " );
ou t.prin tln (tit le );
ou t.prin tln (" < /TI TL E> < /H EA D > < B O D Y > " ) ;
ou t.prin tln (" < H1 > " + title + " < /H1 > " );
ou t.prin tln (" < P> H e llo W o rld!" );
ou t.prin tln (" < /B O D Y > < /HTM L > " ) ;
ou t.clos e ();
} //e n d doG e t

} //e n d clas s

Distributed Computing Introduction,


09/30/22 42
M. Liu
Concurrent Processing
On modern day operating systems, multiple processes
appear to be executing concurrently on a machine by
timesharing resources.

Proce sse s
P1
P2
P3
P4
tim e
T im es haring of a res ourc e
Distributed Computing Introduction,
09/30/22 43
M. Liu
Concurrent processing within a process

It is often useful for a process to have parallel threads of


execution, each of which timeshare the system resources in
much the same way as concurrent processes.

A pa re n t pro ce s s m a y s pa wn ch ild pro ce s s e s . A pro ce s s m a y s pa wn ch ild th re a ds


a p r o c es s
p a r en t p r o c es s
m ain th r ead

c h ild th r ead 1

c h ild th r ead 2
c h ild p r o c es s es

C o n cu rre n t pro ce s s in g wit h in a pro ce s s


Distributed Computing Introduction,
09/30/22 44
M. Liu
Java threads
 The Java Virtual Machine allows an application to have multiple
threads of execution running concurrently.
 Java provides a Thread class:
public class Thread
extends Object
implements Runnable
 When a Java Virtual Machine starts up, there is usually a single thread
(which typically calls the method named main of some designated
class). The Java Virtual Machine continues to execute threads until
either of the following occurs:
 The exit method of class Runtime has been called and the security
manager has permitted the exit operation to take place.
 All threads have ter,omated, either by returning from the call to the run
method or by throwing an exception that propagates beyond the run
method.

Distributed Computing Introduction,


09/30/22 45
M. Liu
Two ways to create a new thread of execution

 Using a subclass of the Thread class


 Using a class that implements the Runnable
interface

Distributed Computing Introduction,


09/30/22 46
M. Liu
Create a class that is a subclass of the Thread class

Declare a class to be a subclass of Thread. This subclass


should override the run method of class Thread. An
instance of the subclass can then be allocated and started:
T h read
...

run( )
s le e p ( )
s ta r t( )

R u nT h reads
S o m eT h read
A J ava m yID
a p p lic a tio n
illu s tr a tin g th e
u s e o f T h r ea d run( )
c la s s
Distributed Computing Introduction,
09/30/22 47
M. Liu
Create a class that is a subclass of the Thread class

im po rt S o m e Th re a d;
pu blic cla s s S o m e Th re a d e x te n ds Th re a d {
pu blic cla s s R u n Th re a ds
in t m y I D ;
{
pu blic s ta tic v o id m a in (S trin g [] a rg s )
S o m e Th re a d(in t id) {
{
th is .m y I D = id;
S o m e Th re a d p1 = n e w S o m e Th re a d(1 );
}
p1 .s ta rt ();
pu blic v o id ru n ( ) {
S o m e Th re a d p2 = n e w S o m e Th re a d(2 );
in t i;
p2 .s ta rt ();
f or (i = 1 ; i < 1 1 ; i+ + )
S y s te m .o u t.prin tln (" Th re a d" + m y I D + " : " + i);
S o m e Th re a d p3 = n e w S o m e Th re a d(3 );
}
p3 .s ta rt ();
} //e n d cla s s S o m e Th re a d
}
} // e n d cla s s R u n Th re a ds

Distributed Computing Introduction,


09/30/22 48
M. Liu
Java Threads-2
The other way to create a thread is to declare a class that
implements the Runnable interface. That class then implements
the run method. An instance of the class can then be allocated,
passed as an argument when creating Thread, and started.
T h r ead
...

run( )
R u n T h r ead s 2
s le ep ( )
A J av a s tar t( )
ap p lic atio n
illu s tr atin g th e
u s e o f th e
R u n n ab le
in ter f ac e S o m eT h r ead 2
m yID R u n n ab le

run( )

Distributed Computing Introduction,


09/30/22 49
M. Liu
Create a class that implements the Runnable interface

class S om e Th re ad2 im ple m e n ts R u n n able {


pu blic class R u n Th re ads2
in t m yID ;
{
pu blic static void m ain (S tring[] args )
S om e Th re ad2(in t id) {
{
th is.m yID = id;
Thre ad p1 = n e w Th re ad(n e w S om e Th re ad2(1));
}
p1.start();
pu blic void ru n () {
Thre ad p2 = n e w Th re ad(n e w S om e Th re ad2(2));
in t i;
p2.start();
for (i = 1; i < 11; i++)
S yste m .ou t.prin tln (" Th re ad" + m yID + " : " + i);
Thre ad p3 = n e w Th re ad(n e w S om e Th re ad2(3));
}
p3.start();
} //e n d class S om e Th re ad
}
}

Distributed Computing Introduction,


09/30/22 50
M. Liu
Program samples
 RunThreads.java
 SomeThread.java
 RunThreads2.java
 SomeThread2.java

Distributed Computing Introduction,


09/30/22 51
M. Liu
Thread-safe Programming
 When two threads independently access and update
the same data object, such as a counter, as part of
their code, the updating needs to be synchronized.
(See next slide.)
 Because the threads are executed concurrently, it is
possible for one of the updates to be overwritten by
the other due to the sequencing of the two sets of
machine instructions executed in behalf of the two
threads.
 To protect against the possibility, a synchronized
method can be used to provide mutual exclusion.

Distributed Computing Introduction,


09/30/22 52
M. Liu
Race Condition
tim e

fe tch va lu e in co u n te r a n d lo a d in to a re g iste r fe tch va lu e in co u n te r a n d lo a d in to a re g iste r

in cre me n t va lu e in re g iste r fe tch va lu e in co u n te r a n d lo a d in to a re g iste r

sto re va lu e in re g iste r to co u n te r in cre m e n t va lu e in re g iste r

in cre m e n t va lu e in re g is te r
fe tch va lu e in co u n te r a n d lo a d in to a re g iste r

in cre m e n t va lu e in re g is te r sto re va lu e in reg iste r to co u n te r

s to re va lu e in re g is te r to co u n te r s to re va lu e in re g is te r to co u n te r

This e xe c utio n re sults in the This e xe c utio n re s ults in the


value 2 in the c o unte r value 1 in the c o unte r

in s tru c tio n ex ec u ted in c o n c u r ren t p ro c es s o r th read 1


in s tr u c tio n ex ec u ted in c o n c u rr en t p ro c es s o r th read 2

Distributed Computing Introduction,


09/30/22 53
M. Liu
Synchronized method in a thread
cla s s S o m e Th re a d3 im ple m e n ts R u n n a ble {
s ta tic in t co u n t= 0 ;

S o m e Th re a d3 () {
s u pe r();
}

pu blic v o id ru n () {
u pda te ( );
}

s ta tic pu blic s y n ch ro n ize d v o id u pda te ( ){


in t m y C ou n t = co u n t;
m y C o u n t+ + ;
co u n t = m y C o u n t ;
S y s te m .o u t.prin tln (" co u n t= " + co u n t+
" ; th re a d co u n t= " + Th re a d.a ctiv e C o u n t ( ));
}
}

Distributed Computing Introduction,


09/30/22 54
M. Liu
Network Basics

Distributed Computing Introduction,


09/30/22 55
M. Liu
Network standards and protocols
 On public networks such as the Internet, it is
necessary for a common set of rules to be
specified for the exchange of data.
 Such rules, called protocols, specify such
matters as the formatting and semantics of
data, flow control, error correction.
 Software can share data over the network
using network software which supports a
common set of protocols.
Distributed Computing Introduction,
09/30/22 56
M. Liu
Protocols
 In the context of communications, a protocol is a set of
rules that must be observed by the participants.
 In communications involving computers,
protocols must be formally defined and precisely
implemented. For each protocol, there must be
rules that specify the followings:
 How is the data exchanged encoded?
 How are events (sending , receiving) synchronized
so that the participants can send and receive in a
coordinated order?
 The specification of a protocol does not dictate how the
rules are to be implemented.
Distributed Computing Introduction,
09/30/22 57
M. Liu
The network architecture

 Network hardware transfers electronic signals,which


represent a bit stream, between two devices.
 Modern day network applications require an application
programming interface (API) which masks the underlying
complexities of data transmission.
 A layered network architecture allows the functionalities
needed to mask the complexities to be provided
incrementally, layer by layer.
 Actual implementation of the functionalities may not be
clearly divided by layer.

Distributed Computing Introduction,


09/30/22 58
M. Liu
The OSI seven-layer network architecture
ap p lic atio n lay er ap p lic atio n layer

pres en tatio n layer pres en tation lay er

s es s io n lay er s es s io n lay er

tran s p o rt lay er trans p ort lay er

n etw o rk lay er n etw o rk lay er

d ata lin k lay er d ata lin k lay er

ph y s ic al lay er ph y s ic al lay er

Distributed Computing Introduction,


09/30/22 59
M. Liu
Network Architecture
The division of the layers is conceptual: the
implementation of the functionalities need
not be clearly divided as such in the
hardware and software that implements the
architecture.
The conceptual division serves at least two
useful purposes :
1. Systematic specification of protocols
it allows protocols to be specified systematically
2. Conceptual Data Flow: it allows programs to be
written in terms of logical data flow.
Distributed Computing Introduction,
09/30/22 60
M. Liu
The TCP/IP Protocol Suite
 The Transmission Control Protocol/Internet Protocol suite is a set of
network protocols which supports a four-layer network architecture.
 It is currently the protocol suite employed on the Internet.

Applic ation layer Applic ation layer

T rans port layer T rans port layer

Internet layer Internet layer

P hys ic al layer P hys ic al layer

Th e In te rn e t n e twork arch ite ctu re

Distributed Computing Introduction,


09/30/22 61
M. Liu
The TCP/IP Protocol Suite -2
 The Internet layer implements the Internet
Protocol, which provides the functionalities
for allowing data to be transmitted between
any two hosts on the Internet.
 The Transport layer delivers the transmitted
data to a specific process running on an
Internet host.
 The Application layer supports the
programming interface used for building a
program.
Distributed Computing Introduction,
09/30/22 62
M. Liu
Network Resources

 Network resources are resources available to


the participants of a distributed computing
community.
 Network resources include hardware such as
computers and equipment, and software such
as processes, email mailboxes, files, web
documents.
 An important class of network resources is
network services such as the World Wide
Web and file transfer (FTP), which are provided
by specific processes running on computers.
Distributed Computing Introduction,
09/30/22 63
M. Liu
Identification of Network Resources

One of the key challenges in distributed


computing is the unique identification of
resources available on the network, such as e-
mail mailboxes, and web documents.
 Addressing an Internet Host
 Addressing a process running on a host

 Email Addresses

 Addressing web contents: URL

Distributed Computing Introduction,


09/30/22 64
M. Liu
Addressing an Internet Host

Distributed Computing Introduction,


09/30/22 65
M. Liu
The Internet Topology

an In tern et h o s t

s u b n ets

T h e In tern et b ac k b o n e

Th e I n te rn e t To polo g y M o de l

Distributed Computing Introduction,


09/30/22 66
M. Liu
The Internet Topology
 The internet consists of an hierarchy of
networks, interconnected via a network
backbone.
 Each network has a unique network address.
 Computers, or hosts, are connected to a
network. Each host has a unique ID within
its network.
 Each process running on a host is associated
with zero or more ports. A port is a logical
entity for data transmission.
Distributed Computing Introduction,
09/30/22 67
M. Liu
The Internet addressing scheme
 In IP version 4, each address is 32 bit long.
 The address space accommodates 232 (4.3 billion) addresses in total.
 Addresses are divided into 5 classes (A through E)

byte 0 byte 1 byte 2 byte 3


class A address 0
class B address 10
netw ork address
class C address 1 1 0
host portion
m ultcast address 1 1 1 0 m ulticast group
reserved address 1 1 1 1 0 reserved
reserved

Distributed Computing Introduction,


09/30/22 68
M. Liu
The Internet addressing scheme - 2

Subdiv iding the host portion of an Internet address:


byte 0 byte 1 byte 2 byte 3

cl ass B address 1 0 netw ork addres s hos t portion

A c lass A/C addre ss spac e c an


also be sim ilarly subdivide d..
W hic h po rtio n o f the ho st addre ss
is use d fo r the subne t ide ntific atio n
is de te rm ine d by a subne t m ask. s ubnet addres s loc al hos t addres s

Distributed Computing Introduction,


09/30/22 69
M. Liu
Example:
Suppose the dotted-decimal notation for a particular Internet
address is129.65.24.50. The 32-bit binary expansion of the
notation is as follows:
1 2 9 .6 5 .2 4 .5 0
10000001

01000001

0 0 0 11 0 0 0
0 0 11 0 0 1 0
Since the leading bit sequence is 10, the address is a Class B address.
Within the class, the network portion is identified by the remaining bits in
the first two bytes, that is, 00000101000001, and the host portion is the
values in the last two bytes, or 0001100000110010. For convenience, the
binary prefix for class identification is often included as part of the network
portion of the address, so that we would say that this particular address is at
network 129.65 and then at host address 24.50 on that network.

Distributed Computing Introduction,


09/30/22 70
M. Liu
Another example:
Given the address 224.0.0.1, one can expand it as
follows:

2 2 4 .0 .0 .1
11 1 00 0 0

00 0 00 00 0

The binary prefix of 111000signifies


0 00 0 00 that this is class D, or
00 0 0 0 00 1
multicast, address. Data packets sent to this
address should therefore be delivered to the
multicast group 0000000000000000000000000001.

Distributed Computing Introduction,


09/30/22 71
M. Liu
The Internet Address Scheme - 3
 For human readability, Internet addresses are
written in a dotted decimal notation:
nnn.nnn.nnn.nnn, where each nnn group is a decimal value
in the range of 0 through 255
# Internet host table (found in /etc/hosts file)
127.0.0.1 localhost
129.65.242.5 falcon.csc.calpoly.edu falcon loghost
129.65.241.9 falcon-srv.csc.calpoly.edu falcon-srv
129.65.242.4 hornet.csc.calpoly.edu hornet
129.65.241.8 hornet-srv.csc.calpoly.edu hornet-srv
129.65.54.9 onion.csc.calpoly.edu onion
129.65.241.3 hercules.csc.calpoly.edu hercules

Distributed Computing Introduction,


09/30/22 72
M. Liu
IP version 6 Addressing Scheme

 Each address is 128-bit long.


 There are three types of addresses:
 Unicast: An identifier for a single interface.
 Anycast: An identifier for a set of interfaces
(typically belonging to different nodes).
 Multicast: An identifier for a set of interfaces
(typically belonging to different nodes). A
packet sent to a multicast address is delivered
to all interfaces identified by that address.
 See Request for Comments: 2373
http://www.faqs.org/rfcs/ (link is in book’s
reference)
Distributed Computing Introduction,
09/30/22 73
M. Liu
The Domain Name System (DNS)

For user friendliness, each Internet address is mapped


to a symbolic name, using the DNS, in the format of:
<computer-name>.<subdomain hierarchy>.<organization>.<sector name>{.<country code>}
e.g., www.csc.calpoly.edu.us
ro o t

to p-le v e l do m a in

co m cou n try co de
e du go v net org m il
in th e U.S .

o rg a n izatio n To p-le v e l do m ain n am e h a s to be a pplie d fo r.


S u bdom a in h ie ra ch y a n d n a m e s a re as s ig n e d
by th e o rg a n iza tio n .

...
s u bdo m a in
...

host nam e

Distributed Computing Introduction,


09/30/22 74
M. Liu
The Domain Name System
 For network applications, a domain name must be
mapped to its corresponding Internet address.
 Processes known as domain name system servers
provide the mapping service, based on a
distributed database of the mapping scheme.
 The mapping service is offered by thousands of
DNS servers on the Internet, each responsible for a
portion of the name space, called a zone. The
servers that have access to the DNS information
(zone file) for a zone is said to have authority for
that zone.

Distributed Computing Introduction,


09/30/22 75
M. Liu
Top-level Domain Names
 .com: For commercial entities, which anyone, anywhere in
the world, can register.
 .net : Originally designated for organizations directly
involved in Internet operations. It is increasingly being used
by businesses when the desired name under "com" is already
registered by another organization. Today anyone can
register a name in the Net domain.
 .org: For miscellaneous organizations, including non-profits.
 .edu: For four-year accredited institutions of higher learning.
 .gov: For US Federal Government entities
 .mil: For US military
 Country Codes :For individual countries based on the
International Standards Organization. For example, ca for
Canada, and jp for Japan.

Distributed Computing Introduction,


09/30/22 76
M. Liu
Domain Name Hierarchy
. (ro ot d om ain )

.au ... .c a ... .u s ... .zw .c o m .go v .ed u .m il .net .o rg

c ou n try c o d e
uc s b.edu ... c alp oly.edu ...

c s c ... ee eng lis h ... w ireles s


cs ... ec e ...

Distributed Computing Introduction,


09/30/22 77
M. Liu
Name lookup and resolution
 If a domain name is used to address a host, its
corresponding IP address must be obtained for the
lower-layer network software.
 The mapping, or name resolution, must be
maintained in some registry.
 For runtime name resolution, a network service is
needed; a protocol must be defined for the naming
scheme and for the service. Example: The DNS
service supports the DNS; the Java RMI registry
supports RMI object lookup; JNDI is a network
service lookup protocol.

Distributed Computing Introduction,


09/30/22 78
M. Liu
Addressing a process running on a host

Distributed Computing
09/30/22 Introduction, M. Liu 79
Logical Ports

host A

host B
...

proc es s

...
port

Ea ch h o s t h a s 6 5 5 3 6 po rt s .

Th e I n t e rn e t

Distributed Computing Introduction,


09/30/22 80
M. Liu
Well Known Ports
 Each Internet host has 216 (65,535) logical
ports. Each port is identified by a number
between 1 and 65535, and can be allocated to
a particular process.
 Port numbers beween 1 and 1023 are reserved
for processes which provide well-known
services such as finger, FTP, HTTP, and
email.

Distributed Computing Introduction,


09/30/22 81
M. Liu
Well-known ports

A ssign m en t of som e well-kn ow n p orts


Pro to co l Po rt S e rv ice
e ch o 7 IP C te stin g

d a ytim e 13 p ro vid e s th e cu rre n t d a te a n d time

ftp 21 file tra n sfe r p ro to co l

te ln e t 23 remote, c ommand-line terminal s es s ion

sm tp 25 simp le ma il tra n sfe r p ro to co l

time 37 p ro vid e s a sta n d a rd tim e

fin g e r 79 p ro vid e s in fo rma tio n a b o u t a u se r

h ttp 80 we b se rve r
R MI R e g istry 1099 re g is try fo r R e m o te Me th o d In vo ca tio n
we b se rve r wh ich su p p o rts
sp e cia l we b se rve r 8080
se rvle ts, JSP, o r ASP

Distributed Computing Introduction,


09/30/22 82
M. Liu
Choosing a port to run your program

 For our programming exercises: when a port


is needed, choose a random number above the
well known ports: 1,024- 65,535.
 If you are providing a network service for the
community, then arrange to have a port
assigned to and reserved for your service.

Distributed Computing Introduction,


09/30/22 83
M. Liu
Addressing a Web Document

Distributed Computing Introduction,


09/30/22 84
M. Liu
The Uniform Resource Identifier (URI)
 Resources to be shared on a network need to
be uniquely identifiable.
 On the Internet, a URI is a character string
which allows a resource to be located.
 There are two types of URIs:
 URL (Uniform Resource Locator) points to a
specific resource at a specific location
 URN (Uniform Resource Name) points to a
specific resource at a nonspecific location.

Distributed Computing Introduction,


09/30/22 85
M. Liu
URL
A URL has the format of:
protocol://host address[:port]/directory path/file name#section

A s am p l e U R L :
http ://w w w .c s c .c alp o ly.ed u :80 8 0 /~ m liu /C S C 3 69 /h w .htm l # h w 1

s e c tio n n a m e
f ile n a m e
hos t nam e
d ir e c to r y p a th
p r o to c o l o f s e r v e r port num ber of s erver proc es s

O th e r p r o to co ls t h a t ca n a p p e a r in a U R L a r e :
fi le
ftp
gopher
news
te l n e t
W A IS

Distributed Computing Introduction,


09/30/22 86
M. Liu
More on URL
 The path in a URL is relative to the
document root of the server. On the CSL
systems, a user’s document root is ~/www.
 A URL may appear in a document in a
relative form:
< a href=“another.html”>
and the actual URL referred to will be
another.html preceded by the protocol,
hostname, directory path of the document .
Distributed Computing Introduction,
09/30/22 87
M. Liu
Summary - 1

We discussed the following topics:


 What is meant by distributed computing
 Distributed system
 Distributed computing vs. parallel computing
 Basic concepts in operating system: processes
and threads

Distributed Computing Introduction,


09/30/22 88
M. Liu
Summary - 2
 Basic concepts in data communication:
 Network architectures: the OSI model and the
Internet model
 Connection-oriented communication vs.

connectionless communication
 Naming schemes for network resources

• The Domain Name System (DNS)


• Protocol port numbers
• Uniform Resource Identifier (URI)
• Email addresses

Distributed Computing Introduction,


09/30/22 89
M. Liu
Summary-3
 Basic concepts in software engineering:
 Procedural programming vs. object-oriented
programming
 UML Class diagrams

 The three-layered architecture of distributed

applications: presentation layer, application or


business logic, the service layer
 The terms toolkit, framework, and component

Distributed Computing Introduction,


09/30/22 90
M. Liu

You might also like