Reputation Based Job Allocation in Computational Grid - Islamic ...
Reputation Based Job Allocation in Computational Grid - Islamic ...
Reputation Based Job Allocation in Computational Grid - Islamic ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Reputation</strong> <strong>Based</strong> <strong>Job</strong> <strong>Allocation</strong> <strong>in</strong> <strong>Computational</strong> <strong>Grid</strong><br />
Supervisor<br />
A.K.M Khaled Ahsan Talukder<br />
Lecturer, CIT Department<br />
<strong>Islamic</strong> University of Technology (IUT)<br />
Thesis Members:<br />
Fahad Hasan Ratul (054439)<br />
Mohammed Yas<strong>in</strong> Rahman (054440)<br />
Adnan Alam Khan (054449)<br />
Department of Computer Science and Information Technology<br />
<strong>Islamic</strong> University of Technology (IUT),<br />
Gazipur, Bangladesh.<br />
October 22, 2009<br />
1
CERTIFICATE OF RESEARCH<br />
This is to certify that the work presented <strong>in</strong> this thesis paper is the outcome<br />
of the <strong>in</strong>vestigation carried out by the candidates under the supervision of<br />
Khaled Ahsan Talukdar <strong>in</strong> the Department of Computer Science and<br />
Information Technology, IUT, Gazipur. It is also declared that this thesis<br />
thereof has been submitted anywhere else for the award of any degree or<br />
diploma or for any publication.<br />
Signature of The Head of the Department<br />
----------------------------------<br />
Prof. Dr. M.A. Mottalib<br />
Head<br />
Department of Computer Science and Information Technology, IUT.<br />
Supervisor<br />
----------------------------------<br />
A K M Khaled Ahsan Talukder<br />
Lecturer, CIT Department<br />
Department of Computer Science and Information Technology, IUT.<br />
Authors<br />
---------------------------------- ------------------------ ------------------------------<br />
Fahad Hasan Ratul Mohammed Yas<strong>in</strong> Rahman Adann Alom Khan<br />
Student # 054439 Student # 054440 Student # 054449<br />
Department of<br />
Computer Science and Information Technology, IUT.<br />
October 22, 2009<br />
2
ACKNOWLEDGEMENT<br />
We express our heartiest gratefulness to Almighty Allah for His div<strong>in</strong>e<br />
bless<strong>in</strong>gs, which made us possible to complete this thesis successfully.<br />
Firstly we express our s<strong>in</strong>cere gratitude, profound <strong>in</strong>debtedness and <strong>in</strong>tense<br />
respect to Prof. Dr.M. A. Mottalib, Professor and Head, Department of<br />
Computer Science and Information Technology, A K M Khaled Ahsan<br />
Talukder, Lecturer, Department of Computer Science and Information<br />
Technology, IUT. Their <strong>in</strong>tense knowledge <strong>in</strong> the field of <strong>Grid</strong> Comput<strong>in</strong>g,<br />
cont<strong>in</strong>ual guidance, encouragement, endless patience, constructive criticism<br />
and advice, constant supervision and guidance made the project possible to<br />
come to this stage.<br />
Without their encouragement, help and support this project could not have<br />
been successful. We would like to thank all the teachers, students, staffs and<br />
friends at <strong>Islamic</strong> University of Technology (IUT) for their support and<br />
encouragement. We wish to express our gratitude to <strong>Islamic</strong> University of<br />
Technology (IUT) for provid<strong>in</strong>g us the environment and support.<br />
F<strong>in</strong>ally, we would like to offer thanks to each and everyone who helped us <strong>in</strong><br />
any way <strong>in</strong> the thesis work.<br />
3
ABSTRACT<br />
<strong>Grid</strong> is an <strong>in</strong>frastructure that <strong>in</strong>volves the <strong>in</strong>tegrated and collaborative use of<br />
computers, networks, databases and scientific <strong>in</strong>struments owned and<br />
managed by multiple organizations. <strong>Grid</strong> provides access to large scale<br />
shared comput<strong>in</strong>g resources with different reliability on which we can solve<br />
computationally large problems. So grid ensures effective use of comput<strong>in</strong>g<br />
resources that otherwise would rema<strong>in</strong> idle for most of the time and to<br />
perform complex and comput<strong>in</strong>g-demand<strong>in</strong>g tasks that would normally<br />
require large-scale comput<strong>in</strong>g resources. There are three major types of fault<br />
tolarence method <strong>in</strong> Voluntary Resource <strong>Allocation</strong>. We would like to modify<br />
the exist<strong>in</strong>g technique for fault tolerance of Voluntary Resource <strong>Allocation</strong> <strong>in</strong><br />
case of jobs with strict deadl<strong>in</strong>e. In our modification we tried to modify the<br />
replication method by <strong>in</strong>troduc<strong>in</strong>g reputation management concept <strong>in</strong> order to<br />
<strong>in</strong>crease resource utilization of nodes and excut<strong>in</strong>g concurrent jobs<br />
successfully.<br />
4
TABLE OF CONTENT<br />
PART ONE<br />
INTRODUCTION<br />
CHAPTER 1: Introduction:<br />
1.1 Introduction 13<br />
1.2 Overview of a grid 14<br />
1.3 Characteristics of grid 15<br />
1.4 Entities of grid 15<br />
1.5 Requirement of grid 17<br />
1.6 Architecture of grid 19<br />
PART TWO<br />
LITERATURE REVIEW<br />
CHAPTER 2: Related Work<br />
2.1 Different Resource allocation mechanism 23<br />
2.1.1. Volunteer resource allocation mechanism 24<br />
2.1.2 Agreement based resource allocation mechanism 25<br />
2.1.3 Economic resource allocation mechanism 26<br />
2.2 <strong>Job</strong> <strong>Allocation</strong> 27<br />
2.2.1 <strong>Job</strong> allocation <strong>in</strong> Volunteer resource allocation 28<br />
2.2.2 <strong>Job</strong> allocation <strong>in</strong> Agreement based resource allocation 29<br />
5
2.2.3 <strong>Job</strong> allocation <strong>in</strong> Economic resource allocation 29<br />
2.3 Fault tolerance mechanism <strong>in</strong> grid 33<br />
PART THREE<br />
THE PROPOSAL<br />
CHAPTER 3: Our Proposed Model<br />
3.1 Application field 37<br />
3.1.1 <strong>Job</strong> allocation mechanism 37<br />
3.1.2 <strong>Job</strong> type 37<br />
3.2 Exist<strong>in</strong>g <strong>Allocation</strong> technique 37<br />
3.2.1 Resource availability comparison 37<br />
3.2.2 Resource allocation technique <strong>in</strong> volunteer grid 38<br />
3.2.3 Fault tolerance methods 39<br />
3.2.4 Problem of replication 40<br />
3.3 General terms related to grid resource allocation problem 40<br />
3.4 Our modifications 41<br />
3.4.1 <strong>Job</strong> allocation <strong>in</strong> our model 42<br />
3.4.2 <strong>Reputation</strong> management 43<br />
3.4.3 Why REP value is between 0 and 10 44<br />
3.4.4 Why REPi is needed 45<br />
3.5 Pseudo code of our proposed model 45<br />
3.6 Performance analysis 46<br />
6
PART FOUR<br />
IMPLEMENTATION AND TESTING<br />
Chapter 4: Simulation Environment<br />
4.1 Simulation environment 51<br />
4.2 Tables <strong>in</strong> the database 52<br />
4.3 Simulation screen shot 55<br />
Chapter 5: Implementation<br />
5.1 Implementation 59<br />
5.2 Two replication system 59<br />
5.3 Three replication system 60<br />
5.4 <strong>Reputation</strong> based system 61<br />
PART FIVE<br />
PERFORMANCE ANALYSIS AND CONCLUSION<br />
Chapter 6: Performance Analysis<br />
6.1 Performance analysis 65<br />
6.2 Fault chance of mach<strong>in</strong>es 65<br />
6.3 Fault chance and mach<strong>in</strong>e reputation <strong>in</strong> our proposal 65<br />
6.4 Simulation result for 9 nodes 67<br />
6.5 Simulation result for 12 nodes 68<br />
6.6 Simulation result for 15 nodes 69<br />
6.7 Graphical comparison 70<br />
6.7.1 Average highest concurrent jobs 71<br />
7
6.7.2 Average highest concurrent nodes 71<br />
6.7.3 Average total successful execution 72<br />
6.7.4 Average total failed execution 73<br />
6.7.5 Average total resubmission 74<br />
Chapter 7: Conclusion<br />
7.1 Conclusion 76<br />
7.2 Future works 76<br />
References 78<br />
Appendix 89<br />
8
LIST OF FIGURES<br />
Figure: 1.1 General layered <strong>Grid</strong> Architecture 18<br />
Figure: 1.2 Data grid Architecture 20<br />
Figure: 2.1 Volunteer Pool<strong>in</strong>g mechanism steps 27<br />
Figure: 2.2 Policy based Fairshare mechanism steps 28<br />
Figure: 2.3 RFPSA mechanism steps.<br />
Figure: 3.1 Current job allocation techniques <strong>in</strong> 30<br />
Volunteer <strong>Allocation</strong><br />
Figure 3.2(a): Exist<strong>in</strong>g Model 36<br />
Figure 3.2(b): Proposed Model 40<br />
Figure 3.3 <strong>Reputation</strong> based job allocation 40<br />
Figure 3.4(a) <strong>Reputation</strong> without limit 41<br />
Figure 3.4(b) <strong>Reputation</strong> with limit 42<br />
Figure: 4.1 Table ‘<strong>Job</strong>’ Before Simulation Starts 42<br />
Figure: 4.2 Table of ‘Node_<strong>in</strong>formation’ Before 50<br />
Simulation Starts<br />
Figure: 4.3 Table of job after the simulation 51<br />
Figure: 4.4 Table of node_<strong>in</strong>formation after 51<br />
end<strong>in</strong>g simulation<br />
Figure: 4.5 Generated database <strong>in</strong> the IDE 52<br />
Figure: 4.6 Output Screen 53<br />
Figure: 5.1 Two Replication System 57<br />
Figure: 5.2 Three Replication System 58<br />
Figure: 5.3 <strong>Reputation</strong> based System 59<br />
Figure: 6.1 Simulation Result for Fault chance and 62<br />
mach<strong>in</strong>e reputation<br />
Figure: 6.2 Simulation Result for Fault chance and 63<br />
9
mach<strong>in</strong>e reputation<br />
Figure: 6.3 Simulation Result for twelve nodes 64<br />
Figure: 6.4 Simulation Result for twelve nodes 65<br />
Figure: 6.5 Simulation Result for Average 66<br />
highest concurrent jobs<br />
Figure: 6.6 Simulation Result for Average 67<br />
highest concurrent nodes<br />
Figure: 6.7 Simulation Result for Average total 68<br />
Successful Execution<br />
Figure: 6.8 Simulation Result for Average total 69<br />
failed Execution<br />
Figure: 6.9 Simulation Result for Average 70<br />
total Resubmissions<br />
10
[PART ONE]<br />
Introduction<br />
11
CHAPTER I<br />
Introduction<br />
12
1.1 Introduction<br />
The term “<strong>Grid</strong>” was <strong>in</strong>troduced <strong>in</strong> early 1998 with the launch of the book<br />
“The <strong>Grid</strong>. Bluepr<strong>in</strong>t for a new comput<strong>in</strong>g <strong>in</strong>frastructure” Written by Ian<br />
Foster and Carl Kesselman.[3] The objective of grid comput<strong>in</strong>g is to distribute<br />
the jobs to heterogeneous environment and <strong>in</strong>crease the speed of process<strong>in</strong>g<br />
the jobs. <strong>Grid</strong> comput<strong>in</strong>g has emerged as a promis<strong>in</strong>g next generation<br />
collaborative problem solv<strong>in</strong>g platform for <strong>in</strong>dustry, science, and eng<strong>in</strong>eer<strong>in</strong>g.<br />
<strong>Grid</strong> comput<strong>in</strong>g is def<strong>in</strong>ed as coord<strong>in</strong>ated resource shar<strong>in</strong>g and problem<br />
solv<strong>in</strong>g <strong>in</strong> dynamic, multi-<strong>in</strong>stitutional virtual organizations. [75] The shar<strong>in</strong>g<br />
ranges from simple file transfer to direct access to computers, software, data,<br />
and other network accessible resources. At the heart of the grid is the ability<br />
to discover, allocate and negotiate the use of these resources. <strong>Grid</strong> enables<br />
this shar<strong>in</strong>g, selection, and aggregation of a wide variety of resources<br />
<strong>in</strong>clud<strong>in</strong>g supercomputers, storage systems, data sources, and specialized<br />
devices that are geographically distributed and owned by different<br />
organizations [2]. <strong>Grid</strong> comput<strong>in</strong>g is generally used for problems with large<br />
scale collaboration and huge computational and/or data storage requirement.<br />
The applications of grid <strong>in</strong>cludes large scale simulations <strong>in</strong> astrophysics,<br />
climate model<strong>in</strong>g, model<strong>in</strong>g for drug design, high energy physics,<br />
<strong>in</strong>frastructure for multiplayer games etc[1]<br />
1.2 Overview of a <strong>Grid</strong><br />
Def<strong>in</strong>ition of <strong>Grid</strong>:<br />
The def<strong>in</strong>ition of grid cannot be given only from one po<strong>in</strong>t of view. There are<br />
many variety of def<strong>in</strong>ition of grid comput<strong>in</strong>g. [65] We will give some of the<br />
most used def<strong>in</strong>ition which is def<strong>in</strong>ed by many top level grid researchers.<br />
13
Def<strong>in</strong>ition #1: <strong>Grid</strong> is an <strong>in</strong>frastructure that <strong>in</strong>volves the <strong>in</strong>tegrated and<br />
collaborative use of computers, networks, databases and scientific<br />
<strong>in</strong>struments owned and managed by multiple organizations. [53] <strong>Grid</strong><br />
provides access to large scale shared comput<strong>in</strong>g resources on which we can<br />
solve computationally large problems. So grid ensures effective use of<br />
comput<strong>in</strong>g resources that otherwise would rema<strong>in</strong> idle for most of the time<br />
and to perform complex and comput<strong>in</strong>g-demand<strong>in</strong>g tasks that would normally<br />
require large-scale comput<strong>in</strong>g resources [2].<br />
Def<strong>in</strong>ition #2: The objective of grid comput<strong>in</strong>g is to distribute the jobs to<br />
heterogeneous environment and <strong>in</strong>crease the speed of process<strong>in</strong>g the jobs.<br />
Most of the <strong>Grid</strong> tool kits use the First Come First [8]<br />
Def<strong>in</strong>ition #3: A computational grid is a widespread comput<strong>in</strong>g environment<br />
that provides huge computational power for large-scale distributed<br />
applications. Load balanc<strong>in</strong>g, has a considerable effect on the grid middleware<br />
performance [9]<br />
Def<strong>in</strong>ition #4: The essence of the def<strong>in</strong>itions above can be captured <strong>in</strong> a<br />
simple checklist, accord<strong>in</strong>g to which a <strong>Grid</strong> is a system that [10]:<br />
1) coord<strong>in</strong>ates resources that are not subject to centralized control (A <strong>Grid</strong><br />
<strong>in</strong>tegrates and coord<strong>in</strong>ates resources and users that live with<strong>in</strong> different<br />
control doma<strong>in</strong>s—for example, the user’s desktop vs. central comput<strong>in</strong>g;<br />
different adm<strong>in</strong>istrative units of the same company; or different companies;<br />
and addresses the issues of security, policy, payment, membership, and so<br />
forth that arise <strong>in</strong> these sett<strong>in</strong>gs. Otherwise, we are deal<strong>in</strong>g with a local<br />
management system) [10]<br />
2) Us<strong>in</strong>g standard, open, general-purpose protocols and <strong>in</strong>terfaces (A <strong>Grid</strong> is<br />
built from multi-purpose protocols and <strong>in</strong>terfaces that address such<br />
fundamental issues as authentication, authorization, resource discovery, and<br />
14
esource access. As I discuss further below, it is important that these<br />
protocols and <strong>in</strong>terfaces be standard and open. Otherwise, we are deal<strong>in</strong>g<br />
with an application-specific system.)[10]<br />
3) To deliver nontrivial qualities of service. (A <strong>Grid</strong> allows its constituent<br />
resources to be used <strong>in</strong> a coord<strong>in</strong>ated fashion to deliver various qualities of<br />
service, relat<strong>in</strong>g for example to response time, throughput, availability, and<br />
security, and/or co-allocation of multiple resource types to meet complex<br />
user demands, so that the utility of the comb<strong>in</strong>ed system is significantly<br />
greater than that of the sum of its parts.)[10]<br />
Def<strong>in</strong>ition #5: <strong>Grid</strong> comput<strong>in</strong>g is a promis<strong>in</strong>g paradigm for shar<strong>in</strong>g ITresources<br />
<strong>in</strong> large-scale geographically distributed systems through<br />
collaboration (Foster, Kesselman 2001). It enables to use software and<br />
hardware <strong>in</strong>frastructures from other <strong>in</strong>stitutes for an effective shar<strong>in</strong>g of<br />
heterogeneous comput<strong>in</strong>g resources, data or even high-performance and<br />
complex services (Joseph et al. 2004). The collaboration <strong>in</strong> the particle<br />
physics <strong>Grid</strong> Community has been facilitated by virtual organizations (VO) like<br />
Atlas or LHCb (Berlich et al. 2005). [11] [45] [33] [71]<br />
Def<strong>in</strong>ition #6: <strong>Grid</strong> comput<strong>in</strong>g is a means of allocat<strong>in</strong>g the computational<br />
power of a large number of computers to a very difficult problem. The goal is<br />
to access computers only when they are needed and to scale the problem so<br />
that even small computers can make a useful contribution [15]<br />
1.3 Characteristics of <strong>Grid</strong><br />
The ma<strong>in</strong> characteristics of a grid are [1]:<br />
• Multiple adm<strong>in</strong>istrative doma<strong>in</strong>s: <strong>Grid</strong> spawns <strong>in</strong>to multiple adm<strong>in</strong>istrative<br />
doma<strong>in</strong>s. This characteristic makes it different from clusters. S<strong>in</strong>ce, it spawns<br />
15
<strong>in</strong>to multiple adm<strong>in</strong>istrative doma<strong>in</strong>s, the policies and autonomy of different<br />
doma<strong>in</strong>s needs to be ma<strong>in</strong>ta<strong>in</strong>ed [1] [21]<br />
• Heterogeneity: <strong>Grid</strong> conta<strong>in</strong>s different types of resources like personal<br />
computers to super computers to specialized devices like telescopes. <strong>Grid</strong><br />
provides seamless way to access different resources [1]<br />
• Scalability: A grid might grow from few <strong>in</strong>tegrated resources to millions.<br />
The performance might be degraded as the size of the grid <strong>in</strong>creases. [29]<br />
The applications that require a large number of geographically located<br />
resources must be designed to be latency and bandwidth tolerant [1]<br />
• Adaptively: <strong>Grid</strong> should be resilient to failure of <strong>in</strong>dividual nodes. As it<br />
conta<strong>in</strong>s a large number of nodes, the probability of failure of nodes will be<br />
high. So the applications and resource brokers behave should adapt<br />
dynamically and use the available resources and services efficiently and<br />
effectively [1] [17] [63] [52]<br />
1.4 Entities of <strong>Grid</strong><br />
In this section, we will expla<strong>in</strong> about the various entities <strong>in</strong> a grid comput<strong>in</strong>g<br />
environment and <strong>in</strong>teraction between them. The ma<strong>in</strong> entities <strong>in</strong> a grid are:<br />
1. User<br />
2.Resource broker:<br />
3.Information service<br />
4.Resources<br />
User: A user is a person who wants to complete his job <strong>in</strong> a grid<br />
environment. A user can be anyone. He can be a normal user or can be an<br />
organization. Whoever comes up with a job to be completed <strong>in</strong> the grid<br />
environment are known as <strong>Grid</strong> Users. [19] [26]<br />
16
Resource Broker: The resource broker acts as a mediator between the user<br />
and grid resources us<strong>in</strong>g middleware services. It is responsible for resource<br />
selection, b<strong>in</strong>d<strong>in</strong>g of software (application), data, and hardware resources,<br />
<strong>in</strong>itiate computations, adapt to the changes <strong>in</strong> grid resources and present the<br />
grid to the user as a s<strong>in</strong>gle, unified resource [4]<br />
Information Service: The Information Service ma<strong>in</strong>ta<strong>in</strong>s complete <strong>in</strong>formation<br />
of all resources (like its capability, status, contact <strong>in</strong>formation etc) available<br />
<strong>in</strong> the grid. The resource broker will select one among them and submit the<br />
job to it. The resource broker contacts an Information Service to f<strong>in</strong>d an<br />
appropriate resource [1]<br />
Resources: An entity that is to be shared. E.g. computers, storage, data,<br />
software. Does not have to be a physical entity. E.g. Condor pool, distributed<br />
file system Def<strong>in</strong>ed <strong>in</strong> terms of <strong>in</strong>terfaces, not devices. E.g. scheduler such as<br />
LSF and PBS def<strong>in</strong>e a computer resource. Open/close/read/write def<strong>in</strong>es<br />
access to a distributed file system, e.g. NFS, AFS, DFS [5] [72]<br />
1.5 Requirement of grids [5]<br />
<strong>Grid</strong> Architecture must have to meet follow<strong>in</strong>g requirements.<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Identity & authentication<br />
Authorization & policy<br />
Resource discovery<br />
Resource characterization<br />
Resource allocation<br />
(Co-)reservation, workflow<br />
Distributed algorithms<br />
Remote data access<br />
High-speed data transfer<br />
Performance guarantees<br />
17
Monitor<strong>in</strong>g<br />
Adaptation<br />
Intrusion detection<br />
Resource management<br />
Account<strong>in</strong>g & payment<br />
Fault management<br />
System evolution<br />
Etc.<br />
1.6 Architecture of grid [5]<br />
General layered <strong>Grid</strong> Architecture<br />
Figure: 1.1 General layered <strong>Grid</strong> Architecture<br />
18
Fabric Layer Protocol and Services<br />
<br />
<br />
<br />
Just what you would expect: the diverse mix of resources that may be<br />
shared Individual computers, Condor pools, file systems, archives,<br />
metadata catalogs, networks, sensors, etc., etc. [5] [16]<br />
Few constra<strong>in</strong>ts on low-level technology connectivity and resource level<br />
protocols form the “neck <strong>in</strong> the hourglass”.<br />
Def<strong>in</strong>ed by <strong>in</strong>terfaces not physical characteristics<br />
Connectivity Layer Protocol and Services [5] [41]<br />
Communication– Internet protocols: IP, DNS, rout<strong>in</strong>g, etc.<br />
Security: <strong>Grid</strong> Security Infrastructure (GSI)<br />
Uniform authentication, authorization, and message protection<br />
mechanisms <strong>in</strong> multi-<strong>in</strong>stitutional sett<strong>in</strong>g, S<strong>in</strong>gle sign-on, delegation,<br />
identity mapp<strong>in</strong>g, Public key technology, SSL, X.509, GSS-API, Support<strong>in</strong>g<br />
<strong>in</strong>frastructure: Certificate, Authorities, certificate & key management. [51]<br />
[64] [73]<br />
Resource Layer Protocols and services<br />
<br />
<br />
<br />
<br />
<strong>Grid</strong> Resource <strong>Allocation</strong> Management (GRAM)<br />
– Remote allocation, reservation, monitor<strong>in</strong>g, control of compute<br />
resources [5] [20]<br />
<strong>Grid</strong>FTP protocol (FTP extensions)<br />
– High-performance data access & transport [18]<br />
<strong>Grid</strong> Resource Information Service (GRIS)<br />
– Access to structure & state <strong>in</strong>formation<br />
All built on connectivity layer: GSI & IP<br />
Collective Layer Protocols and services [5] [22]<br />
19
Index servers aka metadirectory services<br />
– Dynamic resource collections assembled by a community<br />
Resource brokers (e.g., Condor Matchmaker)<br />
– Resource discovery and allocation [31] [40]<br />
Replica catalogs [23] [69]<br />
Replication services [27] [57]<br />
Co-reservation and co-allocation services [37]<br />
Workflow management services [44]<br />
Example (Data <strong>Grid</strong> Architecture):<br />
Application<br />
Discipl<strong>in</strong>e-Specific Data <strong>Grid</strong> Application<br />
Collective<br />
(Application)<br />
Coherency control, replica selection, task management, virtual data<br />
catalog, virtual data code catalog, …<br />
Collective<br />
(Generic)<br />
Replica catalog, replica management, co-allocation, certificate authorities,<br />
metadata catalogs,<br />
Resource<br />
Access to data, access to computers, access to network performance<br />
data, …<br />
Connectivity<br />
Communication, service discovery (DNS), authentication, authorization,<br />
delegation<br />
Fabric<br />
Storage systems, clusters, networks, network caches<br />
Figure 1.2 Data grid Architecture<br />
20
[PART TWO]<br />
Literature Review<br />
21
CHAPTER II<br />
Related Works<br />
22
2.1 Different Resource <strong>Allocation</strong> Mechanism<br />
There are many techniques for allocat<strong>in</strong>g resources <strong>in</strong> <strong>Grid</strong>. We will discuss<br />
thoroughly discuss about each mechanism of resource allocation <strong>in</strong> <strong>Grid</strong>.<br />
Ma<strong>in</strong>ly there are three different allocation mechanisms currently present.<br />
They are:<br />
1. Volunteer Resource <strong>Allocation</strong><br />
2. Agreement <strong>Based</strong> Resource <strong>Allocation</strong><br />
3. Economic Resource <strong>Allocation</strong> [6]<br />
2.1.1 Volunteer Resource <strong>Allocation</strong>:<br />
Volunteer comput<strong>in</strong>g or public resource comput<strong>in</strong>g is based on the idea that<br />
will<strong>in</strong>g participants with idle resources, like CPU, will happily donate these <strong>in</strong><br />
the aid of some cause or task without any tangible remuneration for their<br />
use. It is characterized by the ease of entry and exit of resource provid<strong>in</strong>g<br />
participants <strong>in</strong> shar<strong>in</strong>g their resources. Typically resources are al- located to<br />
volunteers on a pull basis, with blocks of tasks be<strong>in</strong>g allocated on request,<br />
and collected when the next set of tasks is requested. To see the electiveness<br />
of volunteer comput<strong>in</strong>g <strong>in</strong> provid<strong>in</strong>g tremendous amounts of comput<strong>in</strong>g<br />
power, one has to look no further than the SETI@home(Anderson et al.<br />
2002) project. In 2001 the average comput<strong>in</strong>g throughput provided by<br />
volunteers was 23.76 Teraflops! There are a many other BOINC (Anderson<br />
2004) based projects <strong>in</strong>clud<strong>in</strong>g Rosetta@home, TANPAKU@home, LHC@home<br />
etc.One social change that is observable <strong>in</strong> the volunteer comput<strong>in</strong>g<br />
environment is that a high comput<strong>in</strong>g to data ratio is becom<strong>in</strong>g less<br />
important, and therefore the advent of broadband has the potential for data<br />
<strong>in</strong>tensive applications to benefit from this model. However, whilst some might<br />
argue that BOINC does not strictly meet the criteria established for def<strong>in</strong><strong>in</strong>g a<br />
<strong>Grid</strong> due to the topology (star or similar (Sarmenta 2001)), the work is often<br />
published at <strong>Grid</strong> conferences and provides a usefully different allocation<br />
23
mechanism (Anderson et al. 2005) for the purposes of this paper [6] [43]<br />
[55]<br />
2.1.2 Agreement <strong>Based</strong> Resource <strong>Allocation</strong>:<br />
Agreement based resource allocation is a model where the negotiation and<br />
management of resources is formed by set policy. In essence either through<br />
negotiation (automated or not) a set of policies sett<strong>in</strong>g the requirements or<br />
regulations for resource are established and used for the allocation decisions.<br />
Each participant adheres to the policy set out. This form of resource<br />
allocation is usually used <strong>in</strong> an organization on its own grid, between<br />
collaborat<strong>in</strong>g <strong>in</strong>stitutions, etc, i.e. <strong>in</strong> general between places where<br />
collaboration is high and long-term, e.g. universities and closed communities.<br />
Agreement <strong>Based</strong> resource allocation comes <strong>in</strong> two general forms:<br />
• Policy based resource allocation is a model which uses a hierarchical<br />
approach to recursively sub- divide the resources available. For some,<br />
logically divid<strong>in</strong>g the grid resources makes sense, as this way everybody has<br />
access to them. This is heavily l<strong>in</strong>ked to the concept of virtual organizations<br />
(VO) (Foster et al. 2001). Us<strong>in</strong>g a policy, a share of the resources is allocated<br />
to each VO. The VO can then be made to enforce a lower level policy or just<br />
subdivide its resources among its members. Variants of policy based resource<br />
allocation <strong>in</strong>clude Fairshare schedul<strong>in</strong>g (J.Kay & P.Lauder 1988) and<br />
decentralized <strong>Grid</strong>-wide Fairshare schedul<strong>in</strong>g (Elmroth & Gardfjall<br />
2005).These two are focused on grid resource utilization and aim to deliver<br />
the allocated target shares through policies. [6] [61]<br />
• Service level based resource allocation (An-dreozzi et al. 2005), as the<br />
name suggests, relies on the use of service level agreements (SLAs).Each<br />
grid user must produce a service level agreement <strong>in</strong>dicat<strong>in</strong>g their<br />
expectations of ser-vice quality. A resource broker then performs some match<br />
mak<strong>in</strong>g to assign suitable resources to requests. With the service level<br />
24
agreement a better quality of service is enforced. This is an active area of<br />
def<strong>in</strong>ition be<strong>in</strong>g def<strong>in</strong>ed by the <strong>Grid</strong> Resource <strong>Allocation</strong> and Agreement<br />
Protocol Work<strong>in</strong>g Group of the Global <strong>Grid</strong> Forum (<strong>Grid</strong> Resource <strong>Allocation</strong><br />
and Agreement Protocol Work<strong>in</strong>g Group of the Global <strong>Grid</strong> Forum 2003). [25]<br />
[54]<br />
2.1.3 Economic Resource <strong>Allocation</strong>:<br />
Economic resource allocation is where the negotiation of resources is done via<br />
an economic mechanism. A currency is used as the medium of exchange,<br />
<strong>in</strong>dependent of whichever economic mechanism is <strong>in</strong> place. As is seen <strong>in</strong><br />
modern economies, this greatly enables the exchange (or at least a chance<br />
to) of needs and wants <strong>in</strong> return for goods and services. Auctions have long<br />
been suggested as a means to allocate resources <strong>in</strong> a distributed system<br />
(Malone et al. 1988) whereby clients <strong>in</strong>itiate an auction to f<strong>in</strong>d the best offer<br />
of resources to execute a task. Indeed the earliest ex-ample of a<br />
computational resource auction that we have found is (Sutherland 1968) <strong>in</strong><br />
which a white-board based auction was utilized by which bidders could spend<br />
their process<strong>in</strong>g time allocations. [28] [6]<br />
The ma<strong>in</strong> advantage of auctions for distributed and <strong>Grid</strong> comput<strong>in</strong>g is that<br />
they are naturally decentralized which permits many auctioneers to function<br />
<strong>in</strong> a distributed network. Auctions can also compute optimal allocations giv<strong>in</strong>g<br />
providers the best return on resources. There are four ma<strong>in</strong> types of auction<br />
protocol; the English, Dutch, Sealed-Bid, and the Vickrey auction protocol.<br />
The English auction is the conventional open outcry, ascend<strong>in</strong>g price, multiple<br />
bid protocol. The Dutch auction is an open outcry, descend<strong>in</strong>g price, s<strong>in</strong>gle<br />
bid protocol. The Sealed-Bid, or tender, is a sealed s<strong>in</strong>gle bid, best price<br />
protocol. The Vickrey auction is similar to the Sealed-Bid auction, except that<br />
the w<strong>in</strong>n<strong>in</strong>g bidder pays the amount of the second best bid. All four auction<br />
25
protocols yield the same return <strong>in</strong> private value auctions hence the selection<br />
of an auction protocol usually depends on messag<strong>in</strong>g and other<br />
implementation requirements (Vickrey 1961). [30]<br />
Economic resource allocation is seen as the mechanism that will enable real<br />
growth <strong>in</strong> the number of <strong>Grid</strong> systems, <strong>in</strong> particular commercial ones. This<br />
will lead to more choice and better options for potential <strong>Grid</strong> consumers. As<br />
Buyya, Abramson, and Giddy state”It offers <strong>in</strong>centive for resource owners to<br />
be part of the <strong>Grid</strong> and encourages consumers to optimally utilize resources<br />
and balance time frame and access costs.” (Buyya et al. 2001) [34] [35]<br />
Another reason for its attractiveness is that it seems the most <strong>in</strong>tuitive. As<br />
modern day economies revolve heavily around trade and allocation of resources,<br />
which is done via economic mechanisms, implement<strong>in</strong>g this<br />
mechanism would seem the most natural. Experience with these mechanisms<br />
also gives us knowledge with which we can theories what the effects <strong>in</strong> grid<br />
systems would be (R. Wolski and J.Brevik and J. S. Plank and T. Bryan 2003).<br />
The mechanisms proposed for use <strong>in</strong> grid resource allocation <strong>in</strong>clude auctions,<br />
commodity markets, tenders and posted price (Buyya 2002). [36] [46]<br />
With the emergence of Ebay and other Internet auction sites, it is easy to see<br />
that particular economic mechanisms are better suited than others to sell<strong>in</strong>g<br />
or gett<strong>in</strong>g (depend<strong>in</strong>g on your perspective) goods and services <strong>in</strong> a particular<br />
context. For <strong>in</strong>stance market gardeners use a commodity market mechanism<br />
to sell their produce, but at the supermarket we use a posted price<br />
mechanism. Therefore what economic resource allocation mechanism should<br />
be used <strong>in</strong> grid systems? Different mechanisms result <strong>in</strong> potentially different<br />
market properties, like price stability, grid resource utilization, efficiency etc.<br />
This means that choos<strong>in</strong>g the right mechanism(s) would be of utmost<br />
importance for the success of the grid system. There are also issues with a<br />
closed or open currency (Parkes et al.2001) and trust (Bubendorfer &<br />
26
Thomson 2006) that are beyond the scope of this paper. Various types of<br />
auctions and commodity market models have been simulated <strong>in</strong>clud<strong>in</strong>g<br />
(R.Wolski and J. Brevik and J. S. Plank and T. Bryan 2003, Kant & Grosu<br />
2005, Das & Grosu 2005, Regev & Nisan 1998, Pourebrahimi et al.2006).<br />
[38]<br />
2.2 <strong>Job</strong> <strong>Allocation</strong><br />
We have just seen there are 3 different types of resource allocation<br />
techniques <strong>in</strong> grid comput<strong>in</strong>g. Similarly <strong>in</strong> those 3 mechanisms the job<br />
allocation is different. Now <strong>in</strong> each resource allocation mechanism, we will<br />
discuss how job is allocated <strong>in</strong> different mach<strong>in</strong>es. [6] [38]<br />
2.2.1 <strong>Job</strong> allocation <strong>in</strong> volunteer resource allocation-volunteer<br />
pool<strong>in</strong>g:<br />
The volunteer comput<strong>in</strong>g allocation algorithm used <strong>in</strong> our simulation differs<br />
from standard <strong>in</strong> two significant ways. Firstly volunteers are pooled together,<br />
which form several grid resources to better fit the general <strong>Grid</strong> approach.<br />
Secondly reliability is dele-gated to each resource pool, which is responsible<br />
for mak<strong>in</strong>g sure that a job that is assigned to the re-source pool is<br />
completed, even if an <strong>in</strong>dividual mach<strong>in</strong>e fails. The term failure refers to a<br />
mach<strong>in</strong>e that has gone offl<strong>in</strong>e/been disconnected/ chosen not to cont<strong>in</strong>ue<br />
process<strong>in</strong>g the job. In standard BOINC (Ander-son 2004) redundant<br />
computations are used to resolve these forms of failure. In our simulation we<br />
have made the assumption that no volunteer mach<strong>in</strong>e is malicious, so once<br />
jobs are done they are not verified. [6] [39]<br />
27
3<br />
4<br />
<strong>Job</strong><br />
Figure: 2.1 Volunteer Pool<strong>in</strong>g mechanism steps.<br />
<br />
<br />
<br />
Users produce the jobs that are to be executed by the grid system.<br />
They each have a broker which they send these jobs to at a constant<br />
rate (step 1), until they have none left.<br />
Brokers on receiv<strong>in</strong>g a set of user jobs, polls all the available resources<br />
and waits for a response as to how many jobs the resource can take<br />
(steps 2 & 3). The broker distributes the jobs around to random<br />
responsive resources until it has none left (step 4).<br />
Resources on receiv<strong>in</strong>g a subset of jobs, as- signs jobs to any free<br />
mach<strong>in</strong>es (step 5), and then places any rema<strong>in</strong><strong>in</strong>g jobs <strong>in</strong> a queue. <strong>Job</strong>s<br />
are serviced on a first <strong>in</strong> first out basis from the queue. Should a<br />
volunteer mach<strong>in</strong>e crash and fail to do a job, the resource either<br />
reassigns that job, or puts it back <strong>in</strong> first position <strong>in</strong> the queue.<br />
28
2.2.2 <strong>Job</strong> allocation <strong>in</strong> Agreement <strong>Based</strong> Resource <strong>Allocation</strong>-Policy<br />
based Fairshare:<br />
Out of the agreement based resource allocation mechanisms, the decision<br />
was made to implement a policy based one, namely a fairShare variant based<br />
on the <strong>Grid</strong>-wide Fairshare (Elmroth & Gardfjall 2005). The implementation is<br />
simplified <strong>in</strong> that it only has one policy level, i.e. there is only a top level<br />
representation of users and no dist<strong>in</strong>ction, such as sub-users, for which to<br />
have a second level of policies.<br />
<strong>Job</strong><br />
<strong>Job</strong><br />
Figure: 2.2 Policy based Fairshare mechanism steps.<br />
The various roles <strong>in</strong> the allocation algorithm are refer to Figure 2.2<br />
<br />
Users Each user <strong>in</strong> FairShare is assigned a tar-get share of the grid<br />
resources. This is set at the beg<strong>in</strong>n<strong>in</strong>g of each simulation and does not<br />
change. Aga<strong>in</strong> users produce the jobs that are to be executed <strong>in</strong> the<br />
grid system. They each have a broker which they send the jobs to at a<br />
constant rate, until they have none left (step 1).<br />
29
Brokers Once a broker receives a set of jobs, a resource is randomly<br />
picked and assigned a sub-set of the jobs (step 2). The broker is limited<br />
as to how many total jobs can be outstand<strong>in</strong>g at any po<strong>in</strong>t <strong>in</strong> time. This<br />
stops the resources from be<strong>in</strong>g flooded with jobs.<br />
Resources Once at the resource, the job is as-signed a priority based<br />
on the deviation from its user target share and the current share<br />
supplied by the <strong>Grid</strong> Statistics entity (steps 3a & 3b). It is then put <strong>in</strong>to<br />
a priority queue (step 4), and the first job at the queue is the next job<br />
to be processed (step 5). Each time the users current shares are<br />
updated, all the jobs <strong>in</strong> the queue have their priorities updated as well.<br />
In the simulation the current user share used for the priorities takes the<br />
total usage history of the grid system <strong>in</strong>to account rather than decay<strong>in</strong>g<br />
as <strong>in</strong> the real protocol. [6] [49]<br />
2.2.3 <strong>Job</strong> allocation <strong>in</strong> 23 Economic Resource <strong>Allocation</strong>-Auction<br />
The reverse first price sealed auction (RFPSA) was implemented, as it is a<br />
simple, quick auction. <strong>Job</strong>s are put up for tender, and the lowest bid w<strong>in</strong>s. In<br />
total seven different auctions were simulated. The differences between them<br />
were based on their reserve price sett<strong>in</strong>g policy and their job cost<strong>in</strong>g policy.<br />
For the sake of clarity, space and <strong>in</strong>terest, only three of the auctions will be<br />
presented. This is because these auctions were the most <strong>in</strong>terest<strong>in</strong>g, and the<br />
others were the same if not similar. The basic auction was implemented as<br />
standard with the <strong>Grid</strong>Sim distribution - although we did create the auction<br />
cost<strong>in</strong>g and bidd<strong>in</strong>g policies. In short, the different auctions were (refer to<br />
Figure 2.3 for mechanism steps):<br />
<br />
Auction df-load-dif had a broker which was drip fed currency, and the<br />
resources responded by chang<strong>in</strong>g their bidd<strong>in</strong>g price based on the load<br />
difference they experienced.<br />
30
Auction Random had a broker that had no budget, and its resources bid<br />
a random number.<br />
Auction Load had a broker that had no budget, and its resources<br />
returned the current load it was under.<br />
Auction Wait<strong>in</strong>g had a broker that had no budget, and its resources<br />
returned the current average wait<strong>in</strong>g time of jobs currently process<strong>in</strong>g.<br />
Users produce the jobs that are to be executed by the grid system.<br />
They each have a broker, which they send these jobs to at a constant<br />
rate, until they have none left (step 1). [56]<br />
Figure: 2.3 RFPSA mechanism steps.<br />
31
Brokers On receiv<strong>in</strong>g a job, the broker proceeds to make a RFPSA for it<br />
(step 2). The reserve price that it sets is dependent on the price sett<strong>in</strong>g<br />
policy chosen (step 3). In policy drip-feed (df), the broker had no<br />
budget to start with, but was given budget <strong>in</strong>jections at the same rate<br />
at which jobs were com<strong>in</strong>g <strong>in</strong>. The reserve price was set at:<br />
money from <strong>in</strong>jections − money spent / jobs wait<strong>in</strong>g at broker + jobs<br />
be<strong>in</strong>g auctioned<br />
Auction df _load-dif used this policy. This was to recreate a broker be<strong>in</strong>g drip<br />
fed currency (e.g. to-kens or money), and us<strong>in</strong>g the available currency (what<br />
it had not managed to spend) split over the jobs that it currently had. In<br />
policy no-budget, the broker had no budget. The reserve price was not set,<br />
<strong>in</strong>dicat<strong>in</strong>g that the broker would accept anyth<strong>in</strong>g. Once the reserve price was<br />
set, the auction was posted (step 4). After the auction was over, the broker<br />
would computer the w<strong>in</strong>ner(step 7) and then send the job (step 8) to the<br />
w<strong>in</strong>n<strong>in</strong>g resource. [24] [64]<br />
<br />
Resources first receive notification that an auction is tak<strong>in</strong>g place. The<br />
method that the resource uses to cost the job is dependent on the<br />
policy chosen (step 5). There is not space to reiterate all the policies, so<br />
only the least <strong>in</strong>tuitive will be presented here, the rema<strong>in</strong><strong>in</strong>g policies<br />
can be found <strong>in</strong> (Krawczyk 2006). In policy load difference (load-dif)<br />
the price bid by a re-source <strong>in</strong>creased or decreased depend<strong>in</strong>g on the<br />
difference <strong>in</strong> the load the resource was under from the last time it<br />
checked. Specifically load difference was calculated as:<br />
lastload<br />
− (Σ(process<strong>in</strong>g time of jobs <strong>in</strong> the queue)<br />
+ Σ(process<strong>in</strong>g time left of execut<strong>in</strong>g jobs))<br />
32
The resource would then produce a bid for the auction (step 6) and if it<br />
happened to w<strong>in</strong>, would allocate the job on a FIFO policy (step 9). [39]<br />
2.3 Fault tolerance mechanism <strong>in</strong> grid:<br />
This section presents an application of the utility model and knapsack solution<br />
to the challenge of select<strong>in</strong>g between fault tolerances techniques. On a typical<br />
grid, there are many ways to handle failed tasks, <strong>in</strong>clud<strong>in</strong>g retry<strong>in</strong>g,<br />
replication, and check po<strong>in</strong>t<strong>in</strong>g. However, given the variability <strong>in</strong> the urgency<br />
of the tasks and the reliability of the resources, it is not always apparent<br />
which of these techniques should be used for each task. By employ<strong>in</strong>g the<br />
utility model, we characterize each task's need for fault tolerance and the<br />
knapsack solution f<strong>in</strong>ds an optimal mapp<strong>in</strong>g of tasks to techniques. This work<br />
was published <strong>in</strong> the Proceed<strong>in</strong>gs of the IEEE Conference on e-Science and<br />
<strong>Grid</strong> Comput<strong>in</strong>g 2007. [60]<br />
One problem common to most grids is the prevalence of faults, which <strong>in</strong><br />
many cases are caused by the relative immaturity of grid middleware<br />
comb<strong>in</strong>ed with the asymmetric configuration and reliability of the grid<br />
resources. As such, a task and resource management system which can<br />
gracefully recover from or work around faults is paramount to a successful<br />
grid user experience. [59]<br />
<strong>Grid</strong> designers typically implement one or more of three basic techniques to<br />
provide Task-level fault tolerance. The first technique, retry, automatically<br />
resubmitstasks that have failed. The replication technique submits multiple<br />
replicas of a taskto the grid; if at least one of the replicas f<strong>in</strong>ishes<br />
successfully, the task is complete. [48][67]<br />
The third technique makes use of task checkpo<strong>in</strong>t<strong>in</strong>g to roll back failed tasks<br />
to a known-good state when a fault occurs. Each of these techniques varies <strong>in</strong><br />
implementation complexity, resource cost, resilience, and expected response<br />
time. For example, replication requires more resources than retry<strong>in</strong>g, yet <strong>in</strong><br />
33
the case of faults the response time of the task does not <strong>in</strong>crease. In the case<br />
of grids which support more than one fault tolerance technique, it is clear<br />
that the importance or urgency of a task should <strong>in</strong>fluence the technique<br />
employed. However, decid<strong>in</strong>g which tasks employ which technique is<br />
complex, <strong>in</strong>volv<strong>in</strong>g many factors that are usually unknown to users. [42]<br />
we present a technique for automatically match<strong>in</strong>g tasks to fault tolerant<br />
techniques us<strong>in</strong>g task, user, and grid metrics to compute the relative merits<br />
of each of the options. We compute the utility of each allocation option and<br />
then formulate as a knapsack problem to f<strong>in</strong>d the globally optimal allocation<br />
set. We develop three heuristics which take <strong>in</strong>to account the value offered by<br />
a user, the estimated resource cost, and the estimated response time of an<br />
option. It is shown that the utility model effectively selects from a number of<br />
fault tolerance techniques to decrease runn<strong>in</strong>g time, <strong>in</strong>crease profit, while<br />
allow<strong>in</strong>g users to prioritize their tasks. [6] [58].<br />
34
[PART THREE]<br />
The Proposal<br />
35
CHAPTER III<br />
Our Proposed<br />
Modification<br />
36
3.1 Application Field:<br />
3.1.1 Our <strong>Job</strong> allocation Mechanism<br />
In chapter two we have talked about 3 different mechanism of resource<br />
allocation. In our proposal we will work with voluntary based resource<br />
allocation mechanism.<br />
3.1.2 <strong>Job</strong> type<br />
There can be many types of job that comes to the resource broker. They are<br />
1. Random policy based jobs<br />
2. Budget optimized jobs<br />
3. Time optimized jobs<br />
In our proposal we will work with time optimized jobs. And more specifically<br />
our job type will be: <strong>Job</strong>s with strict deadl<strong>in</strong>es [66]<br />
3.2 Exist<strong>in</strong>g <strong>Allocation</strong> Technique:<br />
3.2.1 Resource Availability Comparison<br />
The ma<strong>in</strong> purpose of resource comparison based on the availability properties<br />
is to provide the resource broker and meta-scheduler a rank<strong>in</strong>g of <strong>Grid</strong><br />
resources to assist the optimized resource selection process for advance<br />
reservations and execution plann<strong>in</strong>g respectively. We compare the <strong>Grid</strong><br />
resources for their availability <strong>in</strong> two dimensions: the static availability<br />
comparison through MTBF (mean time before failure) and MTR (mean time to<br />
reboot); the dynamic availability comparison through resource stability (for<br />
different job durations), and the resource dependability (as a function of<br />
time). We argue that the later two metrics are more suitable for resource<br />
comparisons as they <strong>in</strong>clude better probabilities approximations about<br />
resources’ availability. These are described <strong>in</strong> the follow<strong>in</strong>g sections [14]<br />
37
3.2.2 Resource allocation technique <strong>in</strong> Volunteer <strong>Grid</strong>:<br />
This is the current resource allocation technique for Volunteer <strong>Grid</strong>:<br />
1. Users send their jobs to their correspond<strong>in</strong>g Resource Broker.<br />
2. Resource Broker polls all the available resources.<br />
3. Resource Broker gets a response of how many jobs these free<br />
resources can take.<br />
4. The broker distributes the jobs around to random responsive resources<br />
until it has none left.<br />
5. Resources on receiv<strong>in</strong>g a subset of jobs, assigns jobs to any free<br />
mach<strong>in</strong>es and then place any rema<strong>in</strong><strong>in</strong>g jobs <strong>in</strong> a queue. [6] [60]<br />
Figure: 3.1 Current job allocation techniques <strong>in</strong> volunteer allocation<br />
38
Here <strong>in</strong> this figure we have shown how job is allocated <strong>in</strong> different mach<strong>in</strong>es<br />
<strong>in</strong> volunteer resource allocation mechanism. At first the user sends the jobs<br />
to the resource broker. Then the resource broker gets the <strong>in</strong>formation of the<br />
resources from grid <strong>in</strong>formation service (GIS).After gett<strong>in</strong>g the <strong>in</strong>formation<br />
from the GIS the broker selects the resources that have free mach<strong>in</strong>es. And<br />
then the broker divides the jobs <strong>in</strong> many parts and assigns each part of jobs<br />
<strong>in</strong> many mach<strong>in</strong>es. so that the job is done by any means. In this technique<br />
the for one part of job many mach<strong>in</strong>es are used. suppose if the job is divided<br />
<strong>in</strong>to 3 parts and each part is assigned to 3 free mach<strong>in</strong>es then the 3 part will<br />
require 9 free mach<strong>in</strong>es. This is called replication. This is the best technique<br />
<strong>in</strong> voluntary grid out of 3 techniques discussed <strong>in</strong> section 2.3.So here many<br />
multiple mach<strong>in</strong>es are used to do a s<strong>in</strong>gle portion of a job.<br />
3.2.3 Fault Tolerance Methods:<br />
In section 2.3 it is discussed. In summary we can say <strong>Grid</strong> designers typically<br />
implement one or more of three basic techniques to provide job-level fault<br />
tolerance.<br />
Retry: Automatically resubmits tasks that have failed.<br />
Replication: Submits multiple replicas of a task to the grid, if at least<br />
one of the replicas f<strong>in</strong>ishes successfully, the task is complete.<br />
Checkpo<strong>in</strong>t<strong>in</strong>g: Rolls back failed tasks to a known-good state when a<br />
fault occurs.<br />
The Retry and Check po<strong>in</strong>t<strong>in</strong>g method isn’t feasible for jobs with strict<br />
deadl<strong>in</strong>e. So we will consider only Replication.<br />
In voluntary resource allocation method the most suitable is replication. [7]<br />
[66]<br />
39
3.2.4 Problem of Replication<br />
Absorbs additional mach<strong>in</strong>es: We have just seen <strong>in</strong> the figure 3.1<br />
that <strong>in</strong> case of replication there are always many mach<strong>in</strong>es are used for<br />
solv<strong>in</strong>g the same part of the job. So it will always use multiple<br />
mach<strong>in</strong>es which cause resource wastage <strong>in</strong> our view. [50]<br />
Decreases computational efficiency by factor of N: In the<br />
replication technique for 1 portion of a job we use N no of mach<strong>in</strong>es.<br />
But if we did not use the replication method than N no of mach<strong>in</strong>es<br />
would be used for N parts of a job. Instead of do<strong>in</strong>g that we are<br />
allocat<strong>in</strong>g all N mach<strong>in</strong>es only to one portion of the job. So the<br />
efficiency is decreas<strong>in</strong>g by the factor of N. [47]<br />
3.3 General Terms Related to <strong>Grid</strong> Resource <strong>Allocation</strong> Problem<br />
A. <strong>Reputation</strong>: <strong>Reputation</strong> provides a way of assign<strong>in</strong>g quality or value <strong>in</strong><br />
regards to a mach<strong>in</strong>e. If a mach<strong>in</strong>e is known to provide certa<strong>in</strong> qualities over<br />
a period of time irrespective of its limitations, then it is assumed to have<br />
good reputation [12]. We def<strong>in</strong>ed the value of <strong>Reputation</strong> from 0 to 10.<br />
B. <strong>Reputation</strong> Indicator: <strong>Reputation</strong> <strong>in</strong>dicator is a property that <strong>in</strong>dicates the<br />
transition of reputation of a particular mach<strong>in</strong>e. Our model has two values for<br />
<strong>Reputation</strong> Indicator, ‘Up’ and ‘Down’. [70]<br />
C. <strong>Job</strong>: <strong>Job</strong> is a b<strong>in</strong>ary executable or command to be run <strong>in</strong> a remote<br />
mach<strong>in</strong>e. The remote mach<strong>in</strong>e to be contacted should have <strong>Grid</strong> toolkit<br />
<strong>in</strong>stalled [7]. Each job specifies its resource demand, typically the number of<br />
processors requested, the memory required, the execution environment<br />
required, deadl<strong>in</strong>e and others. [68]<br />
40
D. Resource Broker: The resource broker receives a simple and abstract<br />
resource specification from user and translates it <strong>in</strong>to a more concrete<br />
def<strong>in</strong>ition <strong>in</strong> order to f<strong>in</strong>d a match for the request [13].<br />
E. Resource: A collection of mach<strong>in</strong>es which are able to perform<br />
computations. [18]<br />
F. Resource Selection: The method of select<strong>in</strong>g a particular resource that<br />
meets user’s specifications and demand. [55]<br />
G. Resource <strong>Allocation</strong>: The methods and criteria used to allocate a particular<br />
job to a resource. [54]<br />
H. Voluntary Resource <strong>Allocation</strong>: Will<strong>in</strong>g participants with idle resources, like<br />
CPU, will happily donate these <strong>in</strong> the aid of some cause or task without any<br />
tangible remuneration for their use [6].<br />
3.4 Our Modifications:<br />
Our proposal is to implement <strong>Reputation</strong> based job allocation.<br />
<strong>Reputation</strong>: <strong>Reputation</strong> provides a way of assign<strong>in</strong>g quality or value <strong>in</strong><br />
regards to a mach<strong>in</strong>e. We def<strong>in</strong>ed the value of <strong>Reputation</strong> from 0 to 10.<br />
<strong>Reputation</strong> Indicator: <strong>Reputation</strong> <strong>in</strong>dicator is a property that <strong>in</strong>dicates<br />
the transition of reputation of a particular mach<strong>in</strong>e. Our model has two<br />
values for <strong>Reputation</strong> Indicator, ‘Up’ and ‘Down’.<br />
Changes will take place after the resource gets a subset of job.<br />
Resource will list all the free mach<strong>in</strong>es and sort them accord<strong>in</strong>g to their<br />
<strong>Reputation</strong> (REP). Mach<strong>in</strong>es hav<strong>in</strong>g same reputation will be sorted<br />
accord<strong>in</strong>g to their <strong>Reputation</strong> Indicator (REPi).<br />
41
<strong>Job</strong>s which are assigned to highly reputed mach<strong>in</strong>es won’t be assigned<br />
to other mach<strong>in</strong>es. <strong>Job</strong>s assigned to medium reputed mach<strong>in</strong>es will be<br />
assigned to another mach<strong>in</strong>e. <strong>Job</strong>s assigned to lower reputed mach<strong>in</strong>es<br />
will also be assigned to two other mach<strong>in</strong>es.<br />
Figure 3.2(a): Exist<strong>in</strong>g Model<br />
Figure 3.2(b): Proposed Model<br />
Here <strong>in</strong> Figure 3.2(a) we have shown the exist<strong>in</strong>g model which is currently<br />
used. In Figure 3.2(b) we have proposed our model with slight modification <strong>in</strong><br />
job allocation us<strong>in</strong>g reputation. So we <strong>in</strong>troduced a reputation management<br />
system.<br />
3.4.1 <strong>Job</strong> allocation <strong>in</strong> our model:<br />
In our modified model job will be allocated to the mach<strong>in</strong>e accord<strong>in</strong>g to their<br />
reputation. We have divided the reputation <strong>in</strong> 3 parts. High, Medium and low.<br />
42
If the high reputation mach<strong>in</strong>e is free then there will be no replication<br />
If the medium reputation mach<strong>in</strong>e is free but high reputation mach<strong>in</strong>e<br />
is not free then there will be 2 replication <strong>in</strong> the mach<strong>in</strong>es with medium<br />
reputation<br />
If the low reputation mach<strong>in</strong>e is free but other (high+medium)<br />
mach<strong>in</strong>es are not free then there will be 3 replication <strong>in</strong> the mach<strong>in</strong>es<br />
with medium reputation.<br />
Figure 3.3 <strong>Reputation</strong> based job allocation<br />
3.4.2 <strong>Reputation</strong> Management<br />
Mach<strong>in</strong>es will have REP values from 0 to 10. We will consider 3 types of<br />
mach<strong>in</strong>e depend<strong>in</strong>g on their REP value:<br />
• High Reputed ( REP > 8 )<br />
43
• Medium Reputed ( REP > 5 and REP
3.4.4 Why REPi is needed?<br />
It ensures another level of comparison and solves the case of multiple<br />
mach<strong>in</strong>es hav<strong>in</strong>g same REP value.<br />
In figure 3.4(b) both the mach<strong>in</strong>e will have same reputation of 5.But the<br />
latter mach<strong>in</strong>e will have up <strong>in</strong>dicator and the first mach<strong>in</strong>e will have down<br />
<strong>in</strong>dicator. So whenever the resource broker will choose any resource of same<br />
reputation value it will select that resource which will have the up <strong>in</strong>dicator.<br />
What will be mach<strong>in</strong>es <strong>in</strong>itial reputation?<br />
Answer: We will consider three cases when we will simulate the model.<br />
• Initial REP = 0 (Low <strong>Reputation</strong>)<br />
• Initial REP = 5 (Medium <strong>Reputation</strong>)<br />
• Initial REP = Random (0, 10)<br />
3.5 Pseudo code of our proposed Model<br />
//after resource broker sends the job to a resource<br />
Getjob j from broker;<br />
Mach<strong>in</strong>e[]=list all the free mach<strong>in</strong>es;<br />
Rep[][]=each mach<strong>in</strong>es REP and REPi values;<br />
SMach<strong>in</strong>e[]=sort all mach<strong>in</strong>es depend<strong>in</strong>g on REP and REPi;<br />
Select M= SMach<strong>in</strong>e[0];<br />
If(M.getRep()>8) {<br />
Send the job to M;<br />
}<br />
45
else if(M.getREP()>5 && M.getREP()
3.6 Performance Analysis<br />
Consider<strong>in</strong>g 3 Replication <strong>Grid</strong> Architecture and subsets of job that requires<br />
equal time.<br />
Each job replica will be assigned to 3 mach<strong>in</strong>es.<br />
It can process 9 jobs with 27 mach<strong>in</strong>es at a time.<br />
To process N jobs it needs 3N mach<strong>in</strong>es.<br />
Consider<strong>in</strong>g <strong>Reputation</strong> based <strong>Job</strong> <strong>Allocation</strong> and subsets of job that requires<br />
equal time.<br />
Mach<strong>in</strong>e Description:<br />
• 3 Mach<strong>in</strong>es with REP > 8<br />
• 3 Mach<strong>in</strong>es with REP > 5 and REP
[PART FOUR]<br />
Implementation and<br />
Test<strong>in</strong>g<br />
49
CHAPTER IV<br />
Simulation<br />
Environment<br />
50
4.1 Simulation Environment:<br />
In the simulation we tried to complete and touch all the aspect that we gave<br />
<strong>in</strong> our proposal. We simulated 2 replication system as well as 3 replication<br />
system. Our modified reputation based resource allocation system was also<br />
implemented. The reason we simulated the exist<strong>in</strong>g 2 and 3 replication<br />
system <strong>in</strong> order to compare the exist<strong>in</strong>g system with our modified system.<br />
The simulated environment was created by us<strong>in</strong>g the follow<strong>in</strong>g tools:<br />
IDE: NetBeans 6.5<br />
<br />
Database : mysql<br />
The major packages that were used <strong>in</strong> this simulation is:<br />
<br />
Algorithm<br />
o Create<strong>Job</strong>ExecutionThread.java:<br />
Creates a <strong>Job</strong>InExecution object for each job <strong>in</strong><br />
jobqueue.<br />
o Create<strong>Job</strong>ExecutionThread_<strong>Reputation</strong>.java:<br />
Creates a <strong>Job</strong>InExecution_reputation object for each<br />
job <strong>in</strong> jobqueue.It’s for our proposed reputation based allocation<br />
algorithm.<br />
o <strong>Job</strong>InExecution.java:<br />
Creates a NodeInExecution object for each job <strong>in</strong><br />
jobqueue.<br />
o <strong>Job</strong>InExecution_<strong>Reputation</strong>.java:<br />
Creates a NobeInExecution_<strong>Reputation</strong> object for<br />
each job <strong>in</strong> jobqueue. It’s for our proposed reputation based<br />
allocation algorithm.<br />
o NodeInExecution.java:<br />
Simulate execution of job <strong>in</strong> each node.<br />
51
o NodeInExecution_<strong>Reputation</strong>.java:<br />
Simulate execution of job <strong>in</strong> each node. It’s for our<br />
proposed reputation based allocation algorithm.<br />
<br />
Forms<br />
o IndexFrame.java:<br />
Ma<strong>in</strong> GUI frame for the simulator.<br />
o RandomData.java:<br />
Generates jobs and nodes with random data.<br />
o SimulationFrame.java:<br />
Views simulation <strong>in</strong>formation .<br />
o SimulationFrameThread.java:<br />
Executes the SimulationFrame.java <strong>in</strong> a thread.<br />
o TestCaseFile.java:<br />
Generates jobs and nodes from user def<strong>in</strong>ed file.<br />
<br />
<br />
JdbcConnection<br />
o DatabaseConnection.java:<br />
Provides database manipulation API for this<br />
application.<br />
SimResults<br />
o SimInfo.java:<br />
Provides simulation data for simulation.<br />
52
4.2 Tables used <strong>in</strong> the database:<br />
Random <strong>in</strong>put is been given <strong>in</strong>to the tables. After giv<strong>in</strong>g the <strong>in</strong>put <strong>in</strong>to the<br />
table we can choose either of the 3 methods.2 replication,3 replication or<br />
reputation based resource allocation method. We have 2 <strong>in</strong>put tables. The<br />
tables that are used are the follow<strong>in</strong>g:<br />
<br />
<br />
<strong>Job</strong><br />
Node_<strong>in</strong>formation<br />
For <strong>in</strong>put and output we are us<strong>in</strong>g the same tables. After runn<strong>in</strong>g the<br />
simulation we just update the tables with the new <strong>in</strong>formation.<br />
The screenshots of the tables are given below<br />
Figure: 4.1 Table ‘<strong>Job</strong>’ Before Simulation Starts<br />
53
Figure: 4.2 Table ‘Node_<strong>in</strong>formation’ Before Simulation Starts<br />
4.3 Table job after the simulation<br />
54
4.4 Table node_<strong>in</strong>formation after end<strong>in</strong>g simulation<br />
Contents of the tables before simulation are generated randomly shown <strong>in</strong><br />
figure 5.1 and 5.2. But some values of the fields are fixed. Like the status<br />
field of the job table is always given as <strong>in</strong>queue because before<br />
simulation no jobs can be done. It has to be <strong>in</strong> queue and the status field<br />
of the node <strong>in</strong>formation table is fixed to <strong>in</strong>active because no jobs are<br />
supplied to the nodes before simulation starts. The <strong>in</strong>dicator is always set<br />
as up and the reputation field is given the start<strong>in</strong>g value as 5.<br />
The tables after simulation are shown <strong>in</strong> figure 5.3 and 5.4.After this<br />
simulation the status of the job field will be done.Because all those jobs<br />
that were <strong>in</strong>queued were completed <strong>in</strong> the simulation.The status fielf of<br />
the node_<strong>in</strong>formation table will be aga<strong>in</strong> <strong>in</strong>active. It will only rema<strong>in</strong><br />
active <strong>in</strong> the time of simulation. But the reputation field will be changed<br />
accord<strong>in</strong>g to the nodes performance.<br />
55
4.3 Simulation Screenshots:<br />
After we run the simulation we get the output. The screenshots of the output<br />
result are given below:<br />
4.5 The generated database <strong>in</strong> the IDE<br />
56
4.6 Output Screen<br />
In figure 5.5 we have shown the generated database that is taken from the<br />
mysql database. In figure 5.6 the result of the simulation is shown. This is<br />
our f<strong>in</strong>al output screen of the simulation.<br />
57
CHAPTER V<br />
Implementation<br />
58
5.1 Implementation:<br />
In our simulation we actually implemented all the exist<strong>in</strong>g methods and as<br />
well as our own modification of the exist<strong>in</strong>g methods. Total we implemented<br />
3 different resource allocation systems. Two of the exist and they are<br />
<br />
<br />
2 replication system<br />
3 replication system<br />
And our proposed system is<br />
<br />
<strong>Reputation</strong> based system<br />
In our simulation we implemented all the 3 system.<br />
5.2 Two Replication System:<br />
In two replication system we will always assign two nodes for each job. So<br />
whenever we will get 2 nodes <strong>in</strong>active we will immediately assign a job to<br />
those 2 nodes. If one of the two nodes do the job then the job will be counted<br />
as done. So if there are four <strong>in</strong>active nodes and 5 jobs then we will select the<br />
first 2 jobs and assign them to the <strong>in</strong>active nodes. Whenever two nodes will<br />
be free we will assign job 3 to those <strong>in</strong>active nodes. Whenever all the jobs will<br />
be completed the simulation will be f<strong>in</strong>ished. If both the nodes fail to<br />
complete a particular job then job will aga<strong>in</strong> be resubmitted.<br />
The simulation screenshot of the two replication system is given below:<br />
59
Figure: 5.1 Two Replication System<br />
5.3 Three Replication System:<br />
In three replication system we will always assign three nodes for each job. So<br />
whenever we will get 3 <strong>in</strong>active nodes we will immediately assign a job to<br />
those 3 nodes. If one of the three nodes does the job then the job will be<br />
counted as done. So if there are six <strong>in</strong>active nodes and 5 jobs then we will<br />
select the first 2 jobs and assign them to the <strong>in</strong>active nodes. Whenever three<br />
nodes will be free we will assign the third job to those <strong>in</strong>active nodes.<br />
Whenever all the jobs will be completed the simulation will be f<strong>in</strong>ished. If all<br />
the three nodes fail to complete a particular job then job will aga<strong>in</strong> be<br />
resubmitted.<br />
60
The simulation screenshot of the three replication system is given below:<br />
Figure: 5.2 Three Replication System<br />
5.4 <strong>Reputation</strong> <strong>Based</strong> System:<br />
In reputation based system we tried to modify the two or three replication<br />
system <strong>in</strong> order to m<strong>in</strong>imize the nodes utilization. For example <strong>in</strong> Three<br />
replication system to do a job we will always assign 3 nodes to the same job<br />
and <strong>in</strong> Two replication System we assign 2 nodes to the same job. But <strong>in</strong> the<br />
reputation based system for 1 job to be done 1-3 nodes are needed.<br />
M<strong>in</strong>imum we can complete the job by 1 node and maximum we need 3<br />
nodes. So it will vary depend<strong>in</strong>g upon the reputation of the node.<br />
61
The reputation of the nodes varies from 1 to 10.<strong>Reputation</strong> greater than 8 is<br />
considered as high reputation node. For these nodes 1 job will be allocated on<br />
1 node. <strong>Reputation</strong> value less than 8 and greater than 4 will be medium<br />
reputed node. For these nodes 1 job will be assigned to 2 nodes. <strong>Reputation</strong><br />
value less than 5 up to 1 will be considered as low reputed nodes. For these<br />
nodes 1 job will be allocated <strong>in</strong> 3 nodes.<br />
So for high reputed nodes s<strong>in</strong>gle replication system, for medium reputed<br />
nodes two replication and for low reputed nodes three replication systems are<br />
applied. All of the different types systems are implemented accord<strong>in</strong>g to the<br />
reputation of the nodes.<br />
The simulation screenshot of the reputation based system is given below:<br />
Figure: 5.3 <strong>Reputation</strong> based System<br />
62
[PART FIVE]<br />
Performance<br />
Analysis and<br />
Conclusion<br />
63
CHAPTER VI<br />
Performance<br />
Analysis<br />
64
6.1 Performance analysis factors:<br />
In our performance analysis we have compared our proposed model with<br />
exist<strong>in</strong>g 2 replication model and 3 replication models with five factors. They<br />
are:<br />
<br />
<br />
<br />
<br />
<br />
Average Highest concurrent jobs<br />
Average Highest concurrent nodes<br />
Average total Successful Execution<br />
Average total failed Execution<br />
Average total Resubmissions<br />
These are the five factors that we used to compare our model with the<br />
exist<strong>in</strong>g models.All the five factors will be discussed <strong>in</strong> this chapter <strong>in</strong> details.<br />
6.2 Fault chance of mach<strong>in</strong>es:<br />
Fault chance of mach<strong>in</strong>es are random.We have chosn three values for fault<br />
chance. It is 70%, 40% and 10%. So we will get all types of machies<br />
<strong>in</strong>clud<strong>in</strong>g high quality mach<strong>in</strong>es as well as medium and low. So <strong>in</strong> our<br />
simulation these three values randomly chosen.<br />
6.3 Fault chance and Mach<strong>in</strong>e <strong>Reputation</strong> <strong>in</strong> our proposed model:<br />
In our proposed model we have three different fault chances which are<br />
chosen randomely. After runn<strong>in</strong>g the simulation for several times we<br />
observed that the mach<strong>in</strong>es which has 70% fault chance always gets a stable<br />
low reputation and mach<strong>in</strong>es with 40% fault chance always gets a stable<br />
medium reputation and the mach<strong>in</strong>es with 10% fault chance always gets a<br />
high reputation. The observation of the simulation is shown below:<br />
65
Figure: 6.1 Simulation Result for Fault chance and mach<strong>in</strong>e<br />
reputation<br />
We can see from the graph that higher the fault chance lower the reputation<br />
and lower the fault chance higher the reputation of mach<strong>in</strong>es.<br />
6.4 Simulation Result for 9 nodes:<br />
We have done a lot of simulation.The result for 2 replication 3 replication and<br />
our reputation based models are given below:<br />
66
Figure: 6.2 Simulation Result for n<strong>in</strong>e nodes<br />
From the simulation result we clearly see that our reputation based model is<br />
always perform<strong>in</strong>g well compared to the exist<strong>in</strong>g system.<br />
6.5 Simulation Result for 12 nodes:<br />
We have done a lot of simulation.The result for 2 replication 3 replication and<br />
our reputation based models are given below:<br />
67
Figure: 6.3 Simulation Result for twelve nodes<br />
From the simulation result we clearly see that our reputation based model is<br />
always perform<strong>in</strong>g well compared to the exist<strong>in</strong>g system.<br />
6.6 Simulation Result for 15 nodes:<br />
We have done a lot of simulation.The result for 2 replication 3 replication and<br />
our reputation based models are given below:<br />
68
Figure: 6.4 Simulation Result for fifteen nodes<br />
From the simulation result we clearly see that our reputation based model is<br />
always perform<strong>in</strong>g well compared to the exist<strong>in</strong>g system.<br />
6.7 Graphical Comparison:<br />
The graphical comparison between the 3 models <strong>in</strong> terms of 9 nodes, 12<br />
nodes and 15 nodes for 80 jobs are on the above five factors are given<br />
below.<br />
6.6.1 Average highest concurrent jobs:<br />
In this portion we have compared how many jobs can be done concurrently <strong>in</strong><br />
these three models.We have tested the simulation for different variables.We<br />
have tested the simulation by fix<strong>in</strong>g 80 jobs given at a time and fix<strong>in</strong>g the<br />
nodes at 6 and run the simulation.we tested it for 9 nodes and as well as 12<br />
69
nodes.The difference <strong>in</strong> the 3 models are seen clearly.We are generat<strong>in</strong>g the<br />
comparison graph below:<br />
Figure: 6.5 Simulation Result for Average highest concurrent jobs<br />
We can see from the graph that for 9 nodes, 12 nodes and 15 nodes for all<br />
cases 3 replication model is perform<strong>in</strong>g better. Our model is do<strong>in</strong>g more<br />
concurrent jobs compared to other two models.<br />
6.6.2 Average highest concurrent nodes:<br />
In this portion we have compared how many nodes are used concurrently <strong>in</strong><br />
these three models.We have tested the simulation for different variables.We<br />
have tested the simulation by fix<strong>in</strong>g 80 jobs given at a time and fix<strong>in</strong>g the<br />
nodes at 6 and run the simulation.we tested it for 9 nodes and as well as 12<br />
nodes.The difference <strong>in</strong> the 3 models are seen clearly.We are generat<strong>in</strong>g the<br />
comparison graph below:<br />
70
Figure: 6.6 Simulation Result for Average highest concurrent nodes<br />
We can see from the graph that our reputation based model always occupies<br />
fewer nodes compared to other models. So the resource utilization is high.<br />
6.6.3 Average total Successful Execution<br />
In this portion we have compared average successful job execution <strong>in</strong> these<br />
three models.We have tested the simulation for different variables.We have<br />
tested the simulation by fix<strong>in</strong>g 80 jobs given at a time and fix<strong>in</strong>g the nodes at<br />
6 and run the simulation.we tested it for 9 nodes and as well as 12 nodes.The<br />
difference <strong>in</strong> the 3 models are seen clearly.We are generat<strong>in</strong>g the comparison<br />
graph below:<br />
71
Figure: 6.7 Simulation Result for Average total Successful Execution<br />
We can see from the graph that number of successful node is less than other<br />
Two methods which means same amount of job are done with less successful<br />
node thus m<strong>in</strong>imize the wastage of node.<br />
6.6.4 Average total failed Execution:<br />
In this portion we have compared average failed job execution <strong>in</strong> these three<br />
models.We have tested the simulation for different variables.We have tested<br />
the simulation by fix<strong>in</strong>g 80 jobs given at a time and fix<strong>in</strong>g the nodes at 6 and<br />
run the simulation.we tested it for 9 nodes and as well as 12 nodes.The<br />
difference <strong>in</strong> the 3 models are seen clearly.We are generat<strong>in</strong>g the comparison<br />
graph below:<br />
72
Figure: 6.8 Simulation Result for Average total failed Execution<br />
We can see from the graph that <strong>in</strong> our REP based allocation number of node<br />
which failed to execution job is varied with the reliability of the resources.<br />
The reason our model failed more than other models <strong>in</strong> the simulation of 9<br />
nodes is because the fault chances of the mach<strong>in</strong>es were high on the<br />
simulation of 9 nodes.<br />
6.6.5 Average total Resubmissions:<br />
In this portion we have compared average failed job execution <strong>in</strong> these three<br />
models.We have tested the simulation for different variables.We have tested<br />
the simulation by fix<strong>in</strong>g 80 jobs given at a time and fix<strong>in</strong>g the nodes at 6 and<br />
run the simulation.we tested it for 9 nodes and as well as 12 nodes.The<br />
difference <strong>in</strong> the 3 models are seen clearly.We are generat<strong>in</strong>g the comparison<br />
graph below:<br />
73
Figure: 6.9 Simulation Result for Average total Resubmissions<br />
We can see from the graph that <strong>in</strong> our REP based allocation number of jobs<br />
which are resubmitted due to failure of the node is varied with the fault<br />
chance of nodes. The reason our model resubmitted more than other models<br />
<strong>in</strong> the simulation of 9 nodes is because the fault chance of the mach<strong>in</strong>es was<br />
high on the simulation of 9 nodes.<br />
74
CHAPTER VII<br />
Conclusion<br />
75
7.1 Conclusion<br />
In this thesis we tried to show various types of resource allocation<br />
mechanism. We showed how each mechanism works and their job selection<br />
methods. We have chosen the volunteer resource allocation mechanism. We<br />
tried to modify the system by add<strong>in</strong>g a reputation management system. Our<br />
implementation <strong>in</strong>creases resource (mach<strong>in</strong>e) utilization than the exist<strong>in</strong>g<br />
system.<br />
7.2 Future Modifications:<br />
We can implement <strong>Reputation</strong> <strong>Based</strong> <strong>Allocation</strong> <strong>in</strong> Resource level where<br />
a Resource's REP will be calculated by average of all the mach<strong>in</strong>es it<br />
consists.<br />
A Resource with high REP values will <strong>in</strong>dicate that it consists mach<strong>in</strong>es<br />
with higher <strong>Reputation</strong>.<br />
Resource broker will prefer Resources with higher <strong>Reputation</strong>s.<br />
Thus another comparison can be implemented <strong>in</strong> Resource level.<br />
76
References<br />
77
[1] Market Economy <strong>Based</strong> resource <strong>Allocation</strong> <strong>in</strong> <strong>Grid</strong>s, by Sai Rahul Reddy P<br />
and Dr.Arob<strong>in</strong>da Gupta<br />
[2] A Gentle Introduction to <strong>Grid</strong> Comput<strong>in</strong>g and Technologies, by Rajkumar<br />
Buyya and Venugopal<br />
[3] Def<strong>in</strong><strong>in</strong>g the grid: a snapshot on the current view, by He<strong>in</strong>z Stock<strong>in</strong>ger<br />
[4] An Economy Driven Resource Management Architecture for Global<br />
<strong>Computational</strong> Power <strong>Grid</strong>s, by Rajkumar Buyya, David Abramson, and<br />
Jonathan Giddy<br />
[5] Introduction to <strong>Grid</strong> Comput<strong>in</strong>g, by Argonne National Laboratory USC<br />
Information Sciences Institute<br />
[6] <strong>Grid</strong> Resource <strong>Allocation</strong>: <strong>Allocation</strong> Mechanisms and Utilisation Patterns,<br />
by Stefan Krawczyk and Kris Bubendorfer<br />
[7] Resource <strong>Allocation</strong> and Schedul<strong>in</strong>g Strategies on <strong>Computational</strong> <strong>Grid</strong>s, By<br />
Daniel Col<strong>in</strong> Vanderster B.Eng , University of Victoria, 2003<br />
[8] Node <strong>Allocation</strong> In <strong>Grid</strong> Comput<strong>in</strong>g Us<strong>in</strong>g Optimal Resource Constra<strong>in</strong>t<br />
(ORC) Schedul<strong>in</strong>g, by K.Somasundaram,S.Radhakrishnan<br />
[9] An Optimal <strong>Job</strong> Selection method <strong>in</strong> Load Balanc<strong>in</strong>g Algorithms of<br />
Economical <strong>Grid</strong>s, by Mohsen Am<strong>in</strong>i Salehi, Hamid Tabatabaee Yazdi,<br />
Mohammad Reza Akbarzade Toutoonchi<br />
[10] What is the <strong>Grid</strong>? A Three Po<strong>in</strong>t Checklist, by Ian Foster<br />
[11] REPUTATION-BASED PRICING FOR GRID COMPUTING IN E-SCIENCE, by<br />
Anandasivam, Arun, University of Karlsruhe, Englerstr. 14, 76131 Karlsruhe,<br />
Germany, anandasivam@iism.uni-karlsruhe.de andNeumann, Dirk, University<br />
of Freiburg, Platz der Alten Synagoge, 79085 Freiburg, Germany,<br />
dirk.neumann@vwl.uni-freiburg.de<br />
78
[12] <strong>Reputation</strong>-<strong>Based</strong> <strong>Grid</strong> Resource Selection, by Beulah Kurian<br />
Alunkal,Ivana Veljkovic, Gregor von Laszewski and Kaizar Am<strong>in</strong><br />
[13] Role of the Resource Broker <strong>in</strong> the <strong>Grid</strong>, by Enis Afgan<br />
Department of Computer and Information Sciences, University of Alabama at<br />
Birm<strong>in</strong>gham<br />
[14] Availability-based Resource Selection Risk Analysis <strong>in</strong> the <strong>Grid</strong>, by<br />
Farrukh Nadeem , Radu Prodan, Thomas Fahr<strong>in</strong>ger<br />
Institute of Computer Science University of Innsbruck<br />
and V<strong>in</strong>cent Keller<br />
Ecole Polytechnique Federale de Lausanne, LIN-STI, Switzerland<br />
[15] <strong>Grid</strong> Comput<strong>in</strong>g: A Brief Technology Analysis, by Roger Smith<br />
[16] From <strong>Grid</strong> Comput<strong>in</strong>g to cloud comput<strong>in</strong>g-The IBM approach, by<br />
P.Sambath Narayan PhD, India Systems and Technology Lab IBM.<br />
[17] Anderson, D. (2004), BOINC: A System for Public-Resource Comput<strong>in</strong>g<br />
and Storage, <strong>in</strong> ‘5 th IEEE/ACM InternationalWorkshop on <strong>Grid</strong> Comput<strong>in</strong>g’, pp.<br />
365–372.<br />
[18] Anderson, D. P., Cobb, J., Korpela, E., Lebofsky, M.& Werthimer, D.<br />
(2002), ‘SETI@home - An Experiment <strong>in</strong> Public-Resource Comput<strong>in</strong>g’,<br />
Communication of the ACM 45(11), 56–61.<br />
[19] Anderson, D. P., Korpela, E. & Walton, R. (2005),High-performance task<br />
distribution for volunteer comput<strong>in</strong>g, <strong>in</strong> ‘First IEEE International Conference<br />
on e-Science and <strong>Grid</strong> Technologies, Melbourne, Australia’.<br />
79
[20] Andreozzi, S., Ferrari, T., Ronchieri, E. & Monforte, S. (2005),<br />
Agreement-<strong>Based</strong> Workload and Resource Management, <strong>in</strong> ‘the first<br />
<strong>in</strong>ternational conference on escience and <strong>Grid</strong> Comput<strong>in</strong>g’, IEEE,Melbourne,<br />
Australia, pp. 181–188.<br />
[21] Bubendorfer, K. & Thomson, W. (2006), Resource management us<strong>in</strong>g<br />
untrusted auctioneers <strong>in</strong> a grid economy, <strong>in</strong> ‘proceed<strong>in</strong>gs of the 2nd IEEE<br />
International Conference on e-Science and <strong>Grid</strong> Comput<strong>in</strong>g, Amsterdam’.<br />
[22] Buyya, R. (2002), Economic-based Distributed Resource Management<br />
and Schedul<strong>in</strong>g for <strong>Grid</strong> Comput<strong>in</strong>g, PhD thesis, Monash University,<br />
Melbourne,Australia.<br />
[23] Buyya, R., Abramson, D. & Giddy, J. (2000), An Economy Driven<br />
Resource Management Architecture for Global <strong>Computational</strong> Power <strong>Grid</strong>s, <strong>in</strong><br />
‘The 7th International Conference on Parallel and Distributed Process<strong>in</strong>g<br />
Techniques and Applications (PDPTA 2000)’, Las Vegas, USA.<br />
[24] Buyya, R., Abramson, D. & Giddy, J. (2001), A Case for Economy <strong>Grid</strong><br />
Architecture for Service Oriented <strong>Grid</strong> Comput<strong>in</strong>g, <strong>in</strong> ‘Proceed<strong>in</strong>gs of 10th<br />
International Parallel and Distributed Process<strong>in</strong>g Symposium: Heterogeneous<br />
Comput<strong>in</strong>g Workshop’, San<br />
Francisco, California, USA.<br />
[25] Buyya, R. & Murshed, M. (2002), ‘<strong>Grid</strong>Sim: a toolkit for the model<strong>in</strong>g<br />
and simulation of distributed resource management and schedul<strong>in</strong>g for <strong>Grid</strong><br />
comput<strong>in</strong>g’, Concurrency and Computation: Practice and Experience 14.<br />
80
[26] Casanova, H. (2001), Simgrid: A Toolkit for the Simulation of Application<br />
Schedul<strong>in</strong>g, <strong>in</strong> ‘1st International Symposium on Cluster Comput<strong>in</strong>g and the<br />
<strong>Grid</strong>’.<br />
[27] Das, A. & Grosu, D. (2005), Comb<strong>in</strong>atorial Auction<strong>Based</strong> Protocols for<br />
Resource <strong>Allocation</strong> <strong>in</strong> <strong>Grid</strong>s,<strong>in</strong> ‘Proceed<strong>in</strong>gs of the 19th IEEE International<br />
Parallel and Distributed Process<strong>in</strong>g Symposium’.<br />
[28] Dimitrakos, T., Randal, D. M., Yuan, F., Gaeta, M.,Laria, G., Ritrovato,<br />
P., Serhan, B., Wesner, S.& Wulf, K. (2003), An emerg<strong>in</strong>g architecture<br />
enabl<strong>in</strong>g grid based application service provision, <strong>in</strong> ‘Seventh International<br />
Enterprise Distributed Object Comput<strong>in</strong>g Conference (EDOC03),<br />
Brisbane,Queensland, Australia’.<br />
[29] Elmroth, E. & Gardfjall, P. (2005), Design and Evaluation of a<br />
Decentralized System for <strong>Grid</strong>-wide Fair-share Schedul<strong>in</strong>g, <strong>in</strong> ‘the first<br />
<strong>in</strong>ternational conference on escience and <strong>Grid</strong> Comput<strong>in</strong>g’, IEEE, Melbourne,<br />
Australia, pp. 221–229.<br />
[30] Feller, M., Foster, I. & Mart<strong>in</strong>, S. (2007), Gt4 gram:A functionality and<br />
performance study, <strong>in</strong> ‘Tera<strong>Grid</strong> 07’, Madison, WI, USA.<br />
[31] Foster, I. (2002), ‘What is the <strong>Grid</strong>?A Three Po<strong>in</strong>t Checklist’, Web,<br />
http://www.gridtoday.com/02/0722/100136.html.<br />
[32] Foster, I., Kesselman, C. & Tuecke, S. (2001), ‘The Anatomy of the <strong>Grid</strong><br />
- Enabl<strong>in</strong>g Scalable Virtual Organizations’, Intl J. Supercomputer Applications.<br />
[33] <strong>Grid</strong> Resource <strong>Allocation</strong> and Agreement Protocol Work<strong>in</strong>g Group of the<br />
Global <strong>Grid</strong> Forum (2003),<br />
81
Website,http://forge.gridforum.org/projects/graap-wg.Howell, F. & McNab, R.<br />
(1998), simjava: a discrete event simulation package for java with<br />
applications <strong>in</strong> computer systems model<strong>in</strong>g, <strong>in</strong> ‘First International Conference<br />
on Web-based Model<strong>in</strong>g and Simulation, San Diego CA, Society for Computer<br />
Simulation’.<br />
[34] J.Kay & P.Lauder (1988), ‘A fair share scheduler’, Commun. ACM 31(1),<br />
44–55.<br />
[35] Kant, U. (2005), Mercatus: A toolkit for the simulation of market-based<br />
resource allocation protocols <strong>in</strong> grids, Master’s thesis, WAYNE STATE<br />
UNIVERSITY.<br />
[36] Kant, U. & Grosu, D. (2005), Double Auction Protocols for Resource<br />
<strong>Allocation</strong> <strong>in</strong> <strong>Grid</strong>s, <strong>in</strong> ‘Proceed<strong>in</strong>gs of the International Conference on<br />
Information Technology: Cod<strong>in</strong>g and Comput<strong>in</strong>g’.<br />
[37] Krawczyk, S. (2006), ‘<strong>Grid</strong> Resource <strong>Allocation</strong>: an <strong>in</strong>vestigation <strong>in</strong>to the<br />
viability of economic resource allocation’,<br />
http://www.mcs.vuw.ac.nz/research/dsrg/sk.pdf.<br />
[38] Malone, T. W., Fikes, R. E., Grant, K. R. & Howard, M. T. (1988),<br />
Enterprise: A Market-like Task Scheduler for Distributed Comput<strong>in</strong>g<br />
Environments, <strong>in</strong> H. B.A, ed., ‘The Ecology of Computation’, Elsevier Science<br />
Publishers (North-Holland), pp. 177–205.<br />
[39] Netto, M. A. S., Bubendorfer, K. & Buyya, R. (2007), Sla-based advance<br />
reservations with flexible and adaptive time qos parameters, <strong>in</strong> ‘the Fifth<br />
International Conference on Service-Oriented Comput<strong>in</strong>g’,Vienna, Austria.<br />
82
[40] Parkes, D. C., Kalagnanam, J. & Eso, M. (2001), Achiev<strong>in</strong>g Budget-<br />
Balance with Vickrey-<strong>Based</strong> Payment Schemes <strong>in</strong> Exchanges, <strong>in</strong> ‘Proceed<strong>in</strong>gs<br />
of the International Jo<strong>in</strong>t Conference on Artificial Intelligence’, pp. 1161–<br />
1168.Pourebrahimi, B., Bertels, K., Kandru, G. & Vassiliadis, S. (2006),<br />
Market-based resource allocation <strong>in</strong> grids, <strong>in</strong> ‘second IEEE International<br />
Conference on e-Science and <strong>Grid</strong> Comput<strong>in</strong>g’.<br />
[41] R. Wolski and J. Brevik and J. S. Plank and T. Bryan (2003), <strong>Grid</strong><br />
resource allocation and control us<strong>in</strong>g computational economies, <strong>in</strong> F. Berman,<br />
G. Fox & A. Hey, eds, ‘<strong>Grid</strong> Comput<strong>in</strong>g: Mak<strong>in</strong>g The Global Infrastructure a<br />
Reality’, John Wiley & Sons.<br />
[42] Raicu, I., Zhao, Y., Dumitrescu, C., Foster, I. & Wilde, M. (2007),<br />
Falkon: Fast and light-weight task execution framework, <strong>in</strong> ‘Super<br />
Comput<strong>in</strong>g’,Reno, NV, USA.<br />
[43].Regev, O. & Nisan, N. (1998), The POPCORN market— an onl<strong>in</strong>e market<br />
for computational resources, <strong>in</strong> ‘In Proceed<strong>in</strong>gs of the First International<br />
Conference on Information and Computation Economies’, ACM Press,<br />
Charleston, SC, pp. 148–157.<br />
[44] Sarmenta, L. F. (2001), Volunteer Comput<strong>in</strong>g, PhD thesis, MIT<br />
Department of Electrical Eng<strong>in</strong>eer<strong>in</strong>g and Computer Science.<br />
[45] Shannon, R. E. (1975), Systems Simulation the art and science,<br />
Prentice-Hall.<br />
[46] Sun Microsystems (2007), ‘Sun <strong>Grid</strong>’, http://www.network.com/.<br />
83
[47] Sutherland, L. E. (1968), ‘A Futures Market <strong>in</strong> Computer Time’,<br />
Communications of the ACM 11(6), 449–451. Tha<strong>in</strong>, D., Tannenbaum, T. &<br />
Livny, M. (2005), ‘Distributed comput<strong>in</strong>g <strong>in</strong> practice: the condor experience.’,<br />
Concurrency - Practice and Experience<br />
17(2-4), 323–356.<br />
[48] Vickrey, W. (1961), ‘Counterspeculation, Auctions, and Competitive<br />
Sealed Tenders’, The Journal of F<strong>in</strong>ance 16(1), 8–37.<br />
[49] Abramson, D., Giddy, J., and Kotler, L., High Performance Parametric<br />
Model<strong>in</strong>g with Nimrod/G:Killer Application for the Global <strong>Grid</strong>?,<br />
IPDPS’2000,Mexico, IEEE CS Press, USA, 2000.<br />
[50] Almond J., Snell<strong>in</strong>g D., UNICORE: uniform access to supercomput<strong>in</strong>g as<br />
an element of electronic commerce,Future Generation Computer Systems<br />
15(1999) 539-548, NHElsevier.<br />
[50] Baker M., Buyya R., Laforenza D., The <strong>Grid</strong>: International Efforts <strong>in</strong><br />
Global Comput<strong>in</strong>g, Intl.Conference on Advances <strong>in</strong> Infrastructure for<br />
Electronic Bus<strong>in</strong>ess, Science, and Education on the Internet (SSGRR'2000),<br />
Italy, 2000 (to appear).<br />
[51] Brent C. and Culler, D., Rexec: A decentralized, secure remote execution<br />
environment for clusters, 4th Workshop on Communication, Architecture, and<br />
Applications for Network-based Parallel Comput<strong>in</strong>g, France, 2000.<br />
[52] Buyya, R. (ed.), High Performance Cluster Comput<strong>in</strong>g:Architectures and<br />
Systems, Volume 1 and 2, Prentice Hall PTR, NJ, USA, 1999.<br />
84
[53] Buyya, R., Abramson, D., and Giddy, J., Nimrod/G: An<br />
Architecture for a Resource Management and Schedul<strong>in</strong>g System <strong>in</strong> a Global<br />
<strong>Computational</strong> <strong>Grid</strong>, HPC ASIA’2000, Ch<strong>in</strong>a, IEEE CS Press, USA, 2000.<br />
[54] Berman F. and Wolski R., The AppLeS Project: A Status Report,<br />
Proceed<strong>in</strong>gs of the Eight NEC Research Symposium, Germany, May 1997.<br />
[55] Chap<strong>in</strong> S., Clement M., and Snell Q., Strawman 1: A <strong>Grid</strong> Resource<br />
Management Architecture, <strong>Grid</strong> Forum Schedul<strong>in</strong>g Work<strong>in</strong>g Group, Nov. 1999.<br />
[56] Casanova H. and Dongarra, J., NetSolve: A Network Server for Solv<strong>in</strong>g<br />
<strong>Computational</strong> Science Problems, Intl. Journal of Supercomput<strong>in</strong>g<br />
Applications and High<br />
Performance Comput<strong>in</strong>g, Vol. 11, No. 3, 1997.<br />
[57] Czajkowski K., Foster I., Karonis N., Kesselman C.,Mart<strong>in</strong> S., Smith W.,<br />
and Tuecke S., A Resource Management Architecture for Metacomput<strong>in</strong>g<br />
Systems, IPPS/SPDP '98 Workshop on <strong>Job</strong> Schedul<strong>in</strong>g Strategies for Parallel<br />
Process<strong>in</strong>g, 1998.<br />
[58] Distributed.Net – http://www.distributed.net/<br />
[59] Distributed ASCI Supercomputer (DAS) -http://www.cs.vu.nl/das/<br />
[60] Dongarra J., An Overview of <strong>Computational</strong> <strong>Grid</strong>s and Survey of a Few<br />
Research Projects, Symposium on Global Information Process<strong>in</strong>g Technology,<br />
Japan, 1999.<br />
85
[61] Foster I. and Kesselman C., Globus: A Metacomput<strong>in</strong>g Infrastructure<br />
Toolkit, International Journal of Supercomputer Applications, 11(2): 115-128,<br />
1997.<br />
[62] Foster, I., and Kesselman, C. (editors), The <strong>Grid</strong>:Bluepr<strong>in</strong>t for a New<br />
Comput<strong>in</strong>g Infrastructure, Morgan Kaufmann Publishers, USA, 1999.<br />
[63] Globus Project - http://www.globus.org<br />
[64] Globus Testbeds - http://www-fp.globus.org/testbeds/<br />
[65] <strong>Grid</strong> Forum - http://www.gridforum.org/<br />
[66] GF Schedul<strong>in</strong>g Work<strong>in</strong>g Group, General Meet<strong>in</strong>g Notes, 3rd <strong>Grid</strong> Forum<br />
Meet<strong>in</strong>g, March’2000.<br />
[67] <strong>Grid</strong>ware, Cod<strong>in</strong>e/GRD, http://www.gridware.com<br />
[68] JaWS - http://roadrunner.ics.forth.gr:8080/<br />
[69] Legion - http://legion.virg<strong>in</strong>ia.edu/<br />
[70] LSF Home Page - http://www.platform.com<br />
[71] Schopf J., Nitzberg B., Chap<strong>in</strong> S., Clement M., and Snell Q, Strawman2:<br />
A <strong>Grid</strong> Resource Management Architecture, GF Schedul<strong>in</strong>g Work<strong>in</strong>g Group,<br />
Dec. 1999.<br />
[72] SETI@Home – http://setiathome.ssl.berkeley.edu/<br />
86
[73] N<strong>in</strong>f - http://n<strong>in</strong>f.etl.go.jp/<br />
[74] Thigpen B. and Hacker T., Distributed Account<strong>in</strong>g on the<br />
<strong>Grid</strong>, The <strong>Grid</strong> Forum Work<strong>in</strong>g Drafts, 2000.<br />
87
Appendix<br />
88
Class:Create<strong>Job</strong>ExecutionThread.java<br />
package Algorithm;<br />
import Forms.SimulationFrame;<br />
import JdbcConnection.DatabaseConnection;<br />
public class Create<strong>Job</strong>ExecutionThread extends Thread {<br />
<strong>in</strong>t nodeneeded;<br />
boolean stop = false;<br />
public Create<strong>Job</strong>ExecutionThread(<strong>in</strong>t nodeneeded) {<br />
SimulationFrame.editorpane.setText("Create<strong>Job</strong>ExecutionThread Starts .....");<br />
this.nodeneeded = nodeneeded;<br />
}<br />
public void run() {<br />
while (!stop) {<br />
Str<strong>in</strong>g jobselectquery = "SELECT * FROM `job` WHERE `status`='<strong>in</strong>queue' or<br />
`status`='fail' order by `jobid`";<br />
<strong>in</strong>t job<strong>in</strong>queue = DatabaseConnection.countQuery(jobselectquery);<br />
if (job<strong>in</strong>queue != 0) {<br />
Str<strong>in</strong>g nodeavailablequery = "SELECT `nodeid` FROM `node_<strong>in</strong>formation`<br />
WHERE `status`='<strong>in</strong>active'";<br />
<strong>in</strong>t nodeavailable = DatabaseConnection.countQuery(nodeavailablequery);<br />
if (nodeavailable > 1) {<br />
Str<strong>in</strong>g jobselectquery2 = "SELECT * FROM `job` WHERE `status`='<strong>in</strong>queue' or<br />
`status`='fail' order by `jobid`";<br />
Object jobdata[] =<br />
DatabaseConnection.getS<strong>in</strong>gleRowQueryObjects(jobselectquery2);<br />
<strong>in</strong>t jobid = Integer.parseInt("" + jobdata[0]);<br />
Str<strong>in</strong>g resub = "SELECT `status` FROM `job` WHERE `jobid`=" + jobid;<br />
Str<strong>in</strong>g status = DatabaseConnection.s<strong>in</strong>gleStOPQuery(resub);<br />
if (status.equals("fail")) {<br />
SimResults.SimInfo.resub<strong>Job</strong>s++;<br />
}<br />
Str<strong>in</strong>g Selectedjob = "SELECTED <strong>Job</strong> : " + jobid;<br />
SimulationFrame.appendToEditorpane(Selectedjob);<br />
<strong>in</strong>t timeneeded = Integer.parseInt("" + jobdata[1]);<br />
if (nodeneeded < nodeavailable) {<br />
Str<strong>in</strong>g statusUpdate = "UPDATE `job` SET `status` = 'onProcess' WHERE<br />
`jobid` = " + jobid;<br />
DatabaseConnection.<strong>in</strong>sertUpadateQuery(statusUpdate);<br />
<strong>Job</strong>InExecution jb = new <strong>Job</strong>InExecution(jobid, timeneeded, nodeneeded);<br />
jb.start();<br />
} else {<br />
SimulationFrame.appendToEditorpane("INTERRUPTION Not Enough Nodes<br />
for <strong>Job</strong> : " + jobid);<br />
}<br />
}<br />
89
} else {<br />
try {<br />
Thread.sleep(100);<br />
} catch (Exception ex) {<br />
System.out.pr<strong>in</strong>tln("Interupted" + ex.getMessage());<br />
}<br />
Str<strong>in</strong>g jobselectqueryC = "SELECT * FROM `job` WHERE `status`='<strong>in</strong>queue' or<br />
`status`='fail' order by `jobid`";<br />
<strong>in</strong>t job<strong>in</strong>queueC = DatabaseConnection.countQuery(jobselectqueryC);<br />
if (job<strong>in</strong>queueC == 0) {<br />
SimResults.SimInfo.endSim = true;<br />
break;<br />
}<br />
}<br />
try {<br />
Thread.sleep(50);<br />
} catch (Exception ex) {<br />
System.out.pr<strong>in</strong>tln("Interupted" + ex.getMessage());<br />
}<br />
}<br />
try {<br />
Thread.sleep(500);<br />
} catch (Exception ex) {<br />
System.out.pr<strong>in</strong>tln("Interupted" + ex.getMessage());<br />
}<br />
SimulationFrame.appendToEditorpane("> ResBroker | No <strong>Job</strong>s InQueue.");<br />
stop = true;<br />
}}<br />
Class:Create<strong>Job</strong>ExecutionThread_<strong>Reputation</strong>.java<br />
package Algorithm;<br />
import Forms.SimulationFrame;<br />
import JdbcConnection.DatabaseConnection;<br />
public class Create<strong>Job</strong>ExecutionThread_<strong>Reputation</strong> extends Thread {<br />
boolean stop= false;<br />
public Create<strong>Job</strong>ExecutionThread_<strong>Reputation</strong>() {<br />
SimulationFrame.editorpane.setText("Create<strong>Job</strong>ExecutionThread Starts .....");<br />
}<br />
public void run() {<br />
while (!stop) {<br />
Str<strong>in</strong>g jobselectquery = "SELECT * FROM `job` WHERE `status`='<strong>in</strong>queue' or<br />
`status`='fail' order by `jobid`";<br />
<strong>in</strong>t job<strong>in</strong>queue = DatabaseConnection.countQuery(jobselectquery);<br />
if (job<strong>in</strong>queue != 0) {<br />
Str<strong>in</strong>g nodeavailablequery = "SELECT `nodeid` FROM `node_<strong>in</strong>formation`<br />
WHERE `status`='<strong>in</strong>active';";<br />
90
<strong>in</strong>t nodeavailable = DatabaseConnection.countQuery(nodeavailablequery);<br />
if (nodeavailable > 1) {<br />
Str<strong>in</strong>g jobselectquery2 = "SELECT * FROM `job` WHERE `status`='<strong>in</strong>queue' or<br />
`status`='fail' order by `jobid`";<br />
Object jobdata[] =<br />
DatabaseConnection.getS<strong>in</strong>gleRowQueryObjects(jobselectquery2);<br />
<strong>in</strong>t jobid = Integer.parseInt("" + jobdata[0]);<br />
Str<strong>in</strong>g resub = "SELECT `status` FROM `job` WHERE `jobid`=" + jobid;<br />
Str<strong>in</strong>g status = DatabaseConnection.s<strong>in</strong>gleStOPQuery(resub);<br />
if (status.equals("fail")) {<br />
SimResults.SimInfo.resub<strong>Job</strong>s++;<br />
}<br />
Str<strong>in</strong>g Selectedjob = "SELECTED <strong>Job</strong> : " + jobid;<br />
SimulationFrame.appendToEditorpane(Selectedjob);<br />
<strong>in</strong>t timeneeded = Integer.parseInt("" + jobdata[1]);<br />
if (nodeavailable != 0) {<br />
Str<strong>in</strong>g statusUpdate = "UPDATE `job` SET `status` = 'onProcess' WHERE<br />
`jobid` = " + jobid;<br />
DatabaseConnection.<strong>in</strong>sertUpadateQuery(statusUpdate);<br />
<strong>Job</strong>InExecution_<strong>Reputation</strong> jb = new <strong>Job</strong>InExecution_<strong>Reputation</strong>(jobid,<br />
timeneeded);<br />
jb.start();<br />
} else {<br />
SimulationFrame.appendToEditorpane("INTERRUPTION Not Enough Nodes<br />
for <strong>Job</strong> : " + jobid);<br />
}<br />
}<br />
} else {<br />
try {<br />
Thread.sleep(100);<br />
} catch (Exception ex) {<br />
System.out.pr<strong>in</strong>tln("Interupted" + ex.getMessage());<br />
}<br />
Str<strong>in</strong>g jobselectqueryC = "SELECT * FROM `job` WHERE `status`='<strong>in</strong>queue' or<br />
`status`='fail' order by `jobid`";<br />
<strong>in</strong>t job<strong>in</strong>queueC = DatabaseConnection.countQuery(jobselectqueryC);<br />
if (job<strong>in</strong>queueC == 0) {<br />
SimResults.SimInfo.endSim = true;<br />
break;<br />
}<br />
}<br />
try {<br />
Thread.sleep(50);<br />
} catch (Exception ex) {<br />
System.out.pr<strong>in</strong>tln("Interupted" + ex.getMessage());<br />
}<br />
}<br />
try {<br />
Thread.sleep(100);<br />
} catch (Exception ex) {<br />
System.out.pr<strong>in</strong>tln("Interupted" + ex.getMessage());<br />
91
}<br />
SimulationFrame.appendToEditorpane("> ResBroker | No <strong>Job</strong>s InQueue.");<br />
stop = true;<br />
}}<br />
Class : <strong>Job</strong>InExecution.java<br />
package Algorithm;<br />
import Forms.SimulationFrame;<br />
import JdbcConnection.DatabaseConnection;<br />
public class <strong>Job</strong>InExecution extends Thread {<br />
<strong>in</strong>t jobid;<br />
<strong>in</strong>t timeneeded;<br />
<strong>in</strong>t nodeneeded;<br />
<strong>in</strong>t doneflag = 0;<br />
public <strong>Job</strong>InExecution(<strong>in</strong>t jobid, <strong>in</strong>t timeneeded, <strong>in</strong>t nodeneeded) {<br />
this.jobid = jobid;<br />
this.nodeneeded = nodeneeded;<br />
this.timeneeded = timeneeded;<br />
}<br />
public void run() {<br />
Str<strong>in</strong>g assignjobquery = "SELECT * FROM `node_<strong>in</strong>formation` WHERE<br />
`status`='<strong>in</strong>active' limit 0," + nodeneeded;<br />
Str<strong>in</strong>g allocation = "SEARCHING Nodes for <strong>Job</strong> : " + jobid;<br />
SimulationFrame.appendToEditorpane(allocation);<br />
Object nodedata[][] = DatabaseConnection.getMultiRowQueryObjects(assignjobquery);<br />
for (<strong>in</strong>t i = 0; i < nodeneeded; i++) {<br />
<strong>in</strong>t nodeid = Integer.parseInt(nodedata[i][0] + "");<br />
<strong>in</strong>t faultchance = Integer.parseInt(nodedata[i][4] + "");<br />
<strong>in</strong>t uptime = Integer.parseInt(nodedata[i][5] + "");<br />
Str<strong>in</strong>g resource = "ASSIGNING <strong>Job</strong> : " + jobid + " to Node : " + nodeid;<br />
SimulationFrame.appendToEditorpane(resource);<br />
SimulationFrame.appendToEditorpane("EXECUTING <strong>Job</strong> : " + jobid + " on Node : " +<br />
nodeid);<br />
Str<strong>in</strong>g updatenodebeforejob = "UPDATE `node_<strong>in</strong>formation` SET `status` =<br />
'active',`do<strong>in</strong>g_jobid` = '" + jobid + "' WHERE `nodeid` =" + nodeid;<br />
DatabaseConnection.<strong>in</strong>sertUpadateQuery(updatenodebeforejob);<br />
NodeInExecution nie = new NodeInExecution(nodeid, jobid, timeneeded,<br />
faultchance, uptime);<br />
nie.start();<br />
}<br />
this.suspend();<br />
}<br />
}<br />
92
Class: <strong>Job</strong>InExecution_<strong>Reputation</strong>.java<br />
package Algorithm;<br />
import Forms.SimulationFrame;<br />
import JdbcConnection.DatabaseConnection;<br />
public class <strong>Job</strong>InExecution_<strong>Reputation</strong> extends Thread {<br />
<strong>in</strong>t jobid;<br />
<strong>in</strong>t timeneeded;<br />
<strong>in</strong>t doneflag = 0;<br />
public <strong>Job</strong>InExecution_<strong>Reputation</strong>(<strong>in</strong>t jobid, <strong>in</strong>t timeneeded) {<br />
this.jobid = jobid;<br />
this.timeneeded = timeneeded;<br />
}<br />
public void run() {<br />
Str<strong>in</strong>g assignjobquery = "SELECT nodeid, reputation, <strong>in</strong>dicator FROM<br />
`node_<strong>in</strong>formation` WHERE `status`='<strong>in</strong>active' order by reputation desc, <strong>in</strong>dicator desc limit<br />
0,1";<br />
Str<strong>in</strong>g allocation = "SEARCHING Nodes for <strong>Job</strong> : " + jobid;<br />
SimulationFrame.appendToEditorpane(allocation);<br />
Object nodedata[][] = DatabaseConnection.getMultiRowQueryObjects(assignjobquery);<br />
try {<br />
Thread.sleep(30);<br />
} catch (InterruptedException ex) {<br />
}<br />
<strong>in</strong>t reputation = Integer.parseInt(nodedata[0][1].toStr<strong>in</strong>g());<br />
<strong>in</strong>t nodeneeded = nodeNeeded(reputation);<br />
//System.out.pr<strong>in</strong>tln("<strong>Reputation</strong>: " + reputation + " ID: " + this.getId() + " Node<br />
Needed: " + nodeneeded);<br />
for (<strong>in</strong>t i = 0; i < nodeneeded; i++) {<br />
Str<strong>in</strong>g assignjobquery1 = "SELECT * FROM `node_<strong>in</strong>formation` WHERE<br />
`status`='<strong>in</strong>active' order by reputation desc, <strong>in</strong>dicator desc limit 0,1";<br />
Object nodedata1[][] =<br />
DatabaseConnection.getMultiRowQueryObjects(assignjobquery1);<br />
try {<br />
Thread.sleep(10);<br />
} catch (InterruptedException ex) {<br />
}<br />
<strong>in</strong>t nodeid = Integer.parseInt(nodedata1[0][0].toStr<strong>in</strong>g());<br />
<strong>in</strong>t faultchance = Integer.parseInt(nodedata1[0][4].toStr<strong>in</strong>g());<br />
<strong>in</strong>t uptime = Integer.parseInt(nodedata1[0][5].toStr<strong>in</strong>g());<br />
//System.out.pr<strong>in</strong>tln("Node: " + nodeid + " ID: " + this.getId());<br />
Str<strong>in</strong>g resource = "ASSIGNING <strong>Job</strong> : " + jobid + " to Node : " + nodeid;<br />
SimulationFrame.appendToEditorpane(resource);<br />
SimulationFrame.appendToEditorpane("EXECUTING <strong>Job</strong> : " + jobid + " on Node : " +<br />
nodeid);<br />
93
Str<strong>in</strong>g updatenodebeforejob = "UPDATE `node_<strong>in</strong>formation` SET `status` =<br />
'active',`do<strong>in</strong>g_jobid` = '" + jobid + "' WHERE `nodeid` =" + nodeid;<br />
DatabaseConnection.<strong>in</strong>sertUpadateQuery(updatenodebeforejob);<br />
NodeInExecution_<strong>Reputation</strong> niep = new NodeInExecution_<strong>Reputation</strong>(nodeid, jobid,<br />
timeneeded, faultchance, uptime);<br />
niep.start();<br />
}<br />
this.suspend();<br />
}<br />
public <strong>in</strong>t nodeNeeded(<strong>in</strong>t rep) {<br />
if (rep > 8) {<br />
return 1;<br />
}<br />
if (rep > 5 && rep
}<br />
public void run() {<br />
Random generator = new Random();<br />
<strong>in</strong>t rand = generator.nextInt(100);<br />
if (rand > faultchance*10) {<br />
try {<br />
Thread.sleep(timeneeded);<br />
} catch (Exception ex) {<br />
System.out.pr<strong>in</strong>tln("Interupted" + ex.getMessage());<br />
}<br />
Str<strong>in</strong>g jobdone = "COMPLETED <strong>Job</strong> : " + jobid + " on Node : " + nodeid;<br />
SimResults.SimInfo.successNodes++;<br />
SimulationFrame.appendToEditorpane(jobdone);<br />
Str<strong>in</strong>g updatejob = "UPDATE `job` SET `status` = 'done' WHERE `jobid` ='" +<br />
jobid + "'";<br />
DatabaseConnection.<strong>in</strong>sertUpadateQuery(updatejob);<br />
Str<strong>in</strong>g updatenodeafterjob = "UPDATE `node_<strong>in</strong>formation` SET `status` =<br />
'<strong>in</strong>active',`do<strong>in</strong>g_jobid` = '0' WHERE `nodeid` =" + nodeid;<br />
DatabaseConnection.<strong>in</strong>sertUpadateQuery(updatenodeafterjob);<br />
Str<strong>in</strong>g releaseresource = "RELEASED Node : " + nodeid + " for Completed <strong>Job</strong> : " +<br />
jobid;<br />
SimulationFrame.appendToEditorpane(releaseresource);<br />
} else {<br />
try {<br />
Thread.sleep(timeneeded / 2);<br />
} catch (Exception ex) {<br />
System.out.pr<strong>in</strong>tln("Interupted" + ex.getMessage());<br />
}<br />
SimulationFrame.appendToEditorpane("FAILED Node : " + nodeid + " Failed on <strong>Job</strong> :<br />
" + jobid + " Uptime : " + uptime);<br />
SimResults.SimInfo.failedNodes++;<br />
try {<br />
Thread.sleep(uptime);<br />
} catch (Exception ex) {<br />
System.out.pr<strong>in</strong>tln("Interupted" + ex.getMessage());<br />
}<br />
Str<strong>in</strong>g updatenodeafterjob = "UPDATE `node_<strong>in</strong>formation` SET `status` =<br />
'<strong>in</strong>active',`do<strong>in</strong>g_jobid` = '0' WHERE `nodeid` =" + nodeid;<br />
DatabaseConnection.<strong>in</strong>sertUpadateQuery(updatenodeafterjob);<br />
Str<strong>in</strong>g releaseresource = "RELEASED Node : " + nodeid + " for Failed <strong>Job</strong> : " + jobid;<br />
SimulationFrame.appendToEditorpane(releaseresource);<br />
Str<strong>in</strong>g check<strong>Job</strong>Status = "> ResBroker | Node : " + nodeid + " Check<strong>in</strong>g <strong>Job</strong> : " +<br />
jobid + " for other Nodes";<br />
SimulationFrame.appendToEditorpane(check<strong>Job</strong>Status);<br />
Str<strong>in</strong>g resubmit = "SELECT `status` FROM `job` WHERE `jobid` ='" + jobid + "'";<br />
Str<strong>in</strong>g status = DatabaseConnection.s<strong>in</strong>gleStOPQuery(resubmit);<br />
if (!status.equals("done")) {<br />
95
Str<strong>in</strong>g updatejobFail = "UPDATE `job` SET `status` = 'fail' WHERE `jobid` ='" +<br />
jobid + "'";<br />
DatabaseConnection.<strong>in</strong>sertUpadateQuery(updatejobFail);<br />
Str<strong>in</strong>g reSubmit<strong>Job</strong> = "XXX> ResBroker | Resubmitted Failed <strong>Job</strong> : " + jobid;<br />
SimulationFrame.appendToEditorpane(reSubmit<strong>Job</strong>);<br />
} else {<br />
Str<strong>in</strong>g complete<strong>Job</strong> = "> ResBroker | <strong>Job</strong> : " + jobid + " already F<strong>in</strong>ished. Node :<br />
" + nodeid + " Not ReSubmitt<strong>in</strong>g.";<br />
SimulationFrame.appendToEditorpane(complete<strong>Job</strong>);<br />
}<br />
}<br />
//this.stop();<br />
}<br />
}<br />
Class: NodeInExecution_<strong>Reputation</strong>.java<br />
package Algorithm;<br />
import Forms.SimulationFrame;<br />
import JdbcConnection.DatabaseConnection;<br />
import java.util.Random;<br />
public class NodeInExecution_<strong>Reputation</strong> extends Thread {<br />
<strong>in</strong>t nodeid, jobid, timeneeded, faultchance, reputation, uptime;<br />
public NodeInExecution_<strong>Reputation</strong>(<strong>in</strong>t node_id, <strong>in</strong>t job_id, <strong>in</strong>t time_needed, <strong>in</strong>t<br />
fault_chance, <strong>in</strong>t up_time) {<br />
this.nodeid = node_id;<br />
this.jobid = job_id;<br />
this.timeneeded = time_needed * 10;<br />
this.faultchance = fault_chance;<br />
Str<strong>in</strong>g reputationQuery = "SELECT `reputation` FROM `node_<strong>in</strong>formation` WHERE<br />
`nodeid`=" + node_id;<br />
Str<strong>in</strong>g rep = DatabaseConnection.s<strong>in</strong>gleStOPQuery(reputationQuery);<br />
this.reputation = Integer.parseInt(rep);<br />
this.uptime = up_time;<br />
}<br />
@Override<br />
public void run() {<br />
Random generator = new Random();<br />
<strong>in</strong>t rand = generator.nextInt(100);<br />
if (rand > faultchance*10) {<br />
try {<br />
Thread.sleep(timeneeded);<br />
} catch (Exception ex) {<br />
System.out.pr<strong>in</strong>tln("Interupted" + ex.getMessage());<br />
}<br />
Str<strong>in</strong>g jobdone = "COMPLETED <strong>Job</strong> : " + jobid + " on Node : " + nodeid;<br />
SimResults.SimInfo.successNodes++;<br />
96
SimulationFrame.appendToEditorpane(jobdone);<br />
Str<strong>in</strong>g updatejob = "UPDATE `job` SET `status` = 'done' WHERE `jobid` ='" +<br />
jobid + "'";<br />
DatabaseConnection.<strong>in</strong>sertUpadateQuery(updatejob);<br />
if (reputation >= 10) {<br />
reputation = 10;<br />
} else {<br />
reputation++;<br />
}<br />
SimulationFrame.appendToEditorpane("> ResBroker | Increas<strong>in</strong>g <strong>Reputation</strong> of Node<br />
: " + nodeid);<br />
Str<strong>in</strong>g updatenodeafterjob = "UPDATE `node_<strong>in</strong>formation` SET `status` =<br />
'<strong>in</strong>active',`do<strong>in</strong>g_jobid` = '0',`<strong>in</strong>dicator`='up',`reputation`=" + reputation + " WHERE<br />
`nodeid` =" + nodeid;<br />
DatabaseConnection.<strong>in</strong>sertUpadateQuery(updatenodeafterjob);<br />
Str<strong>in</strong>g releaseresource = "RELEASED Node : " + nodeid + " for Completed <strong>Job</strong> : " +<br />
jobid;<br />
SimulationFrame.appendToEditorpane(releaseresource);<br />
} else {<br />
try {<br />
Thread.sleep(timeneeded / 2);<br />
} catch (Exception ex) {<br />
System.out.pr<strong>in</strong>tln("Interupted" + ex.getMessage());<br />
}<br />
SimulationFrame.appendToEditorpane("FAILED Node : " + nodeid + " Failed on <strong>Job</strong> :<br />
" + jobid + " Uptime : " + uptime);<br />
SimResults.SimInfo.failedNodes++;<br />
if (reputation
} catch (Exception ex) {<br />
System.out.pr<strong>in</strong>tln("Interupted" + ex.getMessage());<br />
}*/<br />
Str<strong>in</strong>g resubmit = "SELECT `status` FROM `job` WHERE `jobid` ='" + jobid + "'";<br />
Str<strong>in</strong>g status = DatabaseConnection.s<strong>in</strong>gleStOPQuery(resubmit);<br />
if (!status.equals("done")) {<br />
Str<strong>in</strong>g updatejobFail = "UPDATE `job` SET `status` = 'fail' WHERE `jobid` ='" +<br />
jobid + "'";<br />
DatabaseConnection.<strong>in</strong>sertUpadateQuery(updatejobFail);<br />
Str<strong>in</strong>g reSubmit<strong>Job</strong> = "XXX> ResBroker | Resubmitted Failed <strong>Job</strong> : " + jobid;<br />
SimulationFrame.appendToEditorpane(reSubmit<strong>Job</strong>);<br />
} else {<br />
Str<strong>in</strong>g complete<strong>Job</strong> = "> ResBroker | <strong>Job</strong> : " + jobid + " already F<strong>in</strong>ished. Node :<br />
" + nodeid + " Not ReSubmitt<strong>in</strong>g.";<br />
SimulationFrame.appendToEditorpane(complete<strong>Job</strong>);<br />
}<br />
}<br />
}<br />
//this.stop();<br />
}<br />
Class: IndexFrame.java<br />
package Forms;<br />
import Algorithm.Create<strong>Job</strong>ExecutionThread;<br />
import Algorithm.Create<strong>Job</strong>ExecutionThread_<strong>Reputation</strong>;<br />
import JdbcConnection.DatabaseConnection;<br />
import SimResults.SimInfo;<br />
import java.awt.Dimension;<br />
import java.awt.Po<strong>in</strong>t;<br />
import java.awt.Toolkit;<br />
import javax.sw<strong>in</strong>g.UIManager;<br />
public class IndexFrame extends javax.sw<strong>in</strong>g.JFrame {<br />
Toolkit env = this.getToolkit();<br />
/** Creates new form IndexFrame */<br />
public IndexFrame() {<br />
<strong>in</strong>itComponents();<br />
ERROR.setText("");<br />
this.setExtendedState(this.getExtendedState() | this.MAXIMIZED_BOTH);<br />
this.setLocation(this.getW<strong>in</strong>dowPosition(this.getSize()));<br />
}<br />
private Po<strong>in</strong>t getW<strong>in</strong>dowPosition(Dimension dim) {<br />
Po<strong>in</strong>t p = new Po<strong>in</strong>t();<br />
Dimension envDim = env.getScreenSize();<br />
p.y = (envDim.height / 2) - (dim.height / 2);<br />
p.x = (envDim.width / 2) - (dim.width / 2);<br />
98
}<br />
return p;<br />
private void <strong>in</strong>itComponents() {<br />
jLabel1 = new javax.sw<strong>in</strong>g.JLabel();<br />
jLabel2 = new javax.sw<strong>in</strong>g.JLabel();<br />
databaseOptions = new javax.sw<strong>in</strong>g.JComboBox();<br />
loadButton = new javax.sw<strong>in</strong>g.JButton();<br />
jTabbedPane1 = new javax.sw<strong>in</strong>g.JTabbedPane();<br />
jPanel1 = new javax.sw<strong>in</strong>g.JPanel();<br />
jLabel3 = new javax.sw<strong>in</strong>g.JLabel();<br />
jScrollPane1 = new javax.sw<strong>in</strong>g.JScrollPane();<br />
node<strong>in</strong>foTable = new javax.sw<strong>in</strong>g.JTable();<br />
jPanel2 = new javax.sw<strong>in</strong>g.JPanel();<br />
jLabel4 = new javax.sw<strong>in</strong>g.JLabel();<br />
jScrollPane2 = new javax.sw<strong>in</strong>g.JScrollPane();<br />
job<strong>in</strong>foTable = new javax.sw<strong>in</strong>g.JTable();<br />
SimulationLbl = new javax.sw<strong>in</strong>g.JLabel();<br />
TotaljobLbl = new javax.sw<strong>in</strong>g.JLabel();<br />
TotalnodeLbl = new javax.sw<strong>in</strong>g.JLabel();<br />
jLabel8 = new javax.sw<strong>in</strong>g.JLabel();<br />
jLabel9 = new javax.sw<strong>in</strong>g.JLabel();<br />
simulationAlgorithmComboBox = new javax.sw<strong>in</strong>g.JComboBox();<br />
simulationBtn = new javax.sw<strong>in</strong>g.JButton();<br />
ERROR = new javax.sw<strong>in</strong>g.JLabel();<br />
setDefaultCloseOperation(javax.sw<strong>in</strong>g.W<strong>in</strong>dowConstants.EXIT_ON_CLOSE);<br />
setTitle("<strong>Reputation</strong> <strong>Based</strong> <strong>Job</strong> <strong>Allocation</strong> Simulator");<br />
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12));<br />
jLabel1.setText("<strong>Reputation</strong> <strong>Based</strong> <strong>Job</strong> <strong>Allocation</strong> Simulator");<br />
jLabel2.setText("Database Load Options:");<br />
databaseOptions.setModel(new javax.sw<strong>in</strong>g.DefaultComboBoxModel(new Str<strong>in</strong>g[] {<br />
"Random Data", "Test Case File" }));<br />
loadButton.setText("Load");<br />
loadButton.addActionListener(new java.awt.event.ActionListener() {<br />
public void actionPerformed(java.awt.event.ActionEvent evt) {<br />
loadButtonActionPerformed(evt);<br />
}<br />
});<br />
jLabel3.setText("Node Information Fetched From Database:");<br />
node<strong>in</strong>foTable.setModel(new javax.sw<strong>in</strong>g.table.DefaultTableModel(<br />
new Object [][] {<br />
{"N/A", "N/A", "N/A", "N/A", "N/A", "N/A", null}<br />
},<br />
new Str<strong>in</strong>g [] {<br />
99
"NODE ID", "<strong>Reputation</strong>", "INDICATOR", "STATUS", "FAULT CHNACE", "UPTIME",<br />
"CURRENT JOB"<br />
}<br />
));<br />
jScrollPane1.setViewportView(node<strong>in</strong>foTable);<br />
javax.sw<strong>in</strong>g.GroupLayout jPanel1Layout = new javax.sw<strong>in</strong>g.GroupLayout(jPanel1);<br />
jPanel1.setLayout(jPanel1Layout);<br />
jPanel1Layout.setHorizontalGroup(<br />
jPanel1Layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING)<br />
.addGroup(jPanel1Layout.createSequentialGroup()<br />
.addConta<strong>in</strong>erGap()<br />
.addComponent(jLabel3)<br />
.addConta<strong>in</strong>erGap(730, Short.MAX_VALUE))<br />
.addComponent(jScrollPane1, javax.sw<strong>in</strong>g.GroupLayout.DEFAULT_SIZE, 946,<br />
Short.MAX_VALUE)<br />
);<br />
jPanel1Layout.setVerticalGroup(<br />
jPanel1Layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING)<br />
.addGroup(jPanel1Layout.createSequentialGroup()<br />
.addConta<strong>in</strong>erGap()<br />
.addComponent(jLabel3)<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addComponent(jScrollPane1, javax.sw<strong>in</strong>g.GroupLayout.DEFAULT_SIZE, 312,<br />
Short.MAX_VALUE))<br />
);<br />
jTabbedPane1.addTab("Node Details", jPanel1);<br />
jLabel4.setText("<strong>Job</strong> Information Fetched From Database:");<br />
job<strong>in</strong>foTable.setModel(new javax.sw<strong>in</strong>g.table.DefaultTableModel(<br />
new Object [][] {<br />
{"N/A", "N/A", null}<br />
},<br />
new Str<strong>in</strong>g [] {<br />
"JOB ID", "TIME NEEDED", "STATUS"<br />
}<br />
));<br />
jScrollPane2.setViewportView(job<strong>in</strong>foTable);<br />
javax.sw<strong>in</strong>g.GroupLayout jPanel2Layout = new javax.sw<strong>in</strong>g.GroupLayout(jPanel2);<br />
jPanel2.setLayout(jPanel2Layout);<br />
jPanel2Layout.setHorizontalGroup(<br />
jPanel2Layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING)<br />
.addGroup(jPanel2Layout.createSequentialGroup()<br />
.addConta<strong>in</strong>erGap()<br />
.addComponent(jLabel4)<br />
.addConta<strong>in</strong>erGap(738, Short.MAX_VALUE))<br />
.addComponent(jScrollPane2, javax.sw<strong>in</strong>g.GroupLayout.DEFAULT_SIZE, 946,<br />
Short.MAX_VALUE)<br />
);<br />
jPanel2Layout.setVerticalGroup(<br />
100
jPanel2Layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING)<br />
.addGroup(jPanel2Layout.createSequentialGroup()<br />
.addConta<strong>in</strong>erGap()<br />
.addComponent(jLabel4)<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addComponent(jScrollPane2, javax.sw<strong>in</strong>g.GroupLayout.DEFAULT_SIZE, 312,<br />
Short.MAX_VALUE))<br />
);<br />
jTabbedPane1.addTab("<strong>Job</strong> Details", jPanel2);<br />
SimulationLbl.setText("Simulation Algorithm:");<br />
TotaljobLbl.setText("Total <strong>Job</strong>s:");<br />
TotalnodeLbl.setText("Total Nodes:");<br />
jLabel8.setFont(new java.awt.Font("Tahoma", 1, 11));<br />
jLabel8.setText("Simulation Details");<br />
jLabel9.setText("Choose Simulation Algorithm:");<br />
simulationAlgorithmComboBox.setModel(new javax.sw<strong>in</strong>g.DefaultComboBoxModel(new<br />
Str<strong>in</strong>g[] { "2 Replication", "3 Replication", "<strong>Reputation</strong> <strong>Based</strong>" }));<br />
simulationBtn.setText("Simulate");<br />
simulationBtn.addActionListener(new java.awt.event.ActionListener() {<br />
public void actionPerformed(java.awt.event.ActionEvent evt) {<br />
simulationBtnActionPerformed(evt);<br />
}<br />
});<br />
ERROR.setForeground(new java.awt.Color(255, 0, 0));<br />
ERROR.setText("ERROR: Error will be pr<strong>in</strong>ted here.");<br />
javax.sw<strong>in</strong>g.GroupLayout layout = new javax.sw<strong>in</strong>g.GroupLayout(getContentPane());<br />
getContentPane().setLayout(layout);<br />
layout.setHorizontalGroup(<br />
layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING)<br />
.addGroup(layout.createSequentialGroup()<br />
.addConta<strong>in</strong>erGap()<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING)<br />
.addComponent(jLabel1)<br />
.addGroup(layout.createSequentialGroup()<br />
.addComponent(jLabel2)<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.UNRELATED)<br />
.addComponent(databaseOptions,<br />
javax.sw<strong>in</strong>g.GroupLayout.PREFERRED_SIZE, javax.sw<strong>in</strong>g.GroupLayout.DEFAULT_SIZE,<br />
javax.sw<strong>in</strong>g.GroupLayout.PREFERRED_SIZE)<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.UNRELATED)<br />
101
.addComponent(loadButton)))<br />
.addConta<strong>in</strong>erGap(658, Short.MAX_VALUE))<br />
.addComponent(jTabbedPane1, javax.sw<strong>in</strong>g.GroupLayout.DEFAULT_SIZE, 951,<br />
Short.MAX_VALUE)<br />
.addGroup(layout.createSequentialGroup()<br />
.addConta<strong>in</strong>erGap()<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING)<br />
.addComponent(SimulationLbl)<br />
.addComponent(TotaljobLbl)<br />
.addComponent(TotalnodeLbl)<br />
.addComponent(jLabel8)<br />
.addGroup(layout.createSequentialGroup()<br />
.addComponent(jLabel9)<br />
.addGap(18, 18, 18)<br />
.addComponent(simulationAlgorithmComboBox,<br />
javax.sw<strong>in</strong>g.GroupLayout.PREFERRED_SIZE, javax.sw<strong>in</strong>g.GroupLayout.DEFAULT_SIZE,<br />
javax.sw<strong>in</strong>g.GroupLayout.PREFERRED_SIZE)<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.UNRELATED)<br />
.addComponent(simulationBtn)))<br />
.addConta<strong>in</strong>erGap(591, Short.MAX_VALUE))<br />
.addGroup(layout.createSequentialGroup()<br />
.addConta<strong>in</strong>erGap()<br />
.addComponent(ERROR)<br />
.addConta<strong>in</strong>erGap(777, Short.MAX_VALUE))<br />
);<br />
layout.setVerticalGroup(<br />
layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING)<br />
.addGroup(layout.createSequentialGroup()<br />
.addConta<strong>in</strong>erGap()<br />
.addComponent(jLabel1)<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.UNRELATED)<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.BASELINE)<br />
.addComponent(jLabel2)<br />
.addComponent(databaseOptions, javax.sw<strong>in</strong>g.GroupLayout.PREFERRED_SIZE,<br />
javax.sw<strong>in</strong>g.GroupLayout.DEFAULT_SIZE, javax.sw<strong>in</strong>g.GroupLayout.PREFERRED_SIZE)<br />
.addComponent(loadButton))<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addComponent(jTabbedPane1, javax.sw<strong>in</strong>g.GroupLayout.PREFERRED_SIZE, 371,<br />
javax.sw<strong>in</strong>g.GroupLayout.PREFERRED_SIZE)<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.BASELINE)<br />
.addComponent(jLabel9)<br />
.addComponent(simulationAlgorithmComboBox,<br />
javax.sw<strong>in</strong>g.GroupLayout.PREFERRED_SIZE, javax.sw<strong>in</strong>g.GroupLayout.DEFAULT_SIZE,<br />
javax.sw<strong>in</strong>g.GroupLayout.PREFERRED_SIZE)<br />
.addComponent(simulationBtn))<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.UNRELATED)<br />
.addComponent(jLabel8)<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
102
);<br />
.addComponent(TotalnodeLbl)<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addComponent(TotaljobLbl)<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addComponent(SimulationLbl)<br />
.addGap(18, 18, 18)<br />
.addComponent(ERROR)<br />
.addConta<strong>in</strong>erGap(javax.sw<strong>in</strong>g.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))<br />
}<br />
pack();<br />
private void loadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-<br />
FIRST:event_loadButtonActionPerformed<br />
if (databaseOptions.getSelectedIndex() == 0) {<br />
RandomData rd = new RandomData(this, true, node<strong>in</strong>foTable, job<strong>in</strong>foTable);<br />
rd.setLocation(this.getW<strong>in</strong>dowPosition(rd.getSize()));<br />
rd.setVisible(true);<br />
} else {<br />
TestCaseFile tcf = new TestCaseFile(this, true, node<strong>in</strong>foTable, job<strong>in</strong>foTable);<br />
tcf.setLocation(this.getW<strong>in</strong>dowPosition(tcf.getSize()));<br />
tcf.setVisible(true);<br />
}<br />
}<br />
private void simulationBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-<br />
FIRST:event_simulationBtnActionPerformed<br />
<strong>in</strong>t item = simulationAlgorithmComboBox.getSelectedIndex();<br />
Str<strong>in</strong>g simulationalgorithm = (Str<strong>in</strong>g) simulationAlgorithmComboBox.getItemAt(item);<br />
SimulationLbl.setText("Simulation Algorithm: " + simulationalgorithm);<br />
Str<strong>in</strong>g countjobs = "select `jobid` from `job`;";<br />
<strong>in</strong>t totaljobs = DatabaseConnection.countQuery(countjobs);<br />
TotaljobLbl.setText("Total <strong>Job</strong>s: " + totaljobs);<br />
Str<strong>in</strong>g countnodes = "select `nodeid` from `node_<strong>in</strong>formation`;";<br />
<strong>in</strong>t totalnodes = DatabaseConnection.countQuery(countnodes);<br />
TotalnodeLbl.setText("Total Nodes: " + totalnodes);<br />
/* SimulationFrame sf = new SimulationFrame(this,true);<br />
sf.setLocation(this.getW<strong>in</strong>dowPosition(sf.getSize()));<br />
sf.setVisible(true);*/<br />
SimulationFrameThread sm = new SimulationFrameThread();<br />
SimResults.SimInfo si = new SimInfo();<br />
SimResults.SimInfo.algorithm = simulationalgorithm;<br />
SimResults.SimInfo.total<strong>Job</strong>s = totaljobs;<br />
SimResults.SimInfo.totalNodes = totalnodes;<br />
sm.start();<br />
si.start();<br />
103
SimulationFrame.appendToEditorpane("added 2 replication");<br />
if (item == 0) {// 2 replication<br />
Create<strong>Job</strong>ExecutionThread Cr = new Create<strong>Job</strong>ExecutionThread(2);<br />
Cr.start();<br />
} else if (item == 1) {// 3replication<br />
Create<strong>Job</strong>ExecutionThread Cr = new Create<strong>Job</strong>ExecutionThread(3);<br />
Cr.start();<br />
} else if (item == 2) {// reputation based<br />
Create<strong>Job</strong>ExecutionThread_<strong>Reputation</strong> CrR = new<br />
Create<strong>Job</strong>ExecutionThread_<strong>Reputation</strong>();<br />
CrR.start();<br />
}<br />
}<br />
public static void ma<strong>in</strong>(Str<strong>in</strong>g args[]) {<br />
try {<br />
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());<br />
} catch (Exception ex) {<br />
System.out.pr<strong>in</strong>tln(ex.getMessage());<br />
}<br />
java.awt.EventQueue.<strong>in</strong>vokeLater(new Runnable() {<br />
}<br />
public void run() {<br />
new IndexFrame().setVisible(true);<br />
DatabaseConnection dc = new DatabaseConnection();<br />
}<br />
});<br />
}<br />
// Variables declaration - do not modify//GEN-BEGIN:variables<br />
public static javax.sw<strong>in</strong>g.JLabel ERROR;<br />
private javax.sw<strong>in</strong>g.JLabel SimulationLbl;<br />
private javax.sw<strong>in</strong>g.JLabel TotaljobLbl;<br />
public static javax.sw<strong>in</strong>g.JLabel TotalnodeLbl;<br />
private javax.sw<strong>in</strong>g.JComboBox databaseOptions;<br />
private javax.sw<strong>in</strong>g.JLabel jLabel1;<br />
private javax.sw<strong>in</strong>g.JLabel jLabel2;<br />
private javax.sw<strong>in</strong>g.JLabel jLabel3;<br />
private javax.sw<strong>in</strong>g.JLabel jLabel4;<br />
private javax.sw<strong>in</strong>g.JLabel jLabel8;<br />
private javax.sw<strong>in</strong>g.JLabel jLabel9;<br />
private javax.sw<strong>in</strong>g.JPanel jPanel1;<br />
private javax.sw<strong>in</strong>g.JPanel jPanel2;<br />
private javax.sw<strong>in</strong>g.JScrollPane jScrollPane1;<br />
private javax.sw<strong>in</strong>g.JScrollPane jScrollPane2;<br />
private javax.sw<strong>in</strong>g.JTabbedPane jTabbedPane1;<br />
public static javax.sw<strong>in</strong>g.JTable job<strong>in</strong>foTable;<br />
private javax.sw<strong>in</strong>g.JButton loadButton;<br />
public static javax.sw<strong>in</strong>g.JTable node<strong>in</strong>foTable;<br />
private javax.sw<strong>in</strong>g.JComboBox simulationAlgorithmComboBox;<br />
private javax.sw<strong>in</strong>g.JButton simulationBtn;<br />
// End of variables declaration//GEN-END:variables<br />
104
Class: RandomData.java<br />
package Forms;<br />
import JdbcConnection.DatabaseConnection;<br />
import java.util.Random;<br />
import javax.sw<strong>in</strong>g.JTable;<br />
import javax.sw<strong>in</strong>g.table.DefaultTableModel;<br />
public class RandomData extends javax.sw<strong>in</strong>g.JDialog {<br />
JTable J = new JTable();<br />
JTable N = new JTable();<br />
/** Creates new form RandomData */<br />
public RandomData(java.awt.Frame parent, boolean modal, JTable tableN, JTable tableJ) {<br />
super(parent, modal);<br />
J = tableJ;<br />
N = tableN;<br />
<strong>in</strong>itComponents();<br />
ERROR.setText("");<br />
<strong>in</strong>itRep.setSelectedIndex(1);<br />
jobsOnly.setSelected(true);<br />
nodesField.setEditable(false);<br />
}<br />
private void <strong>in</strong>itComponents() {<br />
buttonGroup1 = new javax.sw<strong>in</strong>g.ButtonGroup();<br />
jLabel1 = new javax.sw<strong>in</strong>g.JLabel();<br />
jLabel2 = new javax.sw<strong>in</strong>g.JLabel();<br />
nodesField = new javax.sw<strong>in</strong>g.JTextField();<br />
jLabel3 = new javax.sw<strong>in</strong>g.JLabel();<br />
jobsField = new javax.sw<strong>in</strong>g.JTextField();<br />
generateButton = new javax.sw<strong>in</strong>g.JButton();<br />
ERROR = new javax.sw<strong>in</strong>g.JLabel();<br />
closeButton = new javax.sw<strong>in</strong>g.JButton();<br />
jLabel4 = new javax.sw<strong>in</strong>g.JLabel();<br />
<strong>in</strong>itRep = new javax.sw<strong>in</strong>g.JComboBox();<br />
jobsOnly = new javax.sw<strong>in</strong>g.JCheckBox();<br />
setDefaultCloseOperation(javax.sw<strong>in</strong>g.W<strong>in</strong>dowConstants.DISPOSE_ON_CLOSE);<br />
setTitle("Load<strong>in</strong>g Database - Random Data");<br />
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11));<br />
jLabel1.setText("Load<strong>in</strong>g Database with Random Data");<br />
jLabel2.setText("Enter Required Amount of Nodes:");<br />
nodesField.setText("10");<br />
jLabel3.setText("Enter Required Amount of <strong>Job</strong>s:");<br />
105
jobsField.setText("80");<br />
generateButton.setText("Generate");<br />
generateButton.addActionListener(new java.awt.event.ActionListener() {<br />
public void actionPerformed(java.awt.event.ActionEvent evt) {<br />
generateButtonActionPerformed(evt);<br />
}<br />
});<br />
ERROR.setForeground(new java.awt.Color(255, 0, 0));<br />
ERROR.setText("ERROR: Error will be pr<strong>in</strong>ted here.");<br />
closeButton.setText("Close");<br />
closeButton.addActionListener(new java.awt.event.ActionListener() {<br />
public void actionPerformed(java.awt.event.ActionEvent evt) {<br />
closeButtonActionPerformed(evt);<br />
}<br />
});<br />
jLabel4.setText("Initial <strong>Reputation</strong>:");<br />
<strong>in</strong>itRep.setModel(new javax.sw<strong>in</strong>g.DefaultComboBoxModel(new Str<strong>in</strong>g[] { "0", "5",<br />
"10", "Random" }));<br />
jobsOnly.setText("Keep Current Nodes");<br />
jobsOnly.addActionListener(new java.awt.event.ActionListener() {<br />
public void actionPerformed(java.awt.event.ActionEvent evt) {<br />
jobsOnlyActionPerformed(evt);<br />
}<br />
});<br />
javax.sw<strong>in</strong>g.GroupLayout layout = new javax.sw<strong>in</strong>g.GroupLayout(getContentPane());<br />
getContentPane().setLayout(layout);<br />
layout.setHorizontalGroup(<br />
layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING)<br />
.addGroup(layout.createSequentialGroup()<br />
.addConta<strong>in</strong>erGap()<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING)<br />
.addComponent(jobsOnly)<br />
.addComponent(ERROR)<br />
.addGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.TRAILING,<br />
layout.createSequentialGroup()<br />
.addComponent(closeButton)<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addComponent(generateButton))<br />
.addComponent(jLabel1)<br />
.addGroup(layout.createSequentialGroup()<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING)<br />
.addComponent(jLabel2)<br />
.addComponent(jLabel3)<br />
106
.addComponent(jLabel4))<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED,<br />
139, Short.MAX_VALUE)<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.TRAILING, false)<br />
.addComponent(<strong>in</strong>itRep, 0, javax.sw<strong>in</strong>g.GroupLayout.DEFAULT_SIZE,<br />
Short.MAX_VALUE)<br />
.addComponent(jobsField)<br />
.addComponent(nodesField, javax.sw<strong>in</strong>g.GroupLayout.DEFAULT_SIZE,<br />
99, Short.MAX_VALUE))))<br />
.addConta<strong>in</strong>erGap())<br />
);<br />
layout.setVerticalGroup(<br />
layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING)<br />
.addGroup(layout.createSequentialGroup()<br />
.addConta<strong>in</strong>erGap()<br />
.addComponent(jLabel1)<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.BASELINE)<br />
.addComponent(jLabel2)<br />
.addComponent(nodesField, javax.sw<strong>in</strong>g.GroupLayout.PREFERRED_SIZE,<br />
javax.sw<strong>in</strong>g.GroupLayout.DEFAULT_SIZE, javax.sw<strong>in</strong>g.GroupLayout.PREFERRED_SIZE))<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.BASELINE)<br />
.addComponent(jLabel3)<br />
.addComponent(jobsField, javax.sw<strong>in</strong>g.GroupLayout.PREFERRED_SIZE,<br />
javax.sw<strong>in</strong>g.GroupLayout.DEFAULT_SIZE, javax.sw<strong>in</strong>g.GroupLayout.PREFERRED_SIZE))<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.BASELINE)<br />
.addComponent(jLabel4)<br />
.addComponent(<strong>in</strong>itRep, javax.sw<strong>in</strong>g.GroupLayout.PREFERRED_SIZE,<br />
javax.sw<strong>in</strong>g.GroupLayout.DEFAULT_SIZE, javax.sw<strong>in</strong>g.GroupLayout.PREFERRED_SIZE))<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED, 77,<br />
Short.MAX_VALUE)<br />
.addComponent(jobsOnly)<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.UNRELATED)<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.BASELINE)<br />
.addComponent(generateButton)<br />
.addComponent(closeButton))<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addComponent(ERROR)<br />
.addConta<strong>in</strong>erGap())<br />
);<br />
}<br />
pack();<br />
private void generateButtonActionPerformed(java.awt.event.ActionEvent evt) {<br />
Str<strong>in</strong>g sqlTJ = "TRUNCATE `job`";<br />
107
DatabaseConnection.<strong>in</strong>sertUpadateQuery(sqlTJ);<br />
<strong>in</strong>t nodesN = Integer.parseInt(nodesField.getText());<br />
<strong>in</strong>t jobsN = Integer.parseInt(jobsField.getText());<br />
//random Nodes<br />
Random rnd = new Random();<br />
if (!jobsOnly.isSelected()) {<br />
Str<strong>in</strong>g sqlTN = "TRUNCATE `node_<strong>in</strong>formation`";<br />
DatabaseConnection.<strong>in</strong>sertUpadateQuery(sqlTN);<br />
<strong>in</strong>t nodeID = 1;<br />
<strong>in</strong>t rep = 0;<br />
for (nodeID = 1; nodeID = 7) {<br />
faultChance = 7;<br />
} else if (faultChance < 7 && faultChance >= 4) {<br />
faultChance = 4;<br />
} else {<br />
faultChance = 1;<br />
}<br />
<strong>in</strong>t upTime = rnd.nextInt(30);<br />
if (upTime < 10) {<br />
upTime = rnd.nextInt(30);<br />
}<br />
if (<strong>in</strong>itRep.getSelectedItem().toStr<strong>in</strong>g().equals("Random")) {<br />
rep = rnd.nextInt(10);<br />
while (rep == 0) {<br />
rep = rnd.nextInt(10);<br />
}<br />
} else {<br />
<strong>in</strong>t <strong>in</strong>it_rep = Integer.parseInt(<strong>in</strong>itRep.getSelectedItem().toStr<strong>in</strong>g());<br />
rep = <strong>in</strong>it_rep;<br />
}<br />
Str<strong>in</strong>g sqlNode = "INSERT INTO `node_<strong>in</strong>formation` VALUES(" + nodeID + ",'" +<br />
rep + "','up','<strong>in</strong>active','" + faultChance + "','" + upTime + "',0)";<br />
DatabaseConnection.<strong>in</strong>sertUpadateQuery(sqlNode);<br />
}<br />
}<br />
<strong>in</strong>t jobID = 1;<br />
for (jobID = 1; jobID
Str<strong>in</strong>g sqlSel<strong>Job</strong>s = "SELECT * FROM `job`";<br />
Object nodedataJ[][] = DatabaseConnection.getMultiRowQueryObjects(sqlSel<strong>Job</strong>s);<br />
dtmJ.setDataVector(nodedataJ, columnsJ);<br />
J.setModel(dtmJ);<br />
J.setEnabled(false);<br />
//Display<strong>in</strong>g Nodes Table<br />
Str<strong>in</strong>g columnsN[] = {"Nodeid", "<strong>Reputation</strong>", "Indicator", "Status", "FaultChance",<br />
"Uptime"};<br />
DefaultTableModel dtmN = new DefaultTableModel(nodesN, 6);<br />
Str<strong>in</strong>g sqlSelNodes = "SELECT * FROM `node_<strong>in</strong>formation`";<br />
Object nodedataN[][] = DatabaseConnection.getMultiRowQueryObjects(sqlSelNodes);<br />
dtmN.setDataVector(nodedataN, columnsN);<br />
N.setModel(dtmN);<br />
N.setEnabled(false);<br />
this.dispose();<br />
}<br />
private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {<br />
this.dispose();<br />
}<br />
private void jobsOnlyActionPerformed(java.awt.event.ActionEvent evt) {<br />
if (jobsOnly.isSelected()) {<br />
nodesField.setEditable(false);<br />
} else {<br />
nodesField.setEditable(true);<br />
}<br />
}<br />
public static void ma<strong>in</strong>(Str<strong>in</strong>g args[]) {<br />
java.awt.EventQueue.<strong>in</strong>vokeLater(new Runnable() {<br />
public void run() {<br />
RandomData dialog = new RandomData(new javax.sw<strong>in</strong>g.JFrame(), true, new<br />
JTable(), new JTable());<br />
dialog.addW<strong>in</strong>dowListener(new java.awt.event.W<strong>in</strong>dowAdapter() {<br />
}<br />
}<br />
});<br />
public void w<strong>in</strong>dowClos<strong>in</strong>g(java.awt.event.W<strong>in</strong>dowEvent e) {<br />
System.exit(0);<br />
}<br />
});<br />
dialog.setVisible(true);<br />
private javax.sw<strong>in</strong>g.JLabel ERROR;<br />
private javax.sw<strong>in</strong>g.ButtonGroup buttonGroup1;<br />
private javax.sw<strong>in</strong>g.JButton closeButton;<br />
private javax.sw<strong>in</strong>g.JButton generateButton;<br />
private javax.sw<strong>in</strong>g.JComboBox <strong>in</strong>itRep;<br />
109
}<br />
private javax.sw<strong>in</strong>g.JLabel jLabel1;<br />
private javax.sw<strong>in</strong>g.JLabel jLabel2;<br />
private javax.sw<strong>in</strong>g.JLabel jLabel3;<br />
private javax.sw<strong>in</strong>g.JLabel jLabel4;<br />
private javax.sw<strong>in</strong>g.JTextField jobsField;<br />
private javax.sw<strong>in</strong>g.JCheckBox jobsOnly;<br />
private javax.sw<strong>in</strong>g.JTextField nodesField;<br />
Class: SimulationFrame<br />
package Forms;<br />
import JdbcConnection.DatabaseConnection;<br />
import java.awt.Dimension;<br />
import java.awt.Po<strong>in</strong>t;<br />
import java.awt.Toolkit;<br />
import javax.sw<strong>in</strong>g.JScrollPane;<br />
public class SimulationFrame extends javax.sw<strong>in</strong>g.JFrame {<br />
Toolkit env = this.getToolkit();<br />
public SimulationFrame() {<br />
<strong>in</strong>itComponents();<br />
editorpane.setEditable(false);<br />
editorpane.setAutoscrolls(true);<br />
jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);<br />
//editorpane.setPreferredSize(editorpane.getSize());<br />
//jScrollPane1.setPreferredSize(jScrollPane1.getSize());<br />
editorpane.setL<strong>in</strong>eWrap(true);<br />
ERROR.setText("");<br />
this.setExtendedState(this.getExtendedState() | this.MAXIMIZED_BOTH);<br />
}<br />
public static void appendToEditorpane(Str<strong>in</strong>g msg) {<br />
editorpane.append("\r\n" + msg);<br />
editorpane.setPreferredSize(new Dimension(editorpane.getWidth(),<br />
editorpane.getHeight() + 10));<br />
editorpane.getCaret().setDot(editorpane.getText().length());<br />
jScrollPane1.scrollRectToVisible(editorpane.getVisibleRect());<br />
}<br />
110
public Po<strong>in</strong>t getW<strong>in</strong>dowPosition(Dimension dim) {<br />
Po<strong>in</strong>t p = new Po<strong>in</strong>t();<br />
Dimension envDim = env.getScreenSize();<br />
p.y = (envDim.height / 2) - (dim.height / 2);<br />
p.x = (envDim.width / 2) - (dim.width / 2);<br />
return p;<br />
}<br />
private void <strong>in</strong>itComponents() {<br />
jLabel1 = new javax.sw<strong>in</strong>g.JLabel();<br />
jButton1 = new javax.sw<strong>in</strong>g.JButton();<br />
jScrollPane1 = new javax.sw<strong>in</strong>g.JScrollPane();<br />
editorpane = new javax.sw<strong>in</strong>g.JTextArea();<br />
jLabel3 = new javax.sw<strong>in</strong>g.JLabel();<br />
jLabel4 = new javax.sw<strong>in</strong>g.JLabel();<br />
jLabel5 = new javax.sw<strong>in</strong>g.JLabel();<br />
t<strong>Job</strong>s = new javax.sw<strong>in</strong>g.JLabel();<br />
tNodes = new javax.sw<strong>in</strong>g.JLabel();<br />
algo = new javax.sw<strong>in</strong>g.JLabel();<br />
jLabel10 = new javax.sw<strong>in</strong>g.JLabel();<br />
jLabel11 = new javax.sw<strong>in</strong>g.JLabel();<br />
jLabel12 = new javax.sw<strong>in</strong>g.JLabel();<br />
jLabel13 = new javax.sw<strong>in</strong>g.JLabel();<br />
jLabel14 = new javax.sw<strong>in</strong>g.JLabel();<br />
hcn = new javax.sw<strong>in</strong>g.JLabel();<br />
hcj = new javax.sw<strong>in</strong>g.JLabel();<br />
fn = new javax.sw<strong>in</strong>g.JLabel();<br />
sn = new javax.sw<strong>in</strong>g.JLabel();<br />
rsj = new javax.sw<strong>in</strong>g.JLabel();<br />
jLabel20 = new javax.sw<strong>in</strong>g.JLabel();<br />
jButton2 = new javax.sw<strong>in</strong>g.JButton();<br />
ERROR = new javax.sw<strong>in</strong>g.JLabel();<br />
setDefaultCloseOperation(javax.sw<strong>in</strong>g.W<strong>in</strong>dowConstants.DISPOSE_ON_CLOSE);<br />
setTitle("Simulation W<strong>in</strong>dow");<br />
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11));<br />
jLabel1.setText("Runn<strong>in</strong>g Simulation...");<br />
jButton1.setText("Exit");<br />
jButton1.addActionListener(new java.awt.event.ActionListener() {<br />
public void actionPerformed(java.awt.event.ActionEvent evt) {<br />
jButton1ActionPerformed(evt);<br />
}<br />
});<br />
editorpane.setBackground(new java.awt.Color(0, 0, 0));<br />
editorpane.setColumns(20);<br />
editorpane.setForeground(new java.awt.Color(255, 255, 153));<br />
editorpane.setRows(5);<br />
jScrollPane1.setViewportView(editorpane);<br />
111
jLabel3.setText("Algorithm:");<br />
jLabel4.setText("Total Nodes:");<br />
jLabel5.setText("Total <strong>Job</strong>s:");<br />
t<strong>Job</strong>s.setText("0");<br />
tNodes.setText("0");<br />
algo.setText("N/A");<br />
jLabel10.setText("Highest Concurrent Nodes:");<br />
jLabel11.setText("Highest Concurrent <strong>Job</strong>s:");<br />
jLabel12.setText("Failed Nodes:");<br />
jLabel13.setText("Successfull Nodes:");<br />
jLabel14.setText("Re-Submitted <strong>Job</strong>s:");<br />
hcn.setText("0");<br />
hcj.setText("0");<br />
fn.setText("0");<br />
sn.setText("0");<br />
rsj.setText("0");<br />
jLabel20.setFont(new java.awt.Font("Tahoma", 1, 11));<br />
jLabel20.setText("Simulation Summery");<br />
jButton2.setText("Save");<br />
jButton2.addActionListener(new java.awt.event.ActionListener() {<br />
public void actionPerformed(java.awt.event.ActionEvent evt) {<br />
jButton2ActionPerformed(evt);<br />
}<br />
});<br />
ERROR.setForeground(new java.awt.Color(255, 51, 0));<br />
ERROR.setText("ERROR:");<br />
javax.sw<strong>in</strong>g.GroupLayout layout = new javax.sw<strong>in</strong>g.GroupLayout(getContentPane());<br />
getContentPane().setLayout(layout);<br />
layout.setHorizontalGroup(<br />
layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING)<br />
.addGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.TRAILING,<br />
layout.createSequentialGroup()<br />
.addConta<strong>in</strong>erGap()<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.TRAILING)<br />
112
.addComponent(jScrollPane1, javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING,<br />
javax.sw<strong>in</strong>g.GroupLayout.DEFAULT_SIZE, 993, Short.MAX_VALUE)<br />
.addGroup(layout.createSequentialGroup()<br />
.addComponent(ERROR)<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED,<br />
840, Short.MAX_VALUE)<br />
.addComponent(jButton2)<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addComponent(jButton1))<br />
.addComponent(jLabel1, javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING)<br />
.addGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING,<br />
layout.createSequentialGroup()<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING)<br />
.addComponent(jLabel5)<br />
.addGroup(layout.createSequentialGroup()<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING)<br />
.addComponent(jLabel4)<br />
.addComponent(jLabel3))<br />
.addGap(32, 32, 32)<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING)<br />
.addComponent(algo)<br />
.addComponent(t<strong>Job</strong>s)<br />
.addComponent(tNodes))))<br />
.addGap(156, 156, 156)<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING)<br />
.addComponent(jLabel10)<br />
.addComponent(jLabel11)<br />
.addComponent(jLabel13)<br />
.addComponent(jLabel14)<br />
.addComponent(jLabel12))<br />
.addGap(38, 38, 38)<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING)<br />
.addComponent(rsj)<br />
.addComponent(sn)<br />
.addComponent(fn)<br />
.addComponent(hcj)<br />
.addComponent(hcn)))<br />
.addComponent(jLabel20, javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING))<br />
.addConta<strong>in</strong>erGap())<br />
);<br />
layout.setVerticalGroup(<br />
layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING)<br />
.addGroup(layout.createSequentialGroup()<br />
.addConta<strong>in</strong>erGap()<br />
.addComponent(jLabel1)<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addComponent(jScrollPane1, javax.sw<strong>in</strong>g.GroupLayout.DEFAULT_SIZE, 288,<br />
Short.MAX_VALUE)<br />
113
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.TRAILING)<br />
.addGroup(layout.createSequentialGroup()<br />
.addComponent(jLabel20)<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.UNRELATED)<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.BASELINE)<br />
.addComponent(jLabel5)<br />
.addComponent(t<strong>Job</strong>s))<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.BASELINE)<br />
.addComponent(jLabel4)<br />
.addComponent(tNodes))<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.BASELINE)<br />
.addComponent(jLabel3)<br />
.addComponent(algo))<br />
.addGap(40, 40, 40))<br />
.addGroup(layout.createSequentialGroup()<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.BASELINE)<br />
.addComponent(jLabel10)<br />
.addComponent(hcn))<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.BASELINE)<br />
.addComponent(jLabel11)<br />
.addComponent(hcj))<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.BASELINE)<br />
.addComponent(fn)<br />
.addComponent(jLabel12))<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.BASELINE)<br />
.addComponent(jLabel13)<br />
.addComponent(sn))<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.BASELINE)<br />
.addComponent(jLabel14)<br />
.addComponent(rsj))))<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.TRAILING)<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.BASELINE)<br />
.addComponent(jButton1)<br />
114
);<br />
.addComponent(jButton2))<br />
.addComponent(ERROR))<br />
.addConta<strong>in</strong>erGap())<br />
}<br />
pack();<br />
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {<br />
SimResults.SimInfo.highestCon<strong>Job</strong>s = 0;<br />
SimResults.SimInfo.highestConNode = 0;<br />
SimResults.SimInfo.failedNodes = 0;<br />
SimResults.SimInfo.successNodes = 0;<br />
SimResults.SimInfo.resub<strong>Job</strong>s = 0;<br />
SimResults.SimInfo.endSim = false;<br />
System.exit(0);<br />
}<br />
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {<br />
Str<strong>in</strong>g sqlRec = "INSERT INTO `records` VALUES('" + SimResults.SimInfo.algorithm +<br />
"'," + SimResults.SimInfo.highestCon<strong>Job</strong>s + "," + SimResults.SimInfo.highestConNode + ","<br />
+ SimResults.SimInfo.failedNodes + "," + SimResults.SimInfo.successNodes + "," +<br />
SimResults.SimInfo.resub<strong>Job</strong>s + ")";<br />
System.out.pr<strong>in</strong>tln(sqlRec);<br />
DatabaseConnection.<strong>in</strong>sertUpadateQuery(sqlRec);<br />
if (SimResults.SimInfo.algorithm.equals("<strong>Reputation</strong> <strong>Based</strong>")) {<br />
Str<strong>in</strong>g sqlRecRep = "SELECT `fault_chance`,avg(`reputation`) FROM<br />
`node_<strong>in</strong>formation` GROUP BY `fault_chance`";<br />
System.out.pr<strong>in</strong>tln(sqlRecRep);<br />
Object records[][] = DatabaseConnection.getMultiRowQueryObjects(sqlRecRep);<br />
float fc_1 = Float.parseFloat(records[0][1].toStr<strong>in</strong>g());<br />
float fc_2 = Float.parseFloat(records[1][1].toStr<strong>in</strong>g());<br />
float fc_3 = Float.parseFloat(records[2][1].toStr<strong>in</strong>g());<br />
Str<strong>in</strong>g <strong>in</strong>sRec = "INSERT INTO `rep_records` VALUES(" + fc_1 + "," + fc_2 + "," +<br />
fc_3 + ")";<br />
System.out.pr<strong>in</strong>tln(<strong>in</strong>sRec);<br />
DatabaseConnection.<strong>in</strong>sertUpadateQuery(<strong>in</strong>sRec);<br />
ERROR.setText("Records Successfully Saved!");<br />
}<br />
}<br />
public static void ma<strong>in</strong>(Str<strong>in</strong>g args[]) {<br />
java.awt.EventQueue.<strong>in</strong>vokeLater(new Runnable() {<br />
public void run() {<br />
new SimulationFrame().setVisible(true);<br />
}<br />
}<br />
});<br />
private javax.sw<strong>in</strong>g.JLabel ERROR;<br />
public static javax.sw<strong>in</strong>g.JLabel algo;<br />
115
public static javax.sw<strong>in</strong>g.JTextArea editorpane;<br />
public static javax.sw<strong>in</strong>g.JLabel fn;<br />
public static javax.sw<strong>in</strong>g.JLabel hcj;<br />
public static javax.sw<strong>in</strong>g.JLabel hcn;<br />
private javax.sw<strong>in</strong>g.JButton jButton1;<br />
private javax.sw<strong>in</strong>g.JButton jButton2;<br />
private javax.sw<strong>in</strong>g.JLabel jLabel1;<br />
private javax.sw<strong>in</strong>g.JLabel jLabel10;<br />
private javax.sw<strong>in</strong>g.JLabel jLabel11;<br />
private javax.sw<strong>in</strong>g.JLabel jLabel12;<br />
private javax.sw<strong>in</strong>g.JLabel jLabel13;<br />
private javax.sw<strong>in</strong>g.JLabel jLabel14;<br />
private javax.sw<strong>in</strong>g.JLabel jLabel20;<br />
private javax.sw<strong>in</strong>g.JLabel jLabel3;<br />
private javax.sw<strong>in</strong>g.JLabel jLabel4;<br />
private javax.sw<strong>in</strong>g.JLabel jLabel5;<br />
public static javax.sw<strong>in</strong>g.JScrollPane jScrollPane1;<br />
public static javax.sw<strong>in</strong>g.JLabel rsj;<br />
public static javax.sw<strong>in</strong>g.JLabel sn;<br />
public static javax.sw<strong>in</strong>g.JLabel t<strong>Job</strong>s;<br />
public static javax.sw<strong>in</strong>g.JLabel tNodes;<br />
}<br />
Class: SimulationFrameThread.java<br />
package Forms;<br />
public class SimulationFrameThread extends Thread {<br />
}<br />
public SimulationFrameThread() {<br />
SimulationFrame sm=new SimulationFrame();<br />
sm.setLocation(sm.getW<strong>in</strong>dowPosition(sm.getSize()));<br />
sm.setVisible(true);<br />
}<br />
Class: TestCaseFile.java<br />
package Forms;<br />
import Utility.TableModel;<br />
import java.awt.Color;<br />
116
import java.io.BufferedReader;<br />
import java.io.FileNotFoundException;<br />
import java.io.FileReader;<br />
import java.io.IOException;<br />
import javax.sw<strong>in</strong>g.JFileChooser;<br />
import javax.sw<strong>in</strong>g.JTextField;<br />
import javax.sw<strong>in</strong>g.filechooser.*;<br />
import JdbcConnection.DatabaseConnection;<br />
import javax.sw<strong>in</strong>g.JTable;<br />
public class TestCaseFile extends javax.sw<strong>in</strong>g.JDialog {<br />
JFileChooser chooser = new JFileChooser();<br />
public TestCaseFile(java.awt.Frame parent, boolean modal, JTable tableN, JTable tableJ) {<br />
super(parent, modal);<br />
<strong>in</strong>itComponents();<br />
ERROR.setText("");<br />
}<br />
private void <strong>in</strong>itComponents() {<br />
jLabel1 = new javax.sw<strong>in</strong>g.JLabel();<br />
jLabel2 = new javax.sw<strong>in</strong>g.JLabel();<br />
filenameTxtfield = new javax.sw<strong>in</strong>g.JTextField();<br />
jButton1 = new javax.sw<strong>in</strong>g.JButton();<br />
ERROR = new javax.sw<strong>in</strong>g.JLabel();<br />
jButton2 = new javax.sw<strong>in</strong>g.JButton();<br />
jButton3 = new javax.sw<strong>in</strong>g.JButton();<br />
setDefaultCloseOperation(javax.sw<strong>in</strong>g.W<strong>in</strong>dowConstants.DISPOSE_ON_CLOSE);<br />
setTitle("Load<strong>in</strong>g Database - Test Case File");<br />
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11));<br />
jLabel1.setText("Load<strong>in</strong>g Database with Test Case File Data");<br />
jLabel2.setText("Please Select a File to Load:");<br />
jButton1.setText("...");<br />
jButton1.addActionListener(new java.awt.event.ActionListener() {<br />
public void actionPerformed(java.awt.event.ActionEvent evt) {<br />
jButton1ActionPerformed(evt);<br />
}<br />
});<br />
ERROR.setForeground(new java.awt.Color(255, 0, 0));<br />
ERROR.setText("ERROR: Error will be pr<strong>in</strong>ted here.");<br />
jButton2.setText("Generate");<br />
jButton2.addActionListener(new java.awt.event.ActionListener() {<br />
public void actionPerformed(java.awt.event.ActionEvent evt) {<br />
jButton2ActionPerformed(evt);<br />
}<br />
});<br />
117
jButton3.setText("Close");<br />
jButton3.addActionListener(new java.awt.event.ActionListener() {<br />
public void actionPerformed(java.awt.event.ActionEvent evt) {<br />
jButton3ActionPerformed(evt);<br />
}<br />
});<br />
javax.sw<strong>in</strong>g.GroupLayout layout = new javax.sw<strong>in</strong>g.GroupLayout(getContentPane());<br />
getContentPane().setLayout(layout);<br />
layout.setHorizontalGroup(<br />
layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING)<br />
.addGroup(layout.createSequentialGroup()<br />
.addConta<strong>in</strong>erGap()<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING, false)<br />
.addComponent(jLabel1, javax.sw<strong>in</strong>g.GroupLayout.DEFAULT_SIZE,<br />
javax.sw<strong>in</strong>g.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)<br />
.addComponent(jLabel2)<br />
.addComponent(filenameTxtfield))<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addComponent(jButton1, javax.sw<strong>in</strong>g.GroupLayout.PREFERRED_SIZE, 24,<br />
javax.sw<strong>in</strong>g.GroupLayout.PREFERRED_SIZE)<br />
.addConta<strong>in</strong>erGap(javax.sw<strong>in</strong>g.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))<br />
.addGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.TRAILING,<br />
layout.createSequentialGroup()<br />
.addConta<strong>in</strong>erGap(136, Short.MAX_VALUE)<br />
.addComponent(jButton3)<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addComponent(jButton2)<br />
.addConta<strong>in</strong>erGap())<br />
.addGroup(layout.createSequentialGroup()<br />
.addConta<strong>in</strong>erGap()<br />
.addComponent(ERROR)<br />
.addConta<strong>in</strong>erGap(114, Short.MAX_VALUE))<br />
);<br />
layout.setVerticalGroup(<br />
layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING)<br />
.addGroup(layout.createSequentialGroup()<br />
.addConta<strong>in</strong>erGap()<br />
.addComponent(jLabel1)<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.UNRELATED)<br />
.addComponent(jLabel2)<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.LEADING)<br />
.addComponent(jButton1)<br />
.addComponent(filenameTxtfield, javax.sw<strong>in</strong>g.GroupLayout.PREFERRED_SIZE,<br />
javax.sw<strong>in</strong>g.GroupLayout.DEFAULT_SIZE, javax.sw<strong>in</strong>g.GroupLayout.PREFERRED_SIZE))<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addGroup(layout.createParallelGroup(javax.sw<strong>in</strong>g.GroupLayout.Alignment.BASELINE)<br />
.addComponent(jButton2)<br />
.addComponent(jButton3))<br />
118
);<br />
.addPreferredGap(javax.sw<strong>in</strong>g.LayoutStyle.ComponentPlacement.RELATED)<br />
.addComponent(ERROR)<br />
.addConta<strong>in</strong>erGap(javax.sw<strong>in</strong>g.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))<br />
layout.l<strong>in</strong>kSize(javax.sw<strong>in</strong>g.Sw<strong>in</strong>gConstants.VERTICAL, new java.awt.Component[]<br />
{filenameTxtfield, jButton1});<br />
}<br />
pack();<br />
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {<br />
Str<strong>in</strong>g filename = filenameTxtfield.getText();<br />
BufferedReader <strong>in</strong>putStream = null;<br />
Str<strong>in</strong>g query;<br />
if (!filename.isEmpty()) {<br />
try {<br />
<strong>in</strong>putStream = new BufferedReader(new FileReader(filename));<br />
while ((query = <strong>in</strong>putStream.readL<strong>in</strong>e()) != null) {<br />
// System.out.pr<strong>in</strong>tln(query);<br />
ERROR.setText("load<strong>in</strong>g...");<br />
DatabaseConnection.<strong>in</strong>sertUpadateQuery(query);<br />
}<br />
} catch (FileNotFoundException ex) {<br />
ERROR.setText("file not found");<br />
} catch (IOException ex) {<br />
ERROR.setText("I/O error occurs");<br />
} f<strong>in</strong>ally {<br />
if (<strong>in</strong>putStream != null) {<br />
try {<br />
<strong>in</strong>putStream.close();<br />
} catch (IOException ex) {<br />
ERROR.setText("I/O error occurs");<br />
}<br />
}<br />
}<br />
} else {<br />
ERROR.setText("Select Filename");<br />
}<br />
IndexFrame.ERROR.setText("Database loaded");<br />
this.dispose();<br />
Str<strong>in</strong>g jobquery = "select * from `job`;";<br />
Object job<strong>in</strong>fo[][] = DatabaseConnection.getMultiRowQueryObjects(jobquery);<br />
TableModel jobtb = new TableModel();<br />
Str<strong>in</strong>g[] columnNames = {"<strong>Job</strong>id", "TimeNeeded", "Status"};<br />
jobtb.setColumnNames(columnNames);<br />
jobtb.setData(job<strong>in</strong>fo);<br />
IndexFrame.job<strong>in</strong>foTable.setModel(jobtb);<br />
IndexFrame.job<strong>in</strong>foTable.getColumnModel().getColumn(0).setHeaderValue("<strong>Job</strong>id");<br />
IndexFrame.job<strong>in</strong>foTable.getColumnModel().getColumn(1).setHeaderValue("TimeNeeded");<br />
IndexFrame.job<strong>in</strong>foTable.getColumnModel().getColumn(2).setHeaderValue("Status");<br />
119
IndexFrame.job<strong>in</strong>foTable.setEnabled(false);<br />
Str<strong>in</strong>g nodequery = "select * from `node_<strong>in</strong>formation`;";<br />
Object node<strong>in</strong>fo[][] = DatabaseConnection.getMultiRowQueryObjects(nodequery);<br />
TableModel nodetb = new TableModel();<br />
Str<strong>in</strong>g[] nodecolumnNames = {"Nodeid","<strong>Reputation</strong>", "Indicator", "Status",<br />
"FaultChance", "Uptime"};<br />
nodetb.setColumnNames(nodecolumnNames);<br />
nodetb.setData(node<strong>in</strong>fo);<br />
IndexFrame.node<strong>in</strong>foTable.setModel(nodetb);<br />
IndexFrame.node<strong>in</strong>foTable.getColumnModel().getColumn(0).setHeaderValue("Nodeid");<br />
IndexFrame.node<strong>in</strong>foTable.getColumnModel().getColumn(1).setHeaderValue("<strong>Reputation</strong>");<br />
IndexFrame.node<strong>in</strong>foTable.getColumnModel().getColumn(2).setHeaderValue("Indicator");<br />
IndexFrame.node<strong>in</strong>foTable.getColumnModel().getColumn(3).setHeaderValue("Status");<br />
IndexFrame.node<strong>in</strong>foTable.getColumnModel().getColumn(4).setHeaderValue("FaultChance");<br />
IndexFrame.node<strong>in</strong>foTable.getColumnModel().getColumn(5).setHeaderValue("Uptime");<br />
IndexFrame.node<strong>in</strong>foTable.setEnabled(false);<br />
}<br />
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {<br />
load_file_chooser(filenameTxtfield)}<br />
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {<br />
this.dispose();<br />
}<br />
private void load_file_chooser(JTextField field) {<br />
JFileChooser file_chooser = new JFileChooser();<br />
FileNameExtensionFilter filter = new FileNameExtensionFilter(<br />
"Text Files", "txt");<br />
file_chooser.setFileFilter(filter);<br />
FILES_ONLY(default)<br />
file_chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);<br />
file_chooser.setFileHid<strong>in</strong>gEnabled(false);<br />
<strong>in</strong>t returnVal = file_chooser.showOpenDialog(null);<br />
if (returnVal == JFileChooser.APPROVE_OPTION) {<br />
field.setText(file_chooser.getSelectedFile().getAbsolutePath());<br />
} else if (returnVal == JFileChooser.CANCEL_OPTION) {<br />
ERROR.setForeground(Color.RED);<br />
ERROR.setText("Open command cancelled by user");<br />
}<br />
}<br />
public static void ma<strong>in</strong>(Str<strong>in</strong>g args[]) {<br />
java.awt.EventQueue.<strong>in</strong>vokeLater(new Runnable() {<br />
public void run() {<br />
TestCaseFile dialog = new TestCaseFile(new javax.sw<strong>in</strong>g.JFrame(), true, new<br />
JTable(), new JTable());<br />
dialog.addW<strong>in</strong>dowListener(new java.awt.event.W<strong>in</strong>dowAdapter() {<br />
120
}<br />
}<br />
});<br />
public void w<strong>in</strong>dowClos<strong>in</strong>g(java.awt.event.W<strong>in</strong>dowEvent e) {<br />
System.exit(0);<br />
}<br />
});<br />
dialog.setVisible(true);<br />
}<br />
private javax.sw<strong>in</strong>g.JLabel ERROR;<br />
private javax.sw<strong>in</strong>g.JTextField filenameTxtfield;<br />
private javax.sw<strong>in</strong>g.JButton jButton1;<br />
private javax.sw<strong>in</strong>g.JButton jButton2;<br />
private javax.sw<strong>in</strong>g.JButton jButton3;<br />
private javax.sw<strong>in</strong>g.JLabel jLabel1;<br />
private javax.sw<strong>in</strong>g.JLabel jLabel2;<br />
}<br />
Class: DatabaseConnection.java<br />
package JdbcConnection;<br />
import java.sql.Connection;<br />
import java.sql.DatabaseMetaData;<br />
import java.sql.DriverManager;<br />
import java.sql.ResultSet;<br />
import java.sql.SQLException;<br />
import java.sql.Statement;<br />
import java.util.logg<strong>in</strong>g.Level;<br />
import java.util.logg<strong>in</strong>g.Logger;<br />
public class DatabaseConnection {<br />
static f<strong>in</strong>al Str<strong>in</strong>g JDBC_DRIVER = "com.mysql.jdbc.Driver";<br />
static f<strong>in</strong>al Str<strong>in</strong>g DATABASE_URL = "jdbc:mysql://localhost/grid<strong>in</strong>formation";<br />
static Connection connection = null;<br />
public DatabaseConnection() {<br />
try {<br />
Class.forName(JDBC_DRIVER);<br />
connection = DriverManager.getConnection(DATABASE_URL, "grid", "123456");<br />
if (connection != null) {<br />
System.out.pr<strong>in</strong>tln("Got Connection.");<br />
DatabaseMetaData meta = (DatabaseMetaData) connection.getMetaData();<br />
System.out.pr<strong>in</strong>tln("Driver Name : " + meta.getDriverName());<br />
System.out.pr<strong>in</strong>tln("Driver Version : " + meta.getDriverVersion());<br />
}<br />
} catch (ClassNotFoundException ex) {<br />
Logger.getLogger(DatabaseConnection.class.getName()).log(Level.SEVERE, null,<br />
ex);<br />
} catch (SQLException ex) {<br />
121
ex);<br />
}<br />
}<br />
Logger.getLogger(DatabaseConnection.class.getName()).log(Level.SEVERE, null,<br />
public Connection getConnection() {<br />
Connection con = connection;<br />
return con;<br />
}<br />
/*get result query*/<br />
public static ResultSet getQueryResult(Str<strong>in</strong>g sql) {<br />
ResultSet rs = null;<br />
//System.out.pr<strong>in</strong>tln("sql: " + sql);<br />
try {<br />
Statement stm = connection.createStatement();<br />
rs = stm.executeQuery(sql);<br />
return rs;<br />
} catch (SQLException ex) {<br />
System.out.pr<strong>in</strong>tln("" + ex.getMessage());<br />
} catch (Exception e) {<br />
System.out.pr<strong>in</strong>tln("" + e.getMessage());<br />
}<br />
return rs;<br />
}<br />
/*count query*/<br />
public static <strong>in</strong>t countQuery(Str<strong>in</strong>g sql) {<br />
<strong>in</strong>t count = 0;<br />
try {<br />
Statement stm = connection.createStatement();<br />
ResultSet rs = getQueryResult(sql);<br />
while (rs.next()) {<br />
count++;<br />
}<br />
} catch (SQLException ex) {<br />
System.out.pr<strong>in</strong>tln("" + ex.getMessage());<br />
} catch (Exception e) {<br />
System.out.pr<strong>in</strong>tln("" + e.getMessage());<br />
}<br />
return count;<br />
}<br />
/*s<strong>in</strong>gle data query ok*/<br />
public static Str<strong>in</strong>g s<strong>in</strong>gleStOPQuery(Str<strong>in</strong>g sql) {<br />
Str<strong>in</strong>g st = null;<br />
try {<br />
122
Statement stm = connection.createStatement();<br />
ResultSet rs = getQueryResult(sql);<br />
while (rs.next()) {<br />
st = rs.getStr<strong>in</strong>g(1);<br />
}<br />
} catch (SQLException ex) {<br />
System.out.pr<strong>in</strong>tln("" + ex.getMessage());<br />
} catch (Exception e) {<br />
System.out.pr<strong>in</strong>tln("" + e.getMessage());<br />
}<br />
return st;<br />
}<br />
/*<strong>in</strong>sert update delete ok*/<br />
public static void <strong>in</strong>sertUpadateQuery(Str<strong>in</strong>g sql) {<br />
try {<br />
Statement stm = connection.createStatement();<br />
//ResultSet rs = getQueryResult(sql);<br />
boolean done = stm.execute(sql);<br />
if (done) {<br />
System.out.pr<strong>in</strong>tln("query executed");<br />
}<br />
} catch (SQLException ex) {<br />
System.out.pr<strong>in</strong>tln("" + ex.getMessage());<br />
} catch (Exception e) {<br />
System.out.pr<strong>in</strong>tln("" + e.getMessage());<br />
}<br />
}<br />
/*s<strong>in</strong>gle rowdata query ok*/<br />
public static Object[] getS<strong>in</strong>gleRowQueryObjects(Str<strong>in</strong>g sql) {<br />
Object obj[] = null;<br />
try {<br />
Statement stm = connection.createStatement();<br />
ResultSet rs = getQueryResult(sql);<br />
obj = new Object[rs.getMetaData().getColumnCount()];<br />
while (rs.next()) {<br />
for (<strong>in</strong>t i = 0; i < rs.getMetaData().getColumnCount(); i++) {<br />
obj[i] = rs.getStr<strong>in</strong>g(i + 1);<br />
}<br />
}<br />
} catch (SQLException ex) {<br />
System.out.pr<strong>in</strong>tln("" + ex.getMessage());<br />
} catch (Exception e) {<br />
System.out.pr<strong>in</strong>tln("" + e.getMessage());<br />
}<br />
return obj;<br />
123
}<br />
/*s<strong>in</strong>gle columndata query ok*/<br />
public static Object[] getS<strong>in</strong>gleColumnQueryObjects(Str<strong>in</strong>g sql) {<br />
Object obj[] = null;<br />
try {<br />
<strong>in</strong>t rowcount = countQuery(sql);<br />
obj = new Object[rowcount];<br />
ResultSet rs = getQueryResult(sql);<br />
<strong>in</strong>t i = 0;<br />
while (rs.next()) {<br />
obj[i] = rs.getStr<strong>in</strong>g(1);<br />
i++;<br />
}<br />
} catch (SQLException ex) {<br />
System.out.pr<strong>in</strong>tln("" + ex.getMessage());<br />
} catch (Exception e) {<br />
System.out.pr<strong>in</strong>tln("" + e.getMessage());<br />
}<br />
return obj;<br />
}<br />
/*multi rowdata query ok*/<br />
public static Object[][] getMultiRowQueryObjects(Str<strong>in</strong>g sql) {<br />
Object obj[][] = null;<br />
<strong>in</strong>t i = 0;<br />
try {<br />
}<br />
}<br />
Statement stm = connection.createStatement();<br />
<strong>in</strong>t rowcount = countQuery(sql);<br />
ResultSet rs = getQueryResult(sql);<br />
obj = new Object[rowcount][rs.getMetaData().getColumnCount()];<br />
//System.out.pr<strong>in</strong>tln(rs.getMetaData().getColumnCount());<br />
while (rs.next()) {<br />
for (<strong>in</strong>t j = 0; j < rs.getMetaData().getColumnCount(); j++) {<br />
obj[i][j] = rs.getStr<strong>in</strong>g(j + 1);<br />
//System.out.pr<strong>in</strong>tln(rs.getStr<strong>in</strong>g(j + 1));<br />
}<br />
i++;<br />
}<br />
} catch (SQLException ex) {<br />
System.out.pr<strong>in</strong>tln("" + ex.getMessage());<br />
} catch (Exception e) {<br />
System.out.pr<strong>in</strong>tln("" + e.getMessage());<br />
}<br />
return obj;<br />
124
Class: SimInfo.java<br />
package SimResults;<br />
import Forms.SimulationFrame;<br />
import JdbcConnection.DatabaseConnection;<br />
public class SimInfo extends Thread {<br />
public static <strong>in</strong>t total<strong>Job</strong>s = 0;<br />
public static <strong>in</strong>t totalNodes = 0;<br />
public static Str<strong>in</strong>g algorithm = "";<br />
public static <strong>in</strong>t highestCon<strong>Job</strong>s = 0;<br />
public static <strong>in</strong>t highestConNode = 0;<br />
public static <strong>in</strong>t failedNodes = 0;<br />
public static <strong>in</strong>t successNodes = 0;<br />
public static <strong>in</strong>t resub<strong>Job</strong>s = 0;<br />
public static boolean endSim = false;<br />
public void run() {<br />
while (!endSim) {<br />
Str<strong>in</strong>g sqlActiveN = "SELECT count(`nodeid`) FROM `node_<strong>in</strong>formation` WHERE<br />
status = 'active'";<br />
Str<strong>in</strong>g activeN = DatabaseConnection.s<strong>in</strong>gleStOPQuery(sqlActiveN);<br />
if (Integer.parseInt(activeN) > highestConNode) {<br />
highestConNode = Integer.parseInt(activeN);<br />
}<br />
Str<strong>in</strong>g sqlActiveJ = "SELECT count(`jobid`) FROM `job` WHERE status =<br />
'onProcess'";<br />
Str<strong>in</strong>g activeJ = DatabaseConnection.s<strong>in</strong>gleStOPQuery(sqlActiveJ);<br />
if (Integer.parseInt(activeJ) > highestCon<strong>Job</strong>s) {<br />
highestCon<strong>Job</strong>s = Integer.parseInt(activeJ);<br />
}<br />
Forms.SimulationFrame.t<strong>Job</strong>s.setText(total<strong>Job</strong>s + "");<br />
Forms.SimulationFrame.tNodes.setText(totalNodes + "");<br />
Forms.SimulationFrame.algo.setText(algorithm);<br />
Forms.SimulationFrame.hcj.setText(highestCon<strong>Job</strong>s + "");<br />
Forms.SimulationFrame.hcn.setText(highestConNode + "");<br />
Forms.SimulationFrame.fn.setText(failedNodes + "");<br />
Forms.SimulationFrame.sn.setText(successNodes + "");<br />
Forms.SimulationFrame.rsj.setText(resub<strong>Job</strong>s + "");<br />
}<br />
SimulationFrame.appendToEditorpane("> ResBroker | Stopp<strong>in</strong>g Records!");<br />
this.suspend();<br />
}<br />
}<br />
125