Aman - DS
Aman - DS
Aman - DS
Preface
Main motto of any laboratory/practical/field work is for enhancing required skills as well as
creating ability amongst students to solve real time problem by developing relevant competencies
in psychomotor domain. By keeping in view, GTU has designed competency focused outcome-
based curriculum for engineering degree programs where sufficient weightage is given to
practical work. It shows importance of enhancement of skills amongst the students and it pays
attention to utilize every second of time allotted for practical amongst students, instructors and
faculty members to achieve relevant outcomes by performing the experiments rather than having
merely study type experiments. It is must for effective implementation of competency focused
outcome-based curriculum that every practical is keenly designed to serve as a tool to develop
and enhance relevant competency required by the various industry among every student. These
psychomotor skills are very difficult to develop through traditional chalk and board content
delivery method in the classroom. Accordingly, this lab manual is designed to focus on the
industry defined relevant outcomes, rather than old practice of conducting practical to prove
concept and theory.
By using this lab manual students can go through the relevant theory and procedure in advance
before the actual performance which creates an interest and students can have basic idea prior to
performance. This in turn enhances pre-determined outcomes amongst students. Each experiment
in this manual begins with competency, industry relevant skills, course outcomes as well as
practical outcomes (objectives). The students will also achieve safety and necessary precautions
to be taken while performing practical.
This manual also provides guidelines to faculty members to facilitate student centric lab activities
through each experiment by arranging and managing necessary resources in order that the
students follow the procedures with required safety and necessary precautions to achieve the
outcomes. It also gives an idea that how students will be assessed by providing rubrics.
A distributed system is a computing environment in which various components are spread across
multiple computers (or other computing devices) on a network. These devices split up the work,
coordinating their efforts to complete the job more efficiently than if a single device had been
responsible for the task. Distributed systems facilitate sharing different resources and capabilities,
to provide users with a single and integrated coherent network.
Utmost care has been taken while preparing this lab manual however always there is chances of
improvement. Therefore, we welcome constructive suggestions for improvement and removal of
errors if any.
Distributed System (3170719) 200180107014
9.
Implement client server application using CORBA √
The following industry relevant competency are expected to be developed in the student by
undertaking the practical work of this laboratory.
1. Will be able to develop web application using Netbeans/Ecllipse IDE
2. Will be able to do Network and distributed programming.
Index
(Progressive Assessment Sheet)
Total
Distributed System (3170719) 200180107014
Experiment No: 1
Theory:
A chat server application is a computer program that enables users to communicate with
each other over the internet or a network. Client-Server Model: A chat server application typically
follows a client-server model, where one or more clients connect to a central server. The server
manages the connections and the communication between the clients.
Procedure:
Implementing a chat server application in Java requires several steps, including setting up a server,
establishing client connections, handling client requests, and sending and receiving messages.
Here's a high-level algorithm for implementing a basic chat server application in Java:
1. Create a server socket that listens for incoming connections on a specific port number.
2. When a client connects, create a new socket to handle the client's requests and establish
input and output streams for sending and receiving messages.
3. Create a thread to handle each client connection so that multiple clients can connect and
communicate simultaneously.
4. Implement the logic for receiving and processing client requests, such as sending messages
to other clients or retrieving a list of currently connected clients.
5. Use synchronization to ensure that multiple threads do not modify shared resources (e.g. a
list of connected clients) at the same time.
6. When a client disconnects, remove it from the list of connected clients and close its socket.
G.E.C Dahod 6
Distributed System (3170719) 200180107014
Program Code:
//Server
import java.net.*;
import java.io.*;
while(true)
{
do
{
s1=br4.readLine();
pw1.println(s1);
}
while(!s1.equals("over"));
do
{
s2=br3.readLine();
System.out.println(s2);
}
while(!s2.equals("over"));
}
}
} //server ends
// Client
import java.net.*;
import java.io.*;
G.E.C Dahod 7
Distributed System (3170719) 200180107014
BufferedReader br1=new BufferedReader(new
InputStreamReader(cc.getInputStream()));
BufferedReader br2=new BufferedReader(new InputStreamReader(System.in));
String str1, str2;
while(true)
{
do
{
str1=br1.readLine();
System.out.println(str1);
}
while(!str1.equals("over"));
do
{
str2=br2.readLine();
pw.println(str2);
}
while(!str2.equals("over"));
}
}
} //client ends
Output:
Server Side:
Client Side:
Conclusion:
We have successfully implemented client-server chat program.
Exercise:
1. What is the role of socket class in Java for client server programing?
2. What method in Java can be used by a client program to establish a connection to a server
program?
a. Socket.accept()
b. ServerSocket.bind()
c. Socket.connect()
d. ServerSocket.accept()
Suggested References:
1. Professional Java Server Programming by Subrahmanyam Allamaraju, Cedric Buest Wiley
Publication
2. "TCP/IP Sockets in Java: Practical Guide for Programmers" by Kenneth L. Calvert and Michael J.
Donahoo.
3. Distributed Computing and application by M L Liu, Pearson Education Inc.
G.E.C Dahod 8
Distributed System (3170719) 200180107014
G.E.C Dahod 9
Distributed System (3170719) 200180107014
Experiment No: 2
Implement Remote Method Invocation (RMI) in java to find whether number is odd or
even
Date:
Theory:
Remote Method Invocation (RMI) is a Java-based technology that enables communication
between different Java Virtual Machines (JVMs) running on different hosts in a network. RMI
provides a mechanism for invoking methods on objects that reside in different JVMs, making it
possible to implement distributed applications in Java.
The basic idea behind RMI is that a Java object running in one JVM can invoke methods on
a Java object running in another JVM. To achieve this, the Java objects that can be accessed
remotely must implement a special interface, called a Remote interface, which extends the
java.rmi.Remote interface. This interface serves as a marker, indicating that the object can be
accessed remotely.
To use RMI, the client needs to know the name or reference of the remote object it wants to
invoke. This can be done by registering the object with a naming service, such as the Java Naming
and Directory Interface (JNDI). Once the client has obtained a reference to the remote object, it can
invoke methods on the object as if it were a local object.
Using RMI you have to implement a program which will find whether the number is odd or even.
Procedure:
1. Define the Remote Interface: Create a remote interface, let's call it OddEvenInterface,
which declares the method signatures that will be used to determine if a number is even or
odd. This interface should extend Remote.
2. Implement the Remote Interface: Implement the OddEvenInterface interface in a class that
will be used as a remote object. Let's call it OddEvenServer. This class must extend
UnicastRemoteObject and provide an implementation for the remote methods.
3. Create the RMI Registry: Start the RMI registry on the host where the remote object will be
G.E.C Dahod 10
Distributed System (3170719) 200180107014
running. This can be done using the rmiregistry command.
4. Register the Remote Object: Register the remote object with the RMI registry using the
Naming.rebind() method. The name of the object that is used in the Naming.rebind() method
is the name that the client will use to access the remote object.
5. Create the RMI Client: Create a client program that will use the remote object to determine
if a number is even or odd. The client must look up the remote object in the RMI registry
using the Naming.lookup() method.
6. Compile and Run: Compile both the server and client classes and run the server first,
followed by the client. The output should indicate whether the number is even or odd.
Program Code:
Interface:-
import java.rmi.*;
Server:-
import java.net.*;
import java.rmi.*;
import java.rmi.registry.*;
String address;
Registry registry;
@Override
public int isEven(String number) throws RemoteException {
int result = 0;
try {
int value = Integer.parseInt(number);
if ((value % 2) == 0)
result = 1;
else
result = 2;
} catch (Exception e) {
}
return result;
}
G.E.C Dahod 11
Distributed System (3170719) 200180107014
public OddEvenServer() throws RemoteException {
try {
address = (InetAddress.getLocalHost()).toString();
} catch (Exception e) {
System.out.println("Can't get Inet Address.");
}
try {
registry = LocateRegistry.createRegistry(3233);
registry.rebind("rmiServer", this);
} catch (RemoteException e) {
System.out.println("Remote Exception" + e);
}
}
Client:-
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.rmi.*;
import java.rmi.registry.*;
Conclusion:
I have successfully implemented NumberChecker server for odd and even number using RMI.
Exercise :
Q.2 Which interface must a remote object implement in order to be accessed remotely?
a) java.rmi.Remote
b) java.rmi.Server
c) java.rmi.Client
d) java.rmi.RemoteObject
Suggested References:
1. Professional Java Server Programming by Subrahmanyam Allamaraju, Cedric Buest Wiley
Publication
2. "Java RMI" by William Grosso.
3. Distributed Computing and application by M L Liu, Pearson Education Inc.
G.E.C Dahod 13
Distributed System (3170719) 200180107014
G.E.C Dahod 14
Distributed System (3170719) 200180107014
Experiment No: 3
Date:
Theory:
Remote Method Invocation (RMI) is a Java-based technology that enables communication
between different Java Virtual Machines (JVMs) running on different hosts in a network. RMI
provides a mechanism for invoking methods on objects that reside in different JVMs, making it
possible to implement distributed applications in Java.
The basic idea behind RMI is that a Java object running in one JVM can invoke methods on
a Java object running in another JVM. To achieve this, the Java objects that can be accessed
remotely must implement a special interface, called a Remote interface, which extends the
java.rmi.Remote interface. This interface serves as a marker, indicating that the object can be
accessed remotely.
To use RMI, the client needs to know the name or reference of the remote object it wants to
invoke. This can be done by registering the object with a naming service, such as the Java Naming
and Directory Interface (JNDI). Once the client has obtained a reference to the remote object, it can
invoke methods on the object as if it were a local object.
A Timer server is a type of server that provides time synchronization services to clients. It
is often used in distributed systems where it is important for all machines to have a consistent view
of time.
To implement a Timer server in Java, you can use the Java Timer class and the RMI (Remote
Method Invocation) framework.
Procedure:
1. Define the remote interface: Define a remote interface that extends the java.rmi.Remote
interface and declares the methods that the server will provide. In this case, you need to
define a method that returns the current time.
G.E.C Dahod 15
Distributed System (3170719) 200180107014
2. Implement the remote interface: Implement the remote interface in a server class that
extends the java.rmi.server.UnicastRemoteObject class. This class should provide an
implementation of the getTime() method.
3. Create the server: Create a server class that creates an instance of the TimeServerImpl class
and binds it to the RMI registry.
4. Create the client: Create a client class that looks up the TimeServer object in the RMI
registry and calls its getTime() method.
5. Run the server and client: Start the server class first and then start the client class. The client
should display the current time obtained from the server.
Program Code:
TimerCallback.java
import java.rmi.Remote;
import java.rmi.RemoteException;
TimerInterface.java
import java.rmi.Remote;
import java.rmi.RemoteException;
TimerServer.java
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
System.out.println("TimerServer is ready.");
} catch (Exception e) {
System.err.println("TimerServer exception: " + e.toString());
e.printStackTrace();
}
}
}
TimerClient.java
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.io.Serializable;
G.E.C Dahod 17
Distributed System (3170719) 200180107014
Output:
Conclusion:
I have successfully created Timer Program using Remote Procedure Call.
Exercise:
1. What is skeleton in RMI?
the skeleton in RMI acts as a gateway between the client and the server,
handling the deserialization of client requests, routing method calls to the
appropriate remote object, and serializing the results to send back to the
client. It is an essential part of the RMI infrastructure that abstracts many of the
complexities of remote method invocation
G.E.C Dahod 18
Distributed System (3170719) 200180107014
Suggested References:
1. Professional Java Server Programming by Subrahmanyam Allamaraju, Cedric Buest Wiley
Publication
2. Distributed Computing and application by M L Liu, Pearson Education Inc.
G.E.C Dahod 19
Distributed System (3170719) 200180107014
Experiment No: 4
Implement a program which print Hello Message using Remote Procedure Call (RPC)
Date:
Objectives: (a) To understand the concept of Remote Procedure Call (RPC) and its
implementation in Java.
(b) To create a simple Java program that demonstrates the use of RPC.
Theory:
Remote Procedure Call (RPC) is a technique used to enable programs to call procedures on
remote computers as if they were local procedures. It allows a program to invoke a procedure on a
remote computer using the same syntax as for local procedure calls. The RPC program consists of
a client program that sends a request to a server program to execute a procedure, and the server
program executes the procedure and sends a response back to the client.
Procedure:
Here's a steps for printing a "Hello" message using Remote Procedure Call (RPC) in Java:
▪ Install the latest version of Java Development Kit (JDK) and NetBeans IDE (or your
preferred IDE).
▪ Create a new Java project in NetBeans.
2. Define the interface for the remote procedure:
G.E.C Dahod 20
Distributed System (3170719) 200180107014
Program Code:
G.E.C Dahod 21
Distributed System (3170719) 200180107014
Output:
Conclusion:
I have successfully implemented Hello world program using Remote Procedure Call.
G.E.C Dahod 22
Distributed System (3170719) 200180107014
Exercise:
1. What is Remote Procedure Call (RPC)?
A Remote Procedure Call (RPC) is a protocol that allows one program to
request a service or function to be executed on another address space or
even on a different machine, as if it were a local function or procedure call.
3. What are some important factors to consider when implementing RPC in Java?
a. Choice of RPC Framework:
b. Serialization
c. Network Protocol
d. Error Handling
Suggested References:
1. Professional Java Server Programming by Subrahmanyam Allamaraju, Cedric Buest Wiley
Publication
2. Distributed Computing and application by M L Liu, Pearson Education Inc.
G.E.C Dahod 23
Distributed System (3170719) 200180107014
Experiment No: 5
Date:
Theory:
Remote Procedure Call (RPC) is a technique used to enable programs to call procedures on
remote computers as if they were local procedures. It allows a program to invoke a procedure on a
remote computer using the same syntax as for local procedure calls. The RPC program consists of
a client program that sends a request to a server program to execute a procedure, and the server
program executes the procedure and sends a response back to the client.
In this experiment, we will use RPC to implement a simple calculator program that performs basic
arithmetic operations such as addition, subtraction, multiplication, and division.
Procedure:
Here's a step-by-step procedure to implement a simple calculator using Remote Procedure Call
(RPC) in Java:
1. Set up your development environment:
▪ Install the latest version of Java Development Kit (JDK) and NetBeans IDE (or your
preferred IDE).
▪ Create a new Java project in NetBeans.
Calculator.java
import java.rmi.Remote;
import java.rmi.RemoteException;
CalculatorServer.java
import java.rmi.*;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
System.out.println("CalculatorServer is ready.");
} catch (Exception e) {
System.err.println("CalculatorServer exception: " + e.toString());
e.printStackTrace();
}
}
}
CalculatorClient.java
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
Output:
Conclusion:
I have successfully implemented a simple Calculator using Remote Procedure Call.
Exercise:
Suggested Reference(s):
1. Professional Java Server Programming by Subrahmanyam Allamaraju, Cedric Buest Wiley
Publication
2. "Java RMI" by William Grosso
3. Distributed Computing and application by M L Liu, Pearson Education Inc.
G.E.C Dahod 27
Distributed System (3170719) 200180107014
G.E.C Dahod 28
Distributed System (3170719) 200180107014
Experiment No: 6
Date :
Theory:
The Lamport algorithm is a logical clock algorithm that allows ordering of events in a
distributed system. The algorithm was proposed by Leslie Lamport in 1978.
The algorithm works by assigning a logical clock value to each event in the system. The
logical clock is a virtual clock that is incremented each time an event occurs in the system. The
logical clock value of an event is the timestamp of the event.
The Lamport algorithm ensures that the events are ordered based on their logical clock
values. If event A has a lower logical clock value than event B, then event A occurred before
event B.
The algorithm is implemented using a message passing mechanism. When a process sends
a message to another process, it includes its current logical clock value in the message. When the
receiving process receives the message, it updates its own logical clock value to the maximum of
its current value and the value received in the message. This ensures that the logical clock values
of events are monotonically increasing.
Safety and necessary Precautions: Handle all necessary compile time Exceptions.
Procedure:
1. Define the Event class: Define an Event class that stores the timestamp and the process id
of an event.
2. Define the Process class: Define a Process class that simulates a process in the distributed
system. The Process class should contain a logical clock value and a queue of events that
have occurred in the process.
3. Implement the Lamport algorithm: Implement the Lamport algorithm in the Process class.
When a process sends a message to another process, it should include its current logical
clock value in the message. When the receiving process receives the message, it should
update its own logical clock value to the maximum of its current value and the value
received in the message. When an event occurs in the process, it should be assigned a
timestamp that is the current logical clock value of the process.
G.E.C Dahod 29
Distributed System (3170719) 200180107014
4. Test the Lamport algorithm: Create a main class that creates a set of processes in the
distributed system. Each process should send messages to other processes and generate
events. The main class should display the events in the order determined by the Lamport
algorithm.
• When a message is sent from one process to another, the sender includes its current logical
clock value as the timestamp of the message.
• When a process receives a message, it sets its logical clock to the maximum of its current
value and the timestamp of the received message plus 1. This ensures that the logical clock
of the receiving process is always greater than the logical clock of the sending process.
• The logical clock values assigned to events by each process can be used to determine the
ordering of events in the system.
Program Code:
import java.util.ArrayList;
import java.util.List;
class LamportClock {
private int value = 0;
class LamportProcess {
private final int id;
private final LamportClock clock;
G.E.C Dahod 30
Distributed System (3170719) 200180107014
G.E.C Dahod 31
Distributed System (3170719) 200180107014
Output:
Conclusion:
I have successfully implemented Lamport’s logical Clock Algorithm for Distributed Systems and
also observed clock cycles successfully.
Exercise:
2. How does the Lamport algorithm ensure that events are ordered based on their logical
clock values?
The Lamport algorithm ensures that if event A causally precedes event B, the
Lamport timestamp of event A is less than the timestamp of event B. This means
that events that are causally related are ordered correctly
3. How can the Lamport algorithm be implemented using Java programming language?
Code is given above.
Suggested Reference(s):
1. Professional Java Server Programming by Subrahmanyam Allamaraju, Cedric Buest Wiley
Publication
2. Distributed Computing and application by M L Liu, Pearson Education Inc.
3. "Distributed Systems: Principles and Paradigms" by Andrew S. Tanenbaum and Maarten van
Steen
G.E.C Dahod 32
Distributed System (3170719) 200180107014
G.E.C Dahod 33
Distributed System (3170719) 200180107014
Experiment No: 7
Date:
Theory:
A vector clock is a list of integer values, where each value represents the number of events
that have occurred in each process up until that point in time. Each process increments its own
value in the vector clock whenever an event occurs, and sends the updated vector clock along with
the message to the other processes. When a process receives a message, it updates its own vector
clock by taking the maximum value of each element in its own vector clock and the vector clock
received in the message.
The Lamport Vector clock algorithm ensures that if event A happened before event B,
then the vector clock of A is less than the vector clock of B.
Procedure:
• Create a Java project in Eclipse or NetBeans.
• Create a Process class that implements Runnable interface. The Process class should have
the following:
o A name for the process.
o A vector clock to keep track of events.
o A method to update the vector clock when an event occurs.
o A run() method that simulates the process.
o A method to send messages to other processes.
• In the main() method, create an array of Process objects.
• Start each process in the array by calling the start() method.
• In the run() method of each Process object, simulate the occurrence of events and update
the vector clock accordingly.
• When a process sends a message to another process, it should update its own vector clock
and send the updated vector clock along with the message.
• When a process receives a message, it should update its own vector clock by taking the
G.E.C Dahod 34
Distributed System (3170719) 200180107014
maximum value of each element in its own vector clock and the vector clock received in
the message.
• Test the implementation of the Lamport Vector clock algorithm by running the program
and observing the vector clocks of each process.
Program Code:
import java.util.*;
G.E.C Dahod 35
Distributed System (3170719) 200180107014
Output:
G.E.C Dahod 36
Distributed System (3170719) 200180107014
Conclusion:
In conclusion, the Lamport Vector clock algorithm is a useful tool for keeping track of the order of
events in distributed systems. By implementing the algorithm in Java, we can ensure that different
processes in a distributed system are able to communicate with each other and maintain a consistent
view of events.
Exercise:
1. What is the purpose of Lamport Vector Clocks in distributed systems?
The primary purpose of Lamport Vector Clocks in distributed systems is to provide
a way to determine a partial ordering of events and understand the causal
relationships between events, even in the absence of global time synchronization.
3. Can two events have the same Lamport timestamp in a distributed system?
Yes, in a Lamport timestamp-based system, it is possible for two events to have
the same Lamport timestamp.
4. How do you update a Lamport Vector Clock when a process receives a message from
another process?
Updating a Lamport Vector Clock when a process receives a message from
another process involves incrementing specific elements in the vector to reflect
the reception of the message and the relationship between the two events. Here's
how you can update a Lamport Vector Clock when a process receives a message
from another process:
5. How can you detect causality violations using Lamport Vector Clocks?
Detecting causality violations or inconsistencies in a distributed system using
Lamport Vector Clocks involves analyzing the vector clocks associated with events
and messages. Causality violations typically indicate situations where the observed
event order is not consistent with the causal relationships among events
6. Can Lamport Vector Clocks handle clock drifts between different processes?
No.
Suggested Reference(s):
1. Professional Java Server Programming by Subrahmanyam Allamaraju, Cedric Buest Wiley
Publication
2. "Distributed Systems: Principles and Paradigms" by Andrew S. Tanenbaum and Maarten
van Steen.
3. Distributed Computing and application by M L Liu, Pearson Education Inc.
G.E.C Dahod 37
Distributed System (3170719) 200180107014
G.E.C Dahod 38
Distributed System (3170719) 200180107014
Experiment No: 8
Date:
Theory:
The Bully Algorithm is a leader election algorithm that is used in distributed systems. It is a
way to elect a leader node among a group of nodes, with the assumption that the leader node will
be responsible for coordinating and managing the system.
The Bully Algorithm is a fault-tolerant algorithm that is designed to handle node failures.
When a node fails, the other nodes will detect the failure and start a new election process to elect a
new leader. The Bully Algorithm is designed to elect a leader with the highest priority among all
the nodes in the system.
Procedure:
1. Create a Java class for the Node object that represents a node in the distributed system. The class
should have fields for the node ID and the priority of the node.
2. Implement a method for sending an election message to all the other nodes in the system.
3. Implement a method for receiving and processing messages from other nodes.
6. Create a main class for the distributed system that creates and initializes the nodes, and starts the
election process.
7. Test the system by simulating node failures and observing how the algorithm handles them.
Algorithm:
▪ Each process in the network has a unique ID number.
▪ If a process P detects that the coordinator has failed, it sends an ELECTION message to all
processes with higher ID numbers.
▪ If a process Q receives an ELECTION message from P, it sends an OK message to P,
G.E.C Dahod 39
Distributed System (3170719) 200180107014
indicating that it is still alive.
▪ If a process Q does not receive a message from a higher-ID process within a certain time
period, it assumes that the higher-ID process has failed and initiates an election process.
▪ When a process R receives an OK message from all higher-ID processes, it becomes the new
coordinator and sends a COORDINATOR message to all other processes to inform them of the
new leader.
Program Code:
import java.util.*;
class Node {
private int id;
private int priority;
private boolean isCoordinator;
private boolean isOnline;
public List<Node> higherPriorityNodes;
if (isOnline) {
System.out.println("Node " + id + " sends OK to Node " + sender.id);
sender.receiveOKMessage(this);
}
}
G.E.C Dahod 40
Distributed System (3170719) 200180107014
public void initiateElection() {
isCoordinator = true;
System.out.println("Node " + id + " becomes the COORDINATOR.");
node2.higherPriorityNodes.add(node3);
node2.higherPriorityNodes.add(node4);
node3.higherPriorityNodes.add(node4);
// Start an election
node1.sendElectionMessage();
}
}
Output:
Conclusion:
I have successfully implemented Bully Algorithm and also implemented election for fault
tolerance.
Exercise :
3. What happens when a node receives an election message from a node with a higher
priority?
When a node in a distributed system receives an election message from another
node with a higher priority, it is an indication that the sender is challenging the
receiver's claim to leadership or coordinator status. In the context of leader
election algorithms like the Bully Algorithm, this situation triggers a response from
the receiving node
G.E.C Dahod 42
Distributed System (3170719) 200180107014
Suggested Reference(s):
1. Professional Java Server Programming by Subrahmanyam Allamaraju, Cedric Buest
Wiley Publication
2. "Distributed Systems: Principles and Paradigms" by Andrew S. Tanenbaum and
Maarten van Steen.
3.
References used by the students:
GeekForGeeks, StackOverflow,j javatpoint
G.E.C Dahod 43
Distributed System (3170719) 200180107014
Experiment 09
Objectives:
Theory:
To use CORBA, you need to define an interface for your objects using the Interface
Definition Language (IDL). The IDL defines the methods and attributes that the objects will
expose to clients. The IDL compiler generates stub and skeleton code for the client and server
objects respectively. The stub and skeleton code provide the necessary marshaling and
unmarshaling of method arguments and results between the client and server.
The steps involved in implementing a simple client-server application using CORBA are:
▪ Make sure that all the software required to run CORBA is installed and properly
configured.
▪ Handle all necessary compile time Exception
Procedure:
▪ Define the IDL interface: Define the interface for your objects using the Interface
Definition Language (IDL). The interface should include the methods and attributes
that the server object will expose to clients.
G.E.C Dahod 44
Distributed System (3170719) 200180107014
▪ Compile the IDL interface using the IDL compiler: Use the IDL compiler to generate
stub and skeleton code for the client and server objects respectively.
▪ Implement the server object: Implement the server object in Java using the skeleton
code generated by the IDL compiler. The server object should implement the
methods defined in the IDL interface.
▪ Start the ORB: Start the ORB by running the orb.run command.
▪ Register the server object with the ORB: Register the server object with the ORB
using the Naming Service.
▪ Implement the client object: Implement the client object in Java using the stub code
generated by the IDL compiler. The client object should invoke the methods defined
in the IDL interface.
▪ Compile the client object: Use the Java compiler to compile the client object.
▪ Run the client object: Run the client object and observe the results.
Program Code:
HelloImpl.java
import HelloApp.HelloPOA;
HelloServer.java
import HelloApp.Hello;
import HelloApp.HelloHelper;
import org.omg.CORBA.ORB;
import org.omg.CosNaming.NameComponent;
import org.omg.CosNaming.NamingContextExt;
import org.omg.CosNaming.NamingContextExtHelper;
G.E.C Dahod 45
Distributed System (3170719) 200180107014
HelloClient.java
import HelloApp.Hello;
import org.omg.CORBA.ORB;
import org.omg.CosNaming.NamingContextExt;
import org.omg.CosNaming.NamingContextExtHelper;
Output:
Conclusion:
I have successfully implemented Hello, World Program using orb in CORBA.
G.E.C Dahod 46
Distributed System (3170719) 200180107014
Exercise :
1. What is CORBA?
CORBA, which stands for Common Object Request Broker Architecture, is a
middleware technology and architecture that enables communication and
interaction between distributed objects in a networked computing environment. It
provides a framework for building distributed systems in which objects written in
different programming languages can interoperate seamlessly.
4. What is the purpose of the stub and skeleton code generated by the IDL compiler?
It acts as a representative or proxy for a remote object located on the server side.
The primary purpose of the stub is to allow the client to invoke methods on the
remote object as if it were a local object, even though the object resides on a
different machine or in a different address space.
Suggested Reference(s):
1. "CORBA: Architecture and Programming with Java" by John Siegel and Thomas
Mowbray
G.E.C Dahod 47
Distributed System (3170719) 200180107014
Experiment 10
Competency and Practical Skills: Web development, programming skills, and knowledge of
web services.
Objectives:
Theory:
A web service is a software system designed to support interoperable machine-to-machine
interaction over a network. It has an interface described in a machine-processable format,
specifically WSDL (Web Service Description Language). Other systems interact with the web
service in a manner prescribed by its description using SOAP messages, typically conveyed using
HTTP with an XML serialization in conjunction with other web-related standards.
Apache Axis is one of the popular implementations of web services that is built on top of the Apache
SOAP project. It is an open-source, XML-based web service framework that provides a means to
generate WSDL and create client applications in various programming languages, including Java.
▪ Make sure to use secure communication protocols such as HTTPS to ensure the
confidentiality of data transmitted over the network.
▪ Make sure to validate user inputs and implement proper error handling mechanisms to
prevent attacks such as SQL injection.
Procedure:
▪ Define the web service interface using the JAX-WS (Java API for XML Web Services)
annotations. This interface should declare the methods that will be exposed as web
service operations. Annotate the interface with @WebService and @WebMethod
annotations.
G.E.C Dahod 48
Distributed System (3170719) 200180107014
▪ Implement the web service interface in a Java class. Annotate the class with
@WebService and @WebServiceProvider annotations. Implement the methods
declared in the interface.
▪ Create a web application project in Eclipse or NetBeans. Add the Java class created in
step 3 to the project.
▪ Create a web service deployment descriptor (web.xml) file. This file should specify the
location of the web service implementation class and the URL mapping for the web
service endpoint.
▪ Deploy the web service to a web server such as Apache Tomcat. Publish the web service
by deploying the web application project created in step 4.
▪ Create a client application that will consume the web service. The client application can
be created in any programming language that supports SOAP messages. For this lab,
create a Java client application using the JAX-WS API.
▪ Generate the client artifacts using the wsimport tool provided by the JDK. This tool
generates Java classes that correspond to the WSDL of the web service.
▪ Use the generated Java classes to invoke the web service operations in the client
application.
▪ Run the client application and observe the results of invoking the web service operations.
Program Code:
ExampleResource.java
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
@Path("/example")
public class ExampleResource {
@GET
@Produces("text/plain")
public String getExample() {
return "Hello, World!";
}
}
Main.java
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
import org.glassfish.jersey.server.ResourceConfig;
import java.net.URI;
G.E.C Dahod 49
Distributed System (3170719) 200180107014
GrizzlyHttpServerFactory.createHttpServer(URI.create(baseUri), resourceConfig);
}
}
Pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>jersey-web-service</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<!-- Jersey dependencies -->
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
<version>2.35</version> <!-- Replace with the latest version -->
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>2.35</version> <!-- Replace with the latest version -->
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.example.Main</mainClass> <!-- Replace with your main class -->
</configuration>
</plugin>
G.E.C Dahod 50
Distributed System (3170719) 200180107014
</plugins>
</build>
</project>
Output:
Conclusion:
▪ Web services provide a means for different applications to interact with each other
over a network.
▪ Apache Axis is a popular implementation of web services that provides a means to
generate WSDL and create client applications in various programming languages.
▪ Web services can be published on a web server and consumed by client applications in
a secure and efficient manner.
Exercise :
2. What is WSDL?
WSDL stands for "Web Services Description Language." It is an XML-based
language used to describe the interface and functionality of a web service.
WSDL serves as a standardized way to define how a web service can be
accessed, what operations it supports, the data types it uses, and the
structure of messages that need to be exchanged between clients and the
service.
Suggested References:
1. Professional Java Server Programming by Subrahmanyam Allamaraju, Cedric Buest Wiley
Publication
2. "Java Web Services: Up and Running" by Martin Kalin
G.E.C Dahod 51
Distributed System (3170719) 200180107014
G.E.C Dahod 52
Distributed System (3170719) 200180107014
Experiment 11
Relevant CO : CO5
Objective: To create a BPEL process and composite application using Oracle JDeveloper.
Theory:
A Business Process Execution Language (BPEL) process is an executable process that
describesthe behavior of a business process based on a set of activities, including receiving and
sending messages, invoking services, and manipulating data.
In this lab, we will use Oracle JDeveloper to create a BPEL process and a composite
application that integrates multiple services.
Procedure:
Open Oracle JDeveloper and create a new application by selecting File > New > Application
from the menu.
▪ In the "Create SOA Application" wizard, enter the application name and click "Next".
▪ In the "Select Template" page, select "Composite with BPEL" and click "Next".
▪ In the "composite.xml" file, drag and drop a "BPEL Process" component from the
Component Palette onto the design canvas.
▪ Double-click the "BPEL Process" component to open the "BPEL Process Editor".
▪ In the "BPEL Process Editor", add the required activities to define the business
process, such as "Receive", "Invoke", "Assign", and "Reply".
▪ Save the BPEL process by selecting File > Save from the menu.
▪ In the "composite.xml" file, drag and drop the required components from the
Component Palette onto the design canvas to create the composite application.
▪ Use the "Service Component Architecture" (SCA) editor to wire the components
together by creating "references" and "bindings".
▪ Save the composite application by selecting File > Save from the menu.
G.E.C Dahod 53
Distributed System (3170719) 200180107014
▪ Deploy the composite application to the Oracle WebLogic Server by right-clicking the
"composite.xml" file and selecting "Deploy".
▪ Test the composite application by accessing the services provided by the components.
Observations:
During the BPEL process creation, we observed that it is possible to add different activities to
the process to define the business logic.
In the composite application, we observed that the components can be easily wired together
using the SCA editor.
During deployment, we observed that the composite application is deployed as a single unit to
the Oracle WebLogic Server.
Conclusion:
Based on the provided observations and the steps for creating a BPEL process and composite
application in Oracle JDeveloper, we can draw the following conclusions:
1. Ease of BPEL Process Creation: Oracle JDeveloper simplifies the process of creating
BPEL processes. You can quickly define complex business logic by adding various
activities, such as Receive, Invoke, Assign, and Reply, to the BPEL process. This visual
approach makes it easy to design and implement business processes efficiently.
2. Composite Application Development: Creating composite applications for orchestrating
various components is straightforward in Oracle JDeveloper. The Service Component
Architecture (SCA) editor allows you to wire components together seamlessly, enabling
you to build composite applications that integrate and manage different services and
components.
3. Modular Development: Composite applications consist of reusable components, and each
component can be developed and tested independently. This modular approach enhances
the maintainability of the application and promotes code reuse.
4. Deployment as a Single Unit: Deploying composite applications to Oracle WebLogic
Server is a smooth process. The composite application, including all its components and
services, is deployed as a single unit, simplifying deployment and management tasks.
5. Testing and Validation: The built-in tools and features in Oracle JDeveloper, such as the
BPEL Process Tester, make it easy to test and validate the behavior of both individual
BPEL processes and composite applications. This is essential for ensuring that the
application functions correctly.
6. Integration with Oracle WebLogic Server: Oracle JDeveloper seamlessly integrates
with Oracle WebLogic Server, making it a suitable environment for developing and
deploying enterprise-level applications. The integrated deployment process ensures that
the composite application is ready for execution in the server environment.
7. Productivity and Efficiency: Oracle JDeveloper provides a user-friendly interface for
both BPEL process development and composite application creation. This results in
increased productivity and efficiency, allowing developers to focus on defining business
processes rather than dealing with low-level technical details.
In conclusion, Oracle JDeveloper offers a powerful and intuitive development environment for
creating BPEL processes and composite applications. It simplifies the design, development,
testing, and deployment of business processes, making it an ideal choice for enterprises looking to
build sophisticated and integrated applications.
G.E.C Dahod 54
Distributed System (3170719) 200180107014
Suggested Reference(s):
1. "Service-Oriented Architecture: Concepts, Technology, and Design" by Thomas Erl
G.E.C Dahod 55
Distributed System (3170719) 200180107014
Experiment 12
Objectives: (a) To understand the concept of key management and its importance in cryptography
(b) To study various open source key management tools and their features
(c) To evaluate and compare the performance of these tools
Theory:
Observations:
Open-source key management tool, HashiCorp Vault:
G.E.C Dahod 56
Distributed System (3170719) 200180107014
Auditing and Compliance:
• Vault has robust auditing capabilities for tracking key access and usage.
• It can be configured to meet compliance requirements, such as GDPR and HIPAA.
User Management and Access Control:
• Vault supports user and role management with fine-grained access controls.
• It offers various authentication mechanisms, including multi-factor authentication.
Scalability and High Availability:
• Vault is designed to scale horizontally to accommodate growing workloads.
• It provides features for high availability to minimize downtime.
Documentation and Support:
• HashiCorp provides extensive documentation, including installation guides and user
manuals.
• Commercial support is available for organizations seeking assistance.
Security and Vulnerability Assessments:
• HashiCorp maintains a robust security process, actively addressing vulnerabilities when
discovered.
Use Cases and Case Studies:
• Vault is used by various organizations for securing secrets, managing encryption keys, and
protecting sensitive data.
Performance and Speed:
• Vault's performance is optimized for cryptographic operations and key management tasks.
Community and Commercial Alternatives:
• While Vault is open source, HashiCorp also offers a commercial version with additional
features and support.
User Feedback and Reviews:
• You can find user reviews and feedback on HashiCorp Vault's performance, security, and
ease of use.
Testing and Deployment:
• Consider setting up a test environment to evaluate Vault's functionality and suitability
before deploying it in a production environment.
HashiCorp Vault is a widely used open-source key management tool that addresses various
aspects of key management, secrets storage, and access control. It provides strong security
features, robust documentation, and a supportive community, making it suitable for a wide range
of use cases.
G.E.C Dahod 57
Distributed System (3170719) 200180107014
Conclusion:
In conclusion, HashiCorp Vault is a powerful open-source key management tool that excels in
securing secrets, managing cryptographic keys, and enforcing access control. It offers
comprehensive features, robust security, and strong integration capabilities, making it a top choice
for organizations seeking to protect sensitive data and cryptographic assets. Its active open-source
community, scalability, and support for compliance requirements make it a versatile solution for
various use cases.
Exercise:
1. What is a private key in OpenSSL, and how is it generated?
In OpenSSL, a private key is a cryptographic key used in various security protocols,
including SSL/TLS for secure communication over the internet, digital signatures,
and encryption.
2. How do you extract the public key from a private key in OpenSSL?
You can extract the public key from a private key in OpenSSL using the openssl
command-line tool.
Suggested References:
1. OpenSSL - https://www.openssl.org/
2. GnuPG - https://gnupg.org/
3. Bouncy Castle - https://www.bouncycastle.org/
4. Keyczar - https://github.com/google/keyczar
5. Vault - https://www.vaultproject.io/
6. HashiCorp - https://www.hashicorp.com/
7. Apache Ranger - https://ranger.apache.org/
G.E.C Dahod 58
Distributed System (3170719) 200180107014
G.E.C Dahod 59