0% found this document useful (0 votes)
39 views8 pages

64 Prerna Jain Dspractassg11

The document describes a distributed railway reservation system that uses distributed file system (DFS) concepts. It provides details on the server and client programs for the system. The server program connects to a database, retrieves passenger details based on a PNR number received from the client, and sends the results back. The client program accepts user input for a PNR number and sends it to the server to check availability and retrieve details.

Uploaded by

Rahul Lavhande
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)
39 views8 pages

64 Prerna Jain Dspractassg11

The document describes a distributed railway reservation system that uses distributed file system (DFS) concepts. It provides details on the server and client programs for the system. The server program connects to a database, retrieves passenger details based on a PNR number received from the client, and sends the results back. The client program accepts user input for a PNR number and sends it to the server to check availability and retrieve details.

Uploaded by

Rahul Lavhande
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/ 8

PRACTICAL ASSIGNMENT NO.

- 11

TITLE​: Implement an application for railway reservation


system by using DFS concept in the Distributed
Environment.

ROLL NO._NAME -> 64_PRERNA JAIN

THEORY​:
Distributed File Systems:
Definition​: ​A distributed implementation of the time-sharing model of a file system
wherein multiple users share files and storage resources.

▪ ​A DFS manages a set of dispersed storage devices


▪ ​The overall storage space is composed of heterogeneous, remotely located,
smaller storage spaces.
▪ ​There is usually a correspondence between constituent storage spaces and sets
of files.

Distributed System Organizational Scheme:

▪ ​Service -​ ​a software entity running on one or more machines. A service


provides a particular type of function to a set of possibly unknown clients.
▪ ​Server ​- service software running on a single machine.
▪ ​Client ​- process that can invoke a service using a set of operations that forms
its client interface.

Distributed File System Requirements ​:

➢ ​Sharing files across nodes (processes,computers, networks) requires or benefits


from certain attributes of the system.
➢ ​Some attributes which are required or may be used as utility metrics for a DFS:

▪ ​naming
▪ ​transparency (works hand-in-hand with naming)
▪ ​concurrency (including synchronization)
▪ ​replication (caching, with consistency checks)
▪ ​platform independence (heterogeneity)
▪ ​fault tolerance
▪ ​consistency
▪ ​security
▪ ​efficiency

1)Naming

▪ ​Definition​:naming - ​mapping between logical and physical objects. ​▪


Definition​: multilevel mapping ​- abstraction of a file that hides the details of
how and where on the disk the file is actually stored.
▪ ​A transparent DFS hides the location where in the network the file is stored. ​▪
For a file being replicated in several sites, the mapping returns a set of the
locations of this file's replicas.

2)Definition​: location transparency ​- a file's name does not reveal the file's physical
storage location. A file name still denotes a specific, although hidden, set of physical
disk blocks.

3)Definition​: location independence ​- a file name does not need to be changed when
the file's physical storage location changes.

Naming Schemes:

Three Main Approaches

1. Files are named by a combination of their host name and local name;
guarantees a unique systemwide name.
2. Attach remote directories to local directories, giving the appearance of a
coherent directory tree; only previously mounted remote directories can be
accessed transparently
3. Total integration of the component file systems.

- A single global name structure spans all the files in the system.
- If a server is unavailable, some arbitrary set of directories on different
machines also becomes unavailable.

Architecture:
A DFS typically is built from an architecture with components similar to the
following:

Data access actions in DFS ​


Architecture of DFS

▪ ​flatfile service (unique file identifiers)


▪ ​directory service (mapping between text names and UFIDs)
▪ ​client modules (e.g., nfs clients)
▪ ​access control

Remote File Access

To reduce network traffic, remote access retains recently accessed disk blocks in a
cache, so that repeated accesses to the same information can be handled locally.

- If needed data not already cached, a copy of data is brought from the server to
the user.
- Accesses are performed on the cached copy.
- Files identified with one master copy residing at the server machine, but
copies of (parts of) the file are scattered in different caches.
- ​Cache-consistency problem ​- keeping the cached copies consistent with the
master file.
Location - Disk Caches vs. Main Memory Cache

▪ ​Advantages of disk caches

- More reliable.
- Cached data kept on disk are still there during recovery and don't need to be
fetched again.

▪ ​Advantages of main-memory caches:

- Permit workstations to be diskless.


- Data can be accessed more quickly.
- Performance speedup in bigger memories.
- Server caches (used to speed up disk I/O) are in main memory regardless of
where user caches are located;
using main-memory caches on the user machine permits a single caching
mechanism for servers and users.

Cache Update Policy

▪ ​Write-through -​ write data through to disk as soon as they are placed on any
cache. Reliable, but poor performance.
▪ ​Delayed-write ​- modifications written to the cache and then written through to
the server later. Write accesses complete quickly; some data may be
overwritten before they are written back, and so need never be written at all.

4)​ Consistency:

Cache consistency is a concern for all types of caching scenarios. This includes
processor cache, application cache (e.g., browsers), and distributed data caches.

the locally cached copy of the data consistent with the master copy? ​▪
▪ ​Is
Client-initiated approach

- Client initiates a validity check.


- Server checks whether the local data are consistent with the master
copy. ​▪ ​Server-initiated approach

- Server records, for each client, the (parts of) files it caches.
- When server detects a potential inconsistency, it reacts.

5) ​File Replication:

▪ ​Replicasof the same file reside on failure-independent machines. ​▪


Improves availability and can shorten service time.
▪ ​Naming scheme maps a replicated file name to a particular replica.

- Existence of replicas should be invisible to higher levels.


- Replicas must be distinguished from one another by different lower-level
names. ​Example ​- Sun Network File System (NFS)
PROGRAM​:

Server Side​: Trainserver.java:   


package ​com.railwayreservation.dfs;

import ​java.net.*;
import ​java.io.*;
import ​java.sql.*;
class ​Trainserver
{
public static void ​main(String ​args​[])
{
String ​Query​;
ResultSet ​rs ​= n ​ ull​;
String ​msg​;
int ​pnr ​= 0,​trainnum​= 0;
String ​from ​= ​new ​String();
String ​to ​= ​new ​String();
String ​date ​= ​new ​String();
String ​name ​= ​new ​String();
try
{
ServerSocket ​ser​=​new ​ServerSocket(8000);
System.​out. ​ println(​"Server Started..."​);
Socket ​soc​=​null​;
soc​=​ser​.accept();
System.​out. ​ println(​"Received Connection: "​+​soc​.getInetAddress().getHostAddress());
DataOutputStream ​out​=​new ​DataOutputStream(​soc​.getOutputStream()); BufferedReader
in ​= ​new ​BufferedReader(​new
InputStreamReader(​soc​.getInputStream()));
try​{
Class.​forName​(" ​ oracle.jdbc.driver.OracleDriver"​);
Connection
conn​=DriverManager.​getConnection( ​ ​"jdbc:oracle:thin:@localhost:1521:XE"​,​"hr"​,​"hr"​);
Statement ​stmt​=​conn​.createStatement();
msg ​= ​in​.readLine();
pnr ​= Integer.​parseInt​(​msg​);
Query ​= ​"Select * from train where pnrno = "​+​pnr​;
rs ​= ​stmt​.executeQuery(​Query​);
if​(​rs​.next())
{
pnr ​= Integer.​parseInt​(​rs​.getString(1));
from ​= r ​ s​.getString(2);
to ​= ​rs​.getString(3);
date ​= r ​ s​.getString(4);
name ​= r ​ s​.getString(5);
trainnum​=Integer.​parseInt( ​ r
​ s​.getString(6));
}
else
{
System.​out​.println(​""​);
}
}
catch​(SQLException ​e​)
{
System.​out​.println(​"Error Caught: "​+​e​);
}
out​.writeBytes(​""​.v ​ alueOf( ​ p​ nr​))
​ ;
out​.write(10);
out​.writeBytes(​from​);
out​.write(10);
out​.writeBytes(​to​);
out​.write(10);
out​.writeBytes(​date​);
out​.write(10);
out​.writeBytes(​name​);
out​.write(10);
out​.writeBytes(​""​.v ​ alueOf( ​ t​ rainnum​)​);
out​.write(10);
soc​.close();
}
catch​(Exception ​e​)
{
System.​out​.println(​"Error Caught: "​+​e​);
}
}
}

Client Side​: Traindbclient.java​:


package ​com.railwayreservation.dfs;

​ ava.io.*;
import j
import j​ ava.net.*;
class ​Traindbclient
{
public static void ​main(String ​args​[])
{
Socket ​objclient​= ​null​;
BufferedReader ​br ​= ​null​,​in ​= ​null​;
DataOutputStream ​out ​= n ​ ull​;
int ​pnr ​= 0;
try
{
objclient ​= ​new ​Socket(​"Localhost"​,8000);
in ​= ​new ​BufferedReader(​new ​InputStreamReader(​objclient​.getInputStream()));
br ​= ​new ​BufferedReader(​new
InputStreamReader(System.​in​));
out ​= ​new ​DataOutputStream(​objclient​.getOutputStream());
System.​out​.println(​"Enter the PNR NO: "​);
pnr ​= Integer.​parseInt( ​ ​br​.readLine());
out​.flush();
out​.writeBytes(​""​.v​ alueOf( ​ p
​ nr​))
​ ;
out​.write(10);
System.​out​.println(​"PNRNo:"​+​in​.readLine());
System.​out​.println(​"SOURCE :"​+i ​ n​.readLine());
System.​out​.println(​"DESTINATION: "​+​in​.readLine());
System.​out​.println(​"JOURNEY DATE: "​+​in​.readLine());
System.​out​.println(​"CUSTOMER NAME:"​+​in​.readLine());
System.​out​.println(​"TRAIN NO: "​+​in​.readLine());
objclient​.close();
}
catch​(Exception ​e​)
{
System.​out​.println(​"Error Caught: "​+​e​);
}
}
}

OUTPUT​: (CLIENT SIDE AND SERVER SIDE)


C

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy