[rhq] Branch 'feature/bundle-group' - modules/enterprise
by mazz
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java | 176 +++++++---
1 file changed, 140 insertions(+), 36 deletions(-)
New commits:
commit a9c76478054bb558012e2706a6d64435f9588d7e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jul 26 15:45:05 2013 -0400
add some javadoc and new apis for bundle groups
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java
index 0ffdc1a..8b4dae6 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java
@@ -72,7 +72,12 @@ public interface BundleManagerRemote {
/**
* Adds a BundleFile to the BundleVersion and implicitly creates the backing PackageVersion. If the PackageVersion
* already exists use {@link #addBundleFileViaPackageVersion(Subject, int, String, int)}
- *
+ * </p>
+ * Required Permissions: Either:
+ * - Global.CREATE_BUNDLES and Global.VIEW_BUNDLES
+ * - Global.CREATE_BUNDLES and BundleGroup.VIEW_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ * - BundleGroup.CREATE_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ *
* @param subject user that must have proper permissions
* @param bundleVersionId id of the BundleVersion incorporating this BundleFile
* @param name name of the BundleFile (and the resulting Package)
@@ -89,7 +94,12 @@ public interface BundleManagerRemote {
* A convenience method taking a byte array as opposed to a stream for the file bits.
* WARNING: obviously, this requires the entire bundle file to have been loaded fully in memory.
* For very large files, this could cause OutOfMemoryErrors.
- *
+ * </p>
+ * Required Permissions: Either:
+ * - Global.CREATE_BUNDLES and Global.VIEW_BUNDLES
+ * - Global.CREATE_BUNDLES and BundleGroup.VIEW_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ * - BundleGroup.CREATE_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ *
* @see {@link #addBundleFile(Subject, int, String, String, Architecture, InputStream)}
*/
BundleFile addBundleFileViaByteArray(Subject subject, int bundleVersionId, String name, String version,
@@ -97,7 +107,12 @@ public interface BundleManagerRemote {
/**
* A convenience method taking a URL String whose content will be streamed to the server and used for the file bits.
- *
+ * </p>
+ * Required Permissions: Either:
+ * - Global.CREATE_BUNDLES and Global.VIEW_BUNDLES
+ * - Global.CREATE_BUNDLES and BundleGroup.VIEW_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ * - BundleGroup.CREATE_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ *
* @see #addBundleFile(Subject, int, String, String, Architecture, InputStream)
*/
BundleFile addBundleFileViaURL(Subject subject, int bundleVersionId, String name, String version,
@@ -106,6 +121,11 @@ public interface BundleManagerRemote {
/**
* A variant of {@link #addBundleFileViaURL(Subject, int, String, String, Architecture, String)} supporting the
* HTTP basic authentication.
+ * </p>
+ * Required Permissions: Either:
+ * - Global.CREATE_BUNDLES and Global.VIEW_BUNDLES
+ * - Global.CREATE_BUNDLES and BundleGroup.VIEW_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ * - BundleGroup.CREATE_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
*
* @see #addBundleFileViaURL(Subject, int, String, String, Architecture, String)
*/
@@ -114,19 +134,40 @@ public interface BundleManagerRemote {
/**
* A convenience method taking an existing PackageVersion as opposed to a stream for the file bits.
- *
+ * </p>
+ * Required Permissions: Either:
+ * - Global.CREATE_BUNDLES and Global.VIEW_BUNDLES
+ * - Global.CREATE_BUNDLES and BundleGroup.VIEW_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ * - BundleGroup.CREATE_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ *
* @see {@link #addBundleFile(Subject, int, String, String, Architecture, InputStream)}
*/
BundleFile addBundleFileViaPackageVersion(Subject subject, int bundleVersionId, String name, int packageVersionId)
throws Exception;
- //void assignBundlesToBundleGroup
-
+ /**
+ * Assign the specified bundles to the specified bundle group.
+ * </p>
+ * Requires VIEW permission for the relevant bundle and either:
+ * - Global.CREATE_BUNDLE
+ * - BundleGroup.CREATE_BUNDLES_IN_GROUP or BundleGroup.ASSIGN_BUNDLES_TO_GROUP for the relevant bundle group
+ *
+ * @param subject
+ * @param bundleGroupId
+ * @param bundleIds
+ */
+ void assignBundlesToBundleGroup(Subject subject, int bundleGroupId, int[] bundleIds);
+
/**
* Create a new bundle deployment. Note that bundle deployment names are generated by this
* call. This provides useful, uniform naming for display. An optional, custom description
* can be added. This call defines a deployment. The defined deployment can then be
* scheduled in a separate call.
+ * </p>
+ * Required Permissions: Either:
+ * - Global.DEPLOY_BUNDLES and a view of the relevant bundle and a view of the relevant resource group (may involve multiple roles)
+ * - Resource.DEPLOY_BUNDLES_TO_GROUP and a view of the relevant bundle and a view of the relevant resource group (may involve multiple roles)
+ *
* @param subject user that must have proper permissions
* @param bundleVersionId the BundleVersion being deployed by this deployment
* @param bundleDestinationId the BundleDestination for the deployment
@@ -141,7 +182,11 @@ public interface BundleManagerRemote {
/**
* Creates a bundle destination that describes a target for the bundle deployments.
- *
+ * </p>
+ * Required Permissions: Either:
+ * - Global.DEPLOY_BUNDLES and a view of the relevant bundle and a view of the relevant resource group (may involve multiple roles)
+ * - Resource.DEPLOY_BUNDLES_TO_GROUP and a view of the relevant bundle and a view of the relevant resource group (may involve multiple roles)
+ *
* @param subject user must have MANAGE_INVENTORY permission
* @param bundleId the Bundle to be deployed to this Destination
* @param name a name for this destination. not null or empty
@@ -161,7 +206,8 @@ public interface BundleManagerRemote {
/**
* Create a new bundle group.
* <p/>
- * Requires Global.MANAGE_BUNDLE_GROUP permission.
+ * Require Permissions:
+ * - Global.MANAGE_BUNDLE_GROUPS
*
* @param subject user that must have proper permissions
* @param name the unique bundle group name
@@ -176,7 +222,12 @@ public interface BundleManagerRemote {
* version, version name and version description. If this is the initial version for the named
* bundle the bundle will be implicitly created. The bundle type is discovered by the bundle server
* plugin that can parse the recipe.
- *
+ * </p>
+ * Required Permissions: Either:
+ * - Global.CREATE_BUNDLES and Global.VIEW_BUNDLES
+ * - Global.CREATE_BUNDLES and BundleGroup.VIEW_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ * - BundleGroup.CREATE_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ *
* @param subject user that must have proper permissions
* @param recipe the recipe that defines the bundle version to be created
* @return the persisted BundleVersion with alot of the internal relationships filled in to help the caller
@@ -190,7 +241,12 @@ public interface BundleManagerRemote {
* with the bundle version. The recipe specifies the bundle name, version, version name and version description.
* If this is the initial version for the named bundle the bundle will be implicitly created. The bundle type
* is discovered by inspecting the distribution file.
- *
+ * </p>
+ * Required Permissions: Either:
+ * - Global.CREATE_BUNDLES and Global.VIEW_BUNDLES
+ * - Global.CREATE_BUNDLES and BundleGroup.VIEW_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ * - BundleGroup.CREATE_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ *
* @param subject user that must have proper permissions
* @param distributionFile a local Bundle Distribution file. It must be read accessible by the RHQ server process.
* @return the persisted BundleVersion with alot of the internal relationships filled in to help the caller
@@ -204,6 +260,11 @@ public interface BundleManagerRemote {
* bytes of the file as opposed to the file itself.
* WARNING: obviously, this requires the entire distribution file to have been loaded fully in memory.
* For very large distribution files, this could cause OutOfMemoryErrors.
+ * </p>
+ * Required Permissions: Either:
+ * - Global.CREATE_BUNDLES and Global.VIEW_BUNDLES
+ * - Global.CREATE_BUNDLES and BundleGroup.VIEW_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ * - BundleGroup.CREATE_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
*
* @param subject user that must have proper permissions
* @param fileBytes the file bits that make up the entire bundle distribution file
@@ -220,7 +281,12 @@ public interface BundleManagerRemote {
* is discovered by inspecting the distribution file.
* <br/></br>
* Note, if the file is local it is more efficient to use {@link #createBundleVersionViaFile(Subject,File)}.
- *
+ * </p>
+ * Required Permissions: Either:
+ * - Global.CREATE_BUNDLES and Global.VIEW_BUNDLES
+ * - Global.CREATE_BUNDLES and BundleGroup.VIEW_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ * - BundleGroup.CREATE_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ *
* @param subject user that must have proper permissions
* @param distributionFileUrl a URL String to the Bundle Distribution file. It must be live, resolvable and read accessible
* by the RHQ server process.
@@ -233,6 +299,11 @@ public interface BundleManagerRemote {
/**
* A version of the {@link #createBundleVersionViaURL(org.rhq.core.domain.auth.Subject, String)} that accepts a
* username and password for basic authentication on the HTTP URLs.
+ * </p>
+ * Required Permissions: Either:
+ * - Global.CREATE_BUNDLES and Global.VIEW_BUNDLES
+ * - Global.CREATE_BUNDLES and BundleGroup.VIEW_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ * - BundleGroup.CREATE_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
*
* @see #createBundleVersionViaURL(org.rhq.core.domain.auth.Subject, String)
*/
@@ -243,7 +314,13 @@ public interface BundleManagerRemote {
* Remove everything associated with the Bundles with the exception of files laid down by related deployments.
* Deployed files are left as is on the deployment platforms but the bundle mechanism will no longer track
* the deployment of all bundles that have been deleted.
- *
+ * The bundles that are deleted will be removed from all bundle groups that it was a member of.
+ * </p>
+ * Required Permissions: Either:
+ * - Global.DELETE_BUNDLES and Global.VIEW_BUNDLES
+ * - Global.DELETE_BUNDLES and BundleGroup.VIEW_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ * - BundleGroup.DELETE_BUNDLES_FROM_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ *
* @param subject user that must have proper permissions
* @param bundleIds IDs of all bundles to be deleted
* @throws Exception if any part of the removal fails.
@@ -254,7 +331,13 @@ public interface BundleManagerRemote {
* Remove everything associated with the Bundle with the exception of files laid down by related deployments.
* Deployed files are left as is on the deployment platforms but the bundle mechanism will no longer track
* the deployment.
- *
+ * The bundles that are deleted will be removed from all bundle groups that it was a member of.
+ * </p>
+ * Required Permissions: Either:
+ * - Global.DELETE_BUNDLES and Global.VIEW_BUNDLES
+ * - Global.DELETE_BUNDLES and BundleGroup.VIEW_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ * - BundleGroup.DELETE_BUNDLES_FROM_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ *
* @param subject user that must have proper permissions
* @param bundleId the id of the bundle to remove
* @throws Exception if any part of the removal fails.
@@ -264,19 +347,26 @@ public interface BundleManagerRemote {
/**
* Delete a bundle group. Any currently assigned bundles will be removed but are not deleted.
* <p/>
- * Requires Global.MANAGE_BUNDLE_GROUP permission.
+ * Required Permissions:
+ * - Global.MANAGE_BUNDLE_GROUPS
*
* @param subject user that must have proper permissions
- * @param id the bundle group id
+ * @param ids the bundle group id
* @throws Exception
*/
- void deleteBundleGroups(Subject subject, int... id) throws Exception;
+ void deleteBundleGroups(Subject subject, int[] ids) throws Exception;
/**
* Remove everything associated with the BundleVersion with the exception of files laid down by related deployments.
* Deployed files are left as is on the deployment platforms but the bundle mechanism will no longer track
* the deployment.
- *
+ * The deleted bundle version will no longer exist in any bundle group.
+ * </p>
+ * Required Permissions: Either:
+ * - Global.DELETE_BUNDLES and Global.VIEW_BUNDLES
+ * - Global.DELETE_BUNDLES and BundleGroup.VIEW_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ * - BundleGroup.DELETE_BUNDLES_FROM_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ *
* @param subject user that must have proper permissions
* @param bundleVersionId the id of the bundle version to remove
* @param deleteBundleIfEmpty if <code>true</code> and if this method deletes the last bundle version for its
@@ -310,7 +400,13 @@ public interface BundleManagerRemote {
/**
* Determine the files required for a BundleVersion and return all of the filenames or optionally, just those
* that lack BundleFiles for the BundleVersion. The recipe may be parsed as part of this call.
- *
+ * This is needed as part of the bundle creation workflow, hence why creation permissions are needed.
+ * </p>
+ * Required Permissions: Either:
+ * - Global.CREATE_BUNDLES and Global.VIEW_BUNDLES
+ * - Global.CREATE_BUNDLES and BundleGroup.VIEW_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ * - BundleGroup.CREATE_BUNDLES_IN_GROUP for bundle group BG and the relevant bundle is assigned to BG
+ *
* @param subject user that must have proper permissions
* @param bundleVersionId the BundleVersion being queried
* @param withoutBundleFileOnly if true omit any filenames that already have a corresponding BundleFile for
@@ -322,23 +418,11 @@ public interface BundleManagerRemote {
throws Exception;
/**
- * Similar to {@link #getBundleVersionFilenames(Subject, int, boolean)}, this will determine the files required for a BundleVersion and return
- * all of the filenames, with the values of the map being true if they already exist or false if they lack BundleFile representation
- * in the BundleVersion.
- *
- * @param subject user that must have proper permissions
- * @param bundleVersionId the BundleVersion being queried
- * @return map keyed on filenames whose value indicates if a bundle file exists for the file or not
- * @throws Exception
- */
- /* comment back in when someone writes an adapter to support Map un/marshalling
- Map<String, Boolean> getAllBundleVersionFilenames(
- Subject subject,
- int bundleVersionId) throws Exception;
- */
-
- /**
* Purges the destination's live deployment content from the remote platforms.
+ * </p>
+ * Required Permissions: Either:
+ * - Global.DEPLOY_BUNDLES and a view of the relevant bundle and a view of the relevant resource group (may involve multiple roles)
+ * - Resource.DEPLOY_BUNDLES_TO_GROUP and a view of the relevant bundle and a view of the relevant resource group (may involve multiple roles)
*
* @param subject user that must have proper permissions
* @param bundleDestinationId the ID of the destination that is to be purged of bundle content
@@ -351,7 +435,11 @@ public interface BundleManagerRemote {
* complete. The returned BundleDeployment can be used to track the history of the individual deployments.
* <br/><br/>
* TODO: Add the scheduling capability, currently it's Immediate.
- * <br/>
+ * </p>
+ * Required Permissions: Either:
+ * - Global.DEPLOY_BUNDLES and a view of the relevant bundle and a view of the relevant resource group (may involve multiple roles)
+ * - Resource.DEPLOY_BUNDLES_TO_GROUP and a view of the relevant bundle and a view of the relevant resource group (may involve multiple roles)
+ *
* @param subject user that must have proper permissions
* @param bundleDeploymentId the BundleDeployment being used to guide the deployments
* @param isCleanDeployment if true perform a wipe of the deploy directory prior to the deployment. If false
@@ -371,7 +459,11 @@ public interface BundleManagerRemote {
* call. This provides useful, uniform naming for display. An optional, custom description can be added.
* <br/><br/>
* TODO: Add the scheduling capability, currently it's Immediate.
- * <br/>
+ * </p>
+ * Required Permissions: Either:
+ * - Global.DEPLOY_BUNDLES and a view of the relevant bundle and a view of the relevant resource group (may involve multiple roles)
+ * - Resource.DEPLOY_BUNDLES_TO_GROUP and a view of the relevant bundle and a view of the relevant resource group (may involve multiple roles)
+ *
* @param subject user that must have proper permissions
* @param deploymentDescription an optional longer description describing this deployment. If null defaults
* to the description of the previous deployment.
@@ -383,4 +475,16 @@ public interface BundleManagerRemote {
BundleDeployment scheduleRevertBundleDeployment(Subject subject, int bundleDestinationId,
String deploymentDescription, boolean isCleanDeployment) throws Exception;
+ /**
+ * Unassign the specified bundles from the specified bundle group.
+ * </p>
+ * Requires VIEW permission for the relevant bundles and either:
+ * - Global.DELETE_BUNDLE
+ * - BundleGroup.DELETE_BUNDLES_FROM_GROUP or BundleGroup.UNASSIGN_BUNDLES_FROM_GROUP for the relevant bundle group
+ *
+ * @param subject
+ * @param bundleGroupId
+ * @param bundleIds
+ */
+ void unassignBundlesFromBundleGroup(Subject subject, int bundleGroupId, int[] bundleIds);
}
10 years, 9 months
[rhq] Branch 'feature/bundle-group' - modules/core
by mazz
modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 4945c1c2722ee77294860be6d99e15d5612f1220
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Jul 26 11:20:54 2013 -0400
trivial change - first commit from intellij :}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java
index 88fb948..4ca733c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java
@@ -193,7 +193,7 @@ public enum Permission {
/**
* Implied - Can view bundles in the bundle group
*/
- VIEW_BUNDLES_IN_GROUP(Target.BUNDLE) // 25
+ VIEW_BUNDLES_IN_GROUP(Target.BUNDLE) // 27
;
10 years, 9 months
[rhq] Branch 'feature/bundle-group' - modules/enterprise
by Jay Shaughnessy
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java | 112 +++++++---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java | 26 ++
2 files changed, 105 insertions(+), 33 deletions(-)
New commits:
commit 57a64d60c88eb9b16c0a4048cd732057acbea65e
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Jul 26 10:16:34 2013 -0400
Start of remote API design/impl for BundleGroups
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
index dbecb26..ac05e20 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
@@ -257,6 +257,31 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
}
@Override
+ @RequiredPermission(Permission.MANAGE_BUNDLE_GROUPS)
+ public BundleGroup createBundleGroup(Subject subject, String name, String description) throws Exception {
+ if (null == name || "".equals(name.trim())) {
+ throw new IllegalArgumentException("Invalid bundleGroupName: " + name);
+ }
+
+ BundleGroupCriteria c = new BundleGroupCriteria();
+ c.addFilterName(name);
+ c.setStrict(true);
+ if (!bundleManager.findBundleGroupsByCriteria(subject, c).isEmpty()) {
+ throw new IllegalArgumentException("Invalid bundleGroupName, bundle group already exists with name: "
+ + name);
+ }
+
+ // create and add the required Repo. the Repo is a detached object which helps in its eventual
+ // removal.
+ BundleGroup bg = new BundleGroup(name);
+ bg.setDescription(description);
+
+ entityManager.persist(bg);
+
+ return bg;
+ }
+
+ @Override
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleDeployment createBundleDeploymentInNewTrans(Subject subject, int bundleVersionId,
@@ -502,8 +527,8 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
RecipeParseResults results;
try {
- results = BundleManagerHelper.getPluginContainer().getBundleServerPluginManager().parseRecipe(
- bundleType.getName(), recipe);
+ results = BundleManagerHelper.getPluginContainer().getBundleServerPluginManager()
+ .parseRecipe(bundleType.getName(), recipe);
} catch (Exception e) {
// ensure that we throw a runtime exception to force a rollback
throw new RuntimeException("Failed to parse recipe", e);
@@ -610,8 +635,8 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
try {
file = downloadFile(distributionFileUrl, username, password);
- log.debug("Copied [" + file.length() + "] bytes from [" + distributionFileUrl + "] into ["
- + file.getPath() + "]");
+ log.debug("Copied [" + file.length() + "] bytes from [" + distributionFileUrl + "] into [" + file.getPath()
+ + "]");
return createBundleVersionViaFile(subject, file);
} finally {
@@ -631,8 +656,7 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
}
}
- private File downloadFileFromHttp(URL url, String username, String password) throws URISyntaxException,
- IOException {
+ private File downloadFileFromHttp(URL url, String username, String password) throws URISyntaxException, IOException {
HttpParams params = new BasicHttpParams();
HttpClientParams.setRedirecting(params, true);
@@ -647,9 +671,8 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
HttpResponse response = httpClient.execute(get);
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
- throw new IllegalArgumentException(
- "Failed to download the file from the URL [" + url + "]. The server responded: " +
- response.getStatusLine().toString());
+ throw new IllegalArgumentException("Failed to download the file from the URL [" + url
+ + "]. The server responded: " + response.getStatusLine().toString());
}
InputStream contents = response.getEntity().getContent();
@@ -842,8 +865,8 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
// Create the mapping between the Bundle's Repo and the BundleFile's PackageVersion
Repo repo = bundle.getRepo();
// add the packageVersion as overlord, this allows users without MANAGE_INVENTORY permission to add bundle files
- repoManager.addPackageVersionsToRepo(subjectManager.getOverlord(), repo.getId(), new int[] { packageVersion
- .getId() });
+ repoManager.addPackageVersionsToRepo(subjectManager.getOverlord(), repo.getId(),
+ new int[] { packageVersion.getId() });
// Classify the Package with the Bundle name in order to distinguish it from the same package name for
// a different bundle.
@@ -904,7 +927,6 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
}
}
-
@Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public BundleFile addBundleFileViaPackageVersion(Subject subject, int bundleVersionId, String name,
@@ -1126,8 +1148,8 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
BundleDeployment revertDeployment = bundleManager.createBundleDeploymentInNewTrans(subject, prevDeployment
.getBundleVersion().getId(), bundleDestinationId, name, desc, config);
- return scheduleBundleDeploymentImpl(subject, revertDeployment.getId(), isCleanDeployment, true, prevDeployment
- .getReplacedBundleDeploymentId());
+ return scheduleBundleDeploymentImpl(subject, revertDeployment.getId(), isCleanDeployment, true,
+ prevDeployment.getReplacedBundleDeploymentId());
}
// revertedDeploymentReplacedDeployment is only meaningful if isRevert is true
@@ -1201,8 +1223,8 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
// The BundleResourceDeployment record must exist in the db before the agent request because the agent may try
// to add History to it during immediate deployments. So, create and persist it (requires a new trans).
- BundleResourceDeployment resourceDeployment = bundleManager.createBundleResourceDeployment(subject, deployment
- .getId(), bundleTargetResourceId);
+ BundleResourceDeployment resourceDeployment = bundleManager.createBundleResourceDeployment(subject,
+ deployment.getId(), bundleTargetResourceId);
if (null != bundleTarget.getResourceType().getResourceTypeBundleConfiguration()) {
@@ -1225,8 +1247,8 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
bundleManager.setBundleResourceDeploymentStatus(subject, resourceDeployment.getId(),
BundleDeploymentStatus.FAILURE);
history = new BundleResourceDeploymentHistory(subject.getName(), AUDIT_ACTION_DEPLOYMENT,
- deployment.getName(), null, BundleResourceDeploymentHistory.Status.FAILURE, response
- .getErrorMessage(), null);
+ deployment.getName(), null, BundleResourceDeploymentHistory.Status.FAILURE,
+ response.getErrorMessage(), null);
bundleManager.addBundleResourceDeploymentHistory(subject, resourceDeployment.getId(), history);
}
} catch (Throwable t) {
@@ -1494,9 +1516,9 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
*/
@Override
public PageList<BundleDeployment> findBundleDeploymentsByCriteriaWithDestinationFilter(Subject subject,
- BundleDeploymentCriteria criteria) {
+ BundleDeploymentCriteria criteria) {
- PageList<BundleDeployment> deployments = findBundleDeploymentsByCriteria(subject,criteria);
+ PageList<BundleDeployment> deployments = findBundleDeploymentsByCriteria(subject, criteria);
if (authorizationManager.isInventoryManager(subject))
return deployments;
@@ -1507,8 +1529,8 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
int bundleId = deployment.getBundleVersion().getBundle().getId();
BundleDestinationCriteria destinationCriteria = new BundleDestinationCriteria();
destinationCriteria.addFilterBundleId(bundleId);
- List<BundleDestination> destinations = findBundleDestinationsByCriteria(subject,destinationCriteria);
- if (destinationsContains(destinations,deployment.getDestination()))
+ List<BundleDestination> destinations = findBundleDestinationsByCriteria(subject, destinationCriteria);
+ if (destinationsContains(destinations, deployment.getDestination()))
resultingDeployments.add(deployment);
}
return resultingDeployments;
@@ -1520,8 +1542,10 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
// Filter by destinations that are viewable
if (!authorizationManager.isInventoryManager(subject)) {
- generator.setAuthorizationResourceFragment(CriteriaQueryGenerator.AuthorizationTokenType.GROUP,subject.getId());
- } CriteriaQueryRunner<BundleDestination> queryRunner = new CriteriaQueryRunner<BundleDestination>(criteria,
+ generator.setAuthorizationResourceFragment(CriteriaQueryGenerator.AuthorizationTokenType.GROUP,
+ subject.getId());
+ }
+ CriteriaQueryRunner<BundleDestination> queryRunner = new CriteriaQueryRunner<BundleDestination>(criteria,
generator, entityManager);
return queryRunner.execute();
}
@@ -1568,26 +1592,27 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
*/
@Override
public PageList<BundleVersion> findBundleVersionsByCriteriaWithDestinationFilter(Subject subject,
- BundleVersionCriteria criteria) {
+ BundleVersionCriteria criteria) {
- PageList<BundleVersion> versions = findBundleVersionsByCriteria(subject,criteria);
+ PageList<BundleVersion> versions = findBundleVersionsByCriteria(subject, criteria);
if (authorizationManager.isInventoryManager(subject)) {
return versions;
}
// Not inv manager -> restrict visible deployments by visible destinations
- for (BundleVersion version:versions) {
+ for (BundleVersion version : versions) {
Bundle bundle = version.getBundle();
BundleDestinationCriteria destinationCriteria = new BundleDestinationCriteria();
destinationCriteria.addFilterBundleId(bundle.getId());
destinationCriteria.clearPaging();//disable paging as the code assumes all the results will be returned.
- List<BundleDestination> destinations = findBundleDestinationsByCriteria(subject,destinationCriteria);
- List<BundleDeployment> resultingDeployments = new ArrayList<BundleDeployment>(version.getBundleDeployments().size());
+ List<BundleDestination> destinations = findBundleDestinationsByCriteria(subject, destinationCriteria);
+ List<BundleDeployment> resultingDeployments = new ArrayList<BundleDeployment>(version
+ .getBundleDeployments().size());
// We now have visible destinations - go over the resultingDeployments and only include the ones with vis. destinations
for (BundleDeployment deployment : version.getBundleDeployments()) {
- if (destinationsContains(destinations,deployment.getDestination()))
+ if (destinationsContains(destinations, deployment.getDestination()))
resultingDeployments.add(deployment);
}
@@ -1639,18 +1664,18 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
@Override
public PageList<Bundle> findBundlesByCriteriaWithDestinationFilter(Subject subject, BundleCriteria criteria) {
// First get the bundles
- PageList<Bundle> bundles = findBundlesByCriteria(subject,criteria);
+ PageList<Bundle> bundles = findBundlesByCriteria(subject, criteria);
if (authorizationManager.isInventoryManager(subject)) {
return bundles;
}
// Not inv manager -> restrict visible destinations
- PageList<Bundle> result = new PageList<Bundle>(bundles.size(),bundles.getPageControl());
+ PageList<Bundle> result = new PageList<Bundle>(bundles.size(), bundles.getPageControl());
for (Bundle bundle : bundles.getValues()) { // TODO clone the bundle and return the modified clones
BundleDestinationCriteria destinationCriteria = new BundleDestinationCriteria();
destinationCriteria.addFilterBundleId(bundle.getId());
destinationCriteria.clearPaging();//disable paging as the code assumes all the results will be returned.
- List<BundleDestination> destinations = findBundleDestinationsByCriteria(subject,destinationCriteria);
+ List<BundleDestination> destinations = findBundleDestinationsByCriteria(subject, destinationCriteria);
bundle.setDestinations(destinations);
}
@@ -1755,6 +1780,27 @@ public class BundleManagerBean implements BundleManagerLocal, BundleManagerRemot
}
@Override
+ @RequiredPermission(Permission.MANAGE_BUNDLE_GROUPS)
+ public void deleteBundleGroups(Subject subject, int... bundleGroupIds) throws Exception {
+
+ for (int bundleGroupId : bundleGroupIds) {
+ BundleGroup bundleGroup = this.entityManager.find(BundleGroup.class, bundleGroupIds);
+ if (null == bundleGroup) {
+ return;
+ }
+
+ // unassign any bundles assigned to the bundle group
+ for (Bundle b : bundleGroup.getBundles()) {
+ bundleGroup.removeBundle(b);
+ }
+ bundleGroup = entityManager.merge(bundleGroup);
+
+ // now remove the bundle group
+ entityManager.remove(bundleGroup);
+ }
+ }
+
+ @Override
@RequiredPermission(Permission.MANAGE_BUNDLE)
public void deleteBundleVersion(Subject subject, int bundleVersionId, boolean deleteBundleIfEmpty) throws Exception {
BundleVersion bundleVersion = this.entityManager.find(BundleVersion.class, bundleVersionId);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java
index b72d6b5..0ffdc1a 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerRemote.java
@@ -120,6 +120,8 @@ public interface BundleManagerRemote {
BundleFile addBundleFileViaPackageVersion(Subject subject, int bundleVersionId, String name, int packageVersionId)
throws Exception;
+ //void assignBundlesToBundleGroup
+
/**
* Create a new bundle deployment. Note that bundle deployment names are generated by this
* call. This provides useful, uniform naming for display. An optional, custom description
@@ -157,6 +159,19 @@ public interface BundleManagerRemote {
String destBaseDirName, String deployDir, Integer groupId) throws Exception;
/**
+ * Create a new bundle group.
+ * <p/>
+ * Requires Global.MANAGE_BUNDLE_GROUP permission.
+ *
+ * @param subject user that must have proper permissions
+ * @param name the unique bundle group name
+ * @param description an optional description
+ * @return the persisted BundleGroup
+ * @throws Exception
+ */
+ BundleGroup createBundleGroup(Subject subject, String name, String description) throws Exception;
+
+ /**
* Creates a bundle version based on single recipe string. The recipe specifies the bundle name,
* version, version name and version description. If this is the initial version for the named
* bundle the bundle will be implicitly created. The bundle type is discovered by the bundle server
@@ -247,6 +262,17 @@ public interface BundleManagerRemote {
void deleteBundle(Subject subject, int bundleId) throws Exception;
/**
+ * Delete a bundle group. Any currently assigned bundles will be removed but are not deleted.
+ * <p/>
+ * Requires Global.MANAGE_BUNDLE_GROUP permission.
+ *
+ * @param subject user that must have proper permissions
+ * @param id the bundle group id
+ * @throws Exception
+ */
+ void deleteBundleGroups(Subject subject, int... id) throws Exception;
+
+ /**
* Remove everything associated with the BundleVersion with the exception of files laid down by related deployments.
* Deployed files are left as is on the deployment platforms but the bundle mechanism will no longer track
* the deployment.
10 years, 9 months
[rhq] modules/enterprise
by Heiko W. Rupp
modules/enterprise/gui/coregui/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 2e33f605b32204385e9dc7c4ea9f2f3ac2e71850
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Jul 26 14:14:15 2013 +0200
Put the real version in here, as otherwise we have a circular dependency.
diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml
index 353f4d9..a227ed4 100644
--- a/modules/enterprise/gui/coregui/pom.xml
+++ b/modules/enterprise/gui/coregui/pom.xml
@@ -19,7 +19,7 @@
<properties>
<!-- dependency versions -->
- <gwt.version>${gwt.version}</gwt.version>
+ <gwt.version>2.5.0</gwt.version>
<smartgwt.version>3.0</smartgwt.version>
<!-- If this is too much memory to allocate to your gwt:debug process then override this property in
10 years, 9 months
[rhq] 2 commits - modules/enterprise modules/helpers pom.xml
by John Sanda
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBeanTest.java | 6
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/test/MeasurementBaselineManagerTest.java | 6
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java | 1
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClientManagerBean.java | 18 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClusterMonitor.java | 69 ++++
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsDAO.java | 153 ++--------
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java | 5
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/StorageResultSetFuture.java | 76 ++++
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/StorageSession.java | 110 +++++++
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/StorageStateListener.java | 20 +
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/domain/ListPagedResult.java | 6
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/domain/SimplePagedResult.java | 11
modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/CassandraIntegrationTest.java | 35 ++
modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/ClusterMonitorTest.java | 92 ++++++
modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsBaselineCalculatorTest.java | 14
modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsDAOTest.java | 17 -
modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsServerTest.java | 7
modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/TimeoutTest.java | 5
modules/enterprise/server/server-metrics/src/test/resources/log4j.properties | 2
modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/Simulator.java | 5
pom.xml | 2
21 files changed, 497 insertions(+), 163 deletions(-)
New commits:
commit 9fbd3da4446f026dd4095f23345a5acaa0b956c0
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jul 25 22:08:20 2013 -0400
check cluster status using cql driver instead of using jmx
The server had been polling storage cluster nodes with a jmx call to make sure
that at least one node is up for client requests. If no nodes are up, then the
server goes into maintenance mode.
That check is no longer done with a quartz job using jmx. It is now performed
with event notifications we receive from the cql driver. This means that the
server no longer has to care about storage node jmx ports. This has a couple
benefits. First, it reduces the complexity involved with changing the jmx port.
Secondly, since the server no longer is making jmx calls to storage nodes, the
port can be locked down to localhost access.
Any server side code that needs access to the driver's Session should instead
use the new StorageSession class. StorageSession provides the same API, and it
also encapsulates the event handling/propagation logic that is necesary for
monitoring the cluster availability.
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBeanTest.java
index 4cc67c0..9f49143 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/MeasurementDataManagerBeanTest.java
@@ -39,7 +39,6 @@ import java.util.List;
import javax.ejb.EJB;
-import com.datastax.driver.core.Session;
import com.datastax.driver.core.exceptions.NoHostAvailableException;
import org.joda.time.DateTime;
@@ -60,13 +59,14 @@ import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.server.auth.SubjectManagerLocal;
-import org.rhq.enterprise.server.storage.StorageClientManagerBean;
import org.rhq.enterprise.server.drift.DriftServerPluginService;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
+import org.rhq.enterprise.server.storage.StorageClientManagerBean;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.test.TransactionCallback;
import org.rhq.enterprise.server.util.ResourceTreeHelper;
import org.rhq.server.metrics.MetricsDAO;
+import org.rhq.server.metrics.StorageSession;
import org.rhq.server.metrics.domain.AggregateNumericMetric;
import org.rhq.server.metrics.domain.AggregateType;
import org.rhq.server.metrics.domain.MetricsTable;
@@ -360,7 +360,7 @@ public class MeasurementDataManagerBeanTest extends AbstractEJB3Test {
private void purgeMetricsTables() {
try {
- Session session = storageClientManager.getSession();
+ StorageSession session = storageClientManager.getSession();
session.execute("TRUNCATE " + MetricsTable.RAW);
session.execute("TRUNCATE " + MetricsTable.ONE_HOUR);
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/test/MeasurementBaselineManagerTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/test/MeasurementBaselineManagerTest.java
index 49048ee..fdf2b1a 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/test/MeasurementBaselineManagerTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/measurement/test/MeasurementBaselineManagerTest.java
@@ -28,7 +28,6 @@ import java.util.Random;
import javax.inject.Inject;
import javax.persistence.Query;
-import com.datastax.driver.core.Session;
import com.datastax.driver.core.exceptions.NoHostAvailableException;
import org.testng.annotations.Test;
@@ -45,13 +44,14 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageControl;
-import org.rhq.enterprise.server.storage.StorageClientManagerBean;
import org.rhq.enterprise.server.measurement.MeasurementBaselineManagerLocal;
import org.rhq.enterprise.server.measurement.MeasurementOOBManagerLocal;
import org.rhq.enterprise.server.resource.ResourceManagerLocal;
+import org.rhq.enterprise.server.storage.StorageClientManagerBean;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.util.LookupUtil;
import org.rhq.server.metrics.MetricsDAO;
+import org.rhq.server.metrics.StorageSession;
import org.rhq.server.metrics.domain.AggregateNumericMetric;
import org.rhq.server.metrics.domain.AggregateType;
import org.rhq.server.metrics.domain.MetricsTable;
@@ -645,7 +645,7 @@ public class MeasurementBaselineManagerTest extends AbstractEJB3Test {
// Query q = em.createNativeQuery(sql);
// q.executeUpdate();
try {
- Session session = storageClientManager.getSession();
+ StorageSession session = storageClientManager.getSession();
session.execute("DELETE FROM " + MetricsTable.ONE_HOUR.getTableName() + " WHERE schedule_id = " +
schedule.getId());
} catch (NoHostAvailableException e) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java
index 7ce77d8..fa88263 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java
@@ -450,7 +450,6 @@ public class StartupBean implements StartupLocal {
}
storageClientManager.init();
- storageClusterHeartBeatJob.scheduleJob();
}
/**
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClientManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClientManagerBean.java
index 2d48092..ae80e50 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClientManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClientManagerBean.java
@@ -50,6 +50,7 @@ import org.rhq.server.metrics.DateTimeService;
import org.rhq.server.metrics.MetricsConfiguration;
import org.rhq.server.metrics.MetricsDAO;
import org.rhq.server.metrics.MetricsServer;
+import org.rhq.server.metrics.StorageSession;
/**
* @author John Sanda
@@ -70,7 +71,7 @@ public class StorageClientManagerBean {
@EJB
private StorageNodeManagerLocal storageNodeManager;
- private Session session;
+ private StorageSession session;
private MetricsConfiguration metricsConfiguration;
private MetricsDAO metricsDAO;
private MetricsServer metricsServer;
@@ -95,7 +96,12 @@ public class StorageClientManagerBean {
String password = getRequiredStorageProperty(PASSWORD_PROP);
metricsConfiguration = new MetricsConfiguration();
- session = createSession(username, password, storageNodeManager.getStorageNodes());
+
+ Session wrappedSession = createSession(username, password, storageNodeManager.getStorageNodes());
+ session = new StorageSession(wrappedSession);
+
+ session.addStorageStateListener(new StorageClusterMonitor());
+
metricsDAO = new MetricsDAO(session, metricsConfiguration);
Server server = serverManager.getServer();
@@ -121,15 +127,15 @@ public class StorageClientManagerBean {
}
public MetricsDAO getMetricsDAO() {
- return this.metricsDAO;
+ return metricsDAO;
}
public MetricsServer getMetricsServer() {
- return this.metricsServer;
+ return metricsServer;
}
- public Session getSession() {
- return this.session;
+ public StorageSession getSession() {
+ return session;
}
public MetricsConfiguration getMetricsConfiguration() {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClusterMonitor.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClusterMonitor.java
new file mode 100644
index 0000000..ec28888
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/storage/StorageClusterMonitor.java
@@ -0,0 +1,69 @@
+package org.rhq.enterprise.server.storage;
+
+import java.net.InetAddress;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import com.datastax.driver.core.exceptions.NoHostAvailableException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.cloud.Server;
+import org.rhq.enterprise.server.auth.SubjectManagerLocal;
+import org.rhq.enterprise.server.cloud.TopologyManagerLocal;
+import org.rhq.enterprise.server.cloud.instance.ServerManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+import org.rhq.server.metrics.StorageStateListener;
+
+/**
+ * @author John Sanda
+ */
+public class StorageClusterMonitor implements StorageStateListener {
+
+ private Log log = LogFactory.getLog(StorageClusterMonitor.class);
+
+ private AtomicBoolean isClusterDown = new AtomicBoolean(false);
+
+ public boolean isClusterDown() {
+ return isClusterDown.get();
+ }
+
+ @Override
+ public void onStorageNodeUp(InetAddress address) {
+ log.info("Storage node at " + address.getHostAddress() + " is up");
+
+ if (isClusterDown.compareAndSet(true, false)) {
+ log.info("Taking server out of maintenance mode");
+ updateServerMode(Server.OperationMode.NORMAL);
+ }
+ }
+
+ @Override
+ public void onStorageNodeDown(InetAddress address) {
+ log.info("Storage node at " + address.getHostAddress() + " is down");
+ }
+
+ @Override
+ public void onStorageNodeRemoved(InetAddress address) {
+ log.info("Storage node at " + address.getHostAddress() + " has been removed from the cluster");
+ }
+
+ @Override
+ public void onStorageClusterDown(NoHostAvailableException e) {
+ if (isClusterDown.compareAndSet(false, true)) {
+ log.error("The server cannot connect to any storage nodes. The server will now go into maintenance mode.");
+ updateServerMode(Server.OperationMode.MAINTENANCE);
+ }
+ }
+
+ private void updateServerMode(Server.OperationMode mode) {
+ ServerManagerLocal serverManager = LookupUtil.getServerManager();
+ TopologyManagerLocal topologyManager = LookupUtil.getTopologyManager();
+ SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();
+
+ Server server = serverManager.getServer();
+
+ topologyManager.updateServerMode(subjectManager.getOverlord(), new Integer[] {server.getId()},
+ Server.OperationMode.MAINTENANCE);
+ }
+}
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsDAO.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsDAO.java
index 3ea47e8..63c11f1 100644
--- a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsDAO.java
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsDAO.java
@@ -26,20 +26,13 @@
package org.rhq.server.metrics;
-import static com.datastax.driver.core.querybuilder.QueryBuilder.insertInto;
-
-import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import com.datastax.driver.core.BoundStatement;
import com.datastax.driver.core.PreparedStatement;
import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.core.ResultSetFuture;
-import com.datastax.driver.core.Session;
-import com.datastax.driver.core.Statement;
import com.datastax.driver.core.exceptions.NoHostAvailableException;
import org.apache.commons.logging.Log;
@@ -67,7 +60,7 @@ public class MetricsDAO {
private final Log log = LogFactory.getLog(MetricsDAO.class);
- private Session session;
+ private StorageSession storageSession;
private MetricsConfiguration configuration;
@@ -86,8 +79,8 @@ public class MetricsDAO {
private PreparedStatement findTimeSliceForIndex;
private PreparedStatement deleteIndexEntries;
- public MetricsDAO(Session session, MetricsConfiguration configuration) {
- this.session = session;
+ public MetricsDAO(StorageSession session, MetricsConfiguration configuration) {
+ this.storageSession = session;
this.configuration = configuration;
initPreparedStatements();
}
@@ -104,176 +97,118 @@ public class MetricsDAO {
// re-initialized and re-prepared with the new TTLs. None of this would be necessary
// if the TTL value could be a bound value.
- insertRawData = session.prepare(
+ insertRawData = storageSession.prepare(
"INSERT INTO " + MetricsTable.RAW + " (schedule_id, time, value) VALUES (?, ?, ?) USING TTL " +
configuration.getRawTTL());
- rawMetricsQuery = session.prepare("SELECT schedule_id, time, value FROM " + MetricsTable.RAW +
+ rawMetricsQuery = storageSession.prepare("SELECT schedule_id, time, value FROM " + MetricsTable.RAW +
" WHERE schedule_id = ? AND time >= ? AND time < ? ORDER BY time");
- insertOneHourData = session.prepare("INSERT INTO " + MetricsTable.ONE_HOUR + "(schedule_id, time, " +
+ insertOneHourData = storageSession.prepare("INSERT INTO " + MetricsTable.ONE_HOUR + "(schedule_id, time, " +
"type, value) VALUES (?, ?, ?, ?) USING TTL " + configuration.getOneHourTTL());
- insertSixHourData = session.prepare("INSERT INTO " + MetricsTable.SIX_HOUR + "(schedule_id, time, " +
+ insertSixHourData = storageSession.prepare("INSERT INTO " + MetricsTable.SIX_HOUR + "(schedule_id, time, " +
"type, value) VALUES (?, ?, ?, ?) USING TTL " + configuration.getOneHourTTL());
- insertTwentyFourHourData = session.prepare("INSERT INTO " + MetricsTable.TWENTY_FOUR_HOUR + "(schedule_id, " +
+ insertTwentyFourHourData = storageSession.prepare("INSERT INTO " + MetricsTable.TWENTY_FOUR_HOUR + "(schedule_id, " +
"time, type, value) VALUES (?, ?, ?, ?) USING TTL " + configuration.getOneHourTTL());
- updateMetricsIndex = session.prepare("INSERT INTO " + MetricsTable.INDEX + " (bucket, time, schedule_id) " +
+ updateMetricsIndex = storageSession.prepare("INSERT INTO " + MetricsTable.INDEX + " (bucket, time, schedule_id) " +
"VALUES (?, ?, ?)");
- findLatestRawMetric = session.prepare("SELECT schedule_id, time, value FROM " + MetricsTable.RAW +
+ findLatestRawMetric = storageSession.prepare("SELECT schedule_id, time, value FROM " + MetricsTable.RAW +
" WHERE schedule_id = ? ORDER BY time DESC LIMIT 1");
- findRawMetrics = session.prepare("SELECT schedule_id, time, value FROM " + MetricsTable.RAW +
+ findRawMetrics = storageSession.prepare("SELECT schedule_id, time, value FROM " + MetricsTable.RAW +
" WHERE schedule_id = ? AND time >= ? AND time <= ?");
- findOneHourMetricsByDateRange = session.prepare("SELECT schedule_id, time, type, value FROM " +
+ findOneHourMetricsByDateRange = storageSession.prepare("SELECT schedule_id, time, type, value FROM " +
MetricsTable.ONE_HOUR + " WHERE schedule_id = ? AND time >= ? AND time < ?");
- findSixHourMetricsByDateRange = session.prepare("SELECT schedule_id, time, type, value FROM "
+ findSixHourMetricsByDateRange = storageSession.prepare("SELECT schedule_id, time, type, value FROM "
+ MetricsTable.SIX_HOUR + " WHERE schedule_id = ? AND time >= ? AND time < ?");
- findTwentyFourHourMetricsByDateRange = session.prepare("SELECT schedule_id, time, type, value FROM " +
+ findTwentyFourHourMetricsByDateRange = storageSession.prepare("SELECT schedule_id, time, type, value FROM " +
MetricsTable.TWENTY_FOUR_HOUR + " WHERE schedule_id = ? AND time >= ? AND time < ?");
- findIndexEntries = session.prepare("SELECT time, schedule_id FROM " + MetricsTable.INDEX +
+ findIndexEntries = storageSession.prepare("SELECT time, schedule_id FROM " + MetricsTable.INDEX +
" WHERE bucket = ? AND time = ?");
- findTimeSliceForIndex = session.prepare("SELECT time FROM " + MetricsTable.INDEX +
+ findTimeSliceForIndex = storageSession.prepare("SELECT time FROM " + MetricsTable.INDEX +
" WHERE bucket = ? AND time = ?");
- deleteIndexEntries = session.prepare("DELETE FROM " + MetricsTable.INDEX + " WHERE bucket = ? AND time = ?");
+ deleteIndexEntries = storageSession.prepare("DELETE FROM " + MetricsTable.INDEX + " WHERE bucket = ? AND time = ?");
long endTime = System.currentTimeMillis();
log.info("Finished initializing prepared statements in " + (endTime - startTime) + " ms");
}
- public ResultSetFuture insertRawData(MeasurementDataNumeric data) {
+ public StorageResultSetFuture insertRawData(MeasurementDataNumeric data) {
BoundStatement statement = insertRawData.bind(data.getScheduleId(), new Date(data.getTimestamp()),
data.getValue());
- return session.executeAsync(statement);
- }
-
- public List<MetricResultFuture<MeasurementDataNumeric>> insertRawMetricsAsync(Set<MeasurementDataNumeric> dataSet,
- int ttl) {
- try {
- List<MetricResultFuture<MeasurementDataNumeric>> resultFutures = new ArrayList<MetricResultFuture<MeasurementDataNumeric>>();
-
- String cql = "INSERT INTO raw_metrics (schedule_id, time, value) VALUES (?, ?, ?) " + "USING TTL " + ttl;
- PreparedStatement statement = session.prepare(cql);
-
- for (MeasurementDataNumeric data : dataSet) {
- BoundStatement boundStatement = statement.bind(data.getScheduleId(), new Date(data.getTimestamp()),
- data.getValue());
-
- resultFutures.add(new MetricResultFuture<MeasurementDataNumeric>(session.executeAsync(boundStatement),
- data));
- }
-
- return resultFutures;
- } catch (NoHostAvailableException e) {
- throw new CQLException(e);
- }
+ return storageSession.executeAsync(statement);
}
public ResultSet insertOneHourData(int scheduleId, long timestamp, AggregateType type, double value) {
BoundStatement statement = insertOneHourData.bind(scheduleId, new Date(timestamp), type.ordinal(), value);
- return session.execute(statement);
+ return storageSession.execute(statement);
}
public ResultSet insertSixHourData(int scheduleId, long timestamp, AggregateType type, double value) {
BoundStatement statement = insertSixHourData.bind(scheduleId, new Date(timestamp), type.ordinal(), value);
- return session.execute(statement);
+ return storageSession.execute(statement);
}
public ResultSet insertTwentyFourHourData(int scheduleId, long timestamp, AggregateType type, double value) {
BoundStatement statement = insertTwentyFourHourData.bind(scheduleId, new Date(timestamp), type.ordinal(),
value);
- return session.execute(statement);
- }
-
- public List<MetricResultFuture<AggregateNumericMetric>> insertAggregatesAsync(MetricsTable table,
- List<AggregateNumericMetric> metrics, int ttl) {
- List<MetricResultFuture<AggregateNumericMetric>> updates = new ArrayList<MetricResultFuture<AggregateNumericMetric>>();
-
- if (metrics.isEmpty()) {
- return updates;
- }
-
- try {
- Statement statement = null;
-
- for (AggregateNumericMetric metric : metrics) {
- statement = insertInto(table.getTableName())
- .value("schedule_id", metric.getScheduleId())
- .value("time", new Date(metric.getTimestamp()))
- .value("type", AggregateType.MIN.ordinal())
- .value("value", metric.getMin());
- updates.add(new MetricResultFuture<AggregateNumericMetric>(session.executeAsync(statement), metric));
-
- statement = insertInto(table.getTableName())
- .value("schedule_id", metric.getScheduleId())
- .value("time", new Date(metric.getTimestamp()))
- .value("type", AggregateType.MAX.ordinal())
- .value("value", metric.getMax());
- updates.add(new MetricResultFuture<AggregateNumericMetric>(session.executeAsync(statement), metric));
-
- statement = insertInto(table.getTableName())
- .value("schedule_id", metric.getScheduleId())
- .value("time", new Date(metric.getTimestamp()))
- .value("type", AggregateType.AVG.ordinal())
- .value("value", metric.getAvg());
- updates.add(new MetricResultFuture<AggregateNumericMetric>(session.executeAsync(statement), metric));
- }
-
- return updates;
- } catch (Exception e) {
- throw new CQLException(e);
- }
+ return storageSession.execute(statement);
}
public Iterable<RawNumericMetric> findRawMetrics(int scheduleId, long startTime, long endTime) {
try {
BoundStatement boundStatement = rawMetricsQuery.bind(scheduleId, new Date(startTime), new Date(endTime));
- return new SimplePagedResult<RawNumericMetric>(boundStatement, new RawNumericMetricMapper(false), session);
+ return new SimplePagedResult<RawNumericMetric>(boundStatement, new RawNumericMetricMapper(false),
+ storageSession);
} catch (NoHostAvailableException e) {
throw new CQLException(e);
}
}
- public ResultSetFuture findRawMetricsAsync(int scheduleId, long startTime, long endTime) {
+ public StorageResultSetFuture findRawMetricsAsync(int scheduleId, long startTime, long endTime) {
BoundStatement boundStatement = rawMetricsQuery.bind(scheduleId, new Date(startTime), new Date(endTime));
- return session.executeAsync(boundStatement);
+ return storageSession.executeAsync(boundStatement);
}
public RawNumericMetric findLatestRawMetric(int scheduleId) {
RawNumericMetricMapper mapper = new RawNumericMetricMapper(false);
BoundStatement boundStatement = findLatestRawMetric.bind(scheduleId);
- ResultSet resultSet = session.execute(boundStatement);
+ ResultSet resultSet = storageSession.execute(boundStatement);
return mapper.mapOne(resultSet);
}
public Iterable<RawNumericMetric> findRawMetrics(List<Integer> scheduleIds, long startTime, long endTime) {
return new ListPagedResult<RawNumericMetric>(findRawMetrics, scheduleIds, startTime, endTime,
- new RawNumericMetricMapper(), session);
+ new RawNumericMetricMapper(), storageSession);
}
public Iterable<AggregateNumericMetric> findOneHourMetrics(int scheduleId, long startTime, long endTime) {
BoundStatement statement = findOneHourMetricsByDateRange.bind(scheduleId, new Date(startTime), new Date(endTime));
- return new SimplePagedResult<AggregateNumericMetric>(statement, new AggregateNumericMetricMapper(), session);
+ return new SimplePagedResult<AggregateNumericMetric>(statement, new AggregateNumericMetricMapper(),
+ storageSession);
}
public Iterable<AggregateNumericMetric> findSixHourMetrics(int scheduleId, long startTime, long endTime) {
BoundStatement statement = findSixHourMetricsByDateRange.bind(scheduleId, new Date(startTime), new Date(endTime));
- return new SimplePagedResult<AggregateNumericMetric>(statement, new AggregateNumericMetricMapper(), session);
+ return new SimplePagedResult<AggregateNumericMetric>(statement, new AggregateNumericMetricMapper(),
+ storageSession);
}
public Iterable<AggregateNumericMetric> findTwentyFourHourMetrics(int scheduleId, long startTime, long endTime) {
BoundStatement statement = findTwentyFourHourMetricsByDateRange.bind(scheduleId, new Date(startTime), new Date(endTime));
- return new SimplePagedResult<AggregateNumericMetric>(statement, new AggregateNumericMetricMapper(), session);
+ return new SimplePagedResult<AggregateNumericMetric>(statement, new AggregateNumericMetricMapper(),
+ storageSession);
}
public Iterable<AggregateSimpleNumericMetric> findAggregatedSimpleOneHourMetric(int scheduleId, long startTime,
@@ -281,52 +216,52 @@ public class MetricsDAO {
BoundStatement statement = findOneHourMetricsByDateRange.bind(scheduleId, new Date(startTime),
new Date(endTime));
return new SimplePagedResult<AggregateSimpleNumericMetric>(statement, new AggregateSimpleNumericMetricMapper(),
- session);
+ storageSession);
}
public Iterable<AggregateNumericMetric> findOneHourMetrics(List<Integer> scheduleIds, long startTime,
long endTime) {
return new ListPagedResult<AggregateNumericMetric>(findOneHourMetricsByDateRange, scheduleIds, startTime, endTime,
- new AggregateNumericMetricMapper(), session);
+ new AggregateNumericMetricMapper(), storageSession);
}
public Iterable<AggregateNumericMetric> findSixHourMetrics(List<Integer> scheduleIds, long startTime,
long endTime) {
return new ListPagedResult<AggregateNumericMetric>(findSixHourMetricsByDateRange, scheduleIds, startTime, endTime,
- new AggregateNumericMetricMapper(), session);
+ new AggregateNumericMetricMapper(), storageSession);
}
public Iterable<AggregateNumericMetric> findTwentyFourHourMetrics(List<Integer> scheduleIds, long startTime,
long endTime) {
return new ListPagedResult<AggregateNumericMetric>(findTwentyFourHourMetricsByDateRange, scheduleIds, startTime, endTime,
- new AggregateNumericMetricMapper(), session);
+ new AggregateNumericMetricMapper(), storageSession);
}
public Iterable<MetricsIndexEntry> findMetricsIndexEntries(final MetricsTable table, long timestamp) {
BoundStatement statement = findIndexEntries.bind(table.toString(), new Date(timestamp));
- return new SimplePagedResult<MetricsIndexEntry>(statement, new MetricsIndexEntryMapper(table), session);
+ return new SimplePagedResult<MetricsIndexEntry>(statement, new MetricsIndexEntryMapper(table), storageSession);
}
public ResultSet setFindTimeSliceForIndex(MetricsTable table, long timestamp) {
BoundStatement statement = findTimeSliceForIndex.bind(table.toString(), new Date(timestamp));
- return session.execute(statement);
+ return storageSession.execute(statement);
}
public void updateMetricsIndex(MetricsTable table, Map<Integer, Long> updates) {
for (Integer scheduleId : updates.keySet()) {
BoundStatement statement = updateMetricsIndex.bind(table.getTableName(),
new Date(updates.get(scheduleId)), scheduleId);
- session.execute(statement);
+ storageSession.execute(statement);
}
}
- public ResultSetFuture updateMetricsIndex(MetricsTable table, int scheduleId, long timestamp) {
+ public StorageResultSetFuture updateMetricsIndex(MetricsTable table, int scheduleId, long timestamp) {
BoundStatement statement = updateMetricsIndex.bind(table.getTableName(), new Date(timestamp), scheduleId);
- return session.executeAsync(statement);
+ return storageSession.executeAsync(statement);
}
public void deleteMetricsIndexEntries(MetricsTable table, long timestamp) {
BoundStatement statement = deleteIndexEntries.bind(table.getTableName(), new Date(timestamp));
- session.execute(statement);
+ storageSession.execute(statement);
}
}
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java
index 7395953..9756006 100644
--- a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java
@@ -35,7 +35,6 @@ import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicInteger;
import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.core.ResultSetFuture;
import com.datastax.driver.core.Row;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
@@ -299,7 +298,7 @@ public class MetricsServer {
for (final MeasurementDataNumeric data : dataSet) {
semaphore.acquire();
- ResultSetFuture resultSetFuture = dao.insertRawData(data);
+ StorageResultSetFuture resultSetFuture = dao.insertRawData(data);
Futures.addCallback(resultSetFuture, new FutureCallback<ResultSet>() {
@Override
public void onSuccess(ResultSet rows) {
@@ -325,7 +324,7 @@ public class MetricsServer {
long timeSlice = dateTimeService.getTimeSlice(new DateTime(rawData.getTimestamp()),
configuration.getRawTimeSliceDuration()).getMillis();
- ResultSetFuture resultSetFuture = dao.updateMetricsIndex(MetricsTable.ONE_HOUR, rawData.getScheduleId(),
+ StorageResultSetFuture resultSetFuture = dao.updateMetricsIndex(MetricsTable.ONE_HOUR, rawData.getScheduleId(),
timeSlice);
Futures.addCallback(resultSetFuture, new FutureCallback<ResultSet>() {
@Override
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/StorageResultSetFuture.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/StorageResultSetFuture.java
new file mode 100644
index 0000000..902bf4a
--- /dev/null
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/StorageResultSetFuture.java
@@ -0,0 +1,76 @@
+package org.rhq.server.metrics;
+
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.ResultSetFuture;
+import com.datastax.driver.core.exceptions.NoHostAvailableException;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * @author John Sanda
+ */
+public class StorageResultSetFuture implements ListenableFuture<ResultSet> {
+
+ private ResultSetFuture wrapperFuture;
+
+ private List<StorageStateListener> listeners;
+
+ public StorageResultSetFuture(ResultSetFuture resultSetFuture, List<StorageStateListener> listeners) {
+ wrapperFuture = resultSetFuture;
+ this.listeners = listeners;
+ }
+
+ @Override
+ public void addListener(Runnable listener, Executor executor) {
+ wrapperFuture.addListener(listener, executor);
+ }
+
+ @Override
+ public boolean cancel(boolean mayInterruptIfRunning) {
+ return wrapperFuture.cancel(mayInterruptIfRunning);
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return wrapperFuture.isCancelled();
+ }
+
+ @Override
+ public boolean isDone() {
+ return wrapperFuture.isDone();
+ }
+
+ @Override
+ public ResultSet get() throws InterruptedException, ExecutionException {
+ try {
+ return wrapperFuture.get();
+ } catch (ExecutionException e) {
+ return handleException(e);
+ }
+ }
+
+ @Override
+ public ResultSet get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException,
+ TimeoutException {
+ try {
+ return wrapperFuture.get(timeout, unit);
+ } catch (ExecutionException e) {
+ return handleException(e);
+ }
+ }
+
+ private ResultSet handleException(ExecutionException e) throws ExecutionException {
+ if (e.getCause() instanceof NoHostAvailableException) {
+ NoHostAvailableException cause = (NoHostAvailableException) e.getCause();
+ for (StorageStateListener listener : listeners) {
+ listener.onStorageClusterDown(cause);
+ }
+ }
+ throw e;
+ }
+}
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/StorageSession.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/StorageSession.java
new file mode 100644
index 0000000..3f7af3f
--- /dev/null
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/StorageSession.java
@@ -0,0 +1,110 @@
+package org.rhq.server.metrics;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.Host;
+import com.datastax.driver.core.PreparedStatement;
+import com.datastax.driver.core.Query;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.ResultSetFuture;
+import com.datastax.driver.core.Session;
+import com.datastax.driver.core.exceptions.NoHostAvailableException;
+
+/**
+ * @author John Sanda
+ */
+public class StorageSession implements Host.StateListener {
+
+ private Session wrappedSession;
+
+ private List<StorageStateListener> listeners = new ArrayList<StorageStateListener>();
+
+ public StorageSession(Session wrappedSession) {
+ this.wrappedSession = wrappedSession;
+ this.wrappedSession.getCluster().register(this);
+ }
+
+ public void addStorageStateListener(StorageStateListener listener) {
+ listeners.add(listener);
+ }
+
+ public ResultSet execute(String query) {
+ try {
+ return wrappedSession.execute(query);
+ } catch (NoHostAvailableException e) {
+ return handleException(e);
+ }
+ }
+
+ public ResultSet execute(Query query) {
+ try {
+ return wrappedSession.execute(query);
+ } catch (NoHostAvailableException e) {
+ return handleException(e);
+ }
+ }
+
+ public StorageResultSetFuture executeAsync(String query) {
+ ResultSetFuture future = wrappedSession.executeAsync(query);
+ return new StorageResultSetFuture(future, listeners);
+ }
+
+ public StorageResultSetFuture executeAsync(Query query) {
+ ResultSetFuture future = wrappedSession.executeAsync(query);
+ return new StorageResultSetFuture(future, listeners);
+ }
+
+ public PreparedStatement prepare(String query) {
+ return wrappedSession.prepare(query);
+ }
+
+ public void shutdown() {
+ wrappedSession.shutdown();
+ }
+
+ public boolean shutdown(long timeout, TimeUnit unit) {
+ return wrappedSession.shutdown(timeout, unit);
+ }
+
+ public Cluster getCluster() {
+ return wrappedSession.getCluster();
+ }
+
+ @Override
+ public void onAdd(Host host) {
+ for (StorageStateListener listener : listeners) {
+ listener.onStorageNodeUp(host.getAddress());
+ }
+ }
+
+ @Override
+ public void onUp(Host host) {
+ for (StorageStateListener listener : listeners) {
+ listener.onStorageNodeUp(host.getAddress());
+ }
+ }
+
+ @Override
+ public void onDown(Host host) {
+ for (StorageStateListener listener : listeners) {
+ listener.onStorageNodeDown(host.getAddress());
+ }
+ }
+
+ @Override
+ public void onRemove(Host host) {
+ for (StorageStateListener listener : listeners) {
+ listener.onStorageNodeRemoved(host.getAddress());
+ }
+ }
+
+ private ResultSet handleException(NoHostAvailableException e) {
+ for (StorageStateListener listener : listeners) {
+ listener.onStorageClusterDown(e);
+ }
+ throw e;
+ }
+}
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/StorageStateListener.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/StorageStateListener.java
new file mode 100644
index 0000000..6a3a216
--- /dev/null
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/StorageStateListener.java
@@ -0,0 +1,20 @@
+package org.rhq.server.metrics;
+
+import java.net.InetAddress;
+
+import com.datastax.driver.core.exceptions.NoHostAvailableException;
+
+/**
+ * @author John Sanda
+ */
+public interface StorageStateListener {
+
+ void onStorageNodeUp(InetAddress address);
+
+ void onStorageNodeDown(InetAddress address);
+
+ void onStorageNodeRemoved(InetAddress address);
+
+ void onStorageClusterDown(NoHostAvailableException e);
+
+}
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/domain/ListPagedResult.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/domain/ListPagedResult.java
index 1c1fdd2..f3abd20 100644
--- a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/domain/ListPagedResult.java
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/domain/ListPagedResult.java
@@ -33,10 +33,10 @@ import java.util.List;
import com.datastax.driver.core.BoundStatement;
import com.datastax.driver.core.PreparedStatement;
import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.core.Session;
import com.datastax.driver.core.exceptions.NoHostAvailableException;
import org.rhq.server.metrics.CQLException;
+import org.rhq.server.metrics.StorageSession;
/**
* This class helps paginate Cassandra results that have a list in the matching clause. Instead of running
@@ -52,12 +52,12 @@ public class ListPagedResult<T> implements Iterable<T> {
private final long startTime;
private final long endTime;
private final ResultSetMapper<T> mapper;
- private final Session session;
+ private final StorageSession session;
private final PreparedStatement preparedStatement;
public ListPagedResult(PreparedStatement preparedStatement, List<Integer> scheduleIds, long startTime, long endTime,
- ResultSetMapper<T> mapper, Session session) {
+ ResultSetMapper<T> mapper, StorageSession session) {
this.preparedStatement = preparedStatement;
this.scheduleIds = new LinkedList<Integer>(scheduleIds);
this.startTime = startTime;
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/domain/SimplePagedResult.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/domain/SimplePagedResult.java
index d14195c..e31db95 100644
--- a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/domain/SimplePagedResult.java
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/domain/SimplePagedResult.java
@@ -34,6 +34,7 @@ import com.datastax.driver.core.SimpleStatement;
import com.datastax.driver.core.exceptions.NoHostAvailableException;
import org.rhq.server.metrics.CQLException;
+import org.rhq.server.metrics.StorageSession;
/**
* This class is just a placeholder for future pagination implementations once Cassandra gets native support for paging results.
@@ -51,7 +52,7 @@ public class SimplePagedResult<T> implements Iterable<T> {
private final ResultSetMapper<T> mapper;
private final Query query;
- private final Session session;
+ private final StorageSession session;
private final int pageSize;
/**
@@ -60,7 +61,7 @@ public class SimplePagedResult<T> implements Iterable<T> {
* @param session Cassandra session
* @param pageSize page size
*/
- public SimplePagedResult(Query query, ResultSetMapper<T> mapper, Session session, int pageSize) {
+ public SimplePagedResult(Query query, ResultSetMapper<T> mapper, StorageSession session, int pageSize) {
this.query = query;
this.mapper = mapper;
this.session = session;
@@ -73,7 +74,7 @@ public class SimplePagedResult<T> implements Iterable<T> {
* @param session Cassandra session
* @param pageSize page size
*/
- public SimplePagedResult(String query, ResultSetMapper<T> mapper, Session session, int pageSize) {
+ public SimplePagedResult(String query, ResultSetMapper<T> mapper, StorageSession session, int pageSize) {
this(new SimpleStatement(query), mapper, session, pageSize);
}
@@ -82,7 +83,7 @@ public class SimplePagedResult<T> implements Iterable<T> {
* @param mapper result set mapper
* @param session Cassandra session
*/
- public SimplePagedResult(Query query, ResultSetMapper<T> mapper, Session session) {
+ public SimplePagedResult(Query query, ResultSetMapper<T> mapper, StorageSession session) {
this(query, mapper, session, DEFAULT_PAGE_SIZE);
}
@@ -92,7 +93,7 @@ public class SimplePagedResult<T> implements Iterable<T> {
* @param session Cassandra session
* @param pageSize page size
*/
- public SimplePagedResult(String query, ResultSetMapper<T> mapper, Session session) {
+ public SimplePagedResult(String query, ResultSetMapper<T> mapper, StorageSession session) {
this(new SimpleStatement(query), mapper, session);
}
diff --git a/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/CassandraIntegrationTest.java b/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/CassandraIntegrationTest.java
index c4c48c8..b227b2d 100644
--- a/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/CassandraIntegrationTest.java
+++ b/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/CassandraIntegrationTest.java
@@ -33,6 +33,7 @@ import java.util.concurrent.CountDownLatch;
import com.datastax.driver.core.BoundStatement;
import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.Host;
import com.datastax.driver.core.PreparedStatement;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Session;
@@ -65,8 +66,12 @@ public class CassandraIntegrationTest {
protected static Session session;
+ protected static StorageSession storageSession;
+
private static DateTimeService dateTimeService;
+ private final Log log = LogFactory.getLog(CassandraIntegrationTest.class);
+
@BeforeSuite
@DeployCluster(numNodes = 2, username = "rhqadmin", password = "rhqadmin", waitForSchemaAgreement = true)
public void deployCluster() throws Exception {
@@ -76,7 +81,31 @@ public class CassandraIntegrationTest {
.addContactPoints("127.0.0.1", "127.0.02")
.withCredentials("rhqadmin", "rhqadmin")
.build();
+
+ cluster.register(new Host.StateListener() {
+ @Override
+ public void onAdd(Host host) {
+ log.info("host " + host + " added");
+ }
+
+ @Override
+ public void onUp(Host host) {
+ log.info("host " + host + " up");
+ }
+
+ @Override
+ public void onDown(Host host) {
+ log.info("host " + host + " down");
+ }
+
+ @Override
+ public void onRemove(Host host) {
+ log.info("host " + host + " removed");
+ }
+ });
+
session = cluster.connect("rhq");
+ storageSession = new StorageSession(session);
}
@AfterSuite(alwaysRun = true)
@@ -98,7 +127,7 @@ public class CassandraIntegrationTest {
BoundStatement boundStatement = statement.bind(scheduleId);
return new SimplePagedResult<AggregateNumericMetric>(boundStatement, new AggregateNumericMetricMapper(),
- session);
+ storageSession);
}
protected Iterable<AggregateNumericMetric> findAggregateMetricsWithMetadata(MetricsTable table, int scheduleId,
@@ -109,11 +138,11 @@ public class CassandraIntegrationTest {
"SELECT schedule_id, time, type, value, ttl(value), writetime(value) " +
"FROM " + table + " " +
"WHERE schedule_id = ? AND time >= ? AND time < ?";
- PreparedStatement statement = session.prepare(cql);
+ PreparedStatement statement = storageSession.prepare(cql);
BoundStatement boundStatement = statement.bind(scheduleId, new Date(startTime), new Date(endTime));
return new SimplePagedResult<AggregateNumericMetric>(boundStatement, new AggregateNumericMetricMapper(true),
- session);
+ storageSession);
} catch (NoHostAvailableException e) {
throw new CQLException(e);
}
diff --git a/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/ClusterMonitorTest.java b/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/ClusterMonitorTest.java
new file mode 100644
index 0000000..871b7c5
--- /dev/null
+++ b/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/ClusterMonitorTest.java
@@ -0,0 +1,92 @@
+package org.rhq.server.metrics;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.ConsistencyLevel;
+import com.datastax.driver.core.Host;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Session;
+import com.datastax.driver.core.querybuilder.QueryBuilder;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.cassandra.util.ClusterBuilder;
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+
+/**
+ * @author John Sanda
+ */
+public class ClusterMonitorTest {
+
+ private final Log log = LogFactory.getLog(ClusterMonitorTest.class);
+
+// @Test
+ public void monitorCluster() {
+ Cluster cluster = new ClusterBuilder()
+ .addContactPoints("127.0.0.1")
+// .withCredentials("cassandra", "cassandra")
+ .withCredentials("rhqadmin", "rhqadmin")
+ .build();
+
+ cluster.register(new Host.StateListener() {
+ @Override
+ public void onAdd(Host host) {
+ log.info("host " + host + " ADDED");
+ }
+
+ @Override
+ public void onUp(Host host) {
+ log.info("host " + host + " UP");
+ }
+
+ @Override
+ public void onDown(Host host) {
+ log.info("host " + host + " DOWN");
+ }
+
+ @Override
+ public void onRemove(Host host) {
+ log.info("host " + host + " REMOVED");
+ }
+ });
+
+ Session session = cluster.connect("rhq");
+ StorageSession storageSession = new StorageSession(session);
+
+ MetricsDAO dao = new MetricsDAO(storageSession, new MetricsConfiguration());
+
+ while (true) {
+ try {
+ Thread.sleep(10000);
+ try {
+// session.execute("select * from system.schema_keyspaces");
+ com.datastax.driver.core.Query query = QueryBuilder.select().from("rhq", "raw_metrics").setConsistencyLevel(
+ ConsistencyLevel.ALL);
+// session.execute(query);
+// session.execute("select * from rhq.raw_metrics");
+// log.info("query succeeded");
+ StorageResultSetFuture future = dao.insertRawData
+ (new MeasurementDataNumeric(System.currentTimeMillis(), 123, 1.1));
+
+ Futures.addCallback(future, new FutureCallback<ResultSet>() {
+ @Override
+ public void onSuccess(ResultSet rows) {
+ log.info("insert succeeded");
+ }
+
+ @Override
+ public void onFailure(Throwable throwable) {
+ log.error("insert failed", throwable);
+ }
+ });
+ } catch (Exception e) {
+ log.error("query failed", e);
+ }
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+
+}
diff --git a/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsBaselineCalculatorTest.java b/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsBaselineCalculatorTest.java
index ab4bd03..2b58222 100644
--- a/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsBaselineCalculatorTest.java
+++ b/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsBaselineCalculatorTest.java
@@ -35,8 +35,6 @@ import java.util.Arrays;
import java.util.List;
import java.util.Random;
-import com.datastax.driver.core.Session;
-
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.testng.PowerMockObjectFactory;
@@ -71,9 +69,9 @@ public class MetricsBaselineCalculatorTest {
//tell the method story as it happens: mock dependencies and configure
//those dependencies to get the method under test to completion.
- Session mockSession = mock(Session.class);
+ StorageSession mockSession = mock(StorageSession.class);
MetricsDAO mockMetricsDAO = mock(MetricsDAO.class);
- PowerMockito.whenNew(MetricsDAO.class).withParameterTypes(Session.class, MetricsConfiguration.class)
+ PowerMockito.whenNew(MetricsDAO.class).withParameterTypes(StorageSession.class, MetricsConfiguration.class)
.withArguments(eq(mockSession), eq(metricsConfiguration)).thenReturn(mockMetricsDAO);
when(mockMetricsDAO.findAggregatedSimpleOneHourMetric(eq(1), eq(0),
@@ -147,9 +145,9 @@ public class MetricsBaselineCalculatorTest {
//tell the method story as it happens: mock dependencies and configure
//those dependencies to get the method under test to completion.
- Session mockSession = mock(Session.class);
+ StorageSession mockSession = mock(StorageSession.class);
MetricsDAO mockMetricsDAO = mock(MetricsDAO.class);
- PowerMockito.whenNew(MetricsDAO.class).withParameterTypes(Session.class, MetricsConfiguration.class)
+ PowerMockito.whenNew(MetricsDAO.class).withParameterTypes(StorageSession.class, MetricsConfiguration.class)
.withArguments(eq(mockSession), eq(metricsConfiguration)).thenReturn(mockMetricsDAO);
when(
@@ -214,9 +212,9 @@ public class MetricsBaselineCalculatorTest {
//tell the method story as it happens: mock dependencies and configure
//those dependencies to get the method under test to completion.
- Session mockSession = mock(Session.class);
+ StorageSession mockSession = mock(StorageSession.class);
MetricsDAO mockMetricsDAO = mock(MetricsDAO.class);
- PowerMockito.whenNew(MetricsDAO.class).withParameterTypes(Session.class, MetricsConfiguration.class)
+ PowerMockito.whenNew(MetricsDAO.class).withParameterTypes(StorageSession.class, MetricsConfiguration.class)
.withArguments(eq(mockSession), eq(metricsConfiguration)).thenReturn(mockMetricsDAO);
when(
diff --git a/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsDAOTest.java b/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsDAOTest.java
index ee65292..b06dfda 100644
--- a/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsDAOTest.java
+++ b/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsDAOTest.java
@@ -38,7 +38,6 @@ import java.util.Map;
import java.util.Random;
import java.util.Set;
-import com.datastax.driver.core.ResultSetFuture;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.Futures;
@@ -78,7 +77,7 @@ public class MetricsDAOTest extends CassandraIntegrationTest {
@BeforeClass
public void initDAO() throws Exception {
- dao = new MetricsDAO(session, new MetricsConfiguration());
+ dao = new MetricsDAO(storageSession, new MetricsConfiguration());
}
@BeforeMethod
@@ -101,7 +100,7 @@ public class MetricsDAOTest extends CassandraIntegrationTest {
WaitForWrite waitForResults = new WaitForWrite(1);
- ResultSetFuture resultSetFuture = dao.insertRawData(expected);
+ StorageResultSetFuture resultSetFuture = dao.insertRawData(expected);
Futures.addCallback(resultSetFuture, waitForResults);
waitForResults.await("Failed to insert raw data");
@@ -131,7 +130,7 @@ public class MetricsDAOTest extends CassandraIntegrationTest {
WaitForWrite waitForWrite = new WaitForWrite(data.size());
for (MeasurementDataNumeric raw : data) {
- ResultSetFuture resultSetFuture = dao.insertRawData(raw);
+ StorageResultSetFuture resultSetFuture = dao.insertRawData(raw);
Futures.addCallback(resultSetFuture, waitForWrite);
}
waitForWrite.await("Failed to insert raw data");
@@ -160,14 +159,14 @@ public class MetricsDAOTest extends CassandraIntegrationTest {
WaitForWrite waitForWrite = new WaitForWrite(data.size());
for (MeasurementDataNumeric raw : data) {
- ResultSetFuture resultSetFuture = dao.insertRawData(raw);
+ StorageResultSetFuture resultSetFuture = dao.insertRawData(raw);
Futures.addCallback(resultSetFuture, waitForWrite);
}
waitForWrite.await("Failed to insert raw data");
RawNumericMetricMapper mapper = new RawNumericMetricMapper();
WaitForRead<RawNumericMetric> waitForRead = new WaitForRead<RawNumericMetric>(mapper);
- ResultSetFuture resultSetFuture = dao.findRawMetricsAsync(scheduleId,
+ StorageResultSetFuture resultSetFuture = dao.findRawMetricsAsync(scheduleId,
threeMinutesAgo.minusSeconds(5).getMillis(), oneMinuteAgo.plusSeconds(5).getMillis());
Futures.addCallback(resultSetFuture, waitForRead);
@@ -200,7 +199,7 @@ public class MetricsDAOTest extends CassandraIntegrationTest {
WaitForWrite waitForWrite = new WaitForWrite(data.size());
for (MeasurementDataNumeric raw : data) {
- ResultSetFuture resultSetFuture = dao.insertRawData(raw);
+ StorageResultSetFuture resultSetFuture = dao.insertRawData(raw);
Futures.addCallback(resultSetFuture, waitForWrite);
}
waitForWrite.await("Failed to insert raw data");
@@ -321,9 +320,9 @@ public class MetricsDAOTest extends CassandraIntegrationTest {
WaitForWrite waitForWrite = new WaitForWrite(2);
- ResultSetFuture resultSetFuture1 = dao.updateMetricsIndex(MetricsTable.TWENTY_FOUR_HOUR, scheduleId1,
+ StorageResultSetFuture resultSetFuture1 = dao.updateMetricsIndex(MetricsTable.TWENTY_FOUR_HOUR, scheduleId1,
hour0().getMillis());
- ResultSetFuture resultSetFuture2 = dao.updateMetricsIndex(MetricsTable.TWENTY_FOUR_HOUR, scheduleId2,
+ StorageResultSetFuture resultSetFuture2 = dao.updateMetricsIndex(MetricsTable.TWENTY_FOUR_HOUR, scheduleId2,
hour0().getMillis());
Futures.addCallback(resultSetFuture1, waitForWrite);
diff --git a/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsServerTest.java b/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsServerTest.java
index 1ec4771..b4de4e0 100644
--- a/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsServerTest.java
+++ b/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsServerTest.java
@@ -43,7 +43,6 @@ import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
-import com.datastax.driver.core.ResultSetFuture;
import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.Futures;
@@ -113,7 +112,7 @@ public class MetricsServerTest extends CassandraIntegrationTest {
dateTimeService.setConfiguration(configuration);
metricsServer.setDateTimeService(dateTimeService);
- dao = new MetricsDAO(session, configuration);
+ dao = new MetricsDAO(storageSession, configuration);
metricsServer.setDAO(dao);
purgeDB();
@@ -230,7 +229,7 @@ public class MetricsServerTest extends CassandraIntegrationTest {
WaitForWrite waitForRawInserts = new WaitForWrite(rawMetrics.size());
for (MeasurementDataNumeric raw : rawMetrics) {
- ResultSetFuture resultSetFuture = dao.insertRawData(raw);
+ StorageResultSetFuture resultSetFuture = dao.insertRawData(raw);
Futures.addCallback(resultSetFuture, waitForRawInserts);
}
waitForRawInserts.await("Failed to insert raw data");
@@ -1008,7 +1007,7 @@ public class MetricsServerTest extends CassandraIntegrationTest {
"SELECT schedule_id, time, value, ttl(value), writetime(value) " +
"FROM " + MetricsTable.RAW + " " +
"WHERE schedule_id = " + scheduleId + " AND time >= " + startTime + " AND time < " + endTime;
- return new SimplePagedResult<RawNumericMetric>(cql, new RawNumericMetricMapper(true), session);
+ return new SimplePagedResult<RawNumericMetric>(cql, new RawNumericMetricMapper(true), storageSession);
}
private static class WaitForRawInserts implements RawDataInsertedCallback {
diff --git a/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/TimeoutTest.java b/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/TimeoutTest.java
index e2b23ec..dabd110 100644
--- a/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/TimeoutTest.java
+++ b/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/TimeoutTest.java
@@ -35,7 +35,6 @@ import com.google.common.base.Throwables;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.testng.annotations.Test;
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
@@ -43,7 +42,7 @@ public class TimeoutTest extends CassandraIntegrationTest {
private final Log log = LogFactory.getLog(TimeoutTest.class);
- @Test
+// @Test
public void generateTimeout() throws Exception {
MetricsConfiguration configuration = new MetricsConfiguration();
@@ -54,7 +53,7 @@ public class TimeoutTest extends CassandraIntegrationTest {
dateTimeService.setConfiguration(configuration);
metricsServer.setDateTimeService(dateTimeService);
- MetricsDAO dao = new MetricsDAO(session, configuration);
+ MetricsDAO dao = new MetricsDAO(new StorageSession(session), configuration);
metricsServer.setDAO(dao);
long time = hour0().getMillis();
diff --git a/modules/enterprise/server/server-metrics/src/test/resources/log4j.properties b/modules/enterprise/server/server-metrics/src/test/resources/log4j.properties
index 67db049..59bd5db 100644
--- a/modules/enterprise/server/server-metrics/src/test/resources/log4j.properties
+++ b/modules/enterprise/server/server-metrics/src/test/resources/log4j.properties
@@ -39,4 +39,4 @@ log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p %c %m%n
log4j.logger.org.rhq=DEBUG
-log4j.logger.com.datastax=DEBUG
+log4j.logger.com.datastax=WARN
diff --git a/modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/Simulator.java b/modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/Simulator.java
index 7ff8f6c..40e00bf 100644
--- a/modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/Simulator.java
+++ b/modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/Simulator.java
@@ -60,6 +60,7 @@ import org.rhq.metrics.simulator.stats.Stats;
import org.rhq.server.metrics.DateTimeService;
import org.rhq.server.metrics.MetricsDAO;
import org.rhq.server.metrics.MetricsServer;
+import org.rhq.server.metrics.StorageSession;
/**
* @author John Sanda
@@ -96,7 +97,9 @@ public class Simulator implements ShutdownManager {
session = createSession(nodes, compression);
}
- MetricsDAO metricsDAO = new MetricsDAO(session, plan.getMetricsServerConfiguration());
+ StorageSession storageSession = new StorageSession(session);
+
+ MetricsDAO metricsDAO = new MetricsDAO(storageSession, plan.getMetricsServerConfiguration());
MetricsServer metricsServer = new MetricsServer();
metricsServer.setDAO(metricsDAO);
metricsServer.setConfiguration(plan.getMetricsServerConfiguration());
commit 6c62c7c89a1707660e86fa97320420c2ef817339
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Jul 25 22:06:31 2013 -0400
upgrade to version 1.0.2 of datastax driver
diff --git a/pom.xml b/pom.xml
index f909033..3f2adbd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -178,7 +178,7 @@
<!-- cassandra dependency versions -->
<cassandra.version>1.2.4</cassandra.version>
<cassandra.thrift.version>0.7.0</cassandra.thrift.version>
- <cassandra.driver.version>1.0.0-rhq-1.2.4</cassandra.driver.version>
+ <cassandra.driver.version>1.0.2-rhq-1.2.4</cassandra.driver.version>
<cassandra.driver.netty.version>3.6.3.Final</cassandra.driver.netty.version>
<cassandra.snappy.version>1.0.4.1-rhq-p1</cassandra.snappy.version>
<cassandra.snakeyaml.version>1.6</cassandra.snakeyaml.version>
10 years, 9 months
[rhq] modules/enterprise modules/plugins
by snegrea
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java | 48 +++++++---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java | 3
modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml | 8 -
3 files changed, 42 insertions(+), 17 deletions(-)
New commits:
commit b9029136b21154a2572c1794807de2ca9a30e2a2
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu Jul 25 17:52:00 2013 -0500
Operations are now created in a new transaction. Also, change the way the configuration is updated.
The steps for a full configuration update:
1) Invoke config update operation on the plugin
2) Update the JMX port on the storage node entity
3) Restart the storage node server
4) Update the connection settings for the storage node if JMX port changed
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
index 7a7eda4..7d861f1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
@@ -35,6 +35,8 @@ import java.util.Queue;
import javax.ejb.EJB;
import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
@@ -134,6 +136,9 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
@EJB
private ConfigurationManagerLocal configurationManager;
+ @EJB
+ private StorageNodeManagerLocal storageNodeManger;
+
@Override
public void linkResource(Resource resource) {
List<StorageNode> storageNodes = this.getStorageNodes();
@@ -658,31 +663,49 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
parameters);
if (result) {
+ //2. Update the JMX port
+ //this is a fast operation compared to the restart
+ storageNode.setJmxPort(storageNodeConfiguration.getJmxPort());
+ entityManager.merge(storageNode);
+
+ //3. Restart the storage node
+ result = runOperationAndWaitForResult(subject, storageNodeResource, RESTART_OPERATION,
+ new Configuration());
+
+ //4. Update the plugin configuration to talk with the new server
+ //Up to this point communication with the storage node should not have been affected by the intermediate
+ //changes
Configuration storageNodePluginConfig = configurationManager.getPluginConfiguration(subject,
storageNodeResource.getId());
String existingJMXPort = storageNodePluginConfig.getSimpleValue("jmxPort");
- storageNodePluginConfig.setSimpleValue("jmxPort", storageNodeConfiguration.getJmxPort() + "");
+ String newJMXPort = storageNodeConfiguration.getJmxPort() + "";
- String existingConnectionURL = storageNodePluginConfig.getSimpleValue("connectorAddress");
- String newConnectionURL = existingConnectionURL.replace(":" + existingJMXPort + "/", ":"
- + storageNodeConfiguration.getJmxPort() + "/");
- storageNodePluginConfig.setSimpleValue("connectorAddress", newConnectionURL);
+ if (!existingJMXPort.equals(newJMXPort)) {
+ storageNodePluginConfig.setSimpleValue("jmxPort", newJMXPort);
- configurationManager.updatePluginConfiguration(subject, storageNodeResource.getId(),
- storageNodePluginConfig);
+ String existingConnectionURL = storageNodePluginConfig.getSimpleValue("connectorAddress");
+ String newConnectionURL = existingConnectionURL.replace(":" + existingJMXPort + "/", ":"
+ + storageNodeConfiguration.getJmxPort() + "/");
+ storageNodePluginConfig.setSimpleValue("connectorAddress", newConnectionURL);
- storageNode.setJmxPort(storageNodeConfiguration.getJmxPort());
- entityManager.merge(storageNode);
- entityManager.flush();
+ configurationManager.updatePluginConfiguration(subject, storageNodeResource.getId(),
+ storageNodePluginConfig);
+ }
- return runOperationAndWaitForResult(subject, storageNodeResource, RESTART_OPERATION, null);
+ return result;
}
}
return false;
}
+ @Override
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public void scheduleOperationInNewTransaction(Subject subject, ResourceOperationSchedule schedule) {
+ operationManager.scheduleResourceOperation(subject, schedule);
+ }
+
private boolean runOperationAndWaitForResult(Subject subject, Resource storageNodeResource, String operationToRun,
Configuration parameters) {
@@ -696,8 +719,7 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
newSchedule.setDescription("Run by StorageNodeManagerBean");
newSchedule.setParameters(parameters);
- operationManager.scheduleResourceOperation(subject, newSchedule);
- entityManager.flush();
+ storageNodeManger.scheduleOperationInNewTransaction(subject, newSchedule);
//waiting for the operation result then return it
int iteration = 0;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
index 69b16c4..15fa85c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
@@ -28,6 +28,7 @@ import org.rhq.core.domain.cloud.StorageNode;
import org.rhq.core.domain.cloud.StorageNodeConfigurationComposite;
import org.rhq.core.domain.cloud.StorageNodeLoadComposite;
import org.rhq.core.domain.criteria.StorageNodeCriteria;
+import org.rhq.core.domain.operation.bean.ResourceOperationSchedule;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.PageList;
@@ -178,4 +179,6 @@ public interface StorageNodeManagerLocal {
*/
ResourceGroup getStorageNodeGroup();
+ void scheduleOperationInNewTransaction(Subject subject, ResourceOperationSchedule schedule);
+
}
diff --git a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
index a42040d..f5a4f6d 100644
--- a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
@@ -132,10 +132,10 @@
<operation name="updateConfiguration" description="Updates the node configuration. Will require a separate server restart for the settings to take effect.">
<parameters>
- <c:simple-property name="jmxPort" type="integer" description="JMX port JVM option."/>
- <c:simple-property name="heapSize" type="string" description="The heap size to be used for both -Xms and -Xmx JVM options."/>
- <c:simple-property name="heapNewSize" type="string" description="The heap new size to be used be used with -Xmn JVM option."/>
- <c:simple-property name="threadStackSize" type="integer" description="The thread stack size. This memory is allocated to each thread off heap. The
+ <c:simple-property name="jmxPort" type="integer" required="false" description="JMX port JVM option."/>
+ <c:simple-property name="heapSize" type="string" required="false" description="The heap size to be used for both -Xms and -Xmx JVM options."/>
+ <c:simple-property name="heapNewSize" type="string" required="false" description="The heap new size to be used be used with -Xmn JVM option."/>
+ <c:simple-property name="threadStackSize" type="integer" required="false" description="The thread stack size. This memory is allocated to each thread off heap. The
value should be an integer that will be interpreted in kilobytes."/>
<c:simple-property name="restartIfRequired" type="boolean" required="true" default="false" description="If [true] then restart the server at the end of the update if and if only the updates made require a restart. If [false] the server will not be restarted regardless of the updates made."/>
</parameters>
10 years, 9 months
[rhq] modules/enterprise
by mike thompson
modules/enterprise/gui/coregui/pom.xml | 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/IconEnum.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/AbstractMetricGraph.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/ButtonBarDateTimeRangeEditor.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/MetricGraphData.java | 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityLineGraphType.java | 311 -------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityOverUnderGraphType.java | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/LineMetricGraph.java | 158 ---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/StackedBarMetricGraphImpl.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/D3GroupGraphListView.java | 115 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupMultiLineGraphListView.java | 79 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/DashboardLinkUtility.java | 258 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 33
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java | 204 -----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/D3GraphListView.java | 308 +++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/MetricD3Graph.java | 27
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/avail/ResourceAvailabilityView.java | 399 ----------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/AddToDashboardComponent.java | 185 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MeasurementTableView.java | 237 -----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java | 167 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableDataSource.java | 213 ++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java | 385 +++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java | 307 +++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/ResourceMetricAvailabilityView.java | 208 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java | 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/enhanced/Enhanced.java | 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 7
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties | 5
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties | 5
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties | 5
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties | 5
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties | 5
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties | 5
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties | 5
modules/enterprise/gui/coregui/src/main/webapp/js/rhq.js | 4
36 files changed, 2078 insertions(+), 1649 deletions(-)
New commits:
commit 97003022a49e9e534fd54488966eb89950760c39
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Thu Jul 25 14:16:38 2013 -0700
[BZ 988574] - Consolidated Metrics Screen - UXD Redesign
diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml
index 969ab8e..353f4d9 100644
--- a/modules/enterprise/gui/coregui/pom.xml
+++ b/modules/enterprise/gui/coregui/pom.xml
@@ -19,7 +19,7 @@
<properties>
<!-- dependency versions -->
- <gwt.version>2.5.0</gwt.version>
+ <gwt.version>${gwt.version}</gwt.version>
<smartgwt.version>3.0</smartgwt.version>
<!-- If this is too much memory to allocate to your gwt:debug process then override this property in
@@ -136,16 +136,7 @@
</dependency>
- <!-- the GWT graphing library (note, this provides jquery 1.3.2. If we get rid of GFlot we will need
- to provide jquery explcitly for jquery.sparkline support. See CoreGUI.gwt.xml for the jquery.sparkline
- declaration and coregui/webapp/js for the lib inclusion.) -->
- <!-- NOTE: soon to be deprecated by d3.js -->
- <dependency>
- <groupId>com.googlecode.gflot</groupId>
- <artifactId>gflot</artifactId>
- <version>2.4.3</version>
- <scope>provided</scope>
- </dependency>
+
<!-- for file uploads -->
<dependency>
@@ -245,7 +236,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
- <version>2.5.0</version>
+ <version>${gwt.version}</version>
<configuration>
<noServer>true</noServer>
<inplace>false</inplace>
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/IconEnum.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/IconEnum.java
index d11467a..b48a712 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/IconEnum.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/IconEnum.java
@@ -114,6 +114,12 @@ public enum IconEnum {
STORAGE_NODE("global/StorageNode_16.png", "global/StorageNode_24.png"),
/////////////////////////////
+ // General
+ /////////////////////////////
+ EXPANDED_ICON("[SKIN]/ListGrid/row_expanded.png"),
+ COLLAPSED_ICON("[SKIN]/ListGrid/row_collapsed.png"),
+
+ /////////////////////////////
// Resource Specific Tabs
/////////////////////////////
CALLTIME("global/Recent_16.png", "global/Recent_24.png");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index 4cfe199..4ce05d2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -1202,16 +1202,15 @@ public class Table<DS extends RPCDataSource> extends EnhancedHLayout implements
}
if (hiddenItem != null) {
- Log.debug("Found hidden items");
// Add the hidden item if it exists
FormItem[] tmpItems = new FormItem[items.length + 1];
System.arraycopy(items, 0, tmpItems, 0, items.length);
tmpItems[items.length] = hiddenItem;
items = tmpItems;
}
- for (FormItem item : items) {
- Log.debug(" ******** Form Items sent: " + item.getName() + ": " + item.getValue());
- }
+// for (FormItem item : items) {
+// Log.debug(" ******** Form Items sent: " + item.getName() + ": " + item.getValue());
+// }
super.setItems(items);
}
@@ -1223,19 +1222,16 @@ public class Table<DS extends RPCDataSource> extends EnhancedHLayout implements
@Override
public void onKeyPress(KeyPressEvent event) {
if (event.getKeyName().equals("Enter")) {
- Log.debug("Table.TableFilter Pressed Enter key");
if (null != searchBarItem) {
if (searchBarItem.getSearchBar().isFilterEnabled()) {
TextItem searchTextItem = searchBarItem.getSearchBar().getSearchTextItem();
String searchBarValue = searchTextItem.getValueAsString();
String hiddenValue = (String) hiddenItem.getValue();
- Log.debug("Table.TableFilter searchBarValue :" + searchBarValue + ", hiddenValue" + hiddenValue);
// Only send a fetch request if the user actually changed the search expression.
if (!equals(searchBarValue, hiddenValue)) {
hiddenItem.setValue(searchBarValue);
- Log.debug("Table.TableFilter fetchFilteredTableData");
fetchFilteredTableData();
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/AbstractMetricGraph.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/AbstractMetricGraph.java
index e75b65a..ace6154 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/AbstractMetricGraph.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/AbstractMetricGraph.java
@@ -202,6 +202,10 @@ public abstract class AbstractMetricGraph extends VLayout implements HasD3Metric
return metricGraphData.getPortalId();
}
+ public boolean isHideLegend(){
+ return metricGraphData.isHideLegend();
+ }
+
public void setGraphListView(AbstractD3GraphListView graphListView) {
this.graphListView = graphListView;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/ButtonBarDateTimeRangeEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/ButtonBarDateTimeRangeEditor.java
index 2075783..b4f1354 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/ButtonBarDateTimeRangeEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/ButtonBarDateTimeRangeEditor.java
@@ -77,7 +77,7 @@ public class ButtonBarDateTimeRangeEditor extends EnhancedVLayout {
prefs = measurementUserPreferences.getMetricRangePreferences();
Log.debug("ButtonBarDateTimeRangeEditor initialized with start Date: " + new Date(prefs.begin) + " end Date: "
+ new Date(prefs.end));
- createButtons();
+ //createButtons();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/MetricGraphData.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/MetricGraphData.java
index ecd3b46..5ae392f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/MetricGraphData.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/MetricGraphData.java
@@ -73,6 +73,7 @@ public class MetricGraphData implements JsonMetricProducer {
private MeasurementOOBComposite lastOOB;
private Integer chartHeight;
private boolean isPortalGraph;
+ private boolean hideLegend;
private MetricGraphData(int portalId) {
@@ -249,6 +250,14 @@ public class MetricGraphData implements JsonMetricProducer {
return isPortalGraph;
}
+ public boolean isHideLegend() {
+ return hideLegend;
+ }
+
+ public void setHideLegend(boolean hideLegend) {
+ this.hideLegend = hideLegend;
+ }
+
public String getChartTitle() {
if(definition != null){
@@ -380,8 +389,8 @@ public class MetricGraphData implements JsonMetricProducer {
* @see StackedBarMetricGraphImpl
*/
public boolean showBarAvgTrendLine() {
+ int numberOfAggBars = 0;
for (MeasurementDataNumericHighLowComposite measurement : metricData) {
- int numberOfAggBars = 0;
boolean noValuesInCurrentBarUndefined = (!Double.isNaN(measurement.getValue()) && !Double.isNaN(measurement.getHighValue()) && !Double.isNaN(measurement.getLowValue()));
boolean foundAggregateBar = (measurement.getValue() != measurement.getHighValue() || measurement.getHighValue() != measurement.getLowValue());
// if there exists a even one aggregate bar then I can short circuit this and exit
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityLineGraphType.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityLineGraphType.java
deleted file mode 100644
index 34ca60b..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityLineGraphType.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2012 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype;
-
-import java.util.Date;
-import java.util.List;
-
-import org.rhq.core.domain.measurement.Availability;
-import org.rhq.core.domain.measurement.MeasurementUnits;
-import org.rhq.core.domain.resource.group.composite.ResourceGroupAvailability;
-import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.Messages;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AvailabilityGraphType;
-import org.rhq.enterprise.gui.coregui.client.util.Log;
-import org.rhq.enterprise.gui.coregui.client.util.MeasurementConverterClient;
-
-/**
- * This is now old and for demonstration purposes only.
- * Contains the javascript chart definition for an implementation of the d3 availability chart. This implementation is
- * just a line that changes color based on availability type: up=green, down=red, orange=disabled, unknown=grey,
- * empty=grey, warn=yellow. This version of the availability graph shows continuous intervals.
- * @deprecated
- * @see AvailabilityOverUnderGraphType
- *
- * @author Mike Thompson
- */
-public class AvailabilityLineGraphType implements AvailabilityGraphType {
-
- private static Messages MSG = CoreGUI.getMessages();
- private List<Availability> availabilityList;
- private List<ResourceGroupAvailability> groupAvailabilityList;
- private Integer entityId;
-
- /**
- * General constructor for stacked bar graph when you have all the data needed to produce the graph. (This is true
- * for all cases but the dashboard portlet).
- */
- public AvailabilityLineGraphType(Integer entityId) {
- this.entityId = entityId;
- }
-
- public void setAvailabilityList(List<Availability> availabilityList) {
- this.availabilityList = availabilityList;
- }
-
- public void setGroupAvailabilityList(List<ResourceGroupAvailability> groupAvailabilityList) {
- this.groupAvailabilityList = groupAvailabilityList;
- }
-
- public String getAvailabilityJson() {
- StringBuilder sb = new StringBuilder("[");
- if (null != availabilityList) {
- // loop through the avail intervals
- for (Availability availability : availabilityList) {
- sb.append("{ \"availType\":\"" + availability.getAvailabilityType() + "\", ");
- sb.append(" \"availTypeMessage\":\"" + availability.getAvailabilityType()+ "\", ");
- sb.append(" \"availStart\":" + availability.getStartTime() + ", ");
- // last record will be null
- long endTime = availability.getEndTime() != null ? availability.getEndTime() : (new Date()).getTime();
- sb.append(" \"availEnd\":" + endTime + ", ");
-
- long availDuration = endTime - availability.getStartTime();
- String availDurationString = MeasurementConverterClient.format((double) availDuration,
- MeasurementUnits.MILLISECONDS, true);
- sb.append(" \"availDuration\": \"" + availDurationString + "\" },");
-
- }
- sb.setLength(sb.length() - 1);
-
- } else if (null != groupAvailabilityList) {
- // loop through the group avail down intervals
- for (ResourceGroupAvailability groupAvailability : groupAvailabilityList) {
- // allows substitution for situations like WARN=MIXED for easier terminology
- String availabilityTypeMessage = (groupAvailability.getGroupAvailabilityType().equals(ResourceGroupComposite.GroupAvailabilityType.WARN))
- ? MSG.chart_hover_availability_type_warn() : groupAvailability.getGroupAvailabilityType().name();
-
- sb.append("{ \"availType\":\"" + groupAvailability.getGroupAvailabilityType() + "\", ");
- sb.append(" \"availTypeMessage\":\"" + availabilityTypeMessage + "\", ");
- sb.append(" \"availStart\":" + groupAvailability.getStartTime() + ", ");
- // last record will be null
- long endTime = groupAvailability.getEndTime() != null ? groupAvailability.getEndTime() : (new Date())
- .getTime();
- sb.append(" \"availEnd\":" + endTime + ", ");
-
- long availDuration = endTime - groupAvailability.getStartTime();
- String availDurationString = MeasurementConverterClient.format((double) availDuration,
- MeasurementUnits.MILLISECONDS, true);
- sb.append(" \"availDuration\": \"" + availDurationString + "\" },");
-
- }
- sb.setLength(sb.length() - 1);
- }
-
- sb.append("]");
- Log.debug(sb.toString());
- return sb.toString();
- }
-
- /**
- * The magic JSNI to draw the charts with d3.
- */
- public native void drawJsniChart() /*-{
- console.log("Draw Availability chart");
-
- var global = this,
- // tidy up all of our interactions with java (via JSNI) thru AvailChartContext class
- // NOTE: rhq.js has the javascript object constructors in it.
- availChartContext = new $wnd.AvailChartContext(global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityLineGraphType::getChartId()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityLineGraphType::getAvailabilityJson()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityLineGraphType::getChartDateLabel()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityLineGraphType::getChartTimeLabel()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityLineGraphType::getChartHoverStartLabel()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityLineGraphType::getChartHoverEndLabel()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityLineGraphType::getChartHoverBarLabel()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityLineGraphType::getChartHoverAvailabilityLabel()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityLineGraphType::getChartHoverTimeFormat()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityLineGraphType::getChartHoverDateFormat()()
- );
-
-
- var availabilityGraph = function () {
- "use strict";
- // privates
-
- var margin = {top: 5, right: 5, bottom: 5, left: 40},
- barOffset = 10,
- width = 750 - margin.left - margin.right + barOffset,
- height = 20 - margin.top - margin.bottom,
- pixelsOffHeight = 0,
- svg;
-
-
- function drawBars(availChartContext) {
- var xAxisMin = $wnd.d3.min(availChartContext.data, function (d) {
- return +d.availStart;
- }),
- xAxisMax = $wnd.d3.max(availChartContext.data, function (d) {
- return +d.availEnd;
- }),
-
- timeScale = $wnd.d3.time.scale()
- .range([0, width])
- .domain([xAxisMin, xAxisMax]),
-
- yScale = $wnd.d3.scale.linear()
- .clamp(true)
- .rangeRound([height, 0])
- .domain([0, 4]),
-
- svg = $wnd.d3.select(availChartContext.chartSelection).append("g")
- .attr("width", width + margin.left + margin.right)
- .attr("height", height + margin.top + margin.bottom)
- .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
-
-
- // The gray bars at the bottom leading up
- svg.selectAll("rect.availBars")
- .data(availChartContext.data)
- .enter().append("rect")
- .attr("class", "availBars")
- .attr("x", function (d) {
- return timeScale(+d.availStart);
- })
- .attr("y", function (d) {
- return yScale(0);
- })
- .attr("height", function (d) {
- return height - yScale(4) - pixelsOffHeight;
- })
- .attr("width", function (d) {
- return timeScale(+d.availEnd) - timeScale(+d.availStart);
- })
-
- .attr("opacity", ".9")
- .attr("fill", function (d) {
- if (d.availType === 'DOWN') {
- return "#FF1919"; // red
- }
- else if (d.availType === 'DISABLED') {
- return "#FF9933"; // orange
- }
- else if (d.availType === 'UNKNOWN') {
- return "#CCC"; // gray
- }
- else if (d.availType === 'UP') {
- return "#198C19"; // green
- }
- else if (d.availType === 'WARN') {
- return "#FFFF00"; // yellow
- }
- else if (d.availType === 'EMPTY') {
- return "#CCC"; // gray
- }
- else {
- // should not ever happen, but...
- console.warn("AvailabilityType not valid.");
- return "#000"; //black
- }
- });
- }
-
- function createHovers() {
- $wnd.jQuery('svg rect.availBars').tipsy({
- gravity: 'n',
- html: true,
- trigger: 'hover',
- title: function () {
- var d = this.__data__;
- return formatHovers(d);
- },
- show: function (e, el) {
- el.css({ 'z-index': '990000'})
- }
- });
- }
-
- function formatHovers(d) {
- var hoverString,
- timeFormatter = $wnd.d3.time.format(availChartContext.chartHoverTimeFormat),
- dateFormatter = $wnd.d3.time.format(availChartContext.chartHoverDateFormat),
- availStart = new Date(+d.availStart),
- availEnd = new Date(+d.availEnd);
-
- hoverString =
- '<div class="chartHoverEnclosingDiv">' +
- '<div class="chartHoverAlignRight"><span >' + availChartContext.hoverBarAvailabilityLabel + ': </span><span style="width:50px;">' + d.availTypeMessage + '</span></div>' +
- '<div class="chartHoverAlignRight"><span >' + availChartContext.hoverStartLabel + ': </span><span style="width:50px;">' + timeFormatter(availStart) + '</span></div>' +
- '<div class="chartHoverAlignRight"><span >' + ' </span><span style="width:50px;">' + dateFormatter(availStart) + '</span></div>' +
- '<div class="chartHoverAlignRight"><span >' + availChartContext.hoverEndLabel + ': </span><span style="width:50px;">' + timeFormatter(availEnd) + '</span></div>' +
- '<div class="chartHoverAlignRight"><span >' + ' </span><span style="width:50px;">' + dateFormatter(availEnd) + '</span></div>' +
- '<div class="chartHoverAlignRight"><span >' + availChartContext.hoverBarLabel + ': </span><span style="width:50px;">' + d.availDuration + '</span></div>' +
- '</div>';
- return hoverString;
-
- }
-
- return {
- // Public API
- draw: function (chartContext) {
- "use strict";
- console.info("AvailabilityChart");
- //console.time("availabilityChart");
-
- drawBars(availChartContext);
- createHovers();
- //console.timeEnd("availabilityChart");
- }
- }; // end public closure
-
-
- }();
-
- if (availChartContext.data !== undefined && availChartContext.data.length > 0) {
- availabilityGraph.draw(availChartContext);
- }
-
- }-*/;
-
- public String getChartId() {
- return String.valueOf(entityId);
- }
-
- public String getChartTimeLabel() {
- return MSG.chart_time_label();
- }
-
- public String getChartDateLabel() {
- return MSG.chart_date_label();
- }
-
- public String getChartHoverAvailabilityLabel() {
- return MSG.chart_hover_availability_label();
- }
-
- public String getChartHoverStartLabel() {
- return MSG.chart_hover_start_label();
- }
-
- public String getChartHoverEndLabel() {
- return MSG.chart_hover_end_label();
- }
-
- public String getChartHoverBarLabel() {
- return MSG.chart_hover_bar_label();
- }
-
- public String getChartHoverTimeFormat() {
- return MSG.chart_hover_time_format();
- }
-
- public String getChartHoverDateFormat() {
- return MSG.chart_hover_date_format();
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityOverUnderGraphType.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityOverUnderGraphType.java
index 7c5f80a..811a579 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityOverUnderGraphType.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityOverUnderGraphType.java
@@ -311,13 +311,6 @@ public class AvailabilityOverUnderGraphType implements AvailabilityGraphType {
});
}
- function timeFormat(formats) {
- return function(date) {
- var i = formats.length - 1, f = formats[i];
- while (!f[1](date)) f = formats[--i];
- return f[0](date);
- }
- }
function formatHovers(d) {
var timeFormatter = $wnd.d3.time.format(availChartContext.chartHoverTimeFormat),
@@ -345,11 +338,13 @@ public class AvailabilityOverUnderGraphType implements AvailabilityGraphType {
}();
- if (availChartContext.data !== undefined && availChartContext.data.length > 0) {
+ console.log("Avail Data records: "+availChartContext.data.length);
+ if (typeof availChartContext.data !== 'undefined' && availChartContext.data.length > 0) {
availabilityGraph.draw(availChartContext);
+ console.log("Availability Chart Drawn");
}
- }-*/;
+ }-*/;
public String getChartId() {
return String.valueOf(entityId);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/LineMetricGraph.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/LineMetricGraph.java
deleted file mode 100644
index 079b2ab..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/LineMetricGraph.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2012 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype;
-
-import org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AbstractMetricGraph;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.graph.MetricGraphData;
-
-/**
- * Contains the javascript chart definition for a d3 Line graph chart.
- * NOTE: this class isn't used just provided as an example as how to create
- * other graph types.
- *
- * @author Mike Thompson
- */
-public final class LineMetricGraph extends AbstractMetricGraph {
-
- /**
- * General constructor for stacked bar graph when you have all the data needed to
- * produce the graph. (This is true for all cases but the dashboard portlet).
- */
- public LineMetricGraph(MetricGraphData metricGraphData) {
- setMetricGraphData(metricGraphData);
- }
-
- /**
- * The magic JSNI to draw the charts with d3.
- */
- public native void drawJsniChart() /*-{
- console.log("Draw Metric Line jsni chart");
- var global = this,
- chartId = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.MetricGraphData::getChartId()(),
- chartHandle = "#rChart-"+chartId,
- chartSelection = chartHandle + " svg",
- json = $wnd.jQuery.parseJSON(global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.MetricGraphData::getJsonMetrics()()),
- yAxisLabel = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.MetricGraphData::getChartTitle()(),
- yAxisUnits = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.MetricGraphData::getYAxisUnits()(),
- xAxisLabel = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.MetricGraphData::getXAxisTitle()();
-
- console.log("chart id: "+chartSelection );
- console.log(global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.MetricGraphData::getJsonMetrics()());
-
-
- function draw(data){
- "use strict";
-
- var margin = {top: 10, right: 5, bottom: 30, left: 70},
- width = 400 - margin.left - margin.right,
- height = 150 - margin.top - margin.bottom;
-
- var timeScale = $wnd.d3.time.scale()
- .range([0, width])
- .domain($wnd.d3.extent(data, function(d) { return d.x; }));
-
- var yScale = $wnd.d3.scale.linear()
- .rangeRound([height, 0])
- .domain([$wnd.d3.min(data.map(function(x) {return x.low;})), $wnd.d3.max(data.map(function(x){return x.high;}))]);
-
- var xAxis = $wnd.d3.svg.axis()
- .scale(timeScale)
- .ticks(5)
- .orient("bottom");
-
- var yAxis = $wnd.d3.svg.axis()
- .scale(yScale)
- .ticks(5)
- .orient("left");
-
- var interpolation = "basis";
-
- var line = $wnd.d3.svg.line()
- .interpolate(interpolation)
- .x(function(d) { return timeScale(d.x); })
- .y(function(d) { return yScale(+d.y); });
-
- var highLine = $wnd.d3.svg.line()
- .interpolate(interpolation)
- .x(function(d) { return timeScale(d.x); })
- .y(function(d) { return yScale(+d.high); });
-
- var lowLine = $wnd.d3.svg.line()
- .interpolate(interpolation)
- .x(function(d) { return timeScale(d.x); })
- .y(function(d) { return yScale(+d.low); });
-
- var svg = $wnd.d3.select(chartSelection).append("g")
- .attr("width", width + margin.left + margin.right)
- .attr("height", height + margin.top + margin.bottom)
- .attr("transform", "translate(" + margin.left + "," + margin.top + ")");
-
- svg.append("g")
- .attr("class", "x axis")
- .attr("transform", "translate(0," + height + ")")
- .call(xAxis);
-
-
- svg.append("g")
- .attr("class", "y axis")
- .call(yAxis)
- .append("text")
- .attr("transform", "rotate(-90)")
- .attr("y", -60)
- .attr("dy", ".71em")
- .style("text-anchor", "end")
- .text(yAxisUnits === "NONE" ? "" : yAxisUnits);
-
- console.log("finished axes");
-
- svg.append("path")
- .datum(data)
- .attr("class", "line")
- .attr("fill", "none")
- .attr("stroke", "steelblue")
- .attr("stroke-width", "2")
- .attr("d", line);
-
- svg.append("path")
- .datum(data)
- .attr("class", "highLine")
- .attr("fill", "none")
- .attr("stroke", "red")
- .attr("stroke-width", "1.5")
- //.attr("stroke-dasharray", "20,10,5,5,5,10")
- .attr("stroke-dasharray", "5,5")
- .attr("stroke-opacity", ".3")
- .attr("d", highLine);
-
- svg.append("path")
- .datum(data)
- .attr("class", "lowLine")
- .attr("fill", "none")
- .attr("stroke", "blue")
- .attr("stroke-width", "1.5")
- .attr("stroke-dasharray", "5,5")
- .attr("stroke-opacity", ".3")
- .attr("d", lowLine);
-
- console.log("finished paths");
- }(data);
-
- }-*/;
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/StackedBarMetricGraphImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/StackedBarMetricGraphImpl.java
index 9058ea5..67552d3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/StackedBarMetricGraphImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/StackedBarMetricGraphImpl.java
@@ -73,7 +73,8 @@ public class StackedBarMetricGraphImpl extends AbstractMetricGraph {
global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AbstractMetricGraph::getButtonBarDateTimeFormat()(),
global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AbstractMetricGraph::getChartSingleValueLabel()(),
global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AbstractMetricGraph::getXAxisTimeFormatHours()(),
- global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AbstractMetricGraph::getXAxisTimeFormatHoursMinutes()()
+ global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AbstractMetricGraph::getXAxisTimeFormatHoursMinutes()(),
+ global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AbstractMetricGraph::isHideLegend()()
);
@@ -217,8 +218,8 @@ public class StackedBarMetricGraphImpl extends AbstractMetricGraph {
.attr("transform", "translate(" + margin.left + "," + (+titleHeight + titleSpace + margin.top) + ")");
legendUnDefined = (typeof min === 'undefined') || (typeof avg === 'undefined') || (typeof peak === 'undefined');
- if (!useSmallCharts() && !legendUnDefined) {
- createMinAvgPeakSidePanel(chartContext.minChartTitle, min, chartContext.avgChartTitle, avg, chartContext.peakChartTitle, peak, chartContext.yAxisUnits);
+ if (!(chartContext.hideLegend && !useSmallCharts())) {
+ createMinAvgPeakSidePanel(chartContext.minChartTitle, min, chartContext.avgChartTitle, avg, chartContext.peakChartTitle, peak, chartContext.yAxisUnits);
}
}
@@ -693,7 +694,7 @@ public class StackedBarMetricGraphImpl extends AbstractMetricGraph {
}; // end public closure
}();
- if(typeof chartContext.data !== 'undefined' && chartContext.data.length > 0){
+ if(typeof chartContext.data !== 'undefined' && chartContext.data !== null && chartContext.data.length > 0){
metricStackedBarGraph.draw(chartContext);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/D3GroupGraphListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/D3GroupGraphListView.java
index 59737ac..a9789c6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/D3GroupGraphListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/D3GroupGraphListView.java
@@ -21,7 +21,6 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
-import java.util.EnumSet;
import java.util.List;
import com.google.gwt.core.client.GWT;
@@ -35,19 +34,17 @@ import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.DisplayType;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
-import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.ResourceGroupAvailability;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.AutoRefresh;
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractD3GraphListView;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityOverUnderGraphType;
import org.rhq.enterprise.gui.coregui.client.inventory.common.graph.MetricGraphData;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityOverUnderGraphType;
import org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.StackedBarMetricGraphImpl;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.MetricD3Graph;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.avail.AvailabilityD3GraphView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.Log;
import org.rhq.enterprise.gui.coregui.client.util.async.CountDownLatch;
@@ -55,7 +52,7 @@ import org.rhq.enterprise.gui.coregui.client.util.async.CountDownLatch;
* Build the Group version of the View that shows the individual graph views.
* @author Mike Thompson
*/
-public final class D3GroupGraphListView extends AbstractD3GraphListView implements AutoRefresh{
+public final class D3GroupGraphListView extends AbstractD3GraphListView implements AutoRefresh {
private ResourceGroup resourceGroup;
private VLayout graphsVLayout;
@@ -75,7 +72,8 @@ public final class D3GroupGraphListView extends AbstractD3GraphListView implemen
addMember(buttonBarDateTimeRangeEditor);
if (showAvailabilityGraph) {
- availabilityGraph = new AvailabilityD3GraphView<AvailabilityOverUnderGraphType>(new AvailabilityOverUnderGraphType(resourceGroup.getId()));
+ availabilityGraph = new AvailabilityD3GraphView<AvailabilityOverUnderGraphType>(
+ new AvailabilityOverUnderGraphType(resourceGroup.getId()));
addMember(availabilityGraph);
}
graphsVLayout = new VLayout();
@@ -89,7 +87,6 @@ public final class D3GroupGraphListView extends AbstractD3GraphListView implemen
addMember(graphsVLayout);
}
-
public void redrawGraphs() {
this.onDraw();
}
@@ -100,68 +97,60 @@ public final class D3GroupGraphListView extends AbstractD3GraphListView implemen
private void buildGraphs() {
queryAvailability(EntityContext.forGroup(resourceGroup), buttonBarDateTimeRangeEditor.getStartTime(),
- buttonBarDateTimeRangeEditor.getEndTime(), null);
+ buttonBarDateTimeRangeEditor.getEndTime(), null);
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(resourceGroup.getResourceType().getId(),
- EnumSet.of(ResourceTypeRepository.MetadataType.measurements),
- new ResourceTypeRepository.TypeLoadedCallback() {
- public void onTypesLoaded(final ResourceType type) {
+ final ArrayList<MeasurementDefinition> measurementDefinitions = new ArrayList<MeasurementDefinition>();
- final ArrayList<MeasurementDefinition> measurementDefinitions = new ArrayList<MeasurementDefinition>();
+ for (MeasurementDefinition def : resourceGroup.getResourceType().getMetricDefinitions()) {
+ if (def.getDataType() == DataType.MEASUREMENT && def.getDisplayType() == DisplayType.SUMMARY) {
+ measurementDefinitions.add(def);
+ }
+ }
- for (MeasurementDefinition def : type.getMetricDefinitions()) {
- if (def.getDataType() == DataType.MEASUREMENT && def.getDisplayType() == DisplayType.SUMMARY) {
- measurementDefinitions.add(def);
- }
- }
+ Collections.sort(measurementDefinitions, new Comparator<MeasurementDefinition>() {
+ public int compare(MeasurementDefinition o1, MeasurementDefinition o2) {
+ return new Integer(o1.getDisplayOrder()).compareTo(o2.getDisplayOrder());
+ }
+ });
- Collections.sort(measurementDefinitions, new Comparator<MeasurementDefinition>() {
- public int compare(MeasurementDefinition o1, MeasurementDefinition o2) {
- return new Integer(o1.getDisplayOrder()).compareTo(o2.getDisplayOrder());
- }
- });
+ int[] measDefIdArray = new int[measurementDefinitions.size()];
+ for (int i = 0; i < measDefIdArray.length; i++) {
+ measDefIdArray[i] = measurementDefinitions.get(i).getId();
+ }
- int[] measDefIdArray = new int[measurementDefinitions.size()];
- for (int i = 0; i < measDefIdArray.length; i++) {
- measDefIdArray[i] = measurementDefinitions.get(i).getId();
- }
+ GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroup(resourceGroup.getId(), measDefIdArray,
+ buttonBarDateTimeRangeEditor.getStartTime(), buttonBarDateTimeRangeEditor.getEndTime(), 60,
+ new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_loadFailed(), caught);
+ loadingLabel.setContents(MSG.view_resource_monitor_graphs_loadFailed());
+ }
- GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroup(resourceGroup.getId(),
- measDefIdArray, buttonBarDateTimeRangeEditor.getStartTime(), buttonBarDateTimeRangeEditor.getEndTime(), 60,
- new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_loadFailed(),
- caught);
- loadingLabel.setContents(MSG.view_resource_monitor_graphs_loadFailed());
- }
-
- @Override
- public void onSuccess(List<List<MeasurementDataNumericHighLowComposite>> result) {
- if (result.isEmpty()) {
- loadingLabel.setContents(MSG.view_resource_monitor_graphs_noneAvailable());
- } else {
- loadingLabel.hide();
- int i = 0;
- for (List<MeasurementDataNumericHighLowComposite> data : result) {
- buildIndividualGraph(measurementDefinitions.get(i++), data);
- }
- // There is a weird timing case when availabilityGraph can be null
- if (availabilityGraph != null) {
- availabilityGraph.setGroupAvailabilityList(groupAvailabilityList);
- new Timer(){
- @Override
- public void run() {
- availabilityGraph.drawJsniChart();
- }
- }.schedule(150);
- }
+ @Override
+ public void onSuccess(List<List<MeasurementDataNumericHighLowComposite>> result) {
+ if (result.isEmpty()) {
+ loadingLabel.setContents(MSG.view_resource_monitor_graphs_noneAvailable());
+ } else {
+ loadingLabel.hide();
+ int i = 0;
+ for (List<MeasurementDataNumericHighLowComposite> data : result) {
+ buildIndividualGraph(measurementDefinitions.get(i++), data);
+ }
+ // There is a weird timing case when availabilityGraph can be null
+ if (availabilityGraph != null) {
+ availabilityGraph.setGroupAvailabilityList(groupAvailabilityList);
+ new Timer() {
+ @Override
+ public void run() {
+ availabilityGraph.drawJsniChart();
}
- }
- });
-
+ }.schedule(150);
+ }
+ }
}
});
+
}
protected void queryAvailability(final EntityContext groupContext, Long startTime, Long endTime,
@@ -197,7 +186,7 @@ public final class D3GroupGraphListView extends AbstractD3GraphListView implemen
List<MeasurementDataNumericHighLowComposite> data) {
MetricGraphData metricGraphData = MetricGraphData.createForResourceGroup(resourceGroup.getId(),
- resourceGroup.getName(), measurementDefinition, data );
+ resourceGroup.getName(), measurementDefinition, data);
StackedBarMetricGraphImpl graph = GWT.create(StackedBarMetricGraphImpl.class);
graph.setMetricGraphData(metricGraphData);
@@ -207,11 +196,9 @@ public final class D3GroupGraphListView extends AbstractD3GraphListView implemen
graphView.setWidth("95%");
graphView.setHeight(MULTI_CHART_HEIGHT);
- if(graphsVLayout != null){
+ if (graphsVLayout != null) {
graphsVLayout.addMember(graphView);
}
}
-
-
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupMultiLineGraphListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupMultiLineGraphListView.java
new file mode 100644
index 0000000..101df60
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupMultiLineGraphListView.java
@@ -0,0 +1,79 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2012 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.table;
+
+
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.Messages;
+
+/**
+ * A MultiLine version of the Composite group single metric multiple resource charts.
+ *
+ * @author Mike Thompson
+ */
+public final class CompositeGroupMultiLineGraphListView extends CompositeGroupD3GraphListView
+{
+ private static final Messages MSG = CoreGUI.getMessages();
+
+ public CompositeGroupMultiLineGraphListView(int groupId, int defId, boolean isAutogroup)
+ {
+ super(groupId, defId, isAutogroup);
+ }
+
+
+
+ @Override
+ public native void drawJsniChart() /*-{
+ console.log("Draw nvd3 charts for composite multiline graph");
+ var chartId = global.@org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.table.CompositeGroupD3GraphListView::getChartId()(),
+ chartHandle = "#mChart-"+chartId,
+ chartSelection = chartHandle + " svg",
+ yAxisUnits = this.@org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.table.CompositeGroupD3GraphListView::getYAxisUnits()(),
+ xAxisLabel = this.@org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.table.CompositeGroupD3GraphListView::getXAxisTitle()(),
+ xAxisTimeFormat = this.@org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.table.CompositeGroupMultiLineGraphListView::getXAxisTimeFormatHoursMinutes()();
+ json = eval(this.@org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.table.CompositeGroupD3GraphListView::getJsonMetrics()());
+
+ $wnd.nv.addGraph(function() {
+ var chart = $wnd.nv.models.lineChart();
+
+ chart.xAxis.axisLabel(xAxisLabel)
+ .tickFormat(function(d) { return $wnd.d3.time.format(xAxisTimeFormat)(new Date(d)) });
+
+ chart.yAxis
+ .axisLabel(yAxisUnits)
+ .tickFormat($wnd.d3.format('.02f'));
+
+ $wnd.d3.select(chartSelection)
+ .datum(json)
+ .transition().duration(300)
+ .call(chart);
+
+ $wnd.nv.utils.windowResize(chart.update);
+
+ return chart;
+ });
+
+ }-*/;
+
+
+
+ public String getXAxisTimeFormatHoursMinutes() {
+ return MSG.chart_xaxis_time_format_hours_minutes();
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/DashboardLinkUtility.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/DashboardLinkUtility.java
new file mode 100644
index 0000000..8ca1ac5
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/DashboardLinkUtility.java
@@ -0,0 +1,258 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TreeSet;
+
+import com.google.gwt.http.client.Request;
+import com.google.gwt.http.client.RequestBuilder;
+import com.google.gwt.http.client.RequestCallback;
+import com.google.gwt.http.client.RequestException;
+import com.google.gwt.http.client.Response;
+import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.menu.Menu;
+import com.smartgwt.client.widgets.menu.MenuItem;
+import com.smartgwt.client.widgets.menu.events.ClickHandler;
+import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.DashboardCriteria;
+import org.rhq.core.domain.criteria.SubjectCriteria;
+import org.rhq.core.domain.dashboard.Dashboard;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.core.domain.measurement.DataType;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.MeasurementSchedule;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.Messages;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.ResourceD3GraphPortlet;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.Log;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.preferences.MeasurementUserPreferences;
+import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
+
+/**
+ * Utility Class to build menus for linking to the Dashboard.
+ * @author Jay Shaughnessy
+ * @author Greg Hinkle
+ * @author Mike Thompson
+ */
+public class DashboardLinkUtility {
+ final static Messages MSG = CoreGUI.getMessages();
+
+ private DashboardLinkUtility() {
+ }
+
+ public static MenuItem buildMetricsMenu(final ResourceType resourceType, final Resource resource, String label) {
+
+ MenuItem measurements = new MenuItem(label);
+ final Menu measurementsSubMenu = new Menu();
+
+ DashboardCriteria criteria = new DashboardCriteria();
+ GWTServiceLookup.getDashboardService().findDashboardsByCriteria(criteria,
+ new AsyncCallback<PageList<Dashboard>>() {
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_contextMenu_loadFailed_dashboard(),
+ caught);
+ }
+
+ public void onSuccess(PageList<Dashboard> result) {
+ //sort the display items alphabetically
+ TreeSet<String> ordered = new TreeSet<String>();
+ Map<String, MeasurementDefinition> definitionMap = new HashMap<String, MeasurementDefinition>();
+ for (MeasurementDefinition m : resourceType.getMetricDefinitions()) {
+ ordered.add(m.getDisplayName());
+ definitionMap.put(m.getDisplayName(), m);
+ }
+
+ for (String displayName : ordered) {
+ final MeasurementDefinition def = definitionMap.get(displayName);
+ //only add menu items for Measurement
+ if (def.getDataType().equals(DataType.MEASUREMENT)) {
+ MenuItem defItem = new MenuItem(def.getDisplayName());
+ measurementsSubMenu.addItem(defItem);
+ Menu defSubItem = new Menu();
+ defItem.setSubmenu(defSubItem);
+
+ for (final Dashboard d : result) {
+ MenuItem addToDBItem = new MenuItem(MSG
+ .view_tree_common_contextMenu_addChartToDashboard(d.getName()));
+ defSubItem.addItem(addToDBItem);
+
+ addToDBItem.addClickHandler(new ClickHandler() {
+
+ public void onClick(MenuItemClickEvent menuItemClickEvent) {
+ DashboardPortlet p = new DashboardPortlet(MSG
+ .view_tree_common_contextMenu_resourceGraph(), ResourceD3GraphPortlet.KEY,
+ 250);
+ p.getConfiguration()
+ .put(
+ new PropertySimple(ResourceD3GraphPortlet.CFG_RESOURCE_ID, resource
+ .getId()));
+ p.getConfiguration().put(
+ new PropertySimple(ResourceD3GraphPortlet.CFG_DEFINITION_ID, def.getId()));
+
+ d.addPortlet(p);
+
+ GWTServiceLookup.getDashboardService().storeDashboard(d,
+ new AsyncCallback<Dashboard>() {
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_tree_common_contextMenu_saveChartToDashboardFailure(),
+ caught);
+ }
+
+ public void onSuccess(Dashboard result) {
+ CoreGUI
+ .getMessageCenter()
+ .notify(
+ new Message(
+ MSG.view_tree_common_contextMenu_saveChartToDashboardSuccessful(result
+ .getName()), Message.Severity.Info));
+ }
+ });
+
+ }
+
+ });
+
+ }
+
+ //add new menu item for adding current graphable element to view if on Monitor/Graphs tab
+ String currentViewPath = History.getToken();
+ if (currentViewPath.contains("Monitoring/Metrics")) {
+ MenuItem addGraphItem = new MenuItem(MSG.common_title_add_graph_to_view());
+ defSubItem.addItem(addGraphItem);
+
+ addGraphItem.addClickHandler(new ClickHandler() {
+ public void onClick(MenuItemClickEvent menuItemClickEvent) {
+ //generate javascript to call out to.
+ //Ex. menuLayers.hide();addMetric('${metric.resourceId},${metric.scheduleId}')
+ if (getScheduleDefinitionId(resource, def.getName()) > -1) {
+ final String resourceGraphElements = resource.getId() + ","
+ + getScheduleDefinitionId(resource, def.getName());
+
+ //Once, the portal-war will be rewritten to GWT and operations performed
+ //within the iframe + JSF will update the user preferences, the following
+ //2 lines could be uncommented and the lines below them refactorized
+ //MeasurementUserPreferences measurementPreferences = new MeasurementUserPreferences(UserSessionManager.getUserPreferences());
+ //String selectedView = measurementPreferences.getSelectedView(String.valueOf(resource.getId()));
+
+ final int sid = UserSessionManager.getSessionSubject().getId();
+ SubjectCriteria c = new SubjectCriteria();
+ c.addFilterId(sid);
+
+ GWTServiceLookup.getSubjectService().findSubjectsByCriteria(c,
+ new AsyncCallback<PageList<Subject>>() {
+ public void onSuccess(PageList<Subject> result) {
+ if (result.size() > 0) {
+ UserPreferences uPreferences = new UserPreferences(result
+ .get(0));
+ MeasurementUserPreferences mPreferences = new MeasurementUserPreferences(
+ uPreferences);
+ String selectedView = mPreferences.getSelectedView(String
+ .valueOf(resource.getId()));
+
+ addNewMetric(String.valueOf(resource.getId()),
+ selectedView, resourceGraphElements);
+ } else {
+ Log.warn("DashboardLinkUtility: Error obtaining subject with id:" + sid);
+ }
+ }
+
+ public void onFailure(Throwable caught) {
+ Log.warn("DashboardLinkUtility: Error obtaining subject with id:" + sid, caught);
+ }
+ });
+ }
+ }
+ });
+ }
+ }
+ }
+
+ }
+ });
+ measurements.setSubmenu(measurementsSubMenu);
+ return measurements;
+ }
+
+ /** Locate the specific schedule definition using the definition identifier.
+ */
+ private static int getScheduleDefinitionId(Resource resource, String definitionName) {
+ int id = -1;
+ if (resource.getSchedules() != null) {
+ boolean located = false;
+ MeasurementSchedule[] schedules = new MeasurementSchedule[resource.getSchedules().size()];
+ resource.getSchedules().toArray(schedules);
+ for (int i = 0; (!located && i < resource.getSchedules().size()); i++) {
+ MeasurementSchedule schedule = schedules[i];
+ MeasurementDefinition definition = schedule.getDefinition();
+ if ((definition != null) && definition.getName().equals(definitionName)) {
+ located = true;
+ id = schedule.getId();
+ }
+ }
+ }
+ return id;
+ }
+
+ private static void addNewMetric(String id, String selectedView, String resourceGraphElements) {
+ //construct portal.war url to access
+ String baseUrl = "/resource/common/monitor/visibility/IndicatorCharts.do";
+ baseUrl += "?id=" + id;
+ baseUrl += "&view=" + selectedView;
+ baseUrl += "&action=addChart&metric=" + resourceGraphElements;
+ final String url = baseUrl;
+ //initiate HTTP request
+ final RequestBuilder b = new RequestBuilder(RequestBuilder.GET, baseUrl);
+
+ try {
+ b.setCallback(new RequestCallback() {
+ public void onResponseReceived(final Request request, final Response response) {
+ Log.trace("Successfully submitted request to add graph to view:" + url);
+
+ //kick off a page reload.
+ String currentViewPath = History.getToken();
+ CoreGUI.goToView(currentViewPath, true);
+ }
+
+ @Override
+ public void onError(Request request, Throwable t) {
+ Log.trace("Error adding Metric:" + url, t);
+ }
+ });
+ b.send();
+ } catch (RequestException e) {
+ Log.warn("Error adding Metric:" + url, e);
+ }
+
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index 2d33d66..ae51195 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -66,9 +66,8 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory.ResourceAgentView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.CalltimeView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.D3GraphListView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.avail.ResourceAvailabilityView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.schedules.ResourceSchedulesView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.table.MeasurementTableView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.table.MetricsResourceView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.traits.TraitsView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryListView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.schedule.ResourceOperationScheduleListView;
@@ -129,10 +128,8 @@ public class ResourceDetailView extends
private SubTab summaryActivity;
private SubTab summaryTimeline;
- private SubTab monitorGraphs;
private SubTab monitorMetrics;
private SubTab monitorTraits;
- private SubTab monitorAvail;
private SubTab monitorSched;
private SubTab monitorCallTime;
private SubTab inventoryChildren;
@@ -196,16 +193,11 @@ public class ResourceDetailView extends
monitoringTab = new TwoLevelTab(new ViewName("Monitoring", MSG.view_tabs_common_monitoring()),
IconEnum.SUSPECT_METRICS);
- monitorGraphs = new SubTab(monitoringTab, new ViewName("Graphs", MSG.view_tabs_common_graphs()), null);
-
- monitorMetrics = new SubTab(monitoringTab, new ViewName("Metrics", "Metrics"), null);
+ monitorMetrics = new SubTab(monitoringTab, new ViewName("Metrics", MSG.view_tabs_common_metrics()), null);
monitorTraits = new SubTab(monitoringTab, new ViewName("Traits", MSG.view_tabs_common_traits()), null);
- monitorAvail = new SubTab(monitoringTab, new ViewName("Availability", MSG.view_tabs_common_availability()),
- null);
monitorSched = new SubTab(monitoringTab, new ViewName("Schedules", MSG.view_tabs_common_schedules()), null);
monitorCallTime = new SubTab(monitoringTab, new ViewName("CallTime", MSG.view_tabs_common_calltime()), null);
- monitoringTab.registerSubTabs(monitorGraphs, monitorMetrics, monitorTraits, monitorAvail,
- monitorSched, monitorCallTime);
+ monitoringTab.registerSubTabs( monitorMetrics, monitorTraits, monitorSched, monitorCallTime);
tabs.add(monitoringTab);
eventsTab = new TwoLevelTab(new ViewName("Events", MSG.view_tabs_common_events()), IconEnum.EVENTS);
@@ -395,22 +387,14 @@ public class ResourceDetailView extends
boolean visibleToIE8 = !BrowserUtility.isBrowserPreIE9();
- viewFactory = (!visibleToIE8) ? null : new ViewFactory() {
- @Override
- public Canvas createView() {
- return createD3GraphListView();
- }
- };
- updateSubTab(this.monitoringTab, this.monitorGraphs, visible, visibleToIE8, viewFactory);
-
// visible = same test as above
viewFactory = (!visible) ? null : new ViewFactory() {
@Override
public Canvas createView() {
- return new MeasurementTableView(resource.getId());
+ return new MetricsResourceView(resource);
}
};
- updateSubTab(this.monitoringTab, this.monitorMetrics, visible, true, viewFactory);
+ updateSubTab(this.monitoringTab, this.monitorMetrics, visible, visibleToIE8, viewFactory);
visible = hasMetricsOfType(this.resourceComposite, DataType.TRAIT);
viewFactory = (!visible) ? null : new ViewFactory() {
@@ -421,13 +405,6 @@ public class ResourceDetailView extends
};
updateSubTab(this.monitoringTab, this.monitorTraits, visible, true, viewFactory);
- updateSubTab(this.monitoringTab, this.monitorAvail, true, true, new ViewFactory() {
- @Override
- public Canvas createView() {
- return new ResourceAvailabilityView(resourceComposite);
- }
- });
-
updateSubTab(this.monitoringTab, this.monitorSched, hasMetricsOfType(this.resourceComposite, null), true,
new ViewFactory() {
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index 071f831..a3990bb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -32,11 +32,6 @@ import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
-import com.google.gwt.http.client.Request;
-import com.google.gwt.http.client.RequestBuilder;
-import com.google.gwt.http.client.RequestCallback;
-import com.google.gwt.http.client.RequestException;
-import com.google.gwt.http.client.Response;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSCallback;
@@ -60,17 +55,8 @@ import com.smartgwt.client.widgets.tree.events.DataArrivedHandler;
import com.smartgwt.client.widgets.tree.events.NodeContextClickEvent;
import com.smartgwt.client.widgets.tree.events.NodeContextClickHandler;
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.criteria.DashboardCriteria;
import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
-import org.rhq.core.domain.criteria.SubjectCriteria;
-import org.rhq.core.domain.dashboard.Dashboard;
-import org.rhq.core.domain.dashboard.DashboardPortlet;
-import org.rhq.core.domain.measurement.DataType;
-import org.rhq.core.domain.measurement.MeasurementDefinition;
-import org.rhq.core.domain.measurement.MeasurementSchedule;
import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
@@ -82,11 +68,9 @@ import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
-import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.tree.EnhancedTreeNode;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.ResourceD3GraphPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync;
@@ -101,8 +85,6 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTyp
import org.rhq.enterprise.gui.coregui.client.util.Log;
import org.rhq.enterprise.gui.coregui.client.util.enhanced.EnhancedVLayout;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import org.rhq.enterprise.gui.coregui.client.util.preferences.MeasurementUserPreferences;
-import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
/**
* @author Jay Shaughnessy
@@ -562,7 +544,7 @@ public class ResourceTreeView extends EnhancedVLayout {
resourceContextMenu.addItem(operations);
// Metric graph addition menu
- resourceContextMenu.addItem(buildMetricsMenu(resourceType, resource));
+ resourceContextMenu.addItem(DashboardLinkUtility.buildMetricsMenu(resourceType, resource, MSG.view_tree_common_contextMenu_measurements()));
// Create Child Menu and Manual Import Menu
final Set<ResourceType> creatableChildTypes = getCreatableChildTypes(resourceType);
@@ -725,190 +707,6 @@ public class ResourceTreeView extends EnhancedVLayout {
tree.reloadChildren(refreshNode);
}
- private MenuItem buildMetricsMenu(final ResourceType type, final Resource resource) {
- MenuItem measurements = new MenuItem(MSG.view_tree_common_contextMenu_measurements());
- final Menu measurementsSubMenu = new Menu();
-
- DashboardCriteria criteria = new DashboardCriteria();
- GWTServiceLookup.getDashboardService().findDashboardsByCriteria(criteria,
- new AsyncCallback<PageList<Dashboard>>() {
-
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_contextMenu_loadFailed_dashboard(),
- caught);
- }
-
- public void onSuccess(PageList<Dashboard> result) {
- //sort the display items alphabetically
- TreeSet<String> ordered = new TreeSet<String>();
- Map<String, MeasurementDefinition> definitionMap = new HashMap<String, MeasurementDefinition>();
- for (MeasurementDefinition m : type.getMetricDefinitions()) {
- ordered.add(m.getDisplayName());
- definitionMap.put(m.getDisplayName(), m);
- }
-
- for (String displayName : ordered) {
- final MeasurementDefinition def = definitionMap.get(displayName);
- //only add menu items for Measurement
- if (def.getDataType().equals(DataType.MEASUREMENT)) {
- MenuItem defItem = new MenuItem(def.getDisplayName());
- measurementsSubMenu.addItem(defItem);
- Menu defSubItem = new Menu();
- defItem.setSubmenu(defSubItem);
-
- for (final Dashboard d : result) {
- MenuItem addToDBItem = new MenuItem(MSG
- .view_tree_common_contextMenu_addChartToDashboard(d.getName()));
- defSubItem.addItem(addToDBItem);
-
- addToDBItem.addClickHandler(new ClickHandler() {
-
- public void onClick(MenuItemClickEvent menuItemClickEvent) {
- DashboardPortlet p = new DashboardPortlet(MSG
- .view_tree_common_contextMenu_resourceGraph(), ResourceD3GraphPortlet.KEY,
- 250);
- p.getConfiguration().put(
- new PropertySimple(ResourceD3GraphPortlet.CFG_RESOURCE_ID, resource.getId()));
- p.getConfiguration().put(
- new PropertySimple(ResourceD3GraphPortlet.CFG_DEFINITION_ID, def.getId()));
-
- d.addPortlet(p);
-
- GWTServiceLookup.getDashboardService().storeDashboard(d,
- new AsyncCallback<Dashboard>() {
-
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(
- MSG.view_tree_common_contextMenu_saveChartToDashboardFailure(),
- caught);
- }
-
- public void onSuccess(Dashboard result) {
- CoreGUI
- .getMessageCenter()
- .notify(
- new Message(
- MSG.view_tree_common_contextMenu_saveChartToDashboardSuccessful(result
- .getName()), Message.Severity.Info));
- }
- });
-
- }
-
- });
-
-
- }//end dashboard iteration
-
- //add new menu item for adding current graphable element to view if on Monitor/Graphs tab
- String currentViewPath = History.getToken();
- if (currentViewPath.contains("Monitoring/NewGraphs")) {
- MenuItem addGraphItem = new MenuItem(MSG.common_title_add_graph_to_view());
- defSubItem.addItem(addGraphItem);
-
- addGraphItem.addClickHandler(new ClickHandler() {
- public void onClick(MenuItemClickEvent menuItemClickEvent) {
- //generate javascript to call out to.
- //Ex. menuLayers.hide();addMetric('${metric.resourceId},${metric.scheduleId}')
- if (getScheduleDefinitionId(resource, def.getName()) > -1) {
- final String resourceGraphElements = resource.getId() + ","
- + getScheduleDefinitionId(resource, def.getName());
-
- //Once, the portal-war will be rewritten to GWT and operations performed
- //within the iframe + JSF will update the user preferences, the following
- //2 lines could be uncommented and the lines below them refactorized
- //MeasurementUserPreferences measurementPreferences = new MeasurementUserPreferences(UserSessionManager.getUserPreferences());
- //String selectedView = measurementPreferences.getSelectedView(String.valueOf(resource.getId()));
-
- final int sid = UserSessionManager.getSessionSubject().getId();
- SubjectCriteria c = new SubjectCriteria();
- c.addFilterId(sid);
-
- GWTServiceLookup.getSubjectService().findSubjectsByCriteria(c,
- new AsyncCallback<PageList<Subject>>() {
- public void onSuccess(PageList<Subject> result) {
- if (result.size() > 0) {
- UserPreferences uPreferences = new UserPreferences(result
- .get(0));
- MeasurementUserPreferences mPreferences = new MeasurementUserPreferences(
- uPreferences);
- String selectedView = mPreferences.getSelectedView(String
- .valueOf(resource.getId()));
-
- addNewMetric(String.valueOf(resource.getId()),
- selectedView, resourceGraphElements);
- } else {
- Log.trace("Error obtaining subject with id:" + sid);
- }
- }
-
- public void onFailure(Throwable caught) {
- Log.trace("Error obtaining subject with id:" + sid, caught);
- }
- });
- }
- }
- });
- } // end add the "add to view" menu item
- }//end trait exclusion
- }//end measurement def iteration
-
- }
- });
- measurements.setSubmenu(measurementsSubMenu);
- return measurements;
- }
-
- private void addNewMetric(String id, String selectedView, String resourceGraphElements) {
- //construct portal.war url to access
- String baseUrl = "/resource/common/monitor/visibility/IndicatorCharts.do";
- baseUrl += "?id=" + id;
- baseUrl += "&view=" + selectedView;
- baseUrl += "&action=addChart&metric=" + resourceGraphElements;
- final String url = baseUrl;
- //initiate HTTP request
- final RequestBuilder b = new RequestBuilder(RequestBuilder.GET, baseUrl);
-
- try {
- b.setCallback(new RequestCallback() {
- public void onResponseReceived(final Request request, final Response response) {
- Log.trace("Successfully submitted request to add graph to view:" + url);
-
- //kick off a page reload.
- String currentViewPath = History.getToken();
- CoreGUI.goToView(currentViewPath, true);
- }
-
- @Override
- public void onError(Request request, Throwable t) {
- Log.trace("Error adding Metric:" + url, t);
- }
- });
- b.send();
- } catch (RequestException e) {
- Log.trace("Error adding Metric:" + url, e);
- }
- }
-
- /** Locate the specific schedule definition using the definition identifier.
- */
- private int getScheduleDefinitionId(Resource resource, String definitionName) {
- int id = -1;
- if (resource.getSchedules() != null) {
- boolean located = false;
- MeasurementSchedule[] schedules = new MeasurementSchedule[resource.getSchedules().size()];
- resource.getSchedules().toArray(schedules);
- for (int i = 0; (!located && i < resource.getSchedules().size()); i++) {
- MeasurementSchedule schedule = schedules[i];
- MeasurementDefinition definition = schedule.getDefinition();
- if ((definition != null) && definition.getName().equals(definitionName)) {
- located = true;
- id = schedule.getId();
- }
- }
- }
- return id;
- }
private void setRootResource(Resource rootResource) {
this.rootResource = rootResource;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/D3GraphListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/D3GraphListView.java
index 65893ce..8b9f327 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/D3GraphListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/D3GraphListView.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2012 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -21,7 +21,6 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitori
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
-import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
@@ -30,7 +29,6 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Overflow;
-import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.common.EntityContext;
@@ -41,16 +39,14 @@ import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
import org.rhq.core.domain.measurement.composite.MeasurementOOBComposite;
import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractD3GraphListView;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityOverUnderGraphType;
import org.rhq.enterprise.gui.coregui.client.inventory.common.graph.MetricGraphData;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityOverUnderGraphType;
import org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.StackedBarMetricGraphImpl;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.avail.AvailabilityD3GraphView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.Log;
import org.rhq.enterprise.gui.coregui.client.util.async.Command;
import org.rhq.enterprise.gui.coregui.client.util.async.CountDownLatch;
@@ -115,17 +111,17 @@ public class D3GraphListView extends AbstractD3GraphListView {
setOverflow(Overflow.HIDDEN);
}
-
@Override
protected void onDraw() {
super.onDraw();
- Log.debug("D3GraphListView.onDraw() for: " + resource.getName()+ " id: "+ resource.getId());
+ Log.debug("D3GraphListView.onDraw() for: " + resource.getName() + " id: " + resource.getId());
destroyMembers();
addMember(buttonBarDateTimeRangeEditor);
if (showAvailabilityGraph) {
- availabilityGraph = new AvailabilityD3GraphView<AvailabilityOverUnderGraphType>(new AvailabilityOverUnderGraphType(resource.getId()));
+ availabilityGraph = new AvailabilityD3GraphView<AvailabilityOverUnderGraphType>(
+ new AvailabilityOverUnderGraphType(resource.getId()));
addMember(availabilityGraph);
}
@@ -163,8 +159,8 @@ public class D3GraphListView extends AbstractD3GraphListView {
@Override
public void onSuccess(List<Availability> availList) {
- Log.debug("\nSuccessfully queried availability in: "
- + (System.currentTimeMillis() - timerStart) + " ms.");
+ Log.debug("\nSuccessfully queried availability in: " + (System.currentTimeMillis() - timerStart)
+ + " ms.");
availabilityList = availList;
if (countDownLatch != null) {
countDownLatch.countDown();
@@ -180,193 +176,179 @@ public class D3GraphListView extends AbstractD3GraphListView {
private void queryAndBuildGraphs() {
final long startTimer = System.currentTimeMillis();
- if(null != availabilityGraph){
+ if (null != availabilityGraph) {
queryAvailability(EntityContext.forResource(resource.getId()), buttonBarDateTimeRangeEditor.getStartTime(),
buttonBarDateTimeRangeEditor.getEndTime(), null);
}
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(resource.getResourceType().getId(),
- EnumSet.of(ResourceTypeRepository.MetadataType.measurements),
- new ResourceTypeRepository.TypeLoadedCallback() {
- public void onTypesLoaded(final ResourceType type) {
+ final ArrayList<MeasurementDefinition> measurementDefinitions = new ArrayList<MeasurementDefinition>();
+ final ArrayList<MeasurementDefinition> summaryMeasurementDefinitions = new ArrayList<MeasurementDefinition>();
- final ArrayList<MeasurementDefinition> measurementDefinitions = new ArrayList<MeasurementDefinition>();
- final ArrayList<MeasurementDefinition> summaryMeasurementDefinitions = new ArrayList<MeasurementDefinition>();
+ for (MeasurementDefinition def : resource.getResourceType().getMetricDefinitions()) {
+ if (def.getDataType() == DataType.MEASUREMENT && def.getDisplayType() == DisplayType.SUMMARY) {
+ summaryMeasurementDefinitions.add(def);
+ }
+ measurementDefinitions.add(def);
+ }
- for (MeasurementDefinition def : type.getMetricDefinitions()) {
- if (def.getDataType() == DataType.MEASUREMENT && def.getDisplayType() == DisplayType.SUMMARY) {
- summaryMeasurementDefinitions.add(def);
- }
- measurementDefinitions.add(def);
- }
+ Collections.sort(measurementDefinitions, new Comparator<MeasurementDefinition>() {
+ @Override
+ public int compare(MeasurementDefinition o1, MeasurementDefinition o2) {
+ return new Integer(o1.getDisplayOrder()).compareTo(o2.getDisplayOrder());
+ }
+ });
+ Collections.sort(summaryMeasurementDefinitions, new Comparator<MeasurementDefinition>() {
+ @Override
+ public int compare(MeasurementDefinition o1, MeasurementDefinition o2) {
+ return new Integer(o1.getDisplayOrder()).compareTo(o2.getDisplayOrder());
+ }
+ });
+
+ int[] measDefIdArray = new int[measurementDefinitions.size()];
+ for (int i = 0; i < measDefIdArray.length; i++) {
+ measDefIdArray[i] = measurementDefinitions.get(i).getId();
+ }
- Collections.sort(measurementDefinitions, new Comparator<MeasurementDefinition>() {
- @Override
- public int compare(MeasurementDefinition o1, MeasurementDefinition o2) {
- return new Integer(o1.getDisplayOrder()).compareTo(o2.getDisplayOrder());
- }
- });
- Collections.sort(summaryMeasurementDefinitions, new Comparator<MeasurementDefinition>() {
- @Override
- public int compare(MeasurementDefinition o1, MeasurementDefinition o2) {
- return new Integer(o1.getDisplayOrder()).compareTo(o2.getDisplayOrder());
- }
- });
-
- int[] measDefIdArray = new int[measurementDefinitions.size()];
- for (int i = 0; i < measDefIdArray.length; i++) {
- measDefIdArray[i] = measurementDefinitions.get(i).getId();
+ // setting up a deferred Command to execute after all resource queries have completed (successfully or unsuccessfully)
+ // we know there are exactly 2 resources
+ final CountDownLatch countDownLatch = CountDownLatch.create(NUM_ASYNC_CALLS, new Command() {
+ @Override
+ /**
+ * Satisfied only after ALL of the metric queries AND availability have completed
+ */
+ public void execute() {
+ Log.debug("Total Time for async metrics/avail query: " + (System.currentTimeMillis() - startTimer));
+ if (null == metricsDataList || metricsDataList.isEmpty()) {
+ loadingLabel.setContents(MSG.view_resource_monitor_graphs_noneAvailable());
+ } else {
+ loadingLabel.hide();
+ if (useSummaryData) {
+ buildSummaryGraphs(metricsDataList, summaryMeasurementDefinitions, measurementDefinitions);
+ } else {
+ determineGraphsToBuild(metricsDataList, measurementDefinitions, definitionIds);
}
-
- // setting up a deferred Command to execute after all resource queries have completed (successfully or unsuccessfully)
- // we know there are exactly 2 resources
- final CountDownLatch countDownLatch = CountDownLatch.create(NUM_ASYNC_CALLS, new Command() {
- @Override
- /**
- * Satisfied only after ALL of the metric queries AND availability have completed
- */
- public void execute() {
- Log.debug("Total Time for async metrics/avail query: "
- + (System.currentTimeMillis() - startTimer));
- if (null == metricsDataList || metricsDataList.isEmpty()) {
- loadingLabel.setContents(MSG.view_resource_monitor_graphs_noneAvailable());
- } else {
- loadingLabel.hide();
- if (useSummaryData) {
- buildSummaryGraphs(metricsDataList, summaryMeasurementDefinitions,
- measurementDefinitions);
- } else {
- determineGraphsToBuild(metricsDataList, measurementDefinitions, definitionIds);
- }
- // There is a weird timing case when availabilityGraph can be null
- if (null != availabilityGraph) {
- // we only need the first metricData since we are only taking the
- // availability data set in there for the dropdowns already
- availabilityGraph.setAvailabilityList(availabilityList);
- new Timer(){
- @Override
- public void run() {
- availabilityGraph.drawJsniChart();
- }
- }.schedule(150);
- }
+ // There is a weird timing case when availabilityGraph can be null
+ if (null != availabilityGraph) {
+ // we only need the first metricData since we are only taking the
+ // availability data set in there for the dropdowns already
+ availabilityGraph.setAvailabilityList(availabilityList);
+ new Timer() {
+ @Override
+ public void run() {
+ availabilityGraph.drawJsniChart();
}
+ }.schedule(150);
+ }
+ }
- }
- });
+ }
+ });
- queryMetricData(measDefIdArray, countDownLatch);
- queryOOBMetrics(resource, countDownLatch);
- // now the countDown latch will run sometime asynchronously
+ queryMetricData(measDefIdArray, countDownLatch);
+ queryOOBMetrics(resource, countDownLatch);
+ // now the countDown latch will run sometime asynchronously
+ }
+ private void queryMetricData(final int[] measDefIdArray, final CountDownLatch countDownLatch) {
+ GWTServiceLookup.getMeasurementDataService().findDataForResource(resource.getId(), measDefIdArray,
+ buttonBarDateTimeRangeEditor.getStartTime(), buttonBarDateTimeRangeEditor.getEndTime(), 60,
+ new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_loadFailed(), caught);
+ loadingLabel.setContents(MSG.view_resource_monitor_graphs_loadFailed());
+ countDownLatch.countDown();
}
- private void queryMetricData(final int[] measDefIdArray, final CountDownLatch countDownLatch) {
- GWTServiceLookup.getMeasurementDataService().findDataForResource(resource.getId(), measDefIdArray,
- buttonBarDateTimeRangeEditor.getStartTime(), buttonBarDateTimeRangeEditor.getEndTime(), 60,
- new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_loadFailed(),
- caught);
- loadingLabel.setContents(MSG.view_resource_monitor_graphs_loadFailed());
- countDownLatch.countDown();
- }
-
- @Override
- public void onSuccess(List<List<MeasurementDataNumericHighLowComposite>> metrics) {
- metricsDataList = metrics;
- Log.debug("Regular Metric graph data queried in: "
- + (System.currentTimeMillis() - startTimer + " ms."));
- countDownLatch.countDown();
+ @Override
+ public void onSuccess(List<List<MeasurementDataNumericHighLowComposite>> metrics) {
+ metricsDataList = metrics;
+ countDownLatch.countDown();
- }
- });
}
+ });
+ }
- private void queryOOBMetrics(final Resource resource, final CountDownLatch countDownLatch) {
+ private void queryOOBMetrics(final Resource resource, final CountDownLatch countDownLatch) {
- final long startTime = System.currentTimeMillis();
+ final long startTime = System.currentTimeMillis();
- GWTServiceLookup.getMeasurementDataService().getHighestNOOBsForResource(resource.getId(), 60,
+ GWTServiceLookup.getMeasurementDataService().getHighestNOOBsForResource(resource.getId(), 60,
- new AsyncCallback<PageList<MeasurementOOBComposite>>() {
- @Override
- public void onSuccess(PageList<MeasurementOOBComposite> measurementOOBComposites) {
+ new AsyncCallback<PageList<MeasurementOOBComposite>>() {
+ @Override
+ public void onSuccess(PageList<MeasurementOOBComposite> measurementOOBComposites) {
- measurementOOBCompositeList = measurementOOBComposites;
- Log.debug("\nSuccessfully queried "+measurementOOBCompositeList.size() +" OOB records in: " + (System.currentTimeMillis() - startTime)
- + " ms.");
- countDownLatch.countDown();
- }
+ measurementOOBCompositeList = measurementOOBComposites;
+ Log.debug("\nSuccessfully queried " + measurementOOBCompositeList.size() + " OOB records in: "
+ + (System.currentTimeMillis() - startTime) + " ms.");
+ countDownLatch.countDown();
+ }
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving out of bound metrics for resource [" + resource.getId() + "]:"
- + caught.getMessage());
- countDownLatch.countDown();
- }
- });
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving out of bound metrics for resource [" + resource.getId() + "]:"
+ + caught.getMessage());
+ countDownLatch.countDown();
+ }
+ });
- }
+ }
- /**
- * Spin through the measurement definitions (in order) checking to see if they are in the
- * summary measurement definition set and if so build a graph.
- * @param measurementData
- * @param summaryMeasurementDefinitions
- * @param measurementDefinitions
- */
- private void buildSummaryGraphs(List<List<MeasurementDataNumericHighLowComposite>> measurementData,
- List<MeasurementDefinition> summaryMeasurementDefinitions,
- List<MeasurementDefinition> measurementDefinitions) {
- Set<Integer> summaryIds = new TreeSet<Integer>();
- for (MeasurementDefinition summaryMeasurementDefinition : summaryMeasurementDefinitions) {
- summaryIds.add(summaryMeasurementDefinition.getId());
- }
+ /**
+ * Spin through the measurement definitions (in order) checking to see if they are in the
+ * summary measurement definition set and if so build a graph.
+ * @param measurementData
+ * @param summaryMeasurementDefinitions
+ * @param measurementDefinitions
+ */
+ private void buildSummaryGraphs(List<List<MeasurementDataNumericHighLowComposite>> measurementData,
+ List<MeasurementDefinition> summaryMeasurementDefinitions, List<MeasurementDefinition> measurementDefinitions) {
+ Set<Integer> summaryIds = new TreeSet<Integer>();
+ for (MeasurementDefinition summaryMeasurementDefinition : summaryMeasurementDefinitions) {
+ summaryIds.add(summaryMeasurementDefinition.getId());
+ }
- int i = 0;
- for (MeasurementDefinition measurementDefinition : measurementDefinitions) {
- if (summaryIds.contains(measurementDefinition.getId())) {
- buildSingleGraph(measurementOOBCompositeList, measurementDefinition,
- measurementData.get(i), MULTI_CHART_HEIGHT);
- }
- i++;
- }
+ int i = 0;
+ for (MeasurementDefinition measurementDefinition : measurementDefinitions) {
+ if (summaryIds.contains(measurementDefinition.getId())) {
+ buildSingleGraph(measurementOOBCompositeList, measurementDefinition, measurementData.get(i),
+ MULTI_CHART_HEIGHT);
+ }
+ i++;
+ }
- }
+ }
- private void determineGraphsToBuild(List<List<MeasurementDataNumericHighLowComposite>> measurementData,
- List<MeasurementDefinition> measurementDefinitions, Set<Integer> definitionIds) {
- int i = 0;
- for (List<MeasurementDataNumericHighLowComposite> metric : measurementData) {
-
- for (Integer selectedDefinitionId : definitionIds) {
- final MeasurementDefinition measurementDefinition = measurementDefinitions.get(i);
- final int measurementId = measurementDefinition.getId();
-
- if (null != selectedDefinitionId) {
- // single graph case
- if (measurementId == selectedDefinitionId) {
- buildSingleGraph(measurementOOBCompositeList, measurementDefinition, metric, SINGLE_CHART_HEIGHT);
- }
- } else {
- // multiple graph case
- buildSingleGraph(measurementOOBCompositeList, measurementDefinition, metric, MULTI_CHART_HEIGHT);
- }
- }
- i++;
+ private void determineGraphsToBuild(List<List<MeasurementDataNumericHighLowComposite>> measurementData,
+ List<MeasurementDefinition> measurementDefinitions, Set<Integer> definitionIds) {
+ int i = 0;
+ for (List<MeasurementDataNumericHighLowComposite> metric : measurementData) {
+
+ for (Integer selectedDefinitionId : definitionIds) {
+ final MeasurementDefinition measurementDefinition = measurementDefinitions.get(i);
+ final int measurementId = measurementDefinition.getId();
+
+ if (null != selectedDefinitionId) {
+ // single graph case
+ if (measurementId == selectedDefinitionId) {
+ buildSingleGraph(measurementOOBCompositeList, measurementDefinition, metric,
+ SINGLE_CHART_HEIGHT);
}
+ } else {
+ // multiple graph case
+ buildSingleGraph(measurementOOBCompositeList, measurementDefinition, metric, MULTI_CHART_HEIGHT);
}
- });
-
+ }
+ i++;
+ }
}
private void buildSingleGraph(PageList<MeasurementOOBComposite> measurementOOBCompositeList,
MeasurementDefinition measurementDefinition, List<MeasurementDataNumericHighLowComposite> data, int height) {
MetricGraphData metricGraphData = MetricGraphData.createForResource(resource.getId(), resource.getName(),
- measurementDefinition, data, measurementOOBCompositeList );
+ measurementDefinition, data, measurementOOBCompositeList);
StackedBarMetricGraphImpl graph = GWT.create(StackedBarMetricGraphImpl.class);
graph.setMetricGraphData(metricGraphData);
graph.setGraphListView(this);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/MetricD3Graph.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/MetricD3Graph.java
index 3b4ec1f..65807f9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/MetricD3Graph.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/MetricD3Graph.java
@@ -22,6 +22,7 @@ import com.google.gwt.user.client.Timer;
import com.smartgwt.client.widgets.HTMLFlow;
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractD3GraphListView;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.graph.RedrawGraphs;
import org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.StackedBarMetricGraphImpl;
import org.rhq.enterprise.gui.coregui.client.util.Log;
import org.rhq.enterprise.gui.coregui.client.util.enhanced.EnhancedVLayout;
@@ -30,7 +31,7 @@ import org.rhq.enterprise.gui.coregui.client.util.enhanced.EnhancedVLayout;
* A D3 graph implementation for graphing Resource metrics.
* Just the graph only. No avail graph no buttons just he graph.
*/
-public class MetricD3Graph<T extends AbstractD3GraphListView> extends EnhancedVLayout {
+public class MetricD3Graph<T extends AbstractD3GraphListView> extends EnhancedVLayout implements RedrawGraphs{
protected StackedBarMetricGraphImpl graph;
private HTMLFlow graphDiv = null;
@@ -59,18 +60,18 @@ public class MetricD3Graph<T extends AbstractD3GraphListView> extends EnhancedVL
*/
private static String getSvgDefs() {
return " <defs>"
- + " <linearGradient id=\"headerGrad\" x1=\"0%\" y1=\"0%\" x2=\"0%\" y2=\"100%\">"
- + " <stop offset=\"0%\" style=\"stop-color:#E6E6E6;stop-opacity:1\"/>"
- + " <stop offset=\"100%\" style=\"stop-color:#F0F0F0;stop-opacity:1\"/>"
- + " </linearGradient>"
- + " <pattern id=\"noDataStripes\" patternUnits=\"userSpaceOnUse\" x=\"0\" y=\"0\""
- + " width=\"6\" height=\"3\">"
- + " <path d=\"M 0 0 6 0\" style=\"stroke:#CCCCCC; fill:none;\"/>"
- + " </pattern>"
- + " <pattern id=\"unknownStripes\" patternUnits=\"userSpaceOnUse\" x=\"0\" y=\"0\""
- + " width=\"6\" height=\"3\">"
- + " <path d=\"M 0 0 6 0\" style=\"stroke:#2E9EC2; fill:none;\"/>"
- + " </pattern>"
+ + " <linearGradient id=\"headerGrad\" x1=\"0%\" y1=\"0%\" x2=\"0%\" y2=\"100%\">"
+ + " <stop offset=\"0%\" style=\"stop-color:#E6E6E6;stop-opacity:1\"/>"
+ + " <stop offset=\"100%\" style=\"stop-color:#F0F0F0;stop-opacity:1\"/>"
+ + " </linearGradient>"
+ + " <pattern id=\"noDataStripes\" patternUnits=\"userSpaceOnUse\" x=\"0\" y=\"0\""
+ + " width=\"6\" height=\"3\">"
+ + " <path d=\"M 0 0 6 0\" style=\"stroke:#CCCCCC; fill:none;\"/>"
+ + " </pattern>"
+ + " <pattern id=\"unknownStripes\" patternUnits=\"userSpaceOnUse\" x=\"0\" y=\"0\""
+ + " width=\"6\" height=\"3\">"
+ + " <path d=\"M 0 0 6 0\" style=\"stroke:#2E9EC2; fill:none;\"/>"
+ + " </pattern>"
+ "<pattern id=\"diagonalHatchFill\" patternUnits=\"userSpaceOnUse\" x=\"0\" y=\"0\" width=\"105\" height=\"105\">"
+ "<g style=\"fill:none; stroke:black; stroke-width:1\">"
+ "<path d=\"M0 90 l15,15\"/>"
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/avail/ResourceAvailabilityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/avail/ResourceAvailabilityView.java
deleted file mode 100644
index 6719070..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/avail/ResourceAvailabilityView.java
+++ /dev/null
@@ -1,399 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright 2012, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.avail;
-
-import java.util.ArrayList;
-import java.util.Date;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.Record;
-import com.smartgwt.client.data.SortSpecifier;
-import com.smartgwt.client.rpc.RPCResponse;
-import com.smartgwt.client.types.Alignment;
-import com.smartgwt.client.types.ListGridFieldType;
-import com.smartgwt.client.types.SortDirection;
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.fields.FormItem;
-import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.layout.Layout;
-
-import org.rhq.core.domain.criteria.AvailabilityCriteria;
-import org.rhq.core.domain.measurement.Availability;
-import org.rhq.core.domain.measurement.MeasurementUnits;
-import org.rhq.core.domain.resource.composite.ResourceAvailabilitySummary;
-import org.rhq.core.domain.resource.composite.ResourceComposite;
-import org.rhq.core.domain.util.PageControl;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.ImageManager;
-import org.rhq.enterprise.gui.coregui.client.components.table.Table;
-import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
-import org.rhq.enterprise.gui.coregui.client.gwt.AvailabilityGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.util.MeasurementConverterClient;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-import org.rhq.enterprise.gui.coregui.client.util.enhanced.EnhancedVLayout;
-
-/**
- * This shows the availability history for a resource.
- *
- * @author Jay Shaughnessy
- * @author John Mazzitelli
- */
-public class ResourceAvailabilityView extends EnhancedVLayout {
-
- private ResourceComposite resourceComposite;
- private StaticTextItem currentField;
- private StaticTextItem availField;
- private StaticTextItem availTimeField;
- private StaticTextItem downField;
- private StaticTextItem downTimeField;
- private StaticTextItem disabledField;
- private StaticTextItem disabledTimeField;
- private StaticTextItem failureCountField;
- private StaticTextItem disabledCountField;
- private StaticTextItem mtbfField;
- private StaticTextItem mttrField;
- private StaticTextItem unknownField;
- private StaticTextItem currentTimeField;
-
- public ResourceAvailabilityView(ResourceComposite resourceComposite) {
- super();
-
- this.resourceComposite = resourceComposite;
-
- setWidth100();
- setHeight100();
- }
-
- @Override
- protected void onInit() {
- super.onInit();
-
- addMember(createSummaryForm());
- addMember(createListView());
- }
-
- private DynamicForm createSummaryForm() {
- DynamicForm form = new DynamicForm();
- form.setWidth100();
- form.setAutoHeight();
- form.setMargin(10);
- form.setNumCols(4);
-
- // row 1
- currentField = new StaticTextItem("current", MSG.view_resource_monitor_availability_currentStatus());
- currentField.setWrapTitle(false);
- currentField.setColSpan(4);
-
- // row 2
- availField = new StaticTextItem("avail", MSG.view_resource_monitor_availability_availability());
- availField.setWrapTitle(false);
- prepareTooltip(availField, MSG.view_resource_monitor_availability_availability_tooltip());
-
- availTimeField = new StaticTextItem("availTime", MSG.view_resource_monitor_availability_uptime());
- availTimeField.setWrapTitle(false);
- prepareTooltip(availTimeField, MSG.view_resource_monitor_availability_uptime_tooltip());
-
- // row 3
- downField = new StaticTextItem("down", MSG.view_resource_monitor_availability_down());
- downField.setWrapTitle(false);
- prepareTooltip(downField, MSG.view_resource_monitor_availability_down_tooltip());
-
- downTimeField = new StaticTextItem("downTime", MSG.view_resource_monitor_availability_downtime());
- downTimeField.setWrapTitle(false);
- prepareTooltip(downTimeField, MSG.view_resource_monitor_availability_downtime_tooltip());
-
- // row 4
- disabledField = new StaticTextItem("disabled", MSG.view_resource_monitor_availability_disabled());
- disabledField.setWrapTitle(false);
- prepareTooltip(disabledField, MSG.view_resource_monitor_availability_disabled_tooltip());
-
- disabledTimeField = new StaticTextItem("disabledTime", MSG.view_resource_monitor_availability_disabledTime());
- disabledTimeField.setWrapTitle(false);
- prepareTooltip(disabledTimeField, MSG.view_resource_monitor_availability_disabledTime_tooltip());
-
- // row 5
- failureCountField = new StaticTextItem("failureCount", MSG.view_resource_monitor_availability_numFailures());
- failureCountField.setWrapTitle(false);
- prepareTooltip(failureCountField, MSG.view_resource_monitor_availability_numFailures_tooltip());
-
- disabledCountField = new StaticTextItem("disabledCount", MSG.view_resource_monitor_availability_numDisabled());
- disabledCountField.setWrapTitle(false);
- prepareTooltip(disabledCountField, MSG.view_resource_monitor_availability_numDisabled_tooltip());
-
- // row 6
- mtbfField = new StaticTextItem("mtbf", MSG.view_resource_monitor_availability_mtbf());
- mtbfField.setWrapTitle(false);
- prepareTooltip(mtbfField, MSG.view_resource_monitor_availability_mtbf_tooltip());
-
- mttrField = new StaticTextItem("mttr", MSG.view_resource_monitor_availability_mttr());
- mttrField.setWrapTitle(false);
- prepareTooltip(mttrField, MSG.view_resource_monitor_availability_mttr_tooltip());
-
- // row 7
- unknownField = new StaticTextItem("unknown");
- unknownField.setWrapTitle(false);
- unknownField.setColSpan(4);
- unknownField.setShowTitle(false);
-
- // row 8
- currentTimeField = new StaticTextItem("currentTime");
- currentTimeField.setWrapTitle(false);
- currentTimeField.setColSpan(4);
- currentTimeField.setShowTitle(false);
-
- form.setItems(currentField, availField, availTimeField, downField, downTimeField, disabledField,
- disabledTimeField, failureCountField, disabledCountField, mtbfField, mttrField, unknownField,
- currentTimeField);
-
- reloadSummaryData();
-
- return form;
- }
-
- private void reloadSummaryData() {
- GWTServiceLookup.getResourceService().getResourceAvailabilitySummary(resourceComposite.getResource().getId(),
- new AsyncCallback<ResourceAvailabilitySummary>() {
-
- @Override
- public void onSuccess(ResourceAvailabilitySummary result) {
-
- currentField.setValue(MSG.view_resource_monitor_availability_currentStatus_value(result
- .getCurrent().getName(), TimestampCellFormatter.format(result.getLastChange().getTime())));
- availField.setValue(MeasurementConverterClient.format(result.getUpPercentage(),
- MeasurementUnits.PERCENTAGE, true));
- availTimeField.setValue(MeasurementConverterClient.format((double) result.getUpTime(),
- MeasurementUnits.MILLISECONDS, true));
- downField.setValue(MeasurementConverterClient.format(result.getDownPercentage(),
- MeasurementUnits.PERCENTAGE, true));
- downTimeField.setValue(MeasurementConverterClient.format((double) result.getDownTime(),
- MeasurementUnits.MILLISECONDS, true));
- disabledField.setValue(MeasurementConverterClient.format(result.getDisabledPercentage(),
- MeasurementUnits.PERCENTAGE, true));
- disabledTimeField.setValue(MeasurementConverterClient.format((double) result.getDisabledTime(),
- MeasurementUnits.MILLISECONDS, true));
- failureCountField.setValue(result.getFailures());
- disabledCountField.setValue(result.getDisabled());
- mtbfField.setValue(MeasurementConverterClient.format((double) result.getMTBF(),
- MeasurementUnits.MILLISECONDS, true));
- mttrField.setValue(MeasurementConverterClient.format((double) result.getMTTR(),
- MeasurementUnits.MILLISECONDS, true));
-
- if (result.getUnknownTime() > 0L) {
- unknownField.setValue(MSG.view_resource_monitor_availability_unknown(MeasurementConverterClient
- .format((double) result.getUnknownTime(), MeasurementUnits.MILLISECONDS, true)));
- } else {
- unknownField.setValue("");
- }
-
- currentTimeField.setValue(MSG.view_resource_monitor_availability_currentAsOf(TimestampCellFormatter
- .format(result.getCurrentTime())));
- }
-
- @Override
- public void onFailure(Throwable caught) {
- currentField.setValue(MSG.common_label_error());
- CoreGUI.getErrorHandler()
- .handleError(MSG.view_resource_monitor_availability_summaryError(), caught);
- }
- });
- }
-
- private void prepareTooltip(FormItem item, String tooltip) {
- item.setHoverWidth(400);
- item.setPrompt(tooltip);
- }
-
- private Table<ListView.DS> createListView() {
- ListView listView = new ListView(resourceComposite.getResource().getId());
- return listView;
- }
-
- private class ListView extends Table<ListView.DS> {
-
- private DS dataSource;
- private int resourceId;
-
- public ListView(int resourceId) {
- super(null, new SortSpecifier[] { new SortSpecifier("startTime", SortDirection.DESCENDING) });
-
- this.resourceId = resourceId;
-
- setDataSource(getDataSource());
- }
-
- @Override
- public DS getDataSource() {
- if (null == this.dataSource) {
- this.dataSource = new DS(resourceId);
- }
- return this.dataSource;
- }
-
- @Override
- public void refresh() {
- super.refresh();
- reloadSummaryData();
- }
-
- @Override
- protected void configureTableContents(Layout contents) {
- super.configureTableContents(contents);
- setAutoHeight();
- }
-
- @Override
- protected void configureTable() {
- ArrayList<ListGridField> dataSourceFields = getDataSource().getListGridFields();
- getListGrid().setFields(dataSourceFields.toArray(new ListGridField[dataSourceFields.size()]));
-
- super.configureTable();
- }
-
- private class DS extends RPCDataSource<Availability, AvailabilityCriteria> {
-
- public static final String ATTR_ID = "id";
- public static final String ATTR_AVAILABILITY = "availabilityType";
- public static final String ATTR_START_TIME = "startTime";
- public static final String ATTR_END_TIME = "endTime";
-
- public static final String ATTR_DURATION = "duration";
-
- private AvailabilityGWTServiceAsync availService = GWTServiceLookup.getAvailabilityService();
- private int resourceId;
-
- public DS(int resourceId) {
- super();
- this.resourceId = resourceId;
- addDataSourceFields();
- }
-
- /**
- * The view that contains the list grid which will display this datasource's data will call this
- * method to get the field information which is used to control the display of the data.
- *
- * @return list grid fields used to display the datasource data
- */
- public ArrayList<ListGridField> getListGridFields() {
- ArrayList<ListGridField> fields = new ArrayList<ListGridField>(6);
-
- ListGridField startTimeField = new ListGridField(ATTR_START_TIME, MSG.common_title_start());
- startTimeField.setCellFormatter(new TimestampCellFormatter());
- startTimeField.setShowHover(true);
- startTimeField.setHoverCustomizer(TimestampCellFormatter.getHoverCustomizer(ATTR_START_TIME));
- startTimeField.setCanSortClientOnly(true);
- fields.add(startTimeField);
-
- ListGridField endTimeField = new ListGridField(ATTR_END_TIME, MSG.common_title_end());
- endTimeField.setCellFormatter(new TimestampCellFormatter());
- endTimeField.setShowHover(true);
- endTimeField.setHoverCustomizer(TimestampCellFormatter.getHoverCustomizer(ATTR_END_TIME));
- endTimeField.setCanSortClientOnly(true);
- fields.add(endTimeField);
-
- ListGridField durationField = new ListGridField(ATTR_DURATION, MSG.common_title_duration());
- durationField.setAlign(Alignment.RIGHT);
- fields.add(durationField);
-
- ListGridField availabilityField = new ListGridField(ATTR_AVAILABILITY, MSG.common_title_availability());
- availabilityField.setType(ListGridFieldType.IMAGE);
- availabilityField.setAlign(Alignment.CENTER);
- fields.add(availabilityField);
-
- return fields;
- }
-
- @Override
- protected AvailabilityCriteria getFetchCriteria(DSRequest request) {
- AvailabilityCriteria c = new AvailabilityCriteria();
- c.addFilterResourceId(resourceId);
- c.addFilterInitialAvailability(false);
-
- // This code is unlikely to be necessary as the encompassing view should be using an initial
- // sort specifier. But just in case, make sure we set the initial sort. Note that we have to
- // manipulate the PageControl directly as per the restrictions on getFetchCriteria() (see jdoc).
- PageControl pageControl = getPageControl(request);
- if (pageControl.getOrderingFields().isEmpty()) {
- pageControl.initDefaultOrderingField("startTime", PageOrdering.DESC);
- }
-
- return c;
- }
-
- @Override
- protected void executeFetch(final DSRequest request, final DSResponse response,
- AvailabilityCriteria criteria) {
-
- this.availService.findAvailabilityByCriteria(criteria, new AsyncCallback<PageList<Availability>>() {
- public void onFailure(Throwable caught) {
- // TODO fix message
- CoreGUI.getErrorHandler().handleError(MSG.common_label_error(), caught);
- response.setStatus(RPCResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
-
- public void onSuccess(final PageList<Availability> result) {
- response.setData(buildRecords(result));
- response.setTotalRows(result.size());
- processResponse(request.getRequestId(), response);
- }
- });
- }
-
- @Override
- public Availability copyValues(Record from) {
- return null;
- }
-
- @Override
- public ListGridRecord copyValues(Availability from) {
- ListGridRecord record = new ListGridRecord();
-
- record.setAttribute(ATTR_ID, from.getId());
- record.setAttribute(ATTR_AVAILABILITY,
- ImageManager.getAvailabilityIconFromAvailType(from.getAvailabilityType()));
- record.setAttribute(ATTR_START_TIME, new Date(from.getStartTime()));
- if (null != from.getEndTime()) {
- record.setAttribute(ATTR_END_TIME, new Date(from.getEndTime()));
- long duration = from.getEndTime() - from.getStartTime();
- record.setAttribute(ATTR_DURATION,
- MeasurementConverterClient.format((double) duration, MeasurementUnits.MILLISECONDS, true));
-
- } else {
- record.setAttribute(ATTR_END_TIME, MSG.common_label_none2());
- long duration = System.currentTimeMillis() - from.getStartTime();
- record.setAttribute(ATTR_DURATION,
- MeasurementConverterClient.format((double) duration, MeasurementUnits.MILLISECONDS, true));
-
- }
-
- return record;
- }
- }
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/AddToDashboardComponent.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/AddToDashboardComponent.java
new file mode 100644
index 0000000..ce4f8ef
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/AddToDashboardComponent.java
@@ -0,0 +1,185 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.table;
+
+import java.util.LinkedHashMap;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.IButton;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.toolbar.ToolStrip;
+
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.DashboardCriteria;
+import org.rhq.core.domain.dashboard.Dashboard;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.ResourceD3GraphPortlet;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.Log;
+import org.rhq.enterprise.gui.coregui.client.util.enhanced.Enhanced;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+
+/**
+ * @author Mike Thompson
+ */
+public class AddToDashboardComponent extends ToolStrip implements Enhanced {
+ final private Resource resource;
+ private SelectItem dashboardSelectItem;
+ private Dashboard selectedDashboard;
+ private IButton addToDashboardButton;
+ private LinkedHashMap<String, String> dashboardMenuMap;
+ private LinkedHashMap<Integer, Dashboard> dashboardMap;
+ private MetricsTableView.MetricsTableListGrid metricsListGrid;
+
+ public AddToDashboardComponent(Resource resource) {
+ this.resource = resource;
+ setPadding(5);
+ setMembersMargin(15);
+ setWidth(300);
+ dashboardMenuMap = new LinkedHashMap<String, String>();
+ dashboardMap = new LinkedHashMap<Integer, Dashboard>();
+ createToolstrip();
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+ removeMembers(getMembers());
+ createToolstrip();
+ }
+
+ private void createToolstrip() {
+ addSpacer(15);
+ dashboardSelectItem = new SelectItem();
+ addToDashboardButton = new IButton(MSG.view_metric_addToDashboard());
+ addToDashboardButton.disable();
+
+ dashboardSelectItem = new SelectItem();
+ dashboardSelectItem.setTitle("Dashboards");
+ dashboardSelectItem.setWidth(300);
+ dashboardSelectItem.setPickListWidth(210);
+ populateDashboardMenu();
+ addFormItem(dashboardSelectItem);
+ addMember(addToDashboardButton);
+
+ dashboardSelectItem.addChangeHandler(new ChangeHandler() {
+ @Override
+ public void onChange(ChangeEvent changeEvent) {
+ Integer selectedDashboardId = Integer.valueOf((String) changeEvent.getValue());
+ selectedDashboard = dashboardMap.get(selectedDashboardId);
+ }
+ });
+ addToDashboardButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
+ @Override
+ public void onClick(ClickEvent clickEvent) {
+ ListGridRecord[] selectedRecords = metricsListGrid.getSelectedRecords();
+ for (ListGridRecord selectedRecord : selectedRecords) {
+ for (MeasurementDefinition measurementDefinition : resource.getResourceType()
+ .getMetricDefinitions()) {
+ if (measurementDefinition.getId() == selectedRecord
+ .getAttributeAsInt(MetricsViewDataSource.FIELD_METRIC_DEF_ID)) {
+ Log.debug("Add to Dashboard -- Storing: " + measurementDefinition.getDisplayName()
+ + " in " + selectedDashboard.getName());
+ storeDashboardMetric(selectedDashboard, resource, measurementDefinition);
+ break;
+ }
+ }
+ }
+ }
+ });
+ }
+
+ public void disableAddToDashboardButton(){
+ addToDashboardButton.disable();
+ }
+
+ public void enableAddToDashboardButton(){
+ addToDashboardButton.enable();
+ }
+
+
+ public void populateDashboardMenu() {
+ dashboardMenuMap.clear();
+ dashboardMap.clear();
+
+ DashboardCriteria criteria = new DashboardCriteria();
+ GWTServiceLookup.getDashboardService().findDashboardsByCriteria(criteria,
+ new AsyncCallback<PageList<Dashboard>>() {
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_contextMenu_loadFailed_dashboard(),
+ caught);
+ }
+
+ public void onSuccess(PageList<Dashboard> dashboards) {
+ for (final Dashboard dashboard : dashboards) {
+ dashboardMenuMap.put(String.valueOf(dashboard.getId()),
+ MSG.view_tree_common_contextMenu_addChartToDashboard(dashboard.getName()));
+ dashboardMap.put(dashboard.getId(), dashboard);
+ }
+ selectedDashboard = dashboards.get(0);
+ dashboardSelectItem.setValueMap(dashboardMenuMap);
+ dashboardSelectItem.setValue(selectedDashboard.getId());
+ }
+ });
+ }
+
+ /**
+ * The metrics list grid is not available on object creation so we must attach later after it has been initialized.
+ * @param metricsListGrid
+ */
+ public void setMetricsListGrid(MetricsTableView.MetricsTableListGrid metricsListGrid) {
+ this.metricsListGrid = metricsListGrid;
+ }
+
+
+ private void storeDashboardMetric(Dashboard dashboard, Resource resource, MeasurementDefinition definition) {
+ DashboardPortlet dashboardPortlet = new DashboardPortlet(MSG.view_tree_common_contextMenu_resourceGraph(),
+ ResourceD3GraphPortlet.KEY, 250);
+ dashboardPortlet.getConfiguration().put(
+ new PropertySimple(ResourceD3GraphPortlet.CFG_RESOURCE_ID, resource.getId()));
+ dashboardPortlet.getConfiguration().put(
+ new PropertySimple(ResourceD3GraphPortlet.CFG_DEFINITION_ID, definition.getId()));
+
+ dashboard.addPortlet(dashboardPortlet);
+
+ GWTServiceLookup.getDashboardService().storeDashboard(dashboard, new AsyncCallback<Dashboard>() {
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_contextMenu_saveChartToDashboardFailure(),
+ caught);
+ }
+
+ public void onSuccess(Dashboard result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message(MSG.view_tree_common_contextMenu_saveChartToDashboardSuccessful(result.getName()),
+ Message.Severity.Info));
+ }
+ });
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MeasurementTableView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MeasurementTableView.java
deleted file mode 100644
index 7022648..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MeasurementTableView.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.table;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.TreeSet;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.types.SelectionStyle;
-import com.smartgwt.client.widgets.Window;
-import com.smartgwt.client.widgets.events.CloseClickEvent;
-import com.smartgwt.client.widgets.events.CloseClickHandler;
-import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-
-import org.rhq.core.domain.criteria.ResourceCriteria;
-import org.rhq.core.domain.measurement.MeasurementData;
-import org.rhq.core.domain.measurement.MeasurementUnits;
-import org.rhq.core.domain.resource.composite.ResourceComposite;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.components.measurement.UserPreferencesMeasurementRangeEditor;
-import org.rhq.enterprise.gui.coregui.client.components.table.Table;
-import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.inventory.InventoryView;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView.ChartViewWindow;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.D3GraphListView;
-import org.rhq.enterprise.gui.coregui.client.util.MeasurementConverterClient;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-
-/**
- * Views a resource's measurements in a tabular view.
- *
- * @author John Mazzitelli
- */
-public class MeasurementTableView extends Table<MetricsTableDataSource> {
-
- private final int resourceId;
-
- public MeasurementTableView(int resourceId) {
- super();
- this.resourceId = resourceId;
- setDataSource(new MetricsTableDataSource(resourceId));
- }
-
- protected void configureTable() {
- ArrayList<ListGridField> fields = getDataSource().getListGridFields();
- setListGridFields(fields.toArray(new ListGridField[0]));
- addExtraWidget(new UserPreferencesMeasurementRangeEditor(), true);
- addTableAction(MSG.view_measureTable_getLive(), new TableAction() {
- @Override
- public boolean isEnabled(ListGridRecord[] selection) {
- return selection != null && selection.length > 0;
- }
-
- @Override
- public void executeAction(ListGridRecord[] selection, Object actionValue) {
- if (selection == null || selection.length == 0) {
- return;
- }
- // keyed on metric name - string[0] is the metric label, [1] is the units
- final HashMap<String, String[]> scheduleNamesAndUnits = new HashMap<String, String[]>();
- int[] definitionIds = new int[selection.length];
- int i = 0;
- for (ListGridRecord record : selection) {
- Integer defId = record.getAttributeAsInt(MetricsTableDataSource.FIELD_METRIC_DEF_ID);
- definitionIds[i++] = defId.intValue();
-
- String name = record.getAttribute(MetricsTableDataSource.FIELD_METRIC_NAME);
- String label = record.getAttribute(MetricsTableDataSource.FIELD_METRIC_LABEL);
- String units = record.getAttribute(MetricsTableDataSource.FIELD_METRIC_UNITS);
- if (units == null || units.length() < 1) {
- units = MeasurementUnits.NONE.name();
- }
-
- scheduleNamesAndUnits.put(name, new String[] { label, units });
- }
-
- // actually go out and ask the agents for the data
- GWTServiceLookup.getMeasurementDataService(60000).findLiveData(resourceId, definitionIds,
- new AsyncCallback<Set<MeasurementData>>() {
- @Override
- public void onSuccess(Set<MeasurementData> result) {
- if (result == null) {
- result = new HashSet<MeasurementData>(0);
- }
- ArrayList<ListGridRecord> records = new ArrayList<ListGridRecord>(result.size());
- for (MeasurementData data : result) {
- String[] nameAndUnits = scheduleNamesAndUnits.get(data.getName());
- if (nameAndUnits != null) {
- double doubleValue;
- if (data.getValue() instanceof Number) {
- doubleValue = ((Number) data.getValue()).doubleValue();
- } else {
- doubleValue = Double.parseDouble(data.getValue().toString());
- }
- String value = MeasurementConverterClient.formatToSignificantPrecision(
- new double[] { doubleValue }, MeasurementUnits.valueOf(nameAndUnits[1]), true)[0];
-
- ListGridRecord record = new ListGridRecord();
- record.setAttribute("name", nameAndUnits[0]);
- record.setAttribute("value", value);
- records.add(record);
- }
- }
- Collections.sort(records, new Comparator<ListGridRecord>() {
- public int compare(ListGridRecord o1, ListGridRecord o2) {
- return o1.getAttribute("name").compareTo(o2.getAttribute("name"));
- }
- });
- showLiveData(records);
- }
-
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_measureTable_getLive_failure(), caught);
- }
- });
- }
- });
-
-
- addTableAction(MSG.view_measureTable_chartMetricValues(), new TableAction() {
- @Override
- public boolean isEnabled(ListGridRecord[] selection) {
- return selection != null && selection.length > 0;
- }
-
- @Override
- public void executeAction(ListGridRecord[] selection, Object actionValue) {
- if (selection == null || selection.length == 0) {
- return;
- }
- final TreeSet<Integer> definitionIds = new TreeSet<Integer>();
- for (ListGridRecord record : selection) {
- Integer defId = record.getAttributeAsInt(MetricsTableDataSource.FIELD_METRIC_DEF_ID);
- definitionIds.add(defId);
- }
-
- ResourceCriteria criteria = new ResourceCriteria();
- criteria.addFilterId(resourceId);
- criteria.fetchSchedules(true);
- GWTServiceLookup.getResourceService().findResourceCompositesByCriteria(criteria,
- new AsyncCallback<PageList<ResourceComposite>>() {
-
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getMessageCenter().notify(
- new Message(MSG.view_inventory_resource_loadFailed(String.valueOf(resourceId)),
- Message.Severity.Warning));
-
- CoreGUI.goToView(InventoryView.VIEW_ID.getName());
- }
-
- @Override
- public void onSuccess(PageList<ResourceComposite> result) {
- if (result.isEmpty()) {
- onFailure(new Exception(MSG.view_inventory_resource_loadFailed(String
- .valueOf(resourceId))));
- } else {
- final ResourceComposite resourceComposite = result.get(0);
-
- ChartViewWindow window = new ChartViewWindow("");
- final D3GraphListView graphListView = D3GraphListView.createMultipleGraphs(
- resourceComposite.getResource(), definitionIds, true);
-
- window.addItem(graphListView);
- window.show();
- refreshTableInfo();
-
- }
- }
- });
-
- }
- });
- }
-
- private void showLiveData(ArrayList<ListGridRecord> records) {
- final Window liveDataWindow = new Window();
- liveDataWindow.setTitle(MSG.view_measureTable_live_title());
- liveDataWindow.setShowModalMask(true);
- liveDataWindow.setShowMinimizeButton(false);
- liveDataWindow.setShowMaximizeButton(true);
- liveDataWindow.setShowCloseButton(true);
- liveDataWindow.setShowResizer(true);
- liveDataWindow.setCanDragResize(true);
- liveDataWindow.setDismissOnEscape(true);
- liveDataWindow.setIsModal(true);
- liveDataWindow.setWidth(700);
- liveDataWindow.setHeight(425);
- liveDataWindow.setAutoCenter(true);
- liveDataWindow.centerInPage();
- liveDataWindow.addCloseClickHandler(new CloseClickHandler() {
- @Override
- public void onCloseClick(CloseClickEvent event) {
- liveDataWindow.destroy();
- refreshTableInfo();
- }
- });
-
- ListGrid liveDataGrid = new ListGrid();
- liveDataGrid.setShowAllRecords(true);
- liveDataGrid.setData(records.toArray(new ListGridRecord[records.size()]));
- liveDataGrid.setSelectionType(SelectionStyle.NONE);
- ListGridField name = new ListGridField("name", MSG.common_title_metric());
- ListGridField value = new ListGridField("value", MSG.common_title_value());
- liveDataGrid.setFields(name, value);
-
- liveDataWindow.addItem(liveDataGrid);
- liveDataWindow.show();
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java
new file mode 100644
index 0000000..bcea825
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java
@@ -0,0 +1,167 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.table;
+
+import java.util.List;
+
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.types.VerticalAlignment;
+import com.smartgwt.client.widgets.Img;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.measurement.Availability;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.IconEnum;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractD3GraphListView;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityOverUnderGraphType;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.avail.AvailabilityD3GraphView;
+import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
+import org.rhq.enterprise.gui.coregui.client.util.Log;
+import org.rhq.enterprise.gui.coregui.client.util.async.CountDownLatch;
+import org.rhq.enterprise.gui.coregui.client.util.enhanced.EnhancedHLayout;
+
+/**
+ * The consolidated metrics view showing metric graphs and availability data both in graphical and tabular form.
+ *
+ * @author Mike Thompson
+ */
+public class MetricsResourceView extends AbstractD3GraphListView {
+
+ private static final String COLLAPSED_TOOLTIP = MSG.chart_metrics_collapse_tooltip();
+ private static final String EXPANDED_TOOLTIP = MSG.chart_metrics_expand_tooltip();
+
+ private final Resource resource;
+ private Img expandCollapseArrow;
+ private final MetricsTableView metricsTableView;
+ private final ResourceMetricAvailabilityView availabilityDetails;
+
+ public MetricsResourceView(Resource resource) {
+ super();
+ setOverflow(Overflow.AUTO);
+ setWidth100();
+ setHeight100();
+ this.resource = resource;
+ metricsTableView = new MetricsTableView(resource, this);
+ availabilityDetails = new ResourceMetricAvailabilityView(resource);
+ }
+
+
+ public void redrawGraphs() {
+ this.onDraw();
+ }
+
+ public void refreshGraphs(){
+ new Timer() {
+ @Override
+ public void run() {
+ availabilityGraph.drawJsniChart();
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+ Log.debug("MetricResourceView.onDraw() for: " + resource.getName() + " id: " + resource.getId());
+ destroyMembers();
+
+
+ addMember(buttonBarDateTimeRangeEditor);
+
+ availabilityGraph = new AvailabilityD3GraphView<AvailabilityOverUnderGraphType>(
+ new AvailabilityOverUnderGraphType(resource.getId()));
+
+ EnhancedHLayout expandCollapseHLayout = new EnhancedHLayout();
+
+ //add expand/collapse icon
+ expandCollapseArrow = new Img(IconEnum.COLLAPSED_ICON.getIcon16x16Path(), 16, 16);
+ expandCollapseArrow.setTooltip(COLLAPSED_TOOLTIP);
+ expandCollapseArrow.setLayoutAlign(VerticalAlignment.BOTTOM);
+ expandCollapseArrow.addClickHandler(new ClickHandler() {
+ private boolean collapsed = true;
+
+ @Override
+ public void onClick(ClickEvent event) {
+ collapsed = !collapsed;
+ if (collapsed) {
+ expandCollapseArrow.setSrc(IconEnum.COLLAPSED_ICON.getIcon16x16Path());
+ expandCollapseArrow.setTooltip(COLLAPSED_TOOLTIP);
+ availabilityDetails.hide();
+ } else {
+ expandCollapseArrow.setSrc(IconEnum.EXPANDED_ICON.getIcon16x16Path());
+ expandCollapseArrow.setTooltip(EXPANDED_TOOLTIP);
+ availabilityDetails.show();
+
+ }
+ refreshGraphs();
+ }
+ });
+
+
+ expandCollapseHLayout.addMember(expandCollapseArrow);
+ expandCollapseHLayout.addMember(availabilityGraph);
+ addMember(expandCollapseHLayout);
+
+ availabilityDetails.hide();
+ addMember(availabilityDetails);
+
+ metricsTableView.setHeight100();
+ addMember(metricsTableView);
+
+
+ queryAvailability(EntityContext.forResource(resource.getId()), buttonBarDateTimeRangeEditor.getStartTime(),
+ buttonBarDateTimeRangeEditor.getEndTime(), null);
+ }
+
+ @Override
+ protected void queryAvailability(final EntityContext context, Long startTime, Long endTime, CountDownLatch notUsed ) {
+
+ final long timerStart = System.currentTimeMillis();
+
+ // now return the availability
+ GWTServiceLookup.getAvailabilityService().getAvailabilitiesForResource(context.getResourceId(), startTime,
+ endTime, new AsyncCallback<List<Availability>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_availability_loadFailed(), caught);
+ }
+
+ @Override
+ public void onSuccess(List<Availability> availList) {
+ Log.debug("\nSuccessfully queried availability in: " + (System.currentTimeMillis() - timerStart)
+ + " ms.");
+ availabilityGraph.setAvailabilityList(availList);
+ new Timer() {
+ @Override
+ public void run() {
+ availabilityGraph.drawJsniChart();
+ }
+ }.schedule(150);
+ }
+ });
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableDataSource.java
index 318166d..57e62ab 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableDataSource.java
@@ -1,7 +1,13 @@
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.table;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
+import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -11,18 +17,28 @@ import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.criteria.Criteria;
+import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.measurement.DataType;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.MeasurementSchedule;
+import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
import org.rhq.core.domain.measurement.ui.MetricDisplaySummary;
import org.rhq.core.domain.measurement.ui.MetricDisplayValue;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
+import org.rhq.enterprise.gui.coregui.client.util.Log;
import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.async.Command;
+import org.rhq.enterprise.gui.coregui.client.util.async.CountDownLatch;
import org.rhq.enterprise.gui.coregui.client.util.preferences.MeasurementUserPreferences;
-import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
/**
* A simple data source to read in metric data summaries for a resource.
@@ -31,9 +47,13 @@ import org.rhq.enterprise.gui.coregui.client.util.preferences.UserPreferences;
* we just load them all in at once.
*
* @author John Mazzitelli
+ * @author Mike Thompson
+ * @todo: get rid of this once we have tested the new screen out
*/
+@Deprecated
public class MetricsTableDataSource extends RPCDataSource<MetricDisplaySummary, Criteria> {
+ public static final String FIELD_SPARKLINE = "sparkline";
public static final String FIELD_METRIC_LABEL = "label";
public static final String FIELD_ALERT_COUNT = "alertCount";
public static final String FIELD_MIN_VALUE = "min";
@@ -44,11 +64,15 @@ public class MetricsTableDataSource extends RPCDataSource<MetricDisplaySummary,
public static final String FIELD_METRIC_SCHED_ID = "schedId";
public static final String FIELD_METRIC_UNITS = "units";
public static final String FIELD_METRIC_NAME = "name";
-
+ public static final String FIELD_RESOURCE_ID = "resourceId";
private int resourceId;
+ private List<MetricDisplaySummary> metricDisplaySummaries;
+ private List<List<MeasurementDataNumericHighLowComposite>> metricsDataList;
+ private MeasurementUserPreferences measurementUserPrefs;
public MetricsTableDataSource(int resourceId) {
this.resourceId = resourceId;
+ measurementUserPrefs = new MeasurementUserPreferences(UserSessionManager.getUserPreferences());
}
/**
@@ -58,7 +82,25 @@ public class MetricsTableDataSource extends RPCDataSource<MetricDisplaySummary,
* @return list grid fields used to display the datasource data
*/
public ArrayList<ListGridField> getListGridFields() {
- ArrayList<ListGridField> fields = new ArrayList<ListGridField>(6);
+ ArrayList<ListGridField> fields = new ArrayList<ListGridField>(7);
+
+ ListGridField sparklineField = new ListGridField(FIELD_SPARKLINE, "chart");
+ sparklineField.setCellFormatter(new CellFormatter() {
+ @Override
+ public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
+ if (value == null) {
+ return "";
+ }
+ String contents = "<span id='sparkline_" + resourceId + "-"
+ + record.getAttributeAsInt(FIELD_METRIC_DEF_ID) + "' class='dynamicsparkline' width='70' "
+ + "values='" + record.getAttribute(FIELD_SPARKLINE) + "'></span>";
+ return contents;
+
+ }
+ });
+
+ sparklineField.setWidth(80);
+ fields.add(sparklineField);
ListGridField nameField = new ListGridField(FIELD_METRIC_LABEL, MSG.common_title_name());
nameField.setWidth("30%");
@@ -101,6 +143,7 @@ public class MetricsTableDataSource extends RPCDataSource<MetricDisplaySummary,
MeasurementUtility.formatSimpleMetrics(from);
ListGridRecord record = new ListGridRecord();
+ record.setAttribute(FIELD_SPARKLINE, getCsvMetricsForSparkline());
record.setAttribute(FIELD_METRIC_LABEL, from.getLabel());
record.setAttribute(FIELD_ALERT_COUNT, String.valueOf(from.getAlertCount()));
record.setAttribute(FIELD_MIN_VALUE, getMetricStringValue(from.getMinMetric()));
@@ -111,9 +154,32 @@ public class MetricsTableDataSource extends RPCDataSource<MetricDisplaySummary,
record.setAttribute(FIELD_METRIC_SCHED_ID, from.getScheduleId());
record.setAttribute(FIELD_METRIC_UNITS, from.getUnits());
record.setAttribute(FIELD_METRIC_NAME, from.getMetricName());
+ record.setAttribute(FIELD_RESOURCE_ID, resourceId);
return record;
}
+ private String getCsvMetricsForSparkline() {
+ StringBuilder sb = new StringBuilder();
+ Log.debug("getCsvMetricsForSparkline.metricsDataList: " + metricsDataList.size());
+ for (List<MeasurementDataNumericHighLowComposite> measurementData : metricsDataList) {
+ for (int i = 0; i < measurementData.size(); i++) {
+ // take the last 20 values
+ if (i >= measurementData.size() - 20) {
+ if (!Double.isNaN(measurementData.get(i).getValue())) {
+ sb.append((int) measurementData.get(i).getValue());
+ sb.append(",");
+ }
+ }
+ }
+ if (sb.toString().endsWith(",")) {
+ sb.setLength(sb.length() - 1);
+ }
+ }
+ Log.debug("getCsvMetricsForSparkline: " + sb.toString());
+
+ return sb.toString();
+ }
+
protected String getMetricStringValue(MetricDisplayValue value) {
return (value != null) ? value.toString() : "";
}
@@ -127,34 +193,54 @@ public class MetricsTableDataSource extends RPCDataSource<MetricDisplaySummary,
@Override
protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
- // see MetricsTableUIBean for the old JSF class to see where this came from
-
GWTServiceLookup.getMeasurementScheduleService().findSchedulesForResourceAndType(resourceId,
DataType.MEASUREMENT, null, true, new AsyncCallback<ArrayList<MeasurementSchedule>>() {
@Override
- public void onSuccess(ArrayList<MeasurementSchedule> result) {
- int[] schedIds = new int[result.size()];
+ public void onSuccess(ArrayList<MeasurementSchedule> measurementSchedules) {
+ int[] scheduleIds = new int[measurementSchedules.size()];
int i = 0;
- for (MeasurementSchedule measurementSchedule : result) {
- schedIds[i++] = measurementSchedule.getId();
+ for (MeasurementSchedule measurementSchedule : measurementSchedules) {
+ scheduleIds[i++] = measurementSchedule.getId();
}
- UserPreferences prefs = UserSessionManager.getUserPreferences();
- MeasurementUserPreferences mprefs = new MeasurementUserPreferences(prefs);
- ArrayList<Long> range = mprefs.getMetricRangePreferences().getBeginEndTimes();
+ final CountDownLatch countDownLatch = CountDownLatch.create(2, new Command() {
+
+ @Override
+ public void execute() {
+ response.setData(buildRecords(metricDisplaySummaries));
+ processResponse(request.getRequestId(), response);
+
+ new Timer() {
+
+ @Override
+ public void run() {
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+ Log.debug("*** Finished CountdownLatch for metrics loaded: " + metricsDataList.size());
+ }
+ });
+
+ retrieveResourceMetrics(resourceId, countDownLatch);
+
GWTServiceLookup.getMeasurementChartsService().getMetricDisplaySummariesForResource(resourceId,
- schedIds, range.get(0), range.get(1), new AsyncCallback<ArrayList<MetricDisplaySummary>>() {
- @Override
- public void onSuccess(ArrayList<MetricDisplaySummary> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
+ scheduleIds, measurementUserPrefs.getMetricRangePreferences().begin,
+ measurementUserPrefs.getMetricRangePreferences().end,
+ new AsyncCallback<ArrayList<MetricDisplaySummary>>() {
+ @Override
+ public void onSuccess(ArrayList<MetricDisplaySummary> metricDisplaySummaries) {
+ setMetricDisplaySummaries(metricDisplaySummaries);
+ countDownLatch.countDown();
+ }
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Cannot load metrics", caught);
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Cannot load metrics", caught);
+ countDownLatch.countDown();
+ }
}
- });
+
+ );
}
@Override
@@ -163,4 +249,87 @@ public class MetricsTableDataSource extends RPCDataSource<MetricDisplaySummary,
}
});
}
+
+ void setMetricDisplaySummaries(List<MetricDisplaySummary> metricDisplaySummaries) {
+ this.metricDisplaySummaries = metricDisplaySummaries;
+ }
+
+ public void retrieveResourceMetrics(final Integer resourceId, final CountDownLatch countDownLatch) {
+
+ ResourceCriteria criteria = new ResourceCriteria();
+ criteria.addFilterId(resourceId);
+
+ //locate the resource
+ GWTServiceLookup.getResourceService().findResourceCompositesByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceComposite>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving resource resource composite for resource [" + resourceId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<ResourceComposite> resourceCompositePageList) {
+ if (!resourceCompositePageList.isEmpty()) {
+ final ResourceComposite resourceComposite = resourceCompositePageList.get(0);
+ final Resource resource = resourceComposite.getResource();
+ // Load the fully fetched ResourceType.
+ ResourceType resourceType = resource.getResourceType();
+ ResourceTypeRepository.Cache.getInstance().getResourceTypes(resourceType.getId(),
+ EnumSet.of(ResourceTypeRepository.MetadataType.measurements),
+ new ResourceTypeRepository.TypeLoadedCallback() {
+ public void onTypesLoaded(ResourceType type) {
+ resource.setResourceType(type);
+ //metric definitions
+ Set<MeasurementDefinition> definitions = type.getMetricDefinitions();
+
+ //build id mapping for measurementDefinition instances Ex. Free Memory -> MeasurementDefinition[100071]
+ final HashMap<String, MeasurementDefinition> measurementDefMap = new HashMap<String, MeasurementDefinition>();
+ for (MeasurementDefinition definition : definitions) {
+ measurementDefMap.put(definition.getDisplayName(), definition);
+ }
+ //bundle definition ids for asynch call.
+ int[] definitionArrayIds = new int[definitions.size()];
+ final String[] displayOrder = new String[definitions.size()];
+ measurementDefMap.keySet().toArray(displayOrder);
+ //sort the charting data ex. Free Memory, Free Swap Space,..System Load
+ Arrays.sort(displayOrder);
+
+ //organize definitionArrayIds for ordered request on server.
+ int index = 0;
+ for (String definitionToDisplay : displayOrder) {
+ definitionArrayIds[index++] = measurementDefMap.get(definitionToDisplay)
+ .getId();
+ }
+
+ GWTServiceLookup.getMeasurementDataService().findDataForResource(resourceId,
+ definitionArrayIds, measurementUserPrefs.getMetricRangePreferences().begin,
+ measurementUserPrefs.getMetricRangePreferences().end, 60,
+ new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.warn("Error retrieving recent metrics charting data for resource ["
+ + resourceId + "]:" + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(
+ List<List<MeasurementDataNumericHighLowComposite>> measurementDataList) {
+
+ if (!measurementDataList.isEmpty()) {
+ metricsDataList = measurementDataList;
+ Log.debug("*** Setting metricsDataList.size: "
+ + metricsDataList.size());
+ countDownLatch.countDown();
+ }
+ }
+ });
+
+ }
+ });
+ }
+ }
+ });
+
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
new file mode 100644
index 0000000..09a7bc3
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
@@ -0,0 +1,385 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.table;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.types.ExpansionMode;
+import com.smartgwt.client.types.SelectionStyle;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.Window;
+import com.smartgwt.client.widgets.events.CloseClickEvent;
+import com.smartgwt.client.widgets.events.CloseClickHandler;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
+import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
+import com.smartgwt.client.widgets.grid.events.RecordCollapseEvent;
+import com.smartgwt.client.widgets.grid.events.RecordCollapseHandler;
+import com.smartgwt.client.widgets.grid.events.RecordExpandEvent;
+import com.smartgwt.client.widgets.grid.events.RecordExpandHandler;
+import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
+import com.smartgwt.client.widgets.grid.events.SelectionEvent;
+import com.smartgwt.client.widgets.grid.events.SortChangedHandler;
+import com.smartgwt.client.widgets.grid.events.SortEvent;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.measurement.MeasurementData;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.MeasurementUnits;
+import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
+import org.rhq.enterprise.gui.coregui.client.components.table.Table;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractD3GraphListView;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.graph.MetricGraphData;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.graph.RedrawGraphs;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.StackedBarMetricGraphImpl;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.MetricD3Graph;
+import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
+import org.rhq.enterprise.gui.coregui.client.util.Log;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementConverterClient;
+import org.rhq.enterprise.gui.coregui.client.util.preferences.MeasurementUserPreferences;
+
+/**
+ * Views a resource's metrics in a tabular view with sparkline graph and optional detailed d3 graph.
+ *
+ * @author John Mazzitelli
+ * @author Mike Thompson
+ */
+public class MetricsTableView extends Table<MetricsViewDataSource> implements RedrawGraphs {
+
+ private final Resource resource;
+ private final AbstractD3GraphListView abstractD3GraphListView;
+
+ private final MeasurementUserPreferences measurementUserPrefs;
+ private final AddToDashboardComponent addToDashboardComponent;
+ private MetricsTableListGrid metricsTableListGrid;
+
+ Set<Integer> expandedRows = new HashSet<Integer>();
+
+ public MetricsTableView(Resource resource, AbstractD3GraphListView abstractD3GraphListView) {
+ super();
+ this.resource = resource;
+ this.abstractD3GraphListView = abstractD3GraphListView;
+ measurementUserPrefs = new MeasurementUserPreferences(UserSessionManager.getUserPreferences());
+ setDataSource(new MetricsViewDataSource(resource));
+ addToDashboardComponent = new AddToDashboardComponent(resource);
+ }
+
+ /**
+ * Creates this Table's list grid (called by onInit()). Subclasses can override this if they require a custom
+ * subclass of ListGrid.
+ *
+ * @return this Table's list grid (must be an instance of ListGrid)
+ */
+ @Override
+ protected ListGrid createListGrid() {
+ metricsTableListGrid = new MetricsTableListGrid(this, resource);
+ addToDashboardComponent.setMetricsListGrid(metricsTableListGrid);
+ return metricsTableListGrid;
+ }
+
+ protected void configureTable() {
+ ArrayList<ListGridField> fields = getDataSource().getListGridFields();
+ setListGridFields(fields.toArray(new ListGridField[0]));
+
+ addTableAction(MSG.view_measureTable_getLive(), new ShowLiveDataTableAction(this));
+ addExtraWidget(addToDashboardComponent, false);
+ addToDashboardComponent.disableAddToDashboardButton();
+ metricsTableListGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
+ @Override
+ public void onSelectionChanged(SelectionEvent selectionEvent) {
+ if(metricsTableListGrid.getSelectedRecords().length > 0){
+ addToDashboardComponent.enableAddToDashboardButton();
+ }else {
+ addToDashboardComponent.disableAddToDashboardButton();
+ }
+ }
+ });
+ }
+
+ private static class ShowLiveDataTableAction implements TableAction {
+ private MetricsTableView metricsTableView;
+
+ public ShowLiveDataTableAction(MetricsTableView metricsTableView) {
+ this.metricsTableView = metricsTableView;
+ }
+
+ @Override
+ public boolean isEnabled(ListGridRecord[] selection) {
+ return selection != null && selection.length > 0;
+ }
+
+ @Override
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ if (selection == null || selection.length == 0) {
+ return;
+ }
+ // keyed on metric name - string[0] is the metric label, [1] is the units
+ final HashMap<String, String[]> scheduleNamesAndUnits = new HashMap<String, String[]>();
+ int[] definitionIds = new int[selection.length];
+ int i = 0;
+ for (ListGridRecord record : selection) {
+ Integer defId = record.getAttributeAsInt(MetricsViewDataSource.FIELD_METRIC_DEF_ID);
+ definitionIds[i++] = defId;
+
+ String name = record.getAttribute(MetricsViewDataSource.FIELD_METRIC_NAME);
+ String label = record.getAttribute(MetricsViewDataSource.FIELD_METRIC_LABEL);
+ String units = record.getAttribute(MetricsViewDataSource.FIELD_METRIC_UNITS);
+ if (units == null || units.length() < 1) {
+ units = MeasurementUnits.NONE.name();
+ }
+
+ scheduleNamesAndUnits.put(name, new String[] { label, units });
+ }
+
+ // actually go out and ask the agents for the data
+ GWTServiceLookup.getMeasurementDataService(60000).findLiveData(metricsTableView.resource.getId(),
+ definitionIds, new AsyncCallback<Set<MeasurementData>>() {
+ @Override
+ public void onSuccess(Set<MeasurementData> result) {
+ if (result == null) {
+ result = new HashSet<MeasurementData>(0);
+ }
+ ArrayList<ListGridRecord> records = new ArrayList<ListGridRecord>(result.size());
+ for (MeasurementData data : result) {
+ String[] nameAndUnits = scheduleNamesAndUnits.get(data.getName());
+ if (nameAndUnits != null) {
+ double doubleValue;
+ if (data.getValue() instanceof Number) {
+ doubleValue = ((Number) data.getValue()).doubleValue();
+ } else {
+ doubleValue = Double.parseDouble(data.getValue().toString());
+ }
+ String value = MeasurementConverterClient.formatToSignificantPrecision(
+ new double[] { doubleValue }, MeasurementUnits.valueOf(nameAndUnits[1]), true)[0];
+
+ ListGridRecord record = new ListGridRecord();
+ record.setAttribute("name", nameAndUnits[0]);
+ record.setAttribute("value", value);
+ records.add(record);
+ }
+ }
+ Collections.sort(records, new Comparator<ListGridRecord>() {
+ public int compare(ListGridRecord o1, ListGridRecord o2) {
+ return o1.getAttribute("name").compareTo(o2.getAttribute("name"));
+ }
+ });
+ showLiveData(records);
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_measureTable_getLive_failure(), caught);
+ }
+ });
+ }
+
+ private void showLiveData(ArrayList<ListGridRecord> records) {
+ final Window liveDataWindow = new Window();
+ liveDataWindow.setTitle(MSG.view_measureTable_live_title());
+ liveDataWindow.setShowModalMask(true);
+ liveDataWindow.setShowMinimizeButton(false);
+ liveDataWindow.setShowMaximizeButton(true);
+ liveDataWindow.setShowCloseButton(true);
+ liveDataWindow.setShowResizer(true);
+ liveDataWindow.setCanDragResize(true);
+ liveDataWindow.setDismissOnEscape(true);
+ liveDataWindow.setIsModal(true);
+ liveDataWindow.setWidth(700);
+ liveDataWindow.setHeight(425);
+ liveDataWindow.setAutoCenter(true);
+ liveDataWindow.centerInPage();
+ liveDataWindow.addCloseClickHandler(new CloseClickHandler() {
+ @Override
+ public void onCloseClick(CloseClickEvent event) {
+ liveDataWindow.destroy();
+ metricsTableView.refreshTableInfo();
+ }
+ });
+
+ ListGrid liveDataGrid = new ListGrid();
+ liveDataGrid.setShowAllRecords(true);
+ liveDataGrid.setData(records.toArray(new ListGridRecord[records.size()]));
+ liveDataGrid.setSelectionType(SelectionStyle.NONE);
+ ListGridField name = new ListGridField("name", MSG.common_title_metric());
+ ListGridField value = new ListGridField("value", MSG.common_title_value());
+ liveDataGrid.setFields(name, value);
+
+ liveDataWindow.addItem(liveDataGrid);
+ liveDataWindow.show();
+ }
+
+ }
+
+ @Override
+ /**
+ * Redraw Graphs in this context means to refresh the table and redraw open graphs.
+ */
+ public void redrawGraphs() {
+ Log.debug("MetricsView.redrawGraphs.");
+
+ new Timer() {
+
+ @Override
+ public void run() {
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+
+ }
+
+ public class MetricsTableListGrid extends ListGrid {
+
+ private static final int TREEVIEW_DETAIL_CHART_HEIGHT = 205;
+ private static final int NUM_METRIC_POINTS = 60;
+ private Resource resource;
+ final MetricsTableView metricsTableView;
+
+ public MetricsTableListGrid(final MetricsTableView metricsTableView, final Resource resource) {
+ super();
+ this.resource = resource;
+ this.metricsTableView = metricsTableView;
+ setCanExpandRecords(true);
+ setCanExpandMultipleRecords(true);
+ setExpansionMode(ExpansionMode.DETAIL_FIELD);
+
+ addRecordExpandHandler(new RecordExpandHandler() {
+ @Override
+ public void onRecordExpand(RecordExpandEvent recordExpandEvent) {
+ metricsTableView.expandedRows.add(recordExpandEvent.getRecord().getAttributeAsInt(
+ MetricsViewDataSource.FIELD_METRIC_DEF_ID));
+ redrawGraphs();
+ }
+
+ });
+ addRecordCollapseHandler(new RecordCollapseHandler() {
+ @Override
+ public void onRecordCollapse(RecordCollapseEvent recordCollapseEvent) {
+ metricsTableView.expandedRows.remove(recordCollapseEvent.getRecord().getAttributeAsInt(
+ MetricsViewDataSource.FIELD_METRIC_DEF_ID));
+ redrawGraphs();
+ }
+ });
+ addSortChangedHandler(new SortChangedHandler() {
+ @Override
+ public void onSortChanged(SortEvent sortEvent) {
+ redrawGraphs();
+ }
+ });
+ addDataArrivedHandler(new DataArrivedHandler() {
+ @Override
+ public void onDataArrived(DataArrivedEvent dataArrivedEvent) {
+ int startRow = dataArrivedEvent.getStartRow();
+ int endRow = dataArrivedEvent.getEndRow();
+ for (int i = startRow; i < endRow; i++) {
+ if (null != metricsTableView.expandedRows
+ && metricsTableView.expandedRows.contains(getRecord(i).getAttributeAsInt(
+ MetricsViewDataSource.FIELD_METRIC_DEF_ID))) {
+ expandRecord(getRecord(i));
+ }
+ }
+ }
+ });
+
+ }
+
+ @Override
+ protected Canvas getExpansionComponent(final ListGridRecord record) {
+ final Integer definitionId = record.getAttributeAsInt(MetricsViewDataSource.FIELD_METRIC_DEF_ID);
+ final Integer resourceId = record.getAttributeAsInt(MetricsViewDataSource.FIELD_RESOURCE_ID);
+ VLayout vLayout = new VLayout();
+ vLayout.setPadding(5);
+
+ final String chartId = "rChart-" + resourceId + "-" + definitionId;
+ HTMLFlow htmlFlow = new HTMLFlow(MetricD3Graph.createGraphMarkerTemplate(chartId,
+ TREEVIEW_DETAIL_CHART_HEIGHT));
+ vLayout.addMember(htmlFlow);
+
+ int[] definitionArrayIds = new int[1];
+ definitionArrayIds[0] = definitionId;
+ GWTServiceLookup.getMeasurementDataService().findDataForResource(resourceId, definitionArrayIds,
+ measurementUserPrefs.getMetricRangePreferences().begin,
+ measurementUserPrefs.getMetricRangePreferences().end, NUM_METRIC_POINTS,
+ new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.warn("Error retrieving recent metrics charting data for resource [" + resourceId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(List<List<MeasurementDataNumericHighLowComposite>> results) {
+ if (!results.isEmpty()) {
+
+ //load the data results for the given metric definition
+ List<MeasurementDataNumericHighLowComposite> measurementList = results.get(0);
+
+ MeasurementDefinition measurementDefinition = null;
+ for (MeasurementDefinition definition : resource.getResourceType().getMetricDefinitions()) {
+ if (definition.getId() == definitionId) {
+ measurementDefinition = definition;
+ break;
+ }
+ }
+
+ MetricGraphData metricGraphData = MetricGraphData.createForResource(resourceId,
+ resource.getName(), measurementDefinition, measurementList, null);
+ metricGraphData.setHideLegend(true);
+
+ StackedBarMetricGraphImpl graph = GWT.create(StackedBarMetricGraphImpl.class);
+ graph.setMetricGraphData(metricGraphData);
+ final MetricD3Graph graphView = new MetricD3Graph(graph, abstractD3GraphListView);
+ new Timer() {
+ @Override
+ public void run() {
+ graphView.drawJsniChart();
+ BrowserUtility.graphSparkLines();
+
+ }
+ }.schedule(150);
+
+ } else {
+ Log.warn("No chart data retrieving for resource [" + resourceId + "-" + definitionId + "]");
+
+ }
+ }
+ });
+
+ return vLayout;
+ }
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java
new file mode 100644
index 0000000..5c2fe25
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java
@@ -0,0 +1,307 @@
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.table;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
+
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.criteria.Criteria;
+import org.rhq.core.domain.measurement.DataType;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.MeasurementSchedule;
+import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
+import org.rhq.core.domain.measurement.ui.MetricDisplaySummary;
+import org.rhq.core.domain.measurement.ui.MetricDisplayValue;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
+import org.rhq.enterprise.gui.coregui.client.util.Log;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.async.Command;
+import org.rhq.enterprise.gui.coregui.client.util.async.CountDownLatch;
+import org.rhq.enterprise.gui.coregui.client.util.preferences.MeasurementUserPreferences;
+
+/**
+ * A simple data source to read in metric data summaries for a resource.
+ * This doesn't support paging - everything is returned in one query. Since
+ * the number of metrics per resource is relatively small (never more than tens of them),
+ * we just load them all in at once.
+ *
+ * @author John Mazzitelli
+ * @author Mike Thompson
+ */
+public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, Criteria> {
+
+ private static final int NUMBER_OF_METRIC_POINTS = 60;
+ public static final String FIELD_SPARKLINE = "sparkline";
+ public static final String FIELD_METRIC_LABEL = "label";
+ public static final String FIELD_ALERT_COUNT = "alertCount";
+ public static final String FIELD_MIN_VALUE = "min";
+ public static final String FIELD_MAX_VALUE = "max";
+ public static final String FIELD_AVG_VALUE = "avg";
+ public static final String FIELD_LAST_VALUE = "last";
+ public static final String FIELD_METRIC_DEF_ID = "defId";
+ public static final String FIELD_METRIC_SCHED_ID = "schedId";
+ public static final String FIELD_METRIC_UNITS = "units";
+ public static final String FIELD_METRIC_NAME = "name";
+ public static final String FIELD_RESOURCE_ID = "resourceId";
+ private final Resource resource;
+ private List<MetricDisplaySummary> metricDisplaySummaries;
+ private List<List<MeasurementDataNumericHighLowComposite>> metricsDataList;
+ private int[] definitionArrayIds;
+ private final MeasurementUserPreferences measurementUserPrefs;
+
+ public MetricsViewDataSource(Resource resource) {
+ this.resource = resource;
+ measurementUserPrefs = new MeasurementUserPreferences(UserSessionManager.getUserPreferences());
+ }
+
+ /**
+ * The view that contains the list grid which will display this datasource's data will call this
+ * method to get the field information which is used to control the display of the data.
+ *
+ * @return list grid fields used to display the datasource data
+ */
+ public ArrayList<ListGridField> getListGridFields() {
+ ArrayList<ListGridField> fields = new ArrayList<ListGridField>(7);
+
+ ListGridField sparklineField = new ListGridField(FIELD_SPARKLINE, MSG.chart_metrics_sparkline_header());
+ sparklineField.setCellFormatter(new CellFormatter() {
+ @Override
+ public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
+ if (value == null) {
+ return "";
+ }
+ String contents = "<span id='sparkline_" + resource.getId() + "-"
+ + record.getAttributeAsInt(FIELD_METRIC_DEF_ID) + "' class='dynamicsparkline' width='70' "
+ + "values='" + record.getAttribute(FIELD_SPARKLINE) + "'></span>";
+ return contents;
+
+ }
+ });
+
+ sparklineField.setWidth(80);
+ fields.add(sparklineField);
+
+ ListGridField nameField = new ListGridField(FIELD_METRIC_LABEL, MSG.common_title_name());
+ nameField.setWidth("30%");
+ fields.add(nameField);
+
+ ListGridField minField = new ListGridField(FIELD_MIN_VALUE, MSG.view_resource_monitor_table_min());
+ minField.setWidth("15%");
+ fields.add(minField);
+
+ ListGridField maxField = new ListGridField(FIELD_MAX_VALUE, MSG.view_resource_monitor_table_max());
+ maxField.setWidth("15%");
+ fields.add(maxField);
+
+ ListGridField avgField = new ListGridField(FIELD_AVG_VALUE, MSG.view_resource_monitor_table_avg());
+ avgField.setWidth("15%");
+ fields.add(avgField);
+
+ ListGridField lastField = new ListGridField(FIELD_LAST_VALUE, MSG.view_resource_monitor_table_last());
+ lastField.setWidth("15%");
+ fields.add(lastField);
+
+ ListGridField alertsField = new ListGridField(FIELD_ALERT_COUNT, MSG.common_title_alerts());
+ alertsField.setWidth("10%");
+ fields.add(alertsField);
+
+ return fields;
+ }
+
+ @Override
+ public MetricDisplaySummary copyValues(Record from) {
+ // we should never need this method - we only go in one direction
+ // if we ever need this, just have copyValues store an "object" attribute whose value is "from"
+ // which this method then just reads out. Since we don't need this now, save memory by not
+ // keeping the MetricDisplayValue around
+ return null;
+ }
+
+ @Override
+ public ListGridRecord copyValues(MetricDisplaySummary from) {
+ MeasurementUtility.formatSimpleMetrics(from);
+
+ ListGridRecord record = new ListGridRecord();
+ record.setAttribute(FIELD_SPARKLINE, getCsvMetricsForSparkline(from.getDefinitionId()));
+ record.setAttribute(FIELD_METRIC_LABEL, from.getLabel());
+ record.setAttribute(FIELD_ALERT_COUNT, String.valueOf(from.getAlertCount()));
+ record.setAttribute(FIELD_MIN_VALUE, getMetricStringValue(from.getMinMetric()));
+ record.setAttribute(FIELD_MAX_VALUE, getMetricStringValue(from.getMaxMetric()));
+ record.setAttribute(FIELD_AVG_VALUE, getMetricStringValue(from.getAvgMetric()));
+ record.setAttribute(FIELD_LAST_VALUE, getMetricStringValue(from.getLastMetric()));
+ record.setAttribute(FIELD_METRIC_DEF_ID, from.getDefinitionId());
+ record.setAttribute(FIELD_METRIC_SCHED_ID, from.getScheduleId());
+ record.setAttribute(FIELD_METRIC_UNITS, from.getUnits());
+ record.setAttribute(FIELD_METRIC_NAME, from.getMetricName());
+ record.setAttribute(FIELD_RESOURCE_ID, resource.getId());
+ return record;
+ }
+
+ private String getCsvMetricsForSparkline(int definitionId) {
+ StringBuilder sb = new StringBuilder();
+ List<MeasurementDataNumericHighLowComposite> selectedMetricsList = getMeasurementsForMeasurementDefId(definitionId);
+
+ for (int i = 0; i < selectedMetricsList.size(); i++) {
+ MeasurementDataNumericHighLowComposite measurementData = selectedMetricsList.get(i);
+ if (!Double.isNaN(measurementData.getValue())) {
+ sb.append((int) measurementData.getValue());
+ sb.append(",");
+ }
+ }
+
+ if (sb.toString().endsWith(",")) {
+ sb.setLength(sb.length() - 1);
+ }
+
+ return sb.toString();
+ }
+
+ List<MeasurementDataNumericHighLowComposite> getMeasurementsForMeasurementDefId(int definitionId) {
+ int selectedIndex = 0;
+
+ // find the ordinal position as specified when querying the metrics
+ for (int i = 0; i < definitionArrayIds.length; i++) {
+ if (definitionArrayIds[i] == definitionId) {
+ selectedIndex = i;
+ break;
+ }
+ }
+
+ return metricsDataList.get(selectedIndex);
+ }
+
+ protected String getMetricStringValue(MetricDisplayValue value) {
+ return (value != null) ? value.toString() : "";
+ }
+
+ @Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // NOTE: we don't use criterias for this datasource, just return null
+ return null;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {
+
+ GWTServiceLookup.getMeasurementScheduleService().findSchedulesForResourceAndType(resource.getId(),
+ DataType.MEASUREMENT, null, true, new AsyncCallback<ArrayList<MeasurementSchedule>>() {
+ @Override
+ public void onSuccess(ArrayList<MeasurementSchedule> measurementSchedules) {
+ int[] scheduleIds = new int[measurementSchedules.size()];
+ int i = 0;
+ for (MeasurementSchedule measurementSchedule : measurementSchedules) {
+ scheduleIds[i++] = measurementSchedule.getId();
+ }
+
+ final CountDownLatch countDownLatch = CountDownLatch.create(2, new Command() {
+
+ @Override
+ public void execute() {
+ response.setData(buildRecords(metricDisplaySummaries));
+ processResponse(request.getRequestId(), response);
+
+ new Timer() {
+
+ @Override
+ public void run() {
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+ }
+ });
+
+ queryResourceMetrics(resource, measurementUserPrefs.getMetricRangePreferences().begin,
+ measurementUserPrefs.getMetricRangePreferences().end, countDownLatch);
+ queryMetricDisplaySummaries(scheduleIds, measurementUserPrefs.getMetricRangePreferences().begin,
+ measurementUserPrefs.getMetricRangePreferences().end, countDownLatch);
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Cannot load schedules", caught);
+ }
+ });
+ }
+
+ private void queryMetricDisplaySummaries(int[] scheduleIds, Long startTime, Long endTime,
+ final CountDownLatch countDownLatch) {
+ GWTServiceLookup.getMeasurementChartsService().getMetricDisplaySummariesForResource(resource.getId(),
+ scheduleIds, startTime, endTime, new AsyncCallback<ArrayList<MetricDisplaySummary>>() {
+ @Override
+ public void onSuccess(ArrayList<MetricDisplaySummary> metricDisplaySummaries) {
+ setMetricDisplaySummaries(metricDisplaySummaries);
+ countDownLatch.countDown();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Cannot load metrics", caught);
+ countDownLatch.countDown();
+ }
+ }
+
+ );
+ }
+
+ void setMetricDisplaySummaries(List<MetricDisplaySummary> metricDisplaySummaries) {
+ this.metricDisplaySummaries = metricDisplaySummaries;
+ }
+
+ public void queryResourceMetrics(final Resource resource, Long startTime, Long endTime,
+ final CountDownLatch countDownLatch) {
+ Set<MeasurementDefinition> definitions = resource.getResourceType().getMetricDefinitions();
+
+ //build id mapping for measurementDefinition instances Ex. Free Memory -> MeasurementDefinition[100071]
+ final HashMap<String, MeasurementDefinition> measurementDefMap = new HashMap<String, MeasurementDefinition>();
+ for (MeasurementDefinition definition : definitions) {
+ measurementDefMap.put(definition.getDisplayName(), definition);
+ }
+ //bundle definition ids for asynch call.
+ definitionArrayIds = new int[definitions.size()];
+ final String[] displayOrder = new String[definitions.size()];
+ measurementDefMap.keySet().toArray(displayOrder);
+ //sort the charting data ex. Free Memory, Free Swap Space,..System Load
+ Arrays.sort(displayOrder);
+
+ //organize definitionArrayIds for ordered request on server.
+ int index = 0;
+ for (String definitionToDisplay : displayOrder) {
+ definitionArrayIds[index++] = measurementDefMap.get(definitionToDisplay).getId();
+ }
+
+ GWTServiceLookup.getMeasurementDataService().findDataForResource(resource.getId(), definitionArrayIds,
+ startTime, endTime, NUMBER_OF_METRIC_POINTS,
+ new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.warn("Error retrieving recent metrics charting data for resource [" + resource.getId() + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(List<List<MeasurementDataNumericHighLowComposite>> measurementDataList) {
+
+ if (null != measurementDataList && !measurementDataList.isEmpty()) {
+ metricsDataList = measurementDataList;
+ countDownLatch.countDown();
+ }
+ }
+ });
+
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/ResourceMetricAvailabilityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/ResourceMetricAvailabilityView.java
new file mode 100644
index 0000000..9d6b892
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/ResourceMetricAvailabilityView.java
@@ -0,0 +1,208 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.table;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+
+import org.rhq.core.domain.measurement.MeasurementUnits;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.composite.ResourceAvailabilitySummary;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementConverterClient;
+import org.rhq.enterprise.gui.coregui.client.util.enhanced.EnhancedVLayout;
+
+/**
+ * This shows the availability history for a resource.
+ *
+ * @author Jay Shaughnessy
+ * @author John Mazzitelli
+ * @author Mike Thompson
+ */
+public class ResourceMetricAvailabilityView extends EnhancedVLayout {
+
+ private Resource resource;
+ private StaticTextItem currentField;
+ private StaticTextItem availField;
+ private StaticTextItem availTimeField;
+ private StaticTextItem downField;
+ private StaticTextItem downTimeField;
+ private StaticTextItem disabledField;
+ private StaticTextItem disabledTimeField;
+ private StaticTextItem failureCountField;
+ private StaticTextItem disabledCountField;
+ private StaticTextItem mtbfField;
+ private StaticTextItem mttrField;
+ private StaticTextItem unknownField;
+ private StaticTextItem currentTimeField;
+
+ public ResourceMetricAvailabilityView(Resource resource) {
+ super();
+
+ this.resource = resource;
+
+ setWidth100();
+ setHeight(165);
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ addMember(createSummaryForm());
+ }
+
+ private DynamicForm createSummaryForm() {
+ DynamicForm form = new DynamicForm();
+ form.setWidth100();
+ form.setAutoHeight();
+ form.setMargin(10);
+ form.setNumCols(4);
+
+ // row 1
+ currentField = new StaticTextItem("current", MSG.view_resource_monitor_availability_currentStatus());
+ currentField.setWrapTitle(false);
+ currentField.setColSpan(4);
+
+ // row 2
+ availField = new StaticTextItem("avail", MSG.view_resource_monitor_availability_availability());
+ availField.setWrapTitle(false);
+ prepareTooltip(availField, MSG.view_resource_monitor_availability_availability_tooltip());
+
+ availTimeField = new StaticTextItem("availTime", MSG.view_resource_monitor_availability_uptime());
+ availTimeField.setWrapTitle(false);
+ prepareTooltip(availTimeField, MSG.view_resource_monitor_availability_uptime_tooltip());
+
+ // row 3
+ downField = new StaticTextItem("down", MSG.view_resource_monitor_availability_down());
+ downField.setWrapTitle(false);
+ prepareTooltip(downField, MSG.view_resource_monitor_availability_down_tooltip());
+
+ downTimeField = new StaticTextItem("downTime", MSG.view_resource_monitor_availability_downtime());
+ downTimeField.setWrapTitle(false);
+ prepareTooltip(downTimeField, MSG.view_resource_monitor_availability_downtime_tooltip());
+
+ // row 4
+ disabledField = new StaticTextItem("disabled", MSG.view_resource_monitor_availability_disabled());
+ disabledField.setWrapTitle(false);
+ prepareTooltip(disabledField, MSG.view_resource_monitor_availability_disabled_tooltip());
+
+ disabledTimeField = new StaticTextItem("disabledTime", MSG.view_resource_monitor_availability_disabledTime());
+ disabledTimeField.setWrapTitle(false);
+ prepareTooltip(disabledTimeField, MSG.view_resource_monitor_availability_disabledTime_tooltip());
+
+ // row 5
+ failureCountField = new StaticTextItem("failureCount", MSG.view_resource_monitor_availability_numFailures());
+ failureCountField.setWrapTitle(false);
+ prepareTooltip(failureCountField, MSG.view_resource_monitor_availability_numFailures_tooltip());
+
+ disabledCountField = new StaticTextItem("disabledCount", MSG.view_resource_monitor_availability_numDisabled());
+ disabledCountField.setWrapTitle(false);
+ prepareTooltip(disabledCountField, MSG.view_resource_monitor_availability_numDisabled_tooltip());
+
+ // row 6
+ mtbfField = new StaticTextItem("mtbf", MSG.view_resource_monitor_availability_mtbf());
+ mtbfField.setWrapTitle(false);
+ prepareTooltip(mtbfField, MSG.view_resource_monitor_availability_mtbf_tooltip());
+
+ mttrField = new StaticTextItem("mttr", MSG.view_resource_monitor_availability_mttr());
+ mttrField.setWrapTitle(false);
+ prepareTooltip(mttrField, MSG.view_resource_monitor_availability_mttr_tooltip());
+
+ // row 7
+ unknownField = new StaticTextItem("unknown");
+ unknownField.setWrapTitle(false);
+ unknownField.setColSpan(4);
+ unknownField.setShowTitle(false);
+
+ // row 8
+ currentTimeField = new StaticTextItem("currentTime");
+ currentTimeField.setWrapTitle(false);
+ currentTimeField.setColSpan(4);
+ currentTimeField.setShowTitle(false);
+
+ form.setItems(currentField, availField, availTimeField, downField, downTimeField, disabledField,
+ disabledTimeField, failureCountField, disabledCountField, mtbfField, mttrField, unknownField,
+ currentTimeField);
+
+ reloadSummaryData();
+
+ return form;
+ }
+
+ private void reloadSummaryData() {
+ GWTServiceLookup.getResourceService().getResourceAvailabilitySummary(resource.getId(),
+ new AsyncCallback<ResourceAvailabilitySummary>() {
+
+ @Override
+ public void onSuccess(ResourceAvailabilitySummary result) {
+
+ currentField.setValue(MSG.view_resource_monitor_availability_currentStatus_value(result
+ .getCurrent().getName(), TimestampCellFormatter.format(result.getLastChange().getTime())));
+ availField.setValue(MeasurementConverterClient.format(result.getUpPercentage(),
+ MeasurementUnits.PERCENTAGE, true));
+ availTimeField.setValue(MeasurementConverterClient.format((double) result.getUpTime(),
+ MeasurementUnits.MILLISECONDS, true));
+ downField.setValue(MeasurementConverterClient.format(result.getDownPercentage(),
+ MeasurementUnits.PERCENTAGE, true));
+ downTimeField.setValue(MeasurementConverterClient.format((double) result.getDownTime(),
+ MeasurementUnits.MILLISECONDS, true));
+ disabledField.setValue(MeasurementConverterClient.format(result.getDisabledPercentage(),
+ MeasurementUnits.PERCENTAGE, true));
+ disabledTimeField.setValue(MeasurementConverterClient.format((double) result.getDisabledTime(),
+ MeasurementUnits.MILLISECONDS, true));
+ failureCountField.setValue(result.getFailures());
+ disabledCountField.setValue(result.getDisabled());
+ mtbfField.setValue(MeasurementConverterClient.format((double) result.getMTBF(),
+ MeasurementUnits.MILLISECONDS, true));
+ mttrField.setValue(MeasurementConverterClient.format((double) result.getMTTR(),
+ MeasurementUnits.MILLISECONDS, true));
+
+ if (result.getUnknownTime() > 0L) {
+ unknownField.setValue(MSG.view_resource_monitor_availability_unknown(MeasurementConverterClient
+ .format((double) result.getUnknownTime(), MeasurementUnits.MILLISECONDS, true)));
+ } else {
+ unknownField.setValue("");
+ }
+
+ currentTimeField.setValue(MSG.view_resource_monitor_availability_currentAsOf(TimestampCellFormatter
+ .format(result.getCurrentTime())));
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ currentField.setValue(MSG.common_label_error());
+ CoreGUI.getErrorHandler()
+ .handleError(MSG.view_resource_monitor_availability_summaryError(), caught);
+ }
+ });
+ }
+
+ private void prepareTooltip(FormItem item, String tooltip) {
+ item.setHoverWidth(400);
+ item.setPrompt(tooltip);
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java
index 1edd076..94fd1e8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/searchbar/BasicSearchStrategy.java
@@ -26,7 +26,6 @@ import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.form.fields.events.KeyUpEvent;
import com.smartgwt.client.widgets.grid.HoverCustomizer;
import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
@@ -89,17 +88,14 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
*/
@Override
public void onRecordClick(RecordClickEvent event) {
- Log.debug("BasicSearchStrategy click");
String kind = event.getRecord().getAttribute(ATTR_KIND);
String searchExpression;
if (kind.equals("SAVED") || kind.equals("GLOBAL")) {
- Log.debug("Saved or Global Search Click");
searchExpression = event.getRecord().getAttribute(ATTR_PATTERN);
} else {
- Log.debug("Regular Search Click");
searchExpression = event.getRecord().getAttribute(ATTR_NAME);
}
@@ -112,14 +108,12 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
@Override
public void searchFocusHandler() {
- Log.debug("focus in BasicSearchStrategy");
String searchExpression = searchBar.getSearchTextItem().getValueAsString();
doSearch(searchExpression);
}
@Override
public void searchKeyUpHandler(KeyUpEvent keyUpEvent) {
- Log.debug("Keyup in BasicSearchStrategy: " + keyUpEvent.getKeyName());
String searchExpression = searchBar.getSearchTextItem().getValueAsString();
doSearch(searchExpression);
}
@@ -131,20 +125,16 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
private void doSearch(String searchExpression) {
if (isSearchInProgress) {
- Log.debug("Adding pending search [" + searchExpression + "]");
pendingSearchExpression = (null == searchExpression) ? "" : searchExpression;
return;
}
- Log.debug("Search Start");
isSearchInProgress = true;
if (null == searchExpression || searchExpression.isEmpty()) {
- Log.debug("Empty Search expression");
getSearchSuggestions(SearchSubsystem.RESOURCE, null, 0);
} else {
- Log.debug("doSearch: " + searchExpression);
getSearchSuggestions(SearchSubsystem.RESOURCE, searchBar.getSearchTextItem().getValueAsString(), searchBar
.getSearchTextItem().getValueAsString().length());
}
@@ -154,7 +144,6 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
final long suggestStart = System.currentTimeMillis();
- Log.debug("Searching for: " + expression);
searchService.getTabAwareSuggestions(searchSubsystem, expression, caretPosition, null,
new AsyncCallback<List<SearchSuggestion>>() {
@@ -179,7 +168,6 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
ds.setFields(idField, valueField);
searchBarPickListGrid.setDataSource(ds);
- ListGridField[] fields = searchBarPickListGrid.getAllFields();
searchBarPickListGrid.getField(ATTR_VALUE).setShowHover(true);
searchBarPickListGrid.getField(ATTR_VALUE).setHoverCustomizer(new HoverCustomizer() {
@@ -223,7 +211,7 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
searchBarPickListGrid.setData(new ListGridRecord[] {});
searchBarPickListGrid.fetchData();
} catch (Exception e) {
- Log.debug("Caught exception on fetchData: " + e);
+ Log.info("Caught exception on fetchData: " + e);
}
long suggestFetchTime = System.currentTimeMillis() - suggestStart;
@@ -250,7 +238,6 @@ public class BasicSearchStrategy extends AbstractSearchStrategy {
@Override
public void onFailure(Throwable caught) {
- Log.debug("Search End");
isSearchInProgress = false;
pendingSearchExpression = null;
CoreGUI.getErrorHandler().handleError(MSG.view_searchBar_suggest_failSuggest(), caught);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/enhanced/Enhanced.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/enhanced/Enhanced.java
index 10505e9..a069a5d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/enhanced/Enhanced.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/enhanced/Enhanced.java
@@ -31,5 +31,5 @@ import org.rhq.enterprise.gui.coregui.client.Messages;
*/
public interface Enhanced {
- Messages MSG = CoreGUI.getMessages();
+ final static Messages MSG = CoreGUI.getMessages();
}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index 19d3fa5..abcfa62 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -20,6 +20,10 @@ chart_hover_period_label = Period
chart_hover_start_label = Start
chart_hover_time_format = %I:%M:%S %p
chart_ie_not_supported = Charting is not available for this browser.
+chart_metrics= Metrics
+chart_metrics_collapse_tooltip= Click here to see additional tabular availability data.
+chart_metrics_expand_tooltip= Click here to collapse additional availability detail.
+chart_metrics_sparkline_header= Chart
chart_no_data_label = No Data
chart_single_value_label = Value
chart_slider_button_bar_day = Day
@@ -1792,6 +1796,7 @@ view_messageCenter_messageTime = Time
view_messageCenter_messageTitle = Message Center
view_messageCenter_noRecentMessages = No Recent Messages
view_messageCenter_stackTraceFollows = --- STACK TRACE FOLLOWS ---
+view_metric_addToDashboard = Add to Dashboard
view_metric_traits = Traits
view_metric_viewTraitHistory = Value History for Trait [{0}]
view_operationHistoryDetails_dateCompleted = Date Completed
@@ -2111,7 +2116,7 @@ view_titleBar_common_updateTagsSuccessful = The tags for [{0}] have been updated
view_titleBar_group_failInfo = Failed to get general info on group [{0}] with ID [{1}]
view_titleBar_group_summary_collapsedTooltip = Click to show more details for this group
view_titleBar_group_summary_expandedTooltip = Click to hide details for this group
-view_tree_common_contextMenu_addChartToDashboard = Add chart to dashboard [{0}]
+view_tree_common_contextMenu_addChartToDashboard = Add Graph to Dashboard [{0}]
view_tree_common_contextMenu_editPluginConfiguration = Edit [{0}] Plugin Configuration
view_tree_common_contextMenu_editResourceConfiguration = Edit [{0}] Resource Configuration
view_tree_common_contextMenu_groupGraph = Group Metric Graph
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
index f71f907..3a79eeb 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
@@ -48,6 +48,10 @@ chart_hover_date_format = %d.%m.%y
##chart_hover_start_label = Start
chart_hover_time_format = %H:%M:%S
##chart_ie_not_supported = Charting is not available for this browser.
+##chart_metrics= Metrics
+##chart_metrics_collapse_tooltip= Click here to see additional tabular availability data.
+##chart_metrics_expand_tooltip= Click here to collapse additional availability detail.
+##chart_metrics_sparkline_header= Chart
##chart_no_data_label = No Data
##chart_single_value_label = Value
##chart_slider_button_bar_day = Day
@@ -1804,6 +1808,7 @@ view_messageCenter_messageTime = Čas
view_messageCenter_messageTitle = Centrum zpráv
view_messageCenter_noRecentMessages = Žádné nové zprávy
view_messageCenter_stackTraceFollows = --- VÝPIS ZÁSOBNÍKU NÍŽE ---
+##view_metric_addToDashboard = Add to Dashboard
view_metric_traits = Vlastnosti
view_metric_viewTraitHistory = Historie hodnot pro vlastnost [{0}]
view_operationHistoryDetails_dateCompleted = Datum ukončení
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index 524dcc0..e79504c 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -23,6 +23,10 @@ chart_hover_period_label = Zeitraum
chart_hover_start_label = Start
chart_hover_time_format = %H:%M:%S
chart_ie_not_supported = Charting ist bei diesem Browser nicht unterstützt
+##chart_metrics= Metrics
+##chart_metrics_collapse_tooltip= Click here to see additional tabular availability data.
+##chart_metrics_expand_tooltip= Click here to collapse additional availability detail.
+##chart_metrics_sparkline_header= Chart
chart_no_data_label = Keine Daten vorhanden
##chart_single_value_label = Value
chart_slider_button_bar_day = Tag
@@ -1591,6 +1595,7 @@ view_messageCenter_messageTime = Zeitpukt
view_messageCenter_messageTitle = Nachrichtencenter
view_messageCenter_noRecentMessages = Keine aktuellen Nachrichten
view_messageCenter_stackTraceFollows = --- STACK TRACE FOLGT ---
+##view_metric_addToDashboard = Add to Dashboard
view_metric_traits = Traits
view_metric_viewTraitHistory = Werteverlauf für Trait [{0}]
##view_operationCreateWizard_error_scheduleOperationFailure = Failed to schedule operation execution.
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
index cb0c35f..3f1f701 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
@@ -24,6 +24,10 @@
##chart_hover_date_format = %m/%d/%y
##chart_hover_time_format = %I:%M:%S %p
##chart_ie_not_supported = Charting is not available for this browser.
+##chart_metrics= Metrics
+##chart_metrics_collapse_tooltip= Click here to see additional tabular availability data.
+##chart_metrics_expand_tooltip= Click here to collapse additional availability detail.
+##chart_metrics_sparkline_header= Chart
##chart_no_data_label = No Data
##chart_single_value_label = Value
##chart_slider_button_bar_minute = Min
@@ -1775,6 +1779,7 @@ view_messageCenter_messageTime = 時間
view_messageCenter_messageTitle = メッセージセンター
view_messageCenter_noRecentMessages = 最近のメッセージはありません
view_messageCenter_stackTraceFollows = --- スタックトレース ---
+##view_metric_addToDashboard = Add to Dashboard
view_metric_traits = トレイト
view_metric_viewTraitHistory = トレイト [{0}] のための値の履歴
view_operationHistoryDetails_dateCompleted = 完了日
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
index 32dc73d..3d40d83 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
@@ -22,6 +22,10 @@
##chart_hover_date_format = %m/%d/%y
##chart_hover_time_format = %I:%M:%S %p
##chart_ie_not_supported = Charting is not available for this browser.
+##chart_metrics= Metrics
+##chart_metrics_collapse_tooltip= Click here to see additional tabular availability data.
+##chart_metrics_expand_tooltip= Click here to collapse additional availability detail.
+##chart_metrics_sparkline_header= Chart
##chart_no_data_label = No Data
##chart_single_value_label = Value
##chart_slider_button_bar_minute = Min
@@ -1496,6 +1500,7 @@ view_messageCenter_messageTime = 시간
view_messageCenter_messageTitle = 메시지 센터
view_messageCenter_noRecentMessages = 최근 메시지는 없습니다
view_messageCenter_stackTraceFollows = --- 스택 추적 ---
+##view_metric_addToDashboard = Add to Dashboard
view_metric_traits = 특성
view_metric_viewTraitHistory = 특성 [{0}]에 대한 값 기록
view_operationHistoryDetails_dateCompleted = 완료일
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
index f4419e1..de43fa4 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
@@ -21,6 +21,10 @@
##chart_hover_date_format = %m/%d/%y
##chart_hover_time_format = %I:%M:%S %p
##chart_ie_not_supported = Charting is not available for this browser.
+##chart_metrics= Metrics
+##chart_metrics_collapse_tooltip= Click here to see additional tabular availability data.
+##chart_metrics_expand_tooltip= Click here to collapse additional availability detail.
+##chart_metrics_sparkline_header= Chart
##chart_no_data_label = No Data
##chart_single_value_label = Value
##chart_slider_button_bar_minute = Min
@@ -1808,6 +1812,7 @@ view_messageCenter_messageTime = Tempo
view_messageCenter_messageTitle = Centro de Mensagens
view_messageCenter_noRecentMessages = N\u00E3o existem Mensagens Recentes
view_messageCenter_stackTraceFollows = --- STACK TRACE FOLLOWS ---
+##view_metric_addToDashboard = Add to Dashboard
view_metric_traits = Traits
view_metric_viewTraitHistory = Value History for Trait [{0}]
view_operationCreateWizard_button_execute = Execute
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
index d75b76e..669d8d6 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
@@ -21,6 +21,10 @@
##chart_hover_date_format = %m/%d/%y
##chart_hover_time_format = %I:%M:%S %p
##chart_ie_not_supported = Charting is not available for this browser.
+##chart_metrics= Metrics
+##chart_metrics_collapse_tooltip= Click here to see additional tabular availability data.
+##chart_metrics_expand_tooltip= Click here to collapse additional availability detail.
+##chart_metrics_sparkline_header= Chart
##chart_no_data_label = No Data
##chart_single_value_label = Value
##chart_slider_button_bar_minute = Min
@@ -1728,6 +1732,7 @@
#view_messageCenter_messageTitle = Message Center
#view_messageCenter_noRecentMessages = No Recent Messages
#view_messageCenter_stackTraceFollows = --- STACK TRACE FOLLOWS ---
+##view_metric_addToDashboard = Add to Dashboard
#view_metric_traits = Traits
#view_metric_viewTraitHistory = Value History for Trait [{0}]
#view_operationHistoryDetails_dateCompleted = Date Completed
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
index a9a24df..b15023f 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
@@ -21,6 +21,10 @@
##chart_hover_date_format = %m/%d/%y
##chart_hover_time_format = %I:%M:%S %p
##chart_ie_not_supported = Charting is not available for this browser.
+##chart_metrics= Metrics
+##chart_metrics_collapse_tooltip= Click here to see additional tabular availability data.
+##chart_metrics_expand_tooltip= Click here to collapse additional availability detail.
+##chart_metrics_sparkline_header= Chart
##chart_no_data_label = No Data
##chart_single_value_label = Value
##chart_slider_button_bar_minute = Min
@@ -1776,6 +1780,7 @@ view_messageCenter_messageTime = \u65f6\u95f4
view_messageCenter_messageTitle = \u6d88\u606f\u4e2d\u5fc3
view_messageCenter_noRecentMessages = \u65e0\u8fd1\u671f\u6d88\u606f
view_messageCenter_stackTraceFollows = --- \u540e\u9762\u662f\u5f02\u5e38\u4fe1\u606f ---
+##view_metric_addToDashboard = Add to Dashboard
view_metric_traits = \u7279\u5f81
view_metric_viewTraitHistory = Value History for Trait [{0}]
view_operationHistoryDetails_dateCompleted = \u5b8c\u6210\u65e5\u671f
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/js/rhq.js b/modules/enterprise/gui/coregui/src/main/webapp/js/rhq.js
index 40c7ca8..ef65e69 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/js/rhq.js
+++ b/modules/enterprise/gui/coregui/src/main/webapp/js/rhq.js
@@ -38,9 +38,10 @@ if (!window.console.log) window.console.log = function () {
* @param singleValueLabel
* @param chartXaxisTimeFormatHours
* @param chartXaxisTimeFormatHoursMinutes
+ * @param showLegend
* @constructor
*/
-var ChartContext = function (chartId, chartHeight, metricsData, xAxisLabel, chartTitle, yAxisUnits, minChartTitle, avgChartTitle, peakChartTitle, dateLabel, timeLabel, downLabel, unknownLabel, noDataLabel, hoverStartLabel, hoverEndLabel, hoverPeriodLabel, hoverBarLabel, chartHoverTimeFormat, chartHoverDateFormat, isPortalGraph, portalId, buttonBarDateTimeFormat, singleValueLabel, chartXaxisTimeFormatHours, chartXaxisTimeFormatHoursMinutes) {
+var ChartContext = function (chartId, chartHeight, metricsData, xAxisLabel, chartTitle, yAxisUnits, minChartTitle, avgChartTitle, peakChartTitle, dateLabel, timeLabel, downLabel, unknownLabel, noDataLabel, hoverStartLabel, hoverEndLabel, hoverPeriodLabel, hoverBarLabel, chartHoverTimeFormat, chartHoverDateFormat, isPortalGraph, portalId, buttonBarDateTimeFormat, singleValueLabel, chartXaxisTimeFormatHours, chartXaxisTimeFormatHoursMinutes, hideLegend) {
"use strict";
if (!(this instanceof ChartContext)) {
throw new Error("ChartContext function cannot be called as a function.")
@@ -78,6 +79,7 @@ var ChartContext = function (chartId, chartHeight, metricsData, xAxisLabel, char
this.buttonBarDateTimeFormat = buttonBarDateTimeFormat;
this.chartXaxisTimeFormatHours = chartXaxisTimeFormatHours;
this.chartXaxisTimeFormatHoursMinutes = chartXaxisTimeFormatHoursMinutes;
+ this.hideLegend = hideLegend;
},
/**
10 years, 9 months
[rhq] Branch 'mtho11/consolidated-metrics' - modules/enterprise
by mike thompson
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/AddToDashboardComponent.java | 1 +
1 file changed, 1 insertion(+)
New commits:
commit da83e836cf14ca8fd6aa2a7195de03a80083eb54
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Thu Jul 25 12:34:13 2013 -0700
Consolidated Metrics - Bug fixes.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/AddToDashboardComponent.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/AddToDashboardComponent.java
index cfb1947..ce4f8ef 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/AddToDashboardComponent.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/AddToDashboardComponent.java
@@ -76,6 +76,7 @@ public class AddToDashboardComponent extends ToolStrip implements Enhanced {
addSpacer(15);
dashboardSelectItem = new SelectItem();
addToDashboardButton = new IButton(MSG.view_metric_addToDashboard());
+ addToDashboardButton.disable();
dashboardSelectItem = new SelectItem();
dashboardSelectItem.setTitle("Dashboards");
10 years, 9 months
[rhq] Branch 'feature/bundle-group' - modules/core modules/enterprise
by Jay Shaughnessy
modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java | 7 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionsEditor.java | 25 ++++++++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java | 5 +-
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties | 8 ++-
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties | 9 +++
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties | 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties | 17 ++++++
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties | 3 -
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties | 10 ++++
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties | 22 ++++----
11 files changed, 91 insertions(+), 19 deletions(-)
New commits:
commit f126a952186530d6e0e84afca704862e9a0a8f60
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Jul 25 15:45:30 2013 -0400
More work on working new bundle group stuff into role edit view. Also, continued
cleanup of Messages.properties.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java
index 5b009b5..88fb948 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java
@@ -228,15 +228,22 @@ public enum Permission {
public static final Set<Permission> GLOBAL_ALL = new HashSet<Permission>();
public static final Set<Permission> RESOURCE_ALL = new HashSet<Permission>();
+ public static final Set<Permission> BUNDLE_ALL = new HashSet<Permission>();
static {
for (Permission permission : Permission.values()) {
switch (permission.getTarget()) {
case GLOBAL:
GLOBAL_ALL.add(permission);
+ if (permission.name().contains("BUNDLE")) {
+ BUNDLE_ALL.add(permission);
+ }
break;
case RESOURCE:
RESOURCE_ALL.add(permission);
break;
+ case BUNDLE:
+ BUNDLE_ALL.add(permission);
+ break;
}
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionsEditor.java
index cde2c6d..5e80d82 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionsEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionsEditor.java
@@ -101,6 +101,11 @@ public class PermissionsEditor extends EnhancedVStack {
this.resourcePermissionsGrid = createResourcePermissionsGrid();
addMember(this.resourcePermissionsGrid);
+ Label bundleGroupPermissionsHeader = new Label("<h4>"
+ + MSG.view_adminRoles_permissions_bundleGroupPermissions() + "</h4>");
+ bundleGroupPermissionsHeader.setHeight(17);
+ addMember(bundleGroupPermissionsHeader);
+
this.bundleGroupPermissionsGrid = createBundleGroupPermissionsGrid();
addMember(this.bundleGroupPermissionsGrid);
@@ -135,6 +140,13 @@ public class PermissionsEditor extends EnhancedVStack {
record.setAttribute("writeAuthorized", this.selectedPermissions.contains(writePermission));
}
+ ListGridRecord[] bundleGroupPermissionRecords = this.bundleGroupPermissionsGrid.getRecords();
+ for (ListGridRecord record : bundleGroupPermissionRecords) {
+ String permissionName = record.getAttribute("name");
+ Permission permission = Permission.valueOf(permissionName);
+ record.setAttribute("authorized", this.selectedPermissions.contains(permission));
+ }
+
markForRedraw();
}
@@ -216,7 +228,6 @@ public class PermissionsEditor extends EnhancedVStack {
MSG.view_adminRoles_permissions_permDesc_deployBundles());
records.add(record);
-
record = createPermissionRecord(MSG.view_adminRoles_permissions_perm_viewUsers(), "global/User",
Permission.VIEW_USERS, MSG.view_adminRoles_permissions_permDesc_viewUsers());
records.add(record);
@@ -481,6 +492,12 @@ public class PermissionsEditor extends EnhancedVStack {
messageString = MSG.view_adminRoles_permissions_autoselecting_configureWrite_implied();
redrawRequired = true;
}
+ } else if (permission == Permission.MANAGE_BUNDLE) {
+ // MANAGE_BUNDLE implies all other bundle-related perms
+ if (this.selectedPermissions.addAll(Permission.BUNDLE_ALL)) {
+ messageString = MSG.view_adminRoles_permissions_autoselecting_manageBundle_implied();
+ redrawRequired = true;
+ }
}
} else {
this.selectedPermissions.remove(permission);
@@ -499,14 +516,14 @@ public class PermissionsEditor extends EnhancedVStack {
}
}
- private ListGridRecord createPermissionRecord(String displayName, String icon, Permission globalPermission,
+ private ListGridRecord createPermissionRecord(String displayName, String icon, Permission permission,
String description) {
ListGridRecord record = new ListGridRecord();
record.setAttribute("displayName", displayName);
record.setAttribute("icon", icon);
- record.setAttribute("name", globalPermission.name());
+ record.setAttribute("name", permission.name());
record.setAttribute("description", description);
- record.setAttribute("authorized", this.selectedPermissions.contains(globalPermission));
+ record.setAttribute("authorized", this.selectedPermissions.contains(permission));
return record;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java
index 63b6e3f..9c2dc96 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/RoleEditView.java
@@ -268,7 +268,7 @@ public class RoleEditView extends AbstractRecordEditor<RolesDataSource> implemen
onItemChanged();
}
});
- updateTab(this.resourceGroupsTab, this.resourceGroupSelector);
+ updateTab(this.bundleGroupsTab, this.bundleGroupSelector);
}
@@ -393,6 +393,9 @@ public class RoleEditView extends AbstractRecordEditor<RolesDataSource> implemen
if (this.ldapGroupSelector != null) {
this.ldapGroupSelector.reset();
}
+ if (this.bundleGroupSelector != null) {
+ this.bundleGroupSelector.reset();
+ }
}
private static void updateTab(Tab tab, Canvas content) {
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index 1f9c73c..25f5171 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -503,8 +503,10 @@ view_adminRoles_ldapGroupsReadOnly = LDAP group data is read only
view_adminRoles_noLdap = The LDAP security integration is not configured. To configure LDAP, go to <a {0}>{1}</a>.
view_adminRoles_permissions_autoselecting_configureRead_implied = Autodeselected CONFIGURE_WRITE permission, since lack of CONFIGURE_READ implies lack of it...
view_adminRoles_permissions_autoselecting_configureWrite_implied = Autoselected CONFIGURE_READ permission, since CONFIGURE_WRITE implies it...
+view_adminRoles_permissions_autoselecting_manageBundle_implied = Autoselected unselected permissions, since MANAGE_BUNDLE implies all other bundle permissions...
view_adminRoles_permissions_autoselecting_manageInventory_implied = Autoselected unselected Resource permissions, since MANAGE_INVENTORY implies all Resource permissions...
view_adminRoles_permissions_autoselecting_manageSecurity_implied = Autoselected unselected permissions, since MANAGE_SECURITY implies all other permissions...
+view_adminRoles_permissions_bundleGroupPermissions = Bundle Group Permissions
view_adminRoles_permissions_globalPermissions = Global Permissions
view_adminRoles_permissions_illegalDeselectionDueToCorrespondingWritePermSelection = {0} read permission cannot be deselected, unless the {0} write permission, which implies the read permission, is deselected first.
view_adminRoles_permissions_illegalDeselectionDueToManageInventorySelection = {0} permission cannot be deselected, unless Manage Inventory, which implies all Resource permissions, is deselected first.
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
index 4e73829..8982a54 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
@@ -522,12 +522,14 @@ view_adminRoles_ldapGroupsReadOnly = data LDAP skupiny jsou jen pro čtení
view_adminRoles_noLdap = Integrace LDAP není nakonfigurována. K nastavení řízení bezpečnosti přes LDAP prosím navštivte <a {0}>{1}</a>.
view_adminRoles_permissions_autoselecting_configureRead_implied = Automaticky odoznačeno CONFIGURE_WRITE povolení, protože absence CONFIGURE_READ to implikuje...
view_adminRoles_permissions_autoselecting_configureWrite_implied = Automaticky označeno CONFIGURE_READ povolení, protože CONFIGURE_WRITE jej implikuje...
+##view_adminRoles_permissions_autoselecting_manageBundle_implied = Autoselected unselected permissions, since MANAGE_BUNDLE implies all other bundle permissions...
view_adminRoles_permissions_autoselecting_manageInventory_implied = Automaticky označeny neoznačené zdroje, protože MANAGE_INVENTORY implikuje povolení na všech zdrojích...
view_adminRoles_permissions_autoselecting_manageSecurity_implied = Automaticky označeny neoznačená povolení, protože MANAGE_SECURITY implikuje povolení na všech práv...
+view_adminRoles_permissions_bundleGroupPermissions = Bundle Group Permissions
view_adminRoles_permissions_globalPermissions = Globální povolení
-view_adminRoles_permissions_illegalDeselectionDueToCorrespondingWritePermSelection = {0} read permission cannot be deselected, unless the {0} write permission, which implies the read permission, is deselected first.
-view_adminRoles_permissions_illegalDeselectionDueToManageInventorySelection = {0} permission cannot be deselected, unless Manage Inventory, which implies all Resource permissions, is deselected first.
-view_adminRoles_permissions_illegalDeselectionDueToManageSecuritySelection = {0} permission cannot be deselected, unless the Manage Security permission, which implies all other permissions, is deselected first.
+##view_adminRoles_permissions_illegalDeselectionDueToCorrespondingWritePermSelection = {0} read permission cannot be deselected, unless the {0} write permission, which implies the read permission, is deselected first.
+##view_adminRoles_permissions_illegalDeselectionDueToManageInventorySelection = {0} permission cannot be deselected, unless Manage Inventory, which implies all Resource permissions, is deselected first.
+##view_adminRoles_permissions_illegalDeselectionDueToManageSecuritySelection = {0} permission cannot be deselected, unless the Manage Security permission, which implies all other permissions, is deselected first.
view_adminRoles_permissions_isAuthorized = Autorizován?
view_adminRoles_permissions_isRead = Čtení?
view_adminRoles_permissions_isWrite = Zápis?
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index 0db1d05..8b086a7 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -499,7 +499,16 @@ view_adminRoles_globalPerms = Applikationsweite Rechte
view_adminRoles_ldapGroups = LDAP-Gruppen
view_adminRoles_ldapGroupsReadOnly = LDAP Gruppendaten können nur gelesen werden
view_adminRoles_noLdap = Die LDAP-Integration ist nicht konfiguriert. Um LDAP zu konfigurieren, wechseln sie zu <a {0}>{1}</a>.
+##view_adminRoles_permissions_autoselecting_configureRead_implied = Autodeselected CONFIGURE_WRITE permission, since lack of CONFIGURE_READ implies lack of it...
+##view_adminRoles_permissions_autoselecting_configureWrite_implied = Autoselected CONFIGURE_READ permission, since CONFIGURE_WRITE implies it...
+##view_adminRoles_permissions_autoselecting_manageBundle_implied = Autoselected unselected permissions, since MANAGE_BUNDLE implies all other bundle permissions...
+##view_adminRoles_permissions_autoselecting_manageInventory_implied = Autoselected unselected Resource permissions, since MANAGE_INVENTORY implies all Resource permissions...
+##view_adminRoles_permissions_autoselecting_manageSecurity_implied = Autoselected unselected permissions, since MANAGE_SECURITY implies all other permissions...
+view_adminRoles_permissions_bundleGroupPermissions = Bundle Group Permissions
view_adminRoles_permissions_globalPermissions = Globale Rechte
+##view_adminRoles_permissions_illegalDeselectionDueToCorrespondingWritePermSelection = {0} read permission cannot be deselected, unless the {0} write permission, which implies the read permission, is deselected first.
+##view_adminRoles_permissions_illegalDeselectionDueToManageInventorySelection = {0} permission cannot be deselected, unless Manage Inventory, which implies all Resource permissions, is deselected first.
+##view_adminRoles_permissions_illegalDeselectionDueToManageSecuritySelection = {0} permission cannot be deselected, unless the Manage Security permission, which implies all other permissions, is deselected first.
view_adminRoles_permissions_isAuthorized = Berechtigt?
view_adminRoles_permissions_isRead = Lesen?
view_adminRoles_permissions_isWrite = Schreiben?
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
index 626243e..a78ab58 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
@@ -500,8 +500,10 @@ view_adminRoles_ldapGroupsReadOnly = LDAPグループデータは読み出し専
view_adminRoles_noLdap = LDAPセキュリティの統合は構成されていません。LDAPを構成するには、 <a {0}>{1}</a>に行ってください。
view_adminRoles_permissions_autoselecting_configureRead_implied = CONFIGURE_WRITE権限が自動的に選択されました。なぜなら、CONFIGURE_READが無いことがそれを暗示しているからです。
view_adminRoles_permissions_autoselecting_configureWrite_implied = CONFIGURE_READ権限が自動的に選択されました。なぜなら、CONFIGURE_WRITEがそれを暗示しているからです。
+##view_adminRoles_permissions_autoselecting_manageBundle_implied = Autoselected unselected permissions, since MANAGE_BUNDLE implies all other bundle permissions...
view_adminRoles_permissions_autoselecting_manageInventory_implied = 未選択のリソース権限が自動的に選択されました。なぜなら、MANAGE_INVENTORYはすべてのリソース権限を暗示しているからです。
view_adminRoles_permissions_autoselecting_manageSecurity_implied = 未選択の権限が自動的に選択されました。なぜなら、MANAGE_SECURITYは他のすべての権限を暗示しているからです。
+view_adminRoles_permissions_bundleGroupPermissions = Bundle Group Permissions
view_adminRoles_permissions_globalPermissions = グローバル権限
view_adminRoles_permissions_illegalDeselectionDueToCorrespondingWritePermSelection = {0} 読み取り権限は選択解除できませんでした。読み取り権限を暗示する {0} 書き込み権限が最初に選択解除されなければそれはできません。
view_adminRoles_permissions_illegalDeselectionDueToManageInventorySelection = {0} 権限は選択解除できませんでした。他のすべてのリソースを暗示する管理インベントリが最初に選択解除されなければそれはできません。
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
index 0da2a6e..a00f560 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
@@ -447,12 +447,21 @@ view_adminRoles_failLdapGroupsRole = 역할을 위해 사용가능한 LDAP 그
view_adminRoles_failRoles = 역할 제거에 실패했습니다.
view_adminRoles_globalPerms = 글로벌 권한
view_adminRoles_ldapGroups = LDAP 그룹
+##view_adminRoles_ldapGroupsReadOnly = LDAP group data is read only
view_adminRoles_noLdap = LDAP 보안 통합이 설정되지 않았습니다. LDAP을 구성하려면 <a {0}>{1}</a>로 가십시요.
+##view_adminRoles_permissions_autoselecting_configureRead_implied = Autodeselected CONFIGURE_WRITE permission, since lack of CONFIGURE_READ implies lack of it...
+##view_adminRoles_permissions_autoselecting_configureWrite_implied = Autoselected CONFIGURE_READ permission, since CONFIGURE_WRITE implies it...
+##view_adminRoles_permissions_autoselecting_manageBundle_implied = Autoselected unselected permissions, since MANAGE_BUNDLE implies all other bundle permissions...
+##view_adminRoles_permissions_autoselecting_manageInventory_implied = Autoselected unselected Resource permissions, since MANAGE_INVENTORY implies all Resource permissions...
+##view_adminRoles_permissions_autoselecting_manageSecurity_implied = Autoselected unselected permissions, since MANAGE_SECURITY implies all other permissions...
+view_adminRoles_permissions_bundleGroupPermissions = Bundle Group Permissions
view_adminRoles_permissions_globalPermissions = 글로벌 권한
view_adminRoles_permissions_illegalDeselectionDueToCorrespondingWritePermSelection = {0} 읽기 권한은 선택 해제 할 수 없습니다. 읽기 권한을 암시하는 {0} 쓰기 권한이 먼저 선택 해제되어야 그것은 수행할 수 있습니다.
view_adminRoles_permissions_illegalDeselectionDueToManageInventorySelection = {0} 권한은 선택 해제 할 수 없습니다. 다른 모든 자원을 암시하는 관리 인벤토리가 먼저 선택 해제되어야 그것은 수행할 수 있습니다.
view_adminRoles_permissions_illegalDeselectionDueToManageSecuritySelection = {0} 권한은 선택 해제 할 수 없습니다. 다른 모든 권한을 암시하는 관리 보안 권한이 먼저 선택 해제되어야 그것은 수행할 수 있습니다.
view_adminRoles_permissions_isAuthorized = 권한이 있습니까?
+##view_adminRoles_permissions_isRead = Read?
+##view_adminRoles_permissions_isWrite = Write?
##view_adminRoles_permissions_permDesc_assignBundlesToGroup = can copy a viewable bundle to the bundle group
##view_adminRoles_permissions_permDesc_createBundles = can create new bundle [version]s. can copy existing bundles between viewable groups
##view_adminRoles_permissions_permDesc_createBundlesInGroup = can create new bundle [version]s for the bundle group. can copy a viewable bundle to the bundle group.
@@ -470,16 +479,22 @@ view_adminRoles_permissions_permDesc_manageSettings = {0} 서버의 수정 및
##view_adminRoles_permissions_permDesc_viewBundlesInGroup = can view any bundle in the group
view_adminRoles_permissions_permDesc_viewUsers = 다른 사용자를 볼 수 있습니다. 그러나 그들에게 할당된 역할은 보이지 않습니다.
view_adminRoles_permissions_permReadDesc_configure = 자원 설정 및 자원 설정 수정 기록 보기
+##view_adminRoles_permissions_permReadDesc_control = (IMPLIED) view available operations and operation execution history
view_adminRoles_permissions_permReadDesc_createChildResources = (암시적) 자식 리소스 만들기 기록 보기
view_adminRoles_permissions_permReadDesc_deleteChildResources = (암시적) 자식 리소스 삭제 기록 보기
+##view_adminRoles_permissions_permReadDesc_inventory = (IMPLIED) view Resource properties (name, description, version, etc.), connection settings, and connection settings history
view_adminRoles_permissions_permReadDesc_manageAlerts = (암시적) 경고 정의 및 경고 기록 보기
view_adminRoles_permissions_permReadDesc_manageContent = (암시적) 설치되어 사용가능한 패키지; 패키지 설치 기록 보기
view_adminRoles_permissions_permReadDesc_manageDrift = (암시적) 드리프트 정의와 드리프트 기록 보기
view_adminRoles_permissions_permReadDesc_manageEvents = (암시적) 이벤트 보기
view_adminRoles_permissions_permReadDesc_manageMeasurements = (암시적) 통계 데이터 및 수집 스케쥴 보기
+##view_adminRoles_permissions_permWriteDesc_configure = update Resource configuration; delete Resource configuration revision history items
+##view_adminRoles_permissions_permWriteDesc_control = execute operations; delete operation execution history items
view_adminRoles_permissions_permWriteDesc_createChildResources = (작성 가능한 유형의 자식 리소스에 대한) 새로운 자식 리소스 만들기
view_adminRoles_permissions_permWriteDesc_deleteChildResources = 자원 제거 인벤토리; (삭제 가능한 유형의 자원에 대한) 리소스 삭제
+##view_adminRoles_permissions_permWriteDesc_inventory = update Resource name, version, description, and connection settings; delete connection settings history items
view_adminRoles_permissions_permWriteDesc_manageAlerts = 경고 정의를 만들기, 수정, 삭제; 경고 기록 확인 및 삭제
+##view_adminRoles_permissions_permWriteDesc_manageContent = subscribe to content sources; install and uninstall packages
view_adminRoles_permissions_permWriteDesc_manageDrift = 드리프트 정의 만들기, 수정, 삭제; 드리프트 인스턴스 관리
view_adminRoles_permissions_permWriteDesc_manageEvents = 이벤트 삭제
view_adminRoles_permissions_permWriteDesc_manageMeasurements = 통계 수집 스케쥴 수정
@@ -517,6 +532,8 @@ view_adminRoles_resourcePerms = 리소스 권한
view_adminRoles_roleAdded = 역할 [{0}]이 추가되었습니다.
view_adminRoles_roleDeleteFailed = 역할 [{0}]의 삭제에 실패했습니다.
view_adminRoles_roleDeleted = 역할 [{0}]이 삭제되었습니다.
+##view_adminRoles_roleUpdateFailed = Failed to update role [{0}].
+##view_adminRoles_roleUpdated = Role [{0}] updated.
view_adminTemplates_definedBy = 정의
view_adminTemplates_platformServices = 플랫폼 서비스
view_adminTemplates_platforms = 플랫폼
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
index 6d74d41..e6a7864 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
@@ -505,8 +505,10 @@ view_adminRoles_ldapGroupsReadOnly = Informa\u00E7\u00F5es do grupo LDAP com per
view_adminRoles_noLdap = A integra\u00E7\u00E3o com o LDAP ainda n\u00E3o foi configurada. Para configurar o LDAP acesse <a {0}>{1}</a>.
view_adminRoles_permissions_autoselecting_configureRead_implied = Permiss\u00E3o CONFIGURE_WRITE desmarcada automaticamente devida a aus\u00EAncia da permiss\u00E3o CONFIGURE_READ...
view_adminRoles_permissions_autoselecting_configureWrite_implied = Permiss\u00E3o CONFIGURE_READ marcada automaticamente devida a marca\u00E7\u00E3o de CONFIGURE_WRITE...
+##view_adminRoles_permissions_autoselecting_manageBundle_implied = Autoselected unselected permissions, since MANAGE_BUNDLE implies all other bundle permissions...
view_adminRoles_permissions_autoselecting_manageInventory_implied = Autoselected unselected Resource permissions, since MANAGE_INVENTORY implies all Resource permissions...
view_adminRoles_permissions_autoselecting_manageSecurity_implied = Autoselected unselected permissions, since MANAGE_SECURITY implies all other permissions...
+view_adminRoles_permissions_bundleGroupPermissions = Bundle Group Permissions
view_adminRoles_permissions_globalPermissions = Permiss\u00F5es Globais
view_adminRoles_permissions_illegalDeselectionDueToCorrespondingWritePermSelection = {0} permiss\u00E3o de leitura n\u00E3 pode ser desmarcada, a menos que {0} permiss\u00E3o de escrita, que implica na permiss\u00E3o de leitura, seja desmarcada primeiro.
view_adminRoles_permissions_illegalDeselectionDueToManageInventorySelection = {0} permiss\u00E3o n\u00E3o pode ser desmarcada, a menos que Gerenciar Invent\u00E1rio, que implica todas as permiss\u00F5es de Recurso, seja desmarcada primeiro.
@@ -584,7 +586,6 @@ view_adminRoles_resourcePerms = Permiss\u00F5es do Recurso
view_adminRoles_roleAdded = Perfil [{0}] adicionado.
view_adminRoles_roleDeleteFailed = Falha ao excluir o perfil [{0}].
view_adminRoles_roleDeleted = Perfil [{0}] exclu\u00EDdo.
-view_adminRoles_roleExists = O perfil com nome [{0}] j\u00E1 existe.
view_adminRoles_roleUpdateFailed = Falha ao atualizar o perfil [{0}].
view_adminRoles_roleUpdated = Perfil [{0}] atualizado.
##view_adminTemplates_definedBy = Defined By
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
index f31b829..4f9a97e 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
@@ -2574,6 +2574,7 @@ view_adminConfig_systemSettings = Системные настройки
view_adminContent_contentSources = Источники контента
view_adminRoles_assignedGroups = Назначенные группы ресурсов
view_adminRoles_assignedSubjects = Назначенные субъекты
+##view_adminRoles_failCreateRoleWithExistingName = Failed to create role with existing name [{0}]. Please use another name.
view_adminRoles_failLdap = Не удалось определить, настроен ли LDAP - предположительно LDAP отсутствует.
view_adminRoles_failLdapGroups = Не удалось получить LDAP-группы. Предположительно LDAP группы отсутствуют
view_adminRoles_failLdapGroupsRole = Не удалось загрузить LDAP группы, доступные для роли.
@@ -2581,10 +2582,13 @@ view_adminRoles_failRoles = Не удалось получить роли.
view_adminRoles_globalPerms = Глобальные полномочия
view_adminRoles_ldapGroups = LDAP-группы
view_adminRoles_ldapGroupsReadOnly = данные LDAP групп доступны только для чтения
+##view_adminRoles_noLdap = The LDAP security integration is not configured. To configure LDAP, go to <a {0}>{1}</a>.
view_adminRoles_permissions_autoselecting_configureRead_implied = Автоматически отключено CONFIGURE_WRITE полномочие, поскольку отсутствует CONFIGURE_READ...
view_adminRoles_permissions_autoselecting_configureWrite_implied = Автоматически выбрано CONFIGURE_READ полномочие, поскольку CONFIGURE_WRITE подразумевает, что ...
+##view_adminRoles_permissions_autoselecting_manageBundle_implied = Autoselected unselected permissions, since MANAGE_BUNDLE implies all other bundle permissions...
view_adminRoles_permissions_autoselecting_manageInventory_implied = Автоматически установлены не выбранные полномочия реусурсов, поскольку MANAGE_INVENTORY предполагает все полномочия ресурса...
view_adminRoles_permissions_autoselecting_manageSecurity_implied = Автоматически установлены невыбранные полномочия, поскольку MANAGE_SECURITY включает все другие полномочия...
+view_adminRoles_permissions_bundleGroupPermissions = Bundle Group Permissions
view_adminRoles_permissions_globalPermissions = Глобальные полномчия
view_adminRoles_permissions_illegalDeselectionDueToCorrespondingWritePermSelection = {0} полномочия на чтение не могут быть отключены, пока предварительно {0} полномочия записи, которые включают полномочия на чтение, не будут отключены.
view_adminRoles_permissions_illegalDeselectionDueToManageInventorySelection = {0} полномочия не могут быть отключены, пока предварительно Manage Inventory, которая включает все полномочия ресурса, не будет отключено.
@@ -2609,17 +2613,23 @@ view_adminRoles_permissions_permDesc_manageSecurity = можно создава
##view_adminRoles_permissions_permDesc_viewBundlesInGroup = can view any bundle in the group
##view_adminRoles_permissions_permDesc_viewUsers = can view other users, with the exception of their assigned roles
view_adminRoles_permissions_permReadDesc_configure = просмотр конфигурации ресурса и историю версий конфигурации ресурса
+##view_adminRoles_permissions_permReadDesc_control = (IMPLIED) view available operations and operation execution history
view_adminRoles_permissions_permReadDesc_createChildResources = (ПОДРАЗУМЕВАЕМЫЙ) просмотр истории создания дочернего ресурса
view_adminRoles_permissions_permReadDesc_deleteChildResources = (ПОДРАЗУМЕВАЕМЫЙ) просмотр истории удаления дочернего ресурса
view_adminRoles_permissions_permReadDesc_inventory = (ПОДРАЗУМЕВАЕМЫЙ) просмотр свойств ресурса (наименование, описание, версия и т.д.), настройки подключения, и историю настроек подключения
view_adminRoles_permissions_permReadDesc_manageAlerts = (ПОДРАЗУМЕВАЕМЫЙ) просмотр определений предупреждений и истории предупреждения
+##view_adminRoles_permissions_permReadDesc_manageContent = (IMPLIED) view installed and available packages; view package installation history
+##view_adminRoles_permissions_permReadDesc_manageDrift = (IMPLIED) view drift definitions and drift history
view_adminRoles_permissions_permReadDesc_manageEvents = (ПОДРАЗУМЕВАЕМЫЙ) просмотр событий
+##view_adminRoles_permissions_permReadDesc_manageMeasurements = (IMPLIED) view metric data and collection schedules
view_adminRoles_permissions_permWriteDesc_configure = обновить конфигурацию ресурса; удалить элементы истории версий конфигурации ресурса
view_adminRoles_permissions_permWriteDesc_control = выполнять операции; удалить элементы истории выполнения операций
+##view_adminRoles_permissions_permWriteDesc_createChildResources = create new child Resources (for child Resources of types that are creatable)
view_adminRoles_permissions_permWriteDesc_deleteChildResources = убрать ресурс из инвентаризации; удалить ресурсы (для типов ресурсов, которые могут быть удалены)
view_adminRoles_permissions_permWriteDesc_inventory = обновить наименование ресурса, версию, описание и настройки подключения; удалить элементы истории настроек подключения
view_adminRoles_permissions_permWriteDesc_manageAlerts = создать, обновить и удалить определения уведомлений; подтверждать и удалять элементы истории предупреждений
view_adminRoles_permissions_permWriteDesc_manageContent = подписаться на источники контента; устанавливать и удалять пакеты
+##view_adminRoles_permissions_permWriteDesc_manageDrift = create, update, and delete drift definitions; and manage drift instances
view_adminRoles_permissions_permWriteDesc_manageEvents = удалять события
view_adminRoles_permissions_permWriteDesc_manageMeasurements = обновление метрик коллекции планировщиков
##view_adminRoles_permissions_perm_assignBundlesToGroup = Assign Bundles To Group
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
index 1aeb1a1..547ebd5 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
@@ -492,14 +492,16 @@ view_adminRoles_globalPerms = \u5168\u5c40\u6388\u6743
view_adminRoles_ldapGroups = LDAP\u7ec4
view_adminRoles_ldapGroupsReadOnly = LDAP\u7ec4\u6570\u636e\u4e3a\u53ea\u8bfb
view_adminRoles_noLdap = \u6ca1\u6709\u96c6\u6210LDAP\u5b89\u5168, \u5230<a {0}>{1}</a>.
-view_adminRoles_permissions_autoselecting_configureRead_implied = Autodeselected CONFIGURE_WRITE permission, since lack of CONFIGURE_READ implies lack of it...
-view_adminRoles_permissions_autoselecting_configureWrite_implied = Autoselected CONFIGURE_READ permission, since CONFIGURE_WRITE implies it...
-view_adminRoles_permissions_autoselecting_manageInventory_implied = Autoselected unselected Resource permissions, since MANAGE_INVENTORY implies all Resource permissions...
-view_adminRoles_permissions_autoselecting_manageSecurity_implied = Autoselected unselected permissions, since MANAGE_SECURITY implies all other permissions...
+##view_adminRoles_permissions_autoselecting_configureRead_implied = Autodeselected CONFIGURE_WRITE permission, since lack of CONFIGURE_READ implies lack of it...
+##view_adminRoles_permissions_autoselecting_configureWrite_implied = Autoselected CONFIGURE_READ permission, since CONFIGURE_WRITE implies it...
+##view_adminRoles_permissions_autoselecting_manageBundle_implied = Autoselected unselected permissions, since MANAGE_BUNDLE implies all other bundle permissions...
+##view_adminRoles_permissions_autoselecting_manageInventory_implied = Autoselected unselected Resource permissions, since MANAGE_INVENTORY implies all Resource permissions...
+##view_adminRoles_permissions_autoselecting_manageSecurity_implied = Autoselected unselected permissions, since MANAGE_SECURITY implies all other permissions...
+view_adminRoles_permissions_bundleGroupPermissions = Bundle Group Permissions
view_adminRoles_permissions_globalPermissions = \u5168\u5c40\u6388\u6743
-view_adminRoles_permissions_illegalDeselectionDueToCorrespondingWritePermSelection = {0} read permission cannot be deselected, unless the {0} write permission, which implies the read permission, is deselected first.
-view_adminRoles_permissions_illegalDeselectionDueToManageInventorySelection = {0} permission cannot be deselected, unless Manage Inventory, which implies all Resource permissions, is deselected first.
-view_adminRoles_permissions_illegalDeselectionDueToManageSecuritySelection = {0} permission cannot be deselected, unless the Manage Security permission, which implies all other permissions, is deselected first.
+##view_adminRoles_permissions_illegalDeselectionDueToCorrespondingWritePermSelection = {0} read permission cannot be deselected, unless the {0} write permission, which implies the read permission, is deselected first.
+##view_adminRoles_permissions_illegalDeselectionDueToManageInventorySelection = {0} permission cannot be deselected, unless Manage Inventory, which implies all Resource permissions, is deselected first.
+##view_adminRoles_permissions_illegalDeselectionDueToManageSecuritySelection = {0} permission cannot be deselected, unless the Manage Security permission, which implies all other permissions, is deselected first.
view_adminRoles_permissions_isAuthorized = \u6388\u6743?
view_adminRoles_permissions_isRead = \u8bfb?
view_adminRoles_permissions_isWrite = \u5199?
@@ -523,16 +525,16 @@ view_adminRoles_permissions_permReadDesc_configure = \u67e5\u770b\u8d44\u6e90\u9
view_adminRoles_permissions_permReadDesc_control = (IMPLIED) \u67e5\u770b\u53ef\u7528\u64cd\u4f5c\u548c\u64cd\u4f5c\u6267\u884c\u5386\u53f2
view_adminRoles_permissions_permReadDesc_createChildResources = (IMPLIED) \u67e5\u770b\u5b50\u8d44\u6e90\u521b\u5efa\u5386\u53f2
view_adminRoles_permissions_permReadDesc_deleteChildResources = (IMPLIED) \u67e5\u770b\u5b50\u8d44\u6e90\u5220\u9664\u5386\u53f2
-view_adminRoles_permissions_permReadDesc_inventory = (IMPLIED) view Resource properties (name, description, version, etc.), connection settings, and connection settings history
+##view_adminRoles_permissions_permReadDesc_inventory = (IMPLIED) view Resource properties (name, description, version, etc.), connection settings, and connection settings history
view_adminRoles_permissions_permReadDesc_manageAlerts = (IMPLIED) \u67e5\u770b\u544a\u8b66\u5b9a\u4e49\u548c\u544a\u8b66\u5386\u53f2
view_adminRoles_permissions_permReadDesc_manageContent = (IMPLIED) \u67e5\u770b\u5b89\u88c5\u7684\u548c\u53ef\u7528\u7684\u5305; \u67e5\u770b\u5305\u5b89\u88c5\u5386\u53f2
##view_adminRoles_permissions_permReadDesc_manageDrift = (IMPLIED) view drift definitions and drift history
view_adminRoles_permissions_permReadDesc_manageEvents = (IMPLIED)\u67e5\u770b\u4e8b\u4ef6
-view_adminRoles_permissions_permReadDesc_manageMeasurements = (IMPLIED) view metric data and collection schedules
+##view_adminRoles_permissions_permReadDesc_manageMeasurements = (IMPLIED) view metric data and collection schedules
view_adminRoles_permissions_permWriteDesc_configure = \u66f4\u65b0\u8d44\u6e90\u914d\u7f6e; \u5220\u9664\u8d44\u6e90\u914d\u7f6e\u4fee\u8ba2\u7684\u5386\u53f2\u9879
view_adminRoles_permissions_permWriteDesc_control = \u6267\u884c\u64cd\u4f5c; \u5220\u9664\u64cd\u4f5c\u6267\u884c\u5386\u53f2
view_adminRoles_permissions_permWriteDesc_createChildResources = \u521b\u5efa\u65b0\u7684\u5b50\u8d44\u6e90 (for child Resources of types that are creatable)
-view_adminRoles_permissions_permWriteDesc_deleteChildResources = uninventory resources; delete Resources (for Resources of types that are deletable)
+##view_adminRoles_permissions_permWriteDesc_deleteChildResources = uninventory resources; delete Resources (for Resources of types that are deletable)
view_adminRoles_permissions_permWriteDesc_inventory = \u66f4\u65b0\u8d44\u6e90\u540d, \u7248\u672c,\u63cf\u8ff0, \u548c\u8fde\u63a5\u8bbe\u7f6e; \u5220\u9664\u8fde\u63a5\u8bbe\u7f6e\u5386\u53f2\u9879
view_adminRoles_permissions_permWriteDesc_manageAlerts = \u521b\u5efa, \u66f4\u65b0, \u548c\u5220\u9664\u544a\u8b66\u5b9a\u4e49; \u786e\u8ba4\u548c\u5220\u9664\u5386\u53f2\u544a\u8b66\u9879
view_adminRoles_permissions_permWriteDesc_manageContent = \u8ba2\u9605\u5185\u5bb9\u6e90; \u5b89\u88c5\u5378\u8f7d\u5305
10 years, 9 months
[rhq] Branch 'mtho11/consolidated-metrics' - modules/enterprise
by mike thompson
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/AddToDashboardComponent.java | 155 ++--------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java | 13
2 files changed, 48 insertions(+), 120 deletions(-)
New commits:
commit bbbaa4ebbadf744568f02f7964a97a5ec4f96198
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Thu Jul 25 09:51:40 2013 -0700
Consolidated Metrics - Add to Dashboard - enable/disable Add to Dashboard if no selection is made.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/AddToDashboardComponent.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/AddToDashboardComponent.java
index 84e20eb..cfb1947 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/AddToDashboardComponent.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/AddToDashboardComponent.java
@@ -20,12 +20,6 @@ package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitori
import java.util.LinkedHashMap;
-import com.google.gwt.http.client.Request;
-import com.google.gwt.http.client.RequestBuilder;
-import com.google.gwt.http.client.RequestCallback;
-import com.google.gwt.http.client.RequestException;
-import com.google.gwt.http.client.Response;
-import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.events.ClickEvent;
@@ -33,8 +27,6 @@ import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.menu.events.ClickHandler;
-import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
import com.smartgwt.client.widgets.toolbar.ToolStrip;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -42,7 +34,6 @@ import org.rhq.core.domain.criteria.DashboardCriteria;
import org.rhq.core.domain.dashboard.Dashboard;
import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.core.domain.measurement.MeasurementDefinition;
-import org.rhq.core.domain.measurement.MeasurementSchedule;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
@@ -68,9 +59,10 @@ public class AddToDashboardComponent extends ToolStrip implements Enhanced {
this.resource = resource;
setPadding(5);
setMembersMargin(15);
- setWidth(400);
+ setWidth(300);
dashboardMenuMap = new LinkedHashMap<String, String>();
dashboardMap = new LinkedHashMap<Integer, Dashboard>();
+ createToolstrip();
}
@Override
@@ -87,8 +79,8 @@ public class AddToDashboardComponent extends ToolStrip implements Enhanced {
dashboardSelectItem = new SelectItem();
dashboardSelectItem.setTitle("Dashboards");
- dashboardSelectItem.setWidth(350);
- dashboardSelectItem.setPickListWidth(250);
+ dashboardSelectItem.setWidth(300);
+ dashboardSelectItem.setPickListWidth(210);
populateDashboardMenu();
addFormItem(dashboardSelectItem);
addMember(addToDashboardButton);
@@ -105,10 +97,13 @@ public class AddToDashboardComponent extends ToolStrip implements Enhanced {
public void onClick(ClickEvent clickEvent) {
ListGridRecord[] selectedRecords = metricsListGrid.getSelectedRecords();
for (ListGridRecord selectedRecord : selectedRecords) {
- for (MeasurementDefinition measurementDefinition : resource.getResourceType().getMetricDefinitions()) {
- if(measurementDefinition.getId() == selectedRecord.getAttributeAsInt(MetricsViewDataSource.FIELD_METRIC_DEF_ID)){
- Log.debug("**Add to Dashboard -- Storing: "+measurementDefinition.getDisplayName() +" in "+ selectedDashboard.getName());
- storeDashboardMetric(selectedDashboard,resource,measurementDefinition);
+ for (MeasurementDefinition measurementDefinition : resource.getResourceType()
+ .getMetricDefinitions()) {
+ if (measurementDefinition.getId() == selectedRecord
+ .getAttributeAsInt(MetricsViewDataSource.FIELD_METRIC_DEF_ID)) {
+ Log.debug("Add to Dashboard -- Storing: " + measurementDefinition.getDisplayName()
+ + " in " + selectedDashboard.getName());
+ storeDashboardMetric(selectedDashboard, resource, measurementDefinition);
break;
}
}
@@ -117,28 +112,39 @@ public class AddToDashboardComponent extends ToolStrip implements Enhanced {
});
}
+ public void disableAddToDashboardButton(){
+ addToDashboardButton.disable();
+ }
+
+ public void enableAddToDashboardButton(){
+ addToDashboardButton.enable();
+ }
+
+
public void populateDashboardMenu() {
dashboardMenuMap.clear();
dashboardMap.clear();
DashboardCriteria criteria = new DashboardCriteria();
GWTServiceLookup.getDashboardService().findDashboardsByCriteria(criteria,
- new AsyncCallback<PageList<Dashboard>>() {
+ new AsyncCallback<PageList<Dashboard>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_contextMenu_loadFailed_dashboard(),
- caught);
- }
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_contextMenu_loadFailed_dashboard(),
+ caught);
+ }
- public void onSuccess(PageList<Dashboard> dashboards) {
- for (final Dashboard dashboard : dashboards) {
- dashboardMenuMap.put(String.valueOf(dashboard.getId()),
- MSG.view_tree_common_contextMenu_addChartToDashboard(dashboard.getName()));
- dashboardMap.put(dashboard.getId(), dashboard);
- dashboardSelectItem.setValueMap(dashboardMenuMap);
- }
+ public void onSuccess(PageList<Dashboard> dashboards) {
+ for (final Dashboard dashboard : dashboards) {
+ dashboardMenuMap.put(String.valueOf(dashboard.getId()),
+ MSG.view_tree_common_contextMenu_addChartToDashboard(dashboard.getName()));
+ dashboardMap.put(dashboard.getId(), dashboard);
}
- });
+ selectedDashboard = dashboards.get(0);
+ dashboardSelectItem.setValueMap(dashboardMenuMap);
+ dashboardSelectItem.setValue(selectedDashboard.getId());
+ }
+ });
}
/**
@@ -149,25 +155,6 @@ public class AddToDashboardComponent extends ToolStrip implements Enhanced {
this.metricsListGrid = metricsListGrid;
}
- /** Locate the specific schedule definition using the definition identifier.
- */
- private static int getScheduleDefinitionId(Resource resource, int definitionId) {
- int id = -1;
- if (resource.getSchedules() != null) {
- boolean located = false;
- MeasurementSchedule[] schedules = new MeasurementSchedule[resource.getSchedules().size()];
- resource.getSchedules().toArray(schedules);
- for (int i = 0; (!located && i < resource.getSchedules().size()); i++) {
- MeasurementSchedule schedule = schedules[i];
- MeasurementDefinition definition = schedule.getDefinition();
- if ((definition != null) && definition.getId() == definitionId) {
- located = true;
- id = schedule.getId();
- }
- }
- }
- return id;
- }
private void storeDashboardMetric(Dashboard dashboard, Resource resource, MeasurementDefinition definition) {
DashboardPortlet dashboardPortlet = new DashboardPortlet(MSG.view_tree_common_contextMenu_resourceGraph(),
@@ -194,76 +181,4 @@ public class AddToDashboardComponent extends ToolStrip implements Enhanced {
});
}
- private static void addNewMetric(String id, String selectedView, String resourceGraphElements) {
- //construct portal.war url to access
- String baseUrl = "/resource/common/monitor/visibility/IndicatorCharts.do";
- baseUrl += "?id=" + id;
- baseUrl += "&view=" + selectedView;
- baseUrl += "&action=addChart&metric=" + resourceGraphElements;
- final String url = baseUrl;
- //initiate HTTP request
- final RequestBuilder b = new RequestBuilder(RequestBuilder.GET, baseUrl);
-
- try {
- b.setCallback(new RequestCallback() {
- public void onResponseReceived(final Request request, final Response response) {
- Log.trace("Successfully submitted request to add graph to view:" + url);
-
- //kick off a page reload.
- String currentViewPath = History.getToken();
- CoreGUI.goToView(currentViewPath, true);
- }
-
- @Override
- public void onError(Request request, Throwable t) {
- Log.warn("Error adding Metric:" + url, t);
- }
- });
- b.send();
- } catch (RequestException e) {
- Log.warn("Error adding Metric:" + url, e);
- }
-
- }
-
- private static class AddToDashboardClickHandler implements ClickHandler {
-
- private final Resource resource;
- private final MeasurementDefinition definition;
- private final Dashboard dashboard;
-
- public AddToDashboardClickHandler(Resource resource, MeasurementDefinition definition, Dashboard dashboard) {
- this.resource = resource;
- this.definition = definition;
- this.dashboard = dashboard;
- }
-
- public void onClick(MenuItemClickEvent menuItemClickEvent) {
- DashboardPortlet dashboardPortlet = new DashboardPortlet(MSG.view_tree_common_contextMenu_resourceGraph(),
- ResourceD3GraphPortlet.KEY, 250);
- dashboardPortlet.getConfiguration().put(
- new PropertySimple(ResourceD3GraphPortlet.CFG_RESOURCE_ID, resource.getId()));
- dashboardPortlet.getConfiguration().put(
- new PropertySimple(ResourceD3GraphPortlet.CFG_DEFINITION_ID, definition.getId()));
-
- dashboard.addPortlet(dashboardPortlet);
-
- GWTServiceLookup.getDashboardService().storeDashboard(dashboard, new AsyncCallback<Dashboard>() {
-
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(
- MSG.view_tree_common_contextMenu_saveChartToDashboardFailure(), caught);
- }
-
- public void onSuccess(Dashboard result) {
- CoreGUI.getMessageCenter().notify(
- new Message(MSG.view_tree_common_contextMenu_saveChartToDashboardSuccessful(result.getName()),
- Message.Severity.Info));
- }
- });
-
- }
-
- }
-
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
index a4b15d1..09a7bc3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
@@ -46,6 +46,8 @@ import com.smartgwt.client.widgets.grid.events.RecordCollapseEvent;
import com.smartgwt.client.widgets.grid.events.RecordCollapseHandler;
import com.smartgwt.client.widgets.grid.events.RecordExpandEvent;
import com.smartgwt.client.widgets.grid.events.RecordExpandHandler;
+import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
+import com.smartgwt.client.widgets.grid.events.SelectionEvent;
import com.smartgwt.client.widgets.grid.events.SortChangedHandler;
import com.smartgwt.client.widgets.grid.events.SortEvent;
import com.smartgwt.client.widgets.layout.VLayout;
@@ -115,6 +117,17 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
addTableAction(MSG.view_measureTable_getLive(), new ShowLiveDataTableAction(this));
addExtraWidget(addToDashboardComponent, false);
+ addToDashboardComponent.disableAddToDashboardButton();
+ metricsTableListGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
+ @Override
+ public void onSelectionChanged(SelectionEvent selectionEvent) {
+ if(metricsTableListGrid.getSelectedRecords().length > 0){
+ addToDashboardComponent.enableAddToDashboardButton();
+ }else {
+ addToDashboardComponent.disableAddToDashboardButton();
+ }
+ }
+ });
}
private static class ShowLiveDataTableAction implements TableAction {
10 years, 9 months