public class MasterContainer extends Container implements ConnectionListener
| Constructor and Description |
|---|
MasterContainer(Platform platform)
Creates a master container, runs its TCP server on an automatically selected port.
|
MasterContainer(Platform platform,
int port)
Creates a master container, runs its TCP server on a specified port.
|
MasterContainer(Platform platform,
int port,
java.util.function.Supplier<Firewall> fwSupplier)
Creates a master container, runs its TCP server on a specified port,
with a specified firewall supplier.
|
MasterContainer(Platform platform,
java.lang.String name)
Creates a named master container, runs its TCP server on an automatically selected port.
|
MasterContainer(Platform platform,
java.lang.String name,
int port)
Creates a named master container, runs its TCP server on a specified port.
|
MasterContainer(Platform platform,
java.lang.String name,
int port,
java.util.function.Supplier<Firewall> fwSupplier)
Creates a named master container, runs its TCP server on a specified port,
with a specified firewall supplier.
|
MasterContainer(Platform platform,
java.lang.String name,
java.util.function.Supplier<Firewall> fwSupplier)
Creates a named master container, runs its TCP server on an automatically selected port,
with a specified firewall supplier.
|
MasterContainer(Platform platform,
java.util.function.Supplier<Firewall> fwSupplier)
Creates a master container, runs its TCP server on an automatically selected port,
with a specified firewall supplier.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addConnector(Connector conn)
Adds a connector over which the master container listens.
|
void |
addConnector(Connector conn,
Firewall fw)
Adds a connector over which the master container listens, but with a custom
firewall for that connector.
|
AgentID |
agentForService(java.lang.String service)
Finds an agent providing a named service.
|
AgentID[] |
agentsForService(java.lang.String service)
Gets the agent IDs of all agents that provide a given service.
|
boolean |
closeWebSocketServer() |
void |
connected(Connector conn) |
void |
connectionClosed(ConnectionHandler handler)
Callback for closure of connection to remote container.
|
AgentID[] |
getAgents()
Gets all agent ids in the container.
|
ConnectionHandler[] |
getConnectionHandlers()
Gets a list of connection handlers for the slaves connected to this master container.
|
java.lang.String[] |
getConnectors()
Gets a list of connector URLs that slaves can use to access the master container.
|
int |
getPort()
Gets the TCP port on which the master container listens for connections.
|
java.lang.String[] |
getServices()
Gets a list of all services that agents in this container provide.
|
protected void |
initComplete()
Called when the container is initialized.
|
protected boolean |
isDuplicate(AgentID aid)
Checks if an agent id already exists in the container.
|
boolean |
openWebSocketServer(int port,
java.lang.String context)
Opens a WebSocket server at the given context on the web server running on a port.
|
boolean |
openWebSocketServer(int port,
java.lang.String context,
int maxMsgSize)
Opens a WebSocket server at the given context on the web server running on a port.
|
boolean |
send(Message m)
Sends a message.
|
boolean |
send(Message m,
boolean relay)
Sends a message.
|
void |
shutdown()
Terminates the container and all agents in it.
|
java.lang.String |
toString()
Gets a string representation of the container.
|
add, add, addListener, canLocateAgent, clone, containsAgent, deregister, deregister, getAgent, getAutoClone, getName, getPlatform, getState, isIdle, isRunning, kill, kill, register, removeListener, setAutoClone, setCloner, setName, start, subscribe, unsubscribe, unsubscribepublic MasterContainer(Platform platform)
platform - platform on which the container runs.public MasterContainer(Platform platform, java.util.function.Supplier<Firewall> fwSupplier)
platform - platform on which the container runs.fwSupplier - firewall supplier to use.public MasterContainer(Platform platform, int port)
platform - platform on which the container runs.port - port on which the container's TCP server runs.public MasterContainer(Platform platform, int port, java.util.function.Supplier<Firewall> fwSupplier)
platform - platform on which the container runs.port - port on which the container's TCP server runs.fwSupplier - firewall supplier to use.public MasterContainer(Platform platform, java.lang.String name)
platform - platform on which the container runs.name - name of the container.public MasterContainer(Platform platform, java.lang.String name, java.util.function.Supplier<Firewall> fwSupplier)
platform - platform on which the container runs.name - name of the container.fwSupplier - firewall supplier to use.public MasterContainer(Platform platform, java.lang.String name, int port)
platform - platform on which the container runs.name - of the container.port - port on which the container's TCP server runs.public MasterContainer(Platform platform, java.lang.String name, int port, java.util.function.Supplier<Firewall> fwSupplier)
platform - platform on which the container runs.name - of the container.port - port on which the container's TCP server runs.fwSupplier - firewall supplier to use.public int getPort()
public void addConnector(Connector conn)
conn - connector.public void addConnector(Connector conn, Firewall fw)
conn - connector.fw - firewall.public java.lang.String[] getConnectors()
public ConnectionHandler[] getConnectionHandlers()
protected boolean isDuplicate(AgentID aid)
ContainerisDuplicate in class Containeraid - the agent id to check.public boolean send(Message m)
Containerpublic boolean send(Message m, boolean relay)
Containerpublic AgentID[] getAgents()
Containerpublic java.lang.String[] getServices()
ContainergetServices in class Containerpublic AgentID agentForService(java.lang.String service)
ContaineragentForService in class Containerservice - name of the service.public AgentID[] agentsForService(java.lang.String service)
agentsForService in class Containerservice - name of the service.protected void initComplete()
ContainerinitComplete in class Containerpublic void shutdown()
Containerpublic java.lang.String toString()
Containerpublic void connectionClosed(ConnectionHandler handler)
handler - indicates the connection that is closed.public boolean openWebSocketServer(int port,
java.lang.String context)
port - web server port.context - context path for the WebSocket server.public boolean openWebSocketServer(int port,
java.lang.String context,
int maxMsgSize)
port - web server port.context - context path for the WebSocket server.maxMsgSize - maximum text message size, or -1 for the default.public boolean closeWebSocketServer()
public void connected(Connector conn)
connected in interface ConnectionListener