Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Creating the JaceP2P repository.
[jaceP2P.git] / src / jaceP2P / Node.java
1 package jaceP2P;
2
3 import java.io.ObjectOutputStream;
4 import java.io.OutputStream;
5
6 public class Node implements java.io.Serializable {
7         private static final long serialVersionUID = 1L;
8
9         // attributes
10         private String ip;
11         private String name = null;
12         private String appliName = null;
13         private boolean aliveFlag;
14         private JaceInterface stub;
15         private long aliveTime = System.currentTimeMillis();
16         @SuppressWarnings("unused")
17         private int port;
18         private int nbOfBeats = 0;
19         private Object o = null;
20         private long id = -1;
21
22         public Node(JaceInterface s) {
23                 stub = s;
24         }
25
26         public void setOutputStream(OutputStream out) {
27                 this.o = out;
28         }
29         
30         public void setId( long _id ) 
31         {
32                 id = _id ;
33         }
34         
35         public long getId()
36         {
37                 return id ;
38         }
39
40         public OutputStream getOutputStream() {
41                 return (ObjectOutputStream) o;
42         }
43
44         public synchronized void setName(String name) {
45                 this.name = name;
46         }
47
48         public synchronized void setIP(String adr) {
49                 this.ip = adr;
50         }
51
52         public synchronized void setAliveFlag(boolean val) {
53                 aliveFlag = val;
54         }
55
56         public synchronized void setAliveTime() {
57                 aliveTime = System.currentTimeMillis();
58         }
59
60         public synchronized long getAliveTime() {
61                 return aliveTime;
62         }
63
64         public synchronized void setPort(int portOfComm) {
65                 port = portOfComm;
66         }
67
68         public synchronized void setAppliName(String appli) {
69                 this.appliName = appli;
70         }
71
72         public synchronized String getAppliName() {
73                 return appliName;
74         }
75
76         public synchronized void setNbOfBeats(int nb) {
77                 nbOfBeats = nb;
78         }
79
80         public synchronized JaceInterface getStub() {
81                 return stub;
82         }
83
84         public synchronized String getName() {
85                 return name;
86         }
87
88         public synchronized void incrementNbOfBeats() {
89                 nbOfBeats++;
90                 if (nbOfBeats > 10000000) {
91                         nbOfBeats = 100;
92                 }
93         }
94
95         public synchronized boolean getAliveFlag() {
96                 return aliveFlag;
97         }
98
99         public synchronized int getNbOfBeats() {
100                 return nbOfBeats;
101         }
102
103         public synchronized String getIP() {
104                 return ip;
105         }
106 }
107
108 /** ! **/