This repository has been archived by the owner on Jul 11, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #389 from josejulio/release/jon3.3.x
Bug 1655980 - Support EAP 7.2+ jgroups-cluster
- Loading branch information
Showing
2 changed files
with
65 additions
and
3 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
...gins/wfly-10/src/main/java/org/rhq/modules/plugins/wildfly10/BroadcastGroupComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package org.rhq.modules.plugins.wildfly10; | ||
|
||
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus; | ||
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition; | ||
import org.rhq.core.domain.resource.CreateResourceStatus; | ||
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport; | ||
import org.rhq.core.pluginapi.inventory.CreateResourceReport; | ||
import org.rhq.modules.plugins.wildfly10.json.ResultFailedException; | ||
|
||
public class BroadcastGroupComponent extends BaseComponent { | ||
|
||
static final String JGROUP_CLUSTERS = "jgroups-cluster"; | ||
|
||
private boolean jGroupClusterExists() throws Exception { | ||
try { | ||
this.readAttribute(JGROUP_CLUSTERS); | ||
return true; | ||
} catch (ResultFailedException ex) { | ||
return false; | ||
} | ||
} | ||
|
||
@Override | ||
public void updateResourceConfiguration(ConfigurationUpdateReport report) { | ||
// If no jgroup cluster found, remove it from the update call, as this property was introduced in EAP 7.2 | ||
try { | ||
if (!this.jGroupClusterExists()) { | ||
final ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition().copy(); | ||
configDef.getPropertyDefinitions().remove(JGROUP_CLUSTERS); | ||
report.getConfiguration().remove(JGROUP_CLUSTERS); | ||
ConfigurationWriteDelegate delegate = new ConfigurationWriteDelegate(configDef, getASConnection(), address); | ||
delegate.updateResourceConfiguration(report); | ||
} else { | ||
super.updateResourceConfiguration(report); | ||
} | ||
} catch (Exception ex) { | ||
getLog().error("Error while updating a BroadcastGroup", ex); | ||
report.setStatus(ConfigurationUpdateStatus.FAILURE); | ||
report.setErrorMessage(ex.getMessage()); | ||
} | ||
} | ||
|
||
@Override | ||
public CreateResourceReport createResource(CreateResourceReport report) { | ||
// If no jgroup cluster found, remove it from the create call, as this property was introduced in EAP 7.2 | ||
try { | ||
if (!this.jGroupClusterExists()) { | ||
ConfigurationDefinition configDef = report.getResourceType().getResourceConfigurationDefinition().copy(); | ||
configDef.getPropertyDefinitions().remove(JGROUP_CLUSTERS); | ||
CreateResourceDelegate delegate = new CreateResourceDelegate(configDef, getASConnection(), address); | ||
return delegate.createResource(report); | ||
} else { | ||
return super.createResource(report); | ||
} | ||
} catch (Exception ex) { | ||
getLog().error("Error while creating a BroadcastGroup", ex); | ||
report.setStatus(CreateResourceStatus.FAILURE); | ||
report.setErrorMessage(ex.getMessage()); | ||
return report; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters