-
Notifications
You must be signed in to change notification settings - Fork 0
/
Queue.java
47 lines (41 loc) · 1.26 KB
/
Queue.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
/**
* Class Queue is the data structure for a queue in the Pub-Sub system. It
* maintains the queue properties, data and the list of subscribers.
*
* @author Aditya Advani
* @author Ankita Sambhare
*
* @version May 13, 2016
*
*/
public class Queue implements Serializable {
// instance variables of the queue
String publisher; // name of the user who can publish into the queue
String name = ""; // name of the queue
String pattern = ""; // Queue identifier
int capacity = 0; // total number of messages that the queue can handle
ArrayList<String> data = new ArrayList<>(); // data holder for queue
HashMap<String, String> Subscribers = new HashMap<>(); // Map of all
// subscribers and
// their IP
//default constructor
Queue() {
}
//constructor for queue at the servers
Queue(String Pub, String QName, String QPattern) {
this.publisher = Pub;
this.name = QName;
this.pattern = QPattern;
this.capacity = 50;
}
//constructor for queue at the bootstrap
Queue(String Pub, String QName, String QPattern, boolean BootstrapQueue) {
this.publisher = Pub;
this.name = QName;
this.pattern = QPattern;
this.capacity = Integer.MAX_VALUE;
}
}