Package com.atlassian.confluence.cluster
Class DefaultClusterConfigurationHelper
- java.lang.Object
-
- com.atlassian.confluence.cluster.DefaultClusterConfigurationHelper
-
- All Implemented Interfaces:
ClusterConfigurationHelper,ClusterConfigurationHelperInternal
@ParametersAreNonnullByDefault public class DefaultClusterConfigurationHelper extends Object implements ClusterConfigurationHelperInternal
An implementation ofClusterConfigurationHelperwhich assumes that a cluster of some sort is being used. The specifics of the underlying clustering technology are handled by theClusterManager. If no cluster is being used, then this class is not appropriate, andNonClusterConfigurationHelpershould be used instead.
-
-
Field Summary
Fields Modifier and Type Field Description static StringCLUSTERstatic StringCLUSTER_ADDRESSstatic StringCLUSTER_AUTHENTICATION_ENABLEDstatic StringCLUSTER_AUTHENTICATION_ENABLED_DEFAULT_VALstatic StringCLUSTER_AUTHENTICATION_SECRETstatic StringCLUSTER_AWSstatic StringCLUSTER_AWS_ACCESS_KEYstatic StringCLUSTER_AWS_HOST_HEADERstatic StringCLUSTER_AWS_IAM_ROLEstatic StringCLUSTER_AWS_REGIONstatic StringCLUSTER_AWS_SECRET_KEYstatic StringCLUSTER_AWS_SECURITY_GROUP_NAMEstatic StringCLUSTER_AWS_TAG_KEYstatic StringCLUSTER_AWS_TAG_VALUEstatic StringCLUSTER_HOMEstatic StringCLUSTER_INTERFACEstatic StringCLUSTER_JOIN_TYPEstatic StringCLUSTER_MULTICAST_PORT_SYS_PROPstatic StringCLUSTER_NAMEstatic StringCLUSTER_PEERSstatic Set<String>CLUSTER_SETUP_ENTRIESstatic StringCLUSTER_TTLstatic StringSHARED_HOMEstatic List<String>SUPPORTED_SHARED_HOME_CONFIG_PROPERTIES
-
Constructor Summary
Constructors Constructor Description DefaultClusterConfigurationHelper(com.atlassian.config.ApplicationConfig applicationConfig, ClusterManager clusterManager, LicenseServiceInternal licenseService, SingleConnectionProvider databaseHelper, com.atlassian.config.db.HibernateConfig hibernateConfig, ClusterCompatibilityValidator clusterCompatibilityValidator, com.atlassian.security.random.SecureTokenGenerator secureTokenGenerator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbootstrapCluster(BootstrapDatabaseAccessor.BootstrapDatabaseData bootstrapDatabaseData)Checks whether clustering is enabled, and bootstraps the cluster manager with an appropriate configurationvoidcreateCluster(String clusterName, File clusterHome, @Nullable String networkInterfaceName, ClusterJoinConfig joinConfig)Creates a new cluster with the given name, on the specified network interface, as long as the given cluster does not exist.voidcreateClusterConfig()Creates and sets up the cluster config file in the shared home if it doesn't already exist.voidcreateSharedHome()Creates shared home directory if it does not exist already.List<NetworkInterface>getClusterableInterfaces()Return a list of interfaces suitable for clustered communication.protected Optional<com.atlassian.config.ApplicationConfig>getClusterApplicationConfig()Optional<String>getSharedBuildNumber()Get the build number stored in the confluence.cfg.xml file in the shared home folderOptional<Object>getSharedProperty(Object key)Get the value of a property stored in the confluence.cfg.xml config file (in the shared home folder)booleanisClusteredInstance()booleanisClusterHomeConfigured()Optional<ClusterJoinConfig>joinConfig()Returns the configured join config if setup has progressed that far.voidpopulateExistingClusterSetupConfig()Merges the config file in shared home into the current config file (in local home folder).voidsaveSetupConfigIntoSharedHome()This method need to be trigger when we finish setup.voidsaveSharedBuildNumber(String sharedBuildNumber)Store the build number into the confluence.cfg.xml file in the shared home foldervoidsaveSharedProperty(Object key, Object value)Save a property into the shared confluence.cfg.xml config file (in the shared home folder)Optional<File>sharedHome()Return the shared home directory if one has been configured.
-
-
-
Field Detail
-
CLUSTER
public static final String CLUSTER
- See Also:
- Constant Field Values
-
CLUSTER_NAME
public static final String CLUSTER_NAME
- See Also:
- Constant Field Values
-
CLUSTER_INTERFACE
public static final String CLUSTER_INTERFACE
- See Also:
- Constant Field Values
-
CLUSTER_JOIN_TYPE
public static final String CLUSTER_JOIN_TYPE
- See Also:
- Constant Field Values
-
CLUSTER_ADDRESS
public static final String CLUSTER_ADDRESS
- See Also:
- Constant Field Values
-
CLUSTER_TTL
public static final String CLUSTER_TTL
- See Also:
- Constant Field Values
-
CLUSTER_MULTICAST_PORT_SYS_PROP
public static final String CLUSTER_MULTICAST_PORT_SYS_PROP
- See Also:
- Constant Field Values
-
CLUSTER_PEERS
public static final String CLUSTER_PEERS
- See Also:
- Constant Field Values
-
CLUSTER_AWS
public static final String CLUSTER_AWS
- See Also:
- Constant Field Values
-
CLUSTER_AWS_ACCESS_KEY
public static final String CLUSTER_AWS_ACCESS_KEY
- See Also:
- Constant Field Values
-
CLUSTER_AWS_SECRET_KEY
public static final String CLUSTER_AWS_SECRET_KEY
- See Also:
- Constant Field Values
-
CLUSTER_AWS_IAM_ROLE
public static final String CLUSTER_AWS_IAM_ROLE
- See Also:
- Constant Field Values
-
CLUSTER_AWS_TAG_KEY
public static final String CLUSTER_AWS_TAG_KEY
- See Also:
- Constant Field Values
-
CLUSTER_AWS_TAG_VALUE
public static final String CLUSTER_AWS_TAG_VALUE
- See Also:
- Constant Field Values
-
CLUSTER_AWS_REGION
public static final String CLUSTER_AWS_REGION
- See Also:
- Constant Field Values
-
CLUSTER_AWS_HOST_HEADER
public static final String CLUSTER_AWS_HOST_HEADER
- See Also:
- Constant Field Values
-
CLUSTER_AWS_SECURITY_GROUP_NAME
public static final String CLUSTER_AWS_SECURITY_GROUP_NAME
- See Also:
- Constant Field Values
-
CLUSTER_HOME
public static final String CLUSTER_HOME
- See Also:
- Constant Field Values
-
SHARED_HOME
public static final String SHARED_HOME
- See Also:
- Constant Field Values
-
CLUSTER_AUTHENTICATION_ENABLED
public static final String CLUSTER_AUTHENTICATION_ENABLED
- See Also:
- Constant Field Values
-
CLUSTER_AUTHENTICATION_ENABLED_DEFAULT_VAL
public static final String CLUSTER_AUTHENTICATION_ENABLED_DEFAULT_VAL
- See Also:
- Constant Field Values
-
CLUSTER_AUTHENTICATION_SECRET
public static final String CLUSTER_AUTHENTICATION_SECRET
- See Also:
- Constant Field Values
-
SUPPORTED_SHARED_HOME_CONFIG_PROPERTIES
public static final List<String> SUPPORTED_SHARED_HOME_CONFIG_PROPERTIES
-
-
Constructor Detail
-
DefaultClusterConfigurationHelper
public DefaultClusterConfigurationHelper(com.atlassian.config.ApplicationConfig applicationConfig, ClusterManager clusterManager, LicenseServiceInternal licenseService, SingleConnectionProvider databaseHelper, com.atlassian.config.db.HibernateConfig hibernateConfig, ClusterCompatibilityValidator clusterCompatibilityValidator, com.atlassian.security.random.SecureTokenGenerator secureTokenGenerator)- Since:
- 7.17.3
-
-
Method Detail
-
getClusterApplicationConfig
protected Optional<com.atlassian.config.ApplicationConfig> getClusterApplicationConfig()
- Returns:
- ApplicationConfig for the cluster if the cluster config file exists otherwise an empty Optional
-
createClusterConfig
public void createClusterConfig()
Description copied from interface:ClusterConfigurationHelperInternalCreates and sets up the cluster config file in the shared home if it doesn't already exist. Does nothing if the cluster config file already exists.- Specified by:
createClusterConfigin interfaceClusterConfigurationHelperInternal
-
populateExistingClusterSetupConfig
public void populateExistingClusterSetupConfig()
Description copied from interface:ClusterConfigurationHelperInternalMerges the config file in shared home into the current config file (in local home folder). Does nothing if the cluster config file doesn't exist.- Specified by:
populateExistingClusterSetupConfigin interfaceClusterConfigurationHelperInternal
-
saveSharedProperty
public void saveSharedProperty(Object key, Object value)
Description copied from interface:ClusterConfigurationHelperInternalSave a property into the shared confluence.cfg.xml config file (in the shared home folder)- Specified by:
saveSharedPropertyin interfaceClusterConfigurationHelperInternal- Parameters:
key- the key of the propertyvalue- the value of the property
-
getSharedProperty
public Optional<Object> getSharedProperty(Object key)
Description copied from interface:ClusterConfigurationHelperInternalGet the value of a property stored in the confluence.cfg.xml config file (in the shared home folder)- Specified by:
getSharedPropertyin interfaceClusterConfigurationHelperInternal- Parameters:
key- the key of the property- Returns:
- the value of the property
-
saveSharedBuildNumber
public void saveSharedBuildNumber(String sharedBuildNumber)
Description copied from interface:ClusterConfigurationHelperInternalStore the build number into the confluence.cfg.xml file in the shared home folder- Specified by:
saveSharedBuildNumberin interfaceClusterConfigurationHelperInternal- Parameters:
sharedBuildNumber- the shared build number to be saved
-
getSharedBuildNumber
public Optional<String> getSharedBuildNumber()
Description copied from interface:ClusterConfigurationHelperInternalGet the build number stored in the confluence.cfg.xml file in the shared home folder- Specified by:
getSharedBuildNumberin interfaceClusterConfigurationHelperInternal- Returns:
- the shared build number
-
saveSetupConfigIntoSharedHome
public void saveSetupConfigIntoSharedHome()
Description copied from interface:ClusterConfigurationHelperInternalThis method need to be trigger when we finish setup. If we setup Confluence Cluster then this method will write all necessary information so from second node won't go to setup again- Specified by:
saveSetupConfigIntoSharedHomein interfaceClusterConfigurationHelperInternal
-
isClusteredInstance
public boolean isClusteredInstance()
- Specified by:
isClusteredInstancein interfaceClusterConfigurationHelper- Returns:
- true if the application is currently configured to be part of a cluster, otherwise false.
-
isClusterHomeConfigured
public boolean isClusterHomeConfigured()
- Specified by:
isClusterHomeConfiguredin interfaceClusterConfigurationHelper- Returns:
- true if the application has the confluence.cluster.home property set, otherwise false.
-
createCluster
public void createCluster(String clusterName, File clusterHome, @Nullable String networkInterfaceName, ClusterJoinConfig joinConfig) throws ClusterException
Description copied from interface:ClusterConfigurationHelperCreates a new cluster with the given name, on the specified network interface, as long as the given cluster does not exist.- Specified by:
createClusterin interfaceClusterConfigurationHelper- Throws:
ClusterException- if an error setting up the cluster.
-
bootstrapCluster
public void bootstrapCluster(BootstrapDatabaseAccessor.BootstrapDatabaseData bootstrapDatabaseData) throws ClusterException
Description copied from interface:ClusterConfigurationHelperChecks whether clustering is enabled, and bootstraps the cluster manager with an appropriate configuration- Specified by:
bootstrapClusterin interfaceClusterConfigurationHelper- Parameters:
bootstrapDatabaseData- contains the build number and cluster upgrade state information to decide whether this node can join- Throws:
ClusterException- if there was an error configuring the cluster manager, or if the licensed nodes were exceeded by joining the cluster.
-
getClusterableInterfaces
public List<NetworkInterface> getClusterableInterfaces()
Description copied from interface:ClusterConfigurationHelperReturn a list of interfaces suitable for clustered communication. The list is ordered for suitable rendering in a UI.- Specified by:
getClusterableInterfacesin interfaceClusterConfigurationHelper- Returns:
- List of
NetworkInterfaceobjects
-
sharedHome
public Optional<File> sharedHome()
Description copied from interface:ClusterConfigurationHelperReturn the shared home directory if one has been configured.- Specified by:
sharedHomein interfaceClusterConfigurationHelper- Returns:
- shared home directory
-
createSharedHome
public void createSharedHome()
Description copied from interface:ClusterConfigurationHelperInternalCreates shared home directory if it does not exist already.Shared home is created only if not clustering.
- Specified by:
createSharedHomein interfaceClusterConfigurationHelperInternal
-
joinConfig
public Optional<ClusterJoinConfig> joinConfig()
Description copied from interface:ClusterConfigurationHelperReturns the configured join config if setup has progressed that far.- Specified by:
joinConfigin interfaceClusterConfigurationHelper- Returns:
- Join configuration
-
-