// StorageNodePluginConfig
Configuration storageNodePluginConfig = configurationManager.getPluginConfiguration(subject,
storageNodeResource.getId());
StorageNodeConfigurationComposite existingStorageNodeConfigurationComposite = StorageNodeConfigurationUtil.createCompositeConfiguration(storageNodeResourceConfig, storageNodePluginConfig, storageNode);
StorageNodeConfigurationUtil.syncConfigs(newStorageNodeConfigurationComposite, existingStorageNodeConfigurationComposite);
if(!existingStorageNodeConfigurationComposite.equals(newStorageNodeConfigurationComposite)) {
// Now we need an update
StorageNodeConfigurationUtil.updateValuesToConfiguration(newStorageNodeConfigurationComposite, storageNodeResourceConfig);
if(!existingStorageNodeConfigurationComposite.isDirectoriesEqual(newStorageNodeConfigurationComposite)) {
storageNodeResourceConfig.setSimpleValue(StorageNodeConfigurationUtil.RHQ_STORAGE_NOTIFY_DIR_CHANGE_PROPERTY, Boolean.TRUE.toString());
}
ResourceConfigurationUpdate resourceUpdate = configurationManager.updateResourceConfiguration(subject, storageNodeResource.getId(),
storageNodeResourceConfig);
// initial waiting before the first check
try {
Thread.sleep(2000L);
} catch (InterruptedException e) {
// nothing
}
// wait for the resource config update
ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
criteria.addFilterId(resourceUpdate.getId());
criteria.addFilterStartTime(System.currentTimeMillis() - (5 * 60 * 1000));
boolean updateSuccess = waitForConfigurationUpdateToFinish(subject, criteria, 10);
// restart the storage node and wait for it
boolean restartSuccess = runOperationAndWaitForResult(subject, storageNodeResource, RESTART_OPERATION,
null, 5000, 15);
if (!updateSuccess || !restartSuccess)
return false;
}
if (existingStorageNodeConfigurationComposite.getJmxPort() != newStorageNodeConfigurationComposite.getJmxPort()) {
String newJMXPort = Integer.toString(newStorageNodeConfigurationComposite.getJmxPort());
String existingJMXPort = Integer.toString(existingStorageNodeConfigurationComposite.getJmxPort());
// 2. upgrade the plugin configuration if there was a change
storageNodePluginConfig.setSimpleValue(StorageNodeConfigurationUtil.RHQ_STORAGE_JMX_PORT_PROPERTY, newJMXPort);
String existingConnectionURL = storageNodePluginConfig.getSimpleValue(StorageNodeConfigurationUtil.RHQ_STORAGE_CONNECTOR_PROPERTY);
String newConnectionURL = existingConnectionURL.replace(":" + existingJMXPort + "/", ":"
+ newStorageNodeConfigurationComposite.getJmxPort() + "/");