Class BNS
java.lang.Object
org.jcsp.net2.bns.BNS
- All Implemented Interfaces:
CSProcess
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final HashMapMap of barriers registered to a Node; NodeID->private static booleanFlag used to denote if the connection to the BNS has been initialisedprivate static final BNSSingleton instance of the BNS.private final HashMapMap of currently logged clients; NodeID->reply-channelprivate final AltingChannelInputA channel used to receive incoming link lost notificationsprivate final HashMapMap of registered barriers; name->locationprivate static BNSServiceThe internal service.private final HashMapMap of currently waiting resolves; name->reply-location -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BNSGets the singleton instance of the BNSstatic voidinitialise(NodeAddress bnsNode) Initialises the connection to the BNSstatic voidinitialise(NodeID bnsNode) Initialises the connection to the BNSstatic NetBarriernetBarrier(String name, int enrolled) Creates a new client end of a NetBarrierstatic NetBarriernetBarrier(String name, int localEnrolled, int netEnrolled) Creates a new server end of a NetBarrier with the given namestatic NetBarriernumberedNetBarrier(String name, int index, int localEnrolled, int netEnrolled) Creates a new server end of a NetBarrier with a given index and namevoidrun()The run method for the BNS process
-
Field Details
-
service
The internal service. This is used by the factory methods. -
initialised
private static boolean initialisedFlag used to denote if the connection to the BNS has been initialised -
instance
Singleton instance of the BNS. Only one may be created on a Node -
registeredBarriers
Map of registered barriers; name->location -
barrierRegister
Map of barriers registered to a Node; NodeID-> -
waitingResolves
Map of currently waiting resolves; name->reply-location -
loggedClients
Map of currently logged clients; NodeID->reply-channel -
lostLink
A channel used to receive incoming link lost notifications
-
-
Constructor Details
-
BNS
private BNS()Private empty constructor
-
-
Method Details
-
getInstance
Gets the singleton instance of the BNS- Returns:
- The singleton instance of the BNS
-
initialise
Initialises the connection to the BNS- Parameters:
bnsNode- The NodeID of the BNS Node- Throws:
JCSPNetworkException- Thrown if something goes wrong in the underlying architecture
-
initialise
Initialises the connection to the BNS- Parameters:
bnsNode- The NodeAddress of the BNS Node- Throws:
JCSPNetworkException- Thrown if something goes wrong in the underlying architecture
-
run
-
netBarrier
public static NetBarrier netBarrier(String name, int localEnrolled, int netEnrolled) throws IllegalArgumentException, IllegalStateException Creates a new server end of a NetBarrier with the given name- Parameters:
name- The name to register with the BNSlocalEnrolled- The number of locally enrolled processesnetEnrolled- The number of net enrolled processes to expect- Returns:
- A new NetBarrier server end with the number of enrolled processes
- Throws:
IllegalArgumentException- Thrown if the parameters are outside the defined rangesIllegalStateException- Thrown if the BNS connection has not been initialised
-
numberedNetBarrier
public static NetBarrier numberedNetBarrier(String name, int index, int localEnrolled, int netEnrolled) throws IllegalArgumentException, IllegalStateException Creates a new server end of a NetBarrier with a given index and name- Parameters:
name- Name to register with the BNSindex- The index to create the NetBarrier withlocalEnrolled- The number of locally enrolled processesnetEnrolled- The number of remote enrollments to wait for- Returns:
- A new NetBarrier
- Throws:
IllegalArgumentException- Thrown if the parameters are outside the defined rangesIllegalStateException- Thrown if the connection to the BNS has not been initialised
-
netBarrier
public static NetBarrier netBarrier(String name, int enrolled) throws IllegalArgumentException, IllegalStateException, JCSPNetworkException Creates a new client end of a NetBarrier- Parameters:
name- The name to resolve with the BNSenrolled- The number of locally enrolled processes- Returns:
- A new NetBarrier client end with the number of enrolled processes
- Throws:
JCSPNetworkException- Thrown if something goes wrong in the underlying architectureIllegalArgumentException- Thrown if the number of of local enrolled is outside the defined rangeIllegalStateException- Thrown if the connection to the BNS has not been initialised
-