- java.lang.Object
-
- com.aoapps.appcluster.AppCluster
-
public class AppCluster extends Object
Central AppCluster manager.- Author:
- AO Industries, Inc.
-
-
Constructor Summary
Constructors Constructor Description AppCluster(AppClusterConfiguration configuration)Creates a cluster with the provided configuration.AppCluster(File file)Creates a cluster loading configuration from the provided properties file.AppCluster(Properties properties)Creates a cluster configurated from the provided properties file.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddResourceListener(ResourceListener resourceListener)Will be called when the resource result has changed in any way.static voidcheckConfiguration(Set<? extends NodeConfiguration> nodeConfigurations, Set<? extends ResourceConfiguration<?,?>> resourceConfigurations)Performs a consistency check on a configuration.StringgetDisplay()Gets the display name for this cluster ornullif not started.NamegetLocalHostname()Gets the hostname used to determine which node this server represents ornullif not started.NodegetLocalNode()Gets the node this machine represents ornullif this machine is not one of the nodes.StringgetLocalUsername()Gets the username used to determine which node this server represents ornullif not started.NodegetNode(String id)Gets a node given its ID ornullif not found.Map<String,Node>getNodeMap()Gets a map view of the nodes, keyed by their id.Set<? extends Node>getNodes()Gets the set of all nodes or empty set if not started.Map<String,? extends Resource<?,?>>getResourceMap()Gets a map view of the resources keyed on String resourceId.Set<? extends Resource<?,?>>getResources()Gets the set of all resources or empty set if not started.UnmodifiableTimestampgetStartedTime()Gets the time this cluster was started ornullif not running.ResourceStatusgetStatus()Gets the overall status of the cluster based on started, enabled, and all resources.EnumSet<ResourceStatus>getStatuses()Gets all of the possible statuses for this cluster.booleanisEnabled()If the cluster is disabled, every node and resource will also be disabled.booleanisRunning()Checks if this cluster is running.voidremoveResourceListener(ResourceListener resourceListener)Removes listener of resource result changes.voidstart()Starts this cluster manager.voidstop()Stops this cluster manager.StringtoString()
-
-
-
Constructor Detail
-
AppCluster
public AppCluster(AppClusterConfiguration configuration)
Creates a cluster with the provided configuration. The cluster is not started untilstartis called.- See Also:
start()
-
AppCluster
public AppCluster(File file)
Creates a cluster loading configuration from the provided properties file. Any change to the file will cause an automatic reload of the cluster configuration. The cluster is not started untilstartis called.- See Also:
start()
-
AppCluster
public AppCluster(Properties properties)
Creates a cluster configurated from the provided properties file. Changes to the properties file will not result in a cluster configuration. The cluster is not started untilstartis called.- See Also:
start()
-
-
Method Detail
-
checkConfiguration
public static void checkConfiguration(Set<? extends NodeConfiguration> nodeConfigurations, Set<? extends ResourceConfiguration<?,?>> resourceConfigurations) throws AppClusterConfigurationException
Performs a consistency check on a configuration.- Throws:
AppClusterConfigurationException
-
addResourceListener
public void addResourceListener(ResourceListener resourceListener)
Will be called when the resource result has changed in any way.
-
removeResourceListener
public void removeResourceListener(ResourceListener resourceListener)
Removes listener of resource result changes.
-
getStartedTime
public UnmodifiableTimestamp getStartedTime()
Gets the time this cluster was started ornullif not running.
-
start
public void start() throws AppClusterConfigurationExceptionStarts this cluster manager.- Throws:
AppClusterConfigurationException- See Also:
stop()
-
stop
public void stop()
Stops this cluster manager.- See Also:
start()
-
isEnabled
public boolean isEnabled()
If the cluster is disabled, every node and resource will also be disabled. A stopped cluster is considered disabled.
-
getDisplay
public String getDisplay()
Gets the display name for this cluster ornullif not started.
-
getNodes
public Set<? extends Node> getNodes()
Gets the set of all nodes or empty set if not started.
-
getNodeMap
public Map<String,Node> getNodeMap()
Gets a map view of the nodes, keyed by their id. This is not a fast implementation and is here for JSP EL compatibility.
-
getLocalHostname
public Name getLocalHostname()
Gets the hostname used to determine which node this server represents ornullif not started.
-
getLocalUsername
public String getLocalUsername()
Gets the username used to determine which node this server represents ornullif not started.
-
getLocalNode
public Node getLocalNode()
Gets the node this machine represents ornullif this machine is not one of the nodes. For this JVM to be considered the local node, the system hostname must match this node's hostname, and the system property "user.name" must match this node's username. Determined at cluster start time, before any resources are started. Returnsnullwhen not started.
-
getResources
public Set<? extends Resource<?,?>> getResources()
Gets the set of all resources or empty set if not started.
-
getResourceMap
public Map<String,? extends Resource<?,?>> getResourceMap()
Gets a map view of the resources keyed on String resourceId. This is for compatibility with JSP EL - it is not a fast implementation.
-
getStatuses
public EnumSet<ResourceStatus> getStatuses()
Gets all of the possible statuses for this cluster. This is primarily for JavaBeans property from JSP EL.
-
getStatus
public ResourceStatus getStatus()
Gets the overall status of the cluster based on started, enabled, and all resources.
-
-