Implement a Cluster Awareness of Configurations
Automation Orchestrator deployments can work in a cluster, which involves transferring configuration data between the clustered nodes. When you make a configuration change, for example, add an inventory object on one of the nodes in the cluster, this change does not automatically propagate to the workflow engines of the rest of the nodes.
- Detect that a change has been applied.
The
IEndpointConfigurationService.getVersion()
method returns the current version of the configuration data in the database.The following code detects the change, by comparing the existing version to the version that is stored in the database.
public class DefaultConnectionPersister implements ConnectionPersister { @Autowired private IEndpointConfigurationService cachingEndpointConfigurationService; private String configurationVersion; public boolean changed() throws IOException { return configurationVersion == null || configurationVersion.isEmpty() || !configurationVersion.equals(cachingEndpointConfigurationService.getVersion()); } }
This check is invoked every time an object that depends on the configuration data is accessed.
- If the check detects a change, load configuration data. Note: The Automation Orchestrator platform caches the
IEndpointConfigurationService.getVersion()
method. The caching interval is different depending on the version of Automation Orchestrator.- If the Automation Orchestrator version is 7.0.0 or
later, the maximum caching interval is two heart-beat intervals.
For example, if the heart-beat interval is five seconds and a configuration change occurs on Node1, calling the
getVersion()
method on the other nodes returns a cached value for a maximum period of 10 seconds. - If the Automation Orchestrator version is earlier
than 7.0.0, the platform does not cache the version.
In this case, caching is additionally provided and the TTL (Time To Live) interval is 10 seconds.
- If the Automation Orchestrator version is 7.0.0 or
later, the maximum caching interval is two heart-beat intervals.
IEndpointConfigurationService Implementation
IEndpointConfigurationService.getVersion()
method can work on all
versions of Automation Orchestrator. - In the Maven pom.xml file, add a compile-time dependency to the
o11n-plugin-tools artifact, so that the plug-in package includes the artifact.
<dependency> <groupId>com.vmware.o11n</groupId> <artifactId>o11n-plugin-tools</artifactId> <version>${vco.version}</version> </dependency>
- Implement
IEndpointConfigurationService depending on the type of the
plug-in. For Spring-based plug-ins, the name of the component is cachingEndpointConfigurationService.
- The name the property must be
cachingEndpointConfigurationService.
@Autowired private IEndpointConfigurationService cachingEndpointConfigurationService;
- Add the application content XML to
the
plug-in.
<context:component-scan basepackage="com.vmware.o11n.plugin.sdk.endpoints.extensions" annotationconfig="true"/>
For plug-ins that are not Spring-based, search the correct version, for example, in thesetServiceRegistry
method.endpointConfigurationService = EndpointConfigurationServiceFactory.lookupEndpointConfigurationService(registry );
- The name the property must be
cachingEndpointConfigurationService.
- Reload the configuration data.
By fetching all data through endpointConfiguratonService, find the changed entries on the other nodes.
- Update the state of the inventory objects according to the loaded configuration data.