Distributed System And Cloud Computing Journal_Abhishek
Distributed System And Cloud Computing Journal_Abhishek
CERTIFICATE
INDEX
Sr. Page
Title Date Signature
No. No.
WRITE A PROGRAM TO DEVELOP MULTI-CLIENT
SERVER APPLICATION WHERE MULTIPLE
1. 28-Sep-24 1-4
CLIENTS CHAT WITH EACH OTHER
CONCURRENTLY.
TO IMPLEMENT A SERVER CALCULATOR USING
2. 28-Sep-24 5-8
RPC CONCEPT.
WRITE A CLIENT-SERVER PROGRAM WHICH
3. DISPLAYS THE SERVER MACHINE'S DATE AND 06-Oct-24 9-10
TIME ON THE CLIENT MACHINE.
DEMONSTRATE A SAMPLE RMI JAVA
4. 06-Oct-24 11-13
APPLICATION.
BOOK INFORMATION FROM LIBRARY DATABASE
5. USING REMOTE OBJECT COMMUNICATION 06-Oct-24 14-17
CONCEPT.
ELECTRIC BILL DATABASE USING REMOTE
6. 06-Oct-24 18-21
OBJECT COMMUNICATION CONCEPT.
IMPLEMENTATION OF CLOUD COMPUTING
7. 06-Oct-24 22-28
SERVICES.
JAVA PROGRAM TO ILLUSTRATE HOW USER
8. 06-Oct-24 29
AUTHENTICATION IS DONE.
JAVA PROGRAM TO CHECK THE
9. 06-Oct-24 30
AUTHENTICATION OF THE USER.
Abhishek Dhuri I
MCA Sem 3 Distributed System and Cloud Computing
Code:
MultiThreadedSocketServer.java
import java.net.*;
try{
ServerSocket server = new ServerSocket(8888);
int counter = 0;
System.out.println("Server started...");
while (true){
counter++;
//SERVER ACCEPT THE CLIENT CONNECTION REQUEST
Socket serverClient = server.accept();
System.out.println(">> Client No.: " + counter + " started!!");
//SEND THE REQUEST TO SEPARATE THREAD
ServerClientThread sct = new ServerClientThread(serverClient, counter);
sct.start();
}
}
catch (Exception e){
System.out.println(e.getMessage());
}
}
}
ServerClientThread.java
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.net.Socket;
Abhishek Dhuri 1
MCA Sem 3 Distributed System and Cloud Computing
try{
DataInputStream inputStream = new
DataInputStream(serverClient.getInputStream());
DataOutputStream outputStream = new
DataOutputStream(serverClient.getOutputStream());
String clientMsg = "", serverMessage = "";
while(!clientMsg.equals("bye")){
clientMsg = inputStream.readUTF();
System.out.println("From Client: " + clientNo + " : Number is: " + clientMsg);
square = Integer.parseInt(clientMsg) * Integer.parseInt(clientMsg);
serverMessage = "From Server to Client: " + clientNo + " : Square of " +
clientMsg + " is " + square;
outputStream.writeUTF(serverMessage);
outputStream.flush();
}
inputStream.close();
outputStream.close();
serverClient.close();
}
catch (Exception e){
System.out.println(e.getMessage());
}
finally {
System.out.println(">> Client: " + clientNo + " exit!!");
}
}
}
Abhishek Dhuri 2
MCA Sem 3 Distributed System and Cloud Computing
TCPClient.java
import java.io.*;
import java.net.Socket;
try {
Socket socket = new Socket("127.0.0.1", 8888);
DataInputStream inputStream = new DataInputStream(socket.getInputStream());
DataOutputStream outputStream = new
DataOutputStream(socket.getOutputStream());
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
String clientMsg = "";
String serverMsg = "";
while (!clientMsg.equals("bye"))
{ System.out.print("Enter Number: ");
clientMsg = br.readLine();
outputStream.writeUTF(clientMsg);
outputStream.flush();
serverMsg = inputStream.readUTF();
System.out.println(serverMsg);
}
outputStream.close();
outputStream.close();
socket.close();
}
catch (Exception e){
System.out.println(e.getMessage());
}
}
}
Abhishek Dhuri 3
MCA Sem 3 Distributed System and Cloud Computing
Output:
Abhishek Dhuri 4
MCA Sem 3 Distributed System and Cloud Computing
Code:
RPCServer.java
import java.net.*;
import java.util.StringTokenizer;
DatagramSocket ds;
DatagramPacket dp;
String str, methodName, result;
int val1, val2;
RPCServer() {
try {
ds = new DatagramSocket(1200);
byte b[] = new byte[4096];
while (true) {
dp = new DatagramPacket(b, b.length);
ds.receive(dp);
str = new String(dp.getData(), 0, dp.getLength());
if (str.equalsIgnoreCase("q")) {
System.exit(1);
} else {
StringTokenizer st = new StringTokenizer(str, " ");
int i = 0;
while (st.hasMoreTokens())
{ String token =
st.nextToken(); methodName
= token;
val1 = Integer.parseInt(st.nextToken());
val2 = Integer.parseInt(st.nextToken());
}
}
System.out.println(str);
InetAddress ia = InetAddress.getLocalHost();
if (methodName.equalsIgnoreCase("add")) {
result = "" + add(val1, val2);
} else if (methodName.equalsIgnoreCase("sub")) {
result = "" + sub(val1, val2);
} else if (methodName.equalsIgnoreCase("mul")) {
result = "" + mul(val1, val2);
Abhishek Dhuri 5
MCA Sem 3 Distributed System and Cloud Computing
} else if (methodName.equalsIgnoreCase("div")) {
result = "" + div(val1, val2);
}
byte b1[] = result.getBytes();
DatagramSocket ds1 = new DatagramSocket();
DatagramPacket dp1 = new
DatagramPacket(b1, b1.length, InetAddress.getLocalHost(), 1300);
System.out.println("result : " + result + "\n");
ds1.send(dp1);
}
} catch (Exception e) {
e.printStackTrace();
}
}
RPCClient.java
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
import java.net.*;
{ RPCClient() {
Abhishek Dhuri 6
MCA Sem 3 Distributed System and Cloud Computing
try {
InetAddress ia = InetAddress.getLocalHost();
DatagramSocket ds = new DatagramSocket();
DatagramSocket ds1 = new DatagramSocket(1300);
System.out.println("\nRPC Client\n");
System.out.println("Enter method name and parameter like add 3 4");
while (true) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
byte b[] = str.getBytes();
DatagramPacket dp = new
DatagramPacket(b, b.length, ia, 1200);
ds.send(dp);
dp = new DatagramPacket(b, b.length);
ds1.receive(dp);
String s = new String(dp.getData(), 0, dp.getLength()); System.out.println("\
nResult = " + s + "\n");
}
} catch (Exception e) {
e.printStackTrace();
}
}
Abhishek Dhuri 7
MCA Sem 3 Distributed System and Cloud Computing
Output:
Abhishek Dhuri 8
MCA Sem 3 Distributed System and Cloud Computing
Code:
DateClient.java
import java.io.*;
import java.net.*;
DateServer.java
import java.net.*;
import java.io.*;
import java.util.*;
Abhishek Dhuri 9
MCA Sem 3 Distributed System and Cloud Computing
Output:
Abhishek Dhuri 10
MCA Sem 3 Distributed System and Cloud Computing
Code:
Hello.java
import java.rmi.Remote;
import java.rmi.RemoteException;
Server.java
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
Abhishek Dhuri 11
MCA Sem 3 Distributed System and Cloud Computing
Client.java
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
private Client() {
}
ImplExample.java
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
@Override
public void printMsg() throws RemoteException
{ System.out.println("This is an example RMI program");
}
}
Abhishek Dhuri 12
MCA Sem 3 Distributed System and Cloud Computing
Output:
Abhishek Dhuri 13
MCA Sem 3 Distributed System and Cloud Computing
Code:
Library.java
import java.io.Serializable;
Hello.java
import java.rmi.Remote;
import java.util. * ;
Abhishek Dhuri 14
MCA Sem 3 Distributed System and Cloud Computing
ImplExample.java
import java.sql.*;
import java.util.*;
@Override
public List<Library> getBookInfo() throws Exception {
while (rs.next()) {
int id = rs.getInt("Book_id");
String name = rs.getString("Book_name");
String author = rs.getString("Book_author");
Library info = new Library();
info.setBookID(id);
info.setBookName(name);
info.setBookAuthor(author);
list.add(info);
}
rs.close();
return list;
}
Abhishek Dhuri 15
MCA Sem 3 Distributed System and Cloud Computing
Server.java
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
Client.java
import
java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.List;
Abhishek Dhuri 16
MCA Sem 3 Distributed System and Cloud Computing
} catch (Exception e) {
System.err.println("Client exception: " + e.toString());
e.printStackTrace();
}
}
}
Output:
Abhishek Dhuri 17
MCA Sem 3 Distributed System and Cloud Computing
Code:
Electric.java
public class Electric implements java.io.Serializable {
Hello.java
import java.rmi.Remote;
import java.util.List;
Abhishek Dhuri 18
MCA Sem 3 Distributed System and Cloud Computing
ImplExample.java
import java.sql.*;
import java.util.*;
Class.forName("com.mysql.cj.jdbc.Driver");
System.out.println("Connecting to a selected database...");
conn = DriverManager.getConnection(DB_URL, USER, PASS);
System.out.println("Connected database successfully...");
System.out.println("Creating statement...");
stmt = conn.createStatement();
String sql = "SELECT * FROM electricbill";
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()) {
float amount = rs.getFloat("BillAmount");
String name = rs.getString("ConsumerName");
String Date = rs.getString("BillDuedate");
Electric info = new Electric();
info.setBillAmount(amount);
info.setCustomerName(name);
info.setBillDueDate(Date);
list.add(info);
}
rs.close();
return list;
}
}
Abhishek Dhuri 19
MCA Sem 3 Distributed System and Cloud Computing
Server.java
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
Client.java
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.util.List;
Abhishek Dhuri 20
MCA Sem 3 Distributed System and Cloud Computing
} catch (Exception e) {
System.err.println("Client exception: " + e.toString());
e.printStackTrace();
}
}
}
Output:
Abhishek Dhuri 21
MCA Sem 3 Distributed System and Cloud Computing
A storage account is an Azure Resource Manager resource. Resource Manager is the deployment
and management service for Azure. For more information, see Azure Resource Manager
overview.
https://k21academy.com/microsoft-azure/create-free-microsoft-azure-trial-account/
https://azure.microsoft.com/en-in/free/students/
Abhishek Dhuri 22
MCA Sem 3 Distributed System and Cloud Computing
1. From the left portal menu, select Storage accounts to display a list of your storage
accounts. If the portal menu isn't visible, click the menu button to toggle it on.
Abhishek Dhuri 23
MCA Sem 3 Distributed System and Cloud Computing
Tutorial: Deploy Node.js app to Azure Web App using DevOps Starter for GitHub Actions
DevOps Starter creates a workflow in GitHub. You can use an existing GitHub organization.
DevOps Starter also creates Azure resources such as Web App in the Azure subscription of your
choice.
Abhishek Dhuri 24
MCA Sem 3 Distributed System and Cloud Computing
Abhishek Dhuri 25
MCA Sem 3 Distributed System and Cloud Computing
Abhishek Dhuri 26
MCA Sem 3 Distributed System and Cloud Computing
Software as a service (SaaS) allows users to connect to and use cloud based apps over the
Internet. Common examples are email, calendaring and office tools (such as Microsoft Office
365).
To manage your web app, go to the Azure portal, and search for and select App Services.
On the App Services page, select the name of your web app.
Abhishek Dhuri 27
MCA Sem 3 Distributed System and Cloud Computing
The Overview page for your web app, contains options for basic management like browse, stop,
start, restart, and delete. The left menu provides further pages for configuring your app.
Abhishek Dhuri 28
MCA Sem 3 Distributed System and Cloud Computing
Code:
UserAuthentication.java
import java.util.Scanner;
Output:
Abhishek Dhuri 29
MCA Sem 3 Distributed System and Cloud Computing
Code:
AuthenticationOfUser.java
public class AuthenticationOfUser {
public static void main(String[] args)
{ String userName = "Uday Bhai";
String password = "Aalu Kanda";
if(userName.equals("Uday Bhai") && password.equals("Aalu Kanda"))
System.out.println("Authentication Successful!!");
else
System.out.println("Username/Password not matching");
}
}
Output:
AuthenticationOfUser.java
public class AuthenticationOfUser {
public static void main(String[] args)
{ String userName = "Uday Bhai";
String password = "Alu Kanda";
if(userName.equals("Uday Bhai") && password.equals("Aalu Kanda"))
System.out.println("Authentication Successful!!");
else
System.out.println("Username/Password not matching");
}
}
Output:
Abhishek Dhuri 30
MCA Sem 3 Distributed System and Cloud Computing
Code:
LoginForm.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
{ JButton b1;
JPanel newPanel;
JLabel userLabel, passLabel;
final JTextField textField1, textField2;
LoginForm()
{
userLabel = new JLabel();
userLabel.setText("Username");
textField1 = new JTextField(15);
passLabel = new JLabel();
passLabel.setText("Password");
textField2 = new JPasswordField(15);
b1 = new JButton("SUBMIT");
newPanel = new JPanel(new GridLayout(3, 1));
newPanel.add(userLabel);
newPanel.add(textField1);
newPanel.add(passLabel);
newPanel.add(textField2);
newPanel.add(b1);
add(newPanel, BorderLayout.CENTER);
b1.addActionListener(this);
setTitle("LOGIN FORM");
}
public void actionPerformed(ActionEvent ae)
{
String userValue = textField1.getText();
String passValue = textField2.getText();
if (userValue.equals("[email protected]") && passValue.equals("test"))
{
NewPage page = new NewPage();
page.setVisible(true);
JLabel wel_label = new JLabel("Welcome: "+userValue);
Abhishek Dhuri 31
MCA Sem 3 Distributed System and Cloud Computing
page.getContentPane().add(wel_label);
}
else{
System.out.println("Please enter valid username and password");
}
}
}
class LoginFormDemo
{
public static void main(String arg[])
{
try
{
LoginForm form = new LoginForm();
form.setSize(300,100);
form.setVisible(true);
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e.getMessage());
}
}
}
NewPage.java
import
javax.swing.*;
Abhishek Dhuri 32
MCA Sem 3 Distributed System and Cloud Computing
Output:
Abhishek Dhuri 33
MCA Sem 3 Distributed System and Cloud Computing
Code:
ColorChange.html
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></
script>
</head>
<body style="text-align: center;" id="body">
<h1>Enter Your Color Choice</h1>
<button type="button" onclick="changecolor()">
Color
</button>
<script>
function changecolor() {
// Generating random color each time
var color = "#" + ((Math.random() * 16777215) | 0).toString(16);
$("body").css("background-color", color);
}
</script>
</body>
</html>
Output:
Abhishek Dhuri 34