0% found this document useful (0 votes)
6 views

Lab Manual - LP V - LA 6

Uploaded by

Aayush Agrawal
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 views

Lab Manual - LP V - LA 6

Uploaded by

Aayush Agrawal
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/ 11

Progressive Education Society’s

MODERN COLLEGE OF ENGINEERING

Department of Information Technology

LAB MANUAL
Distributed System

Lab Practice - V

Class:-BE Course:-2019
P.E.S’s Modern College of Engineering, Pune-05.
Department of Information Technology

Lab Manual
Subject Code & Name: 414454 LP - V (2019 Pat)
Class: BE
Semester: II

Compiled by:
Mrs. Sampada A. Kulkarni
Ms. Shoma S. Mitkari
VISION AND MISSION OF THE INSTITUTE

Vision Statement:
To create a collaborative academic environment to foster professional excellence and
ethical values

Mission Statement:
1. To develop outstanding professionals with high ethical standards capable of creating and
managing global enterprises
2. To foster innovation and research by providing a stimulating learning environment
3. To ensure equitable development of students of all ability levels and backgrounds
4. To be responsive to changes in technology, socio-economic and environmental conditions
5. To foster and maintain mutually beneficial partnerships with alumni and industry

VISION AND MISSION OF THE DEPARTMENT

Vision Statement:
To develop proficient IT engineers for the benefit of Industry and Society.

Mission Statement:
1. To achieve academic excellence.

2. To develop students for being competent in dynamic IT environment.

3. To encourage research and innovation.

4. To inculcate moral and professional ethics.


PEO’s OF THE DEPARTMENT

1. Demonstrate sustained learning by building the profound foundation of math’s, science


and engineering principles and make the students erudite self reliant and adaptable to
diverse culture of multidisciplinary environment.
2. Prepare graduate with strong knowledge and skills in the field of Information Technology
to develop solutions of complex engineering problems.
3. To bring leadership skill with teamwork in continuous learning environment to bear with
professional challenges.
4. To inculcate ethics towards issues of professional and social relevance.

PSO’s OF THE DEPARTMENT

1. Graduate exhibits skills to analyze, design and develop software.


2. Graduate demonstrate technical competency and leadership qualities to work in multidisciplinary
environment.
Course Objectives

● The course aims to provide an understanding of the principles on which the distributed
systems are based, their architecture, algorithms and how they meet the demands of
Distributed applications.

● The course covers the building blocks for a study related to the design and the
implementation of distributed systems and applications.

Course Outcomes

1. Demonstrate knowledge of the core concepts and techniques in distributed systems.


2. Learn how to apply principles of state-of-the-Art Distributed systems in practical
application.
3. Design, build and test application programs on distributed systems
INDEX

Sr. Page
Title
No. No.
Implement multi-threaded client/server Process communication
1.
using RMI.
Develop any distributed application using CORBA to
2. demonstrate object brokering.
(Calculator or String operations).
Develop a distributed system, to find sum of N elements in an
array by distributing N/n elements to n number of processors
3.
MPI or OpenMP. Demonstrate by displaying the intermediate
sums calculated at different processors.
4. Implement Berkeley algorithm for clock synchronization.
5. Implement token ring based mutual exclusion algorithm.
6. Implement Bully and Ring algorithm for leader election.
Create a simple web service and write any distributed
7.
application to consume the web service.
Mini Project (In group): A Distributed Application for
8.
Interactive Multiplayer Games
Assignment No: 6
Title / Objective: Bully and Ring Algorithm

Problem Statement: Implement Bully and Ring algorithm for leader election.

Course Outcome:

CO No. CO Statement BTL


C414454.2 Learn how to apply principles of state-of-the-Art Apply
Distributed systems in practical application

Pre-requisites: Computer Network Technology

Study Material: (Blogs / Videos / Courses / Web Sites / Books / e-Books)

A. For Prerequisites –

B. For Assignment -

Requirements: Java Programming Environment, JDK 1.8, Eclipse Neon(EE).

Theory:

Election Algorithm:
1. Many distributed algorithms require a process to act as a coordinator.
2. The coordinator can be any process that organizes actions of other processes.
3. A coordinator may fail.
4. How is a new coordinator chosen or elected?

Assumptions:
Each process has a unique number to distinguish them. Processes know each other's process
Number.
There are two types of Distributed Algorithms:
1. Bully Algorithm
2. Ring Algorithm

Bully Algorithm:
A. When a process, P, notices that the coordinator is no longer responding to requests, it
initiates an election.
1. P sends an ELECTION message to all processes with higher numbers.
2. If no one responds, P wins the election and becomes a coordinator.
3. If one of the higher-ups answers, it takes over. P’s job is done.
B. When a process gets an ELECTION message from one of its lower-numbered
colleagues:
1. Receiver sends an OK message back to the sender to indicate that he is alive and will take
over.
2. Eventually, all processes give up a part of one, and that one is the new coordinator.
3. The new coordinator announces its victory by sending all processes a CO-ORDINATOR
message telling them that it is the new coordinator.
C. If a process that was previously down comes back:
1. It holds an election.
2. If it happens to be the highest process currently running, it will win the election and take over
the coordinators job.
“Biggest guy" always wins and hence the name bully algorithm

Ring Algorithm:
Initiation:
1. When a process notices that coordinator is not functioning:
2. Another process (initiator) initiates the election by sending "ELECTION" message (containing
its own process number)
Leader Election:
3. Initiator sends the message to its successor (if successor is down, sender skips over it and goes
to the next member along the ring, or the one after that, until a running process is located).
4. At each step, sender adds its own process number to the list in the message.
5. When the message gets back to the process that started it all: Message comes back to initiator.
In the queue the process with maximum ID Number wins.
Initiator announces the winner by sending another message around the ring.

Algorithm / Methods / Steps:

A. For Ring Algorithm


Initiation:
1. Consider the Process 4 understands that Process 7 is not responding.
2. Process 4 initiates the Election by sending "ELECTION" message to it's successor (or next
alive process) with it's ID.
Leader Election:
3. Messages comes back to initiator. Here the initiator is 4.
4. Initiator announces the winner by sending another message around the ring. Here the process
1) With highest process ID is 6. The initiator will announce that Process 6 is Coordinator.

B. For Bully Algorithm:


Implementation and Execution:

For Ring Algorithm:


1. Creating Class for Process which includes
i) State: Active / Inactive
ii) Index: Stores index of process.
iii) ID: Process ID
2. Import Scanner Class for getting input from Console
3. Getting input from User for number of Processes and store them into object of classes.
4. Sort these objects on the basis of process id.
5. Make the last process id as "inactive".
6. Ask for menu 1.Election 2.Exit
7. Ask for initializing election process.
8. These inputs will be used by Ring Algorithm.

Ring.java
Bully.java
Inference:

Election algorithms are designed to choose a coordinator. We have two election algorithms for
two different configurations of distributed system. The Bully algorithm applies to system where
every process can send a message to every other process in the system and The Ring algorithm
applies to systems organized as a ring (logically or physically). In this algorithm we assume that
the link between the processes are unidirectional and every process can message to the process
on its right only

Oral questions:

1. What is Election Algorithm?


2. Name different election algorithms?
3. What is Bully and Ring Algorithm?
4. What election algorithm does?
5. Why election algorithms are normally needed in a distributed system?
6. What is leader election algorithm and why do we need this algorithm?
7. How many types of messages are there in election algorithm?
8. What are the features required for election algorithms?
9. What is the purpose of election system?
10.What is the time complexity of leader election?

You might also like