public class BrokerManager
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.util.Map<java.lang.String,Broker> |
activeBrokers
Brokers registry
|
private static java.util.Map<java.lang.String,java.util.List<java.net.InetAddress>> |
allHosts
Map of users to hosts
|
private static java.util.Map<java.lang.String,java.util.List<java.net.InetAddress>> |
dedicatedHosts
Map of users to dedicated hosts
|
private static java.util.Map<java.net.InetAddress,java.lang.Integer> |
hosts
Dynamic hosts map of registered brokers agents
|
private static java.lang.String |
HOSTS_FILE_PATH
The path to the hosts file
|
private static java.util.logging.Logger |
LOG
Logger.
|
private static java.util.concurrent.atomic.AtomicInteger |
nextRegisteredHost
Next registered broker agent
|
private static SessionListener |
sessionListener
Session listener
|
Constructor and Description |
---|
BrokerManager() |
Modifier and Type | Method and Description |
---|---|
private static void |
addUserHostWithCheck(java.lang.String user,
java.net.InetAddress hostAddress,
java.util.Map<java.lang.String,java.util.List<java.net.InetAddress>> targetUserHosts)
Add a new user host to the target "user to hosts" map.
|
static void |
cleanup()
Called on server shutdown from a server hook.
|
(package private) static void |
deregisterBroker(BrokerParameters brokerAgent)
Removes user hosts associated with the broker agent that closes its session.
|
private static BrokerParameters |
findBroker(java.lang.String uuid)
Find a broker using the given ID.
|
private static java.util.List<java.lang.String> |
getBrokerAccounts(DirectoryService ds,
java.lang.String broker)
Get a list of P2J accounts which are served by this broker or and empty list if
no accounts are configured for this broker.
|
static Brokers |
getBrokers(java.lang.String user)
Get a list of brokers for the given P2J or OS user account.
|
private static java.util.List<BrokerParameters> |
getBrokersForUser(java.lang.String user)
Get a list of brokers for a specified account.
|
private static java.util.List<java.net.InetAddress> |
getHostsForUser(java.lang.String user,
boolean dedicatedMode)
Get dedicated hosts or all hosts for a specified account.
|
static java.lang.Integer |
getOrderedNumber(java.lang.String host)
Returns the host order number.
|
static void |
initialize()
Read brokers configuration from directory.
|
static java.lang.String |
registerBroker(java.lang.String host,
java.lang.String user,
boolean dedicatedMode)
Register a remote launcher (broker).
|
private static void |
removeBroker(Session session)
Remove a broker from registry when the remote session is closed.
|
private static void |
removeUserHostWithCheck(java.lang.String user,
java.net.InetAddress hostAddress,
java.util.Map<java.lang.String,java.util.List<java.net.InetAddress>> targetUserHosts)
Removes a given user host from the target "user to hosts" map.
|
private static BrokerParameters |
schedule(java.util.List<BrokerParameters> brokers,
java.lang.String dedicatedUser,
java.lang.String clientAddress)
Select a broker from the broker list which has the lowest system loading.
|
static BrokerSpawnResult |
spawn(java.lang.String dedicatedUser,
Brokers brokers,
BrokerSpawnParameters args)
Spawn a process remotely via a broker.
|
static void |
start(java.lang.String uuid)
Open a communication route to broker.
|
private static final java.util.logging.Logger LOG
private static final java.lang.String HOSTS_FILE_PATH
private static java.util.Map<java.lang.String,Broker> activeBrokers
private static java.util.Map<java.lang.String,java.util.List<java.net.InetAddress>> dedicatedHosts
private static java.util.Map<java.lang.String,java.util.List<java.net.InetAddress>> allHosts
private static java.util.Map<java.net.InetAddress,java.lang.Integer> hosts
private static java.util.concurrent.atomic.AtomicInteger nextRegisteredHost
private static SessionListener sessionListener
public static void initialize()
public static void cleanup()
public static java.lang.String registerBroker(java.lang.String host, java.lang.String user, boolean dedicatedMode)
BrokerServerServices.registerBroker(java.lang.String, java.lang.String, boolean)
host
- The host address of the remote launcheruser
- P2J or OS user account associated with this registering brokerdedicatedMode
- True value indicates that this registering broker client will spawn clients
accessed only from its local host, otherwise spawned clients can be accessed
from network.public static void start(java.lang.String uuid)
uuid
- Broker UUID.public static BrokerSpawnResult spawn(java.lang.String dedicatedUser, Brokers brokers, BrokerSpawnParameters args)
For brokers having the user name defined in the list of accounts a broker is selected from list based on system loading reported by broker and this broker is used to launch the remote client. On error no other brokers are selected.
dedicatedUser
- The dedicated user associated with the host on which the spawned client
will be runbrokers
- List of available brokers.args
- Process parameters.public static Brokers getBrokers(java.lang.String user)
user
- P2J or OS user accountstatic void deregisterBroker(BrokerParameters brokerAgent)
brokerAgent
- private static void removeUserHostWithCheck(java.lang.String user, java.net.InetAddress hostAddress, java.util.Map<java.lang.String,java.util.List<java.net.InetAddress>> targetUserHosts)
user
- The user account namehostAddress
- The agent host addresstargetUserHosts
- The target "user to hosts" mapprivate static BrokerParameters schedule(java.util.List<BrokerParameters> brokers, java.lang.String dedicatedUser, java.lang.String clientAddress)
brokers
- List of brokers.dedicatedUser
- The dedicated user for which the spawned client will be runclientAddress
- The client addressprivate static void addUserHostWithCheck(java.lang.String user, java.net.InetAddress hostAddress, java.util.Map<java.lang.String,java.util.List<java.net.InetAddress>> targetUserHosts)
user
- The user account namehostAddress
- The agent host addresstargetUserHosts
- The target "user to hosts" mapprivate static java.util.List<BrokerParameters> getBrokersForUser(java.lang.String user)
user
- User account. If null select a list of brokers having no accounts.private static java.util.List<java.net.InetAddress> getHostsForUser(java.lang.String user, boolean dedicatedMode)
user
- The specified user accountdedicatedMode
- True value indicates that only hosts that are for the dedicated broker clients,
otherwise all userpublic static java.lang.Integer getOrderedNumber(java.lang.String host) throws java.net.UnknownHostException
host
- The target hostjava.net.UnknownHostException
- If the host IP address can't be resolvedprivate static BrokerParameters findBroker(java.lang.String uuid)
uuid
- Broker ID.private static void removeBroker(Session session)
session
- Broker session instance.private static java.util.List<java.lang.String> getBrokerAccounts(DirectoryService ds, java.lang.String broker)
ds
- Directory services API.broker
- Directory path of this broker.