Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Bugfix in kademlia example
[simgrid.git] / examples / bittorrent / TrackerTask.java
1 package bittorrent;
2 import java.util.ArrayList;
3
4 import org.simgrid.msg.Task;
5
6 /**
7  * Task exchanged between the tracker
8  * and the peers. 
9  */
10 public class TrackerTask extends Task {
11         /**
12          * Type of the tasks
13          */
14         public enum Type {
15                 REQUEST,
16                 ANSWER
17         };
18         public Type type;
19         public String hostname;
20         public String mailbox;
21         public int peerId;
22         public int uploaded;
23         public int downloaded;
24         public int left;
25         public double interval;
26         public ArrayList<Integer> peers;
27         
28         public TrackerTask(String hostname, String mailbox, int peerId) {
29                 this(hostname, mailbox, peerId, 0, 0, Common.FILE_SIZE);
30         }       
31         public TrackerTask(String hostname, String mailbox, int peerId, int uploaded, int downloaded, int left) {
32                 super("", 0, Common.TRACKER_COMM_SIZE);
33                 this.type = Type.REQUEST;
34                 this.hostname = hostname;
35                 this.mailbox = mailbox;
36                 this.peerId = peerId;
37                 this.uploaded = uploaded;
38                 this.downloaded = downloaded;
39                 this.left = left;
40                 this.peers = new ArrayList<Integer>();
41         }
42         
43 }