Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Creating the JaceP2P repository.
[jaceP2P.git] / src / jaceP2P / RunningApplication.java
1 package jaceP2P;
2
3
4 public class RunningApplication /* implements java.io.Serializable */{
5
6         // attributes
7         public static RunningApplication Instance;
8
9         private String name; // nom de l'application
10         @SuppressWarnings("unused")
11         private int nbTasks; // nb de taches de l'appli
12         private MsgChrono chrono = new MsgChrono(); // chrono global de l'appli
13         private boolean running = false;
14
15         private int numberOfDisconnections = 0; // nb de deconnection de demons
16                                                                                         // depuis debut appli
17         private int numberOfSpawnerDisconnections = 0; // nb de deconnection de
18                                                                                                         // spawners depuis debut
19                                                                                                         // appli
20         private int numberOfCouilles = 0; // nb de deconnection depuis debut appli
21         private int numberOfSuicides = 0; // nb de deconnection depuis debut appli
22
23         private RunningApplication() {
24         }
25
26         public static RunningApplication Instance() {
27                 if (Instance == null) {
28                         Instance = new RunningApplication();
29                 }
30                 return Instance;
31         }
32
33         public synchronized MsgChrono getChrono() {
34                 return chrono;
35         }
36
37         // modificateurs d'attribut
38         public synchronized void setName(String appliName) {
39                 name = appliName;
40         }
41
42         public synchronized String getName() {
43                 return name;
44         }
45
46         public synchronized int getNumberOfCouilles() {
47                 return numberOfCouilles;
48         }
49
50         public synchronized void setNbTasks(int nb) {
51                 nbTasks = nb;
52         }
53
54         public void setRunning(boolean value) {
55                 running = value;
56         }
57
58         public synchronized int getNumberOfSpawnerDisconnections() {
59                 return numberOfSpawnerDisconnections;
60         }
61
62         public synchronized int getNumberOfDisconnections() {
63                 return numberOfDisconnections;
64         }
65
66         public synchronized void purge() {
67                 Instance = null;
68
69                 running = false;
70                 try {
71                         Thread.sleep(5000);
72                 } catch (Exception e) {
73                 }
74                 Register.Instance().purge();
75         }
76
77         public boolean isRunning() {
78                 return running;
79         }
80
81         public synchronized void incrementNumberOfDisconnections() {
82                 numberOfDisconnections++;
83         }
84
85         public synchronized void incrementNumberOfSpawnerDisconnections() {
86                 numberOfSpawnerDisconnections++;
87         }
88
89         public synchronized void setNumberOfDisconnections(int nb) {
90                 numberOfDisconnections = nb;
91         }
92
93         public synchronized void setNumberOfSpawnerDisconnections(int nb) {
94                 numberOfSpawnerDisconnections = nb;
95         }
96
97         public synchronized void incrementNumberOfCouille() {
98                 numberOfCouilles++;
99         }
100
101         public synchronized void incrementNumberOfSuicides() {
102                 numberOfSuicides++;
103         }
104
105 }