View Javadoc

1   package org.xvsm.remote.freepastry;
2   
3   import java.util.ArrayList;
4   
5   import rice.p2p.commonapi.NodeHandle;
6   
7   /***
8    * Configuration class, which stores the parameters of the network like the
9    * ports, the number of replicas, etc.
10   * 
11   * @author Hannu-Daniel Goiss
12   */
13  public class FreePastryConfiguration {
14  	private static FreePastryConfiguration fpc;
15  	private String pastryIp;
16  	private int pastryPort;
17  	private int localPort;
18  	private int numberOfContainers;
19  	private static int neighbours = 0;
20  	private static ArrayList<NodeHandle> handles = new ArrayList<NodeHandle>();
21  
22  	private FreePastryConfiguration() {
23  	}
24  
25  	public void increaseNeighbours(NodeHandle arg0) {
26  		neighbours++;
27  		handles.add(arg0);
28  	}
29  
30  	public void decreaseNeighbours(NodeHandle arg0) {
31  		neighbours--;
32  		handles.remove(arg0);
33  	}
34  
35  	public static FreePastryConfiguration getInstance() {
36  		if (fpc == null) {
37  			fpc = new FreePastryConfiguration();
38  		}
39  
40  		return fpc;
41  	}
42  
43  	public String getPastryIp() {
44  		return pastryIp;
45  	}
46  
47  	public void setPastryIp(String pastryIp) {
48  		this.pastryIp = pastryIp;
49  	}
50  
51  	public int getPastryPort() {
52  		return pastryPort;
53  	}
54  
55  	public void setPastryPort(int pastryPort) {
56  		this.pastryPort = pastryPort;
57  	}
58  
59  	public int getLocalPort() {
60  		return localPort;
61  	}
62  
63  	public void setLocalPort(int localPort) {
64  		this.localPort = localPort;
65  	}
66  
67  	public int getNumberOfContainers() {
68  		return numberOfContainers;
69  	}
70  
71  	public void setNumberOfContainers(int numberOfContainers) {
72  		this.numberOfContainers = numberOfContainers;
73  	}
74  
75  	public static int getNeighbours() {
76  		return neighbours;
77  	}
78  }