Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/bz1069606-r…
Browse files Browse the repository at this point in the history
…ebase-eap-63
  • Loading branch information
jmazzitelli committed Jun 14, 2014
2 parents dadc434 + 2fa7c54 commit 4d3d64c
Show file tree
Hide file tree
Showing 67 changed files with 1,495 additions and 473 deletions.
9 changes: 6 additions & 3 deletions etc/samples/mbeans-on-as7-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<plugin>
<groupId>org.rhq.maven.plugins</groupId>
<artifactId>rhq-agent-plugin-plugin</artifactId>
<version>0.6</version>
<version>1.0-SNAPSHOT</version>
<extensions>true</extensions>
<configuration>
<archive>
Expand All @@ -65,13 +65,16 @@
<Build-Time>${buildTime}</Build-Time>
</manifestEntries>
</archive>
<rhqVersion>${rhq.version}</rhqVersion>
<host>127.0.0.1</host>
<port>7080</port>
<username>rhqadmin</username>
<password>rhqadmin</password>
<startScan>true</startScan>
<startScan>false</startScan>
<updatePluginsOnAllAgents>true</updatePluginsOnAllAgents>
<failOnError>false</failOnError>
<rhqVersion>${rhq.version}</rhqVersion>
<waitForPluginsUpdateOnAllAgents>false</waitForPluginsUpdateOnAllAgents>
<maxWaitForPluginsUpdateOnAllAgents>300</maxWaitForPluginsUpdateOnAllAgents>
</configuration>
<executions>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@ public int getId() {
resp.setUpgradedResourceDescription(resource.getDescription());
}

if (request.getNewVersion() != null) {
resource.setVersion(request.getNewVersion());
resp.setUpgradedResourceVersion(resource.getVersion());
}

if (request.getNewName() != null) {
resource.setName(request.getNewName());
resp.setUpgradedResourceName(resource.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@
import org.rhq.core.domain.discovery.MergeResourceResponse;
import org.rhq.core.domain.discovery.PlatformSyncInfo;
import org.rhq.core.domain.discovery.ResourceSyncInfo;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceError;
import org.rhq.core.domain.resource.ResourceType;

/**
Expand Down Expand Up @@ -129,13 +127,13 @@ void updatePluginConfiguration(int resourceId, Configuration newPluginConfigurat
AvailabilityReport executeAvailabilityScanImmediately(boolean changedOnlyReport);

/**
* Returns the current availability for the specified resource.
* Return an availability report for the specified root resource and its descendants.
* <p/>
* This call returns an availability report (rather just a simple availability of a single resource)
* because it also scans for the changes in availability in the child resources. Notice that the returned report may
* contain no results if {@code changesOnly} is set to true. If it is false, the report will always contain
* the availability of the supplied resource but can also additionally contain the availabilities of some of its
* child resources, if they were eligible for availability collection at the time of calling this method.
* The returned report may contain no results if {@code changesOnly} is set to true. Otherwise it will return
* the availability of the root resource and its descendants. Note, a live availability check (i.e. a call
* to getAvailability()) is always performed on the root resource. Only descendants normally eligible for
* availability collection at the time of this call will also have live availability. Others will report their
* most recently reported availability.
* <p/>
* Also note that the availability types of the resources in the report may have any of the following values from
* the {@link AvailabilityType} enum - it may happen that the availability of the resource is
Expand All @@ -146,13 +144,10 @@ void updatePluginConfiguration(int resourceId, Configuration newPluginConfigurat
* correctly handle the report within the server.
*
* @param resource the resource to return the availability of.
* @param changesOnly if true, only changes in availability will be reported, if false the report will contain
* the availabilities of all resources eligible for collection at the time of the call regardless
* of whether their availability changed or not.
* @return an availability report containing at least the availability of the supplied resource + possibly avails
* of some of the child resources that were eligible for avail collection at the time. The rest of the
* children are scheduled for availability collection in the next collector run (which happens
* approximately 30 seconds after this call).
* @param changesOnly if true, only changes in availability will be reported. if false the report will contain
* the availabilities of the root resource and all descendants, whether their availability
* changed or not.
* @return an availability report populated as described in the above options.
*/
@NotNull
AvailabilityReport getCurrentAvailability(Resource resource, boolean changesOnly);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

/**
* Represents a request to upgrade a resource.
*
*
* @author Lukas Krejci
*/
public class ResourceUpgradeRequest extends ResourceUpgradeReport {
Expand Down Expand Up @@ -119,13 +119,16 @@ public void fillInFromReport(ResourceUpgradeReport report) {
setNewName(report.getNewName());
setNewResourceKey(report.getNewResourceKey());
setNewPluginConfiguration(report.getNewPluginConfiguration());
setNewVersion(report.getNewVersion());
setForceGenericPropertyUpgrade(report.isForceGenericPropertyUpgrade());
}

public void fillInFromResource(Resource resource) {
setNewDescription(resource.getDescription());
setNewName(resource.getName());
setNewResourceKey(resource.getResourceKey());
setNewPluginConfiguration(resource.getPluginConfiguration());
setNewVersion(resource.getVersion());
}

public void updateResource(Resource resource) {
Expand All @@ -144,6 +147,10 @@ public void updateResource(Resource resource) {
if (getNewPluginConfiguration() != null) {
resource.setPluginConfiguration(getNewPluginConfiguration());
}

if (getNewVersion() != null) {
resource.setVersion(getNewVersion());
}
}

/**
Expand All @@ -154,6 +161,8 @@ public void clearUpgradeData() {
setNewName(null);
setNewResourceKey(null);
setNewPluginConfiguration(null);
setNewVersion(null);
setForceGenericPropertyUpgrade(false);
}

@Override
Expand Down Expand Up @@ -183,9 +192,8 @@ public boolean equals(Object other) {

@Override
public String toString() {
return "ResourceUpgradeRequest[resourceId = '" + resourceId + "', newResourceKey = '" + getNewResourceKey()
+ "', newName = '" + getNewName() + "', newDescription = '" + getNewDescription()
+ "', hasNewPluginConfig = '" + (null != getNewPluginConfiguration()) + "', upgradeErrorMessage = '"
+ upgradeErrorMessage + "', upgradeErrorStackTrace = '" + upgradeErrorStackTrace + "']";
return "ResourceUpgradeRequest [resourceId=" + resourceId + ", upgradeErrorMessage=" + upgradeErrorMessage
+ ", upgradeErrorStackTrace=" + upgradeErrorStackTrace + ", timestamp=" + timestamp + ", toString()="
+ super.toString() + "]";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@
* Represents a response to a resource upgrade request.
* The upgraded* properties contain the values of the corresponding resource properties
* as they were stored on the server.
*
*
* @author Lukas Krejci
*/
public class ResourceUpgradeResponse implements Serializable {

private static final long serialVersionUID = 2L;
private static final long serialVersionUID = 3L;

private int resourceId;

private String upgradedResourceName;
private String upgradedResourceKey;
private String upgradedResourceDescription;
private String upgradedResourceVersion;
private Configuration upgradedResourcePluginConfiguration;

public ResourceUpgradeResponse() {

}

public int getResourceId() {
Expand Down Expand Up @@ -85,6 +85,14 @@ public void setUpgradedResourceDescription(String upgradedResourceDescription) {
this.upgradedResourceDescription = upgradedResourceDescription;
}

public String getUpgradedResourceVersion() {
return upgradedResourceVersion;
}

public void setUpgradedResourceVersion(String upgradedResourceVersion) {
this.upgradedResourceVersion = upgradedResourceVersion;
}

public void setUpgradedResourcePluginConfiguration(Configuration upgradedResourcePluginConfiguration) {
this.upgradedResourcePluginConfiguration = upgradedResourcePluginConfiguration;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import org.rhq.core.communications.command.annotation.Asynchronous;
import org.rhq.core.communications.command.annotation.LimitedConcurrency;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.Property;

/**
* Interface that allows an agent to provide information about a resource's configuration.
Expand Down Expand Up @@ -71,4 +69,18 @@ public interface ConfigurationServerService {
@LimitedConcurrency(CONCURRENCY_LIMIT_CONFIG_UPDATE)
void persistUpdatedResourceConfiguration(int resourceId, Configuration resourceConfiguration);

/**
* This is for when the agent needs to notify the server that a new Plugin configuration has been
* discovered on the agent side. This happens when resource discovery discovers a new version of a resource.
* The properties set by discovery are merged into the existing config, and need to be updated
* server-side.
*
* @param resourceId the resourceId to update
* @param resourceConfiguration the newly detected configuration
*
* @return The persisted plugin configuration
*/
@LimitedConcurrency(CONCURRENCY_LIMIT_CONFIG_UPDATE)
Configuration persistUpdatedPluginConfiguration(int resourceId, Configuration pluginConfiguration);

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class AlertCriteria extends Criteria {
private List<AlertPriority> filterPriorities; // requires overrides
private String filterResourceTypeId; // requires overrides
private String filterResourceTypeName; // requires overrides
private String filterPluginName; // requires overrides
private List<Integer> filterResourceIds; // requires overrides
private List<Integer> filterResourceGroupIds; // requires overrides
private List<Integer> filterAlertDefinitionIds; // requires overrides
Expand Down Expand Up @@ -88,6 +89,7 @@ public AlertCriteria() {
filterOverrides.put("priorities", "alertDefinition.priority IN ( ? )");
filterOverrides.put("resourceTypeId", "alertDefinition.resource.resourceType.id = ?");
filterOverrides.put("resourceTypeName", "alertDefinition.resource.resourceType.name like ?");
filterOverrides.put("pluginName", "alertDefinition.resource.resourceType.plugin like ?");
filterOverrides.put("resourceIds", "alertDefinition.resource.id IN ( ? )");
filterOverrides.put("resourceGroupIds", "alertDefinition.resource.id IN " //
+ "( SELECT res.id " //
Expand Down Expand Up @@ -143,6 +145,10 @@ public void addFilterResourceTypeName(String filterResourceTypeName) {
this.filterResourceTypeName = filterResourceTypeName;
}

public void addFilterPluginName(String filterPluginName) {
this.filterPluginName = filterPluginName;
}

public void addFilterEntityContext(EntityContext filterEntityContext) {
if (filterEntityContext.getType() == EntityContext.Type.Resource) {
addFilterResourceIds(filterEntityContext.getResourceId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class MeasurementDefinitionCriteria extends Criteria {
private String filterDisplayName;
private String filterDescription;
private String filterResourceTypeName; // requires overrides
private String filterPluginName; // requires overrides
private Integer filterResourceTypeId; // requires overrides
private MeasurementCategory filterCategory;
private MeasurementUnits filterUnits;
Expand All @@ -69,6 +70,7 @@ public class MeasurementDefinitionCriteria extends Criteria {

public MeasurementDefinitionCriteria() {
filterOverrides.put("resourceTypeName", "resourceType.name like ?");
filterOverrides.put("pluginName", "resourceType.plugin like ?");
filterOverrides.put("resourceTypeId", "resourceType.id = ?");

sortOverrides.put("resourceTypeName", "resourceType.name");
Expand All @@ -95,6 +97,10 @@ public void addFilterResourceTypeName(String filterResourceTypeName) {
this.filterResourceTypeName = filterResourceTypeName;
}

public void addFilterPluginName(String filterPluginName) {
this.filterPluginName = filterPluginName;
}

public void addFilterResourceTypeId(Integer filterResourceTypeId) {
this.filterResourceTypeId = filterResourceTypeId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import org.rhq.core.domain.configuration.Configuration;

/**
* Represents the changes that should be applied to the existing resource
* in order to upgrade it to conform to the new requirements set by the
* Represents the changes that should be applied to the existing resource
* in order to upgrade it to conform to the new requirements set by the
* changed resource component.
* </p>
* Null values of the properties mean no change, non-null values represent
Expand All @@ -38,30 +38,31 @@
* Configuration updates are limited to only changing values for existing
* properties. The Configuration must still reflect the types configuration
* definition. Also, updates must be judicious as config values can also
* be updated by users.
*
* be updated by users.
*
* @author Lukas Krejci
*/
public class ResourceUpgradeReport implements Serializable {

private static final long serialVersionUID = 2L;
private static final long serialVersionUID = 3L;

private String newResourceKey;
private String newName;

// version changes are handled differently.
// private String newVersion;

// version changes are typically handled differently, but in certain cases may be done here.
private String newVersion;
private String newDescription;
// Plugin configuration changes must still conform to the configuration definition.
private Configuration newPluginConfiguration;

// Is resource config update useful? Wouldn't resource config change discovery handle this?
// private Configuration newResourceConfiguration;

private String newDescription;
// In some cases assume the plugin knows best, and let it force upgrade of what we call "generic" resource
// properties (name, description). If set to true by the plugin code the server will obey,
// regardless of the value of SystemSetting.ALLOW_RESOURCE_GENERIC_PROPERTIES_UPGRADE.
private boolean forceGenericPropertyUpgrade = false;

public ResourceUpgradeReport() {

}

public String getNewResourceKey() {
Expand All @@ -80,13 +81,14 @@ public void setNewName(String newName) {
this.newName = newName;
}

// public String getNewVersion() {
// return newVersion;
// }
//
// public void setNewVersion(String newVersion) {
// this.newVersion = newVersion;
// }
public String getNewVersion() {
return newVersion;
}

public void setNewVersion(String newVersion) {
this.newVersion = newVersion;
}

//
// public Configuration getNewResourceConfiguration() {
// return newResourceConfiguration;
Expand All @@ -109,18 +111,38 @@ public Configuration getNewPluginConfiguration() {
}

/**
* See class javadoc for restrictions.
* See class javadoc for restrictions.
*/
public void setNewPluginConfiguration(Configuration newPluginConfiguration) {
this.newPluginConfiguration = newPluginConfiguration;
}

public boolean isForceGenericPropertyUpgrade() {
return forceGenericPropertyUpgrade;
}

/**
* In some cases assume the plugin knows best. Set true (with care) to force upgrade of what we call "generic"
* resource properties (name, description). If set to true by the plugin code the server will obey,
* regardless of the value of SystemSetting.ALLOW_RESOURCE_GENERIC_PROPERTIES_UPGRADE, which is false by default
* in order to protect hand-edited resource names.
*
* @param forceGenericPropertyUpgrade
*/
public void setForceGenericPropertyUpgrade(boolean forceGenericPropertyUpgrade) {
this.forceGenericPropertyUpgrade = forceGenericPropertyUpgrade;
}

public boolean hasSomethingToUpgrade() {
return newResourceKey != null || newName != null || newDescription != null || newPluginConfiguration != null;
return newResourceKey != null || newName != null || newVersion != null || newDescription != null
|| newPluginConfiguration != null;
}

@Override
public String toString() {
return "ResourceUpgradeReport[newResourceKey = '" + newResourceKey + "', newName = '" + newName
+ "', newDescription = '" + newDescription + "']";
return "ResourceUpgradeReport [newResourceKey=" + newResourceKey + ", newName=" + newName + ", newVersion="
+ newVersion + ", newDescription=" + newDescription + ", newPluginConfiguration=" + newPluginConfiguration
+ ", forceGenericPropertyUpgrade=" + forceGenericPropertyUpgrade + "]";
}

}
Loading

0 comments on commit 4d3d64c

Please sign in to comment.