Logo AND Algorithmique Numérique Distribuée

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