public class BNS extends java.lang.Object implements CSProcess
CNS
,
BNSService
,
Node
Modifier and Type | Field and Description |
---|---|
private java.util.HashMap |
barrierRegister
Map of barriers registered to a Node; NodeID->
|
private static boolean |
initialised
Flag used to denote if the connection to the BNS has been initialised
|
private static BNS |
instance
Singleton instance of the BNS.
|
private java.util.HashMap |
loggedClients
Map of currently logged clients; NodeID->reply-channel
|
private AltingChannelInput |
lostLink
A channel used to receive incoming link lost notifications
|
private java.util.HashMap |
registeredBarriers
Map of registered barriers; name->location
|
private static BNSService |
service
The internal service.
|
private java.util.HashMap |
waitingResolves
Map of currently waiting resolves; name->reply-location
|
Modifier | Constructor and Description |
---|---|
private |
BNS()
Private empty constructor
|
Modifier and Type | Method and Description |
---|---|
static BNS |
getInstance()
Gets the singleton instance of the BNS
|
static void |
initialise(NodeAddress bnsNode)
Initialises the connection to the BNS
|
static void |
initialise(NodeID bnsNode)
Initialises the connection to the BNS
|
static NetBarrier |
netBarrier(java.lang.String name,
int enrolled)
Creates a new client end of a NetBarrier
|
static NetBarrier |
netBarrier(java.lang.String name,
int localEnrolled,
int netEnrolled)
Creates a new server end of a NetBarrier with the given name
|
static NetBarrier |
numberedNetBarrier(java.lang.String name,
int index,
int localEnrolled,
int netEnrolled)
Creates a new server end of a NetBarrier with a given index and name
|
void |
run()
The run method for the BNS process
|
private static BNSService service
private static boolean initialised
private static final BNS instance
private final java.util.HashMap registeredBarriers
private final java.util.HashMap barrierRegister
private final java.util.HashMap waitingResolves
private final java.util.HashMap loggedClients
private final AltingChannelInput lostLink
public static BNS getInstance()
public static void initialise(NodeID bnsNode) throws JCSPNetworkException
bnsNode
- The NodeID of the BNS NodeJCSPNetworkException
- Thrown if something goes wrong in the underlying architecturepublic static void initialise(NodeAddress bnsNode) throws JCSPNetworkException
bnsNode
- The NodeAddress of the BNS NodeJCSPNetworkException
- Thrown if something goes wrong in the underlying architecturepublic static NetBarrier netBarrier(java.lang.String name, int localEnrolled, int netEnrolled) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
name
- The name to register with the BNSlocalEnrolled
- The number of locally enrolled processesnetEnrolled
- The number of net enrolled processes to expectjava.lang.IllegalArgumentException
- Thrown if the parameters are outside the defined rangesjava.lang.IllegalStateException
- Thrown if the BNS connection has not been initialisedpublic static NetBarrier numberedNetBarrier(java.lang.String name, int index, int localEnrolled, int netEnrolled) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
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 forjava.lang.IllegalArgumentException
- Thrown if the parameters are outside the defined rangesjava.lang.IllegalStateException
- Thrown if the connection to the BNS has not been initialisedpublic static NetBarrier netBarrier(java.lang.String name, int enrolled) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException, JCSPNetworkException
name
- The name to resolve with the BNSenrolled
- The number of locally enrolled processesJCSPNetworkException
- Thrown if something goes wrong in the underlying architecturejava.lang.IllegalArgumentException
- Thrown if the number of of local enrolled is outside the defined rangejava.lang.IllegalStateException
- Thrown if the connection to the BNS has not been initialised