Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
keep playing
[simgrid.git] / examples / java / app / bittorrent / TrackerTask.java
1 /* Copyright (c) 2006-2014, 2016. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 package app.bittorrent;
8 import java.util.ArrayList;
9
10 import org.simgrid.msg.Task;
11
12 /* Task exchanged between the tracker and the peers. */
13 public class TrackerTask extends Task {
14   public enum Type {
15     REQUEST,
16     ANSWER
17   }
18
19   protected Type type;
20   protected String hostname;
21   protected String mailbox;
22   protected int peerId;
23   protected int uploaded;
24   protected int downloaded;
25   protected int left;
26   protected double interval;
27   protected ArrayList<Integer> peers;
28
29   public TrackerTask(String hostname, String mailbox, int peerId) {
30     this(hostname, mailbox, peerId, 0, 0, Common.FILE_SIZE);
31   }
32
33   public TrackerTask(String hostname, String mailbox, int peerId, int uploaded, int downloaded, int left) {
34     super("", 0, Common.TRACKER_COMM_SIZE);
35     this.type = Type.REQUEST;
36     this.hostname = hostname;
37     this.mailbox = mailbox;
38     this.peerId = peerId;
39     this.uploaded = uploaded;
40     this.downloaded = downloaded;
41     this.left = left;
42     this.peers = new ArrayList<>();
43   }
44 }