Sie sind auf Seite 1von 60

A PROXIMITY-AWARE INTEREST-CLUSTERED P2P FILE SHARING

SYSTEM

ABSTRACT
Efficient file query is important to the overall performance of peer-to-peer (P2P)
file sharing systems. Clustering peers by their common interests can significantly
enhance the efficiency of file query. Clustering peers by their physical proximity
can also improve file query performance. However, few current works are able to
cluster peers based on both peer interest and physical proximity. Although
structured P2Ps provide higher file query efficiency than unstructured P2Ps, it is
difficult to realize it due to their strictly defined topologies. Proximity-Aware and
Interest-clustered P2P file sharing System (PAIS) is proposed, which is based on a
structured P2P, which forms physically-close nodes into a cluster and further
groups physically-close and common-interest nodes into a subcluster based on a
hierarchical topology. PAIS uses an intelligent file replication algorithm to further
enhance file query efficiency. It creates replicas of files that are frequently
requested by a group of physically close nodes in their location. PAIS enhances the
intra-sub-cluster file searching through several approaches. First, it further
classifies the interest of a sub-cluster to a number of sub-interests, and clusters
common-sub-interest nodes into a group for file sharing. Second, PAIS builds an
overlay for each group that connects lower capacity nodes to higher capacity nodes
for distributed file querying while avoiding node overload. Third, to reduce file
searching delay, PAIS uses proactive file information collection so that a file
requester can know if its requested file is in its nearby nodes. Fourth, to reduce the
overhead of the file information collection, PAIS uses bloom filter based file
information collection and corresponding distributed file searching. Fifth, to
improve the file sharing efficiency, PAIS ranks the bloom filter results in order.
Sixth, considering that a recently visited file tends to be visited again, the bloom

filter based approach is enhanced by only checking the newly added bloom filter
information to reduce file searching delay.

INTRODUCTION
Over the past few years, the immense popularity of the Internet has produced a
significant stimulus to P2P file sharing systems. For example, BitTorrent
constitutes roughly 35% of all traffic on the Internet. There are two classes of P2P
systems: unstructured and structured. Unstructured P2P networks such as Gnutella
and Freenet do not assign responsibility for data to specific nodes. Nodes join and
leave the network according to some loose rules. Currently, unstructured P2P
networks file query method is based on either flooding where the query is
propagated to all the nodes neighbors, or random-walkers where the query is
forwarded to randomly chosen neighbors until the file is found.
However, flooding and random walkers cannot guarantee data location. Structured
P2P networks, i.e. Distributed Hash Tables (DHTs), can overcome the drawbacks
with their features of higher efficiency, scalability, and deterministic data location.
They have strictly controlled topologies, and their data placement and lookup
algorithms are precisely defined based on a DHT data structure and consistent
hashing function. The node responsible for a key can always be found even if the
system is in a continuous state of change.

EXISTING SYSTEM
A key criterion to judge a P2P file sharing system is its file location efficiency.
Super-peer topology
Super-peer topology consists of supernodes with fast connections and
regular nodes with slower connections. A supernode connects with other
supernodes and some regular nodes, and a regular node connects with a
supernode. The nodes at the center of the network are faster and therefore
produce a more reliable and stable backbone. This allows more messages to
be routed than a slower backbone and, therefore, allows greater scalability.
Super-peer networks occupy the middle-ground between centralized and
entirely symmetric P2P networks, and have the potential to combine the
benefits of both centralized and distributed searches.
Disadvantages
A logical proximity abstraction derived from a P2P system does not
necessarily match the physical proximity information in reality.
The shortest path according to the routing protocol is not necessarily the
shortest physical path.
This mismatch becomes a big obstacle for the deployment and performance
optimization of P2P file sharing systems.

Proximity-aware clustering
This can be used to group physically close peers to effectively improve
efficiency. The third class of methods to improve file location efficiency is to
cluster nodes with similar interests, which reduce the file location latency.
Disadvantages
Only few methods are able to cluster peers according to both proximity and
interest
In addition, most of these methods are on unstructured P2P systems that
have no strict policy for topology construction.
They cannot be directly applied to general DHTs in spite of their higher file
location efficiency.

PROPOSED SYSTEM
A Proximity-Aware and Interest clustered P2P file sharing System (PAIS) on
a structured P2P system.
It forms physically-close nodes into a cluster and further groups physicallyclose and common interest nodes into a sub-cluster.
It also places files with the same interests together and make them accessible
through the DHT Lookup() routing function.
It creates replicas of files that are frequently requested by a group of
physically close nodes in their location.
Advantages
Relying on DHT lookup policy rather than broadcasting, the PAIS
construction consumes much less cost in mapping nodes to clusters and
mapping clusters to interest sub-clusters.
PAIS uses an intelligent file replication algorithm to further enhance file
lookup efficiency.
PAIS enhances the intra-sub-cluster file searching through several
approaches.
First, it further classifies the interest of a sub-cluster to a number of
subinterests, and clusters common-sub-interest nodes into a group for file
sharing.

Second, PAIS builds an overlay for each group that connects lower capacity
nodes to higher capacity nodes for distributed file querying while avoiding
node overload.
Third, to reduce file searching delay, PAIS uses proactive file information
collection so that a file requester can know if its requested file is in its
nearby nodes.
Fourth, to reduce the overhead of the file information collection, PAIS uses
bloom filter based file information collection and corresponding distributed
file searching.
Fifth, to improve the file sharing efficiency, PAIS ranks the bloom filter
results in order.
Sixth, considering that a recently visited file tends to be visited again, the
bloom filter based approach is enhanced by only checking the newly added
bloom filter information to reduce file searching delay.

ENHANCEMENT
In the proposed work, file distribution is done between the peers by FILEID and
FILE. The proposed work can be enhanced to provide more user specific search
such as file name and his sub interest. Thus the requester will get his specific file
of his interest. Also this reduces query latency. We can compare the query
processing time, in our enhancement, the query processing time can be reduced
considerably and also the users satisfaction on his interest file reply.

APPLICATIONS USED
Although this work is for P2P file sharing systems, the techniques proposed in this
paper can benefit many current applications such as content delivery networks, P2P
video-on-demand systems, and data sharing in online social networks. Since the
architecture of PAIS is based on a structured P2P system, its architecture cannot be
used for unstructured P2P systems. However, PAISs techniques for enhance
efficiency of the intra-subcluster file searching can be used for unstructured P2P
systems since nodes in a intra-sub-cluster are connected in an unstructured manner.

LITERATURE SUMMARY
Super-peer topology
FastTrack and Morpheus use super-peer topology. The super-peer network is for
efficient and scalable file consistency maintenance in structured P2P systems.
Garbacki et al. proposed a self-organizing super-peer network architecture that
solves four issues in a fully decentralized manner: how client peers are related to
super-peers, how super-peers locate files, how the load is balanced among the
super-peers, and how the system deals with node failures.
Mitra et al. developed an analytical framework, which explains the emergence of
super-peer networks on execution of the commercial P2P bootstrapping protocols
by incoming nodes.
Chordella is a P2P system that is particularly designed for heterogeneous
environments such as wireless networks.
Sachez-Artigaz et al. investigated the feasibility of super-peer ratio maintenance, in
which each peer can decide to be a super-peer independently of each other.
Liu et al. proposed a hierarchical secure load balancing scheme in a P2P cloud
system. It first balances the load among supernodes, and then depends on each
supernode to balance the load among nodes under its management.
Garbacki et al. proposed a self-organizing supernode architecture to facilitate file
querying. Each supernode caches the files recently requested by its children, and
other peers send requests to the supernodes that can solve most of their requests.

Proximity-awareness
Techniques to exploit topology information in P2P overlay routing include
geographic layout, proximity routing, and proximity-neighbor selection.
Genaud et al. proposed a P2P-based middleware for locality-aware resource
discovery.
Some of the work measured the inter-ISP traffic in BitTorrent and indicated the
importance of locality-awareness traffic in reducing the traffic over long-distance
connections.
Guo et al. examined traffic locality in PPLive and revealed that PPLive achieves
high ISP level traffic locality.
Shen and Hwang proposed a locality-aware architecture with resource clustering
and discovery algorithms for efficient and robust resource location in wide-area
distributed grid systems.
Lehrieder et al. studied locality-awareness in scenarios with real-life, skewed peer
distributions and heterogeneous access bandwidths of peers.
Yang et al. combined the structured and unstructured overlays with proximityawareness for P2P networks to ensure the availability of searching results.
Gross et al. proposed a BitTorrent-like downloading scheme with locality-aware
file searching and replication in order to supply a robust and fast downloading.
Manzillo et al. proposed the collaborative locality aware overlay service, which
reduces the transmit cost of ISPs by switching to the source inside the same ISP
with the requester. Interest-base file sharing.

Hang et al. proposed a method for clustering peers that share similar properties
together and a new intelligent query routing strategy.
Crespo et al. proposed a semantic overlay network (SON) based on the semantic
relations among peers.
Ruffo and Schifanella studied the spontaneous communities of users in P2P file
sharing applications and found that a family of structures show self-organized
interest-based clusters.
Iamnitchi et al. found the small world pattern in the interest-sharing community
graphs, and suggested clustering common-interest nodes to improve file searching
efficiency. Some works leverage the social network common-interest property for
efficient file searching.
Cheng et al. proposed NetTube for P2P short video sharing. It clusters users with
the same interests together for efficient peer assisted video delivering.
Li et al. proposed a P2P file sharing system based on social networks, in which
common multi- interest nodes are grouped into a cluster and are connected based
on social relationship.
Lin et al. proposed a social based P2P assisted video sharing system through
friends and acquaintances.
Li et al. grouped users by interests for efficient file querying and used the relevant
judgment of a file to a query to facilitate subsequent same queries.
Liu et al. proposed online storage systems with peer assistance.

HARDWARE REQUIREMENTS
Processor

: Any Processor above 500 MHz.

Ram

: 128Mb.

Hard Disk

: 10 Gb.

Compact Disk

: 650 Mb.

Input device

: Standard Keyboard and Mouse.

Output device

: VGA and High Resolution Monitor.

SOFTWARE SPECIFICATION
Operating System

: Windows Family.

Pages developed using : Java Swing


Techniques
Database

: JDK 1.5 or higher


: MySQL 5.0

SOFTWARE DESCRIPTION:

JAVA
Java is an object-oriented multithread programming languages .It is designed
to be small, simple and portable across different platforms as well as operating
systems.

FEATURES OF JAVA

Platform Independence

The Write-Once-Run-Anywhere ideal has not been achieved (tuning for


different platforms usually required), but closer than with other languages.

Object Oriented

Object oriented throughout - no coding outside of class definitions,


including main().

An extensive class library available in the core language packages.

Compiler/Interpreter Combo

Code is compiled to byte codes that are interpreted by a Java virtual


machines (JVM).

This provides portability to any machine for which a virtual machine has
been written.

The two steps of compilation and interpretation allow for extensive code
checking and improved security.

Robust

Exception handling built-in, strong type checking (that is, all data must be
declared an explicit type), local variables must be initialized.

Several features of C & C++ eliminated:

No memory pointers

No preprocessor

Array index limit checking

Automatic Memory Management

Automatic garbage collection - memory management handled by JVM.

Security

No memory pointers

Programs run inside the virtual machine sandbox.

Array index limit checking

Code pathologies reduced by


o

Byte code verifier - checks classes after loading

Class loader - confines objects to unique namespaces. Prevents


loading a hacked "java.lang.SecurityManager" class, for example.

Security manager - determines what resources a class can access such


as reading and writing to the local disk.

Dynamic Binding

The linking of data and methods to where they are located is done at runtime.

New classes can be loaded while a program is running. Linking is done on


the fly.

Even if libraries are recompiled, there is no need to recompile code that uses
classes in those libraries.

This differs from C++, which uses static binding. This can result in fragile
classes for cases where linked code is changed and memory pointers then
point to the wrong addresses.

Good Performance

Interpretation of byte codes slowed performance in early versions, but


advanced virtual machines with adaptive and just-in-time compilation and
other techniques now typically provide performance up to 50% to 100% the
speed of C++ programs.

Threading

Lightweight processes, called threads, can easily be spun off to perform


multiprocessing.

Can take advantage of multiprocessors where available

Great for multimedia displays.

Built-in Networking

Java was designed with networking in mind and comes with many classes to
develop sophisticated Internet communications.

IMP applications are called IMlets, but in reality they are MIDlets. They subclass
MIDlet, and follow the same packaging, deployment, security and life-cycle as
MIDlets.
Connected Device Configuration
CDC is a smaller subset of Java SE, containing almost all the libraries that are not
GUI related.
Foundation Profile
A headless version of Java SE.
Personal Basis Profile
Extends the Foundation Profile to include lightweight GUI support in the form of
an AWT subset.
Personal Profile
This extension of Personal Basis Profile includes a more comprehensive AWT
subset and adds applet support.

Net Beans

Net Beans A Java-based development environment (IDE) and platform


originally developed by Sun. It includes user interface functions, source code

editor, GUI editor, version control as well as support for distributed applications
(CORBA,

RMI,

etc.)

and

Web

applications

(JSPs,

servlets,

etc.).

In 1999, Sun acquired NetBeans Developer from NetBeans and rebranded it as


Forte for Java Community Edition (Sun acquired Forte in 1999). In 2000, Sun
made the NetBeans IDE open source.

1. GUI: The major requirement of todays developers is to have a good User


Interface for their users. They can provide whatever functionality they need but its
the GUI that lets the user better know the existence of that particular functionality
and its easier for them to click and select than type something on a black boring
screen. Thus, todays developers need IDEs such as netbeans that develop ready
made windows forms with all the required buttons, labels, text boxes and like that
can

be

tailor

made

for

the

program

in

question.

2. Database Integration: Database based program developers know how hard it is


to interface your back-end database to your front-end program. This is where
netbeans packs the punch by providing you a CRUD(create, Read, Update, Delete)
application shell.

MySQL
MySQL is a relational database management system (RDBMS) that runs as a server providing
multi-user access to a number of databases. It is named after developer Michael Widenius'
daughter, My. The SQL phrase stands for Structured Query Language.

The MySQL development project has made its source code available under the terms of the GNU
General Public License, as well as under a variety of proprietary agreements. MySQL was
owned and sponsored by a single for-profit firm, the Swedish company MySQL AB, now owned
by Oracle Corporation.

Free-software-open source projects that require a full-featured database management system


often use MySQL. For commercial use, several paid editions are available, and offer additional
functionality. Applications which use MySQL databases include: TYPO3, Joomla, WordPress,
phpBB, Drupal and other software built on the LAMP software stack.

Features
MySQL offered MySQL 5.1 in two different variants: the open source MySQL Community
Server and the commercial Enterprise Server. MySQL 5.5 is offered under the same licences.
They have a common code base and include the following features:

* A broad subset of ANSI SQL 99, as well as extensions


* Cross-platform support
* Stored procedures
* Triggers
* Cursors
* Updatable Views
* True Varchar support
* Information schema
* Strict mode[further explanation needed]

* X/Open XA distributed transaction processing (DTP) support; two phase commit as part of
this, using Oracle's InnoDB engine
* Independent storage engines (MyISAM for read speed, InnoDB for transactions and
referential integrity, MySQL Archive for storing historical data in little space)
* Transactions with the InnoDB, and Cluster storage engines; savepoints with InnoDB
* SSL support
* Query caching
* Sub-SELECTs (i.e. nested SELECTs)
* Replication support (i.e. Master-Master Replication & Master-Slave Replication) with one
master per slave, many slaves per master, no automatic support for multiple masters per slave.
* Full-text indexing and searching using MyISAM engine
* Embedded database library
* Partial Unicode support (UTF-8 and UCS-2 encoded strings are limited to the BMP)
* ACID compliance when using transaction capable storage engines (InnoDB and Cluster)[28]
* Partititoned tables with pruning of partitions in optimiser
* Shared-nothing clustering through MySQL Cluster
* Hot backup (via mysqlhotcopy) under certain conditions

SYSTEM ARCHITECTURE

Intra-cluster
query process

Cluster
1
Peer1

query

Intercluster
query
process

query

reply

Peer2

Cluster
1
Peer3
reply

reply
query

Peer4

MODULES
PAIS Construction and Maintenance
File Distribution
File Querying Algorithm
File replication

PAIS Construction and Maintenance


A landmarking method can be used to represent node closeness on the network by
indices. Landmark clustering has been widely adopted to generate proximity
information. It is based on the intuition that nodes close to each other are likely to
have similar distances to a few selected landmark nodes. It is represented that
cluster1, cluster2 for landmark.
Consistent hash functions such as SHA-1 is widely used in DHT networks for node
or file ID due to its collision-resistant nature. When using such a hash function, it
is computationally infeasible to find two different messages that produce the same
message digest. The consistent hash function is effective to cluster messages based
on message difference. Peer nodes are assigned with a Hash key.
File Distribution
As physically close and common-interest nodes form a subcluster, they can share
files between each other so that a node can retrieve its requested file in its interest
from a physically close node. For this purpose, the sub-cluster server maintains the

index of all files in its sub-cluster for file sharing among nodes in its sub-cluster. A
nodes requested file may not exist in its sub-cluster. To help nodes find files not
existing in their sub-clusters, as in traditional DHT networks, PAIS re-distributes
all files among nodes in the network for efficient global search.

File Querying Algorithm


The file querying algorithm has several stages: intra-cluster searching (consisting
of intra-sub-cluster searching and inter-sub-cluster searching) and inter-cluster
searching. If the intra-sub-cluster searching fails, PAIS relies on inter-sub-cluster
searching. If the inter-sub-cluster searching fails, it will depend on DHT routing for
file searching.
When node I wants to retrieve a file, if the files key is one of the requesters
interest attributes, it uses the intra-subcluster searching. Node I sends the request to
its server in the sub-cluster of the interest. Recall that the server maintains the
index of all files in its sub-cluster. Every time a server receives a request, it checks
if its sub-cluster has the requested file. If yes, the server sends the file location to
the requester directly.

File replication
A threshold is maintained for file access. If the file is access frequency is equal or
higher than the threshold, then the file is replicated with that peer. Replicated data
is stored in peer. If the same query is given by any other peer from the same
cluster, then the query is processed as inter cluster query.

DATA FLOW DIAGRAM


Level 0

Peer

Register

node

Level 1

Peer

Search
query

infodetai
ls

Query
process

Peer

Query
reply

searc
h

Level 2

Peer

Query

Check
freque
ncy

Data
replicati
on

peerna
me

UML DIAGRAM
USE CASE DIAGRAM

Current location

Issue Query

Query search

Query result

Data replication

SEQUENCE DIAGRAM

Peer

Peer

Proxy

Server

Submit
location
query

Query process
Reply user
Send to
server
Data
replication

COLLABORATION DIAGRAM

1: query

Peer

5:data

Replicatio
n

proxy

3:
process

Server

4:
reply

Peer
Cluster
search

ACTIVITY DIAGRAM

Peer

Query

Intercluster

Intracluster

Result

Peer

SAMPLE SOURCE CODE


ProxyDesign.java
package com.Design;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.ObjectOutputStream;
import javax.swing.*;
import
import
import
import
import
import
import
import
import

javax.swing.JButton;
javax.swing.JFrame;
javax.swing.JLabel;
javax.swing.JOptionPane;
javax.swing.JRadioButton;
javax.swing.JScrollPane;
javax.swing.JTable;
javax.swing.JTextField;
javax.swing.table.DefaultTableModel;

import
import
import
import
import
import
import

com.database.RetrieveQuery;
com.logic.Details;
com.logic.ProxyServer;
com.logic.SocketConnection;
com.serial.ClientInfo;
com.serial.ProxyInfo;
com.serial.SourceRes;

public class ProxyDesign extends JFrame implements ActionListener


{
public static DefaultTableModel defaultBulk=null;
public static DefaultTableModel defaultTableModel=null;
private JScrollPane jScrollBulk=null;
private static JTable jTableBulk=null;
private JTable jTable=null;
private JScrollPane jScrollPane=null;
private ProxyServer proxyServer=null;
private JRadioButton bulkButton=null;
private JRadioButton progressButton=null;
private JButton processButton=new JButton("Proceed");
private String process="";
private String[] det=null;
private Details details=null;
private SocketConnection socketConnection=null;
public static String requestStr="";
public static String categoryStr="";
public static String regionStr="";
public static String nodeIdStr="";
public static String lbsPort="";
public static String lbsSys="";
public static String sourePort="";
public static String soureSys="";

private static JLabel jLabelBuk=null;


public static DefaultTableModel defaultProgress=null;
private static JTable jTableProgress=null;
private JScrollPane jScrollProgress=null;
private JLabel jLabelProgress=null;
public ProxyDesign()
{
setTitle("QueryPorcessing");
jLabelBuk=new JLabel("Bulk Process :");
jLabelProgress=new JLabel("Progress Process :");
jScrollBulk=new JScrollPane();
defaultBulk=new DefaultTableModel();
jTableBulk=new JTable(defaultBulk);
defaultProgress=new DefaultTableModel();
jTableProgress=new JTable(defaultProgress);
jScrollProgress=new JScrollPane(jTableProgress);
socketConnection=new SocketConnection();
details=new Details();
det=details.Config("lbsPort", "lbsSys");
lbsPort=det[0];
lbsSys=det[1];
proxyServer=new ProxyServer();
setLayout(null);
bulkButton=new JRadioButton("Bulk Process");
progressButton=new JRadioButton("Progressive Process");
defaultTableModel=new DefaultTableModel();
jTable=new JTable(defaultTableModel);
defaultTableModel.addColumn("Sub-Interest");
defaultTableModel.addColumn("Interest");
defaultTableModel.addColumn("Peer Name");
defaultTableModel.addColumn("Cluster");
defaultTableModel.addColumn("Status");
defaultBulk.addColumn("Sub-Interest");
defaultBulk.addColumn("Interest");
defaultBulk.addColumn("PeerName");
defaultProgress.addColumn("Sub-Interest");
defaultProgress.addColumn("Interest");
defaultProgress.addColumn("PeerName");
jScrollBulk=new JScrollPane(jTableBulk);
jScrollProgress=new JScrollPane(jTableProgress);
jScrollPane=new JScrollPane(jTable);
jLabelBuk.setBounds(560, 100, 100, 30);
jLabelProgress.setBounds(560, 300, 120, 30);
jScrollBulk.setBounds(560, 150, 250, 150);
jScrollProgress.setBounds(560, 350, 250, 150);
processButton.setBounds(480, 550, 100, 30);
jScrollPane.setBounds(10, 20, 500, 500);
bulkButton.setBounds(500, 20, 120, 30);
progressButton.setBounds(550, 70, 150, 30);
bulkButton.addActionListener(this);
progressButton.addActionListener(this);
processButton.addActionListener(this);
//add(jLabelProgress);
//add(jScrollProgress);
//add(jLabelBuk);
//add(jScrollBulk);
add(processButton);

//add(bulkButton);
//add(progressButton);
add(jScrollPane);
setSize(600, 700);
setVisible(true);
}
public static void main(String[] args)
{
try {
UIManager.setLookAndFeel("com.easynth.lookandfeel.EaSynthLookAndFeel");
} catch (Exception e) {
e.printStackTrace();
}
ProxyDesign proxyDesign=new ProxyDesign();
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==bulkButton)
{
progressButton.setSelected(false);
System.out.println(process);
}
if(e.getSource()==progressButton)
{
bulkButton.setSelected(false);
process=progressButton.getText();
System.out.println(process);
}
if(e.getSource()==processButton)
{
try
{
process=bulkButton.getText();
System.out.println(process);
System.out.println("*********");
System.out.println(categoryStr);
System.out.println(requestStr);
System.out.println(regionStr);
det=details.Config("port", "proxy");
String proxyPort=det[0];
String proxySys=det[1];
System.out.println("*********");
RetrieveQuery retrieveQuery=new RetrieveQuery();
String
output=retrieveQuery.CacheFetch(categoryStr,requestStr,regionStr,nodeIdStr);
System.out.println("full output..."+output);
if(output.equals(":"))
{
ProxyInfo proxyInfo=new ProxyInfo(requestStr,
categoryStr, regionStr,
nodeIdStr,process,sourePort,soureSys,proxyPort,proxySys,process);
ObjectOutputStream
objectOutputStream=socketConnection.SocketSend(lbsPort, lbsSys);
objectOutputStream.writeObject(proxyInfo);

}
else
{

objectOutputStream.close();

for(int
count=0;count<defaultTableModel.getRowCount();count++)
{
if(count==(defaultTableModel.getRowCount()-1))
{
System.out.println("aaaaaaaaaaaaaaa");
defaultTableModel.setValueAt("Responsed",count,
4);
}

Inter-Cluster Peer");

}
System.out.println("cache...."+output);
JOptionPane.showMessageDialog(null, "Response from

ObjectOutputStream
objectOutputStream=socketConnection.SocketSend(sourePort, soureSys);
SourceRes sourceRes=new
SourceRes(output,sourePort,soureSys);
objectOutputStream.writeObject(sourceRes);
}
}
catch (Exception ee) {
ee.printStackTrace();
}
}
}
}

ClientDesign.java
package com.Design;
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import

java.awt.event.ActionEvent;
java.awt.event.ActionListener;
java.awt.event.WindowAdapter;
java.awt.event.WindowEvent;
java.io.ObjectOutputStream;
java.net.InetAddress;
java.util.Random;
javax.swing.*;
java.util.Vector;
java.util.*;
java.awt.image.BufferedImage;
java.io.File;
java.io.FileInputStream;
java.io.FileOutputStream;
java.io.BufferedReader;

import java.io.FileReader;
import java.io.IOException;
import
import
import
import
import
import
import
import
import
import

javax.swing.JButton;
javax.swing.JFrame;
javax.swing.JLabel;
javax.swing.JOptionPane;
javax.swing.JProgressBar;
javax.swing.JScrollPane;
javax.swing.JTable;
javax.swing.JTextArea;
javax.swing.JTextField;
javax.swing.table.DefaultTableModel;

import
import
import
import
import
import
import
import
import
import
import

com.database.RetrieveQuery;
com.logic.ClientReceive;
com.logic.Details;
com.logic.RandomName;
com.logic.SocketConnection;
com.serial.ClientInfo;
com.serial.ClientInfo1;
com.serial.GreedyScheme;
com.serial.InsertNode;
com.serial.GetLiveNode;
com.serial.ExitNode;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
class WindowEventHandler extends WindowAdapter {
public void windowClosing(WindowEvent evt) {
RetrieveQuery retrieveQuery=new RetrieveQuery();
retrieveQuery.DeleteUnique(ClientDesign.nodeId, ClientDesign.region);
}
}
public class ClientDesign extends JFrame implements ActionListener
{
public static boolean status=true;
private JButton changeButton=new JButton("Dynamic Region");
private JButton addButton=new JButton("Add Records");
private JButton greedy=new JButton("Greedy Data Replication Scheme");
private JButton otoo=new JButton("OTOO");
private JButton rn=new JButton("Reliable Neighbor");
private JButton rg=new JButton("Reliable Grouping");
private JButton livenode=new JButton("Live Node");
private JButton exit=new JButton("Exit");
private JButton openButton = new JButton("Open");
private JTextField serTextField=new JTextField();
private JTextField catTextField=new JTextField();
private JButton jbutton=null;
public static String region=null;
public static String limit=null;

public static JProgressBar jProgressBar = new JProgressBar();


private RandomName randomName=null;
public static String nodeId="";
public static String groupId="";
public static String nregion="";
public static Vector nodevector=new Vector();
public JLabel service=new JLabel("Sub-Interest :");
public JLabel category=new JLabel("Interest :");
public JLabel fileup=new JLabel("File Upload :");
private JTextField fileupload=new JTextField();
public static JTextArea data;
JScrollPane scrollPane;

public
public
public
public
private
private
private
private

JLabel
JLabel
JLabel
JLabel

addservice=new JLabel("Sub-Interest :");


addcategory=new JLabel("Interest :");
adddetails=new JLabel("Details :");
addgroup=new JLabel("Group :");

JTextField
JTextField
JTextField
JTextField

addser=new
addcat=new
adddet=new
addgro=new

JTextField();
JTextField();
JTextField();
JTextField();

public static DefaultTableModel defaultTableModel=new DefaultTableModel();


public static DefaultTableModel defaultTableModel1=new DefaultTableModel();
public static DefaultTableModel defaultTableModel2=new DefaultTableModel();

public static JTable response=new JTable(defaultTableModel);


public static JTable live=new JTable(defaultTableModel1);
public static JTable result=new JTable(defaultTableModel2);
//public static JTextArea response=new JTextArea();
public JScrollPane jScrollPane =new JScrollPane(response);
public JScrollPane jScrollPane1 =new JScrollPane(live);
public JScrollPane jScrollPane2 =new JScrollPane(result);
public JLabel outputLabel=new JLabel("HASHKEY :");
public JLabel regionLabel=new JLabel("");
private Details details=null;
private String[] det=null;
private String port=null;
private String proxySys=null;
private SocketConnection socketConnection=null;
private String portRandom="";
public JLabel regionValue=new JLabel();
boolean inp=true;

boolean inplim=true;
boolean getnodeid=true;
boolean groupids=true;
String con="";

ClientDesign()
{
defaultTableModel.addColumn("Sub-Interest");
defaultTableModel.addColumn("Details");
defaultTableModel1.addColumn("Peer");
//defaultTableModel1.addColumn("Link Failure");
defaultTableModel1.addColumn("Cluster");
defaultTableModel2.addColumn("Interest");
defaultTableModel2.addColumn("Sub-Interest");
defaultTableModel2.addColumn("Details");
defaultTableModel2.addColumn("Cluster");

details=new Details();
det=details.Config("port", "proxy");
port=det[0];
proxySys=det[1];
socketConnection=new SocketConnection();
randomName=new RandomName();
portRandom=randomName.portNo();
ClientReceive clientReceive=new ClientReceive(portRandom);
while(getnodeid){
nodeId=JOptionPane.showInputDialog("Enter the NodeId");
if(!nodeId.equals(""))
{
getnodeid=false;
}
}
while(groupids){
groupId=JOptionPane.showInputDialog("Enter the Cluster");
if(!groupId.equals(""))
{
groupids=false;
}
}
String input = "some input string";
int hashCode = input.hashCode();
System.out.println("input hash code = " + hashCode);
try{

Random randomNumber = new Random();


int name=randomNumber.nextInt(1000);
String st1=Integer.toString(name);
final String inputString = st1;

//final String inputString = "Hello MD5";


System.out.println("MD5 hex for '" + inputString + "' :");
System.out.println(getMD5Hex(inputString));
regionLabel.setText(getMD5Hex(inputString));
}catch(Exception ee)
{
ee.printStackTrace();
}
//nodeId=randomName.NodeName();
try{
InsertNode InsertNode=new InsertNode(nodeId,groupId);
ObjectOutputStream objectOutputStream=socketConnection.SocketSend(port,
proxySys);
objectOutputStream.writeObject(InsertNode);
objectOutputStream.close();

}catch(Exception ee)
{
ee.printStackTrace();
}
setTitle(nodeId);
setLayout(null);

outputLabel.setBounds(300, 50, 100, 30);


regionLabel.setBounds(380, 50, 300, 30);
jScrollPane.setBounds(300, 150, 200, 130);
jScrollPane1.setBounds(300, 300, 200, 130);
jScrollPane2.setBounds(530, 100, 480, 330);

addcategory.setBounds(10, 20, 100, 30);


addservice.setBounds(10, 70, 100, 30);
fileup.setBounds(10, 120, 100, 30);

addser.setBounds(100, 20, 100, 30);


addcat.setBounds(100, 70, 100, 30);
fileupload.setBounds(100, 120, 100, 30);
category.setBounds(10, 350, 100, 30);
service.setBounds(10, 400, 100, 30);

catTextField.setBounds(100, 350, 100, 30);


serTextField.setBounds(100, 400, 100, 30);
jbutton=new JButton("Request");
jbutton.setBounds(10, 470, 100, 30);
jbutton.addActionListener(this);
changeButton.setBounds(300, 100, 200, 30);
changeButton.addActionListener(this);
openButton.setBounds(230, 120, 50, 30);
openButton.addActionListener(this);
addButton.setBounds(60, 170, 150, 30);
addButton.addActionListener(this);

livenode.setBounds(250, 470, 100, 30);


livenode.addActionListener(this);
exit.setBounds(410, 470, 100, 30);
exit.addActionListener(this);
data = new JTextArea();
scrollPane = new JScrollPane(data,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scrollPane.setBounds(530,450,480,200);
add(scrollPane);

add(addButton);
add(openButton);
//add(greedy);
//add(otoo);
//add(rn);
//add(rg);
add(livenode);
add(exit);
add(outputLabel);
add(regionLabel);
add(jScrollPane);
add(jScrollPane1);
add(jScrollPane2);
add(catTextField);

add(category);
add(service);
add(addcategory);
add(addservice);
//add(adddetails);
//add(addgroup);
add(serTextField);
add(addcat);
add(addser);
add(adddet);
//add(addgro);
add(fileup);
add(fileupload);
add(jbutton);
addWindowListener(new WindowEventHandler());
setSize(1020,720);
setVisible(true);
}
public static void main(String[] args)
{
try {
UIManager.setLookAndFeel("com.easynth.lookandfeel.EaSynthLookAndFeel");
} catch (Exception e) {
e.printStackTrace();
}
ClientDesign clientDesign=new ClientDesign();
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==jbutton)
{
try
{
String request=serTextField.getText();
String category=catTextField.getText();
if(request.equals(""))
{
JOptionPane.showMessageDialog(null, "Enter the Service");
}
else if(category.equals(""))
{
JOptionPane.showMessageDialog(null, "Enter the Category");
}
if(!request.equals("")&&!category.equals(""))
{

ClientInfo clientInfo=new ClientInfo(request, category,


groupId, nodeId,portRandom,InetAddress.getLocalHost().getHostName(),groupId);
ObjectOutputStream
objectOutputStream=socketConnection.SocketSend(port, proxySys);
objectOutputStream.writeObject(clientInfo);
objectOutputStream.close();
}
}
catch(Exception ee)
{
ee.printStackTrace();
}
}
if(e.getSource()==openButton)
{
BufferedReader br = null;
String sCurrentLine;
try
{

JFileChooser chooser = new JFileChooser();


chooser.setMultiSelectionEnabled(true);
int option = chooser.showOpenDialog(ClientDesign.this);
if (option == JFileChooser.APPROVE_OPTION) {
File[] sf = chooser.getSelectedFiles();
String filelist = "nothing";
if (sf.length > 0) filelist = sf[0].getName();
String path = chooser.getSelectedFile().getAbsolutePath();
for (int i = 1; i < sf.length; i++) {
filelist += ", " + sf[i].getName();
}
fileupload.setText(path);
br = new BufferedReader(new FileReader(path));
while ((sCurrentLine = br.readLine()) != null) {
System.out.println(sCurrentLine);
con=con+""+sCurrentLine;
}
System.out.println("content"+con);
}
else {
}

fileupload.setText("You canceled.");

}
catch(Exception ee)
{
ee.printStackTrace();
}
}
if(e.getSource()==addButton)
{

try
{
String request=addser.getText();
String category=addcat.getText();
String det=adddet.getText();
//String gro=addgro.getText();
if(request.equals(""))
{
JOptionPane.showMessageDialog(null, "Enter the Service");
}
if(category.equals(""))
{
JOptionPane.showMessageDialog(null, "Enter the Category");
}
if(det.equals(""))
{
JOptionPane.showMessageDialog(null, "Enter the Details");
}
if(!request.equals("")&&!category.equals("")&&!det.equals(""))
{
ClientInfo1 clientInfo1=new ClientInfo1(request,
category,con,groupId,nodeId,portRandom,InetAddress.getLocalHost().getHostName(
));
ObjectOutputStream
objectOutputStream=socketConnection.SocketSend(port, proxySys);
objectOutputStream.writeObject(clientInfo1);
objectOutputStream.close();
}
}
catch(Exception ee)
{
ee.printStackTrace();
}
}
if(e.getSource()==livenode)
{
try
{
GetLiveNode GetLiveNode=new
GetLiveNode(nodeId,portRandom,InetAddress.getLocalHost().getHostName());
ObjectOutputStream
objectOutputStream=socketConnection.SocketSend(port, proxySys);
objectOutputStream.writeObject(GetLiveNode);
objectOutputStream.close();
}
catch(Exception ee)
{
ee.printStackTrace();
}

}
if(e.getSource()==exit)
{
try
{
ExitNode ExitNode=new
ExitNode(nodeId,portRandom,InetAddress.getLocalHost().getHostName());
ObjectOutputStream
objectOutputStream=socketConnection.SocketSend(port, proxySys);
objectOutputStream.writeObject(ExitNode);
objectOutputStream.close();
System.exit(0);
}
catch(Exception ee)
{
ee.printStackTrace();
}
}

}
public boolean IsDigit(String text) {
int index = 0;
boolean status = true;
char[] charText = text.toCharArray();
while (charText.length > index) {
if ((int) charText[index] < 48 || (int) charText[index] > 57) {
status = false;
break;
}
index++;
}
return status;
}
public static String getMD5Hex(final String inputString) throws
NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(inputString.getBytes());
byte[] digest = md.digest();
}

return convertByteToHex(digest);

private static String convertByteToHex(byte[] byteData) {


StringBuilder sb = new StringBuilder();
for (int i = 0; i < byteData.length; i++) {

sb.append(Integer.toString((byteData[i] & 0xff) + 0x100,


16).substring(1));
}
}
}

return sb.toString();

SYSTEM TESTING

The purpose of testing is to discover errors. Testing is the process of trying


to discover every conceivable fault or weakness in a work product. It provides a
way to check the functionality of components, sub assemblies, assemblies and/or a
finished product It is the process of exercising software with the intent of ensuring
that the
Software system meets its requirements and user expectations and does not fail in
an unacceptable manner. There are various types of test. Each test type addresses a
specific testing requirement.

TYPES OF TESTS

Unit testing
Unit testing involves the design of test cases that validate that the internal
program logic is functioning properly, and that program inputs produce valid
outputs. All decision branches and internal code flow should be validated. It is the
testing of individual software units of the application .it is done after the
completion of an individual unit before integration. This is a structural testing, that
relies on knowledge of its construction and is invasive. Unit tests perform basic
tests at component level and test a specific business process, application, and/or
system configuration. Unit tests ensure that each unique path of a business process
performs accurately to the documented specifications and contains clearly defined
inputs and expected results.

Integration testing

Integration tests are designed to test integrated software components to


determine if they actually run as one program. Testing is event driven and is more
concerned with the basic outcome of screens or fields. Integration tests
demonstrate that although the components were individually satisfaction, as shown
by successfully unit testing, the combination of components is correct and
consistent. Integration testing is specifically aimed at exposing the problems that
arise from the combination of components.

Functional test

Functional tests provide systematic demonstrations that functions tested are


available as specified by the business and technical requirements, system
documentation, and user manuals.
Functional testing is centered on the following items:
Valid Input

: identified classes of valid input must be accepted.

Invalid Input

: identified classes of invalid input must be rejected.

Functions

: identified functions must be exercised.

Output

: identified classes of application outputs must be exercised.

Systems/Procedures: interfacing systems or procedures must be invoked.

Organization and preparation of functional tests is focused on requirements, key


functions, or special test cases. In addition, systematic coverage pertaining to
identify Business process flows; data fields, predefined processes, and successive
processes must be considered for testing. Before functional testing is complete,
additional tests are identified and the effective value of current tests is determined.

System Test
System testing ensures that the entire integrated software system meets
requirements. It tests a configuration to ensure known and predictable results. An
example of system testing is the configuration oriented system integration test.
System testing is based on process descriptions and flows, emphasizing pre-driven
process links and integration points.

White Box Testing


White Box Testing is a testing in which in which the software tester has
knowledge of the inner workings, structure and language of the software, or at least
its purpose. It is purpose. It is used to test areas that cannot be reached from a black
box level.

Black Box Testing


Black Box Testing is testing the software without any knowledge of the inner
workings, structure or language of the module being tested. Black box tests, as
most other kinds of tests, must be written from a definitive source document, such
as specification or requirements document, such as specification or requirements
document. It is a testing in which the software under test is treated, as a black

box .you cannot see into it. The test provides inputs and responds to outputs
without considering how the software works.

6.1 Unit Testing:

Unit testing is usually conducted as part of a combined code and unit test
phase of the software lifecycle, although it is not uncommon for coding and unit
testing to be conducted as two distinct phases.

Test strategy and approach


Field testing will be performed manually and functional tests
will be written in detail.
Test objectives
All field entries must work properly.
Pages must be activated from the identified link.
The entry screen, messages and responses must not be
delayed.
Features to be tested
Verify that the entries are of the correct format
No duplicate entries should be allowed
All links should take the user to the correct page.

6.2 Integration Testing

Software integration testing is the incremental integration testing of two or


more integrated software components on a single platform to produce failures
caused by interface defects.
The task of the integration test is to check that components or software
applications, e.g. components in a software system or one step up software
applications at the company level interact without error.

Test Results: All the test cases mentioned above passed successfully. No defects
encountered.

6.3 Acceptance Testing

User Acceptance Testing is a critical phase of any project and requires


significant participation by the end user. It also ensures that the system meets the
functional requirements.
Test Results: All the test cases mentioned above passed successfully. No defects
encountered.

SAMPLE SCREEN SHOTS

CONCLUSIONS
To enhance file location efficiency in P2P systems, interest-clustered super-peer
networks and proximity- clustered super-peer networks have been proposed. A
proximity-aware and interest-clustered P2P file sharing system is proposed based
on a structured P2P. It groups peers based on both interest and proximity by taking
advantage of a hierarchical structure of a structured P2P. PAIS uses an intelligent
file replication algorithm that replicates a file frequently requested by physically
close nodes near their physical location to enhance the file lookup efficiency.
Finally, PAIS enhances the file searching efficiency among the proximity-close and
common interest nodes through a number of approaches. It dramatically reduces
the overhead and yields significant improvements in file location efficiency even in
node dynamism. Also, the experimental results show the effectiveness of the
approaches for improving file searching efficiency among the proximity close and
common-interest nodes.

REFERENCES
[1] BitTorrent. (2013) [Online]. Available: http://www.bittorrent.com/
[2] Gnutella home page. (2003) [Online]. Available: http://www.gnutella.com
[3] I. Clarke, O. Sandberg, B. Wiley, and T. W. Hong, Freenet: A distributed anonymous
information storage and retrieval system, in Proc. Int. Workshop Des. Issues Anonymity
Unobservability, 2001, pp. 4666.
[4] I. Stoica, R. Morris, D. Liben-Nowell, D. R. Karger, M. F. Kaashoek, F. Dabek, and H.
Balakrishnan, Chord: A scalable peer-topeer lookup protocol for internet applications,
IEEE/ACM Trans. Netw., vol. 11, no. 1, pp. 1732, Feb. 2003.
[5] A. Rowstron and P. Druschel, Pastry: Scalable, decentralizedobject location and routing for
large-scale peer-to-peer systems, in Proc. IFIP/ACM Int. Conf. Distrib. Syst. Platforms
Heidelberg, 2001, pp. 329350.
[6] B. Y. Zhao, L. Huang, J. Stribling, S. C. Rhea, A. D. Joseph, and J. Kubiatowicz, Tapestry: A
resilient global-scale overlay for service deployment, IEEE J. Sel. Areas Commun., vol. 22, no.
1, pp. 4153, 2004.
[7] H. Shen, C. Xu, and G. Chen, Cycloid: A scalable constant-degree P2P overlay network,
Perform. Eval., vol. 63, pp. 195216, 2006.
[8] Z. Li, G. Xie, and Z. Li, Efficient and scalable consistency maintenance for heterogeneous
peer-to-peer systems, IEEE Trans. ParallelDistrib. Syst., vol. 19, no. 12, pp. 16951708, Dec.
2008.
[9] H. Shen and C.-Z. Xu, Hash-based proximity clustering for efficient load balancing in
heterogeneous DHT networks, J. Parallel Distrib. Comput., vol. 68, pp. 686702, 2008.
[10] FastTrack. (2003) [Online]. Available: http://www.fasttrack.nu/index_int.html

Das könnte Ihnen auch gefallen