[rhq] Branch 'jsanda/aggregation' - modules/enterprise
by John Sanda
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/Aggregate1HourData.java | 58 +++++---
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/AggregateRawData.java | 65 ++++++----
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/AggregationState.java | 20 +++
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/Aggregator.java | 6
4 files changed, 100 insertions(+), 49 deletions(-)
New commits:
commit 5180691f7af23d517bf07e0590fe03d5ab33a006
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Dec 18 17:24:01 2013 -0500
[BZ 1009945] eliminate a couple possible race condition when processing index entries
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/Aggregate1HourData.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/Aggregate1HourData.java
index bf50f26..4a5e78b 100644
--- a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/Aggregate1HourData.java
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/Aggregate1HourData.java
@@ -14,6 +14,10 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
+ * Generates 6 hour data for a batch of 1 hour data futures. After data is inserted for the batch, aggregation of 6 hour
+ * data will start immediately for the batch if the 24 hour time slice has finished.
+ *
+ * @see Compute6HourData
* @author John Sanda
*/
public class Aggregate1HourData implements Runnable {
@@ -54,44 +58,52 @@ public class Aggregate1HourData implements Runnable {
public void onSuccess(List<ResultSet> result) {
log.debug("Finished aggregating 1 hour data for " + result.size() + " schedules in " +
(System.currentTimeMillis() - start) + " ms");
- state.getRemaining1HourData().addAndGet(-scheduleIds.size());
start6HourDataAggregationIfNecessary();
}
@Override
public void onFailure(Throwable t) {
log.warn("Failed to aggregate 1 hour data", t);
- state.getRemaining1HourData().addAndGet(-scheduleIds.size());
start6HourDataAggregationIfNecessary();
}
});
}
private void start6HourDataAggregationIfNecessary() {
- if (state.is24HourTimeSliceFinished()) {
- log.debug("Starting 6 hour data aggregation for " + scheduleIds.size() + " schedules");
- try {
- state.getSixHourIndexEntriesArrival().await();
- try {
- state.getSixHourIndexEntriesLock().writeLock().lock();
- state.getSixHourIndexEntries().removeAll(scheduleIds);
- } finally {
- state.getSixHourIndexEntriesLock().writeLock().unlock();
+ try {
+ if (state.is24HourTimeSliceFinished()) {
+ update6HourIndexEntries();
+ List<StorageResultSetFuture> queryFutures = new ArrayList<StorageResultSetFuture>(scheduleIds.size());
+ for (Integer scheduleId : scheduleIds) {
+ queryFutures.add(dao.findSixHourMetricsAsync(scheduleId, state.getTwentyFourHourTimeSlice().getMillis(),
+ state.getTwentyFourHourTimeSliceEnd().getMillis()));
}
- } catch (InterruptedException e) {
- log.warn("An interrupt occurred waiting for 6 hour index entries", e);
- } catch (AbortedException e) {
- // This means we failed to retrieve the index entries. We can however
- // continue generating 6 hour data because we do not need the index
- // here since we already have 6 hour data to aggregate along with the
- // schedule ids.
+ state.getAggregationTasks().submit(new Aggregate6HourData(dao, state, scheduleIds, queryFutures));
}
- List<StorageResultSetFuture> queryFutures = new ArrayList<StorageResultSetFuture>(scheduleIds.size());
- for (Integer scheduleId : scheduleIds) {
- queryFutures.add(dao.findSixHourMetricsAsync(scheduleId, state.getTwentyFourHourTimeSlice().getMillis(),
- state.getTwentyFourHourTimeSliceEnd().getMillis()));
+ } catch (InterruptedException e) {
+ log.debug("An interrupt occurred while waiting for 6 hour data index entries. Aborting data aggregation",
+ e);
+ log.info("An interrupt occurred while waiting for 6 hour data index entries. Aborting data aggregation: " +
+ e.getMessage());
+ } finally {
+ state.getRemaining1HourData().addAndGet(-scheduleIds.size());
+ }
+ }
+
+ private void update6HourIndexEntries() throws InterruptedException {
+ try {
+ state.getSixHourIndexEntriesArrival().await();
+ try {
+ state.getSixHourIndexEntriesLock().writeLock().lock();
+ state.getSixHourIndexEntries().removeAll(scheduleIds);
+ } finally {
+ state.getSixHourIndexEntriesLock().writeLock().unlock();
}
- state.getAggregationTasks().submit(new Aggregate6HourData(dao, state, scheduleIds, queryFutures));
+ } catch (AbortedException e) {
+ // This means we failed to retrieve the index entries. We can however
+ // continue generating 6 hour data because we do not need the index
+ // here since we already have 6 hour data to aggregate along with the
+ // schedule ids.
}
}
}
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/AggregateRawData.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/AggregateRawData.java
index 2cde763..dbfc289 100644
--- a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/AggregateRawData.java
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/AggregateRawData.java
@@ -14,6 +14,10 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
+ * Generates 1 hour data for a batch of raw data futures. After data is inserted for the batch, aggregation of 1 hour
+ * data will start immediately for the batch if the 6 hour time slice has finished.
+ *
+ * @see Compute1HourData
* @author John Sanda
*/
public class AggregateRawData implements Runnable {
@@ -55,7 +59,6 @@ public class AggregateRawData implements Runnable {
public void onSuccess(List<ResultSet> resultSets) {
log.debug("Finished aggregating raw data for " + resultSets.size() + " schedules in " +
(System.currentTimeMillis() - start) + " ms");
- state.getRemainingRawData().addAndGet(-scheduleIds.size());
start1HourDataAggregationIfNecessary();
}
@@ -63,39 +66,51 @@ public class AggregateRawData implements Runnable {
public void onFailure(Throwable t) {
log.warn("Failed to aggregate raw data", t);
// TODO maybe add debug statement to log those schedule ids for which aggregation failed
- state.getRemainingRawData().addAndGet(-scheduleIds.size());
start1HourDataAggregationIfNecessary();
}
}, state.getAggregationTasks());
}
private void start1HourDataAggregationIfNecessary() {
- if (state.is6HourTimeSliceFinished()) {
- log.debug("Starting 1 hour data aggregation for " + scheduleIds.size() + " schedules");
- try {
- state.getOneHourIndexEntriesArrival().await();
- try {
- state.getOneHourIndexEntriesLock().writeLock().lock();
- state.getOneHourIndexEntries().removeAll(scheduleIds);
- } finally {
- state.getOneHourIndexEntriesLock().writeLock().unlock();
+ try {
+ if (state.is6HourTimeSliceFinished()) {
+ update1HourIndexEntries();
+ List<StorageResultSetFuture> oneHourDataQueryFutures = new ArrayList<StorageResultSetFuture>(
+ scheduleIds.size());
+ for (Integer scheduleId : scheduleIds) {
+ oneHourDataQueryFutures.add(dao.findOneHourMetricsAsync(scheduleId,
+ state.getSixHourTimeSlice().getMillis(), state.getSixHourTimeSliceEnd().getMillis()));
}
- } catch (InterruptedException e) {
- log.warn("An interrupt occurred waiting for one hour data index entries", e);
- return;
- } catch (AbortedException e) {
- // This means we failed to retrieve the index entries. We can however
- // continue generating 1 hour data because we do not need the index
- // here since we already have 1 hour data to aggregate along with the
- // schedule ids.
+ state.getAggregationTasks().submit(new Aggregate1HourData(dao, state, scheduleIds,
+ oneHourDataQueryFutures));
}
- List<StorageResultSetFuture> oneHourDataQueryFutures = new ArrayList<StorageResultSetFuture>(
- scheduleIds.size());
- for (Integer scheduleId : scheduleIds) {
- oneHourDataQueryFutures.add(dao.findOneHourMetricsAsync(scheduleId,
- state.getSixHourTimeSlice().getMillis(), state.getSixHourTimeSliceEnd().getMillis()));
+ } catch (InterruptedException e) {
+ log.debug("An interrupt occurred while waiting for 1 hour data index entries. Aborting data aggregation",
+ e);
+ log.info("An interrupt occurred while waiting for 1 hour data index entries. Aborting data aggregation: " +
+ e.getMessage());
+ } finally {
+ state.getRemainingRawData().addAndGet(-scheduleIds.size());
+ }
+ }
+
+ private void update1HourIndexEntries() throws InterruptedException {
+ try {
+ // Wait for the arrival so that we can remove the schedules ids in this
+ // batch from the one hour index entries. This will prevent duplicate tasks
+ // being submitted to process the same 1 hour data.
+ state.getOneHourIndexEntriesArrival().await();
+ try {
+ state.getOneHourIndexEntriesLock().writeLock().lock();
+ state.getOneHourIndexEntries().removeAll(scheduleIds);
+ } finally {
+ state.getOneHourIndexEntriesLock().writeLock().unlock();
}
- state.getAggregationTasks().submit(new Aggregate1HourData(dao, state, scheduleIds, oneHourDataQueryFutures));
+ } catch (AbortedException e) {
+ // This means we failed to retrieve the index entries. We can however
+ // continue generating 1 hour data because we do not need the index
+ // here since we already have 1 hour data to aggregate along with the
+ // schedule ids.
}
}
}
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/AggregationState.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/AggregationState.java
index 1b67350..bd1ce0d 100644
--- a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/AggregationState.java
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/AggregationState.java
@@ -62,6 +62,10 @@ public class AggregationState {
return this;
}
+ /**
+ * @return A {@link SignalingCountDownLatch} to signal the arrival of index entries for schedules with 1 hour
+ * data to be aggregated
+ */
public SignalingCountDownLatch getOneHourIndexEntriesArrival() {
return oneHourIndexEntriesArrival;
}
@@ -71,6 +75,10 @@ public class AggregationState {
return this;
}
+ /**
+ * @return A {@link SignalingCountDownLatch} to signal the arrival of index entries for schedules with 6 hour
+ * data to be aggregated
+ */
public SignalingCountDownLatch getSixHourIndexEntriesArrival() {
return sixHourIndexEntriesArrival;
}
@@ -80,6 +88,9 @@ public class AggregationState {
return this;
}
+ /**
+ * @return The remaining number of schedules with raw data to be aggregated
+ */
public AtomicInteger getRemainingRawData() {
return remainingRawData;
}
@@ -89,6 +100,9 @@ public class AggregationState {
return this;
}
+ /**
+ * @return The remaining number of schedules with 1 hour data to be aggregated
+ */
public AtomicInteger getRemaining1HourData() {
return remaining1HourData;
}
@@ -98,6 +112,9 @@ public class AggregationState {
return this;
}
+ /**
+ * @return The remaining number of schedules with 6 hour data to be aggregated
+ */
public AtomicInteger getRemaining6HourData() {
return remaining6HourData;
}
@@ -107,6 +124,9 @@ public class AggregationState {
return this;
}
+ /**
+ * @return The schedule ids with 1 hour data to be aggregated
+ */
public Set<Integer> getOneHourIndexEntries() {
return oneHourIndexEntries;
}
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/Aggregator.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/Aggregator.java
index f9bba5f..4ff222a 100644
--- a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/Aggregator.java
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/Aggregator.java
@@ -48,6 +48,10 @@ public class Aggregator {
private DateTime startTime;
+ /**
+ * Signals when raw data index entries (in metrics_index) can be deleted. We cannot delete the row in metrics_index
+ * until we know that it has been read, successfully or otherwise.
+ */
private SignalingCountDownLatch rawDataIndexEntriesArrival;
private RateLimiter readPermits;
@@ -289,7 +293,7 @@ public class Aggregator {
}
}
- private boolean isAggregationFinished() throws InterruptedException {
+ private boolean isAggregationFinished() {
return state.getRemainingRawData().get() <= 0 && state.getRemaining1HourData().get() <= 0 &&
state.getRemaining6HourData().get() <= 0 && remainingIndexEntries.get() <= 0;
}
10 years, 4 months
[rhq] Changes to 'jsanda/aggregation'
by John Sanda
New branch 'jsanda/aggregation' available with the following commits:
commit 6ad96024e571f92d385f5d3ebf355df5c8c6d4af
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Dec 18 11:05:37 2013 -0500
[BZ 1009945] add support for running async aggregation in simulator
commit ae1b76655665a6fef2ddbba9b2b1f125c6297dcb
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Oct 23 15:12:15 2013 -0400
[BZ 1009945] make connection pool sizes and rate limits configurable
Connection pools per host and rate limits are configurable via system
properties. While the connection pool sizes are only set at start up, I plan to
make the rate limits self-tuning.
This commit also adds the missing method body to kick off 6 hour data
aggregation in Aggregate1HourData.java.
Conflicts:
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java
commit 7d96099e86e4634d1137197059a1f5ba4f3a187b
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Oct 22 17:01:50 2013 -0400
[BZ 1009945] refactoring some duplicate code and fixing when tasks are scheduled
Aggregation tasks for 1 and 6 hour data were getting schedule too early. They
cannot get scheduled until both their respective index entries have arrived and
aggregation for the previous buckets has completed.
commit 19bd7da1c72ea245744de25740314bbd55458e45
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Oct 22 11:51:22 2013 -0400
[BZ 1009945] set counters for remaining data when we fail to get index entries for 1 and 6 hr data
commit 09901ef4a098844bd005507ec1cc0827535d6670
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Oct 22 07:30:32 2013 -0400
[BZ 1009945] fix logic for determining if aggregation has finished
We check the respective counters to see if raw, 1 hr, and 6 hr data aggregation
has finished. Prior to checking the counters though, we need to make sure that
they have been initialized. They do not get initialized until the respective
index entries arrive. I have refactored the logic into a new method,
isAggregationFinished. It first waits for the arrival of all the index entries
and then checks the counters.
commit 322cdb7a3181c3160f134e0373b510feeaa5f8ec
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Oct 21 11:06:17 2013 -0400
[BZ 1009945] adding back support for aggregating 6 hour data
commit ba38ad638efe2553911f9452d4affc7398089601
Author: John Sanda <jsanda(a)redhat.com>
Date: Sat Oct 19 21:58:37 2013 -0400
[BZ 1009945] This is a big refactoring of the initial implementation of Aggregator.java
The overall design is the same in terms of the fan out approach for doing the
calculations, but some changes were necessary after an extensive performance
analysis. Initially the aggregation tasks were to granular. Tasks were
submitted to the thread pool to process a single schedule. Schedules are now
processed in batches of 250. I did a lot of performance testing with various
batch sizes, and 250 seems optimal both in terms of execution time as well as
memory consumption. The other major change involves throttling. The initial
implementation had no throttling in place which immediately caused read and/or
write timeouts. Then I put throttling in place using RateLimiters, but there
was separate throttling that is used in MetricsServer for inserting raw data.
The same throttling is now used by both MetricsServer and Aggregator. There
are actually separate rate limiters for reads and for writes. Both are
configurable as well.
Conflicts:
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java
commit da67ebe5d7b4b9caf3790cc599a973a511851dec
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Oct 10 13:02:06 2013 -0400
[BZ 1009945] adding initial test for failure scenario
This test is for when we fail to fetch the raw data index.
commit aa715c07ad1051d04632e3730ddc4e284e6da995
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Oct 9 22:29:19 2013 -0400
[BZ 1009945] finishing test for 24 hour data
Conflicts:
modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/AggregationTests.java
commit 884dbd89deffdb06dd8614f88603126087408c2d
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri Oct 4 17:12:15 2013 -0400
[BZ 1009945] handle scenarios for when there is no 1 hr and/or 6 hr data
This commit also includes some major test changes. AggregationTests is a more
thorough set (of not yet complete) tests to provide better coverage.
commit b22be76adcd85aa0ad4421789718ead66d00b22c
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu Oct 3 07:50:23 2013 -0400
[BZ 1009945] delete 1 hr index entries when aggregation of time slice data is finished
commit ef1b470e9e15ec1a9301c84032e2ae3698556f2c
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Oct 2 22:53:11 2013 -0400
[BZ 1009945] initial support for generating 6 hr and 24 hr data
Conflicts:
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsDAO.java
commit 7709dfcc778411294c2f4bacb47327837ba5da54
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Oct 2 17:58:38 2013 -0400
[BZ 1009945] update 6 hr index after inserting 1 hr data
commit 1d061eaf875757537254880ccd4b5d72cacc415a
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Oct 2 17:36:21 2013 -0400
[BZ 1009945] Initial commit for new Aggregator class
This is a first pass at computing multiple aggregates concurrently.
Conflicts:
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java
10 years, 4 months
[rhq] Branch 'jay-sync' - modules/core modules/enterprise
by Jay Shaughnessy
modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java | 46 -
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/discovery/DiscoveryAgentService.java | 19
modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/discovery/DiscoveryServerService.java | 3
modules/core/domain/src/main/java/org/rhq/core/domain/discovery/PlatformSyncInfo.java | 73 +-
modules/core/domain/src/main/java/org/rhq/core/domain/discovery/ResourceSyncInfo.java | 140 ++--
modules/core/domain/src/main/java/org/rhq/core/domain/discovery/SyncInfo.java | 98 --
modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/inventory/AbstractIgnoreTypesInventoryManagerBaseTest.java | 36 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java | 3
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/RuntimeSynchronizer.java | 2
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 329 ++++------
modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/AbstractResourceUpgradeHandlingTest.java | 4
modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java | 48 -
modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/ResourceUpgradeTest.java | 20
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanTest.java | 28
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/configuration/LargeGroupPluginConfigurationTest.java | 17
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.java | 65 +
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java | 18
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java | 87 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossLocal.java | 7
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java | 5
20 files changed, 553 insertions(+), 495 deletions(-)
New commits:
commit b71b50566d781cebacf3301d5692f87a23a495a5
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Dec 18 09:28:48 2013 -0500
[1023451] [perf] Large retained heap during inventory report merge (causing OOMs)
Note - this is related work, not necessarily a solution to this problem.
This commit builds on the "chunking" work introduced earlier. This work
replaces the tree structure, previously used to pass sync info between
agent and server, with flat collections. This allows us to replace the
costly Hibernate-based tree building approach with more comprehensive queries
that reduce the number of DB round trips dramatically.
Notes:
- This commit fixed an issue with the previous work regarding the handling
of top level services.
- The ResourceSyncInfo class is now even lighter weight, parent-child info is
removed.
- PlatformSyncInfo is now a POJO.
- The handling of unknown resources (agent side) changed significantly
because it had depended on the previous tree structure.
- mocks again had to be updated
diff --git a/modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java b/modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java
index 74a0acc..60f61c1 100644
--- a/modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java
+++ b/modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java
@@ -19,7 +19,6 @@
package org.rhq.test.arquillian;
-import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
@@ -248,10 +247,10 @@ public class FakeServerInventory {
};
}
- public synchronized Answer<ResourceSyncInfo> getResourceSyncInfo() {
- return new Answer<ResourceSyncInfo>() {
+ public synchronized Answer<Collection<ResourceSyncInfo>> getResourceSyncInfo() {
+ return new Answer<Collection<ResourceSyncInfo>>() {
@Override
- public ResourceSyncInfo answer(InvocationOnMock invocation) throws Throwable {
+ public Collection<ResourceSyncInfo> answer(InvocationOnMock invocation) throws Throwable {
synchronized (FakeServerInventory.this) {
Integer resourceId = (Integer) invocation.getArguments()[0];
@@ -622,37 +621,29 @@ public class FakeServerInventory {
return platform == null ? null : PlatformSyncInfo.buildPlatformSyncInfo(platform);
}
- private ResourceSyncInfo getResourceSyncInfo(Resource resource) {
+ private Collection<ResourceSyncInfo> getResourceSyncInfo(Resource resource) {
return resource == null ? null : convert(resource);
}
- private static ResourceSyncInfo convert(Resource root) {
- return convertInternal(root, true, new HashMap<String, ResourceSyncInfo>());
+ private static Collection<ResourceSyncInfo> convert(Resource root) {
+ Set<ResourceSyncInfo> result = new HashSet<ResourceSyncInfo>();
+ convertInternal(root, result);
+ return result;
}
- private static ResourceSyncInfo convertInternal(Resource root, boolean isTopLevelServer,
- Map<String, ResourceSyncInfo> intermediateResults) {
+ private static void convertInternal(Resource root, Collection<ResourceSyncInfo> result) {
- ResourceSyncInfo ret = intermediateResults.get(root.getUuid());
+ ResourceSyncInfo rootSyncInfo = ResourceSyncInfo.buildResourceSyncInfo(root);
- if (ret != null) {
- return ret;
+ if (result.contains(rootSyncInfo)) {
+ return;
}
try {
- ret = ResourceSyncInfo.buildResourceSyncInfo(root);
- intermediateResults.put(root.getUuid(), ret);
+ result.add(rootSyncInfo);
- Integer parentId = root.getParentResource() == null ? null : root.getParentResource().getId();
- getPrivateField(ResourceSyncInfo.class, "parentId").set(ret, parentId);
-
- Set<ResourceSyncInfo> children = new LinkedHashSet<ResourceSyncInfo>();
for (Resource child : root.getChildResources()) {
- ResourceSyncInfo syncChild = convertInternal(child, false, intermediateResults);
-
- children.add(syncChild);
+ convertInternal(child, result);
}
- getPrivateField(ResourceSyncInfo.class, "childSyncInfos").set(ret, children);
- return ret;
} catch (Exception e) {
throw new IllegalStateException("Failed to convert resource " + root
@@ -660,15 +651,6 @@ public class FakeServerInventory {
}
}
- private static Field getPrivateField(Class<?> clazz, String fieldName) throws NoSuchFieldException {
- Field field = clazz.getDeclaredField(fieldName);
- if (!field.isAccessible()) {
- field.setAccessible(true);
- }
-
- return field;
- }
-
private void throwIfFailing() {
if (failing) {
throw new RuntimeException("Fake server inventory is in the failing mode.");
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/discovery/DiscoveryAgentService.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/discovery/DiscoveryAgentService.java
index e3313f0..4c2a821 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/discovery/DiscoveryAgentService.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/discovery/DiscoveryAgentService.java
@@ -22,6 +22,8 @@
*/
package org.rhq.core.clientapi.agent.discovery;
+import java.util.Collection;
+
import org.jetbrains.annotations.NotNull;
import org.rhq.core.clientapi.agent.PluginContainerException;
@@ -29,8 +31,8 @@ import org.rhq.core.clientapi.server.discovery.InventoryReport;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.discovery.AvailabilityReport;
import org.rhq.core.domain.discovery.MergeResourceResponse;
+import org.rhq.core.domain.discovery.PlatformSyncInfo;
import org.rhq.core.domain.discovery.ResourceSyncInfo;
-import org.rhq.core.domain.measurement.Availability;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceError;
@@ -56,11 +58,20 @@ public interface DiscoveryAgentService {
throws InvalidPluginConfigurationClientException, PluginContainerException;
/**
- * Called to inform the agent of a status change for the resource represented by syncInfo. The agent processes the syncInfo for the resource and initiates a status update for its sub-tree.
+ * Called by the server when requesting a full platform sync. The provided info will guide the subsequent
+ * agent-initiated sync.
+ *
+ * @param syncInfo for the platform to be synchronized with the server.
+ */
+ void synchronizePlatform(PlatformSyncInfo syncInfo);
+
+ /**
+ * Called by the server to update the agent with changed for specified top level server. The agent will
+ * synchronize its inventory for the server and its subtree given the provided information.
*
- * @param syncInfo for the root of the tree to be updated.
+ * @param syncInfo for the top level server to be synchronized with the server.
*/
- void synchronizeInventory(ResourceSyncInfo syncInfo);
+ void synchronizeServer(int resourceId, Collection<ResourceSyncInfo> toplevelServerSyncInfo);
/**
* Access to the current inventory managed by the plugin container.
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/discovery/DiscoveryServerService.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/discovery/DiscoveryServerService.java
index df2a286..4280305 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/discovery/DiscoveryServerService.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/discovery/DiscoveryServerService.java
@@ -22,6 +22,7 @@
*/
package org.rhq.core.clientapi.server.discovery;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -73,7 +74,7 @@ public interface DiscoveryServerService {
@LimitedConcurrency(CONCURRENCY_LIMIT_INVENTORY_REPORT)
@Timeout(0L)
// should be something like 1000L * 60 * 30 but until we can be assured we never take longer, disable timeout
- ResourceSyncInfo getResourceSyncInfo(int resourceId);
+ Collection<ResourceSyncInfo> getResourceSyncInfo(int resourceId);
/**
* Merges a new availability report from the agent into the server. This updates the availability statuses of known
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/discovery/PlatformSyncInfo.java b/modules/core/domain/src/main/java/org/rhq/core/domain/discovery/PlatformSyncInfo.java
index 951f542..3d989f3 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/discovery/PlatformSyncInfo.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/discovery/PlatformSyncInfo.java
@@ -23,52 +23,69 @@
package org.rhq.core.domain.discovery;
import java.io.Serializable;
-import java.util.Collection;
-import java.util.Collections;
+import java.util.HashSet;
import java.util.Set;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
-
-import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceCategory;
/**
- * @author Ian Springer
+ * This immutable POJO returns the information necessary for the agent to perform a complete sync with the server
+ * inventory. It does not provide *all* of the sync info, only the platform and its top level *service* hierarchy. It
+ * expects the agent to call back to the server for each of the platform's top level servers and therefore provides
+ * only the top level server Ids.
+ *
* @author Jay Shaughnessy
*/
-@Entity
-@Table(name = "RHQ_RESOURCE")
-public class PlatformSyncInfo extends SyncInfo implements Serializable {
+public class PlatformSyncInfo implements Serializable {
private static final long serialVersionUID = 1L;
- @OneToMany(mappedBy = "parentResource", fetch = FetchType.EAGER)
- private Set<Resource> topLevelServers;
+ private ResourceSyncInfo platform;
+ private Set<ResourceSyncInfo> services;
+ private Set<Integer> topLevelServerIds;
+
+ public PlatformSyncInfo(ResourceSyncInfo platform, Set<ResourceSyncInfo> services, Set<Integer> topLevelServerIds) {
+ super();
+ this.platform = platform;
+ this.services = services;
+ this.topLevelServerIds = topLevelServerIds;
+ }
+
+ /**
+ * @return just the platform sync info
+ */
+ public ResourceSyncInfo getPlatform() {
+ return platform;
+ }
- // JPA requires public or protected no-param constructor; Externalizable requires public no-param constructor.
- public PlatformSyncInfo() {
+ /**
+ * @return the sync info for the platform hierarchy excluding the platform itself and the top level servers
+ */
+ public Set<ResourceSyncInfo> getServices() {
+ return services;
}
- public Collection<Resource> getTopLevelServers() {
- return topLevelServers;
+ /**
+ * @return just the type level server ids, so that the agent can call back for sync info on each top level server
+ */
+ public Set<Integer> getTopLevelServerIds() {
+ return topLevelServerIds;
}
// for testing
public static PlatformSyncInfo buildPlatformSyncInfo(Resource platform) {
- Set<Resource> toplevelServers = platform.getChildResources();
+ Set<Integer> toplevelServerIds = new HashSet<Integer>();
+ for (Resource r : platform.getChildResources()) {
+ if (r.getResourceType().getCategory().equals(ResourceCategory.SERVER)) {
+ toplevelServerIds.add(r.getId());
+ }
+ }
- PlatformSyncInfo syncInfo = new PlatformSyncInfo(platform.getId(), platform.getUuid(), platform.getMtime(),
- platform.getInventoryStatus(), (null == toplevelServers ? Collections.EMPTY_SET : toplevelServers));
+ ResourceSyncInfo resSyncInfo = ResourceSyncInfo.buildResourceSyncInfo(platform);
- return syncInfo;
- }
+ PlatformSyncInfo syncInfo = new PlatformSyncInfo(resSyncInfo, new HashSet<ResourceSyncInfo>(1),
+ toplevelServerIds);
- // for testing
- private PlatformSyncInfo(int id, String uuid, long mtime, InventoryStatus istatus, Set<Resource> children) {
- super(id, uuid, mtime, istatus);
- this.topLevelServers = children;
+ return syncInfo;
}
-
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/discovery/ResourceSyncInfo.java b/modules/core/domain/src/main/java/org/rhq/core/domain/discovery/ResourceSyncInfo.java
index e9cb222..b1fb366 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/discovery/ResourceSyncInfo.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/discovery/ResourceSyncInfo.java
@@ -23,85 +23,131 @@
package org.rhq.core.domain.discovery;
import java.io.Serializable;
-import java.util.Collection;
-import java.util.HashSet;
import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.OneToMany;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
import javax.persistence.Table;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
/**
- * Sync info for any non-platform resource.
+ * Sync info for a resource. This is a lightweight "Resource" entity that contains only the information required
+ * to perform Inventory Sync between the Agent and Server.
*
- * @author Ian Springer
* @author Jay Shaughnessy
*/
@Entity
+@NamedQueries({
+ @NamedQuery(name = ResourceSyncInfo.QUERY_SERVICE_CHILDREN, query = "" //
+ + "SELECT r " //
+ + " FROM ResourceSyncInfo r " //
+ + " WHERE r.id IN ( SELECT rr.id FROM Resource rr WHERE rr.parentResource.id IN ( :parentIds )) " //
+ + ""),
+ @NamedQuery(name = ResourceSyncInfo.QUERY_TOP_LEVEL_SERVER, query = "" //
+ + "SELECT rsi " //
+ + " FROM ResourceSyncInfo rsi " //
+ + " WHERE rsi.id = :resourceId " //
+ + " OR rsi.id IN (SELECT rr.id FROM Resource rr WHERE rr.parentResource.id = :resourceId) "
+ + " OR rsi.id IN (SELECT rr.id FROM Resource rr WHERE rr.parentResource.parentResource.id = :resourceId) "
+ + " OR rsi.id IN (SELECT rr.id FROM Resource rr WHERE rr.parentResource.parentResource.parentResource.id = :resourceId) "
+ + " OR rsi.id IN (SELECT rr.id FROM Resource rr WHERE rr.parentResource.parentResource.parentResource.parentResource.id = :resourceId) "
+ + " OR rsi.id IN (SELECT rr.id FROM Resource rr WHERE rr.parentResource.parentResource.parentResource.parentResource.parentResource.id = :resourceId) "
+ + " ") })
@Table(name = "RHQ_RESOURCE")
-public class ResourceSyncInfo extends SyncInfo implements Serializable {
+public class ResourceSyncInfo implements Serializable {
private static final long serialVersionUID = 1L;
- @Column(name = "PARENT_RESOURCE_ID")
- private Integer parentId;
-
- @OneToMany(mappedBy = "parentId", fetch = FetchType.EAGER)
- private Collection<ResourceSyncInfo> childSyncInfos;
+ /** Sync info for platform service children (for building up hierarchy that excludes the top level servers */
+ public static final String QUERY_SERVICE_CHILDREN = "ResourceSyncInfo.platformServiceChildren";
+ /** Sync info rooted at the specified top level server and including all of it's hierarchy (up to 5 levels below
+ * the top level server. note that we support up to 6 levels below platform but we are starting one level down) */
+ public static final String QUERY_TOP_LEVEL_SERVER = "ResourceSyncInfo.topLevelServer";
+
+ /**
+ * Server-assigned id
+ */
+ @Column(name = "ID", nullable = false)
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private int id;
+
+ /**
+ * Agent-assigned uuid
+ */
+ @Column(name = "UUID")
+ private String uuid;
+
+ /**
+ * Last modified time
+ */
+ @Column(name = "MTIME")
+ private long mtime;
+
+ @Column(name = "INVENTORY_STATUS")
+ @Enumerated(EnumType.STRING)
+ private InventoryStatus inventoryStatus;
// JPA requires public or protected no-param constructor; Externalizable requires public no-param constructor.
public ResourceSyncInfo() {
}
- public Collection<ResourceSyncInfo> getChildSyncInfos() {
- return childSyncInfos;
+ public int getId() {
+ return id;
}
- // for testing
- public static ResourceSyncInfo buildResourceSyncInfo(Resource resource) {
- Collection<ResourceSyncInfo> children;
-
- if (resource.getChildResources() != null) {
- children = new HashSet<ResourceSyncInfo>(resource.getChildResources().size());
- for (Resource child : resource.getChildResources()) {
- children.add(buildResourceSyncInfo(child));
- }
- } else {
- children = new HashSet<ResourceSyncInfo>(0);
- }
-
- return buildResourceSyncInfo(resource, children);
+ public String getUuid() {
+ return uuid;
}
- // for testing
- public static ResourceSyncInfo buildResourceSyncInfo(Resource resource, Collection<ResourceSyncInfo> children) {
-
- ResourceSyncInfo syncInfo = new ResourceSyncInfo(resource.getId(), resource.getUuid(), resource.getMtime(),
- resource.getInventoryStatus(), children);
-
- return syncInfo;
+ public long getMtime() {
+ return mtime;
}
-
- public static ResourceSyncInfo buildResourceSyncInfo(SyncInfo syncInfo) {
-
- return buildResourceSyncInfo(syncInfo, ((Collection<ResourceSyncInfo>) null));
+ public InventoryStatus getInventoryStatus() {
+ return inventoryStatus;
}
- public static ResourceSyncInfo buildResourceSyncInfo(SyncInfo syncInfo, Collection<ResourceSyncInfo> children) {
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((uuid == null) ? 0 : uuid.hashCode());
+ return result;
+ }
- ResourceSyncInfo resourceSyncInfo = new ResourceSyncInfo(syncInfo.getId(), syncInfo.getUuid(),
- syncInfo.getMtime(), syncInfo.getInventoryStatus(), children);
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ResourceSyncInfo other = (ResourceSyncInfo) obj;
+ if (uuid == null) {
+ if (other.uuid != null)
+ return false;
+ } else if (!uuid.equals(other.uuid))
+ return false;
+ return true;
+ }
- return resourceSyncInfo;
+ protected ResourceSyncInfo(int id, String uuid, long mtime, InventoryStatus istatus) {
+ this.id = id;
+ this.uuid = uuid;
+ this.mtime = mtime;
+ this.inventoryStatus = istatus;
}
- private ResourceSyncInfo(int id, String uuid, long mtime, InventoryStatus istatus,
- Collection<ResourceSyncInfo> children) {
- super(id, uuid, mtime, istatus);
- this.childSyncInfos = children;
+ static public ResourceSyncInfo buildResourceSyncInfo(Resource res) {
+ return new ResourceSyncInfo(res.getId(), res.getUuid(), res.getMtime(), res.getInventoryStatus());
}
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/discovery/SyncInfo.java b/modules/core/domain/src/main/java/org/rhq/core/domain/discovery/SyncInfo.java
deleted file mode 100644
index 370d84f..0000000
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/discovery/SyncInfo.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * 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 and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.rhq.core.domain.discovery;
-
-import java.io.Serializable;
-
-import javax.persistence.Column;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.MappedSuperclass;
-
-import org.rhq.core.domain.resource.InventoryStatus;
-
-/**
- * This is the abstract base class for SyncInfo, which may be for a platform or a [top level server] resource.
- *
- * @author Ian Springer
- * @author Jay Shaughnessy
- */
-@MappedSuperclass
-public abstract class SyncInfo implements Serializable {
- private static final long serialVersionUID = 1L;
-
- /**
- * Server-assigned id
- */
- @Column(name = "ID", nullable = false)
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private int id;
-
- /**
- * Agent-assigned uuid
- */
- @Column(name = "UUID")
- private String uuid;
-
- /**
- * Last modified time
- */
- @Column(name = "MTIME")
- private long mtime;
-
- @Column(name = "INVENTORY_STATUS")
- @Enumerated(EnumType.STRING)
- private InventoryStatus inventoryStatus;
-
- // JPA requires public or protected no-param constructor; Externalizable requires public no-param constructor.
- public SyncInfo() {
- }
-
- public int getId() {
- return id;
- }
-
- public String getUuid() {
- return uuid;
- }
-
- public long getMtime() {
- return mtime;
- }
-
- public InventoryStatus getInventoryStatus() {
- return inventoryStatus;
- }
-
- protected SyncInfo(int id, String uuid, long mtime, InventoryStatus istatus) {
- this.id = id;
- this.uuid = uuid;
- this.mtime = mtime;
- this.inventoryStatus = istatus;
- }
-
-}
diff --git a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/inventory/AbstractIgnoreTypesInventoryManagerBaseTest.java b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/inventory/AbstractIgnoreTypesInventoryManagerBaseTest.java
index 4591dfc..cb799de 100644
--- a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/inventory/AbstractIgnoreTypesInventoryManagerBaseTest.java
+++ b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/inventory/AbstractIgnoreTypesInventoryManagerBaseTest.java
@@ -22,8 +22,10 @@ import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;
import java.io.File;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -217,17 +219,43 @@ public abstract class AbstractIgnoreTypesInventoryManagerBaseTest extends Arquil
return;
}
- protected Answer<ResourceSyncInfo> getResourceSyncInfo() {
- return new Answer<ResourceSyncInfo>() {
+ protected Answer<Collection<ResourceSyncInfo>> getResourceSyncInfo() {
+ return new Answer<Collection<ResourceSyncInfo>>() {
@Override
- public ResourceSyncInfo answer(InvocationOnMock invocation) throws Throwable {
+ public Collection<ResourceSyncInfo> answer(InvocationOnMock invocation) throws Throwable {
Integer resourceId = (Integer) invocation.getArguments()[0];
- ResourceSyncInfo result = ResourceSyncInfo.buildResourceSyncInfo(simulatedInventory.get(resourceId));
+ Collection<ResourceSyncInfo> result = convert(simulatedInventory.get(resourceId));
return result;
}
};
}
+ private static Collection<ResourceSyncInfo> convert(Resource root) {
+ Set<ResourceSyncInfo> result = new HashSet<ResourceSyncInfo>();
+ convertInternal(root, result);
+ return result;
+ }
+
+ private static void convertInternal(Resource root, Collection<ResourceSyncInfo> result) {
+
+ ResourceSyncInfo rootSyncInfo = ResourceSyncInfo.buildResourceSyncInfo(root);
+
+ if (result.contains(rootSyncInfo)) {
+ return;
+ }
+ try {
+ result.add(rootSyncInfo);
+
+ for (Resource child : root.getChildResources()) {
+ convertInternal(child, result);
+ }
+
+ } catch (Exception e) {
+ throw new IllegalStateException("Failed to convert resource " + root
+ + " to a ResourceSyncInfo. This should not happen.", e);
+ }
+ }
+
protected void validateFullInventory() {
System.out.println("Validating full inventory...");
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
index 33cf21a..849541d 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
@@ -25,6 +25,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
@@ -903,7 +904,7 @@ public class StandaloneContainer {
}
@Override
- public ResourceSyncInfo getResourceSyncInfo(int resourceId) {
+ public Collection<ResourceSyncInfo> getResourceSyncInfo(int resourceId) {
return null;
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/RuntimeSynchronizer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/RuntimeSynchronizer.java
index 679db62..1708072 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/RuntimeSynchronizer.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/RuntimeSynchronizer.java
@@ -45,7 +45,7 @@ import org.rhq.core.pc.drift.ScheduleQueue;
* <br/><br/>
* Note that inventory sync happens regularly after the plugin container is initialized.
* Discovery scans are performed at fixed intervals. The results of a discovery scan are
- * reported to the server, and the server sends back {@link org.rhq.core.domain.discovery.ResourceSyncInfo resource sync info}
+ * reported to the server, and the server sends back {@link org.rhq.core.domain.discovery.OldResourceSyncInfo resource sync info}
* which is then used to sync with the local inventory.
*/
class RuntimeSynchronizer implements DriftSynchronizer {
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
index b809f6f..24dcb44 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
@@ -228,6 +228,7 @@ public class InventoryManager extends AgentService implements ContainerService,
/**
* @see ContainerService#initialize()
*/
+ @Override
public void initialize() {
inventoryLock.writeLock().lock();
@@ -290,6 +291,7 @@ public class InventoryManager extends AgentService implements ContainerService,
/**
* @see ContainerService#shutdown()
*/
+ @Override
public void shutdown() {
PluginContainer pluginContainer = PluginContainer.getInstance();
pluginContainer.shutdownExecutorService(this.inventoryThreadPoolExecutor, true);
@@ -626,10 +628,12 @@ public class InventoryManager extends AgentService implements ContainerService,
}
}
+ @Override
public void setConfiguration(PluginContainerConfiguration configuration) {
this.configuration = configuration;
}
+ @Override
public void updatePluginConfiguration(int resourceId, Configuration newPluginConfiguration)
throws InvalidPluginConfigurationClientException, PluginContainerException {
ResourceContainer container = getResourceContainer(resourceId);
@@ -673,11 +677,13 @@ public class InventoryManager extends AgentService implements ContainerService,
}
}
+ @Override
@NotNull
public InventoryReport executeServerScanImmediately() {
return submit(serverScanExecutor);
}
+ @Override
@NotNull
public InventoryReport executeServiceScanImmediately() {
return submit(serviceScanExecutor);
@@ -689,6 +695,7 @@ public class InventoryManager extends AgentService implements ContainerService,
return submit(discoveryExecutor);
}
+ @Override
public void executeServiceScanDeferred() {
inventoryThreadPoolExecutor.submit((Callable<InventoryReport>) this.serviceScanExecutor);
}
@@ -705,6 +712,7 @@ public class InventoryManager extends AgentService implements ContainerService,
* @param changedOnlyReport
* @return The report, for inspection
*/
+ @Override
public AvailabilityReport executeAvailabilityScanImmediately(boolean changedOnlyReport) {
return executeAvailabilityScanImmediately(changedOnlyReport, false);
}
@@ -745,6 +753,7 @@ public class InventoryManager extends AgentService implements ContainerService,
}
}
+ @Override
@NotNull
public AvailabilityReport getCurrentAvailability(Resource resource, boolean changesOnly) {
try {
@@ -790,6 +799,7 @@ public class InventoryManager extends AgentService implements ContainerService,
configuration.getServerServices().getDiscoveryServerService().setResourceEnablement(resourceId, setEnabled);
}
+ @Override
public MergeResourceResponse manuallyAddResource(ResourceType resourceType, int parentResourceId,
Configuration pluginConfiguration, int ownerSubjectId) throws InvalidPluginConfigurationClientException,
PluginContainerException {
@@ -1202,36 +1212,45 @@ public class InventoryManager extends AgentService implements ContainerService,
/**
* Performs a full platform sync so that resources passed in are reflected in the agent's inventory.
*
- * @param platformSyncInfo sync info on the platform and references to the top level servers
+ * @param platformSyncInfo sync info on the platform and references to the top level servers. not null.
*/
private void syncPlatform(PlatformSyncInfo platformSyncInfo) {
final Set<String> allServerSideUuids = new HashSet<String>();
boolean hadSyncedResources = false;
+ ResourceSyncInfo platformResourceSyncInfo = platformSyncInfo.getPlatform();
- // always sync the platform because it does not get included in the top level server sync
- allServerSideUuids.add(platformSyncInfo.getUuid());
- ResourceSyncInfo platformResourceSyncInfo = ResourceSyncInfo.buildResourceSyncInfo(platformSyncInfo);
- log.info("Sync Starting: Platform [" + platformResourceSyncInfo.getId() + "]");
- hadSyncedResources = syncResource(platformResourceSyncInfo) || hadSyncedResources;
- log.info("Sync Complete: Platform [" + platformResourceSyncInfo.getId() + "]. Local inventory changed: ["
+ // sync the platform because it does not get included in the top level server sync
+ allServerSideUuids.add(platformResourceSyncInfo.getUuid());
+ // sync the top level service hierarchy
+ addAllUuids(platformSyncInfo.getServices(), allServerSideUuids);
+
+ // Add the platform sync info to the service hierarchy in order to process in one batch
+ Collection<ResourceSyncInfo> syncInfos = platformSyncInfo.getServices();
+ syncInfos.add(platformResourceSyncInfo);
+
+ log.info("Sync Starting: Platform [" + platformSyncInfo.getPlatform().getId() + "] and top level services.");
+ hadSyncedResources = syncResources(platformResourceSyncInfo.getId(), syncInfos) || hadSyncedResources;
+ log.info("Sync Complete: Platform [" + platformSyncInfo.getPlatform().getId() + "]. Local inventory changed: ["
+ hadSyncedResources + "]");
+ syncInfos = null; // release to GC
+
// then sync the top level servers by calling back to the server for the sync info for each. We
// do this one at a time to avoid forcing the whole inventory into active memory at one time during the sync.
- Collection<Resource> topLevelServers = platformSyncInfo.getTopLevelServers();
- if (null != topLevelServers) {
+ Collection<Integer> topLevelServerIds = platformSyncInfo.getTopLevelServerIds();
+ if (null != topLevelServerIds) {
DiscoveryServerService service = configuration.getServerServices().getDiscoveryServerService();
- for (Resource topLevelServer : topLevelServers) {
- ResourceSyncInfo topLevelServerSyncInfo = service.getResourceSyncInfo(topLevelServer.getId());
- if (null != topLevelServerSyncInfo) {
- //topLevelServerSyncInfo = ResourceSyncInfo.buildResourceSyncInfo(platformSyncInfo,
- // topLevelServerSyncInfo);
- getAllUuids(topLevelServerSyncInfo, allServerSideUuids);
- log.info("Sync Starting: Top Level Server [" + topLevelServerSyncInfo.getId() + "]");
- hadSyncedResources = syncResource(topLevelServerSyncInfo) || hadSyncedResources;
- log.info("Sync Complete: Top Level Server [" + topLevelServerSyncInfo.getId()
- + "] Local inventory changed: [" + hadSyncedResources + "]");
+ for (Integer topLevelServerId : topLevelServerIds) {
+ syncInfos = service.getResourceSyncInfo(topLevelServerId);
+ if (null != syncInfos) {
+ addAllUuids(syncInfos, allServerSideUuids);
+ log.info("Sync Starting: Top Level Server [" + topLevelServerId + "]");
+ hadSyncedResources = syncResources(topLevelServerId, syncInfos) || hadSyncedResources;
+ log.info("Sync Complete: Top Level Server [" + topLevelServerId + "] Local inventory changed: ["
+ + hadSyncedResources + "]");
+
+ syncInfos = null; // release to GC
}
}
}
@@ -1261,13 +1280,9 @@ public class InventoryManager extends AgentService implements ContainerService,
}
}
- private void getAllUuids(ResourceSyncInfo syncInfo, Set<String> allServerSideUuids) {
- allServerSideUuids.add(syncInfo.getUuid());
-
- if (null != syncInfo.getChildSyncInfos()) {
- for (ResourceSyncInfo child : syncInfo.getChildSyncInfos()) {
- getAllUuids(child, allServerSideUuids);
- }
+ private void addAllUuids(Collection<ResourceSyncInfo> syncInfos, Set<String> allServerSideUuids) {
+ for (ResourceSyncInfo syncInfo : syncInfos) {
+ allServerSideUuids.add(syncInfo.getUuid());
}
}
@@ -1278,7 +1293,7 @@ public class InventoryManager extends AgentService implements ContainerService,
* @param syncInfo the resources' sync data
* @return true if any resources needed synchronization, false otherwise
*/
- private boolean syncResource(ResourceSyncInfo syncInfo) {
+ private boolean syncResources(int rootResourceId, Collection<ResourceSyncInfo> syncInfos) {
boolean result = false;
final long startTime = System.currentTimeMillis();
final Set<Resource> syncedResources = new LinkedHashSet<Resource>();
@@ -1292,7 +1307,7 @@ public class InventoryManager extends AgentService implements ContainerService,
try {
log.debug("Processing Server sync info...");
- processSyncInfo(syncInfo, syncedResources, unknownResourceSyncInfos, modifiedResourceIds,
+ processSyncInfo(syncInfos, syncedResources, unknownResourceSyncInfos, modifiedResourceIds,
deletedResourceIds, newlyCommittedResources, ignoredResources);
if (log.isDebugEnabled()) {
@@ -1318,7 +1333,7 @@ public class InventoryManager extends AgentService implements ContainerService,
result = !(syncedResources.isEmpty() && unknownResourceSyncInfos.isEmpty() && modifiedResourceIds.isEmpty());
} catch (Throwable t) {
- log.warn("Failed to synchronize local inventory with Server inventory for Resource [" + syncInfo.getId()
+ log.warn("Failed to synchronize local inventory with Server inventory for Resource [" + rootResourceId
+ "] and its descendants: " + t.getMessage());
// convert to runtime exception so as not to change the api
throw new RuntimeException(t);
@@ -1327,13 +1342,19 @@ public class InventoryManager extends AgentService implements ContainerService,
return result;
}
- public void synchronizeInventory(ResourceSyncInfo resourceSyncInfo) {
- log.info("Synchronizing local inventory with Server inventory for Resource [" + resourceSyncInfo.getId()
- + "] and its descendants...");
+ @Override
+ public void synchronizePlatform(PlatformSyncInfo syncInfo) {
+ syncPlatform(syncInfo);
+ performServiceScan(syncInfo.getPlatform().getId()); // NOTE: This will block (the initial scan blocks).
+ // TODO: (jshaughn) should we also request a full avail scan?
+ }
- // Get the latest resource data rooted at the given id.
- syncResource(resourceSyncInfo); // this method assumes we only get a single resource and its children (BZ 887411)
- performServiceScan(resourceSyncInfo.getId()); // NOTE: This will block (the initial scan blocks).
+ @Override
+ public void synchronizeServer(int resourceId, Collection<ResourceSyncInfo> topLevelServerSyncInfo) {
+ log.info("Synchronizing local inventory with Server inventory for Resource [" + resourceId
+ + "] and its descendants...");
+ syncResources(resourceId, topLevelServerSyncInfo);
+ performServiceScan(resourceId); // NOTE: This will block (the initial scan blocks).
// TODO: (jshaughn) should we also request a full avail scan?
}
@@ -1397,6 +1418,7 @@ public class InventoryManager extends AgentService implements ContainerService,
return resourceContainer.getResourceComponent();
}
+ @Override
public void uninventoryResource(int resourceId) {
ResourceContainer resourceContainer = getResourceContainer(resourceId);
if (resourceContainer == null) {
@@ -1542,6 +1564,7 @@ public class InventoryManager extends AgentService implements ContainerService,
return parentContainerResource.getChildResources();
}
+ @Override
public Resource getPlatform() {
return platform;
}
@@ -2541,6 +2564,7 @@ public class InventoryManager extends AgentService implements ContainerService,
return mgr;
}
+ @Override
public void requestFullAvailabilityReport() {
if (null != availabilityExecutor) {
availabilityExecutor.sendFullReportNextTime();
@@ -2684,10 +2708,12 @@ public class InventoryManager extends AgentService implements ContainerService,
}
}
+ @Override
public void enableServiceScans(int serverResourceId, Configuration config) {
throw new UnsupportedOperationException("not implemented yet"); // TODO: Implement this method.
}
+ @Override
public void disableServiceScans(int serverResourceId) {
throw new UnsupportedOperationException("not implemented yet"); // TODO: Implement this method.
}
@@ -2905,84 +2931,79 @@ public class InventoryManager extends AgentService implements ContainerService,
return versionUpdated;
}
- private void processSyncInfo(ResourceSyncInfo syncInfo, Set<Resource> syncedResources,
+ private void processSyncInfo(Collection<ResourceSyncInfo> syncInfos, Set<Resource> syncedResources,
Set<ResourceSyncInfo> unknownResourceSyncInfos, Set<Integer> modifiedResourceIds,
Set<Integer> deletedResourceIds, Set<Resource> newlyCommittedResources, Set<Resource> ignoredResources) {
- if (InventoryStatus.DELETED == syncInfo.getInventoryStatus()) {
- // A previously deleted resource still being reported by the server. Support for this option can
- // be removed if the server is ever modified to not report deleted resources. It is happening currently
- // because deleted resources are kept to support resource history. The deleted resources are rightfully not
- // in the PC inventory, and so must be handled separately, and not as unknown resources.
- deletedResourceIds.add(syncInfo.getId());
- } else {
- ResourceContainer container = getResourceContainer(syncInfo.getUuid());
- if (container == null) {
- // Either a manually added Resource or just something we haven't discovered.
- // If this unknown resource is to be ignored, then don't bother to do anything.
- if (InventoryStatus.IGNORED != syncInfo.getInventoryStatus()) {
- unknownResourceSyncInfos.add(syncInfo);
- log.info("Got unknown resource: " + syncInfo.getId());
- } else {
- log.info("Got an unknown but ignored resource - ignoring it: " + syncInfo.getId());
- }
+ for (ResourceSyncInfo syncInfo : syncInfos) {
+ if (InventoryStatus.DELETED == syncInfo.getInventoryStatus()) {
+ // A previously deleted resource still being reported by the server. Support for this option can
+ // be removed if the server is ever modified to not report deleted resources. It is happening currently
+ // because deleted resources are kept to support resource history. The deleted resources are rightfully not
+ // in the PC inventory, and so must be handled separately, and not as unknown resources.
+ deletedResourceIds.add(syncInfo.getId());
} else {
- Resource resource = container.getResource();
- // Ensure the Resource classloader is initialized on the Resource container.
- initResourceContainer(resource);
-
- if (log.isDebugEnabled()) {
- log.debug("Local Resource: id=" + resource.getId() + ", status=" + resource.getInventoryStatus()
- + ", mtime=" + resource.getMtime());
- log.debug("Sync Resource: " + syncInfo.getId() + ", status=" + syncInfo.getInventoryStatus()
- + ", mtime=" + syncInfo.getMtime());
- }
-
- final boolean ignoreResource = (InventoryStatus.IGNORED == syncInfo.getInventoryStatus());
- final boolean ignoreResourceType = this.pluginManager.getMetadataManager()
- .isDisabledOrIgnoredResourceType(resource.getResourceType());
- if (ignoreResource || ignoreResourceType) {
- // a resource or its type has been tagged to be ignored - we need to remove it from our inventory
- ignoredResources.add(resource);
+ ResourceContainer container = getResourceContainer(syncInfo.getUuid());
+ if (container == null) {
+ // Either a manually added Resource or just something we haven't discovered.
+ // If this unknown resource is to be ignored, then don't bother to do anything.
+ if (InventoryStatus.IGNORED != syncInfo.getInventoryStatus()) {
+ unknownResourceSyncInfos.add(syncInfo);
+ log.info("Got unknown resource: " + syncInfo.getId());
+ } else {
+ log.info("Got an unknown but ignored resource - ignoring it: " + syncInfo.getId());
+ }
} else {
- if (resource.getInventoryStatus() != InventoryStatus.COMMITTED
- && syncInfo.getInventoryStatus() == InventoryStatus.COMMITTED) {
- newlyCommittedResources.add(resource);
+ Resource resource = container.getResource();
+ // Ensure the Resource classloader is initialized on the Resource container.
+ initResourceContainer(resource);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Local Resource: id=" + resource.getId() + ", status="
+ + resource.getInventoryStatus() + ", mtime=" + resource.getMtime());
+ log.debug("Sync Resource: " + syncInfo.getId() + ", status=" + syncInfo.getInventoryStatus()
+ + ", mtime=" + syncInfo.getMtime());
}
- if (resource.getId() == 0) {
- // This must be a Resource we just reported to the server. Just update its id, mtime, and status.
- resource.setId(syncInfo.getId());
- resource.setMtime(syncInfo.getMtime());
- resource.setInventoryStatus(syncInfo.getInventoryStatus());
- refreshResourceComponentState(container, true);
- syncedResources.add(resource);
+ final boolean ignoreResource = (InventoryStatus.IGNORED == syncInfo.getInventoryStatus());
+ final boolean ignoreResourceType = this.pluginManager.getMetadataManager()
+ .isDisabledOrIgnoredResourceType(resource.getResourceType());
+ if (ignoreResource || ignoreResourceType) {
+ // a resource or its type has been tagged to be ignored - we need to remove it from our inventory
+ ignoredResources.add(resource);
} else {
- // It's a resource that was already synced at least once.
- if (resource.getId() != syncInfo.getId()) {
- // This really should never happen, but check for it just to be bulletproof.
- log.error("PC Resource id (" + resource.getId() + ") does not match Server Resource id ("
- + syncInfo.getId() + ") for Resource with uuid " + resource.getUuid() + ": " + resource);
- modifiedResourceIds.add(syncInfo.getId());
+ if (resource.getInventoryStatus() != InventoryStatus.COMMITTED
+ && syncInfo.getInventoryStatus() == InventoryStatus.COMMITTED) {
+ newlyCommittedResources.add(resource);
}
- // See if it's been modified on the Server since the last time we synced.
- else if (resource.getMtime() < syncInfo.getMtime()) {
- modifiedResourceIds.add(resource.getId());
+
+ if (resource.getId() == 0) {
+ // This must be a Resource we just reported to the server. Just update its id, mtime, and status.
+ resource.setId(syncInfo.getId());
+ resource.setMtime(syncInfo.getMtime());
+ resource.setInventoryStatus(syncInfo.getInventoryStatus());
+ refreshResourceComponentState(container, true);
+ syncedResources.add(resource);
} else {
- // Only try to start up the component if the Resource has *not* been modified on the Server.
- // Otherwise, hold off until we've synced the Resource with the Server.
- refreshResourceComponentState(container, false);
+ // It's a resource that was already synced at least once.
+ if (resource.getId() != syncInfo.getId()) {
+ // This really should never happen, but check for it just to be bulletproof.
+ log.error("PC Resource id (" + resource.getId()
+ + ") does not match Server Resource id (" + syncInfo.getId()
+ + ") for Resource with uuid " + resource.getUuid() + ": " + resource);
+ modifiedResourceIds.add(syncInfo.getId());
+ }
+ // See if it's been modified on the Server since the last time we synced.
+ else if (resource.getMtime() < syncInfo.getMtime()) {
+ modifiedResourceIds.add(resource.getId());
+ } else {
+ // Only try to start up the component if the Resource has *not* been modified on the Server.
+ // Otherwise, hold off until we've synced the Resource with the Server.
+ refreshResourceComponentState(container, false);
+ }
}
}
}
-
- // Recurse...
- if (null != syncInfo.getChildSyncInfos()) {
- for (ResourceSyncInfo childSyncInfo : syncInfo.getChildSyncInfos()) {
- processSyncInfo(childSyncInfo, syncedResources, unknownResourceSyncInfos, modifiedResourceIds,
- deletedResourceIds, newlyCommittedResources, ignoredResources);
- }
- }
}
}
}
@@ -3037,46 +3058,20 @@ public class InventoryManager extends AgentService implements ContainerService,
}
private Set<Resource> getResourcesFromSyncInfos(Set<ResourceSyncInfo> syncInfos) {
-
- final StopWatch stopWatch = new StopWatch();
- final int syncInfosSize = syncInfos.size();
- final Set<Resource> result = new HashSet<Resource>(syncInfosSize);
-
- for (ResourceSyncInfo syncInfo : syncInfos) {
- Resource resource = getResourceFromSyncInfo(syncInfo);
- result.add(resource);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Time to build resource tree from [" + syncInfosSize + "] sync infos=" + stopWatch.getElapsed());
- }
-
- return result;
- }
-
- private Resource getResourceFromSyncInfo(ResourceSyncInfo syncInfo) {
- final boolean isDebugEnabled = log.isDebugEnabled();
- final StopWatch stopWatch = new StopWatch();
- String marker = null;
-
/////
- // First we need to do a breadth first traversal of the sync info tree and build a list of all resource IDs.
-
- if (isDebugEnabled) {
- marker = "a. Breadth-first retrieval of sync info tree";
- stopWatch.markTimeBegin(marker);
- }
-
- List<Integer> resourceIdList = treeToBreadthFirstList(syncInfo);
- int fullResourceTreeSize = resourceIdList.size();
- if (isDebugEnabled) {
- stopWatch.markTimeEnd(marker);
+ // First we need to get a list of the unknown resource ids
+ List<Integer> resourceIdList = new ArrayList<Integer>(syncInfos.size());
+ for (ResourceSyncInfo syncInfo : syncInfos) {
+ resourceIdList.add(syncInfo.getId());
}
/////
// Now we need to loop over batches of the resource ID list - asking the server for their resource representations.
// When we get the resources from the server, we put them in our resourceMap, keyed on ID.
+ final boolean isDebugEnabled = log.isDebugEnabled();
+ final StopWatch stopWatch = new StopWatch();
+ String marker = null;
Map<Integer, Resource> resourceMap = new HashMap<Integer, Resource>(resourceIdList.size());
int batchNumber = 0;
while (!resourceIdList.isEmpty()) {
@@ -3091,7 +3086,7 @@ public class InventoryManager extends AgentService implements ContainerService,
// This usage of .clear() will remove the processed resources from the backing list.
String markerPrefix = null;
if (isDebugEnabled) {
- markerPrefix = String.format("b. Batch [%03d] (%d): ", batchNumber, fullResourceTreeSize);
+ markerPrefix = String.format("a. Batch [%03d] (%d): ", batchNumber, syncInfos.size());
marker = String.format("%sGet resource ID sublist - %d of %d remaining", markerPrefix, end, size);
stopWatch.markTimeBegin(marker);
}
@@ -3136,61 +3131,39 @@ public class InventoryManager extends AgentService implements ContainerService,
}
}
- if (fullResourceTreeSize != resourceMap.size()) {
- log.warn("Expected [" + fullResourceTreeSize + "] but found [" + resourceMap.size()
+ if (syncInfos.size() != resourceMap.size()) {
+ log.warn("Expected [" + syncInfos.size() + "] but found [" + resourceMap.size()
+ "] resources when fetching from server");
}
/////
// We now have all the resources associated with all sync infos in a map.
- // We need to build the full resource tree using the sync info as the blueprint for how to order the resources in a tree.
+ // We need to build the full resource tree using the resource parent info as the blueprint for how to
+ // link the resources in the tree.
if (isDebugEnabled) {
- marker = "c. Build the full resource tree";
+ marker = "b. Build the resource hierarchies";
stopWatch.markTimeBegin(marker);
}
- Resource result = syncInfoTreeToResourceTree(syncInfo, resourceMap);
- resourceMap.clear();
-
- if (isDebugEnabled) {
- stopWatch.markTimeEnd(marker);
-
- log.debug("Full resource tree built from sync info - performance: " + stopWatch);
- }
-
- return result;
- }
-
- private Resource syncInfoTreeToResourceTree(ResourceSyncInfo syncInfo, Map<Integer, Resource> resourceMap) {
- Resource result = resourceMap.get(syncInfo.getId());
-
- if (null == result || null == syncInfo.getChildSyncInfos()) {
- return result;
- }
-
- for (ResourceSyncInfo child : syncInfo.getChildSyncInfos()) {
- Resource childResource = syncInfoTreeToResourceTree(child, resourceMap);
- if (null != childResource) {
- result.addChildResource(childResource);
+ // The root resources to be merged (i.e. the resources whose parents are not in the map)
+ Set<Resource> result = new HashSet<Resource>();
+ for (Resource resource : resourceMap.values()) {
+ if (null == resource.getParentResource()) {
+ result.add(resource); // the platform, make sure we have this
+ continue;
+ }
+ Resource parent = resourceMap.get(resource.getParentResource().getId());
+ if (null != parent) {
+ parent.addChildResource(resource);
+ } else {
+ result.add(resource);
}
}
- return result;
- }
-
- private List<Integer> treeToBreadthFirstList(ResourceSyncInfo syncInfo) {
- List<Integer> result = new ArrayList<Integer>();
+ if (isDebugEnabled) {
+ stopWatch.markTimeEnd(marker);
- LinkedList<ResourceSyncInfo> queue = new LinkedList<ResourceSyncInfo>();
- queue.add(syncInfo);
- while (!queue.isEmpty()) {
- ResourceSyncInfo node = queue.remove();
- result.add(node.getId());
- if (null != node.getChildSyncInfos()) {
- for (ResourceSyncInfo child : node.getChildSyncInfos()) {
- queue.add(child);
- }
- }
+ log.debug("Resource trees built from map - performance: " + stopWatch);
}
return result;
@@ -3500,6 +3473,7 @@ public class InventoryManager extends AgentService implements ContainerService,
*/
class ResourceGotActivatedListener implements InventoryEventListener {
+ @Override
public void resourceActivated(Resource resource) {
if (resource != null && resource.getId() > 0) {
if (log.isDebugEnabled()) {
@@ -3514,14 +3488,17 @@ public class InventoryManager extends AgentService implements ContainerService,
removeInventoryEventListener(this);
}
+ @Override
public void resourceDeactivated(Resource resource) {
// nothing to do
}
+ @Override
public void resourcesAdded(Set<Resource> resources) {
// nothing to do
}
+ @Override
public void resourcesRemoved(Set<Resource> resources) {
// nothing to do
}
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/AbstractResourceUpgradeHandlingTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/AbstractResourceUpgradeHandlingTest.java
index cfa6fa7..e9a3c05 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/AbstractResourceUpgradeHandlingTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/AbstractResourceUpgradeHandlingTest.java
@@ -56,6 +56,10 @@ public abstract class AbstractResourceUpgradeHandlingTest extends ResourceUpgrad
expectations.with(Expectations.any(InventoryReport.class)));
expectations.will(inventory.mergeInventoryReport(InventoryStatus.COMMITTED));
+ expectations.allowing(ss.getDiscoveryServerService()).getResourceSyncInfo(
+ expectations.with(Expectations.any(Integer.class)));
+ expectations.will(inventory.getResourceSyncInfo());
+
expectations.allowing(ss.getDiscoveryServerService()).upgradeResources(
expectations.with(Expectations.any(Set.class)));
expectations.will(inventory.upgradeResources());
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java
index 5a18d65..2bcb7aa 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java
@@ -19,7 +19,6 @@
package org.rhq.core.pc.upgrade;
-import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -132,12 +131,12 @@ public class FakeServerInventory {
throwIfFailing();
Integer resourceId = (Integer) invocation.getParameter(0);
-
- for (Resource c : platform.getChildResources()) {
- if (c.getId() == resourceId) {
- return getResourceSyncInfo(c);
+ for (Resource r : resourceStore.values()) {
+ if (resourceId.equals(r.getId())) {
+ return convert(r);
}
}
+
return null;
}
}
@@ -422,37 +421,29 @@ public class FakeServerInventory {
return platform == null ? null : PlatformSyncInfo.buildPlatformSyncInfo(platform);
}
- private ResourceSyncInfo getResourceSyncInfo(Resource resource) {
+ private Collection<ResourceSyncInfo> getResourceSyncInfo(Resource resource) {
return resource == null ? null : convert(resource);
}
- private static ResourceSyncInfo convert(Resource root) {
- return convertInternal(root, true, new HashMap<String, ResourceSyncInfo>());
+ private static Collection<ResourceSyncInfo> convert(Resource root) {
+ Set<ResourceSyncInfo> result = new HashSet<ResourceSyncInfo>();
+ convertInternal(root, result);
+ return result;
}
- private static ResourceSyncInfo convertInternal(Resource root, boolean isTopLevelServer,
- Map<String, ResourceSyncInfo> intermediateResults) {
+ private static void convertInternal(Resource root, Collection<ResourceSyncInfo> result) {
- ResourceSyncInfo ret = intermediateResults.get(root.getUuid());
+ ResourceSyncInfo rootSyncInfo = ResourceSyncInfo.buildResourceSyncInfo(root);
- if (ret != null) {
- return ret;
+ if (result.contains(rootSyncInfo)) {
+ return;
}
try {
- ret = ResourceSyncInfo.buildResourceSyncInfo(root);
- intermediateResults.put(root.getUuid(), ret);
-
- Integer parentId = root.getParentResource() == null ? null : root.getParentResource().getId();
- getPrivateField(ResourceSyncInfo.class, "parentId").set(ret, parentId);
+ result.add(rootSyncInfo);
- Set<ResourceSyncInfo> children = new LinkedHashSet<ResourceSyncInfo>();
for (Resource child : root.getChildResources()) {
- ResourceSyncInfo syncChild = convertInternal(child, false, intermediateResults);
-
- children.add(syncChild);
+ convertInternal(child, result);
}
- getPrivateField(ResourceSyncInfo.class, "childSyncInfos").set(ret, children);
- return ret;
} catch (Exception e) {
throw new IllegalStateException("Failed to convert resource " + root
@@ -460,15 +451,6 @@ public class FakeServerInventory {
}
}
- private static Field getPrivateField(Class<?> clazz, String fieldName) throws NoSuchFieldException {
- Field field = clazz.getDeclaredField(fieldName);
- if (!field.isAccessible()) {
- field.setAccessible(true);
- }
-
- return field;
- }
-
private static Resource findResource(Resource root, Resource template, Comparator<Resource> comparator) {
if (root == null)
return null;
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/ResourceUpgradeTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/ResourceUpgradeTest.java
index 176f0a4..5572adf 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/ResourceUpgradeTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/ResourceUpgradeTest.java
@@ -42,7 +42,7 @@ import org.rhq.test.pc.PluginContainerSetup;
import org.rhq.test.pc.PluginContainerTest;
/**
- *
+ *
*
* @author Lukas Krejci
*/
@@ -91,6 +91,9 @@ public class ResourceUpgradeTest extends ResourceUpgradeTestBase {
allowing(ss.getDiscoveryServerService()).mergeInventoryReport(with(any(InventoryReport.class)));
will(inv.mergeInventoryReport(InventoryStatus.COMMITTED));
+ allowing(ss.getDiscoveryServerService()).getResourceSyncInfo(with(any(Integer.class)));
+ will(inv.getResourceSyncInfo());
+
oneOf(ss.getDiscoveryServerService()).upgradeResources(with(any(Set.class)));
will(inv.upgradeResources());
}
@@ -159,6 +162,9 @@ public class ResourceUpgradeTest extends ResourceUpgradeTestBase {
allowing(ss.getDiscoveryServerService()).mergeInventoryReport(with(any(InventoryReport.class)));
will(inv.mergeInventoryReport(InventoryStatus.COMMITTED));
+ allowing(ss.getDiscoveryServerService()).getResourceSyncInfo(with(any(Integer.class)));
+ will(inv.getResourceSyncInfo());
+
never(ss.getDiscoveryServerService()).upgradeResources(with(any(Set.class)));
}
});
@@ -208,6 +214,9 @@ public class ResourceUpgradeTest extends ResourceUpgradeTestBase {
allowing(ss.getDiscoveryServerService()).mergeInventoryReport(with(any(InventoryReport.class)));
will(inv.mergeInventoryReport(InventoryStatus.COMMITTED));
+ allowing(ss.getDiscoveryServerService()).getResourceSyncInfo(with(any(Integer.class)));
+ will(inv.getResourceSyncInfo());
+
never(ss.getDiscoveryServerService()).upgradeResources(with(any(Set.class)));
}
});
@@ -258,6 +267,9 @@ public class ResourceUpgradeTest extends ResourceUpgradeTestBase {
allowing(ss.getDiscoveryServerService()).mergeInventoryReport(with(any(InventoryReport.class)));
will(inv.mergeInventoryReport(InventoryStatus.COMMITTED));
+ allowing(ss.getDiscoveryServerService()).getResourceSyncInfo(with(any(Integer.class)));
+ will(inv.getResourceSyncInfo());
+
oneOf(ss.getDiscoveryServerService()).upgradeResources(with(any(Set.class)));
will(inv.upgradeResources());
}
@@ -297,6 +309,9 @@ public class ResourceUpgradeTest extends ResourceUpgradeTestBase {
allowing(ss.getDiscoveryServerService()).mergeInventoryReport(with(any(InventoryReport.class)));
will(inv.mergeInventoryReport(requiredInventoryStatus));
+
+ allowing(ss.getDiscoveryServerService()).getResourceSyncInfo(with(any(Integer.class)));
+ will(inv.getResourceSyncInfo());
}
});
@@ -334,6 +349,9 @@ public class ResourceUpgradeTest extends ResourceUpgradeTestBase {
allowing(ss.getDiscoveryServerService()).mergeInventoryReport(with(any(InventoryReport.class)));
will(serverInventory.mergeInventoryReport(InventoryStatus.COMMITTED));
+ allowing(ss.getDiscoveryServerService()).getResourceSyncInfo(with(any(Integer.class)));
+ will(serverInventory.getResourceSyncInfo());
+
oneOf(ss.getDiscoveryServerService()).upgradeResources(with(any(Set.class)));
will(serverInventory.upgradeResources());
}
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanTest.java
index 35fa7f1..4de1380 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBeanTest.java
@@ -20,6 +20,7 @@ package org.rhq.enterprise.server.configuration;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -35,7 +36,6 @@ import org.rhq.core.clientapi.agent.discovery.DiscoveryAgentService;
import org.rhq.core.clientapi.agent.discovery.InvalidPluginConfigurationClientException;
import org.rhq.core.clientapi.server.configuration.ConfigurationUpdateResponse;
import org.rhq.core.clientapi.server.discovery.InventoryReport;
-import org.rhq.core.communications.command.annotation.Asynchronous;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
@@ -50,8 +50,8 @@ import org.rhq.core.domain.configuration.group.GroupPluginConfigurationUpdate;
import org.rhq.core.domain.criteria.ResourceConfigurationUpdateCriteria;
import org.rhq.core.domain.discovery.AvailabilityReport;
import org.rhq.core.domain.discovery.MergeResourceResponse;
+import org.rhq.core.domain.discovery.PlatformSyncInfo;
import org.rhq.core.domain.discovery.ResourceSyncInfo;
-import org.rhq.core.domain.measurement.Availability;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
@@ -227,7 +227,7 @@ public class ConfigurationManagerBeanTest extends AbstractEJB3Test {
inProgress = configurationManager.isResourceConfigurationUpdateInProgress(overlord, resourceId);
if (inProgress) {
- // history2 should be history1 since the update is not complete
+ // history2 should be history1 since the update is not complete
assert history2 != null;
assert history2.getId() == history1.getId();
myprop = history2.getConfiguration().getSimple("myboolean");
@@ -235,7 +235,7 @@ public class ConfigurationManagerBeanTest extends AbstractEJB3Test {
assert "true".equals(myprop.getStringValue());
myprop = history2.getConfiguration().getSimple("mysleep"); // this wasn't in the first config
assert myprop == null;
- // record that this test case ran, we expect it will if the agent delay is there
+ // record that this test case ran, we expect it will if the agent delay is there
inProgressTested = true;
} else {
// update is complete, history 2 should be different
@@ -284,7 +284,7 @@ public class ConfigurationManagerBeanTest extends AbstractEJB3Test {
assert "true".equals(myprop.getStringValue());
// now update to config2 - the "agent" will sleep for a bit before it completes
- // so we will have an INPROGRESS configuration for a few seconds before it goes to SUCCESS
+ // so we will have an INPROGRESS configuration for a few seconds before it goes to SUCCESS
configurationManager.updateResourceConfiguration(overlord, resourceId, configuration2);
// now update to config3 - this should fail as you can't update while there is one in progress
@@ -306,7 +306,7 @@ public class ConfigurationManagerBeanTest extends AbstractEJB3Test {
inProgress = configurationManager.isResourceConfigurationUpdateInProgress(overlord, resourceId);
if (inProgress) {
- // history2 should be history1 since the update is not complete
+ // history2 should be history1 since the update is not complete
assert history2 != null;
assert history2.getId() == history1.getId();
myprop = history2.getConfiguration().getSimple("myboolean");
@@ -314,7 +314,7 @@ public class ConfigurationManagerBeanTest extends AbstractEJB3Test {
assert "true".equals(myprop.getStringValue());
myprop = history2.getConfiguration().getSimple("mysleep"); // this wasn't in the first config
assert myprop == null;
- // record that this test case ran, we expect it will if the agent delay is there
+ // record that this test case ran, we expect it will if the agent delay is there
inProgressTested = true;
} else {
// update is complete, history 2 should be different
@@ -741,7 +741,7 @@ public class ConfigurationManagerBeanTest extends AbstractEJB3Test {
}
/** Exercise the ConfigurationManagerBean getOptionsForConfigurationDefinition.
- *
+ *
* @throws Exception
*/
@Test(enabled = ENABLE_TESTS)
@@ -1219,10 +1219,6 @@ public class ConfigurationManagerBeanTest extends AbstractEJB3Test {
public void uninventoryResource(int resourceId) {
}
- @Asynchronous(guaranteedDelivery = true)
- public void synchronizeInventory(ResourceSyncInfo syncInfo) {
- }
-
public Configuration validate(Configuration configuration, int resourceId, boolean isStructured)
throws PluginContainerException {
return null;
@@ -1232,5 +1228,13 @@ public class ConfigurationManagerBeanTest extends AbstractEJB3Test {
public void requestFullAvailabilityReport() {
return;
}
+
+ @Override
+ public void synchronizePlatform(PlatformSyncInfo syncInfo) {
+ }
+
+ @Override
+ public void synchronizeServer(int resourceId, Collection<ResourceSyncInfo> toplevelServerSyncInfo) {
+ }
}
}
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/configuration/LargeGroupPluginConfigurationTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/configuration/LargeGroupPluginConfigurationTest.java
index 13343d8..b5e0dba 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/configuration/LargeGroupPluginConfigurationTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/configuration/LargeGroupPluginConfigurationTest.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.server.configuration;
+import java.util.Collection;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -34,8 +35,8 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.discovery.AvailabilityReport;
import org.rhq.core.domain.discovery.MergeResourceResponse;
+import org.rhq.core.domain.discovery.PlatformSyncInfo;
import org.rhq.core.domain.discovery.ResourceSyncInfo;
-import org.rhq.core.domain.measurement.Availability;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.enterprise.server.authz.PermissionException;
@@ -112,7 +113,7 @@ public class LargeGroupPluginConfigurationTest extends LargeGroupTestBase {
int groupUpdateId = configurationManager.scheduleGroupPluginConfigurationUpdate(env.normalSubject,
env.compatibleGroup.getId(), existingMap);
- // group plugin configuration update has been kicked off, wait for the mock agents to each complete their update
+ // group plugin configuration update has been kicked off, wait for the mock agents to each complete their update
System.out.print("Waiting for mock agents");
assert latch.await(5, TimeUnit.MINUTES) : "agents should not have taken this long";
System.out.println(" Mock agents are done.");
@@ -222,10 +223,6 @@ public class LargeGroupPluginConfigurationTest extends LargeGroupTestBase {
}
@Override
- public void synchronizeInventory(ResourceSyncInfo syncInfo) {
- }
-
- @Override
public void uninventoryResource(int resourceId) {
}
@@ -241,5 +238,13 @@ public class LargeGroupPluginConfigurationTest extends LargeGroupTestBase {
public void requestFullAvailabilityReport() {
return;
}
+
+ @Override
+ public void synchronizePlatform(PlatformSyncInfo syncInfo) {
+ }
+
+ @Override
+ public void synchronizeServer(int resourceId, Collection<ResourceSyncInfo> toplevelServerSyncInfo) {
+ }
}
}
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.java
index 9cf9f98..eb3cf20 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.java
@@ -205,10 +205,12 @@ public class DiscoveryBossBeanTest extends AbstractEJB3Test {
assert results != null;
assert results.getIgnoredResourceTypes() == null : "nothing should have been ignored in this test";
assertNotNull(results.getPlatformSyncInfo());
- ResourceSyncInfo syncInfo = discoveryBoss.getResourceSyncInfo(results.getPlatformSyncInfo().getId());
- assert syncInfo != null;
+ Collection<ResourceSyncInfo> syncInfos = discoveryBoss.getResourceSyncInfo(results.getPlatformSyncInfo()
+ .getPlatform().getId());
+ assert syncInfos != null;
+ assert !syncInfos.isEmpty();
- platform.setId(syncInfo.getId());
+ platform.setId(results.getPlatformSyncInfo().getPlatform().getId());
// Now submit the server and its children as an update report
inventoryReport = new InventoryReport(agent);
@@ -251,16 +253,19 @@ public class DiscoveryBossBeanTest extends AbstractEJB3Test {
assert results != null;
assert results.getIgnoredResourceTypes() == null : "nothing should have been ignored in this test";
assertNotNull(results.getPlatformSyncInfo());
- ResourceSyncInfo syncInfo = discoveryBoss.getResourceSyncInfo(results.getPlatformSyncInfo().getId());
- assert syncInfo != null;
+ assertNotNull(results.getPlatformSyncInfo().getTopLevelServerIds());
+ assertTrue(!results.getPlatformSyncInfo().getTopLevelServerIds().isEmpty());
+ Integer resourceId = results.getPlatformSyncInfo().getTopLevelServerIds().iterator().next();
+ Collection<ResourceSyncInfo> syncInfos = discoveryBoss.getResourceSyncInfo(resourceId);
+ assert syncInfos != null;
+ assert !syncInfos.isEmpty();
- ResourceSyncInfo serverSyncInfo = syncInfo.getChildSyncInfos().iterator().next();
Resource resource1 = discoveryBoss.manuallyAddResource(subjectManager.getOverlord(), serviceType2.getId(),
- serverSyncInfo.getId(), new Configuration());
+ resourceId, new Configuration());
try {
Resource resource2 = discoveryBoss.manuallyAddResource(subjectManager.getOverlord(), serviceType2.getId(),
- serverSyncInfo.getId(), new Configuration());
+ resourceId, new Configuration());
fail("Manually adding a singleton that already existed succeeded: " + resource2);
} catch (EJBException e) {
assertEquals(String.valueOf(e.getCause()), RuntimeException.class, e.getCause().getClass());
@@ -295,15 +300,15 @@ public class DiscoveryBossBeanTest extends AbstractEJB3Test {
assert platformSyncInfo != null;
// Check merge result
- assertEquals(InventoryStatus.NEW, platformSyncInfo.getInventoryStatus());
- assertEquals(platform.getChildResources().size(), platformSyncInfo.getTopLevelServers().size());
+ assertEquals(InventoryStatus.NEW, platformSyncInfo.getPlatform().getInventoryStatus());
+ assertEquals(platform.getChildResources().size(), platformSyncInfo.getTopLevelServerIds().size());
// Collect the resource ids generated for the platform and the servers
- int platformId = platformSyncInfo.getId();
+ int platformId = platformSyncInfo.getPlatform().getId();
List<Integer> serverIds = new LinkedList<Integer>();
- for (Resource serverSyncInfo : platformSyncInfo.getTopLevelServers()) {
- serverIds.add(serverSyncInfo.getId());
+ for (Integer serverId : platformSyncInfo.getTopLevelServerIds()) {
+ serverIds.add(serverId);
}
int[] arrayOfServerIds = ArrayUtils.unwrapCollection(serverIds);
@@ -368,8 +373,8 @@ public class DiscoveryBossBeanTest extends AbstractEJB3Test {
assert mergeResults.getIgnoredResourceTypes().contains(new ResourceTypeFlyweight(serverType));
// Check merge result - make sure we should not see any children under the platform (it should have been ignored)
- assertEquals(InventoryStatus.NEW, platformSyncInfo.getInventoryStatus());
- assertEquals(platformSyncInfo.getTopLevelServers().size(), 0);
+ assertEquals(InventoryStatus.NEW, platformSyncInfo.getPlatform().getInventoryStatus());
+ assertEquals(platformSyncInfo.getTopLevelServerIds().size(), 0);
}
@Test(groups = "integration.ejb3")
@@ -428,10 +433,10 @@ public class DiscoveryBossBeanTest extends AbstractEJB3Test {
assert platformSyncInfo != null;
// Collect the resource ids generated for the platform and the servers
- int platformId = platformSyncInfo.getId();
+ int platformId = platformSyncInfo.getPlatform().getId();
List<Integer> serverIds = new LinkedList<Integer>();
- for (Resource serverSyncInfo : platformSyncInfo.getTopLevelServers()) {
- serverIds.add(serverSyncInfo.getId());
+ for (Integer serverId : platformSyncInfo.getTopLevelServerIds()) {
+ serverIds.add(serverId);
}
int[] arrayOfServerIds = ArrayUtils.unwrapCollection(serverIds);
@@ -469,8 +474,8 @@ public class DiscoveryBossBeanTest extends AbstractEJB3Test {
assertEquals(mergeResults.getIgnoredResourceTypes().size(), 1);
assert mergeResults.getIgnoredResourceTypes().contains(new ResourceTypeFlyweight(serverType));
- assertEquals(InventoryStatus.COMMITTED, platformSyncInfo.getInventoryStatus()); // notice platform is committed now
- assertEquals(platformSyncInfo.getTopLevelServers().size(), 0); // notice there are no server children now
+ assertEquals(InventoryStatus.COMMITTED, platformSyncInfo.getPlatform().getInventoryStatus()); // notice platform is committed now
+ assertEquals(platformSyncInfo.getTopLevelServerIds().size(), 0); // notice there are no server children now
}
@Test(groups = "integration.ejb3")
@@ -501,11 +506,11 @@ public class DiscoveryBossBeanTest extends AbstractEJB3Test {
assert platformSyncInfo != null;
// Check merge result
- assertEquals(InventoryStatus.COMMITTED, platformSyncInfo.getInventoryStatus());
- assertEquals(storagePlatform.getChildResources().size(), platformSyncInfo.getTopLevelServers().size());
+ assertEquals(InventoryStatus.COMMITTED, platformSyncInfo.getPlatform().getInventoryStatus());
+ assertEquals(storagePlatform.getChildResources().size(), platformSyncInfo.getTopLevelServerIds().size());
storageNode = resourceManager.getResourceById(subjectManager.getOverlord(), platformSyncInfo
- .getTopLevelServers().iterator().next().getId());
+ .getTopLevelServerIds().iterator().next());
assertNotNull(storageNode);
assertEquals(InventoryStatus.COMMITTED, storageNode.getInventoryStatus());
}
@@ -533,8 +538,7 @@ public class DiscoveryBossBeanTest extends AbstractEJB3Test {
// Then simulate a create resource request
final String userSuppliedResourceName = prefix("User Supplied Resource Name");
final String newResourceKey = prefix("Created Resource Key");
- Resource serverSyncInfo = firstDiscoverySyncInfo.getTopLevelServers().iterator().next();
- final int serverResourceId = serverSyncInfo.getId();
+ final int serverResourceId = firstDiscoverySyncInfo.getTopLevelServerIds().iterator().next();
executeInTransaction(false, new TransactionCallback() {
@Override
@@ -568,10 +572,13 @@ public class DiscoveryBossBeanTest extends AbstractEJB3Test {
// Check that the resource ends with the user supplied name in inventory
- ResourceSyncInfo topLevelServerSyncInfo = discoveryBoss.getResourceSyncInfo(secondDiscoverySyncInfo
- .getTopLevelServers().iterator().next().getId());
- ResourceSyncInfo service1SyncInfo = topLevelServerSyncInfo.getChildSyncInfos().iterator().next();
- Resource service1Resource = getEntityManager().find(Resource.class, service1SyncInfo.getId());
+ Integer toplevelServerId = secondDiscoverySyncInfo.getTopLevelServerIds().iterator().next();
+ Collection<ResourceSyncInfo> topLevelServerSyncInfo = discoveryBoss.getResourceSyncInfo(toplevelServerId);
+ assert topLevelServerSyncInfo.size() == 2;
+ Iterator<ResourceSyncInfo> iter = topLevelServerSyncInfo.iterator();
+ Integer childId = iter.next().getId();
+ childId = childId.equals(toplevelServerId) ? iter.next().getId() : childId;
+ Resource service1Resource = getEntityManager().find(Resource.class, childId);
assertEquals(userSuppliedResourceName, service1Resource.getName());
}
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java
index 0c3a86e..93e2220 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.server.test;
import java.io.InputStream;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -53,17 +54,16 @@ import org.rhq.core.clientapi.server.content.DeletePackagesRequest;
import org.rhq.core.clientapi.server.content.DeployPackagesRequest;
import org.rhq.core.clientapi.server.content.RetrievePackageBitsRequest;
import org.rhq.core.clientapi.server.discovery.InventoryReport;
-import org.rhq.core.communications.command.annotation.Asynchronous;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.content.transfer.DeployPackageStep;
import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
import org.rhq.core.domain.discovery.AvailabilityReport;
import org.rhq.core.domain.discovery.MergeResourceResponse;
+import org.rhq.core.domain.discovery.PlatformSyncInfo;
import org.rhq.core.domain.discovery.ResourceSyncInfo;
import org.rhq.core.domain.drift.DriftDefinition;
import org.rhq.core.domain.drift.DriftFile;
import org.rhq.core.domain.drift.DriftSnapshot;
-import org.rhq.core.domain.measurement.Availability;
import org.rhq.core.domain.measurement.MeasurementData;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.domain.measurement.ResourceMeasurementScheduleRequest;
@@ -333,12 +333,6 @@ public class TestAgentClient implements AgentClient, BundleAgentService, DriftAg
throws InvalidPluginConfigurationClientException, PluginContainerException {
}
- @Asynchronous(guaranteedDelivery = true)
- @Override
- public void synchronizeInventory(ResourceSyncInfo syncInfo) {
- return;
- }
-
@Override
public void createResource(CreateResourceRequest request) throws PluginContainerException {
}
@@ -421,4 +415,12 @@ public class TestAgentClient implements AgentClient, BundleAgentService, DriftAg
public void requestFullAvailabilityReport() {
return;
}
+
+ @Override
+ public void synchronizePlatform(PlatformSyncInfo syncInfo) {
+ }
+
+ @Override
+ public void synchronizeServer(int resourceId, Collection<ResourceSyncInfo> toplevelServerSyncInfo) {
+ }
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
index 71e2e3f..656abd2 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java
@@ -24,6 +24,7 @@ import static org.rhq.core.util.StringUtil.isBlank;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.EnumSet;
@@ -271,14 +272,78 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
return null;
}
- PlatformSyncInfo result = entityManager.find(PlatformSyncInfo.class, platform.getId());
+ Set<Resource> toplevelServices = new HashSet<Resource>();
+ Set<Integer> topLevelServerIds = new HashSet<Integer>();
+
+ for (Resource platformChild : platform.getChildResources()) {
+ switch (platformChild.getResourceType().getCategory()) {
+ case SERVER:
+ topLevelServerIds.add(platformChild.getId());
+ break;
+ case SERVICE:
+ toplevelServices.add(platformChild);
+ break;
+ default:
+ break;
+ }
+ }
+
+ ResourceSyncInfo platformSyncInfo = ResourceSyncInfo.buildResourceSyncInfo(platform);
+ Set<ResourceSyncInfo> topLevelServiceSyncInfo = getToplevelServiceSyncInfo(toplevelServices);
+ PlatformSyncInfo result = new PlatformSyncInfo(platformSyncInfo, topLevelServiceSyncInfo, topLevelServerIds);
+
return result;
}
+ /**
+ * At the time of writing (4.10) platform top level services don't have children so this will be quick, but
+ * write it to handle any future children. In general this will still be a relatively small number of resources.
+ *
+ * @param topLevelServices
+ * @return The top level service hierarchy sync info
+ */
+ private Set<ResourceSyncInfo> getToplevelServiceSyncInfo(Set<Resource> topLevelServices) {
+ Set<ResourceSyncInfo> result = new HashSet<ResourceSyncInfo>(topLevelServices.size());
+ Set<Integer> topLevelServiceIds = new HashSet<Integer>();
+
+ for (Resource topLevelService : topLevelServices) {
+ result.add(ResourceSyncInfo.buildResourceSyncInfo(topLevelService));
+ topLevelServiceIds.add(topLevelService.getId());
+ }
+
+ getToplevelServiceSyncInfoHierarchy(topLevelServiceIds, result);
+
+ return result;
+ }
+
+ private void getToplevelServiceSyncInfoHierarchy(Set<Integer> parentIds, Set<ResourceSyncInfo> result) {
+ if (parentIds.isEmpty()) {
+ return;
+ }
+
+ Query q = entityManager.createNamedQuery(ResourceSyncInfo.QUERY_SERVICE_CHILDREN);
+ q.setParameter("parentIds", parentIds);
+ List<ResourceSyncInfo> childSyncInfos = q.getResultList();
+
+ if (!childSyncInfos.isEmpty()) {
+ result.addAll(childSyncInfos);
+
+ Set<Integer> childIds = new HashSet<Integer>(childSyncInfos.size());
+ for (ResourceSyncInfo childSyncInfo : childSyncInfos) {
+ childIds.add(childSyncInfo.getId());
+ }
+ getToplevelServiceSyncInfoHierarchy(childIds, result);
+ }
+ }
+
@Override
- public ResourceSyncInfo getResourceSyncInfo(int resourceId) {
- // [PERF] this is expensive, it let's hibernate grab the whole hierarchy via eager fetch of children.
- ResourceSyncInfo result = entityManager.find(ResourceSyncInfo.class, resourceId);
+ public Collection<ResourceSyncInfo> getResourceSyncInfo(int resourceId) {
+ // [PERF] this is an expensive query that can return a large collection. But it's faster than the old way of
+ // letting hibernate grab the whole hierarchy via eager fetch of children...
+ Query q = entityManager.createNamedQuery(ResourceSyncInfo.QUERY_TOP_LEVEL_SERVER);
+ q.setParameter("resourceId", resourceId);
+
+ Collection<ResourceSyncInfo> result = q.getResultList();
return result;
}
@@ -360,7 +425,7 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
servers = attachedServers;
// Update and persist the actual inventory statuses
- // This is done is a separate transaction to stop failures in the agent from rolling back the transaction
+ // This is done in a separate transaction to stop failures in the agent from rolling back the transaction
discoveryBoss.updateInventoryStatusInNewTransaction(user, platforms, servers, status);
scheduleAgentInventoryOperationJob(platforms, servers);
@@ -422,7 +487,7 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
}
/**
- * Synchronize the agents inventory status for platforms, and then the servers,
+ * Synchronize the agent's inventory status for platforms, and then the servers,
* omitting servers under synced platforms since they will have been handled
* already. On status change request an agent sync on the affected resources.
* The agent will sync status and determine what other sync work needs to be
@@ -438,8 +503,9 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
AgentClient agentClient = agentManager.getAgentClient(platform.getAgent());
if (agentClient != null) {
try {
- syncInfo = entityManager.find(ResourceSyncInfo.class, platform.getId());
- agentClient.getDiscoveryAgentService().synchronizeInventory(syncInfo);
+ //syncInfo = entityManager.find(ResourceSyncInfo.class, platform.getId());
+ PlatformSyncInfo platformSyncInfo = getPlatformSyncInfo(platform.getAgent());
+ agentClient.getDiscoveryAgentService().synchronizePlatform(platformSyncInfo);
} catch (Exception e) {
LOG.warn("Could not perform commit synchronization with agent for platform [" + platform.getName()
+ "]", e);
@@ -455,8 +521,9 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
AgentClient agentClient = agentManager.getAgentClient(server.getAgent());
if (agentClient != null) {
try {
- syncInfo = entityManager.find(ResourceSyncInfo.class, server.getId());
- agentClient.getDiscoveryAgentService().synchronizeInventory(syncInfo);
+ //syncInfo = entityManager.find(ResourceSyncInfo.class, server.getId());
+ Collection<ResourceSyncInfo> syncInfos = getResourceSyncInfo(server.getId());
+ agentClient.getDiscoveryAgentService().synchronizeServer(server.getId(), syncInfos);
} catch (Exception e) {
LOG.warn("Could not perform commit synchronization with agent for server [" + server.getName()
+ "]", e);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossLocal.java
index 7ed9445..85b55f0 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossLocal.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.server.discovery;
+import java.util.Collection;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
@@ -87,9 +88,11 @@ public interface DiscoveryBossLocal extends DiscoveryBossRemote {
/**
* @param resourceid the root resourceId on which we want to sync
- * @return null if resource not found, otherwise the entire tree rooted at the specified resource
+ * @return null if resource not found, otherwise the entire tree rooted at the specified resource, as an
+ * unordered collection. Although not strictly a Set (to save on computation) this collection should not
+ * contain duplicates.
*/
- ResourceSyncInfo getResourceSyncInfo(int resourceId);
+ Collection<ResourceSyncInfo> getResourceSyncInfo(int resourceId);
/**
* Returns a map of platforms (the keys) and their servers (the values) that are in the auto-discovery queue but not
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java
index 533948b..8fd2cf2 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.server.discovery;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -121,10 +122,10 @@ public class DiscoveryServerServiceImpl implements DiscoveryServerService {
}
@Override
- public ResourceSyncInfo getResourceSyncInfo(int resourceId) {
+ public Collection<ResourceSyncInfo> getResourceSyncInfo(int resourceId) {
long start = System.currentTimeMillis();
DiscoveryBossLocal discoveryBoss = LookupUtil.getDiscoveryBoss();
- ResourceSyncInfo results;
+ Collection<ResourceSyncInfo> results;
results = discoveryBoss.getResourceSyncInfo(resourceId);
10 years, 4 months
[rhq] Branch 'heiko/agentFootprint' - 4 commits - modules/core modules/enterprise
by Heiko W. Rupp
modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java | 6
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java | 9
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java | 6
modules/core/dbutils/pom.xml | 2
modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml | 2
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 3
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java | 77 +
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/ConfigurationDefinition.java | 10
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 2
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java | 2
modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java | 16
modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java | 4
modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/ResourceUpgradeFailureHandlingTest.java | 101 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/D3GroupGraphListView.java | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java | 408 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupView.java | 193 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupViewDataSource.java | 314 +++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricAvailabilityView.java | 223 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsGridFieldName.java | 63 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java | 30
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java | 56 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/ResourceMetricAvailabilityView.java | 224 -----
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/util/rpc/TrackingRequestCallback.java | 6
modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh | 10
modules/enterprise/remoting/cli/src/etc/rhq-cli.sh | 67 -
modules/enterprise/server/xml-schemas/src/main/java/org/rhq/enterprise/server/xmlschema/ConfigurationInstanceDescriptorUtil.java | 8
modules/enterprise/server/xml-schemas/src/test/java/org/rhq/enterprise/server/xmlschema/ConfigurationInstanceDescriptorUtilTest.java | 110 +-
29 files changed, 1506 insertions(+), 453 deletions(-)
New commits:
commit e0e6a56d96c39dd84d18b0111abcc5328bfaf382
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Dec 17 17:03:44 2013 +0100
Various changes to fix (most) test suite issues.
diff --git a/modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java b/modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java
index 94654ee..dd44e81 100644
--- a/modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java
+++ b/modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java
@@ -63,7 +63,7 @@ import org.rhq.core.domain.resource.ResourceType;
* own. It is only meant as a helper.
* <p>
* This impl uses mockito for defining the answers to various calls.
- *
+ *
* @author Lukas Krejci
*/
public class FakeServerInventory {
@@ -75,7 +75,7 @@ public class FakeServerInventory {
* for the complete discovery to finish in case your
* fake server commits some resources (which starts off
* asynchronous discovery of children).
- *
+ *
*
* @author Lukas Krejci
*/
@@ -554,7 +554,7 @@ public class FakeServerInventory {
if (parent != null && parent != Resource.ROOT) {
parent = fakePersist(agentSideResource.getParentResource(), requiredInventoryStatus, inProgressUUIds);
persisted.setParentResource(parent);
- parent.getChildResources().add(persisted);
+ parent.addChildResource(persisted);
} else {
persisted.setParentResource(parent);
}
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java
index d40d82d..f7dbb73 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java
@@ -29,6 +29,7 @@ import javax.xml.bind.JAXBElement;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jetbrains.annotations.NotNull;
import org.rhq.core.clientapi.agent.configuration.ConfigurationUtility;
import org.rhq.core.clientapi.descriptor.configuration.ConfigurationDescriptor;
@@ -79,13 +80,17 @@ public class ConfigurationMetadataParser {
private static Log log = LogFactory.getLog("ConfigurationMetadataParser");
- public static ConfigurationDefinition parse(String configurationName, ConfigurationDescriptor descriptor)
+ public static ConfigurationDefinition parse(@NotNull String configurationName, ConfigurationDescriptor descriptor)
throws InvalidPluginDescriptorException {
if (descriptor == null) {
return null;
}
- ConfigurationDefinition configurationDefinition = new ConfigurationDefinition(configurationName.intern(),
+ if (configurationName==null) {
+ throw new IllegalArgumentException("ConfigurationName must not be null");
+ }
+
+ ConfigurationDefinition configurationDefinition = new ConfigurationDefinition(configurationName,
descriptor.getNotes());
configurationDefinition.setConfigurationFormat(getConfigurationFormat(descriptor));
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
index e5d58b2..c4b1229 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
@@ -769,7 +769,11 @@ public class PluginMetadataParser {
private void registerResourceTypeAndComponentClasses(ResourceType resourceType, String discoveryClass,
String componentClass) {
this.resourceTypes.add(resourceType);
- this.componentClasses.put(resourceType, componentClass.intern());
+ if (componentClass!=null) {
+ this.componentClasses.put(resourceType, componentClass.intern());
+ } else {
+ this.componentClasses.put(resourceType, null);
+ }
if (discoveryClass != null) {
this.discoveryClasses.put(resourceType, discoveryClass.intern());
}
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 779f7b3..95eb62a 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -17,7 +17,7 @@
<description>Database schema setup, upgrade and other utilities</description>
<properties>
- <db.schema.version>2.142</db.schema.version>
+ <db.schema.version>2.143</db.schema.version>
<rhq.ds.type-mapping>${rhq.test.ds.type-mapping}</rhq.ds.type-mapping>
<rhq.ds.server-name>${rhq.test.ds.server-name}</rhq.ds.server-name>
<rhq.ds.db-name>${rhq.test.ds.db-name}</rhq.ds.db-name>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
index b484d2b..303b991 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
@@ -127,7 +127,7 @@
<table name="RHQ_RAW_CONFIG">
<column name="ID" type="INTEGER" required="true" default="sequence-only" initial="10001" primarykey="true"/>
- <column name="CONFIG_ID" type="INTEGER" required="true" references="RHQ_CONFIG(ID)"/>
+ <column name="CONFIG_ID" type="INTEGER" required="false" references="RHQ_CONFIG(ID)"/>
<column name="PATH" type="VARCHAR2" required="false" size="512"/>
<column name="CONTENTS" type="CLOB" required="true"/>
<column name="SHA256" type="VARCHAR2" size="64" required="true"/>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index dc7abfb..3d66d1d 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -2286,6 +2286,9 @@
<schemaSpec version="2.142">
<schema-javaTask className="SystemSettingsPasswordObfuscationTask" />
</schemaSpec>
+ <schemaSpec version="2.143">
+ <schema-alterColumn table="RHQ_RAW_CONFIG" column="config_ID" nullable="true"/>
+ </schemaSpec>
</dbupgrade>
</target>
</project>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
index 64dc441..65d760e 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
@@ -30,6 +30,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.NoSuchElementException;
import java.util.Set;
import javax.persistence.Column;
@@ -402,27 +403,33 @@ public class Configuration implements Serializable, Cloneable, AbstractPropertyM
@Override
public int size() {
- return properties.size();
+ return properties==null ? 0: properties.size();
}
@Override
public boolean isEmpty() {
- return properties.isEmpty();
+ return properties == null || properties.isEmpty();
}
@Override
public boolean contains(Object o) {
- return properties.containsValue(o);
+ return properties==null ? false : properties.containsValue(o);
}
@Override
public Iterator<Property> iterator() {
- return properties.values().iterator();
+ if (properties == null) {
+ // TODO replace with Collections.emptyIterator(); when we require java 7
+ return Configuration.emptyIterator();
+ }
+ else {
+ return properties.values().iterator();
+ }
}
@Override
public Object[] toArray() {
- return properties.values().toArray();
+ return properties==null ? new Object[]{} :properties.values().toArray();
}
@Override
@@ -481,7 +488,9 @@ public class Configuration implements Serializable, Cloneable, AbstractPropertyM
@Override
public void clear() {
- properties.clear();
+ if (properties!=null) {
+ properties.clear();
+ }
}
@Override
@@ -510,9 +519,9 @@ public class Configuration implements Serializable, Cloneable, AbstractPropertyM
private transient PropertiesProxy propertiesProxy;
- @OneToMany(mappedBy = "configuration", fetch = FetchType.EAGER)
+ @OneToMany(mappedBy = "configuration", fetch = FetchType.LAZY)
@Cascade({ CascadeType.PERSIST, CascadeType.MERGE, CascadeType.DELETE_ORPHAN })
- private Set<RawConfiguration> rawConfigurations = new HashSet<RawConfiguration>();
+ private Set<RawConfiguration> rawConfigurations;
@Column(name = "NOTES")
private String notes;
@@ -852,7 +861,7 @@ public class Configuration implements Serializable, Cloneable, AbstractPropertyM
rawConfiguration.setConfiguration(null);
}
if (rawConfigurations.isEmpty()) {
- rawConfigurations = null;
+ rawConfigurations = Collections.emptySet();
}
return removed;
}
@@ -982,16 +991,34 @@ public class Configuration implements Serializable, Cloneable, AbstractPropertyM
Configuration that = (Configuration) obj;
+ if (this.properties == null || this.properties.isEmpty()){
+ if ( that.properties== null || that.properties.isEmpty()) {
+ return true;
+ }
+ else {
+ return false;
+ }
+ } else {
+ if (!this.properties.equals(that.properties)) {
+ return false;
+ }
+ }
+
boolean rcEquals=true;
if (this.rawConfigurations!=null) {
rcEquals = this.getRawConfigurations().equals(that.getRawConfigurations());
- }
- return (this.properties.equals(that.properties)) && rcEquals;
+ }
+
+ return rcEquals;
}
@Override
public int hashCode() {
- int hc = properties.hashCode(); // TODO this requires loading of all properties and is expensive
+ int hc = 1;
+ if (properties!=null ) {
+ hc = properties.hashCode(); // TODO this requires loading of all properties and is expensive
+ }
+
if (rawConfigurations!=null) {
int rchc = rawConfigurations.hashCode() ;
hc = hc * rchc + 19;
@@ -1062,6 +1089,32 @@ public class Configuration implements Serializable, Cloneable, AbstractPropertyM
* @return {@code Map<String, Property>}
*/
public Map<String, Property> getAllProperties() {
+ if (this.properties==null) {
+ return Collections.emptyMap();
+ }
return this.properties;
}
+
+
+ /*
+ ************ Copied from JDK7, as JDK6 is lacking that
+ * remove when we can require JDK 7
+ */
+
+ @SuppressWarnings("unchecked")
+ @Deprecated
+ public static <T> Iterator<T> emptyIterator() {
+ return (Iterator<T>) EmptyIterator.EMPTY_ITERATOR;
+ }
+
+ @Deprecated
+ private static class EmptyIterator<E> implements Iterator<E> {
+ static final EmptyIterator<Object> EMPTY_ITERATOR
+ = new EmptyIterator();
+
+ public boolean hasNext() { return false; }
+ public E next() { throw new NoSuchElementException(); }
+ public void remove() { throw new IllegalStateException(); }
+ }
+
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/ConfigurationDefinition.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/ConfigurationDefinition.java
index d745b28..5e7457d 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/ConfigurationDefinition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/ConfigurationDefinition.java
@@ -95,7 +95,7 @@ public class ConfigurationDefinition implements Serializable {
@MapKey(name = "name")
// base the insert-order on propDef Id (asc). Since rows are inserted in the order presented in the
// plugin descriptor, iterating on the map (LinkedHashMap) will give us the same ordering. So, unless
- // propDef.order is set and used for ordering by the accessing code, we'll default to the descriptor order.
+ // propDef.order is set and used for ordering by the accessing code, we'll default to the descriptor order.
@OrderBy
@org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
@OneToMany(mappedBy = "configurationDefinition", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@@ -104,7 +104,7 @@ public class ConfigurationDefinition implements Serializable {
// use the configTemplate name as the map key
@MapKey(name = "name")
// base the insert-order on configTemplate Id (asc). Since rows are inserted in the order presented in the
- // plugin descriptor, iterating on the map (LinkedHashMap) will give us the same ordering.
+ // plugin descriptor, iterating on the map (LinkedHashMap) will give us the same ordering.
@OrderBy
@OneToMany(mappedBy = "configurationDefinition", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private Map<String, ConfigurationTemplate> templates = new LinkedHashMap<String, ConfigurationTemplate>();
@@ -118,7 +118,7 @@ public class ConfigurationDefinition implements Serializable {
}
public ConfigurationDefinition(@NotNull String name, String description) {
- this.name = name;
+ this.name = name.intern();
this.description = description;
}
@@ -136,7 +136,7 @@ public class ConfigurationDefinition implements Serializable {
}
public void setName(@NotNull String name) {
- this.name = name;
+ this.name = name.intern();
}
public String getDescription() {
@@ -151,7 +151,7 @@ public class ConfigurationDefinition implements Serializable {
* This property is currently used only for resource configuration which may support structured config, raw
* config, both, or neither. For an older plugin that was implemented prior to raw config support, this would be
* <code>null</code>.
- *
+ *
* @return The configuration format which may be structured, raw, or both. <code>null</code> indicates an older
* plugin that was developed prior to raw configuration being supported.
*/
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
index fd5713c..b5826da 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
@@ -3243,7 +3243,7 @@ public class InventoryManager extends AgentService implements ContainerService,
if (parentResourceFromServer != null) {
ResourceContainer parentResourceContainer = getResourceContainer(parentResourceFromServer);
if (parentResourceContainer == null) {
- parentResourceContainer = getResourceContainer(parentResourceFromServer.getId());
+ parentResourceContainer = getResourceContainer(parentResourceFromServer);
}
if (parentResourceContainer != null) {
parentResource = parentResourceContainer.getResource();
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java
index fd423a7..5265977 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java
@@ -161,7 +161,7 @@ public class RuntimeDiscoveryExecutor implements Runnable, Callable<InventoryRep
log.debug("Discovering child Resources for " + parent + "...");
- ResourceContainer parentContainer = this.inventoryManager.getResourceContainer(parent.getId());
+ ResourceContainer parentContainer = this.inventoryManager.getResourceContainer(parent);
if (parentContainer == null) {
if (log.isDebugEnabled()) {
log.debug("Cannot perform service scan on parent [" + parent + "] without a container");
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java
index 503db49..303dcb6 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/upgrade/ResourceUpgradeDelegate.java
@@ -47,12 +47,12 @@ import org.rhq.core.pluginapi.upgrade.ResourceUpgradeFacet;
/**
* This is a helper class to {@link InventoryManager} that takes care of resource upgrade.
* Note that this class is not thread-safe in any manner.
- *
+ *
* This class must not call (explicitly or implicitly anywhere in its outgoing call chain)
* any other plugin container manager other than the InventoryManager. This is because
* this delegate is called within the Inventory Manager's initialize method and hence
* many other managers are not yet initialized themselves yet.
- *
+ *
* @author Lukas Krejci
*/
public class ResourceUpgradeDelegate {
@@ -73,7 +73,7 @@ public class ResourceUpgradeDelegate {
}
/**
- * Is the delegate enabled? In another words has the resource upgrade phase finished in the {@link IventoryManager#initialize()}
+ * Is the delegate enabled? In another words has the resource upgrade phase finished in the {@link InventoryManager#initialize()}
* method?
*/
public boolean enabled() {
@@ -96,7 +96,7 @@ public class ResourceUpgradeDelegate {
* If later on the upgrade fails to finish due to communication error with server or the
* server doesn't approve some upgrades for whatever reason, the resources will be restarted
* with the original data.
- *
+ *
* @param resourceContainer
* @return true if the resource was queued for upgrade with no problems,
* false if there was some problem upgrading and the resource container was deactivated as
@@ -120,7 +120,7 @@ public class ResourceUpgradeDelegate {
/**
* Tells whether given resource had a upgrade failure during the {@link #processAndQueue(ResourceContainer)} invocation.
- *
+ *
* @param resource the resource to test
* @return true if there was an error upgrading this resource, false otherwise
*/
@@ -131,7 +131,7 @@ public class ResourceUpgradeDelegate {
/**
* Tells whether at least one of the children with given resource type of the given parent resource
* had an upgrade failure during {@link #processAndQueue(ResourceContainer)} invocation.
- *
+ *
* @return true if at least one of the children of given type failed to upgrade, false otherwise
*/
public boolean hasUpgradeFailedInChildren(Resource parentResource, ResourceType childrenResourceType) {
@@ -157,7 +157,7 @@ public class ResourceUpgradeDelegate {
if ((upgradeErrors = checkUpgradeValid(resource, request)) != null) {
//the resource is in its upgraded state but it's going to get reverted back to the original state
//in the code below. Let's use the original resource for the error message so that we don't confuse
- //the user.
+ //the user.
ResourceUpgradeRequest orig = findOriginal(request);
//orig should never be null, but let's be paranoid
@@ -193,7 +193,7 @@ public class ResourceUpgradeDelegate {
//now before we talk to server and sync up the upgraded data,
//reset the resources to their original values so that any changes
- //the server makes to the upgrade data are applied to the "vanilla" state
+ //the server makes to the upgrade data are applied to the "vanilla" state
//of the resources. i.e we only want to make changes the server approves.
for (ResourceUpgradeRequest request : originalResourceData) {
ResourceContainer container = inventoryManager.getResourceContainer(request.getResourceId());
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java
index 3f2bbb9..cf9c1bb 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/FakeServerInventory.java
@@ -210,7 +210,7 @@ public class FakeServerInventory {
ResourceError error = new ResourceError(resource, ResourceErrorType.UPGRADE,
request.getUpgradeErrorMessage(), request.getUpgradeErrorStackTrace(),
request.getTimestamp());
- resource.getResourceErrors().add(error);
+ resource.addResourceError(error);
}
responses.add(resp);
@@ -372,7 +372,7 @@ public class FakeServerInventory {
if (parent != null && parent != Resource.ROOT) {
parent = fakePersist(agentSideResource.getParentResource(), statusJudge, inProgressUUIds);
persisted.setParentResource(parent);
- parent.getChildResources().add(persisted);
+ parent.addChildResource(persisted);
} else {
persisted.setParentResource(parent);
}
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/ResourceUpgradeFailureHandlingTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/ResourceUpgradeFailureHandlingTest.java
index c559553..e86dda7 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/ResourceUpgradeFailureHandlingTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/ResourceUpgradeFailureHandlingTest.java
@@ -53,7 +53,7 @@ import org.rhq.test.pc.PluginContainerSetup;
* / \
* ParentDependency(parentdep) ParentDepSibling(parentsibling)
* / \
- * TestResource(test) TestResourceSibling(sibling)
+ * TestResource(test) TestResourceSibling(sibling)
* </pre>
* The dependencies in the above "chart" are formed using either the <code><runs-inside></code>
* or <code>sourcePlugin/sourceType</code> approaches just to test that both are handled correctly.
@@ -61,7 +61,7 @@ import org.rhq.test.pc.PluginContainerSetup;
* The <code>parentdep</code>, <code>parentsibling</code>, <code>test</code> and <code>sibling</code> plugins are present
* in two versions and support the {@link ResourceUpgradeFacet}, while the rest of the plugins is
* present only in single version.
- *
+ *
* @author Lukas Krejci
*/
@Test(singleThreaded = true, invocationCount = 1)
@@ -72,7 +72,7 @@ public class ResourceUpgradeFailureHandlingTest extends AbstractResourceUpgradeH
private static final String FAILURE_ON_LEAF_TEST = "FAILURE_ON_LEAF_TEST";
private static final String FAILURE_ON_DEPENDENCIES_TEST = "FAILURE_ON_DEPENDENCIES_TEST";
private static final String RESOURCES_REVERTED_TO_ORIGINAL_STATE_AFTER_FAILED_UPGRAGE_TEST = "RESOURCES_REVERTED_TO_ORIGINAL_STATE_AFTER_FAILED_UPGRAGE_TEST";
-
+
//plugin names
private static final String BASE_PLUGIN_NAME = "classpath:///resource-upgrade-test-plugin-multi-base-1.0.0.jar";
private static final String PARENT_DEP_V1_PLUGIN_NAME = "classpath:///resource-upgrade-test-plugin-multi-parentdep-1.0.0.jar";
@@ -101,17 +101,17 @@ public class ResourceUpgradeFailureHandlingTest extends AbstractResourceUpgradeH
public void testSuccess_V1() throws Exception {
final FakeServerInventory inv = new FakeServerInventory();
setServerSideFake(SUCCESS_TEST, inv);
-
+
context.checking(new Expectations() {
{
defineDefaultExpectations(inv, this);
}
});
-
- //let the discovery run in V1
+
+ //let the discovery run in V1
startConfiguredPluginContainer();
}
-
+
@Test(dependsOnMethods = "testSuccess_V1")
@PluginContainerSetup(plugins = {TEST_V2_PLUGIN_NAME, PARENT_SIBLING_V2_PLUGIN_NAME, BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V2_PLUGIN_NAME, SIBLING_V2_PLUGIN_NAME},
sharedGroup = SUCCESS_TEST, clearInventoryDat = false, numberOfInitialDiscoveries = 3)
@@ -124,9 +124,9 @@ public class ResourceUpgradeFailureHandlingTest extends AbstractResourceUpgradeH
});
startConfiguredPluginContainer();
-
+
Map<ResType, Set<Resource>> resources = getResourcesFromInventory(inventory, ALL_TYPES);
-
+
checkPresenceOfResourceTypes(resources, ALL_TYPES);
checkNumberOfResources(resources, ROOT_TYPE, 1);
@@ -138,14 +138,14 @@ public class ResourceUpgradeFailureHandlingTest extends AbstractResourceUpgradeH
checkResourcesUpgraded(resources.get(SIBLING_TYPE), 45);
checkResourcesUpgraded(resources.get(TEST_TYPE), 45);
}
-
+
@Test
- @PluginContainerSetup(plugins = {TEST_V1_PLUGIN_NAME, PARENT_SIBLING_V1_PLUGIN_NAME, BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V1_PLUGIN_NAME, SIBLING_V1_PLUGIN_NAME},
+ @PluginContainerSetup(plugins = {TEST_V1_PLUGIN_NAME, PARENT_SIBLING_V1_PLUGIN_NAME, BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V1_PLUGIN_NAME, SIBLING_V1_PLUGIN_NAME},
sharedGroup = FAILURE_ON_LEAF_TEST, clearDataDir = true, numberOfInitialDiscoveries = 3)
public void testFailureOnLeaf_V1() throws Exception {
final FakeServerInventory inventory = new FakeServerInventory();
setServerSideFake(FAILURE_ON_LEAF_TEST, inventory);
-
+
context.checking(new Expectations() {
{
defineDefaultExpectations(inventory, this);
@@ -167,7 +167,7 @@ public class ResourceUpgradeFailureHandlingTest extends AbstractResourceUpgradeH
}
@Test(dependsOnMethods = "testFailureOnLeaf_V1")
- @PluginContainerSetup(plugins = {TEST_V2_PLUGIN_NAME, PARENT_SIBLING_V2_PLUGIN_NAME, BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V2_PLUGIN_NAME, SIBLING_V2_PLUGIN_NAME},
+ @PluginContainerSetup(plugins = {TEST_V2_PLUGIN_NAME, PARENT_SIBLING_V2_PLUGIN_NAME, BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V2_PLUGIN_NAME, SIBLING_V2_PLUGIN_NAME},
sharedGroup = FAILURE_ON_LEAF_TEST, clearInventoryDat = false, numberOfInitialDiscoveries = 3)
public void testFailureOnLeaf_V2() throws Exception {
final FakeServerInventory inventory = (FakeServerInventory) getServerSideFake(FAILURE_ON_LEAF_TEST);
@@ -176,11 +176,11 @@ public class ResourceUpgradeFailureHandlingTest extends AbstractResourceUpgradeH
defineDefaultExpectations(inventory, this);
}
});
-
+
startConfiguredPluginContainer();
-
+
Map<ResType, Set<Resource>> resources = getResourcesFromInventory(inventory, ALL_TYPES);
-
+
checkPresenceOfResourceTypes(resources, ALL_TYPES);
checkNumberOfResources(resources, ROOT_TYPE, 1);
@@ -192,14 +192,14 @@ public class ResourceUpgradeFailureHandlingTest extends AbstractResourceUpgradeH
Resource parent0 = findResourceWithOrdinal(PARENT_TYPE, 0);
Resource parent1 = findResourceWithOrdinal(PARENT_TYPE, 1);
Resource parent2 = findResourceWithOrdinal(PARENT_TYPE, 2);
-
+
Set<Resource> testsUnderParent0 = filterResources(parent0.getChildResources(), TEST_TYPE);
Set<Resource> siblingsUnderParent0 = filterResources(parent0.getChildResources(), SIBLING_TYPE);
Set<Resource> testsUnderParent1 = filterResources(parent1.getChildResources(), TEST_TYPE);
Set<Resource> siblingsUnderParent1 = filterResources(parent1.getChildResources(), SIBLING_TYPE);
Set<Resource> testsUnderParent2 = filterResources(parent2.getChildResources(), TEST_TYPE);
Set<Resource> siblingsUnderParent2 = filterResources(parent2.getChildResources(), SIBLING_TYPE);
-
+
//first check for the successful upgrades
checkResourcesUpgraded(testsUnderParent2, 15);
checkResourcesUpgraded(siblingsUnderParent2, 15);
@@ -212,8 +212,8 @@ public class ResourceUpgradeFailureHandlingTest extends AbstractResourceUpgradeH
//check that the failed resources have the error attached to them
//we find the resource instance from the map provided to this method
- //because that map contains the resources as found on the server-side
- //(i.e. they include error objects).
+ //because that map contains the resources as found on the server-side
+ //(i.e. they include error objects).
Resource failedTest1 = getEqualFrom(resources.get(TEST_TYPE),
findResourceWithOrdinal(testsUnderParent0, 1));
Resource failedTest2 = getEqualFrom(resources.get(TEST_TYPE),
@@ -227,35 +227,35 @@ public class ResourceUpgradeFailureHandlingTest extends AbstractResourceUpgradeH
findResourceWithOrdinal(siblingsUnderParent1, 1));
checkResourceFailedUpgrade(failedSibling);
- checkOthersUpgraded(siblingsUnderParent1, failedSibling);
+ checkOthersUpgraded(siblingsUnderParent1, failedSibling);
}
-
+
@Test
- @PluginContainerSetup(plugins = {TEST_V1_PLUGIN_NAME, PARENT_SIBLING_V1_PLUGIN_NAME, BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V1_PLUGIN_NAME, SIBLING_V1_PLUGIN_NAME},
+ @PluginContainerSetup(plugins = {TEST_V1_PLUGIN_NAME, PARENT_SIBLING_V1_PLUGIN_NAME, BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V1_PLUGIN_NAME, SIBLING_V1_PLUGIN_NAME},
sharedGroup = FAILURE_ON_DEPENDENCIES_TEST, clearDataDir = true, numberOfInitialDiscoveries = 3)
public void testFailureOnDependencies_V1() throws Exception {
final FakeServerInventory inventory = new FakeServerInventory();
setServerSideFake(FAILURE_ON_DEPENDENCIES_TEST, inventory);
-
+
context.checking(new Expectations() {
{
defineDefaultExpectations(inventory, this);
}
});
-
- startConfiguredPluginContainer();
-
+
+ startConfiguredPluginContainer();
+
//in here we set up the failures that are going to happen when
//the v2 plugins are run
Resource parent = findResourceWithOrdinal(PARENT_DEP_TYPE, 0);
assertNotNull(parent, "Failed to find the parent to setup the failures for.");
-
+
addChildrenToFail(parent, PARENT_TYPE, 0);
}
-
+
@Test(dependsOnMethods = "testFailureOnDependencies_V1")
- @PluginContainerSetup(plugins = {TEST_V2_PLUGIN_NAME, PARENT_SIBLING_V2_PLUGIN_NAME, BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V2_PLUGIN_NAME, SIBLING_V2_PLUGIN_NAME},
+ @PluginContainerSetup(plugins = {TEST_V2_PLUGIN_NAME, PARENT_SIBLING_V2_PLUGIN_NAME, BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V2_PLUGIN_NAME, SIBLING_V2_PLUGIN_NAME},
sharedGroup = FAILURE_ON_DEPENDENCIES_TEST, clearInventoryDat = false, numberOfInitialDiscoveries = 3)
public void testFailureOnDependencies_V2() throws Exception {
final FakeServerInventory inventory = (FakeServerInventory) getServerSideFake(FAILURE_ON_DEPENDENCIES_TEST);
@@ -264,11 +264,11 @@ public class ResourceUpgradeFailureHandlingTest extends AbstractResourceUpgradeH
defineDefaultExpectations(inventory, this);
}
});
-
+
startConfiguredPluginContainer();
-
+
Map<ResType, Set<Resource>> resources = getResourcesFromInventory(inventory, ALL_TYPES);
-
+
checkPresenceOfResourceTypes(resources, ALL_TYPES);
checkNumberOfResources(resources, ROOT_TYPE, 1);
@@ -277,7 +277,7 @@ public class ResourceUpgradeFailureHandlingTest extends AbstractResourceUpgradeH
//check that the failed resources have the error attached to them
//we find the resource instance from the map provided to this method
- //because that map contains the resources as found on the server-side
+ //because that map contains the resources as found on the server-side
//(i.e. they include error objects).
Resource parent0 = getEqualFrom(resources.get(PARENT_TYPE), findResourceWithOrdinal(PARENT_TYPE, 0));
Resource parent1 = getEqualFrom(resources.get(PARENT_TYPE), findResourceWithOrdinal(PARENT_TYPE, 1));
@@ -288,37 +288,37 @@ public class ResourceUpgradeFailureHandlingTest extends AbstractResourceUpgradeH
//v2 plugin discovers 3 resources but because parent0 failed to upgrade,
//the discovery shouldn't have occurred leaving us with the 2 already existing resources.
checkNumberOfResources(resources, PARENT_TYPE, 2);
-
+
//parent1 upgraded ok, so discovering its children should have executed.
//this is v2, so we should find 15 of each.
checkResourcesUpgraded(filterResources(parent1.getChildResources(), TEST_TYPE), 15);
checkResourcesUpgraded(filterResources(parent1.getChildResources(), SIBLING_TYPE), 15);
-
+
//these shouldn't have been upgraded. in v1 we had 10 resources of TEST_TYPE
//and 10 resources of SIBLING_TYPE and that's what we should be seeing
//now.
checkResourcesNotUpgraded(filterResources(parent0.getChildResources(), TEST_TYPE), 10);
- checkResourcesNotUpgraded(filterResources(parent0.getChildResources(), SIBLING_TYPE), 10);
+ checkResourcesNotUpgraded(filterResources(parent0.getChildResources(), SIBLING_TYPE), 10);
}
-
+
@Test
- @PluginContainerSetup(plugins = {TEST_V1_PLUGIN_NAME, PARENT_SIBLING_V1_PLUGIN_NAME, BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V1_PLUGIN_NAME, SIBLING_V1_PLUGIN_NAME},
+ @PluginContainerSetup(plugins = {TEST_V1_PLUGIN_NAME, PARENT_SIBLING_V1_PLUGIN_NAME, BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V1_PLUGIN_NAME, SIBLING_V1_PLUGIN_NAME},
sharedGroup = RESOURCES_REVERTED_TO_ORIGINAL_STATE_AFTER_FAILED_UPGRAGE_TEST, clearDataDir = true, numberOfInitialDiscoveries = 3)
public void testResourcesRevertedToOriginalStateAfterFailedUpgrade_V1() throws Exception {
final FakeServerInventory inventory = new FakeServerInventory();
setServerSideFake(RESOURCES_REVERTED_TO_ORIGINAL_STATE_AFTER_FAILED_UPGRAGE_TEST, inventory);
-
+
context.checking(new Expectations() {
{
defineDefaultExpectations(inventory, this);
}
});
-
- startConfiguredPluginContainer();
+
+ startConfiguredPluginContainer();
}
-
+
@Test(dependsOnMethods = "testResourcesRevertedToOriginalStateAfterFailedUpgrade_V1")
- @PluginContainerSetup(plugins = {TEST_V2_PLUGIN_NAME, PARENT_SIBLING_V2_PLUGIN_NAME, BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V2_PLUGIN_NAME, SIBLING_V2_PLUGIN_NAME},
+ @PluginContainerSetup(plugins = {TEST_V2_PLUGIN_NAME, PARENT_SIBLING_V2_PLUGIN_NAME, BASE_PLUGIN_NAME, ROOT_PLUGIN_NAME, PARENT_DEP_V2_PLUGIN_NAME, SIBLING_V2_PLUGIN_NAME},
sharedGroup = RESOURCES_REVERTED_TO_ORIGINAL_STATE_AFTER_FAILED_UPGRAGE_TEST, clearInventoryDat = false, numberOfInitialDiscoveries = 3)
public void testResourcesRevertedToOriginalStateAfterFailedUpgrade_V2() throws Exception {
final FakeServerInventory inventory = (FakeServerInventory) getServerSideFake(RESOURCES_REVERTED_TO_ORIGINAL_STATE_AFTER_FAILED_UPGRAGE_TEST);
@@ -329,11 +329,11 @@ public class ResourceUpgradeFailureHandlingTest extends AbstractResourceUpgradeH
});
inventory.setFailUpgrade(true);
-
+
startConfiguredPluginContainer();
-
+
Map<ResType, Set<Resource>> resources = getResourcesFromInventory(inventory, ALL_TYPES);
-
+
checkPresenceOfResourceTypes(resources, ALL_TYPES);
checkNumberOfResources(resources, ROOT_TYPE, 1);
@@ -343,7 +343,7 @@ public class ResourceUpgradeFailureHandlingTest extends AbstractResourceUpgradeH
checkResourcesNotUpgraded(resources.get(PARENT_DEP_SIBLING_TYPE), 1);
checkResourcesNotUpgraded(resources.get(PARENT_TYPE), 2);
checkResourcesNotUpgraded(resources.get(SIBLING_TYPE), 20);
- checkResourcesNotUpgraded(resources.get(TEST_TYPE), 20);
+ checkResourcesNotUpgraded(resources.get(TEST_TYPE), 20);
}
protected static void checkPresenceOfResourceTypes(Map<ResType, Set<Resource>> resources, Collection<ResType> expectedTypes) {
@@ -367,6 +367,9 @@ public class ResourceUpgradeFailureHandlingTest extends AbstractResourceUpgradeH
ResourceContainer parentContainer = inventoryManager.getResourceContainer(parent);
BaseResourceComponentInterface parentComponent = (BaseResourceComponentInterface) parentContainer
.getResourceComponent();
+ if (parentComponent==null) {
+ throw new RuntimeException("Did not get a container for parent " + parent.getName() + ", " + parent.getUuid() + ", " + parent.getId());
+ }
Map<String, Set<Integer>> childrenToFail = new HashMap<String, Set<Integer>>();
Set<Integer> ordinals = new HashSet<Integer>();
@@ -416,7 +419,7 @@ public class ResourceUpgradeFailureHandlingTest extends AbstractResourceUpgradeH
Set<Resource> rs = inventory.findResourcesByType(resType);
resources.put(type, rs);
}
-
+
return resources;
}
diff --git a/modules/enterprise/server/xml-schemas/src/main/java/org/rhq/enterprise/server/xmlschema/ConfigurationInstanceDescriptorUtil.java b/modules/enterprise/server/xml-schemas/src/main/java/org/rhq/enterprise/server/xmlschema/ConfigurationInstanceDescriptorUtil.java
index 7c6687a..8a74074 100644
--- a/modules/enterprise/server/xml-schemas/src/main/java/org/rhq/enterprise/server/xmlschema/ConfigurationInstanceDescriptorUtil.java
+++ b/modules/enterprise/server/xml-schemas/src/main/java/org/rhq/enterprise/server/xmlschema/ConfigurationInstanceDescriptorUtil.java
@@ -66,7 +66,7 @@ import org.rhq.enterprise.server.xmlschema.generated.configuration.instance.Prop
import org.rhq.enterprise.server.xmlschema.generated.configuration.instance.SimplePropertyInstanceDescriptor;
/**
- *
+ *
*
* @author Lukas Krejci
*/
@@ -420,7 +420,7 @@ public class ConfigurationInstanceDescriptorUtil {
ConfigurationInstanceDescriptor descriptor) {
ConfigurationAndDefinition ret = new ConfigurationAndDefinition();
Configuration configuration = new Configuration();
- ConfigurationDefinition definition = new ConfigurationDefinition(null, null);
+ ConfigurationDefinition definition = new ConfigurationDefinition("tmp", null);
ret.configuration = configuration;
ret.definition = definition;
@@ -514,7 +514,7 @@ public class ConfigurationInstanceDescriptorUtil {
ConfigurationDescriptor tmp = new ConfigurationDescriptor();
tmp.getConfigurationProperty().add(
new JAXBElement<ConfigurationProperty>(getTagName(def), ConfigurationProperty.class, def));
- ConfigurationDefinition configDef = ConfigurationMetadataParser.parse(null, tmp);
+ ConfigurationDefinition configDef = ConfigurationMetadataParser.parse("null", tmp);
return configDef.getPropertyDefinitions().values().iterator().next();
} catch (InvalidPluginDescriptorException e) {
@@ -572,7 +572,7 @@ public class ConfigurationInstanceDescriptorUtil {
* configuration instance with defined values. This is used during the config synchronization
* to output the default configuration of an importer directly in the export file so that the
* users have an easy way of modifying that configuration.
- *
+ *
* @param definition
* @param configuration
* @return
diff --git a/modules/enterprise/server/xml-schemas/src/test/java/org/rhq/enterprise/server/xmlschema/ConfigurationInstanceDescriptorUtilTest.java b/modules/enterprise/server/xml-schemas/src/test/java/org/rhq/enterprise/server/xmlschema/ConfigurationInstanceDescriptorUtilTest.java
index 28f05de..a11be8f 100644
--- a/modules/enterprise/server/xml-schemas/src/test/java/org/rhq/enterprise/server/xmlschema/ConfigurationInstanceDescriptorUtilTest.java
+++ b/modules/enterprise/server/xml-schemas/src/test/java/org/rhq/enterprise/server/xmlschema/ConfigurationInstanceDescriptorUtilTest.java
@@ -59,7 +59,7 @@ import org.rhq.enterprise.server.xmlschema.generated.configuration.instance.List
import org.rhq.enterprise.server.xmlschema.generated.configuration.instance.SimplePropertyInstanceDescriptor;
/**
- *
+ *
*
* @author Lukas Krejci
*/
@@ -90,7 +90,7 @@ public class ConfigurationInstanceDescriptorUtilTest {
}
public void testSimplePropertyConversion() throws Exception {
- ConfigurationDefinition def = new ConfigurationDefinition(null, null);
+ ConfigurationDefinition def = new ConfigurationDefinition("null", null);
PropertyDefinitionSimple propDef =
new PropertyDefinitionSimple("prop", "prop descr", true, PropertySimpleType.BOOLEAN);
def.put(propDef);
@@ -117,7 +117,7 @@ public class ConfigurationInstanceDescriptorUtilTest {
}
public void testListOfSimplesPropertyConversion() throws Exception {
- ConfigurationDefinition def = new ConfigurationDefinition(null, null);
+ ConfigurationDefinition def = new ConfigurationDefinition("null", null);
PropertyDefinitionList listDef =
new PropertyDefinitionList("list", "list descr", true, new PropertyDefinitionSimple("prop", "prop descr",
false, PropertySimpleType.FLOAT));
@@ -160,7 +160,7 @@ public class ConfigurationInstanceDescriptorUtilTest {
}
public void testListOfMapsPropertyConversion() throws Exception {
- ConfigurationDefinition def = new ConfigurationDefinition(null, null);
+ ConfigurationDefinition def = new ConfigurationDefinition("null", null);
PropertyDefinitionList listDef =
new PropertyDefinitionList("list", "list descr", true, new PropertyDefinitionMap("map", "map descr", true,
new PropertyDefinitionSimple("prop1", "prop1 descr", true, PropertySimpleType.BOOLEAN),
@@ -201,12 +201,12 @@ public class ConfigurationInstanceDescriptorUtilTest {
assertEquals(map1.getComplexValue().size(), 2, "Unexpected number of map elements in the first map value.");
assertEquals(map2.getComplexValue().size(), 2, "Unexpected number of map elements in the second map value.");
-
+
ComplexValueSimpleDescriptor value11 = (ComplexValueSimpleDescriptor) map1.getComplexValue().get(0).getValue();
ComplexValueSimpleDescriptor value12 = (ComplexValueSimpleDescriptor) map1.getComplexValue().get(1).getValue();
ComplexValueSimpleDescriptor value21 = (ComplexValueSimpleDescriptor) map2.getComplexValue().get(0).getValue();
ComplexValueSimpleDescriptor value22 = (ComplexValueSimpleDescriptor) map2.getComplexValue().get(1).getValue();
-
+
assertEquals(value11.getPropertyName(), "prop1", "Unexpected name of the first property in the first map value");
assertEquals(value11.getValue(), "value1", "Unexpected value of the first property in the first map value");
assertEquals(value12.getPropertyName(), "prop2", "Unexpected name of the second property in the first map value");
@@ -215,7 +215,7 @@ public class ConfigurationInstanceDescriptorUtilTest {
assertEquals(value21.getValue(), "value2", "Unexpected value of the first property in the second map value");
assertEquals(value22.getPropertyName(), "prop2", "Unexpected name of the second property in the second map value");
assertEquals(value22.getValue(), "value2", "Unexpected value of the second property in the second map value");
-
+
logInstance("List of maps", instance);
}
@@ -228,33 +228,33 @@ public class ConfigurationInstanceDescriptorUtilTest {
"<standaloneConfigurationInstance xmlns:ci='urn:xmlns:rhq-configuration-instance' xmlns:c='urn:xmlns:rhq-configuration'>" +
" <ci:simple-property value='42' name='my-name' type='integer'/>" +
"</standaloneConfigurationInstance>";
-
+
ConfigurationInstanceDescriptor descriptor = (ConfigurationInstanceDescriptor) CONFIGURATION_INSTANCE_UNMARSHALLER.unmarshal(new StringReader(xml));
-
+
ConfigurationInstanceDescriptorUtil.ConfigurationAndDefinition ccd = ConfigurationInstanceDescriptorUtil.createConfigurationAndDefinition(descriptor);
-
+
ConfigurationDefinition def = ccd.definition;
Configuration conf = ccd.configuration;
-
+
assertEquals(def.getPropertyDefinitions().size(), 1, "Unexpected number of defined properties");
assertEquals(conf.getProperties().size(), 1, "Unexpected number of properties");
-
+
PropertyDefinition propDef = def.get("my-name");
Property prop = conf.get("my-name");
-
+
assertNotNull(propDef, "Could not find the expected property definition");
assertNotNull(prop, "Could not find the expected property");
-
+
assertEquals(propDef.getClass(), PropertyDefinitionSimple.class, "Unexpected type of the property definition");
assertEquals(prop.getClass(), PropertySimple.class, "Unexpecetd type of the property");
-
+
PropertyDefinitionSimple simpleDef = (PropertyDefinitionSimple) propDef;
PropertySimple simpleProp = (PropertySimple) prop;
-
+
assertEquals(simpleDef.getType(), PropertySimpleType.INTEGER, "Unexpected type of the simple property definition");
- assertEquals(simpleProp.getIntegerValue(), Integer.valueOf(42), "Unexpected value of the simple property");
+ assertEquals(simpleProp.getIntegerValue(), Integer.valueOf(42), "Unexpected value of the simple property");
}
-
+
public void testReverseListPropertyConversion() throws Exception {
String xml = "" +
"<standaloneConfigurationInstance xmlns:ci='urn:xmlns:rhq-configuration-instance' xmlns:c='urn:xmlns:rhq-configuration'>" +
@@ -269,44 +269,44 @@ public class ConfigurationInstanceDescriptorUtilTest {
"</standaloneConfigurationInstance>";
ConfigurationInstanceDescriptor descriptor = (ConfigurationInstanceDescriptor) CONFIGURATION_INSTANCE_UNMARSHALLER.unmarshal(new StringReader(xml));
-
+
ConfigurationInstanceDescriptorUtil.ConfigurationAndDefinition ccd = ConfigurationInstanceDescriptorUtil.createConfigurationAndDefinition(descriptor);
-
+
ConfigurationDefinition def = ccd.definition;
Configuration conf = ccd.configuration;
-
+
assertEquals(def.getPropertyDefinitions().size(), 1, "Unexpected number of defined properties");
assertEquals(conf.getProperties().size(), 1, "Unexpected number of properties");
PropertyDefinition propDef = def.get("list");
Property prop = conf.get("list");
-
+
assertNotNull(propDef, "Could not find the expected property definition");
assertNotNull(prop, "Could not find the expected property");
-
+
assertEquals(propDef.getClass(), PropertyDefinitionList.class, "Unexpected type of the property definition");
assertEquals(prop.getClass(), PropertyList.class, "Unexpecetd type of the property");
-
+
PropertyDefinitionList listDef = (PropertyDefinitionList) propDef;
PropertyList listProp = (PropertyList) prop;
-
+
PropertyDefinition memberDef = listDef.getMemberDefinition();
assertEquals(memberDef.getClass(), PropertyDefinitionSimple.class, "Unexpected type of the list member property definition");
-
+
PropertyDefinitionSimple memberSimpleDef = (PropertyDefinitionSimple) memberDef;
assertEquals(memberSimpleDef.getName(), "member");
assertEquals(memberSimpleDef.getType(), PropertySimpleType.INTEGER);
-
+
assertEquals(listProp.getList().size(), 3, "Unexpected number of list members");
-
+
for(int i = 0; i < 3; ++i) {
Property memberProp = listProp.getList().get(i);
assertEquals(memberProp.getClass(), PropertySimple.class, "Unexpected type of the property in the list on index " + i);
assertEquals(memberProp.getName(), "member");
assertEquals(((PropertySimple)memberProp).getIntegerValue(), Integer.valueOf(i + 1));
- }
+ }
}
-
+
public void testReverseMapPropertyConversion() throws Exception {
String xml = "" +
"<standaloneConfigurationInstance xmlns:ci='urn:xmlns:rhq-configuration-instance' xmlns:c='urn:xmlns:rhq-configuration'>" +
@@ -321,56 +321,56 @@ public class ConfigurationInstanceDescriptorUtilTest {
"</standaloneConfigurationInstance>";
ConfigurationInstanceDescriptor descriptor = (ConfigurationInstanceDescriptor) CONFIGURATION_INSTANCE_UNMARSHALLER.unmarshal(new StringReader(xml));
-
+
ConfigurationInstanceDescriptorUtil.ConfigurationAndDefinition ccd = ConfigurationInstanceDescriptorUtil.createConfigurationAndDefinition(descriptor);
-
+
ConfigurationDefinition def = ccd.definition;
Configuration conf = ccd.configuration;
-
+
assertEquals(def.getPropertyDefinitions().size(), 1, "Unexpected number of defined properties");
assertEquals(conf.getProperties().size(), 1, "Unexpected number of properties");
PropertyDefinition propDef = def.get("map");
Property prop = conf.get("map");
-
+
assertNotNull(propDef, "Could not find the expected property definition");
assertNotNull(prop, "Could not find the expected property");
-
+
assertEquals(propDef.getClass(), PropertyDefinitionMap.class, "Unexpected type of the property definition");
assertEquals(prop.getClass(), PropertyMap.class, "Unexpecetd type of the property");
-
+
PropertyDefinitionMap mapDef = (PropertyDefinitionMap) propDef;
PropertyMap mapProp = (PropertyMap) prop;
assertEquals(mapDef.getMap().size(), 2, "Unexpected number of map member definitions");
assertEquals(mapProp.getMap().size(), 2, "Unexpected number of map members");
-
+
PropertyDefinition m1Def = mapDef.get("m1");
PropertyDefinition m2Def = mapDef.get("m2");
Property m1Prop = mapProp.get("m1");
Property m2Prop = mapProp.get("m2");
-
+
assertEquals(m1Def.getClass(), PropertyDefinitionSimple.class);
assertEquals(m2Def.getClass(), PropertyDefinitionSimple.class);
assertEquals(m1Prop.getClass(), PropertySimple.class);
assertEquals(m2Prop.getClass(), PropertySimple.class);
-
+
PropertyDefinitionSimple m1SimpleDef = (PropertyDefinitionSimple) m1Def;
PropertyDefinitionSimple m2SimpleDef = (PropertyDefinitionSimple) m2Def;
PropertySimple m1SimpleProp = (PropertySimple) m1Prop;
PropertySimple m2SimpleProp = (PropertySimple) m2Prop;
-
+
assertEquals(m1SimpleDef.getName(), "m1");
assertEquals(m2SimpleDef.getName(), "m2");
assertEquals(m1SimpleDef.getType(), PropertySimpleType.INTEGER);
assertEquals(m2SimpleDef.getType(), PropertySimpleType.STRING);
-
+
assertEquals(m1SimpleProp.getName(), "m1");
assertEquals(m2SimpleProp.getName(), "m2");
assertEquals(m1SimpleProp.getIntegerValue(), Integer.valueOf(1));
assertEquals(m2SimpleProp.getStringValue(), "v");
}
-
+
public void testReverseListOfMapsConversion() throws Exception {
String xml = "" +
"<standaloneConfigurationInstance xmlns:ci='urn:xmlns:rhq-configuration-instance' xmlns:c='urn:xmlns:rhq-configuration'>" +
@@ -393,41 +393,41 @@ public class ConfigurationInstanceDescriptorUtilTest {
"</standaloneConfigurationInstance>";
ConfigurationInstanceDescriptor descriptor = (ConfigurationInstanceDescriptor) CONFIGURATION_INSTANCE_UNMARSHALLER.unmarshal(new StringReader(xml));
-
+
ConfigurationInstanceDescriptorUtil.ConfigurationAndDefinition ccd = ConfigurationInstanceDescriptorUtil.createConfigurationAndDefinition(descriptor);
-
+
ConfigurationDefinition def = ccd.definition;
Configuration conf = ccd.configuration;
-
+
assertEquals(def.getPropertyDefinitions().size(), 1, "Unexpected number of defined properties");
- assertEquals(conf.getProperties().size(), 1, "Unexpected number of properties");
-
+ assertEquals(conf.getProperties().size(), 1, "Unexpected number of properties");
+
PropertyDefinitionList listDef = (PropertyDefinitionList) def.get("list");
PropertyList listProp = (PropertyList) conf.get("list");
-
+
PropertyDefinitionMap mapDef = (PropertyDefinitionMap) listDef.getMemberDefinition();
PropertyDefinitionSimple m1Def = (PropertyDefinitionSimple) mapDef.get("m1");
PropertyDefinitionSimple m2Def = (PropertyDefinitionSimple) mapDef.get("m2");
-
+
assertEquals(mapDef.getName(), "map");
assertEquals(m1Def.getType(), PropertySimpleType.INTEGER);
assertEquals(m2Def.getType(), PropertySimpleType.STRING);
-
+
assertEquals(listProp.getList().size(), 2, "Unexpected number of maps in the list");
-
+
PropertyMap firstMapValue = (PropertyMap) listProp.getList().get(0);
PropertyMap secondMapValue = (PropertyMap) listProp.getList().get(1);
-
+
assertEquals(firstMapValue.getName(), "map");
assertEquals(secondMapValue.getName(), "map");
-
+
assertEquals(firstMapValue.getSimpleValue("m1", null), "1", "Unexpected value of m1 property in the first map.");
assertEquals(firstMapValue.getSimpleValue("m2", null), "m1", "Unexpected value of m2 property in the first map.");
-
+
assertEquals(secondMapValue.getSimpleValue("m1", null), "2", "Unexpected value of m1 property in the second map.");
assertEquals(secondMapValue.getSimpleValue("m2", null), "m2", "Unexpected value of m2 property in the second map.");
}
-
+
private static void logInstance(String message, ConfigurationInstanceDescriptor instance) throws JAXBException,
IOException {
StringWriter wrt = new StringWriter();
commit d8c0cedf853a3ffd1bfc9479ca78be288739a52f
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Mon Dec 16 19:23:37 2013 +0100
[BZ 970181] - RHQ doesn't work after restart with open GUI in web browser. - if the server restarts at the background, the session id is lost on the server therefore we can't allow the logged user to continue sending the requests without a new AuthN. It would be a security risk to allow it. Now, if the server restarts the UI requires the new log in (the login form is displayed).
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/util/rpc/TrackingRequestCallback.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/util/rpc/TrackingRequestCallback.java
index 07893f6..b443c1a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/util/rpc/TrackingRequestCallback.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/util/rpc/TrackingRequestCallback.java
@@ -23,6 +23,7 @@ import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.Response;
import org.rhq.coregui.client.CoreGUI;
+import org.rhq.coregui.client.LoginView;
import org.rhq.coregui.client.UserSessionManager;
import org.rhq.coregui.client.util.Log;
@@ -86,6 +87,11 @@ public class TrackingRequestCallback implements RequestCallback {
switch (statusCode) {
case STATUS_CODE_OK:
+ if (response != null && response.getText() != null && response.getText().isEmpty()
+ && !LoginView.isLoginShowing()) { // this happen when the RHQ server was restarted
+ new LoginView().showLoginDialog();
+ break;
+ }
RPCTracker.getInstance().succeedCall(this);
callback.onResponseReceived(request, response);
break;
commit b6206b7b938ea3c34f9a01f037f3a711c3cf09da
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Fri Dec 13 15:51:56 2013 -0800
[BZ 1034512] Update Group Metric Graphs to be more like new Resource Metrics Graphs
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/D3GroupGraphListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/D3GroupGraphListView.java
index d0b56a7..f6805e2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/D3GroupGraphListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/D3GroupGraphListView.java
@@ -189,6 +189,7 @@ public final class D3GroupGraphListView extends AbstractD3GraphListView implemen
private void buildIndividualGraph(MeasurementDefinition measurementDefinition,
List<MeasurementDataNumericHighLowComposite> data) {
+ Log.debug("\n***** D3GroupGraphListView.MD: "+measurementDefinition);
MetricGraphData metricGraphData = MetricGraphData.createForResourceGroup(resourceGroup.getId(),
resourceGroup.getName(), measurementDefinition, data);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 9ddbb77..8394217 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -63,6 +63,7 @@ import org.rhq.coregui.client.inventory.groups.detail.configuration.HistoryGroup
import org.rhq.coregui.client.inventory.groups.detail.inventory.GroupPluginConfigurationEditView;
import org.rhq.coregui.client.inventory.groups.detail.inventory.HistoryGroupPluginConfigurationView;
import org.rhq.coregui.client.inventory.groups.detail.inventory.MembersView;
+import org.rhq.coregui.client.inventory.groups.detail.monitoring.metric.MetricsGroupView;
import org.rhq.coregui.client.inventory.groups.detail.monitoring.schedules.ResourceGroupSchedulesView;
import org.rhq.coregui.client.inventory.groups.detail.monitoring.table.GroupMonitoringTablesView;
import org.rhq.coregui.client.inventory.groups.detail.monitoring.traits.TraitsView;
@@ -332,7 +333,7 @@ public class ResourceGroupDetailView extends
viewFactory = (!showOnPage) ? null : new ViewFactory() {
@Override
public Canvas createView() {
- return createD3GraphListView();
+ return MetricsGroupView.create(groupComposite.getResourceGroup());
}
};
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java
new file mode 100644
index 0000000..89d4f67
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java
@@ -0,0 +1,408 @@
+/*
+ * 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.coregui.client.inventory.groups.detail.monitoring.metric;
+
+import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.METRIC_DEF_ID;
+import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.RESOURCE_GROUP_ID;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+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.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.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 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.measurement.composite.MeasurementDataNumericHighLowComposite;
+import org.rhq.core.domain.resource.group.GroupCategory;
+import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.coregui.client.CoreGUI;
+import org.rhq.coregui.client.components.table.Table;
+import org.rhq.coregui.client.dashboard.portlets.inventory.groups.graph.ResourceGroupD3GraphPortlet;
+import org.rhq.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.coregui.client.inventory.common.AbstractD3GraphListView;
+import org.rhq.coregui.client.inventory.common.graph.CustomDateRangeState;
+import org.rhq.coregui.client.inventory.common.graph.MetricGraphData;
+import org.rhq.coregui.client.inventory.common.graph.Refreshable;
+import org.rhq.coregui.client.inventory.common.graph.graphtype.StackedBarMetricGraphImpl;
+import org.rhq.coregui.client.inventory.resource.detail.monitoring.MetricD3Graph;
+import org.rhq.coregui.client.util.BrowserUtility;
+import org.rhq.coregui.client.util.Log;
+import org.rhq.coregui.client.util.message.Message;
+
+/**
+ * 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 MetricsGroupTableView extends Table<MetricsGroupViewDataSource> implements Refreshable {
+
+ private final ResourceGroup resourceGroup;
+ private final AbstractD3GraphListView abstractD3GraphListView;
+ private ToolStrip toolStrip;
+ private SelectItem dashboardSelectItem;
+ private Dashboard selectedDashboard;
+ private IButton addToDashboardButton;
+ private LinkedHashMap<String, String> dashboardMenuMap;
+ private LinkedHashMap<Integer, Dashboard> dashboardMap;
+ private Set<Integer> expandedRows;
+ private MetricsTableListGrid metricsTableListGrid;
+ private int selectedMetricDefinitionId;
+
+ public MetricsGroupTableView(ResourceGroup resourceGroup, AbstractD3GraphListView abstractD3GraphListView,
+ Set<Integer> expandedRows) {
+ super();
+ this.resourceGroup = resourceGroup;
+ this.abstractD3GraphListView = abstractD3GraphListView;
+ dashboardMenuMap = new LinkedHashMap<String, String>();
+ dashboardMap = new LinkedHashMap<Integer, Dashboard>();
+ setDataSource(new MetricsGroupViewDataSource(resourceGroup));
+ this.expandedRows = expandedRows;
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ }
+
+ /**
+ * 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, resourceGroup);
+ metricsTableListGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
+ @Override
+ public void onSelectionChanged(SelectionEvent selectionEvent) {
+ if (resourceGroup.getGroupCategory() == GroupCategory.COMPATIBLE) {
+ addToDashboardButton.enable();
+ ListGridRecord selectedRecord = selectionEvent.getSelectedRecord();
+ if (null != selectedRecord) {
+ selectedMetricDefinitionId = selectedRecord.getAttributeAsInt(METRIC_DEF_ID.getValue());
+ }
+ }
+ }
+ });
+
+ if (null == toolStrip) {
+ toolStrip = createToolstrip();
+ }
+ addExtraWidget(toolStrip, false);
+ addToDashboardButton.disable();
+ return metricsTableListGrid;
+ }
+
+ protected void configureTable() {
+ ArrayList<ListGridField> fields = getDataSource().getListGridFields();
+ setListGridFields(fields.toArray(new ListGridField[0]));
+ }
+
+ private ToolStrip createToolstrip() {
+ toolStrip = new ToolStrip();
+ toolStrip.setWidth(300);
+ toolStrip.setMembersMargin(15);
+ toolStrip.setPadding(5);
+ toolStrip.addSpacer(10);
+ addToDashboardButton = new IButton(MSG.chart_metrics_add_to_dashboard_button());
+ addToDashboardButton.setWidth(80);
+ dashboardSelectItem = new SelectItem();
+ dashboardSelectItem.setTitle(MSG.chart_metrics_add_to_dashboard_label());
+ dashboardSelectItem.setWidth(240);
+ dashboardSelectItem.setWrapTitle(false);
+ populateDashboardMenu();
+ toolStrip.addFormItem(dashboardSelectItem);
+ toolStrip.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) {
+ for (MeasurementDefinition measurementDefinition : resourceGroup.getResourceType()
+ .getMetricDefinitions()) {
+ if (measurementDefinition.getId() == selectedMetricDefinitionId) {
+ Log.debug("Add to Dashboard -- Storing: " + measurementDefinition.getDisplayName() + " in "
+ + selectedDashboard.getName());
+
+ storeDashboardMetric(selectedDashboard, resourceGroup.getId(), measurementDefinition);
+ break;
+ }
+ }
+ }
+ });
+ return toolStrip;
+ }
+
+ @Override
+ /**
+ * Redraw Graphs in this context means to refresh the table and redraw open graphs.
+ */
+ public void refreshData() {
+ new Timer() {
+ @Override
+ public void run() {
+ metricsTableListGrid.expandOpenedRows();
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+
+ }
+
+ @Override
+ public void refresh() {
+ super.refresh(false);
+ metricsTableListGrid.expandOpenedRows();
+ }
+
+ private 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) {
+ if (dashboards.size() > 0) {
+ for (final Dashboard dashboard : dashboards) {
+ dashboardMenuMap.put(String.valueOf(dashboard.getId()), dashboard.getName());
+ dashboardMap.put(dashboard.getId(), dashboard);
+ }
+ selectedDashboard = dashboards.get(0);
+ dashboardSelectItem.setValueMap(dashboardMenuMap);
+ dashboardSelectItem.setValue(selectedDashboard.getId());
+ }
+ }
+ });
+ }
+
+ private void storeDashboardMetric(Dashboard dashboard, int resourceGroupId, MeasurementDefinition definition) {
+
+ DashboardPortlet dashboardPortlet = new DashboardPortlet(MSG.view_tree_common_contextMenu_groupGraph(),
+ ResourceGroupD3GraphPortlet.KEY, 260);
+ dashboardPortlet.getConfiguration().put(
+ new PropertySimple(ResourceGroupD3GraphPortlet.CFG_RESOURCE_GROUP_ID, resourceGroupId));
+ dashboardPortlet.getConfiguration().put(
+ new PropertySimple(ResourceGroupD3GraphPortlet.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) {
+ String msg = MSG.view_tree_common_contextMenu_saveChartToDashboardSuccessful(result.getName());
+ CoreGUI.getMessageCenter().notify(new Message(msg, Message.Severity.Info));
+ }
+ });
+ }
+
+ public class MetricsTableListGrid extends ListGrid {
+
+ private static final int TREEVIEW_DETAIL_CHART_HEIGHT = 205;
+ private static final int NUM_METRIC_POINTS = 60;
+ final MetricsGroupTableView metricsTableView;
+ private ResourceGroup group;
+
+ public MetricsTableListGrid(final MetricsGroupTableView metricsTableView, final ResourceGroup group) {
+ super();
+ this.group = group;
+ this.metricsTableView = metricsTableView;
+ setCanExpandRecords(true);
+ setSelectionType(SelectionStyle.SINGLE);
+ setCanExpandMultipleRecords(true);
+ setExpansionMode(ExpansionMode.DETAIL_FIELD);
+
+ addRecordExpandHandler(new RecordExpandHandler() {
+ @Override
+ public void onRecordExpand(RecordExpandEvent recordExpandEvent) {
+ metricsTableView.expandedRows.add(recordExpandEvent.getRecord().getAttributeAsInt(
+ METRIC_DEF_ID.getValue()));
+ refreshData();
+ }
+
+ });
+ addRecordCollapseHandler(new RecordCollapseHandler() {
+ @Override
+ public void onRecordCollapse(RecordCollapseEvent recordCollapseEvent) {
+ metricsTableView.expandedRows.remove(recordCollapseEvent.getRecord().getAttributeAsInt(
+ METRIC_DEF_ID.getValue()));
+ refresh();
+ new Timer() {
+ @Override
+ public void run() {
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+ }
+ });
+ addSortChangedHandler(new SortChangedHandler() {
+ @Override
+ public void onSortChanged(SortEvent sortEvent) {
+ refreshData();
+ }
+ });
+
+ addDataArrivedHandler(new DataArrivedHandler() {
+ @Override
+ public void onDataArrived(DataArrivedEvent dataArrivedEvent) {
+ expandOpenedRows();
+ }
+ });
+
+ }
+
+ public void expandOpenedRows() {
+ int startRow = 0;
+ int endRow = this.getRecords().length;
+ for (int i = startRow; i < endRow; i++) {
+ ListGridRecord listGridRecord = getRecord(i);
+ if (null != listGridRecord) {
+ int metricDefinitionId = listGridRecord.getAttributeAsInt(METRIC_DEF_ID.getValue());
+ if (null != metricsTableView && null != expandedRows
+ && metricsTableView.expandedRows.contains(metricDefinitionId)) {
+ expandRecord(listGridRecord);
+ }
+ }
+ }
+ }
+
+ @Override
+ /**
+ * If you expand a grid row then create a graph.
+ */
+ protected Canvas getExpansionComponent(final ListGridRecord record) {
+ final Integer definitionId = record.getAttributeAsInt(METRIC_DEF_ID.getValue());
+ final Integer resourceGroupId = record.getAttributeAsInt(RESOURCE_GROUP_ID.getValue());
+ VLayout vLayout = new VLayout();
+ vLayout.setPadding(5);
+
+ final String chartId = "rChart-" + resourceGroupId + "-" + 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().findDataForCompatibleGroup(resourceGroupId,
+ definitionArrayIds, CustomDateRangeState.getInstance().getStartTime(),
+ CustomDateRangeState.getInstance().getEndTime(), NUM_METRIC_POINTS,
+ new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.warn("Error retrieving recent metrics charting data for resource group [" + resourceGroupId
+ + "]:" + 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 : group.getResourceType().getMetricDefinitions()) {
+ if (definition.getId() == definitionId) {
+ measurementDefinition = definition;
+ break;
+ }
+ }
+
+ MetricGraphData metricGraphData = MetricGraphData.createForResourceGroup(group.getId(),
+ group.getName(), measurementDefinition, measurementList);
+ 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();
+ new Timer() {
+ @Override
+ public void run() {
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+ }
+ }.schedule(150);
+
+ } else {
+ Log.warn("No chart data retrieving for resource group [" + resourceGroupId + "-"
+ + definitionId + "]");
+ }
+ }
+ });
+
+ return vLayout;
+ }
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupView.java
new file mode 100644
index 0000000..1e07e7a
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupView.java
@@ -0,0 +1,193 @@
+/*
+ * 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.coregui.client.inventory.groups.detail.monitoring.metric;
+
+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.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.group.ResourceGroup;
+import org.rhq.coregui.client.CoreGUI;
+import org.rhq.coregui.client.IconEnum;
+import org.rhq.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.coregui.client.inventory.common.AbstractD3GraphListView;
+import org.rhq.coregui.client.inventory.common.detail.AbstractTwoLevelTabSetView;
+import org.rhq.coregui.client.inventory.common.graph.CustomDateRangeState;
+import org.rhq.coregui.client.inventory.common.graph.graphtype.AvailabilityOverUnderGraphType;
+import org.rhq.coregui.client.inventory.resource.detail.monitoring.ExpandedRowsMomento;
+import org.rhq.coregui.client.inventory.resource.detail.monitoring.avail.AvailabilityD3GraphView;
+import org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricAvailabilityView;
+import org.rhq.coregui.client.util.BrowserUtility;
+import org.rhq.coregui.client.util.async.CountDownLatch;
+import org.rhq.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 MetricsGroupView extends AbstractD3GraphListView implements
+ AbstractTwoLevelTabSetView.ViewRenderedListener {
+
+ private static final String COLLAPSED_TOOLTIP = MSG.chart_metrics_collapse_tooltip();
+ private static final String EXPANDED_TOOLTIP = MSG.chart_metrics_expand_tooltip();
+
+ private final ResourceGroup resourceGroup;
+ private EnhancedHLayout expandCollapseHLayout;
+ private MetricsGroupTableView metricsTableView;
+ private static Integer lastResourceGroupId = 0;
+
+ /**
+ * Encapsulate the creation logic and not let it leak out into other objects.
+ * Clear the expanded rows set when changing resources as well.
+ * @see ExpandedRowsMomento
+ * @param group
+ * @return MetricsGroupView
+ */
+ public static MetricsGroupView create(ResourceGroup group ){
+
+ boolean isDifferentResource = (group.getId() != lastResourceGroupId);
+
+ if(isDifferentResource){
+ ExpandedRowsMomento.getInstance().clear();
+ }
+
+ return new MetricsGroupView(group, ExpandedRowsMomento.getInstance().getExpandedRows());
+
+ }
+
+ private MetricsGroupView(ResourceGroup resourceGroup, Set<Integer> expandedRows) {
+ super();
+ setOverflow(Overflow.AUTO);
+ setWidth100();
+ setHeight100();
+ this.resourceGroup = resourceGroup;
+ metricsTableView = new MetricsGroupTableView(resourceGroup, this, expandedRows);
+
+ final MetricAvailabilityView availabilityDetails = new MetricAvailabilityView(resourceGroup.getId());
+ availabilityDetails.hide();
+
+ metricsTableView.setHeight100();
+
+ availabilityGraph = AvailabilityD3GraphView.create( new AvailabilityOverUnderGraphType(resourceGroup.getId()));
+
+ expandCollapseHLayout = new EnhancedHLayout();
+ //add expand/collapse icon
+ final Img 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();
+
+ }
+ drawAvailabilityGraphAndSparklines();
+ }
+ });
+ expandCollapseHLayout.addMember(expandCollapseArrow);
+ addAvailabilityGraph();
+
+ addMember(buttonBarDateTimeRangeEditor);
+ addMember(expandCollapseHLayout);
+ addMember(availabilityDetails);
+ addMember(metricsTableView);
+ lastResourceGroupId = resourceGroup.getId();
+ }
+
+
+ private void addAvailabilityGraph() {
+ expandCollapseHLayout.removeMember(availabilityGraph);
+ availabilityGraph.destroy();
+
+ availabilityGraph = AvailabilityD3GraphView.create(new AvailabilityOverUnderGraphType(resourceGroup.getId()));
+
+ expandCollapseHLayout.addMember(availabilityGraph);
+
+ queryAvailability(EntityContext.forGroup(resourceGroup.getId()), CustomDateRangeState.getInstance().getStartTime(),
+ CustomDateRangeState.getInstance().getEndTime(), null);
+ }
+
+
+ @Override
+ protected void queryAvailability(final EntityContext context, Long startTime, Long endTime, CountDownLatch notUsed) {
+
+ // now return the availability
+ GWTServiceLookup.getAvailabilityService().getAvailabilitiesForResource(context.getGroupId(), 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) {
+ availabilityGraph.setAvailabilityList(availList);
+ new Timer() {
+ @Override
+ public void run() {
+ buttonBarDateTimeRangeEditor.updateTimeRangeToNow();
+ availabilityGraph.drawJsniChart();
+
+ }
+ }.schedule(150);
+ }
+ });
+ }
+
+ private void drawAvailabilityGraphAndSparklines() {
+ new Timer() {
+ @Override
+ public void run() {
+ availabilityGraph.drawJsniChart();
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+ }
+
+ @Override
+ public void refreshData() {
+ addAvailabilityGraph();
+ metricsTableView.refresh();
+ }
+
+ @Override
+ public void onViewRendered() {
+ // refresh the graphs on subtab nav because we are a cached view not new
+ refreshData();
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupViewDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupViewDataSource.java
new file mode 100644
index 0000000..a5f1353
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupViewDataSource.java
@@ -0,0 +1,314 @@
+/*
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.coregui.client.inventory.groups.detail.monitoring.metric;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+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.MeasurementDefinition;
+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.group.ResourceGroup;
+import org.rhq.coregui.client.CoreGUI;
+import org.rhq.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.coregui.client.inventory.common.graph.CustomDateRangeState;
+import org.rhq.coregui.client.util.BrowserUtility;
+import org.rhq.coregui.client.util.Log;
+import org.rhq.coregui.client.util.MeasurementUtility;
+import org.rhq.coregui.client.util.RPCDataSource;
+import org.rhq.coregui.client.util.async.Command;
+import org.rhq.coregui.client.util.async.CountDownLatch;
+
+import static org.rhq.core.domain.measurement.DataType.COMPLEX;
+import static org.rhq.core.domain.measurement.DataType.MEASUREMENT;
+import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.*;
+
+/**
+ * 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 MetricsGroupViewDataSource extends RPCDataSource<MetricDisplaySummary, Criteria> {
+
+ private static final int NUMBER_OF_METRIC_POINTS = 60;
+
+ private final ResourceGroup resourceGroup;
+ private List<MetricDisplaySummary> metricDisplaySummaries;
+ private List<List<MeasurementDataNumericHighLowComposite>> metricsDataList;
+ private int[] definitionArrayIds;
+
+ public MetricsGroupViewDataSource(ResourceGroup resourceGroup) {
+ this.resourceGroup = resourceGroup;
+ }
+
+ /**
+ * 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(SPARKLINE.getValue(), 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_" + resourceGroup.getId() + "-"
+ + record.getAttributeAsInt(METRIC_DEF_ID.getValue()) + "' class='dynamicsparkline' width='70' "
+ + "values='" + record.getAttribute(SPARKLINE.getValue()) + "'></span>";
+ return contents;
+
+ }
+ });
+
+ sparklineField.setWidth(80);
+ fields.add(sparklineField);
+
+ ListGridField nameField = new ListGridField(METRIC_LABEL.getValue(), METRIC_LABEL.getLabel());
+ nameField.setWidth("30%");
+ fields.add(nameField);
+
+ ListGridField minField = new ListGridField(MIN_VALUE.getValue(), MIN_VALUE.getLabel());
+ minField.setWidth("15%");
+ fields.add(minField);
+
+ ListGridField maxField = new ListGridField(MAX_VALUE.getValue(), MAX_VALUE.getLabel());
+ maxField.setWidth("15%");
+ fields.add(maxField);
+
+ ListGridField avgField = new ListGridField(AVG_VALUE.getValue(), AVG_VALUE.getLabel());
+ avgField.setWidth("15%");
+ fields.add(avgField);
+
+ ListGridField alertsField = new ListGridField(ALERT_COUNT.getValue(), ALERT_COUNT.getLabel());
+ 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(SPARKLINE.getValue(), getCsvMetricsForSparkline(from.getDefinitionId()));
+ record.setAttribute(METRIC_LABEL.getValue(), from.getLabel());
+ record.setAttribute(ALERT_COUNT.getValue(), String.valueOf(from.getAlertCount()));
+ record.setAttribute(MIN_VALUE.getValue(), getMetricStringValue(from.getMinMetric()));
+ record.setAttribute(MAX_VALUE.getValue(), getMetricStringValue(from.getMaxMetric()));
+ record.setAttribute(AVG_VALUE.getValue(), getMetricStringValue(from.getAvgMetric()));
+ record.setAttribute(METRIC_DEF_ID.getValue(), from.getDefinitionId());
+ record.setAttribute(METRIC_SCHEDULE_ID.getValue(), from.getScheduleId());
+ record.setAttribute(METRIC_UNITS.getValue(), from.getUnits());
+ record.setAttribute(METRIC_NAME.getValue(), from.getMetricName());
+ record.setAttribute(RESOURCE_GROUP_ID.getValue(), resourceGroup.getId());
+ return record;
+ }
+
+ private String getCsvMetricsForSparkline(int definitionId) {
+ StringBuilder sb = new StringBuilder();
+ List<MeasurementDataNumericHighLowComposite> selectedMetricsList = getMeasurementsForMeasurementDefId(definitionId);
+
+ for (MeasurementDataNumericHighLowComposite measurementData : selectedMetricsList) {
+ if (!Double.isNaN(measurementData.getValue())) {
+ sb.append((int) measurementData.getValue());
+ sb.append(",");
+ }
+ }
+
+ if (sb.toString().endsWith(",")) {
+ sb.setLength(sb.length() - 1);
+ }
+ // handle the case where we have just installed the server so not much history
+ // and our date range is set such that only one value returns which the
+ // sparkline graph will not plot anything, so we need at least 2 values
+ if (!sb.toString().contains(",")) {
+ // append another value just so we have 2 values and it will graph
+ return "0," + sb.toString();
+ }
+
+ return sb.toString();
+ }
+
+ private 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) {
+
+ // This latch is the last thing that gets executed after we have executed the
+ // 1 query
+ final CountDownLatch countDownLatch = CountDownLatch.create(1, new Command() {
+
+ @Override
+ public void execute() {
+
+ // NOTE: this runs after the queryMetricDisplaySummaries is complete
+ queryGroupMetrics(resourceGroup, request, response);
+ }
+ });
+
+ organizeMeasurementDefinitionOrder(resourceGroup);
+ queryMetricDisplaySummaries(definitionArrayIds, CustomDateRangeState.getInstance().getStartTime(),
+ CustomDateRangeState.getInstance().getEndTime(), countDownLatch);
+
+ }
+
+ private void queryGroupMetrics(final ResourceGroup resourceGroup, final DSRequest request, final DSResponse response) {
+
+ GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroup(resourceGroup.getId(),
+ definitionArrayIds, CustomDateRangeState.getInstance().getStartTime(),
+ CustomDateRangeState.getInstance().getEndTime(), 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 [" + resourceGroup.getId()
+ + "]:" + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(List<List<MeasurementDataNumericHighLowComposite>> measurementDataList) {
+ if (null != measurementDataList && !measurementDataList.isEmpty()) {
+ metricsDataList = measurementDataList;
+ response.setData(buildRecords(metricDisplaySummaries));
+ processResponse(request.getRequestId(), response);
+ new Timer() {
+ @Override
+ public void run() {
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+ }
+ }
+ });
+
+ }
+
+ private void organizeMeasurementDefinitionOrder(ResourceGroup resourceGroup) {
+ Set<MeasurementDefinition> definitions = getMetricDefinitions(resourceGroup);
+
+ //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();
+ }
+ }
+
+ private void queryMetricDisplaySummaries(int[] measurementDefIds, Long startTime, Long endTime,
+ final CountDownLatch countDownLatch) {
+ GWTServiceLookup.getMeasurementChartsService().getMetricDisplaySummariesForCompatibleGroup(
+ resourceGroup.getId(), measurementDefIds, startTime, endTime, false,
+ 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();
+ }
+ }
+
+ );
+ }
+
+ private void setMetricDisplaySummaries(List<MetricDisplaySummary> metricDisplaySummaries) {
+ this.metricDisplaySummaries = metricDisplaySummaries;
+ }
+
+ private Set<MeasurementDefinition> getMetricDefinitions(ResourceGroup resourceGroup) {
+ Set<MeasurementDefinition> definitions = new HashSet<MeasurementDefinition>();
+ for (MeasurementDefinition measurementDefinition : resourceGroup.getResourceType().getMetricDefinitions()) {
+ if (measurementDefinition.getDataType() == MEASUREMENT || measurementDefinition.getDataType() == COMPLEX) {
+ definitions.add(measurementDefinition);
+ }
+ }
+ return definitions;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricAvailabilityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricAvailabilityView.java
new file mode 100644
index 0000000..4b542c9
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricAvailabilityView.java
@@ -0,0 +1,223 @@
+/*
+ * 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.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.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementUnits;
+import org.rhq.core.domain.resource.composite.ResourceAvailabilitySummary;
+import org.rhq.coregui.client.CoreGUI;
+import org.rhq.coregui.client.components.table.TimestampCellFormatter;
+import org.rhq.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.coregui.client.util.MeasurementConverterClient;
+import org.rhq.coregui.client.util.enhanced.EnhancedVLayout;
+
+/**
+ * This shows the availability history for a resource.
+ *
+ * @author Jay Shaughnessy
+ * @author John Mazzitelli
+ * @author Mike Thompson
+ */
+public class MetricAvailabilityView extends EnhancedVLayout {
+
+ private int resourceId;
+ 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 MetricAvailabilityView(int resourceId) {
+ super();
+
+ this.resourceId = resourceId;
+
+ 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.common_title_availability());
+ availField.setWrapTitle(false);
+ prepareTooltip(availField, MSG.view_resource_monitor_availability_tooltip_up());
+
+ 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.common_status_avail_down_lower());
+ downField.setWrapTitle(false);
+ prepareTooltip(downField, MSG.view_resource_monitor_availability_tooltip_down());
+
+ 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.common_status_avail_disabled_lower());
+ disabledField.setWrapTitle(false);
+ prepareTooltip(disabledField, MSG.view_resource_monitor_availability_tooltip_disabled());
+
+ 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(resourceId,
+ new AsyncCallback<ResourceAvailabilitySummary>() {
+
+ @Override
+ public void onSuccess(ResourceAvailabilitySummary result) {
+
+ currentField.setValue(MSG.view_resource_monitor_availability_currentStatus_value(
+ getAvailabilityTypeMessage(result.getCurrent()),
+ 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 String getAvailabilityTypeMessage(AvailabilityType availabilityType) {
+ switch (availabilityType) {
+ case UP:
+ return MSG.common_status_avail_up();
+ case DOWN:
+ return MSG.common_status_avail_down();
+ case DISABLED:
+ return MSG.common_status_avail_disabled();
+ case UNKNOWN:
+ default:
+ return MSG.common_status_avail_unknown();
+ }
+ }
+
+ 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/coregui/client/inventory/resource/detail/monitoring/table/MetricsGridFieldName.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsGridFieldName.java
new file mode 100644
index 0000000..f912dee
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsGridFieldName.java
@@ -0,0 +1,63 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2014 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.coregui.client.inventory.resource.detail.monitoring.table;
+
+import static org.rhq.core.domain.measurement.ui.MetricDisplayConstants.AVERAGE_KEY;
+import static org.rhq.core.domain.measurement.ui.MetricDisplayConstants.MAX_KEY;
+import static org.rhq.core.domain.measurement.ui.MetricDisplayConstants.MIN_KEY;
+
+import org.rhq.coregui.client.CoreGUI;
+
+/**
+ * Typesafe field names used in consolidated metrics screen grids for Resource and ResourceGroup.
+ * Also associates the proper label with the value.
+ *
+ * @author Mike Thompson
+ */
+@SuppressWarnings("GwtInconsistentSerializableClass")
+public enum MetricsGridFieldName {
+
+ SPARKLINE("sparkline"), METRIC_LABEL("label", CoreGUI.getMessages().common_title_name()), ALERT_COUNT("alertCount",
+ CoreGUI.getMessages().common_title_alerts()), MAX_VALUE(MAX_KEY, CoreGUI.getMessages()
+ .common_title_monitor_maximum()), MIN_VALUE(MIN_KEY, CoreGUI.getMessages().common_title_monitor_minimum()), AVG_VALUE(
+ AVERAGE_KEY, CoreGUI.getMessages().common_title_monitor_average()), METRIC_DEF_ID("defId"), METRIC_SCHEDULE_ID(
+ "schedId"), METRIC_UNITS("units"), METRIC_NAME("name"), RESOURCE_GROUP_ID("resourceGroupId"),
+ RESOURCE_ID("resourceId"), LIVE_VALUE("live", CoreGUI.getMessages().view_resource_monitor_table_live());
+
+ private final String value;
+ private final String label;
+
+ MetricsGridFieldName(String value, String label) {
+ this.value = value;
+ this.label = label;
+ }
+
+ MetricsGridFieldName(String value) {
+ this.value = value;
+ this.label = "";
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java
index efba122..7e84c3d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java
@@ -41,7 +41,6 @@ import org.rhq.coregui.client.inventory.common.graph.graphtype.AvailabilityOverU
import org.rhq.coregui.client.inventory.resource.detail.monitoring.ExpandedRowsMomento;
import org.rhq.coregui.client.inventory.resource.detail.monitoring.avail.AvailabilityD3GraphView;
import org.rhq.coregui.client.util.BrowserUtility;
-import org.rhq.coregui.client.util.Log;
import org.rhq.coregui.client.util.async.CountDownLatch;
import org.rhq.coregui.client.util.enhanced.EnhancedHLayout;
@@ -87,7 +86,7 @@ public class MetricsResourceView extends AbstractD3GraphListView implements
this.resource = resource;
metricsTableView = new MetricsTableView(resource, this, expandedRows);
- final ResourceMetricAvailabilityView availabilityDetails = new ResourceMetricAvailabilityView(resource);
+ final MetricAvailabilityView availabilityDetails = new MetricAvailabilityView(resource.getId());
availabilityDetails.hide();
metricsTableView.setHeight100();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
index 63a6619..6f0f7f7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
@@ -74,6 +74,8 @@ import org.rhq.coregui.client.util.BrowserUtility;
import org.rhq.coregui.client.util.Log;
import org.rhq.coregui.client.util.message.Message;
+import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.*;
+
/**
* Views a resource's metrics in a tabular view with sparkline graph and optional detailed d3 graph.
*
@@ -125,10 +127,8 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
addToDashboardButton.enable();
ListGridRecord selectedRecord = selectionEvent.getSelectedRecord();
if (null != selectedRecord) {
- //Log.debug("Selected Metric Label: "
- // + selectedRecord.getAttribute(MetricsViewDataSource.FIELD_METRIC_LABEL));
- selectedMetricDefinitionId = selectedRecord
- .getAttributeAsInt(MetricsViewDataSource.FIELD_METRIC_DEF_ID);
+ selectedMetricDefinitionId = selectedRecord.getAttributeAsInt(METRIC_DEF_ID
+ .getValue());
}
}
});
@@ -176,7 +176,7 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
if (measurementDefinition.getId() == selectedMetricDefinitionId) {
Log.debug("Add to Dashboard -- Storing: " + measurementDefinition.getDisplayName() + " in "
+ selectedDashboard.getName());
- storeDashboardMetric(selectedDashboard, resource, measurementDefinition);
+ storeDashboardMetric(selectedDashboard, resource.getId(), measurementDefinition);
break;
}
}
@@ -233,11 +233,11 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
});
}
- private void storeDashboardMetric(Dashboard dashboard, Resource resource, MeasurementDefinition definition) {
+ private void storeDashboardMetric(Dashboard dashboard, int resourceId, MeasurementDefinition definition) {
DashboardPortlet dashboardPortlet = new DashboardPortlet(MSG.view_tree_common_contextMenu_resourceGraph(),
- ResourceD3GraphPortlet.KEY, 200);
+ ResourceD3GraphPortlet.KEY, 260);
dashboardPortlet.getConfiguration().put(
- new PropertySimple(ResourceD3GraphPortlet.CFG_RESOURCE_ID, resource.getId()));
+ new PropertySimple(ResourceD3GraphPortlet.CFG_RESOURCE_ID, resourceId));
dashboardPortlet.getConfiguration().put(
new PropertySimple(ResourceD3GraphPortlet.CFG_DEFINITION_ID, definition.getId()));
@@ -278,7 +278,7 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
@Override
public void onRecordExpand(RecordExpandEvent recordExpandEvent) {
metricsTableView.expandedRows.add(recordExpandEvent.getRecord().getAttributeAsInt(
- MetricsViewDataSource.FIELD_METRIC_DEF_ID));
+ METRIC_DEF_ID.getValue()));
refreshData();
}
@@ -287,7 +287,7 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
@Override
public void onRecordCollapse(RecordCollapseEvent recordCollapseEvent) {
metricsTableView.expandedRows.remove(recordCollapseEvent.getRecord().getAttributeAsInt(
- MetricsViewDataSource.FIELD_METRIC_DEF_ID));
+ METRIC_DEF_ID.getValue()));
refresh();
new Timer() {
@Override
@@ -321,7 +321,7 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
ListGridRecord listGridRecord = getRecord(i);
if (null != listGridRecord) {
int metricDefinitionId = listGridRecord
- .getAttributeAsInt(MetricsViewDataSource.FIELD_METRIC_DEF_ID);
+ .getAttributeAsInt(METRIC_DEF_ID.getValue());
if (null != metricsTableView && null != expandedRows
&& metricsTableView.expandedRows.contains(metricDefinitionId)) {
expandRecord(listGridRecord);
@@ -330,18 +330,14 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
}
}
- public void expandOpenedRows(Set<Integer> selectedRows) {
- expandedRows = selectedRows;
- expandOpenedRows();
- }
@Override
/**
* If you expand a grid row then create a graph.
*/
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);
+ final Integer definitionId = record.getAttributeAsInt(METRIC_DEF_ID.getValue());
+ final Integer resourceId = record.getAttributeAsInt(RESOURCE_ID.getValue());
VLayout vLayout = new VLayout();
vLayout.setPadding(5);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java
index 4c9c7c1..248eee0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java
@@ -61,6 +61,7 @@ import org.rhq.coregui.client.util.RPCDataSource;
import org.rhq.coregui.client.util.async.Command;
import org.rhq.coregui.client.util.async.CountDownLatch;
import org.rhq.coregui.client.util.preferences.MeasurementUserPreferences;
+import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.*;
/**
* A simple data source to read in metric data summaries for a resource.
@@ -75,19 +76,6 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
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_LIVE_VALUE = "live";
- 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;
@@ -111,7 +99,7 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
public ArrayList<ListGridField> getListGridFields() {
ArrayList<ListGridField> fields = new ArrayList<ListGridField>(7);
- ListGridField sparklineField = new ListGridField(FIELD_SPARKLINE, MSG.chart_metrics_sparkline_header());
+ ListGridField sparklineField = new ListGridField(SPARKLINE.getValue(), MSG.chart_metrics_sparkline_header());
sparklineField.setCellFormatter(new CellFormatter() {
@Override
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
@@ -119,8 +107,8 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
return "";
}
String contents = "<span id='sparkline_" + resource.getId() + "-"
- + record.getAttributeAsInt(FIELD_METRIC_DEF_ID) + "' class='dynamicsparkline' width='70' "
- + "values='" + record.getAttribute(FIELD_SPARKLINE) + "'></span>";
+ + record.getAttributeAsInt(METRIC_DEF_ID.getValue()) + "' class='dynamicsparkline' width='70' "
+ + "values='" + record.getAttribute(SPARKLINE.getValue()) + "'></span>";
return contents;
}
@@ -129,27 +117,27 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
sparklineField.setWidth(80);
fields.add(sparklineField);
- ListGridField nameField = new ListGridField(FIELD_METRIC_LABEL, MSG.common_title_name());
+ ListGridField nameField = new ListGridField(METRIC_LABEL.getValue(), METRIC_LABEL.getLabel());
nameField.setWidth("30%");
fields.add(nameField);
- ListGridField minField = new ListGridField(FIELD_MIN_VALUE, MSG.common_title_monitor_minimum());
+ ListGridField minField = new ListGridField(MIN_VALUE.getValue(), MIN_VALUE.getLabel());
minField.setWidth("15%");
fields.add(minField);
- ListGridField maxField = new ListGridField(FIELD_MAX_VALUE, MSG.common_title_monitor_maximum());
+ ListGridField maxField = new ListGridField(MAX_VALUE.getValue(), MAX_VALUE.getLabel());
maxField.setWidth("15%");
fields.add(maxField);
- ListGridField avgField = new ListGridField(FIELD_AVG_VALUE, MSG.common_title_monitor_average());
+ ListGridField avgField = new ListGridField(AVG_VALUE.getValue(), AVG_VALUE.getLabel());
avgField.setWidth("15%");
fields.add(avgField);
- ListGridField liveField = new ListGridField(FIELD_LIVE_VALUE, MSG.view_resource_monitor_table_live());
+ ListGridField liveField = new ListGridField(LIVE_VALUE.getValue(), LIVE_VALUE.getLabel());
liveField.setWidth("15%");
fields.add(liveField);
- ListGridField alertsField = new ListGridField(FIELD_ALERT_COUNT, MSG.common_title_alerts());
+ ListGridField alertsField = new ListGridField(ALERT_COUNT.getValue(), ALERT_COUNT.getLabel());
alertsField.setWidth("10%");
fields.add(alertsField);
@@ -170,18 +158,18 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
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_LIVE_VALUE, buildLiveValue(from));
- 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());
+ record.setAttribute(SPARKLINE.getValue(), getCsvMetricsForSparkline(from.getDefinitionId()));
+ record.setAttribute(METRIC_LABEL.getValue(), from.getLabel());
+ record.setAttribute(ALERT_COUNT.getValue(), String.valueOf(from.getAlertCount()));
+ record.setAttribute(MIN_VALUE.getValue(), getMetricStringValue(from.getMinMetric()));
+ record.setAttribute(MAX_VALUE.getValue(), getMetricStringValue(from.getMaxMetric()));
+ record.setAttribute(AVG_VALUE.getValue(), getMetricStringValue(from.getAvgMetric()));
+ record.setAttribute(LIVE_VALUE.getValue(), buildLiveValue(from));
+ record.setAttribute(METRIC_DEF_ID.getValue(), from.getDefinitionId());
+ record.setAttribute(METRIC_SCHEDULE_ID.getValue(), from.getScheduleId());
+ record.setAttribute(METRIC_UNITS.getValue(), from.getUnits());
+ record.setAttribute(METRIC_NAME.getValue(), from.getMetricName());
+ record.setAttribute(RESOURCE_ID.getValue(), resource.getId());
return record;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/ResourceMetricAvailabilityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/ResourceMetricAvailabilityView.java
deleted file mode 100644
index 5919f83..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/ResourceMetricAvailabilityView.java
+++ /dev/null
@@ -1,224 +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.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.AvailabilityType;
-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.coregui.client.CoreGUI;
-import org.rhq.coregui.client.components.table.TimestampCellFormatter;
-import org.rhq.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.coregui.client.util.MeasurementConverterClient;
-import org.rhq.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.common_title_availability());
- availField.setWrapTitle(false);
- prepareTooltip(availField, MSG.view_resource_monitor_availability_tooltip_up());
-
- 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.common_status_avail_down_lower());
- downField.setWrapTitle(false);
- prepareTooltip(downField, MSG.view_resource_monitor_availability_tooltip_down());
-
- 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.common_status_avail_disabled_lower());
- disabledField.setWrapTitle(false);
- prepareTooltip(disabledField, MSG.view_resource_monitor_availability_tooltip_disabled());
-
- 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(
- getAvailabilityTypeMessage(result.getCurrent()),
- 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 String getAvailabilityTypeMessage(AvailabilityType availabilityType) {
- switch (availabilityType) {
- case UP:
- return MSG.common_status_avail_up();
- case DOWN:
- return MSG.common_status_avail_down();
- case DISABLED:
- return MSG.common_status_avail_disabled();
- case UNKNOWN:
- default:
- return MSG.common_status_avail_unknown();
- }
- }
-
- private void prepareTooltip(FormItem item, String tooltip) {
- item.setHoverWidth(400);
- item.setPrompt(tooltip);
- }
-
-}
commit ba14a590a9c7e2d98c9a405087ce0f82da2d84a1
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Dec 13 17:39:57 2013 +0100
[BZ 1042892] Don't use ${} notation for shell variables in CLI scripts.
As of BZ 959603, the files are subject to maven resource filtering and
so it can happen that the build server passes a variable to the build
process that clashes with the variable name defined in the script.
(Yes, this actually happened on our Jenkins server that passed
"-DCLASSPATH=" to the maven process for some reason, which resulted in
wonderful corruption of the rhq-cli.sh script).
diff --git a/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh b/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh
index 112ec66..80f24c5 100755
--- a/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh
+++ b/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh
@@ -3,6 +3,14 @@
#===========================================================================
#
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# IMPORTANT: Avoid enclosing shell variables in braces using the ${XXX}
+# notation. This file is subject to maven resource variable expansion
+# during the build and so it can happen that the build environment
+# could corrupt this file by expanding variables that clash with
+# the names defined herein.
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
# RHQ_CLI_DEBUG - If this is defined, the script will emit debug
# messages. It will also enable debug
# messages to be emitted from the cli itself.
@@ -41,7 +49,7 @@
# to the CLI's defaults, then you will want to
# use RHQ_CLI_ADDITIONAL_JAVA_OPTS instead.
#
-#RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true -Drhq.scripting.modules.root-dir=${RHQ_CLI_MODULES_DIR}"
+#RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true -Drhq.scripting.modules.root-dir=$RHQ_CLI_MODULES_DIR"
# RHQ_CLI_JAVA_ENDORSED_DIRS - Java VM command line option to set the
# endorsed dirs for the CLI's VM. If this
diff --git a/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh b/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh
index 8399b50..b0980e6 100644
--- a/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh
+++ b/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh
@@ -11,6 +11,14 @@
# set via rhq-client-env.sh, which is sourced by this script.
# =============================================================================
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# IMPORTANT: Avoid enclosing shell variables in braces using the ${XXX}
+# notation. This file is subject to maven resource variable expansion
+# during the build and so it can happen that the build environment
+# could corrupt this file by expanding variables that clash with
+# the names defined herein.
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
# ----------------------------------------------------------------------
# Subroutine that simply dumps a message iff debug mode is enabled
# ----------------------------------------------------------------------
@@ -42,16 +50,17 @@ esac
_DOLLARZERO=`readlink "$0" 2>/dev/null || echo "$0"`
RHQ_CLI_BIN_DIR_PATH=`dirname "$_DOLLARZERO"`
-if [ -f "${RHQ_CLI_BIN_DIR_PATH}/rhq-cli-env.sh" ]; then
- debug_msg "Loading environment script: ${RHQ_CLI_BIN_DIR_PATH}/rhq-cli-env.sh"
- . "${RHQ_CLI_BIN_DIR_PATH}/rhq-cli-env.sh" $*
+if [ -f "$RHQ_CLI_BIN_DIR_PATH/rhq-cli-env.sh" ]; then
+ debug_msg "Loading environment script: $RHQ_CLI_BIN_DIR_PATH/rhq-cli-env.sh"
+ . "$RHQ_CLI_BIN_DIR_PATH/rhq-cli-env.sh" $*
else
- debug_msg "No environment script found at: ${RHQ_CLI_BIN_DIR_PATH}/rhq-cli-env.sh"
+ debug_msg "No environment script found at: $RHQ_CLI_BIN_DIR_PATH/rhq-cli-env.sh"
fi
# this variable is set during the build and defines the desired default behavior for directory changing
# we do want to change the dir in RHQ, but possibly don't want to do that in JBoss ON for backwards compatibility
# reasons.
+# (yes, this USES ${} in the source (not in the distribution) because we seed the default value from the build)
RHQ_CLI_CHANGE_DIR_ON_START_DEFAULT=${rhq.cli.change-dir-on-start-default}
if [ -z "$RHQ_CLI_CHANGE_DIR_ON_START" ]; then
RHQ_CLI_CHANGE_DIR_ON_START="$RHQ_CLI_CHANGE_DIR_ON_START_DEFAULT"
@@ -61,24 +70,24 @@ fi
# Previous versions always changed directory.
if [ -n "$RHQ_CLI_CHANGE_DIR_ON_START" -a "$RHQ_CLI_CHANGE_DIR_ON_START" != "false" ]; then
if [ -z "$RHQ_CLI_HOME" ]; then
- cd "${RHQ_CLI_BIN_DIR_PATH}/.."
+ cd "$RHQ_CLI_BIN_DIR_PATH/.."
else
- cd "${RHQ_CLI_HOME}" || {
- echo "Cannot go to the RHQ_CLI_HOME directory: ${RHQ_CLI_HOME}"
+ cd "$RHQ_CLI_HOME" || {
+ echo "Cannot go to the RHQ_CLI_HOME directory: $RHQ_CLI_HOME"
exit 1
}
fi
RHQ_CLI_HOME=`pwd`
else
if [ -z "$RHQ_CLI_HOME" ]; then
- RHQ_CLI_HOME="${RHQ_CLI_BIN_DIR_PATH}/.."
+ RHQ_CLI_HOME="$RHQ_CLI_BIN_DIR_PATH/.."
fi
#get an absolute path
RHQ_CLI_HOME=`readlink -f "$RHQ_CLI_HOME"`
if [ ! -d "$RHQ_CLI_HOME" ]; then
- echo "RHQ_CLI_HOME detected or defined as [${RHQ_CLI_HOME}] doesn't seem to exist or is not a directory"
+ echo "RHQ_CLI_HOME detected or defined as [$RHQ_CLI_HOME] doesn't seem to exist or is not a directory"
exit 1
fi
fi
@@ -90,7 +99,7 @@ debug_msg "RHQ_CLI_HOME: $RHQ_CLI_HOME"
# sample modules.
# ----------------------------------------------------------------------
if [ -z "$RHQ_CLI_MODULES_DIR" ]; then
- RHQ_CLI_MODULES_DIR="${RHQ_CLI_HOME}/samples/modules"
+ RHQ_CLI_MODULES_DIR="$RHQ_CLI_HOME/samples/modules"
fi
# ----------------------------------------------------------------------
@@ -110,7 +119,7 @@ fi
if [ -z "$RHQ_CLI_JAVA_EXE_FILE_PATH" ]; then
if [ -z "$RHQ_CLI_JAVA_HOME" ]; then
- RHQ_CLI_JAVA_HOME="${RHQ_CLI_HOME}/jre"
+ RHQ_CLI_JAVA_HOME="$RHQ_CLI_HOME/jre"
if [ -d "$RHQ_CLI_JAVA_HOME" ]; then
debug_msg "Using the embedded JRE"
else
@@ -119,7 +128,7 @@ if [ -z "$RHQ_CLI_JAVA_EXE_FILE_PATH" ]; then
fi
fi
debug_msg "RHQ_CLI_JAVA_HOME: $RHQ_CLI_JAVA_HOME"
- RHQ_CLI_JAVA_EXE_FILE_PATH=${RHQ_CLI_JAVA_HOME}/bin/java
+ RHQ_CLI_JAVA_EXE_FILE_PATH="$RHQ_CLI_JAVA_HOME/bin/java"
fi
debug_msg "RHQ_CLI_JAVA_EXE_FILE_PATH: $RHQ_CLI_JAVA_EXE_FILE_PATH"
@@ -133,14 +142,14 @@ fi
# Prepare the classpath (take into account possible spaces in dir names)
# ----------------------------------------------------------------------
-CLASSPATH="${RHQ_CLI_HOME}/conf"
-_JAR_FILES=`cd "${RHQ_CLI_HOME}/lib";ls -1 *.jar`
+CLASSPATH="$RHQ_CLI_HOME/conf"
+_JAR_FILES=`cd "$RHQ_CLI_HOME/lib";ls -1 *.jar`
for _JAR in $_JAR_FILES ; do
- _JAR="${RHQ_CLI_HOME}/lib/${_JAR}"
+ _JAR="$RHQ_CLI_HOME/lib/$_JAR"
if [ -z "$CLASSPATH" ]; then
- CLASSPATH="${_JAR}"
+ CLASSPATH="$_JAR"
else
- CLASSPATH="${CLASSPATH}:${_JAR}"
+ CLASSPATH="$CLASSPATH:$_JAR"
fi
debug_msg "CLASSPATH entry: $_JAR"
done
@@ -151,7 +160,7 @@ debug_msg "CLASSPATH entry: $_JAR"
# ----------------------------------------------------------------------
if [ -z "$RHQ_CLI_JAVA_OPTS" ]; then
- RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true -Drhq.scripting.modules.root-dir=${RHQ_CLI_MODULES_DIR}"
+ RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true -Drhq.scripting.modules.root-dir=$RHQ_CLI_MODULES_DIR"
fi
debug_msg "RHQ_CLI_JAVA_OPTS: $RHQ_CLI_JAVA_OPTS"
@@ -159,7 +168,7 @@ if [ "$RHQ_CLI_JAVA_ENDORSED_DIRS" = "none" ]; then
debug_msg "Not explicitly setting java.endorsed.dirs"
else
if [ -z "$RHQ_CLI_JAVA_ENDORSED_DIRS" ]; then
- RHQ_CLI_JAVA_ENDORSED_DIRS="${RHQ_CLI_HOME}/lib/endorsed"
+ RHQ_CLI_JAVA_ENDORSED_DIRS="$RHQ_CLI_HOME/lib/endorsed"
fi
# convert the path if on Windows
@@ -167,14 +176,14 @@ else
RHQ_CLI_JAVA_ENDORSED_DIRS=`cygpath --windows --path "$RHQ_CLI_JAVA_ENDORSED_DIRS"`
fi
debug_msg "RHQ_CLI_JAVA_ENDORSED_DIRS: $RHQ_CLI_JAVA_ENDORSED_DIRS"
- _JAVA_ENDORSED_DIRS_OPT="-Djava.endorsed.dirs=\"${RHQ_CLI_JAVA_ENDORSED_DIRS}\""
+ _JAVA_ENDORSED_DIRS_OPT="-Djava.endorsed.dirs=\"$RHQ_CLI_JAVA_ENDORSED_DIRS\""
fi
if [ "$RHQ_CLI_JAVA_LIBRARY_PATH" = "none" ]; then
debug_msg "Not explicitly setting java.library.path"
else
if [ -z "$RHQ_CLI_JAVA_LIBRARY_PATH" ]; then
- RHQ_CLI_JAVA_LIBRARY_PATH="${RHQ_CLI_HOME}/lib"
+ RHQ_CLI_JAVA_LIBRARY_PATH="$RHQ_CLI_HOME/lib"
fi
# convert the path if on Windows
@@ -182,7 +191,7 @@ else
RHQ_CLI_JAVA_LIBRARY_PATH=`cygpath --windows --path "$RHQ_CLI_JAVA_LIBRARY_PATH"`
fi
debug_msg "RHQ_CLI_JAVA_LIBRARY_PATH: $RHQ_CLI_JAVA_LIBRARY_PATH"
- _JAVA_LIBRARY_PATH_OPT="-Djava.library.path=\"${RHQ_CLI_JAVA_LIBRARY_PATH}\""
+ _JAVA_LIBRARY_PATH_OPT="-Djava.library.path=\"$RHQ_CLI_JAVA_LIBRARY_PATH\""
fi
debug_msg "RHQ_CLI_ADDITIONAL_JAVA_OPTS: $RHQ_CLI_ADDITIONAL_JAVA_OPTS"
@@ -201,8 +210,8 @@ if [ -n "$RHQ_CLI_DEBUG" ]; then
fi
# create the logs directory
-if [ ! -d "${RHQ_CLI_HOME}/logs" ]; then
- mkdir "${RHQ_CLI_HOME}/logs"
+if [ ! -d "$RHQ_CLI_HOME/logs" ]; then
+ mkdir "$RHQ_CLI_HOME/logs"
fi
# convert some of the paths if we are on Windows
@@ -220,15 +229,15 @@ fi
debug_msg "Executing the CLI with this command line:"
exit_code=0
if [ -z "$RHQ_CLI_CMDLINE_OPTS" ]; then
- debug_msg "${RHQ_CLI_JAVA_EXE_FILE_PATH} ${_JAVA_ENDORSED_DIRS_OPT} ${_JAVA_LIBRARY_PATH_OPT} ${RHQ_CLI_JAVA_OPTS} ${RHQ_CLI_ADDITIONAL_JAVA_OPTS} ${_LOG_CONFIG} -cp ${CLASSPATH} org.rhq.enterprise.client.ClientMain $@"
- "${RHQ_CLI_JAVA_EXE_FILE_PATH}" ${_JAVA_ENDORSED_DIRS_OPT} ${_JAVA_LIBRARY_PATH_OPT} ${RHQ_CLI_JAVA_OPTS} ${RHQ_CLI_ADDITIONAL_JAVA_OPTS} ${_LOG_CONFIG} -cp "${CLASSPATH}" org.rhq.enterprise.client.ClientMain "$@"
+ debug_msg "$RHQ_CLI_JAVA_EXE_FILE_PATH $_JAVA_ENDORSED_DIRS_OPT $_JAVA_LIBRARY_PATH_OPT $RHQ_CLI_JAVA_OPTS $RHQ_CLI_ADDITIONAL_JAVA_OPTS $_LOG_CONFIG -cp $CLASSPATH org.rhq.enterprise.client.ClientMain $@"
+ "$RHQ_CLI_JAVA_EXE_FILE_PATH" $_JAVA_ENDORSED_DIRS_OPT $_JAVA_LIBRARY_PATH_OPT $RHQ_CLI_JAVA_OPTS $RHQ_CLI_ADDITIONAL_JAVA_OPTS $_LOG_CONFIG -cp "$CLASSPATH" org.rhq.enterprise.client.ClientMain "$@"
exit_code=$?
else
- debug_msg "${RHQ_CLI_JAVA_EXE_FILE_PATH} ${_JAVA_ENDORSED_DIRS_OPT} ${_JAVA_LIBRARY_PATH_OPT} ${RHQ_CLI_JAVA_OPTS} ${RHQ_CLI_ADDITIONAL_JAVA_OPTS} ${_LOG_CONFIG} -cp ${CLASSPATH} org.rhq.enterprise.client.ClientMain ${RHQ_CLI_CMDLINE_OPTS}"
- "${RHQ_CLI_JAVA_EXE_FILE_PATH}" ${_JAVA_ENDORSED_DIRS_OPT} ${_JAVA_LIBRARY_PATH_OPT} ${RHQ_CLI_JAVA_OPTS} ${RHQ_CLI_ADDITIONAL_JAVA_OPTS} ${_LOG_CONFIG} -cp "${CLASSPATH}" org.rhq.enterprise.client.ClientMain ${RHQ_CLI_CMDLINE_OPTS}
+ debug_msg "$RHQ_CLI_JAVA_EXE_FILE_PATH $_JAVA_ENDORSED_DIRS_OPT $_JAVA_LIBRARY_PATH_OPT $RHQ_CLI_JAVA_OPTS $RHQ_CLI_ADDITIONAL_JAVA_OPTS $_LOG_CONFIG -cp $CLASSPATH org.rhq.enterprise.client.ClientMain $RHQ_CLI_CMDLINE_OPTS"
+ "$RHQ_CLI_JAVA_EXE_FILE_PATH" $_JAVA_ENDORSED_DIRS_OPT $_JAVA_LIBRARY_PATH_OPT $RHQ_CLI_JAVA_OPTS $RHQ_CLI_ADDITIONAL_JAVA_OPTS $_LOG_CONFIG -cp "$CLASSPATH" org.rhq.enterprise.client.ClientMain $RHQ_CLI_CMDLINE_OPTS
exit_code=$?
fi
debug_msg "$0 done."
-exit ${exit_code}
+exit $exit_code
10 years, 4 months
[rhq] modules/enterprise
by Jiri Kremser
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/util/rpc/TrackingRequestCallback.java | 6 ++++++
1 file changed, 6 insertions(+)
New commits:
commit 50aed986a19b2e1cbd7d13e179c0342857d22854
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Mon Dec 16 19:23:37 2013 +0100
[BZ 970181] - RHQ doesn't work after restart with open GUI in web browser. - if the server restarts at the background, the session id is lost on the server therefore we can't allow the logged user to continue sending the requests without a new AuthN. It would be a security risk to allow it. Now, if the server restarts the UI requires the new log in (the login form is displayed).
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/util/rpc/TrackingRequestCallback.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/util/rpc/TrackingRequestCallback.java
index 07893f6..b443c1a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/util/rpc/TrackingRequestCallback.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/util/rpc/TrackingRequestCallback.java
@@ -23,6 +23,7 @@ import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.Response;
import org.rhq.coregui.client.CoreGUI;
+import org.rhq.coregui.client.LoginView;
import org.rhq.coregui.client.UserSessionManager;
import org.rhq.coregui.client.util.Log;
@@ -86,6 +87,11 @@ public class TrackingRequestCallback implements RequestCallback {
switch (statusCode) {
case STATUS_CODE_OK:
+ if (response != null && response.getText() != null && response.getText().isEmpty()
+ && !LoginView.isLoginShowing()) { // this happen when the RHQ server was restarted
+ new LoginView().showLoginDialog();
+ break;
+ }
RPCTracker.getInstance().succeedCall(this);
callback.onResponseReceived(request, response);
break;
10 years, 4 months
[rhq] Branch 'heiko/agentFootprint' - 5 commits - modules/core
by Heiko W. Rupp
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java | 22 ++++---
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java | 11 +--
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java | 18 ++++-
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java | 5 +
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationCheckExecutor.java | 2
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AvailabilityExecutor.java | 31 +++++-----
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ForceAvailabilityExecutor.java | 4 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 13 ++--
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java | 2
9 files changed, 66 insertions(+), 42 deletions(-)
New commits:
commit e460fc848e588afa2d4f0c005424db908be70f9c
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Dec 16 12:15:35 2013 +0100
Tune down logging. Obtain resource containers by numeric resource id instead of uuid String.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationCheckExecutor.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationCheckExecutor.java
index abd0ae1..1dce1d9 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationCheckExecutor.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationCheckExecutor.java
@@ -77,7 +77,7 @@ public class ConfigurationCheckExecutor implements Runnable, Callable {
}
public CountTime checkConfigurations(Resource resource, boolean checkChildren) {
- ResourceContainer resourceContainer = this.inventoryManager.getResourceContainer(resource);
+ ResourceContainer resourceContainer = this.inventoryManager.getResourceContainer(resource.getId());
ConfigurationFacet resourceComponent = null;
ResourceType resourceType = resource.getResourceType();
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AvailabilityExecutor.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AvailabilityExecutor.java
index c23809d..d21505e 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AvailabilityExecutor.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AvailabilityExecutor.java
@@ -355,7 +355,7 @@ public class AvailabilityExecutor implements Runnable, Callable<AvailabilityRepo
t.getLocalizedMessage(), ThrowableUtil.getStackAsString(t), System.currentTimeMillis());
this.inventoryManager.sendResourceErrorToServer(resourceError);
LOG.warn("Availability collection failed with exception on " + resource
- + ", availability will be reported as " + DOWN.name(), t);
+ + ", availability will be reported as " + DOWN.name() + ", reason=" + t.getMessage());
current = DOWN;
}
} else {
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
index 27bd7ef..fd5713c 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
@@ -1031,7 +1031,7 @@ public class InventoryManager extends AgentService implements ContainerService,
*/
@Nullable
public Availability getAvailabilityIfKnown(Resource resource) {
- ResourceContainer resourceContainer = getResourceContainer(resource);
+ ResourceContainer resourceContainer = getResourceContainer(resource.getId());
if (resourceContainer != null) {
if (ResourceComponentState.STARTED == resourceContainer.getResourceComponentState()) {
@@ -1926,6 +1926,12 @@ public class InventoryManager extends AgentService implements ContainerService,
// because we're not actually STARTED
container.setResourceComponentState(ResourceComponentState.STOPPED);
+ String message = "Failed to start component for resource " + resource
+ + ".";
+ if (t.getCause()!=null) {
+ message += " Cause: " + t.getCause().getMessage();
+ }
+
if (updatedPluginConfig || (t instanceof InvalidPluginConfigurationException)) {
if (log.isDebugEnabled()) {
log.debug("Resource has a bad config, waiting for this to go away: " + resource);
@@ -1933,11 +1939,10 @@ public class InventoryManager extends AgentService implements ContainerService,
InventoryEventListener iel = new ResourceGotActivatedListener();
addInventoryEventListener(iel);
- throw new InvalidPluginConfigurationException("Failed to start component for resource " + resource
- + ".", t);
+ throw new InvalidPluginConfigurationException(message);
}
- throw new PluginContainerException("Failed to start component for resource " + resource + ".", t);
+ throw new PluginContainerException(message);
}
// We purposefully do not get availability of this resource yet
commit 2c79b84224f0e25264935edfbcdb4a09f2528266
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Dec 16 11:54:46 2013 +0100
Do some string interning.
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java
index 35ef00a..d40d82d 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/ConfigurationMetadataParser.java
@@ -85,7 +85,7 @@ public class ConfigurationMetadataParser {
return null;
}
- ConfigurationDefinition configurationDefinition = new ConfigurationDefinition(configurationName,
+ ConfigurationDefinition configurationDefinition = new ConfigurationDefinition(configurationName.intern(),
descriptor.getNotes());
configurationDefinition.setConfigurationFormat(getConfigurationFormat(descriptor));
@@ -181,14 +181,14 @@ public class ConfigurationMetadataParser {
}
}
- private static ConfigurationTemplate parseTemplate(ConfigurationTemplateDescriptor templateDescripter)
+ private static ConfigurationTemplate parseTemplate(ConfigurationTemplateDescriptor templateDescriptor)
throws InvalidPluginDescriptorException {
- ConfigurationTemplate template = new ConfigurationTemplate(templateDescripter.getName(),
- templateDescripter.getDescription());
+ ConfigurationTemplate template = new ConfigurationTemplate(templateDescriptor.getName(),
+ templateDescriptor.getDescription());
Configuration templateConfiguration = new Configuration();
template.setConfiguration(templateConfiguration);
- parseProperties(templateDescripter, templateConfiguration, null);
+ parseProperties(templateDescriptor, templateConfiguration, null);
return template;
}
@@ -313,12 +313,14 @@ public class ConfigurationMetadataParser {
PropertyDefinition memberDefinition = (memberProperty != null) ? parseProperty(memberProperty.getValue(), 0)
: null;
- PropertyDefinitionList list = new PropertyDefinitionList(listProperty.getName(), description,
+ PropertyDefinitionList list = new PropertyDefinitionList(listProperty.getName().intern(), description,
listProperty.isRequired(), memberDefinition);
String displayName = (listProperty.getDisplayName() != null) ? listProperty.getDisplayName() : StringUtils
.deCamelCase(listProperty.getName());
- list.setDisplayName(displayName);
+ if (displayName!=null) {
+ list.setDisplayName(displayName.intern());
+ }
list.setReadOnly(listProperty.isReadOnly());
list.setSummary(listProperty.isSummary());
@@ -336,12 +338,14 @@ public class ConfigurationMetadataParser {
AbstractPropertyMap defaultConfigurationParentMap) throws InvalidPluginDescriptorException {
String description = parseMultiValue(mapProperty.getDescription(), mapProperty.getLongDescription());
- PropertyDefinitionMap propDefMap = new PropertyDefinitionMap(mapProperty.getName(), description,
+ PropertyDefinitionMap propDefMap = new PropertyDefinitionMap(mapProperty.getName().intern(), description,
mapProperty.isRequired());
String displayName = (mapProperty.getDisplayName() != null) ? mapProperty.getDisplayName() : StringUtils
.deCamelCase(mapProperty.getName());
- propDefMap.setDisplayName(displayName);
+ if (displayName!=null) {
+ propDefMap.setDisplayName(displayName.intern());
+ }
propDefMap.setReadOnly(mapProperty.isReadOnly());
propDefMap.setSummary(mapProperty.isSummary());
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
index 7e7e574..e5d58b2 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
@@ -602,7 +602,7 @@ public class PluginMetadataParser {
}
try {
- resourceType.setPlugin(pluginDescriptor.getName());
+ resourceType.setPlugin(pluginDescriptor.getName().intern());
if (resourceDescriptor.getPluginConfiguration() != null) {
resourceType.setPluginConfigurationDefinition(ConfigurationMetadataParser.parse(resourceType.getName(),
@@ -744,7 +744,11 @@ public class PluginMetadataParser {
* @return the resource discovery component class name
*/
public String getDiscoveryComponentClass(ResourceType resourceType) {
- return this.discoveryClasses.get(resourceType);
+ String s = this.discoveryClasses.get(resourceType);
+ if (s!=null) {
+ s = s.intern();
+ }
+ return s;
}
/**
@@ -755,15 +759,19 @@ public class PluginMetadataParser {
* @return the resource component class name
*/
public String getComponentClass(ResourceType resourceType) {
- return this.componentClasses.get(resourceType);
+ String s = this.componentClasses.get(resourceType);
+ if (s!=null) {
+ s=s.intern();
+ }
+ return s;
}
private void registerResourceTypeAndComponentClasses(ResourceType resourceType, String discoveryClass,
String componentClass) {
this.resourceTypes.add(resourceType);
- this.componentClasses.put(resourceType, componentClass);
+ this.componentClasses.put(resourceType, componentClass.intern());
if (discoveryClass != null) {
- this.discoveryClasses.put(resourceType, discoveryClass);
+ this.discoveryClasses.put(resourceType, discoveryClass.intern());
}
}
commit e7cc75bfa28c5cb28c9f55ab91dfa005b6dd2d53
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Dec 16 11:38:27 2013 +0100
Synchronize on final fields
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java
index 5b22e3e..6c0703c 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 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
@@ -69,7 +69,7 @@ public class PluginMetadataManager {
private Map<ResourceCategory, LinkedHashSet<ResourceType>> typesByCategory = new HashMap<ResourceCategory, LinkedHashSet<ResourceType>>();
private Set<ResourceType> types = new HashSet<ResourceType>();
- private Object typesLock = new Object();
+ private final Object typesLock = new Object();
private Map<String, PluginMetadataParser> parsersByPlugin = new HashMap<String, PluginMetadataParser>();
@@ -80,12 +80,13 @@ public class PluginMetadataManager {
private List<String> disabledResourceTypesAsStrings = null;
private Map<ResourceType, String> disabledResourceTypes = null;
private Set<ResourceType> ignoredResourceTypes = null;
- private Object disabledIgnoredTypesLock = new Object(); // used when accessing disabled and ignored collections
+ private final Object disabledIgnoredTypesLock = new Object(); // used when accessing disabled and ignored collections
// these define the discovery callbacks per resource type. The key is the resource type whose discovered details
// need to be funneled through callbacks. The value is a map whose key is plugin names and whose values are
// discovery callback implementation classes defined in the plugins.
private Map<ResourceType, Map<String, List<String>>> discoveryCallbacks = new HashMap<ResourceType, Map<String, List<String>>>();
+ private final Object discoveryCallbacksLock = new Object();
public PluginMetadataManager() {
}
@@ -516,14 +517,14 @@ public class PluginMetadataManager {
* @return the collection of callbacks, grouped by the plugins that defined them (may be null)
*/
public Map<String, List<String>> getDiscoveryCallbacks(ResourceType resourceType) {
- synchronized (discoveryCallbacks) {
+ synchronized (discoveryCallbacksLock) {
Map<String, List<String>> map = discoveryCallbacks.get(resourceType);
return map;
}
}
private void addDiscoveryCallbackClassName(ResourceType resourceType, String pluginName, String className) {
- synchronized (discoveryCallbacks) {
+ synchronized (discoveryCallbacksLock) {
Map<String, List<String>> map = discoveryCallbacks.get(resourceType);
if (map == null) {
map = new HashMap<String, List<String>>(1);
commit 80c42d099588802c7b12af7a51baf1640f0e4374
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Dec 16 11:33:37 2013 +0100
When cloning, directly allocate a collection of the right size.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
index 27e9dc3..64dc441 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
@@ -953,6 +953,11 @@ public class Configuration implements Serializable, Cloneable, AbstractPropertyM
if (properties==null) {
return;
}
+
+ if (copy.properties==null) {
+ copy.properties=new LinkedHashMap<String, Property>(this.properties.size());
+ }
+
for (Property property : this.properties.values()) {
copy.put(property.deepCopy(keepId));
}
commit 2fb20f60d6acdc2108ecbedb9091849a5aed0847
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Dec 16 09:34:59 2013 +0100
Pull out determination of log.trace
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AvailabilityExecutor.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AvailabilityExecutor.java
index e278062..c23809d 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AvailabilityExecutor.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AvailabilityExecutor.java
@@ -169,8 +169,9 @@ public class AvailabilityExecutor implements Runnable, Callable<AvailabilityRepo
parentAvailabilityType = UP;
}
+ boolean traceEnabled = LOG.isTraceEnabled();
try {
- checkInventory(scanRoot, availabilityReport, parentAvailabilityType, false, scan);
+ checkInventory(scanRoot, availabilityReport, parentAvailabilityType, false, scan, traceEnabled);
} catch (InterruptedException e) {
LOG.debug("Availability check was interrupted", e);
return;
@@ -217,14 +218,14 @@ public class AvailabilityExecutor implements Runnable, Callable<AvailabilityRepo
* @throws InterruptedException if this checking thread was interrupted
*/
protected void checkInventory(Resource resource, AvailabilityReport availabilityReport,
- AvailabilityType parentAvailType, boolean isForced, Scan scan) throws InterruptedException {
+ AvailabilityType parentAvailType, boolean isForced, Scan scan, boolean traceEnabled) throws InterruptedException {
// Only report avail for committed Resources - that's all the Server cares about.
if (resource.getId() == 0 || resource.getInventoryStatus() != InventoryStatus.COMMITTED) {
return;
}
- ResourceContainer resourceContainer = this.inventoryManager.getResourceContainer(resource);
+ ResourceContainer resourceContainer = this.inventoryManager.getResourceContainer(resource.getId());
// Only report avail for synchronized Resources, otherwise the Server will likely know nothing of the Resource.
if (resourceContainer == null
|| resourceContainer.getSynchronizationState() != ResourceContainer.SynchronizationState.SYNCHRONIZED) {
@@ -248,7 +249,7 @@ public class AvailabilityExecutor implements Runnable, Callable<AvailabilityRepo
// if there is no availability schedule (platform) then just perform the avail check
// (note, platforms always return UP anyway).
if (null == availScheduleRequest) {
- if (LOG.isTraceEnabled()) {
+ if (traceEnabled) {
LOG.trace("No availScheduleRequest for " + resource + ". checkAvail set to true");
}
checkAvail = true;
@@ -263,14 +264,14 @@ public class AvailabilityExecutor implements Runnable, Callable<AvailabilityRepo
availabilityScheduleTime = scan.startTime + RANDOM.nextInt(interval + 1);
resourceContainer.setAvailabilityScheduleTime(availabilityScheduleTime);
- if (LOG.isTraceEnabled()) {
+ if (traceEnabled) {
LOG.trace("Forced availabilityScheduleTime to " + new Date(availabilityScheduleTime) + " for "
+ resource);
}
++scan.numScheduledRandomly;
} else {
- if (LOG.isTraceEnabled()) {
+ if (traceEnabled) {
LOG.trace("Deferred availability to parent for " + resource);
}
deferToParent = true;
@@ -281,14 +282,14 @@ public class AvailabilityExecutor implements Runnable, Callable<AvailabilityRepo
checkAvail = scan.startTime >= availabilityScheduleTime;
if (checkAvail) {
- if (LOG.isTraceEnabled()) {
+ if (traceEnabled) {
LOG.trace("Scheduled time has been reached for " + resource);
}
long interval = availScheduleRequest.getInterval(); // intervals are short enough for safe cast
resourceContainer.setAvailabilityScheduleTime(scan.startTime + interval);
++scan.numPushedByInterval;
} else {
- if (LOG.isTraceEnabled()) {
+ if (traceEnabled) {
LOG.trace("Scheduled time has not been reached for " + resource);
}
}
@@ -311,7 +312,7 @@ public class AvailabilityExecutor implements Runnable, Callable<AvailabilityRepo
// the child. For now, we'll leave it alone and let the next check happen according to the
// schedule already established.
- if (LOG.isTraceEnabled()) {
+ if (traceEnabled) {
LOG.trace("Gave parent availability " + parentAvailType + " to " + resource);
}
} else {
@@ -322,7 +323,7 @@ public class AvailabilityExecutor implements Runnable, Callable<AvailabilityRepo
}
if (checkAvail) {
- if (LOG.isTraceEnabled()) {
+ if (traceEnabled) {
LOG.trace("Now checking availability for " + resource);
}
@@ -346,7 +347,7 @@ public class AvailabilityExecutor implements Runnable, Callable<AvailabilityRepo
current = DOWN;
}
}
- if (LOG.isTraceEnabled()) {
+ if (traceEnabled) {
LOG.trace("Current availability is " + current + " for " + resource);
}
} catch (Throwable t) {
@@ -370,7 +371,7 @@ public class AvailabilityExecutor implements Runnable, Callable<AvailabilityRepo
Availability availability;
if (availChanged) {
- if (LOG.isTraceEnabled()) {
+ if (traceEnabled) {
LOG.trace("Availability changed for " + resource);
}
++scan.numAvailabilityChanges;
@@ -381,7 +382,7 @@ public class AvailabilityExecutor implements Runnable, Callable<AvailabilityRepo
// children, to ensure their avails are up to date. Note that if it changed to NOT UP
// then the children will just get the parent avail type and there is no avail check anyway.
if (!isForced && (UP == current)) {
- if (LOG.isTraceEnabled()) {
+ if (traceEnabled) {
LOG.trace("Forcing availability check for children of " + resource);
}
isForced = true;
@@ -396,7 +397,7 @@ public class AvailabilityExecutor implements Runnable, Callable<AvailabilityRepo
}
for (Resource child : this.inventoryManager.getContainerChildren(resource, resourceContainer)) {
- checkInventory(child, availabilityReport, current, isForced, scan);
+ checkInventory(child, availabilityReport, current, isForced, scan, traceEnabled);
}
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ForceAvailabilityExecutor.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ForceAvailabilityExecutor.java
index 53475fd..74a4901 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ForceAvailabilityExecutor.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ForceAvailabilityExecutor.java
@@ -37,9 +37,9 @@ public class ForceAvailabilityExecutor extends AvailabilityExecutor {
@Override
protected void checkInventory(Resource resource, AvailabilityReport availabilityReport,
- AvailabilityType parentAvailType, boolean forceCheck, Scan scan) throws InterruptedException {
+ AvailabilityType parentAvailType, boolean forceCheck, Scan scan, boolean traceEnabled) throws InterruptedException {
scan.setForced(true);
- super.checkInventory(resource, availabilityReport, parentAvailType, true, scan);
+ super.checkInventory(resource, availabilityReport, parentAvailType, true, scan, traceEnabled);
}
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java
index 5265977..fd423a7 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java
@@ -161,7 +161,7 @@ public class RuntimeDiscoveryExecutor implements Runnable, Callable<InventoryRep
log.debug("Discovering child Resources for " + parent + "...");
- ResourceContainer parentContainer = this.inventoryManager.getResourceContainer(parent);
+ ResourceContainer parentContainer = this.inventoryManager.getResourceContainer(parent.getId());
if (parentContainer == null) {
if (log.isDebugEnabled()) {
log.debug("Cannot perform service scan on parent [" + parent + "] without a container");
10 years, 4 months
[rhq] modules/enterprise
by mike thompson
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/D3GroupGraphListView.java | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java | 408 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupView.java | 193 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupViewDataSource.java | 314 +++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricAvailabilityView.java | 223 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsGridFieldName.java | 63 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java | 30
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java | 56 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/ResourceMetricAvailabilityView.java | 224 -----
11 files changed, 1240 insertions(+), 278 deletions(-)
New commits:
commit 1b05bf1c0d1976e7109e163e10cdc0c736fec9e0
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Fri Dec 13 15:51:56 2013 -0800
[BZ 1034512] Update Group Metric Graphs to be more like new Resource Metrics Graphs
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/D3GroupGraphListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/D3GroupGraphListView.java
index d0b56a7..f6805e2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/D3GroupGraphListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/D3GroupGraphListView.java
@@ -189,6 +189,7 @@ public final class D3GroupGraphListView extends AbstractD3GraphListView implemen
private void buildIndividualGraph(MeasurementDefinition measurementDefinition,
List<MeasurementDataNumericHighLowComposite> data) {
+ Log.debug("\n***** D3GroupGraphListView.MD: "+measurementDefinition);
MetricGraphData metricGraphData = MetricGraphData.createForResourceGroup(resourceGroup.getId(),
resourceGroup.getName(), measurementDefinition, data);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 9ddbb77..8394217 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -63,6 +63,7 @@ import org.rhq.coregui.client.inventory.groups.detail.configuration.HistoryGroup
import org.rhq.coregui.client.inventory.groups.detail.inventory.GroupPluginConfigurationEditView;
import org.rhq.coregui.client.inventory.groups.detail.inventory.HistoryGroupPluginConfigurationView;
import org.rhq.coregui.client.inventory.groups.detail.inventory.MembersView;
+import org.rhq.coregui.client.inventory.groups.detail.monitoring.metric.MetricsGroupView;
import org.rhq.coregui.client.inventory.groups.detail.monitoring.schedules.ResourceGroupSchedulesView;
import org.rhq.coregui.client.inventory.groups.detail.monitoring.table.GroupMonitoringTablesView;
import org.rhq.coregui.client.inventory.groups.detail.monitoring.traits.TraitsView;
@@ -332,7 +333,7 @@ public class ResourceGroupDetailView extends
viewFactory = (!showOnPage) ? null : new ViewFactory() {
@Override
public Canvas createView() {
- return createD3GraphListView();
+ return MetricsGroupView.create(groupComposite.getResourceGroup());
}
};
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java
new file mode 100644
index 0000000..89d4f67
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java
@@ -0,0 +1,408 @@
+/*
+ * 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.coregui.client.inventory.groups.detail.monitoring.metric;
+
+import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.METRIC_DEF_ID;
+import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.RESOURCE_GROUP_ID;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+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.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.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 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.measurement.composite.MeasurementDataNumericHighLowComposite;
+import org.rhq.core.domain.resource.group.GroupCategory;
+import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.coregui.client.CoreGUI;
+import org.rhq.coregui.client.components.table.Table;
+import org.rhq.coregui.client.dashboard.portlets.inventory.groups.graph.ResourceGroupD3GraphPortlet;
+import org.rhq.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.coregui.client.inventory.common.AbstractD3GraphListView;
+import org.rhq.coregui.client.inventory.common.graph.CustomDateRangeState;
+import org.rhq.coregui.client.inventory.common.graph.MetricGraphData;
+import org.rhq.coregui.client.inventory.common.graph.Refreshable;
+import org.rhq.coregui.client.inventory.common.graph.graphtype.StackedBarMetricGraphImpl;
+import org.rhq.coregui.client.inventory.resource.detail.monitoring.MetricD3Graph;
+import org.rhq.coregui.client.util.BrowserUtility;
+import org.rhq.coregui.client.util.Log;
+import org.rhq.coregui.client.util.message.Message;
+
+/**
+ * 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 MetricsGroupTableView extends Table<MetricsGroupViewDataSource> implements Refreshable {
+
+ private final ResourceGroup resourceGroup;
+ private final AbstractD3GraphListView abstractD3GraphListView;
+ private ToolStrip toolStrip;
+ private SelectItem dashboardSelectItem;
+ private Dashboard selectedDashboard;
+ private IButton addToDashboardButton;
+ private LinkedHashMap<String, String> dashboardMenuMap;
+ private LinkedHashMap<Integer, Dashboard> dashboardMap;
+ private Set<Integer> expandedRows;
+ private MetricsTableListGrid metricsTableListGrid;
+ private int selectedMetricDefinitionId;
+
+ public MetricsGroupTableView(ResourceGroup resourceGroup, AbstractD3GraphListView abstractD3GraphListView,
+ Set<Integer> expandedRows) {
+ super();
+ this.resourceGroup = resourceGroup;
+ this.abstractD3GraphListView = abstractD3GraphListView;
+ dashboardMenuMap = new LinkedHashMap<String, String>();
+ dashboardMap = new LinkedHashMap<Integer, Dashboard>();
+ setDataSource(new MetricsGroupViewDataSource(resourceGroup));
+ this.expandedRows = expandedRows;
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ }
+
+ /**
+ * 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, resourceGroup);
+ metricsTableListGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
+ @Override
+ public void onSelectionChanged(SelectionEvent selectionEvent) {
+ if (resourceGroup.getGroupCategory() == GroupCategory.COMPATIBLE) {
+ addToDashboardButton.enable();
+ ListGridRecord selectedRecord = selectionEvent.getSelectedRecord();
+ if (null != selectedRecord) {
+ selectedMetricDefinitionId = selectedRecord.getAttributeAsInt(METRIC_DEF_ID.getValue());
+ }
+ }
+ }
+ });
+
+ if (null == toolStrip) {
+ toolStrip = createToolstrip();
+ }
+ addExtraWidget(toolStrip, false);
+ addToDashboardButton.disable();
+ return metricsTableListGrid;
+ }
+
+ protected void configureTable() {
+ ArrayList<ListGridField> fields = getDataSource().getListGridFields();
+ setListGridFields(fields.toArray(new ListGridField[0]));
+ }
+
+ private ToolStrip createToolstrip() {
+ toolStrip = new ToolStrip();
+ toolStrip.setWidth(300);
+ toolStrip.setMembersMargin(15);
+ toolStrip.setPadding(5);
+ toolStrip.addSpacer(10);
+ addToDashboardButton = new IButton(MSG.chart_metrics_add_to_dashboard_button());
+ addToDashboardButton.setWidth(80);
+ dashboardSelectItem = new SelectItem();
+ dashboardSelectItem.setTitle(MSG.chart_metrics_add_to_dashboard_label());
+ dashboardSelectItem.setWidth(240);
+ dashboardSelectItem.setWrapTitle(false);
+ populateDashboardMenu();
+ toolStrip.addFormItem(dashboardSelectItem);
+ toolStrip.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) {
+ for (MeasurementDefinition measurementDefinition : resourceGroup.getResourceType()
+ .getMetricDefinitions()) {
+ if (measurementDefinition.getId() == selectedMetricDefinitionId) {
+ Log.debug("Add to Dashboard -- Storing: " + measurementDefinition.getDisplayName() + " in "
+ + selectedDashboard.getName());
+
+ storeDashboardMetric(selectedDashboard, resourceGroup.getId(), measurementDefinition);
+ break;
+ }
+ }
+ }
+ });
+ return toolStrip;
+ }
+
+ @Override
+ /**
+ * Redraw Graphs in this context means to refresh the table and redraw open graphs.
+ */
+ public void refreshData() {
+ new Timer() {
+ @Override
+ public void run() {
+ metricsTableListGrid.expandOpenedRows();
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+
+ }
+
+ @Override
+ public void refresh() {
+ super.refresh(false);
+ metricsTableListGrid.expandOpenedRows();
+ }
+
+ private 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) {
+ if (dashboards.size() > 0) {
+ for (final Dashboard dashboard : dashboards) {
+ dashboardMenuMap.put(String.valueOf(dashboard.getId()), dashboard.getName());
+ dashboardMap.put(dashboard.getId(), dashboard);
+ }
+ selectedDashboard = dashboards.get(0);
+ dashboardSelectItem.setValueMap(dashboardMenuMap);
+ dashboardSelectItem.setValue(selectedDashboard.getId());
+ }
+ }
+ });
+ }
+
+ private void storeDashboardMetric(Dashboard dashboard, int resourceGroupId, MeasurementDefinition definition) {
+
+ DashboardPortlet dashboardPortlet = new DashboardPortlet(MSG.view_tree_common_contextMenu_groupGraph(),
+ ResourceGroupD3GraphPortlet.KEY, 260);
+ dashboardPortlet.getConfiguration().put(
+ new PropertySimple(ResourceGroupD3GraphPortlet.CFG_RESOURCE_GROUP_ID, resourceGroupId));
+ dashboardPortlet.getConfiguration().put(
+ new PropertySimple(ResourceGroupD3GraphPortlet.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) {
+ String msg = MSG.view_tree_common_contextMenu_saveChartToDashboardSuccessful(result.getName());
+ CoreGUI.getMessageCenter().notify(new Message(msg, Message.Severity.Info));
+ }
+ });
+ }
+
+ public class MetricsTableListGrid extends ListGrid {
+
+ private static final int TREEVIEW_DETAIL_CHART_HEIGHT = 205;
+ private static final int NUM_METRIC_POINTS = 60;
+ final MetricsGroupTableView metricsTableView;
+ private ResourceGroup group;
+
+ public MetricsTableListGrid(final MetricsGroupTableView metricsTableView, final ResourceGroup group) {
+ super();
+ this.group = group;
+ this.metricsTableView = metricsTableView;
+ setCanExpandRecords(true);
+ setSelectionType(SelectionStyle.SINGLE);
+ setCanExpandMultipleRecords(true);
+ setExpansionMode(ExpansionMode.DETAIL_FIELD);
+
+ addRecordExpandHandler(new RecordExpandHandler() {
+ @Override
+ public void onRecordExpand(RecordExpandEvent recordExpandEvent) {
+ metricsTableView.expandedRows.add(recordExpandEvent.getRecord().getAttributeAsInt(
+ METRIC_DEF_ID.getValue()));
+ refreshData();
+ }
+
+ });
+ addRecordCollapseHandler(new RecordCollapseHandler() {
+ @Override
+ public void onRecordCollapse(RecordCollapseEvent recordCollapseEvent) {
+ metricsTableView.expandedRows.remove(recordCollapseEvent.getRecord().getAttributeAsInt(
+ METRIC_DEF_ID.getValue()));
+ refresh();
+ new Timer() {
+ @Override
+ public void run() {
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+ }
+ });
+ addSortChangedHandler(new SortChangedHandler() {
+ @Override
+ public void onSortChanged(SortEvent sortEvent) {
+ refreshData();
+ }
+ });
+
+ addDataArrivedHandler(new DataArrivedHandler() {
+ @Override
+ public void onDataArrived(DataArrivedEvent dataArrivedEvent) {
+ expandOpenedRows();
+ }
+ });
+
+ }
+
+ public void expandOpenedRows() {
+ int startRow = 0;
+ int endRow = this.getRecords().length;
+ for (int i = startRow; i < endRow; i++) {
+ ListGridRecord listGridRecord = getRecord(i);
+ if (null != listGridRecord) {
+ int metricDefinitionId = listGridRecord.getAttributeAsInt(METRIC_DEF_ID.getValue());
+ if (null != metricsTableView && null != expandedRows
+ && metricsTableView.expandedRows.contains(metricDefinitionId)) {
+ expandRecord(listGridRecord);
+ }
+ }
+ }
+ }
+
+ @Override
+ /**
+ * If you expand a grid row then create a graph.
+ */
+ protected Canvas getExpansionComponent(final ListGridRecord record) {
+ final Integer definitionId = record.getAttributeAsInt(METRIC_DEF_ID.getValue());
+ final Integer resourceGroupId = record.getAttributeAsInt(RESOURCE_GROUP_ID.getValue());
+ VLayout vLayout = new VLayout();
+ vLayout.setPadding(5);
+
+ final String chartId = "rChart-" + resourceGroupId + "-" + 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().findDataForCompatibleGroup(resourceGroupId,
+ definitionArrayIds, CustomDateRangeState.getInstance().getStartTime(),
+ CustomDateRangeState.getInstance().getEndTime(), NUM_METRIC_POINTS,
+ new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.warn("Error retrieving recent metrics charting data for resource group [" + resourceGroupId
+ + "]:" + 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 : group.getResourceType().getMetricDefinitions()) {
+ if (definition.getId() == definitionId) {
+ measurementDefinition = definition;
+ break;
+ }
+ }
+
+ MetricGraphData metricGraphData = MetricGraphData.createForResourceGroup(group.getId(),
+ group.getName(), measurementDefinition, measurementList);
+ 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();
+ new Timer() {
+ @Override
+ public void run() {
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+ }
+ }.schedule(150);
+
+ } else {
+ Log.warn("No chart data retrieving for resource group [" + resourceGroupId + "-"
+ + definitionId + "]");
+ }
+ }
+ });
+
+ return vLayout;
+ }
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupView.java
new file mode 100644
index 0000000..1e07e7a
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupView.java
@@ -0,0 +1,193 @@
+/*
+ * 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.coregui.client.inventory.groups.detail.monitoring.metric;
+
+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.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.group.ResourceGroup;
+import org.rhq.coregui.client.CoreGUI;
+import org.rhq.coregui.client.IconEnum;
+import org.rhq.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.coregui.client.inventory.common.AbstractD3GraphListView;
+import org.rhq.coregui.client.inventory.common.detail.AbstractTwoLevelTabSetView;
+import org.rhq.coregui.client.inventory.common.graph.CustomDateRangeState;
+import org.rhq.coregui.client.inventory.common.graph.graphtype.AvailabilityOverUnderGraphType;
+import org.rhq.coregui.client.inventory.resource.detail.monitoring.ExpandedRowsMomento;
+import org.rhq.coregui.client.inventory.resource.detail.monitoring.avail.AvailabilityD3GraphView;
+import org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricAvailabilityView;
+import org.rhq.coregui.client.util.BrowserUtility;
+import org.rhq.coregui.client.util.async.CountDownLatch;
+import org.rhq.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 MetricsGroupView extends AbstractD3GraphListView implements
+ AbstractTwoLevelTabSetView.ViewRenderedListener {
+
+ private static final String COLLAPSED_TOOLTIP = MSG.chart_metrics_collapse_tooltip();
+ private static final String EXPANDED_TOOLTIP = MSG.chart_metrics_expand_tooltip();
+
+ private final ResourceGroup resourceGroup;
+ private EnhancedHLayout expandCollapseHLayout;
+ private MetricsGroupTableView metricsTableView;
+ private static Integer lastResourceGroupId = 0;
+
+ /**
+ * Encapsulate the creation logic and not let it leak out into other objects.
+ * Clear the expanded rows set when changing resources as well.
+ * @see ExpandedRowsMomento
+ * @param group
+ * @return MetricsGroupView
+ */
+ public static MetricsGroupView create(ResourceGroup group ){
+
+ boolean isDifferentResource = (group.getId() != lastResourceGroupId);
+
+ if(isDifferentResource){
+ ExpandedRowsMomento.getInstance().clear();
+ }
+
+ return new MetricsGroupView(group, ExpandedRowsMomento.getInstance().getExpandedRows());
+
+ }
+
+ private MetricsGroupView(ResourceGroup resourceGroup, Set<Integer> expandedRows) {
+ super();
+ setOverflow(Overflow.AUTO);
+ setWidth100();
+ setHeight100();
+ this.resourceGroup = resourceGroup;
+ metricsTableView = new MetricsGroupTableView(resourceGroup, this, expandedRows);
+
+ final MetricAvailabilityView availabilityDetails = new MetricAvailabilityView(resourceGroup.getId());
+ availabilityDetails.hide();
+
+ metricsTableView.setHeight100();
+
+ availabilityGraph = AvailabilityD3GraphView.create( new AvailabilityOverUnderGraphType(resourceGroup.getId()));
+
+ expandCollapseHLayout = new EnhancedHLayout();
+ //add expand/collapse icon
+ final Img 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();
+
+ }
+ drawAvailabilityGraphAndSparklines();
+ }
+ });
+ expandCollapseHLayout.addMember(expandCollapseArrow);
+ addAvailabilityGraph();
+
+ addMember(buttonBarDateTimeRangeEditor);
+ addMember(expandCollapseHLayout);
+ addMember(availabilityDetails);
+ addMember(metricsTableView);
+ lastResourceGroupId = resourceGroup.getId();
+ }
+
+
+ private void addAvailabilityGraph() {
+ expandCollapseHLayout.removeMember(availabilityGraph);
+ availabilityGraph.destroy();
+
+ availabilityGraph = AvailabilityD3GraphView.create(new AvailabilityOverUnderGraphType(resourceGroup.getId()));
+
+ expandCollapseHLayout.addMember(availabilityGraph);
+
+ queryAvailability(EntityContext.forGroup(resourceGroup.getId()), CustomDateRangeState.getInstance().getStartTime(),
+ CustomDateRangeState.getInstance().getEndTime(), null);
+ }
+
+
+ @Override
+ protected void queryAvailability(final EntityContext context, Long startTime, Long endTime, CountDownLatch notUsed) {
+
+ // now return the availability
+ GWTServiceLookup.getAvailabilityService().getAvailabilitiesForResource(context.getGroupId(), 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) {
+ availabilityGraph.setAvailabilityList(availList);
+ new Timer() {
+ @Override
+ public void run() {
+ buttonBarDateTimeRangeEditor.updateTimeRangeToNow();
+ availabilityGraph.drawJsniChart();
+
+ }
+ }.schedule(150);
+ }
+ });
+ }
+
+ private void drawAvailabilityGraphAndSparklines() {
+ new Timer() {
+ @Override
+ public void run() {
+ availabilityGraph.drawJsniChart();
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+ }
+
+ @Override
+ public void refreshData() {
+ addAvailabilityGraph();
+ metricsTableView.refresh();
+ }
+
+ @Override
+ public void onViewRendered() {
+ // refresh the graphs on subtab nav because we are a cached view not new
+ refreshData();
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupViewDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupViewDataSource.java
new file mode 100644
index 0000000..a5f1353
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupViewDataSource.java
@@ -0,0 +1,314 @@
+/*
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.coregui.client.inventory.groups.detail.monitoring.metric;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+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.MeasurementDefinition;
+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.group.ResourceGroup;
+import org.rhq.coregui.client.CoreGUI;
+import org.rhq.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.coregui.client.inventory.common.graph.CustomDateRangeState;
+import org.rhq.coregui.client.util.BrowserUtility;
+import org.rhq.coregui.client.util.Log;
+import org.rhq.coregui.client.util.MeasurementUtility;
+import org.rhq.coregui.client.util.RPCDataSource;
+import org.rhq.coregui.client.util.async.Command;
+import org.rhq.coregui.client.util.async.CountDownLatch;
+
+import static org.rhq.core.domain.measurement.DataType.COMPLEX;
+import static org.rhq.core.domain.measurement.DataType.MEASUREMENT;
+import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.*;
+
+/**
+ * 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 MetricsGroupViewDataSource extends RPCDataSource<MetricDisplaySummary, Criteria> {
+
+ private static final int NUMBER_OF_METRIC_POINTS = 60;
+
+ private final ResourceGroup resourceGroup;
+ private List<MetricDisplaySummary> metricDisplaySummaries;
+ private List<List<MeasurementDataNumericHighLowComposite>> metricsDataList;
+ private int[] definitionArrayIds;
+
+ public MetricsGroupViewDataSource(ResourceGroup resourceGroup) {
+ this.resourceGroup = resourceGroup;
+ }
+
+ /**
+ * 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(SPARKLINE.getValue(), 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_" + resourceGroup.getId() + "-"
+ + record.getAttributeAsInt(METRIC_DEF_ID.getValue()) + "' class='dynamicsparkline' width='70' "
+ + "values='" + record.getAttribute(SPARKLINE.getValue()) + "'></span>";
+ return contents;
+
+ }
+ });
+
+ sparklineField.setWidth(80);
+ fields.add(sparklineField);
+
+ ListGridField nameField = new ListGridField(METRIC_LABEL.getValue(), METRIC_LABEL.getLabel());
+ nameField.setWidth("30%");
+ fields.add(nameField);
+
+ ListGridField minField = new ListGridField(MIN_VALUE.getValue(), MIN_VALUE.getLabel());
+ minField.setWidth("15%");
+ fields.add(minField);
+
+ ListGridField maxField = new ListGridField(MAX_VALUE.getValue(), MAX_VALUE.getLabel());
+ maxField.setWidth("15%");
+ fields.add(maxField);
+
+ ListGridField avgField = new ListGridField(AVG_VALUE.getValue(), AVG_VALUE.getLabel());
+ avgField.setWidth("15%");
+ fields.add(avgField);
+
+ ListGridField alertsField = new ListGridField(ALERT_COUNT.getValue(), ALERT_COUNT.getLabel());
+ 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(SPARKLINE.getValue(), getCsvMetricsForSparkline(from.getDefinitionId()));
+ record.setAttribute(METRIC_LABEL.getValue(), from.getLabel());
+ record.setAttribute(ALERT_COUNT.getValue(), String.valueOf(from.getAlertCount()));
+ record.setAttribute(MIN_VALUE.getValue(), getMetricStringValue(from.getMinMetric()));
+ record.setAttribute(MAX_VALUE.getValue(), getMetricStringValue(from.getMaxMetric()));
+ record.setAttribute(AVG_VALUE.getValue(), getMetricStringValue(from.getAvgMetric()));
+ record.setAttribute(METRIC_DEF_ID.getValue(), from.getDefinitionId());
+ record.setAttribute(METRIC_SCHEDULE_ID.getValue(), from.getScheduleId());
+ record.setAttribute(METRIC_UNITS.getValue(), from.getUnits());
+ record.setAttribute(METRIC_NAME.getValue(), from.getMetricName());
+ record.setAttribute(RESOURCE_GROUP_ID.getValue(), resourceGroup.getId());
+ return record;
+ }
+
+ private String getCsvMetricsForSparkline(int definitionId) {
+ StringBuilder sb = new StringBuilder();
+ List<MeasurementDataNumericHighLowComposite> selectedMetricsList = getMeasurementsForMeasurementDefId(definitionId);
+
+ for (MeasurementDataNumericHighLowComposite measurementData : selectedMetricsList) {
+ if (!Double.isNaN(measurementData.getValue())) {
+ sb.append((int) measurementData.getValue());
+ sb.append(",");
+ }
+ }
+
+ if (sb.toString().endsWith(",")) {
+ sb.setLength(sb.length() - 1);
+ }
+ // handle the case where we have just installed the server so not much history
+ // and our date range is set such that only one value returns which the
+ // sparkline graph will not plot anything, so we need at least 2 values
+ if (!sb.toString().contains(",")) {
+ // append another value just so we have 2 values and it will graph
+ return "0," + sb.toString();
+ }
+
+ return sb.toString();
+ }
+
+ private 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) {
+
+ // This latch is the last thing that gets executed after we have executed the
+ // 1 query
+ final CountDownLatch countDownLatch = CountDownLatch.create(1, new Command() {
+
+ @Override
+ public void execute() {
+
+ // NOTE: this runs after the queryMetricDisplaySummaries is complete
+ queryGroupMetrics(resourceGroup, request, response);
+ }
+ });
+
+ organizeMeasurementDefinitionOrder(resourceGroup);
+ queryMetricDisplaySummaries(definitionArrayIds, CustomDateRangeState.getInstance().getStartTime(),
+ CustomDateRangeState.getInstance().getEndTime(), countDownLatch);
+
+ }
+
+ private void queryGroupMetrics(final ResourceGroup resourceGroup, final DSRequest request, final DSResponse response) {
+
+ GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroup(resourceGroup.getId(),
+ definitionArrayIds, CustomDateRangeState.getInstance().getStartTime(),
+ CustomDateRangeState.getInstance().getEndTime(), 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 [" + resourceGroup.getId()
+ + "]:" + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(List<List<MeasurementDataNumericHighLowComposite>> measurementDataList) {
+ if (null != measurementDataList && !measurementDataList.isEmpty()) {
+ metricsDataList = measurementDataList;
+ response.setData(buildRecords(metricDisplaySummaries));
+ processResponse(request.getRequestId(), response);
+ new Timer() {
+ @Override
+ public void run() {
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
+ }
+ }
+ });
+
+ }
+
+ private void organizeMeasurementDefinitionOrder(ResourceGroup resourceGroup) {
+ Set<MeasurementDefinition> definitions = getMetricDefinitions(resourceGroup);
+
+ //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();
+ }
+ }
+
+ private void queryMetricDisplaySummaries(int[] measurementDefIds, Long startTime, Long endTime,
+ final CountDownLatch countDownLatch) {
+ GWTServiceLookup.getMeasurementChartsService().getMetricDisplaySummariesForCompatibleGroup(
+ resourceGroup.getId(), measurementDefIds, startTime, endTime, false,
+ 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();
+ }
+ }
+
+ );
+ }
+
+ private void setMetricDisplaySummaries(List<MetricDisplaySummary> metricDisplaySummaries) {
+ this.metricDisplaySummaries = metricDisplaySummaries;
+ }
+
+ private Set<MeasurementDefinition> getMetricDefinitions(ResourceGroup resourceGroup) {
+ Set<MeasurementDefinition> definitions = new HashSet<MeasurementDefinition>();
+ for (MeasurementDefinition measurementDefinition : resourceGroup.getResourceType().getMetricDefinitions()) {
+ if (measurementDefinition.getDataType() == MEASUREMENT || measurementDefinition.getDataType() == COMPLEX) {
+ definitions.add(measurementDefinition);
+ }
+ }
+ return definitions;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricAvailabilityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricAvailabilityView.java
new file mode 100644
index 0000000..4b542c9
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricAvailabilityView.java
@@ -0,0 +1,223 @@
+/*
+ * 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.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.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementUnits;
+import org.rhq.core.domain.resource.composite.ResourceAvailabilitySummary;
+import org.rhq.coregui.client.CoreGUI;
+import org.rhq.coregui.client.components.table.TimestampCellFormatter;
+import org.rhq.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.coregui.client.util.MeasurementConverterClient;
+import org.rhq.coregui.client.util.enhanced.EnhancedVLayout;
+
+/**
+ * This shows the availability history for a resource.
+ *
+ * @author Jay Shaughnessy
+ * @author John Mazzitelli
+ * @author Mike Thompson
+ */
+public class MetricAvailabilityView extends EnhancedVLayout {
+
+ private int resourceId;
+ 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 MetricAvailabilityView(int resourceId) {
+ super();
+
+ this.resourceId = resourceId;
+
+ 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.common_title_availability());
+ availField.setWrapTitle(false);
+ prepareTooltip(availField, MSG.view_resource_monitor_availability_tooltip_up());
+
+ 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.common_status_avail_down_lower());
+ downField.setWrapTitle(false);
+ prepareTooltip(downField, MSG.view_resource_monitor_availability_tooltip_down());
+
+ 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.common_status_avail_disabled_lower());
+ disabledField.setWrapTitle(false);
+ prepareTooltip(disabledField, MSG.view_resource_monitor_availability_tooltip_disabled());
+
+ 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(resourceId,
+ new AsyncCallback<ResourceAvailabilitySummary>() {
+
+ @Override
+ public void onSuccess(ResourceAvailabilitySummary result) {
+
+ currentField.setValue(MSG.view_resource_monitor_availability_currentStatus_value(
+ getAvailabilityTypeMessage(result.getCurrent()),
+ 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 String getAvailabilityTypeMessage(AvailabilityType availabilityType) {
+ switch (availabilityType) {
+ case UP:
+ return MSG.common_status_avail_up();
+ case DOWN:
+ return MSG.common_status_avail_down();
+ case DISABLED:
+ return MSG.common_status_avail_disabled();
+ case UNKNOWN:
+ default:
+ return MSG.common_status_avail_unknown();
+ }
+ }
+
+ 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/coregui/client/inventory/resource/detail/monitoring/table/MetricsGridFieldName.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsGridFieldName.java
new file mode 100644
index 0000000..f912dee
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsGridFieldName.java
@@ -0,0 +1,63 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2014 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.coregui.client.inventory.resource.detail.monitoring.table;
+
+import static org.rhq.core.domain.measurement.ui.MetricDisplayConstants.AVERAGE_KEY;
+import static org.rhq.core.domain.measurement.ui.MetricDisplayConstants.MAX_KEY;
+import static org.rhq.core.domain.measurement.ui.MetricDisplayConstants.MIN_KEY;
+
+import org.rhq.coregui.client.CoreGUI;
+
+/**
+ * Typesafe field names used in consolidated metrics screen grids for Resource and ResourceGroup.
+ * Also associates the proper label with the value.
+ *
+ * @author Mike Thompson
+ */
+@SuppressWarnings("GwtInconsistentSerializableClass")
+public enum MetricsGridFieldName {
+
+ SPARKLINE("sparkline"), METRIC_LABEL("label", CoreGUI.getMessages().common_title_name()), ALERT_COUNT("alertCount",
+ CoreGUI.getMessages().common_title_alerts()), MAX_VALUE(MAX_KEY, CoreGUI.getMessages()
+ .common_title_monitor_maximum()), MIN_VALUE(MIN_KEY, CoreGUI.getMessages().common_title_monitor_minimum()), AVG_VALUE(
+ AVERAGE_KEY, CoreGUI.getMessages().common_title_monitor_average()), METRIC_DEF_ID("defId"), METRIC_SCHEDULE_ID(
+ "schedId"), METRIC_UNITS("units"), METRIC_NAME("name"), RESOURCE_GROUP_ID("resourceGroupId"),
+ RESOURCE_ID("resourceId"), LIVE_VALUE("live", CoreGUI.getMessages().view_resource_monitor_table_live());
+
+ private final String value;
+ private final String label;
+
+ MetricsGridFieldName(String value, String label) {
+ this.value = value;
+ this.label = label;
+ }
+
+ MetricsGridFieldName(String value) {
+ this.value = value;
+ this.label = "";
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java
index efba122..7e84c3d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsResourceView.java
@@ -41,7 +41,6 @@ import org.rhq.coregui.client.inventory.common.graph.graphtype.AvailabilityOverU
import org.rhq.coregui.client.inventory.resource.detail.monitoring.ExpandedRowsMomento;
import org.rhq.coregui.client.inventory.resource.detail.monitoring.avail.AvailabilityD3GraphView;
import org.rhq.coregui.client.util.BrowserUtility;
-import org.rhq.coregui.client.util.Log;
import org.rhq.coregui.client.util.async.CountDownLatch;
import org.rhq.coregui.client.util.enhanced.EnhancedHLayout;
@@ -87,7 +86,7 @@ public class MetricsResourceView extends AbstractD3GraphListView implements
this.resource = resource;
metricsTableView = new MetricsTableView(resource, this, expandedRows);
- final ResourceMetricAvailabilityView availabilityDetails = new ResourceMetricAvailabilityView(resource);
+ final MetricAvailabilityView availabilityDetails = new MetricAvailabilityView(resource.getId());
availabilityDetails.hide();
metricsTableView.setHeight100();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
index 63a6619..6f0f7f7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
@@ -74,6 +74,8 @@ import org.rhq.coregui.client.util.BrowserUtility;
import org.rhq.coregui.client.util.Log;
import org.rhq.coregui.client.util.message.Message;
+import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.*;
+
/**
* Views a resource's metrics in a tabular view with sparkline graph and optional detailed d3 graph.
*
@@ -125,10 +127,8 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
addToDashboardButton.enable();
ListGridRecord selectedRecord = selectionEvent.getSelectedRecord();
if (null != selectedRecord) {
- //Log.debug("Selected Metric Label: "
- // + selectedRecord.getAttribute(MetricsViewDataSource.FIELD_METRIC_LABEL));
- selectedMetricDefinitionId = selectedRecord
- .getAttributeAsInt(MetricsViewDataSource.FIELD_METRIC_DEF_ID);
+ selectedMetricDefinitionId = selectedRecord.getAttributeAsInt(METRIC_DEF_ID
+ .getValue());
}
}
});
@@ -176,7 +176,7 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
if (measurementDefinition.getId() == selectedMetricDefinitionId) {
Log.debug("Add to Dashboard -- Storing: " + measurementDefinition.getDisplayName() + " in "
+ selectedDashboard.getName());
- storeDashboardMetric(selectedDashboard, resource, measurementDefinition);
+ storeDashboardMetric(selectedDashboard, resource.getId(), measurementDefinition);
break;
}
}
@@ -233,11 +233,11 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
});
}
- private void storeDashboardMetric(Dashboard dashboard, Resource resource, MeasurementDefinition definition) {
+ private void storeDashboardMetric(Dashboard dashboard, int resourceId, MeasurementDefinition definition) {
DashboardPortlet dashboardPortlet = new DashboardPortlet(MSG.view_tree_common_contextMenu_resourceGraph(),
- ResourceD3GraphPortlet.KEY, 200);
+ ResourceD3GraphPortlet.KEY, 260);
dashboardPortlet.getConfiguration().put(
- new PropertySimple(ResourceD3GraphPortlet.CFG_RESOURCE_ID, resource.getId()));
+ new PropertySimple(ResourceD3GraphPortlet.CFG_RESOURCE_ID, resourceId));
dashboardPortlet.getConfiguration().put(
new PropertySimple(ResourceD3GraphPortlet.CFG_DEFINITION_ID, definition.getId()));
@@ -278,7 +278,7 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
@Override
public void onRecordExpand(RecordExpandEvent recordExpandEvent) {
metricsTableView.expandedRows.add(recordExpandEvent.getRecord().getAttributeAsInt(
- MetricsViewDataSource.FIELD_METRIC_DEF_ID));
+ METRIC_DEF_ID.getValue()));
refreshData();
}
@@ -287,7 +287,7 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
@Override
public void onRecordCollapse(RecordCollapseEvent recordCollapseEvent) {
metricsTableView.expandedRows.remove(recordCollapseEvent.getRecord().getAttributeAsInt(
- MetricsViewDataSource.FIELD_METRIC_DEF_ID));
+ METRIC_DEF_ID.getValue()));
refresh();
new Timer() {
@Override
@@ -321,7 +321,7 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
ListGridRecord listGridRecord = getRecord(i);
if (null != listGridRecord) {
int metricDefinitionId = listGridRecord
- .getAttributeAsInt(MetricsViewDataSource.FIELD_METRIC_DEF_ID);
+ .getAttributeAsInt(METRIC_DEF_ID.getValue());
if (null != metricsTableView && null != expandedRows
&& metricsTableView.expandedRows.contains(metricDefinitionId)) {
expandRecord(listGridRecord);
@@ -330,18 +330,14 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
}
}
- public void expandOpenedRows(Set<Integer> selectedRows) {
- expandedRows = selectedRows;
- expandOpenedRows();
- }
@Override
/**
* If you expand a grid row then create a graph.
*/
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);
+ final Integer definitionId = record.getAttributeAsInt(METRIC_DEF_ID.getValue());
+ final Integer resourceId = record.getAttributeAsInt(RESOURCE_ID.getValue());
VLayout vLayout = new VLayout();
vLayout.setPadding(5);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java
index 4c9c7c1..248eee0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java
@@ -61,6 +61,7 @@ import org.rhq.coregui.client.util.RPCDataSource;
import org.rhq.coregui.client.util.async.Command;
import org.rhq.coregui.client.util.async.CountDownLatch;
import org.rhq.coregui.client.util.preferences.MeasurementUserPreferences;
+import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.*;
/**
* A simple data source to read in metric data summaries for a resource.
@@ -75,19 +76,6 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
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_LIVE_VALUE = "live";
- 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;
@@ -111,7 +99,7 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
public ArrayList<ListGridField> getListGridFields() {
ArrayList<ListGridField> fields = new ArrayList<ListGridField>(7);
- ListGridField sparklineField = new ListGridField(FIELD_SPARKLINE, MSG.chart_metrics_sparkline_header());
+ ListGridField sparklineField = new ListGridField(SPARKLINE.getValue(), MSG.chart_metrics_sparkline_header());
sparklineField.setCellFormatter(new CellFormatter() {
@Override
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
@@ -119,8 +107,8 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
return "";
}
String contents = "<span id='sparkline_" + resource.getId() + "-"
- + record.getAttributeAsInt(FIELD_METRIC_DEF_ID) + "' class='dynamicsparkline' width='70' "
- + "values='" + record.getAttribute(FIELD_SPARKLINE) + "'></span>";
+ + record.getAttributeAsInt(METRIC_DEF_ID.getValue()) + "' class='dynamicsparkline' width='70' "
+ + "values='" + record.getAttribute(SPARKLINE.getValue()) + "'></span>";
return contents;
}
@@ -129,27 +117,27 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
sparklineField.setWidth(80);
fields.add(sparklineField);
- ListGridField nameField = new ListGridField(FIELD_METRIC_LABEL, MSG.common_title_name());
+ ListGridField nameField = new ListGridField(METRIC_LABEL.getValue(), METRIC_LABEL.getLabel());
nameField.setWidth("30%");
fields.add(nameField);
- ListGridField minField = new ListGridField(FIELD_MIN_VALUE, MSG.common_title_monitor_minimum());
+ ListGridField minField = new ListGridField(MIN_VALUE.getValue(), MIN_VALUE.getLabel());
minField.setWidth("15%");
fields.add(minField);
- ListGridField maxField = new ListGridField(FIELD_MAX_VALUE, MSG.common_title_monitor_maximum());
+ ListGridField maxField = new ListGridField(MAX_VALUE.getValue(), MAX_VALUE.getLabel());
maxField.setWidth("15%");
fields.add(maxField);
- ListGridField avgField = new ListGridField(FIELD_AVG_VALUE, MSG.common_title_monitor_average());
+ ListGridField avgField = new ListGridField(AVG_VALUE.getValue(), AVG_VALUE.getLabel());
avgField.setWidth("15%");
fields.add(avgField);
- ListGridField liveField = new ListGridField(FIELD_LIVE_VALUE, MSG.view_resource_monitor_table_live());
+ ListGridField liveField = new ListGridField(LIVE_VALUE.getValue(), LIVE_VALUE.getLabel());
liveField.setWidth("15%");
fields.add(liveField);
- ListGridField alertsField = new ListGridField(FIELD_ALERT_COUNT, MSG.common_title_alerts());
+ ListGridField alertsField = new ListGridField(ALERT_COUNT.getValue(), ALERT_COUNT.getLabel());
alertsField.setWidth("10%");
fields.add(alertsField);
@@ -170,18 +158,18 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
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_LIVE_VALUE, buildLiveValue(from));
- 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());
+ record.setAttribute(SPARKLINE.getValue(), getCsvMetricsForSparkline(from.getDefinitionId()));
+ record.setAttribute(METRIC_LABEL.getValue(), from.getLabel());
+ record.setAttribute(ALERT_COUNT.getValue(), String.valueOf(from.getAlertCount()));
+ record.setAttribute(MIN_VALUE.getValue(), getMetricStringValue(from.getMinMetric()));
+ record.setAttribute(MAX_VALUE.getValue(), getMetricStringValue(from.getMaxMetric()));
+ record.setAttribute(AVG_VALUE.getValue(), getMetricStringValue(from.getAvgMetric()));
+ record.setAttribute(LIVE_VALUE.getValue(), buildLiveValue(from));
+ record.setAttribute(METRIC_DEF_ID.getValue(), from.getDefinitionId());
+ record.setAttribute(METRIC_SCHEDULE_ID.getValue(), from.getScheduleId());
+ record.setAttribute(METRIC_UNITS.getValue(), from.getUnits());
+ record.setAttribute(METRIC_NAME.getValue(), from.getMetricName());
+ record.setAttribute(RESOURCE_ID.getValue(), resource.getId());
return record;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/ResourceMetricAvailabilityView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/ResourceMetricAvailabilityView.java
deleted file mode 100644
index 5919f83..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/ResourceMetricAvailabilityView.java
+++ /dev/null
@@ -1,224 +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.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.AvailabilityType;
-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.coregui.client.CoreGUI;
-import org.rhq.coregui.client.components.table.TimestampCellFormatter;
-import org.rhq.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.coregui.client.util.MeasurementConverterClient;
-import org.rhq.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.common_title_availability());
- availField.setWrapTitle(false);
- prepareTooltip(availField, MSG.view_resource_monitor_availability_tooltip_up());
-
- 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.common_status_avail_down_lower());
- downField.setWrapTitle(false);
- prepareTooltip(downField, MSG.view_resource_monitor_availability_tooltip_down());
-
- 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.common_status_avail_disabled_lower());
- disabledField.setWrapTitle(false);
- prepareTooltip(disabledField, MSG.view_resource_monitor_availability_tooltip_disabled());
-
- 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(
- getAvailabilityTypeMessage(result.getCurrent()),
- 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 String getAvailabilityTypeMessage(AvailabilityType availabilityType) {
- switch (availabilityType) {
- case UP:
- return MSG.common_status_avail_up();
- case DOWN:
- return MSG.common_status_avail_down();
- case DISABLED:
- return MSG.common_status_avail_disabled();
- case UNKNOWN:
- default:
- return MSG.common_status_avail_unknown();
- }
- }
-
- private void prepareTooltip(FormItem item, String tooltip) {
- item.setHoverWidth(400);
- item.setPrompt(tooltip);
- }
-
-}
10 years, 4 months
[rhq] Branch 'mtho11/group-metrics' - 9 commits - modules/enterprise modules/plugins
by mike thompson
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java | 41 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupViewDataSource.java | 62 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/CommonMetricsTableView.java | 404 ----------
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsGridFieldName.java | 63 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java | 28
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java | 56 -
modules/enterprise/remoting/cli/pom.xml | 19
modules/enterprise/remoting/cli/src/etc/Remoting_Setup.txt | 43 -
modules/enterprise/remoting/cli/src/etc/build.xml | 80 -
modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.bat | 16
modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.sh | 18
modules/enterprise/remoting/cli/src/etc/rhq-cli-env.bat | 32
modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh | 40
modules/enterprise/remoting/cli/src/etc/rhq-cli.bat | 51 +
modules/enterprise/remoting/cli/src/etc/rhq-cli.sh | 104 +-
modules/enterprise/remoting/cli/src/etc/toRun.txt | 3
modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/script/ModulesDirectoryScriptSourceProvider.java | 33
modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml | 2
modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/script/ModulesDirectoryScriptSourceProviderTest.java | 67 +
modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheDiscoveryComponent.java | 10
modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationHostDiscoveryComponent.java | 9
22 files changed, 458 insertions(+), 725 deletions(-)
New commits:
commit 203903abf68f5a62a84c52d5d857f1251dcf4fc3
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Fri Dec 13 14:08:13 2013 -0800
[BZ 1034512] Fix bug avail refresh issue when navigating certain paths.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupView.java
index ed26dad..1e07e7a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupView.java
@@ -131,7 +131,6 @@ public class MetricsGroupView extends AbstractD3GraphListView implements
private void addAvailabilityGraph() {
- if(lastResourceGroupId.equals(resourceGroup.getId())) {
expandCollapseHLayout.removeMember(availabilityGraph);
availabilityGraph.destroy();
@@ -141,7 +140,6 @@ public class MetricsGroupView extends AbstractD3GraphListView implements
queryAvailability(EntityContext.forGroup(resourceGroup.getId()), CustomDateRangeState.getInstance().getStartTime(),
CustomDateRangeState.getInstance().getEndTime(), null);
- }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
index ea18153..6f0f7f7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
@@ -176,7 +176,7 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
if (measurementDefinition.getId() == selectedMetricDefinitionId) {
Log.debug("Add to Dashboard -- Storing: " + measurementDefinition.getDisplayName() + " in "
+ selectedDashboard.getName());
- storeDashboardMetric(selectedDashboard, resource, measurementDefinition);
+ storeDashboardMetric(selectedDashboard, resource.getId(), measurementDefinition);
break;
}
}
@@ -233,11 +233,11 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
});
}
- private void storeDashboardMetric(Dashboard dashboard, Resource resource, MeasurementDefinition definition) {
+ private void storeDashboardMetric(Dashboard dashboard, int resourceId, MeasurementDefinition definition) {
DashboardPortlet dashboardPortlet = new DashboardPortlet(MSG.view_tree_common_contextMenu_resourceGraph(),
ResourceD3GraphPortlet.KEY, 260);
dashboardPortlet.getConfiguration().put(
- new PropertySimple(ResourceD3GraphPortlet.CFG_RESOURCE_ID, resource.getId()));
+ new PropertySimple(ResourceD3GraphPortlet.CFG_RESOURCE_ID, resourceId));
dashboardPortlet.getConfiguration().put(
new PropertySimple(ResourceD3GraphPortlet.CFG_DEFINITION_ID, definition.getId()));
commit 83a449919639de7ce158638acdee4ced5b3b9023
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Fri Dec 13 13:59:55 2013 -0800
[BZ 1034512] Fix a refresh issue with the sparkline graph if a graph row is expanded.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java
index 442067a..89d4f67 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java
@@ -19,6 +19,9 @@
package org.rhq.coregui.client.inventory.groups.detail.monitoring.metric;
+import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.METRIC_DEF_ID;
+import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.RESOURCE_GROUP_ID;
+
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
@@ -58,6 +61,7 @@ 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.composite.MeasurementDataNumericHighLowComposite;
+import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.PageList;
import org.rhq.coregui.client.CoreGUI;
@@ -74,9 +78,6 @@ import org.rhq.coregui.client.util.BrowserUtility;
import org.rhq.coregui.client.util.Log;
import org.rhq.coregui.client.util.message.Message;
-import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.METRIC_DEF_ID;
-import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.RESOURCE_GROUP_ID;
-
/**
* Views a resource's metrics in a tabular view with sparkline graph and optional detailed d3 graph.
*
@@ -125,11 +126,12 @@ public class MetricsGroupTableView extends Table<MetricsGroupViewDataSource> imp
metricsTableListGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
@Override
public void onSelectionChanged(SelectionEvent selectionEvent) {
- addToDashboardButton.enable();
- ListGridRecord selectedRecord = selectionEvent.getSelectedRecord();
- if (null != selectedRecord) {
- selectedMetricDefinitionId = selectedRecord
- .getAttributeAsInt(METRIC_DEF_ID.getValue());
+ if (resourceGroup.getGroupCategory() == GroupCategory.COMPATIBLE) {
+ addToDashboardButton.enable();
+ ListGridRecord selectedRecord = selectionEvent.getSelectedRecord();
+ if (null != selectedRecord) {
+ selectedMetricDefinitionId = selectedRecord.getAttributeAsInt(METRIC_DEF_ID.getValue());
+ }
}
}
});
@@ -242,14 +244,15 @@ public class MetricsGroupTableView extends Table<MetricsGroupViewDataSource> imp
ResourceGroupD3GraphPortlet.KEY, 260);
dashboardPortlet.getConfiguration().put(
new PropertySimple(ResourceGroupD3GraphPortlet.CFG_RESOURCE_GROUP_ID, resourceGroupId));
- dashboardPortlet.getConfiguration().put(new PropertySimple(ResourceGroupD3GraphPortlet.CFG_DEFINITION_ID, definition.getId()));
+ dashboardPortlet.getConfiguration().put(
+ new PropertySimple(ResourceGroupD3GraphPortlet.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);
+ caught);
}
public void onSuccess(Dashboard result) {
@@ -288,7 +291,7 @@ public class MetricsGroupTableView extends Table<MetricsGroupViewDataSource> imp
@Override
public void onRecordCollapse(RecordCollapseEvent recordCollapseEvent) {
metricsTableView.expandedRows.remove(recordCollapseEvent.getRecord().getAttributeAsInt(
- METRIC_DEF_ID.getValue()));
+ METRIC_DEF_ID.getValue()));
refresh();
new Timer() {
@Override
@@ -320,8 +323,7 @@ public class MetricsGroupTableView extends Table<MetricsGroupViewDataSource> imp
for (int i = startRow; i < endRow; i++) {
ListGridRecord listGridRecord = getRecord(i);
if (null != listGridRecord) {
- int metricDefinitionId = listGridRecord
- .getAttributeAsInt(METRIC_DEF_ID.getValue());
+ int metricDefinitionId = listGridRecord.getAttributeAsInt(METRIC_DEF_ID.getValue());
if (null != metricsTableView && null != expandedRows
&& metricsTableView.expandedRows.contains(metricDefinitionId)) {
expandRecord(listGridRecord);
@@ -336,8 +338,7 @@ public class MetricsGroupTableView extends Table<MetricsGroupViewDataSource> imp
*/
protected Canvas getExpansionComponent(final ListGridRecord record) {
final Integer definitionId = record.getAttributeAsInt(METRIC_DEF_ID.getValue());
- final Integer resourceGroupId = record
- .getAttributeAsInt(RESOURCE_GROUP_ID.getValue());
+ final Integer resourceGroupId = record.getAttributeAsInt(RESOURCE_GROUP_ID.getValue());
VLayout vLayout = new VLayout();
vLayout.setPadding(5);
@@ -384,7 +385,12 @@ public class MetricsGroupTableView extends Table<MetricsGroupViewDataSource> imp
@Override
public void run() {
graphView.drawJsniChart();
- BrowserUtility.graphSparkLines();
+ new Timer() {
+ @Override
+ public void run() {
+ BrowserUtility.graphSparkLines();
+ }
+ }.schedule(150);
}
}.schedule(150);
commit cf71a218e08650623b2308e6e2dda16906e781a0
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Fri Dec 13 09:47:43 2013 -0800
[BZ 1034512] Replace the grid field name constants with a more type-safe enum.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java
index bd9762b..442067a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupTableView.java
@@ -74,6 +74,9 @@ import org.rhq.coregui.client.util.BrowserUtility;
import org.rhq.coregui.client.util.Log;
import org.rhq.coregui.client.util.message.Message;
+import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.METRIC_DEF_ID;
+import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.RESOURCE_GROUP_ID;
+
/**
* Views a resource's metrics in a tabular view with sparkline graph and optional detailed d3 graph.
*
@@ -125,10 +128,8 @@ public class MetricsGroupTableView extends Table<MetricsGroupViewDataSource> imp
addToDashboardButton.enable();
ListGridRecord selectedRecord = selectionEvent.getSelectedRecord();
if (null != selectedRecord) {
- //Log.debug("Selected Metric Label: "
- // + selectedRecord.getAttribute(MetricsViewDataSource.FIELD_METRIC_LABEL));
selectedMetricDefinitionId = selectedRecord
- .getAttributeAsInt(MetricsGroupViewDataSource.FIELD_METRIC_DEF_ID);
+ .getAttributeAsInt(METRIC_DEF_ID.getValue());
}
}
});
@@ -278,7 +279,7 @@ public class MetricsGroupTableView extends Table<MetricsGroupViewDataSource> imp
@Override
public void onRecordExpand(RecordExpandEvent recordExpandEvent) {
metricsTableView.expandedRows.add(recordExpandEvent.getRecord().getAttributeAsInt(
- MetricsGroupViewDataSource.FIELD_METRIC_DEF_ID));
+ METRIC_DEF_ID.getValue()));
refreshData();
}
@@ -287,7 +288,7 @@ public class MetricsGroupTableView extends Table<MetricsGroupViewDataSource> imp
@Override
public void onRecordCollapse(RecordCollapseEvent recordCollapseEvent) {
metricsTableView.expandedRows.remove(recordCollapseEvent.getRecord().getAttributeAsInt(
- MetricsGroupViewDataSource.FIELD_METRIC_DEF_ID));
+ METRIC_DEF_ID.getValue()));
refresh();
new Timer() {
@Override
@@ -320,7 +321,7 @@ public class MetricsGroupTableView extends Table<MetricsGroupViewDataSource> imp
ListGridRecord listGridRecord = getRecord(i);
if (null != listGridRecord) {
int metricDefinitionId = listGridRecord
- .getAttributeAsInt(MetricsGroupViewDataSource.FIELD_METRIC_DEF_ID);
+ .getAttributeAsInt(METRIC_DEF_ID.getValue());
if (null != metricsTableView && null != expandedRows
&& metricsTableView.expandedRows.contains(metricDefinitionId)) {
expandRecord(listGridRecord);
@@ -334,9 +335,9 @@ public class MetricsGroupTableView extends Table<MetricsGroupViewDataSource> imp
* If you expand a grid row then create a graph.
*/
protected Canvas getExpansionComponent(final ListGridRecord record) {
- final Integer definitionId = record.getAttributeAsInt(MetricsGroupViewDataSource.FIELD_METRIC_DEF_ID);
+ final Integer definitionId = record.getAttributeAsInt(METRIC_DEF_ID.getValue());
final Integer resourceGroupId = record
- .getAttributeAsInt(MetricsGroupViewDataSource.FIELD_RESOURCE_GROUP_ID);
+ .getAttributeAsInt(RESOURCE_GROUP_ID.getValue());
VLayout vLayout = new VLayout();
vLayout.setPadding(5);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupViewDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupViewDataSource.java
index 101e70d..a5f1353 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupViewDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupViewDataSource.java
@@ -19,9 +19,6 @@
package org.rhq.coregui.client.inventory.groups.detail.monitoring.metric;
-import static org.rhq.core.domain.measurement.DataType.COMPLEX;
-import static org.rhq.core.domain.measurement.DataType.MEASUREMENT;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -41,7 +38,6 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.criteria.Criteria;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
-import org.rhq.core.domain.measurement.ui.MetricDisplayConstants;
import org.rhq.core.domain.measurement.ui.MetricDisplaySummary;
import org.rhq.core.domain.measurement.ui.MetricDisplayValue;
import org.rhq.core.domain.resource.group.ResourceGroup;
@@ -55,6 +51,10 @@ import org.rhq.coregui.client.util.RPCDataSource;
import org.rhq.coregui.client.util.async.Command;
import org.rhq.coregui.client.util.async.CountDownLatch;
+import static org.rhq.core.domain.measurement.DataType.COMPLEX;
+import static org.rhq.core.domain.measurement.DataType.MEASUREMENT;
+import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.*;
+
/**
* 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
@@ -68,18 +68,6 @@ public class MetricsGroupViewDataSource extends RPCDataSource<MetricDisplaySumma
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_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_GROUP_ID = "resourceGroupId";
-
private final ResourceGroup resourceGroup;
private List<MetricDisplaySummary> metricDisplaySummaries;
private List<List<MeasurementDataNumericHighLowComposite>> metricsDataList;
@@ -98,7 +86,7 @@ public class MetricsGroupViewDataSource extends RPCDataSource<MetricDisplaySumma
public ArrayList<ListGridField> getListGridFields() {
ArrayList<ListGridField> fields = new ArrayList<ListGridField>(7);
- ListGridField sparklineField = new ListGridField(FIELD_SPARKLINE, MSG.chart_metrics_sparkline_header());
+ ListGridField sparklineField = new ListGridField(SPARKLINE.getValue(), MSG.chart_metrics_sparkline_header());
sparklineField.setCellFormatter(new CellFormatter() {
@Override
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
@@ -106,8 +94,8 @@ public class MetricsGroupViewDataSource extends RPCDataSource<MetricDisplaySumma
return "";
}
String contents = "<span id='sparkline_" + resourceGroup.getId() + "-"
- + record.getAttributeAsInt(FIELD_METRIC_DEF_ID) + "' class='dynamicsparkline' width='70' "
- + "values='" + record.getAttribute(FIELD_SPARKLINE) + "'></span>";
+ + record.getAttributeAsInt(METRIC_DEF_ID.getValue()) + "' class='dynamicsparkline' width='70' "
+ + "values='" + record.getAttribute(SPARKLINE.getValue()) + "'></span>";
return contents;
}
@@ -116,23 +104,23 @@ public class MetricsGroupViewDataSource extends RPCDataSource<MetricDisplaySumma
sparklineField.setWidth(80);
fields.add(sparklineField);
- ListGridField nameField = new ListGridField(FIELD_METRIC_LABEL, MSG.common_title_name());
+ ListGridField nameField = new ListGridField(METRIC_LABEL.getValue(), METRIC_LABEL.getLabel());
nameField.setWidth("30%");
fields.add(nameField);
- ListGridField minField = new ListGridField(FIELD_MIN_VALUE, MSG.common_title_monitor_minimum());
+ ListGridField minField = new ListGridField(MIN_VALUE.getValue(), MIN_VALUE.getLabel());
minField.setWidth("15%");
fields.add(minField);
- ListGridField maxField = new ListGridField(FIELD_MAX_VALUE, MSG.common_title_monitor_maximum());
+ ListGridField maxField = new ListGridField(MAX_VALUE.getValue(), MAX_VALUE.getLabel());
maxField.setWidth("15%");
fields.add(maxField);
- ListGridField avgField = new ListGridField(FIELD_AVG_VALUE, MSG.common_title_monitor_average());
+ ListGridField avgField = new ListGridField(AVG_VALUE.getValue(), AVG_VALUE.getLabel());
avgField.setWidth("15%");
fields.add(avgField);
- ListGridField alertsField = new ListGridField(FIELD_ALERT_COUNT, MSG.common_title_alerts());
+ ListGridField alertsField = new ListGridField(ALERT_COUNT.getValue(), ALERT_COUNT.getLabel());
alertsField.setWidth("10%");
fields.add(alertsField);
@@ -153,17 +141,17 @@ public class MetricsGroupViewDataSource extends RPCDataSource<MetricDisplaySumma
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_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_GROUP_ID, resourceGroup.getId());
+ record.setAttribute(SPARKLINE.getValue(), getCsvMetricsForSparkline(from.getDefinitionId()));
+ record.setAttribute(METRIC_LABEL.getValue(), from.getLabel());
+ record.setAttribute(ALERT_COUNT.getValue(), String.valueOf(from.getAlertCount()));
+ record.setAttribute(MIN_VALUE.getValue(), getMetricStringValue(from.getMinMetric()));
+ record.setAttribute(MAX_VALUE.getValue(), getMetricStringValue(from.getMaxMetric()));
+ record.setAttribute(AVG_VALUE.getValue(), getMetricStringValue(from.getAvgMetric()));
+ record.setAttribute(METRIC_DEF_ID.getValue(), from.getDefinitionId());
+ record.setAttribute(METRIC_SCHEDULE_ID.getValue(), from.getScheduleId());
+ record.setAttribute(METRIC_UNITS.getValue(), from.getUnits());
+ record.setAttribute(METRIC_NAME.getValue(), from.getMetricName());
+ record.setAttribute(RESOURCE_GROUP_ID.getValue(), resourceGroup.getId());
return record;
}
@@ -231,7 +219,7 @@ public class MetricsGroupViewDataSource extends RPCDataSource<MetricDisplaySumma
}
});
- organizeMeasurementDefitionOrder(resourceGroup);
+ organizeMeasurementDefinitionOrder(resourceGroup);
queryMetricDisplaySummaries(definitionArrayIds, CustomDateRangeState.getInstance().getStartTime(),
CustomDateRangeState.getInstance().getEndTime(), countDownLatch);
@@ -267,7 +255,7 @@ public class MetricsGroupViewDataSource extends RPCDataSource<MetricDisplaySumma
}
- private void organizeMeasurementDefitionOrder(ResourceGroup resourceGroup) {
+ private void organizeMeasurementDefinitionOrder(ResourceGroup resourceGroup) {
Set<MeasurementDefinition> definitions = getMetricDefinitions(resourceGroup);
//build id mapping for measurementDefinition instances Ex. Free Memory -> MeasurementDefinition[100071]
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/CommonMetricsTableView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/CommonMetricsTableView.java
deleted file mode 100644
index c814b97..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/CommonMetricsTableView.java
+++ /dev/null
@@ -1,404 +0,0 @@
-/*
- * 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.coregui.client.inventory.resource.detail.monitoring.table;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-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.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.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 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.measurement.composite.MeasurementDataNumericHighLowComposite;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.coregui.client.CoreGUI;
-import org.rhq.coregui.client.components.table.Table;
-import org.rhq.coregui.client.dashboard.portlets.inventory.resource.graph.ResourceD3GraphPortlet;
-import org.rhq.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.coregui.client.inventory.common.AbstractD3GraphListView;
-import org.rhq.coregui.client.inventory.common.graph.CustomDateRangeState;
-import org.rhq.coregui.client.inventory.common.graph.MetricGraphData;
-import org.rhq.coregui.client.inventory.common.graph.Refreshable;
-import org.rhq.coregui.client.inventory.common.graph.graphtype.StackedBarMetricGraphImpl;
-import org.rhq.coregui.client.inventory.resource.detail.monitoring.MetricD3Graph;
-import org.rhq.coregui.client.util.BrowserUtility;
-import org.rhq.coregui.client.util.Log;
-import org.rhq.coregui.client.util.message.Message;
-
-/**
- * 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 CommonMetricsTableView<T extends Resource> extends Table<MetricsViewDataSource> implements Refreshable {
-
- private final T resource;
- private final AbstractD3GraphListView abstractD3GraphListView;
- private ToolStrip toolStrip;
- private SelectItem dashboardSelectItem;
- private Dashboard selectedDashboard;
- private IButton addToDashboardButton;
- private LinkedHashMap<String, String> dashboardMenuMap;
- private LinkedHashMap<Integer, Dashboard> dashboardMap;
- private Set<Integer> expandedRows;
- private MetricsTableListGrid metricsTableListGrid;
- private int selectedMetricDefinitionId;
-
- public CommonMetricsTableView(T resource, AbstractD3GraphListView abstractD3GraphListView,
- Set<Integer> expandedRows) {
- super();
- this.resource = resource;
- this.abstractD3GraphListView = abstractD3GraphListView;
- dashboardMenuMap = new LinkedHashMap<String, String>();
- dashboardMap = new LinkedHashMap<Integer, Dashboard>();
- setDataSource(new MetricsViewDataSource(resource));
- this.expandedRows = expandedRows;
- }
-
- @Override
- protected void onInit() {
- super.onInit();
- }
-
- /**
- * 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);
- metricsTableListGrid.addSelectionChangedHandler(new SelectionChangedHandler() {
- @Override
- public void onSelectionChanged(SelectionEvent selectionEvent) {
- addToDashboardButton.enable();
- ListGridRecord selectedRecord = selectionEvent.getSelectedRecord();
- if (null != selectedRecord) {
- //Log.debug("Selected Metric Label: "
- // + selectedRecord.getAttribute(MetricsViewDataSource.FIELD_METRIC_LABEL));
- selectedMetricDefinitionId = selectedRecord
- .getAttributeAsInt(MetricsViewDataSource.FIELD_METRIC_DEF_ID);
- }
- }
- });
-
- if (null == toolStrip) {
- toolStrip = createToolstrip();
- }
- addExtraWidget(toolStrip, false);
- addToDashboardButton.disable();
- return metricsTableListGrid;
- }
-
- protected void configureTable() {
- ArrayList<ListGridField> fields = getDataSource().getListGridFields();
- setListGridFields(fields.toArray(new ListGridField[0]));
- }
-
- private ToolStrip createToolstrip() {
- toolStrip = new ToolStrip();
- toolStrip.setWidth(300);
- toolStrip.setMembersMargin(15);
- toolStrip.setPadding(5);
- toolStrip.addSpacer(10);
- addToDashboardButton = new IButton(MSG.chart_metrics_add_to_dashboard_button());
- addToDashboardButton.setWidth(80);
- dashboardSelectItem = new SelectItem();
- dashboardSelectItem.setTitle(MSG.chart_metrics_add_to_dashboard_label());
- dashboardSelectItem.setWidth(240);
- dashboardSelectItem.setWrapTitle(false);
- populateDashboardMenu();
- toolStrip.addFormItem(dashboardSelectItem);
- toolStrip.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) {
- for (MeasurementDefinition measurementDefinition : resource.getResourceType().getMetricDefinitions()) {
- if (measurementDefinition.getId() == selectedMetricDefinitionId) {
- Log.debug("Add to Dashboard -- Storing: " + measurementDefinition.getDisplayName() + " in "
- + selectedDashboard.getName());
- storeDashboardMetric(selectedDashboard, resource, measurementDefinition);
- break;
- }
- }
- }
- });
- return toolStrip;
- }
-
- @Override
- /**
- * Redraw Graphs in this context means to refresh the table and redraw open graphs.
- */
- public void refreshData() {
- new Timer() {
- @Override
- public void run() {
- metricsTableListGrid.expandOpenedRows();
- BrowserUtility.graphSparkLines();
- }
- }.schedule(150);
-
- }
-
- @Override
- public void refresh() {
- super.refresh(false);
- metricsTableListGrid.expandOpenedRows();
- }
-
- private 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) {
- if (dashboards.size() > 0) {
- for (final Dashboard dashboard : dashboards) {
- dashboardMenuMap.put(String.valueOf(dashboard.getId()), dashboard.getName());
- dashboardMap.put(dashboard.getId(), dashboard);
- }
- selectedDashboard = dashboards.get(0);
- dashboardSelectItem.setValueMap(dashboardMenuMap);
- dashboardSelectItem.setValue(selectedDashboard.getId());
- }
- }
- });
- }
-
- private void storeDashboardMetric(Dashboard dashboard, Resource resource, MeasurementDefinition definition) {
- DashboardPortlet dashboardPortlet = new DashboardPortlet(MSG.view_tree_common_contextMenu_resourceGraph(),
- ResourceD3GraphPortlet.KEY, 200);
- 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));
- }
- });
- }
-
- public class MetricsTableListGrid extends ListGrid {
-
- private static final int TREEVIEW_DETAIL_CHART_HEIGHT = 205;
- private static final int NUM_METRIC_POINTS = 60;
- final CommonMetricsTableView metricsTableView;
- private Resource resource;
-
- public MetricsTableListGrid(final CommonMetricsTableView metricsTableView, final Resource resource) {
- super();
- this.resource = resource;
- this.metricsTableView = metricsTableView;
- setCanExpandRecords(true);
- setSelectionType(SelectionStyle.SINGLE);
- 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));
- refreshData();
- }
-
- });
- addRecordCollapseHandler(new RecordCollapseHandler() {
- @Override
- public void onRecordCollapse(RecordCollapseEvent recordCollapseEvent) {
- metricsTableView.expandedRows.remove(recordCollapseEvent.getRecord().getAttributeAsInt(
- MetricsViewDataSource.FIELD_METRIC_DEF_ID));
- refresh();
- new Timer() {
- @Override
- public void run() {
- BrowserUtility.graphSparkLines();
- }
- }.schedule(150);
- }
- });
- addSortChangedHandler(new SortChangedHandler() {
- @Override
- public void onSortChanged(SortEvent sortEvent) {
- refreshData();
- }
- });
-
- addDataArrivedHandler(new DataArrivedHandler() {
- @Override
- public void onDataArrived(DataArrivedEvent dataArrivedEvent) {
- expandOpenedRows();
- }
- });
-
- }
-
- public void expandOpenedRows() {
-
- int startRow = 0;
- int endRow = this.getRecords().length;
- for (int i = startRow; i < endRow; i++) {
- ListGridRecord listGridRecord = getRecord(i);
- if (null != listGridRecord) {
- int metricDefinitionId = listGridRecord
- .getAttributeAsInt(MetricsViewDataSource.FIELD_METRIC_DEF_ID);
- if (null != metricsTableView && null != expandedRows
- && metricsTableView.expandedRows.contains(metricDefinitionId)) {
- expandRecord(listGridRecord);
- }
- }
- }
- }
-
- public void expandOpenedRows(Set<Integer> selectedRows) {
- expandedRows = selectedRows;
- expandOpenedRows();
- }
-
- @Override
- /**
- * If you expand a grid row then create a graph.
- */
- 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,
- CustomDateRangeState.getInstance().getStartTime(), CustomDateRangeState.getInstance().getEndTime(),
- 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/coregui/client/inventory/resource/detail/monitoring/table/MetricsGridFieldName.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsGridFieldName.java
new file mode 100644
index 0000000..f912dee
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsGridFieldName.java
@@ -0,0 +1,63 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2014 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.coregui.client.inventory.resource.detail.monitoring.table;
+
+import static org.rhq.core.domain.measurement.ui.MetricDisplayConstants.AVERAGE_KEY;
+import static org.rhq.core.domain.measurement.ui.MetricDisplayConstants.MAX_KEY;
+import static org.rhq.core.domain.measurement.ui.MetricDisplayConstants.MIN_KEY;
+
+import org.rhq.coregui.client.CoreGUI;
+
+/**
+ * Typesafe field names used in consolidated metrics screen grids for Resource and ResourceGroup.
+ * Also associates the proper label with the value.
+ *
+ * @author Mike Thompson
+ */
+@SuppressWarnings("GwtInconsistentSerializableClass")
+public enum MetricsGridFieldName {
+
+ SPARKLINE("sparkline"), METRIC_LABEL("label", CoreGUI.getMessages().common_title_name()), ALERT_COUNT("alertCount",
+ CoreGUI.getMessages().common_title_alerts()), MAX_VALUE(MAX_KEY, CoreGUI.getMessages()
+ .common_title_monitor_maximum()), MIN_VALUE(MIN_KEY, CoreGUI.getMessages().common_title_monitor_minimum()), AVG_VALUE(
+ AVERAGE_KEY, CoreGUI.getMessages().common_title_monitor_average()), METRIC_DEF_ID("defId"), METRIC_SCHEDULE_ID(
+ "schedId"), METRIC_UNITS("units"), METRIC_NAME("name"), RESOURCE_GROUP_ID("resourceGroupId"),
+ RESOURCE_ID("resourceId"), LIVE_VALUE("live", CoreGUI.getMessages().view_resource_monitor_table_live());
+
+ private final String value;
+ private final String label;
+
+ MetricsGridFieldName(String value, String label) {
+ this.value = value;
+ this.label = label;
+ }
+
+ MetricsGridFieldName(String value) {
+ this.value = value;
+ this.label = "";
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
index 8c0cc13..ea18153 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsTableView.java
@@ -74,6 +74,8 @@ import org.rhq.coregui.client.util.BrowserUtility;
import org.rhq.coregui.client.util.Log;
import org.rhq.coregui.client.util.message.Message;
+import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.*;
+
/**
* Views a resource's metrics in a tabular view with sparkline graph and optional detailed d3 graph.
*
@@ -125,10 +127,8 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
addToDashboardButton.enable();
ListGridRecord selectedRecord = selectionEvent.getSelectedRecord();
if (null != selectedRecord) {
- //Log.debug("Selected Metric Label: "
- // + selectedRecord.getAttribute(MetricsViewDataSource.FIELD_METRIC_LABEL));
- selectedMetricDefinitionId = selectedRecord
- .getAttributeAsInt(MetricsViewDataSource.FIELD_METRIC_DEF_ID);
+ selectedMetricDefinitionId = selectedRecord.getAttributeAsInt(METRIC_DEF_ID
+ .getValue());
}
}
});
@@ -278,7 +278,7 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
@Override
public void onRecordExpand(RecordExpandEvent recordExpandEvent) {
metricsTableView.expandedRows.add(recordExpandEvent.getRecord().getAttributeAsInt(
- MetricsViewDataSource.FIELD_METRIC_DEF_ID));
+ METRIC_DEF_ID.getValue()));
refreshData();
}
@@ -287,7 +287,7 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
@Override
public void onRecordCollapse(RecordCollapseEvent recordCollapseEvent) {
metricsTableView.expandedRows.remove(recordCollapseEvent.getRecord().getAttributeAsInt(
- MetricsViewDataSource.FIELD_METRIC_DEF_ID));
+ METRIC_DEF_ID.getValue()));
refresh();
new Timer() {
@Override
@@ -321,7 +321,7 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
ListGridRecord listGridRecord = getRecord(i);
if (null != listGridRecord) {
int metricDefinitionId = listGridRecord
- .getAttributeAsInt(MetricsViewDataSource.FIELD_METRIC_DEF_ID);
+ .getAttributeAsInt(METRIC_DEF_ID.getValue());
if (null != metricsTableView && null != expandedRows
&& metricsTableView.expandedRows.contains(metricDefinitionId)) {
expandRecord(listGridRecord);
@@ -330,18 +330,14 @@ public class MetricsTableView extends Table<MetricsViewDataSource> implements Re
}
}
- public void expandOpenedRows(Set<Integer> selectedRows) {
- expandedRows = selectedRows;
- expandOpenedRows();
- }
@Override
/**
* If you expand a grid row then create a graph.
*/
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);
+ final Integer definitionId = record.getAttributeAsInt(METRIC_DEF_ID.getValue());
+ final Integer resourceId = record.getAttributeAsInt(RESOURCE_ID.getValue());
VLayout vLayout = new VLayout();
vLayout.setPadding(5);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java
index 4c9c7c1..248eee0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java
@@ -61,6 +61,7 @@ import org.rhq.coregui.client.util.RPCDataSource;
import org.rhq.coregui.client.util.async.Command;
import org.rhq.coregui.client.util.async.CountDownLatch;
import org.rhq.coregui.client.util.preferences.MeasurementUserPreferences;
+import static org.rhq.coregui.client.inventory.resource.detail.monitoring.table.MetricsGridFieldName.*;
/**
* A simple data source to read in metric data summaries for a resource.
@@ -75,19 +76,6 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
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_LIVE_VALUE = "live";
- 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;
@@ -111,7 +99,7 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
public ArrayList<ListGridField> getListGridFields() {
ArrayList<ListGridField> fields = new ArrayList<ListGridField>(7);
- ListGridField sparklineField = new ListGridField(FIELD_SPARKLINE, MSG.chart_metrics_sparkline_header());
+ ListGridField sparklineField = new ListGridField(SPARKLINE.getValue(), MSG.chart_metrics_sparkline_header());
sparklineField.setCellFormatter(new CellFormatter() {
@Override
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
@@ -119,8 +107,8 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
return "";
}
String contents = "<span id='sparkline_" + resource.getId() + "-"
- + record.getAttributeAsInt(FIELD_METRIC_DEF_ID) + "' class='dynamicsparkline' width='70' "
- + "values='" + record.getAttribute(FIELD_SPARKLINE) + "'></span>";
+ + record.getAttributeAsInt(METRIC_DEF_ID.getValue()) + "' class='dynamicsparkline' width='70' "
+ + "values='" + record.getAttribute(SPARKLINE.getValue()) + "'></span>";
return contents;
}
@@ -129,27 +117,27 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
sparklineField.setWidth(80);
fields.add(sparklineField);
- ListGridField nameField = new ListGridField(FIELD_METRIC_LABEL, MSG.common_title_name());
+ ListGridField nameField = new ListGridField(METRIC_LABEL.getValue(), METRIC_LABEL.getLabel());
nameField.setWidth("30%");
fields.add(nameField);
- ListGridField minField = new ListGridField(FIELD_MIN_VALUE, MSG.common_title_monitor_minimum());
+ ListGridField minField = new ListGridField(MIN_VALUE.getValue(), MIN_VALUE.getLabel());
minField.setWidth("15%");
fields.add(minField);
- ListGridField maxField = new ListGridField(FIELD_MAX_VALUE, MSG.common_title_monitor_maximum());
+ ListGridField maxField = new ListGridField(MAX_VALUE.getValue(), MAX_VALUE.getLabel());
maxField.setWidth("15%");
fields.add(maxField);
- ListGridField avgField = new ListGridField(FIELD_AVG_VALUE, MSG.common_title_monitor_average());
+ ListGridField avgField = new ListGridField(AVG_VALUE.getValue(), AVG_VALUE.getLabel());
avgField.setWidth("15%");
fields.add(avgField);
- ListGridField liveField = new ListGridField(FIELD_LIVE_VALUE, MSG.view_resource_monitor_table_live());
+ ListGridField liveField = new ListGridField(LIVE_VALUE.getValue(), LIVE_VALUE.getLabel());
liveField.setWidth("15%");
fields.add(liveField);
- ListGridField alertsField = new ListGridField(FIELD_ALERT_COUNT, MSG.common_title_alerts());
+ ListGridField alertsField = new ListGridField(ALERT_COUNT.getValue(), ALERT_COUNT.getLabel());
alertsField.setWidth("10%");
fields.add(alertsField);
@@ -170,18 +158,18 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
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_LIVE_VALUE, buildLiveValue(from));
- 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());
+ record.setAttribute(SPARKLINE.getValue(), getCsvMetricsForSparkline(from.getDefinitionId()));
+ record.setAttribute(METRIC_LABEL.getValue(), from.getLabel());
+ record.setAttribute(ALERT_COUNT.getValue(), String.valueOf(from.getAlertCount()));
+ record.setAttribute(MIN_VALUE.getValue(), getMetricStringValue(from.getMinMetric()));
+ record.setAttribute(MAX_VALUE.getValue(), getMetricStringValue(from.getMaxMetric()));
+ record.setAttribute(AVG_VALUE.getValue(), getMetricStringValue(from.getAvgMetric()));
+ record.setAttribute(LIVE_VALUE.getValue(), buildLiveValue(from));
+ record.setAttribute(METRIC_DEF_ID.getValue(), from.getDefinitionId());
+ record.setAttribute(METRIC_SCHEDULE_ID.getValue(), from.getScheduleId());
+ record.setAttribute(METRIC_UNITS.getValue(), from.getUnits());
+ record.setAttribute(METRIC_NAME.getValue(), from.getMetricName());
+ record.setAttribute(RESOURCE_ID.getValue(), resource.getId());
return record;
}
commit 6123aeeb10388f8dec4983d8ac83e80fa46ecfee
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Fri Dec 13 17:39:57 2013 +0100
[BZ 1042892] Don't use ${} notation for shell variables in CLI scripts.
As of BZ 959603, the files are subject to maven resource filtering and
so it can happen that the build server passes a variable to the build
process that clashes with the variable name defined in the script.
(Yes, this actually happened on our Jenkins server that passed
"-DCLASSPATH=" to the maven process for some reason, which resulted in
wonderful corruption of the rhq-cli.sh script).
diff --git a/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh b/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh
index 112ec66..80f24c5 100755
--- a/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh
+++ b/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh
@@ -3,6 +3,14 @@
#===========================================================================
#
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# IMPORTANT: Avoid enclosing shell variables in braces using the ${XXX}
+# notation. This file is subject to maven resource variable expansion
+# during the build and so it can happen that the build environment
+# could corrupt this file by expanding variables that clash with
+# the names defined herein.
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
# RHQ_CLI_DEBUG - If this is defined, the script will emit debug
# messages. It will also enable debug
# messages to be emitted from the cli itself.
@@ -41,7 +49,7 @@
# to the CLI's defaults, then you will want to
# use RHQ_CLI_ADDITIONAL_JAVA_OPTS instead.
#
-#RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true -Drhq.scripting.modules.root-dir=${RHQ_CLI_MODULES_DIR}"
+#RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true -Drhq.scripting.modules.root-dir=$RHQ_CLI_MODULES_DIR"
# RHQ_CLI_JAVA_ENDORSED_DIRS - Java VM command line option to set the
# endorsed dirs for the CLI's VM. If this
diff --git a/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh b/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh
index 8399b50..b0980e6 100644
--- a/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh
+++ b/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh
@@ -11,6 +11,14 @@
# set via rhq-client-env.sh, which is sourced by this script.
# =============================================================================
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+# IMPORTANT: Avoid enclosing shell variables in braces using the ${XXX}
+# notation. This file is subject to maven resource variable expansion
+# during the build and so it can happen that the build environment
+# could corrupt this file by expanding variables that clash with
+# the names defined herein.
+# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
# ----------------------------------------------------------------------
# Subroutine that simply dumps a message iff debug mode is enabled
# ----------------------------------------------------------------------
@@ -42,16 +50,17 @@ esac
_DOLLARZERO=`readlink "$0" 2>/dev/null || echo "$0"`
RHQ_CLI_BIN_DIR_PATH=`dirname "$_DOLLARZERO"`
-if [ -f "${RHQ_CLI_BIN_DIR_PATH}/rhq-cli-env.sh" ]; then
- debug_msg "Loading environment script: ${RHQ_CLI_BIN_DIR_PATH}/rhq-cli-env.sh"
- . "${RHQ_CLI_BIN_DIR_PATH}/rhq-cli-env.sh" $*
+if [ -f "$RHQ_CLI_BIN_DIR_PATH/rhq-cli-env.sh" ]; then
+ debug_msg "Loading environment script: $RHQ_CLI_BIN_DIR_PATH/rhq-cli-env.sh"
+ . "$RHQ_CLI_BIN_DIR_PATH/rhq-cli-env.sh" $*
else
- debug_msg "No environment script found at: ${RHQ_CLI_BIN_DIR_PATH}/rhq-cli-env.sh"
+ debug_msg "No environment script found at: $RHQ_CLI_BIN_DIR_PATH/rhq-cli-env.sh"
fi
# this variable is set during the build and defines the desired default behavior for directory changing
# we do want to change the dir in RHQ, but possibly don't want to do that in JBoss ON for backwards compatibility
# reasons.
+# (yes, this USES ${} in the source (not in the distribution) because we seed the default value from the build)
RHQ_CLI_CHANGE_DIR_ON_START_DEFAULT=${rhq.cli.change-dir-on-start-default}
if [ -z "$RHQ_CLI_CHANGE_DIR_ON_START" ]; then
RHQ_CLI_CHANGE_DIR_ON_START="$RHQ_CLI_CHANGE_DIR_ON_START_DEFAULT"
@@ -61,24 +70,24 @@ fi
# Previous versions always changed directory.
if [ -n "$RHQ_CLI_CHANGE_DIR_ON_START" -a "$RHQ_CLI_CHANGE_DIR_ON_START" != "false" ]; then
if [ -z "$RHQ_CLI_HOME" ]; then
- cd "${RHQ_CLI_BIN_DIR_PATH}/.."
+ cd "$RHQ_CLI_BIN_DIR_PATH/.."
else
- cd "${RHQ_CLI_HOME}" || {
- echo "Cannot go to the RHQ_CLI_HOME directory: ${RHQ_CLI_HOME}"
+ cd "$RHQ_CLI_HOME" || {
+ echo "Cannot go to the RHQ_CLI_HOME directory: $RHQ_CLI_HOME"
exit 1
}
fi
RHQ_CLI_HOME=`pwd`
else
if [ -z "$RHQ_CLI_HOME" ]; then
- RHQ_CLI_HOME="${RHQ_CLI_BIN_DIR_PATH}/.."
+ RHQ_CLI_HOME="$RHQ_CLI_BIN_DIR_PATH/.."
fi
#get an absolute path
RHQ_CLI_HOME=`readlink -f "$RHQ_CLI_HOME"`
if [ ! -d "$RHQ_CLI_HOME" ]; then
- echo "RHQ_CLI_HOME detected or defined as [${RHQ_CLI_HOME}] doesn't seem to exist or is not a directory"
+ echo "RHQ_CLI_HOME detected or defined as [$RHQ_CLI_HOME] doesn't seem to exist or is not a directory"
exit 1
fi
fi
@@ -90,7 +99,7 @@ debug_msg "RHQ_CLI_HOME: $RHQ_CLI_HOME"
# sample modules.
# ----------------------------------------------------------------------
if [ -z "$RHQ_CLI_MODULES_DIR" ]; then
- RHQ_CLI_MODULES_DIR="${RHQ_CLI_HOME}/samples/modules"
+ RHQ_CLI_MODULES_DIR="$RHQ_CLI_HOME/samples/modules"
fi
# ----------------------------------------------------------------------
@@ -110,7 +119,7 @@ fi
if [ -z "$RHQ_CLI_JAVA_EXE_FILE_PATH" ]; then
if [ -z "$RHQ_CLI_JAVA_HOME" ]; then
- RHQ_CLI_JAVA_HOME="${RHQ_CLI_HOME}/jre"
+ RHQ_CLI_JAVA_HOME="$RHQ_CLI_HOME/jre"
if [ -d "$RHQ_CLI_JAVA_HOME" ]; then
debug_msg "Using the embedded JRE"
else
@@ -119,7 +128,7 @@ if [ -z "$RHQ_CLI_JAVA_EXE_FILE_PATH" ]; then
fi
fi
debug_msg "RHQ_CLI_JAVA_HOME: $RHQ_CLI_JAVA_HOME"
- RHQ_CLI_JAVA_EXE_FILE_PATH=${RHQ_CLI_JAVA_HOME}/bin/java
+ RHQ_CLI_JAVA_EXE_FILE_PATH="$RHQ_CLI_JAVA_HOME/bin/java"
fi
debug_msg "RHQ_CLI_JAVA_EXE_FILE_PATH: $RHQ_CLI_JAVA_EXE_FILE_PATH"
@@ -133,14 +142,14 @@ fi
# Prepare the classpath (take into account possible spaces in dir names)
# ----------------------------------------------------------------------
-CLASSPATH="${RHQ_CLI_HOME}/conf"
-_JAR_FILES=`cd "${RHQ_CLI_HOME}/lib";ls -1 *.jar`
+CLASSPATH="$RHQ_CLI_HOME/conf"
+_JAR_FILES=`cd "$RHQ_CLI_HOME/lib";ls -1 *.jar`
for _JAR in $_JAR_FILES ; do
- _JAR="${RHQ_CLI_HOME}/lib/${_JAR}"
+ _JAR="$RHQ_CLI_HOME/lib/$_JAR"
if [ -z "$CLASSPATH" ]; then
- CLASSPATH="${_JAR}"
+ CLASSPATH="$_JAR"
else
- CLASSPATH="${CLASSPATH}:${_JAR}"
+ CLASSPATH="$CLASSPATH:$_JAR"
fi
debug_msg "CLASSPATH entry: $_JAR"
done
@@ -151,7 +160,7 @@ debug_msg "CLASSPATH entry: $_JAR"
# ----------------------------------------------------------------------
if [ -z "$RHQ_CLI_JAVA_OPTS" ]; then
- RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true -Drhq.scripting.modules.root-dir=${RHQ_CLI_MODULES_DIR}"
+ RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true -Drhq.scripting.modules.root-dir=$RHQ_CLI_MODULES_DIR"
fi
debug_msg "RHQ_CLI_JAVA_OPTS: $RHQ_CLI_JAVA_OPTS"
@@ -159,7 +168,7 @@ if [ "$RHQ_CLI_JAVA_ENDORSED_DIRS" = "none" ]; then
debug_msg "Not explicitly setting java.endorsed.dirs"
else
if [ -z "$RHQ_CLI_JAVA_ENDORSED_DIRS" ]; then
- RHQ_CLI_JAVA_ENDORSED_DIRS="${RHQ_CLI_HOME}/lib/endorsed"
+ RHQ_CLI_JAVA_ENDORSED_DIRS="$RHQ_CLI_HOME/lib/endorsed"
fi
# convert the path if on Windows
@@ -167,14 +176,14 @@ else
RHQ_CLI_JAVA_ENDORSED_DIRS=`cygpath --windows --path "$RHQ_CLI_JAVA_ENDORSED_DIRS"`
fi
debug_msg "RHQ_CLI_JAVA_ENDORSED_DIRS: $RHQ_CLI_JAVA_ENDORSED_DIRS"
- _JAVA_ENDORSED_DIRS_OPT="-Djava.endorsed.dirs=\"${RHQ_CLI_JAVA_ENDORSED_DIRS}\""
+ _JAVA_ENDORSED_DIRS_OPT="-Djava.endorsed.dirs=\"$RHQ_CLI_JAVA_ENDORSED_DIRS\""
fi
if [ "$RHQ_CLI_JAVA_LIBRARY_PATH" = "none" ]; then
debug_msg "Not explicitly setting java.library.path"
else
if [ -z "$RHQ_CLI_JAVA_LIBRARY_PATH" ]; then
- RHQ_CLI_JAVA_LIBRARY_PATH="${RHQ_CLI_HOME}/lib"
+ RHQ_CLI_JAVA_LIBRARY_PATH="$RHQ_CLI_HOME/lib"
fi
# convert the path if on Windows
@@ -182,7 +191,7 @@ else
RHQ_CLI_JAVA_LIBRARY_PATH=`cygpath --windows --path "$RHQ_CLI_JAVA_LIBRARY_PATH"`
fi
debug_msg "RHQ_CLI_JAVA_LIBRARY_PATH: $RHQ_CLI_JAVA_LIBRARY_PATH"
- _JAVA_LIBRARY_PATH_OPT="-Djava.library.path=\"${RHQ_CLI_JAVA_LIBRARY_PATH}\""
+ _JAVA_LIBRARY_PATH_OPT="-Djava.library.path=\"$RHQ_CLI_JAVA_LIBRARY_PATH\""
fi
debug_msg "RHQ_CLI_ADDITIONAL_JAVA_OPTS: $RHQ_CLI_ADDITIONAL_JAVA_OPTS"
@@ -201,8 +210,8 @@ if [ -n "$RHQ_CLI_DEBUG" ]; then
fi
# create the logs directory
-if [ ! -d "${RHQ_CLI_HOME}/logs" ]; then
- mkdir "${RHQ_CLI_HOME}/logs"
+if [ ! -d "$RHQ_CLI_HOME/logs" ]; then
+ mkdir "$RHQ_CLI_HOME/logs"
fi
# convert some of the paths if we are on Windows
@@ -220,15 +229,15 @@ fi
debug_msg "Executing the CLI with this command line:"
exit_code=0
if [ -z "$RHQ_CLI_CMDLINE_OPTS" ]; then
- debug_msg "${RHQ_CLI_JAVA_EXE_FILE_PATH} ${_JAVA_ENDORSED_DIRS_OPT} ${_JAVA_LIBRARY_PATH_OPT} ${RHQ_CLI_JAVA_OPTS} ${RHQ_CLI_ADDITIONAL_JAVA_OPTS} ${_LOG_CONFIG} -cp ${CLASSPATH} org.rhq.enterprise.client.ClientMain $@"
- "${RHQ_CLI_JAVA_EXE_FILE_PATH}" ${_JAVA_ENDORSED_DIRS_OPT} ${_JAVA_LIBRARY_PATH_OPT} ${RHQ_CLI_JAVA_OPTS} ${RHQ_CLI_ADDITIONAL_JAVA_OPTS} ${_LOG_CONFIG} -cp "${CLASSPATH}" org.rhq.enterprise.client.ClientMain "$@"
+ debug_msg "$RHQ_CLI_JAVA_EXE_FILE_PATH $_JAVA_ENDORSED_DIRS_OPT $_JAVA_LIBRARY_PATH_OPT $RHQ_CLI_JAVA_OPTS $RHQ_CLI_ADDITIONAL_JAVA_OPTS $_LOG_CONFIG -cp $CLASSPATH org.rhq.enterprise.client.ClientMain $@"
+ "$RHQ_CLI_JAVA_EXE_FILE_PATH" $_JAVA_ENDORSED_DIRS_OPT $_JAVA_LIBRARY_PATH_OPT $RHQ_CLI_JAVA_OPTS $RHQ_CLI_ADDITIONAL_JAVA_OPTS $_LOG_CONFIG -cp "$CLASSPATH" org.rhq.enterprise.client.ClientMain "$@"
exit_code=$?
else
- debug_msg "${RHQ_CLI_JAVA_EXE_FILE_PATH} ${_JAVA_ENDORSED_DIRS_OPT} ${_JAVA_LIBRARY_PATH_OPT} ${RHQ_CLI_JAVA_OPTS} ${RHQ_CLI_ADDITIONAL_JAVA_OPTS} ${_LOG_CONFIG} -cp ${CLASSPATH} org.rhq.enterprise.client.ClientMain ${RHQ_CLI_CMDLINE_OPTS}"
- "${RHQ_CLI_JAVA_EXE_FILE_PATH}" ${_JAVA_ENDORSED_DIRS_OPT} ${_JAVA_LIBRARY_PATH_OPT} ${RHQ_CLI_JAVA_OPTS} ${RHQ_CLI_ADDITIONAL_JAVA_OPTS} ${_LOG_CONFIG} -cp "${CLASSPATH}" org.rhq.enterprise.client.ClientMain ${RHQ_CLI_CMDLINE_OPTS}
+ debug_msg "$RHQ_CLI_JAVA_EXE_FILE_PATH $_JAVA_ENDORSED_DIRS_OPT $_JAVA_LIBRARY_PATH_OPT $RHQ_CLI_JAVA_OPTS $RHQ_CLI_ADDITIONAL_JAVA_OPTS $_LOG_CONFIG -cp $CLASSPATH org.rhq.enterprise.client.ClientMain $RHQ_CLI_CMDLINE_OPTS"
+ "$RHQ_CLI_JAVA_EXE_FILE_PATH" $_JAVA_ENDORSED_DIRS_OPT $_JAVA_LIBRARY_PATH_OPT $RHQ_CLI_JAVA_OPTS $RHQ_CLI_ADDITIONAL_JAVA_OPTS $_LOG_CONFIG -cp "$CLASSPATH" org.rhq.enterprise.client.ClientMain $RHQ_CLI_CMDLINE_OPTS
exit_code=$?
fi
debug_msg "$0 done."
-exit ${exit_code}
+exit $exit_code
commit 54f1ba2671403d2d03be92fe788af6c56e8a77af
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Dec 13 10:08:04 2013 +0100
No need to print the stack trace here - many systems do not have libvirt installed.
diff --git a/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationHostDiscoveryComponent.java b/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationHostDiscoveryComponent.java
index 749c4c1..98aca93 100644
--- a/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationHostDiscoveryComponent.java
+++ b/modules/plugins/virt/src/main/java/org/rhq/plugins/virt/VirtualizationHostDiscoveryComponent.java
@@ -35,7 +35,7 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.plugins.virt.LibVirtConnection.HVInfo;
/**
- * Discovers Host and Guest information using
+ * Discovers Host and Guest information using
*/
public class VirtualizationHostDiscoveryComponent implements ResourceDiscoveryComponent, ManualAddFacet {
@@ -68,7 +68,12 @@ public class VirtualizationHostDiscoveryComponent implements ResourceDiscoveryCo
res.getPluginConfiguration().put(new PropertySimple("connectionURI", virt.getConnectionURI()));
virt.close();
} catch (Throwable t) {
- log.warn("Can not load libvirt: " + t.getMessage(), t);
+ String message = t.getMessage();
+ if (t.getCause()!=null) {
+ message += ": " + t.getCause().getMessage();
+ }
+ log.warn("Can not load libvirt: " + message);
+
}
return res;
commit ccfecb8ea65625758ceaf277892a67e580bf7197
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Dec 12 22:17:25 2013 +0100
Check if the parent can be cast to JMXComponent before doing so.
diff --git a/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheDiscoveryComponent.java b/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheDiscoveryComponent.java
index 4d1eecf..b3fabfa 100644
--- a/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheDiscoveryComponent.java
+++ b/modules/plugins/jboss-cache/src/main/java/org/rhq/plugins/jbosscache/JBossCacheDiscoveryComponent.java
@@ -23,6 +23,7 @@
package org.rhq.plugins.jbosscache;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -43,10 +44,10 @@ import org.rhq.plugins.jmx.MBeanResourceDiscoveryComponent;
/**
* Discover JBossCache instances. The only way to detect them are to
* look for "*:cache-interceptor=CacheMgmtInterceptor,*" or "*:treecache-interceptor=CacheMgmtInterceptor,*"
- * This is done in {@link MBeanResourceDiscoveryComponent}. We postprocess the result here to
+ * This is done in {@link MBeanResourceDiscoveryComponent}. We postprocess the result here to
* get the base MBean name (without the property for detection) to be able to use this later and also
* for display purposes, as this is the MBean name the user set up in his MBean.
- *
+ *
* @author Heiko W. Rupp
*/
public class JBossCacheDiscoveryComponent extends MBeanResourceDiscoveryComponent<JMXComponent<?>> {
@@ -60,6 +61,11 @@ public class JBossCacheDiscoveryComponent extends MBeanResourceDiscoveryComponen
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<JMXComponent<?>> context) {
ResourceContext parentCtx = context.getParentResourceContext();
+
+ if (!(parentCtx.getParentResourceComponent() instanceof JMXComponent)) {
+ return Collections.emptySet();
+ }
+
JMXComponent<JBossASServerComponent<?>> gparentComponent = (JMXComponent<JBossASServerComponent<?>>) parentCtx.getParentResourceComponent();
Set<DiscoveredResourceDetails> discovered = super.performDiscovery(context.getDefaultPluginConfiguration(), gparentComponent, context.getResourceType(), false);
commit 91aae3c93d39aba6d745b10a1833a361e9043809
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Dec 12 22:43:55 2013 +0100
Better testability in the ModulesDirectoryScriptSourceProvider.
Also changed the default module path from "./samples/modules" to
"./modules". This should be safe with the fix for BZ 959603 which
causes the CLI to always pass the system property to load the modules
from. The new default path is less coupled with the FS layout of the CLI
distribution.
diff --git a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/script/ModulesDirectoryScriptSourceProvider.java b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/script/ModulesDirectoryScriptSourceProvider.java
index 0e46abe..6040e8e 100644
--- a/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/script/ModulesDirectoryScriptSourceProvider.java
+++ b/modules/enterprise/remoting/cli/src/main/java/org/rhq/enterprise/client/script/ModulesDirectoryScriptSourceProvider.java
@@ -30,13 +30,38 @@ import java.net.URI;
*/
public class ModulesDirectoryScriptSourceProvider extends FileSystemScriptSourceProvider {
- private static final File ROOT_DIR = new File(System.getProperty("rhq.scripting.modules.root-dir", "./samples/modules"));
private static final String SCHEME = "modules";
-
+
+ private File rootDir;
+
+ /**
+ * Creates a new instance of module script source provider that looks for the module sources in a directory
+ * specified by the "rhq.scripting.modules.root-dir" system property. If none such exists, the default value
+ * is assumed to be "./modules".
+ */
public ModulesDirectoryScriptSourceProvider() {
+ this(new File(System.getProperty("rhq.scripting.modules.root-dir", "./modules")));
+ }
+
+ /**
+ * Provided for testing purposes. A script source provider is only instantiated through its no-arg constructor
+ * in the scripting environment.
+ *
+ * @param rootDir the root directory under which to locate module sources
+ */
+ public ModulesDirectoryScriptSourceProvider(File rootDir) {
super(SCHEME);
+ this.rootDir = rootDir;
}
-
+
+ public File getRootDir() {
+ return rootDir;
+ }
+
+ public void setRootDir(File rootDir) {
+ this.rootDir = rootDir;
+ }
+
@Override
protected File getFile(URI location) {
String path = location.getPath();
@@ -44,6 +69,6 @@ public class ModulesDirectoryScriptSourceProvider extends FileSystemScriptSource
//remove the leading /
path = path.substring(1);
- return new File(ROOT_DIR, path);
+ return new File(rootDir, path);
}
}
diff --git a/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/script/ModulesDirectoryScriptSourceProviderTest.java b/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/script/ModulesDirectoryScriptSourceProviderTest.java
new file mode 100644
index 0000000..4060d07
--- /dev/null
+++ b/modules/enterprise/remoting/cli/src/test/java/org/rhq/enterprise/client/script/ModulesDirectoryScriptSourceProviderTest.java
@@ -0,0 +1,67 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 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.client.script;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.junit.BeforeClass;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author Lukas Krejci
+ * @since 4.10.0
+ */
+@Test
+public class ModulesDirectoryScriptSourceProviderTest {
+
+ private File scriptFile;
+
+ @BeforeClass
+ public void createScriptFile() throws IOException {
+ scriptFile = File.createTempFile("modules-test", ".js", new File("."));
+ PrintWriter wrt = new PrintWriter(new FileOutputStream(scriptFile));
+ try {
+ wrt.write("var a = 2;");
+ } finally {
+ wrt.close();
+ }
+ }
+
+ @AfterClass
+ public void deleteScriptFile() {
+ scriptFile.delete();
+ }
+
+ public void testLoad() throws URISyntaxException {
+ ModulesDirectoryScriptSourceProvider provider = new ModulesDirectoryScriptSourceProvider(new File("."));
+
+ File f = provider.getFile(new URI("modules:/" + scriptFile.getName()));
+
+ assertEquals(f, scriptFile, "Unexpected file loaded");
+ }
+}
commit 62a923a74661305cf4532525ec36a2c7d7a2a719
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Dec 12 23:10:14 2013 +0100
[BZ 959603] - Don't change CWD on CLI startup.
Since the very beginning of CLI, RHQ always changed the CWD to
$RHQ_CLI_HOME when starting up, which is rather strange and
non-standard.
To keep the backwards compatibility, the behavior can be toggled on
or off.
The default behavior can be changed in the build by setting the
rhq.cli.change-dir-on-start-default
property. In RHQ, this defaults to "false", causing RHQ to NOT change
directories when starting up the CLI anymore.
Further, the behavior can be toggled by the user by setting the
RHQ_CLI_CHANGE_DIR_ON_START environment variable to "true" (or any
other value but "false" actually) or "false" explicitly.
Additionally, a new environment variable called "RHQ_CLI_MODULES_DIR"
was added. This was necessary to not break the loading of the
provided CommonJS modules available in the
$RHQ_CLI_HOME/samples/modules directory if the CLI was started from
another directory.
By adding the new RHQ_CLI_MODULES_DIR, which is initialized to the
correct value if not provided externally, we correctly load the
sample modules with the additional benefit of easier change of the
modules location for the user (previously this was only possible
through
RHQ_CLI_ADDITIONAL_JAVA_OPTS="-Drhq.scripting.modules.root-dir=..."
, while now one only needs RHQ_CLI_MODULES_DIR=...).
diff --git a/modules/enterprise/remoting/cli/pom.xml b/modules/enterprise/remoting/cli/pom.xml
index 7515110..296b490 100644
--- a/modules/enterprise/remoting/cli/pom.xml
+++ b/modules/enterprise/remoting/cli/pom.xml
@@ -13,7 +13,11 @@
<name>RHQ Enterprise Remote CLI</name>
<description>RHQ Enterprise Remote Command Line Interface</description>
-
+
+ <properties>
+ <rhq.cli.change-dir-on-start-default>false</rhq.cli.change-dir-on-start-default>
+ </properties>
+
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
@@ -78,7 +82,18 @@
</dependencies>
<build>
- <plugins>
+ <resources>
+ <resource>
+ <directory>src/etc</directory>
+ <filtering>true</filtering>
+ <targetPath>${project.build.outputDirectory}/../etc</targetPath>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+
+ <plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
diff --git a/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.bat b/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.bat
index d5d1189..dcf1ec8 100644
--- a/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.bat
+++ b/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.bat
@@ -37,7 +37,7 @@ rem CLI's defaults. If you only want to add options
rem to the CLI's defaults, then you will want to
rem use RHQ_CLI_ADDITIONAL_JAVA_OPTS instead.
rem
-rem set RHQ_CLI_JAVA_OPTS=-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true
+rem set RHQ_CLI_JAVA_OPTS=-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true -Drhq.scripting.modules.root-dir="%RHQ_CLI_MODULES_DIR%"
rem RHQ_CLI_JAVA_ENDORSED_DIRS - Java VM command line option to set the
rem endorsed dirs for the CLI's VM. If this
@@ -74,3 +74,33 @@ rem line options and the ones specified here will
rem be passed to the CLI.
rem
rem set RHQ_CLI_CMDLINE_OPTS=
+
+rem RHQ_CLI_CHANGE_DIR_ON_START - By setting this variable to true (or any
+rem other value than "false") you can make RHQ
+rem change the directory to $RHQ_CLI_HOME when
+rem starting the CLI. When this variable is set
+rem to false, the current working directory is
+rem NOT changed when starting the CLI.
+rem
+rem If not set, this variable is understood
+rem to be: ${rhq.cli.change-dir-on-start-default}
+rem set RHQ_CLI_CHANGE_DIR_ON_START=true
+
+rem RHQ_CLI_MODULES_DIR - The default location from which to load CommonJS
+rem modules available through the "modules:/" scheme
+rem is $RHQ_CLI_HOME/samples/modules.
+rem Setting this variable to another value, causes
+rem the modules to be loaded from another location.
+rem
+rem Notice that this can be a relative path, too.
+rem For example, setting:
+rem RHQ_CLI_MODULES_DIR=./modules
+rem would cause the CLI to load modules from the
+rem "modules" subdirectory of whichever current
+rem working directory it is started from.
+rem (See RHQ_CLI_JAVA_OPTS and
+rem RHQ_CLI_CHANGE_DIR_ON_START variables above for
+rem further details of this approach).
+rem
+rem set RHQ_CLI_MODULE_DIR=Z:\company-wide\rhq\cli\modules
+
diff --git a/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh b/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh
index 2c0affa..112ec66 100755
--- a/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh
+++ b/modules/enterprise/remoting/cli/src/etc/rhq-cli-env.sh
@@ -41,7 +41,7 @@
# to the CLI's defaults, then you will want to
# use RHQ_CLI_ADDITIONAL_JAVA_OPTS instead.
#
-#RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true"
+#RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true -Drhq.scripting.modules.root-dir=${RHQ_CLI_MODULES_DIR}"
# RHQ_CLI_JAVA_ENDORSED_DIRS - Java VM command line option to set the
# endorsed dirs for the CLI's VM. If this
@@ -78,3 +78,33 @@
# be passed to the CLI.
#
#RHQ_CLI_CMDLINE_OPTS=""
+
+# RHQ_CLI_CHANGE_DIR_ON_START - By setting this variable to true (or any
+# other value than "false") you can make RHQ
+# change the directory to $RHQ_CLI_HOME when
+# starting the CLI. When this variable is set
+# to false, the current working directory is
+# NOT changed when starting the CLI.
+#
+# If not set, this variable is understood
+# to be: ${rhq.cli.change-dir-on-start-default}
+#RHQ_CLI_CHANGE_DIR_ON_START=true
+
+# RHQ_CLI_MODULES_DIR - The default location from which to load CommonJS
+# modules available through the "modules:/" scheme
+# is $RHQ_CLI_HOME/samples/modules.
+# Setting this variable to another value, causes
+# the modules to be loaded from another location.
+#
+# Notice that this can be a relative path, too.
+# For example, setting:
+# RHQ_CLI_MODULES_DIR=./modules
+# would cause the CLI to load modules from the
+# "modules" subdirectory of whichever current
+# working directory it is started from.
+# (See RHQ_CLI_JAVA_OPTS and
+# RHQ_CLI_CHANGE_DIR_ON_START variables above for
+# further details of this approach).
+#
+#RHQ_CLI_MODULE_DIR=/opt/company-wide/rhq/cli/modules
+
diff --git a/modules/enterprise/remoting/cli/src/etc/rhq-cli.bat b/modules/enterprise/remoting/cli/src/etc/rhq-cli.bat
index 8c96ed7..13dd762 100644
--- a/modules/enterprise/remoting/cli/src/etc/rhq-cli.bat
+++ b/modules/enterprise/remoting/cli/src/etc/rhq-cli.bat
@@ -20,13 +20,6 @@ if "%RHQ_CLI_DEBUG%" == "false" (
set RHQ_CLI_DEBUG=
)
-rem ----------------------------------------------------------------------
-rem Change directory so the current directory is the CLI home.
-rem Here we assume this script is a child directory of the CLI home
-rem We also assume our custom environment script is located in the same
-rem place as this script.
-rem ----------------------------------------------------------------------
-
set RHQ_CLI_BIN_DIR_PATH=%~dp0
if exist "%RHQ_CLI_BIN_DIR_PATH%\rhq-cli-env.bat" (
@@ -36,11 +29,38 @@ if exist "%RHQ_CLI_BIN_DIR_PATH%\rhq-cli-env.bat" (
if defined RHQ_CLI_DEBUG echo No environment script found at: %RHQ_CLI_BIN_DIR_PATH%\rhq-cli-env.bat
)
-rem if debug variable is set, it is assumed to be on, unless its value is false
+rem this variable is set during the build and defines the desired default behavior for directory changing
+rem we do want to change the dir in RHQ, but possibly don't want to do that in JBoss ON for backwards compatibility
+rem reasons.
+set RHQ_CLI_CHANGE_DIR_ON_START_DEFAULT=${rhq.cli.change-dir-on-start-default}
+
+if not defined RHQ_CLI_CHANGE_DIR_ON_START (
+ set RHQ_CLI_CHANGE_DIR_ON_START=%RHQ_CLI_CHANGE_DIR_ON_START_DEFAULT%
+)
+
+rem RHQ_CLI_CHANGE_DIR_ON_START behaves the same as RHQ_CLI_DEBUG - if set, it is assumed on, unless equal to false
+if "%RHQ_CLI_CHANGE_DIR_ON_START%" == "false" (
+ set RHQ_CLI_CHANGE_DIR_ON_START=
+)
+
+rem if debug variable is set, it is assumed to be on, unless its value is false (do this again after we've loaded
+rem the env script)
if "%RHQ_CLI_DEBUG%" == "false" (
set RHQ_CLI_DEBUG=
)
+rem ----------------------------------------------------------------------
+rem Change directory so the current directory is the CLI home.
+rem Here we assume this script is a child directory of the CLI home
+rem We also assume our custom environment script is located in the same
+rem place as this script.
+rem ----------------------------------------------------------------------
+
+rem since RHQ 4.10.0 we don't change the directory to the RHQ_CLI_HOME by default
+if not defined RHQ_CLI_CHANGE_DIR_ON_START (
+ pushd .
+)
+
if not defined RHQ_CLI_HOME (
cd "%RHQ_CLI_BIN_DIR_PATH%\.."
) else (
@@ -52,9 +72,22 @@ if not defined RHQ_CLI_HOME (
set RHQ_CLI_HOME=%CD%
+rem since RHQ 4.10.0 we don't change the directory to the RHQ_CLI_HOME by default
+if not defined RHQ_CLI_CHANGE_DIR_ON_START (
+ popd
+)
+
if defined RHQ_CLI_DEBUG echo RHQ_CLI_HOME: %RHQ_CLI_HOME%
rem ----------------------------------------------------------------------
+rem Prepare the modules:/ script source provider to by default load our
+rem sample modules.
+rem ----------------------------------------------------------------------
+if not defined RHQ_CLI_MODULES_DIR (
+ set RHQ_CLI_MODULES_DIR="%RHQ_CLI_HOME%\samples\modules"
+)
+
+rem ----------------------------------------------------------------------
rem Find the Java executable and verify we have a VM available
rem Note that RHQ_CLI_JAVA_* props are still handled for back compat
rem ----------------------------------------------------------------------
@@ -105,7 +138,7 @@ rem Prepare the VM command line options to be passed in
rem ----------------------------------------------------------------------
if not defined RHQ_CLI_JAVA_OPTS (
- set RHQ_CLI_JAVA_OPTS=-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true
+ set RHQ_CLI_JAVA_OPTS=-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true -Drhq.scripting.modules.root-dir="%RHQ_CLI_MODULES_DIR%"
)
if defined RHQ_CLI_DEBUG echo RHQ_CLI_JAVA_OPTS: %RHQ_CLI_JAVA_OPTS%
diff --git a/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh b/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh
index 9fce451..8399b50 100644
--- a/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh
+++ b/modules/enterprise/remoting/cli/src/etc/rhq-cli.sh
@@ -49,20 +49,51 @@ else
debug_msg "No environment script found at: ${RHQ_CLI_BIN_DIR_PATH}/rhq-cli-env.sh"
fi
-if [ -z "$RHQ_CLI_HOME" ]; then
- cd "${RHQ_CLI_BIN_DIR_PATH}/.."
-else
- cd "${RHQ_CLI_HOME}" || {
- echo "Cannot go to the RHQ_CLI_HOME directory: ${RHQ_CLI_HOME}"
- exit 1
- }
+# this variable is set during the build and defines the desired default behavior for directory changing
+# we do want to change the dir in RHQ, but possibly don't want to do that in JBoss ON for backwards compatibility
+# reasons.
+RHQ_CLI_CHANGE_DIR_ON_START_DEFAULT=${rhq.cli.change-dir-on-start-default}
+if [ -z "$RHQ_CLI_CHANGE_DIR_ON_START" ]; then
+ RHQ_CLI_CHANGE_DIR_ON_START="$RHQ_CLI_CHANGE_DIR_ON_START_DEFAULT"
fi
-RHQ_CLI_HOME=`pwd`
+# Only change the directory on start when told so. This is new in RHQ 4.10.0.
+# Previous versions always changed directory.
+if [ -n "$RHQ_CLI_CHANGE_DIR_ON_START" -a "$RHQ_CLI_CHANGE_DIR_ON_START" != "false" ]; then
+ if [ -z "$RHQ_CLI_HOME" ]; then
+ cd "${RHQ_CLI_BIN_DIR_PATH}/.."
+ else
+ cd "${RHQ_CLI_HOME}" || {
+ echo "Cannot go to the RHQ_CLI_HOME directory: ${RHQ_CLI_HOME}"
+ exit 1
+ }
+ fi
+ RHQ_CLI_HOME=`pwd`
+else
+ if [ -z "$RHQ_CLI_HOME" ]; then
+ RHQ_CLI_HOME="${RHQ_CLI_BIN_DIR_PATH}/.."
+ fi
+
+ #get an absolute path
+ RHQ_CLI_HOME=`readlink -f "$RHQ_CLI_HOME"`
+
+ if [ ! -d "$RHQ_CLI_HOME" ]; then
+ echo "RHQ_CLI_HOME detected or defined as [${RHQ_CLI_HOME}] doesn't seem to exist or is not a directory"
+ exit 1
+ fi
+fi
debug_msg "RHQ_CLI_HOME: $RHQ_CLI_HOME"
# ----------------------------------------------------------------------
+# Prepare the modules:/ script source provider to by default load our
+# sample modules.
+# ----------------------------------------------------------------------
+if [ -z "$RHQ_CLI_MODULES_DIR" ]; then
+ RHQ_CLI_MODULES_DIR="${RHQ_CLI_HOME}/samples/modules"
+fi
+
+# ----------------------------------------------------------------------
# If we are on a Mac and JAVA_HOME is not set, then set it to /usr
# as this is the default location.
# ----------------------------------------------------------------------
@@ -113,8 +144,6 @@ for _JAR in $_JAR_FILES ; do
fi
debug_msg "CLASSPATH entry: $_JAR"
done
-_JAR="${RHQ_CLI_HOME}/jbossws-native-dist/deploy/lib/jbossws-client.jar"
-CLASSPATH="${CLASSPATH}:${_JAR}"
debug_msg "CLASSPATH entry: $_JAR"
# ----------------------------------------------------------------------
@@ -122,7 +151,7 @@ debug_msg "CLASSPATH entry: $_JAR"
# ----------------------------------------------------------------------
if [ -z "$RHQ_CLI_JAVA_OPTS" ]; then
- RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true"
+ RHQ_CLI_JAVA_OPTS="-Xms64m -Xmx128m -Djava.net.preferIPv4Stack=true -Drhq.scripting.modules.root-dir=${RHQ_CLI_MODULES_DIR}"
fi
debug_msg "RHQ_CLI_JAVA_OPTS: $RHQ_CLI_JAVA_OPTS"
diff --git a/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml b/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml
index 1836e9f..a752037 100644
--- a/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml
+++ b/modules/enterprise/remoting/cli/src/main/scripts/rhq-client.build.xml
@@ -26,7 +26,7 @@
<target name="prepare-bin-dir">
<echo>*** Populating bin scripts...</echo>
<copy verbose="true" toDir="${bin.home}">
- <fileset dir="${basedir}/src/etc/" includes="rhq-cli*.*" />
+ <fileset dir="${basedir}/target/etc/" includes="rhq-cli*.*" />
</copy>
<chmod dir="${bin.home}" perm="ug+rx" includes="*.sh" />
</target>
commit 8c9d4c7aa2b894f1d3ddbe7b8d65f3fb45c2ba74
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Dec 12 13:43:56 2013 +0100
Removing old WS client files from CLI codebase
diff --git a/modules/enterprise/remoting/cli/src/etc/Remoting_Setup.txt b/modules/enterprise/remoting/cli/src/etc/Remoting_Setup.txt
deleted file mode 100644
index 10bf3dc..0000000
--- a/modules/enterprise/remoting/cli/src/etc/Remoting_Setup.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-# Steps to build and run Remoting CLI:
-
-i) Checkout RHQ
-
-ii) Enable [rhq_source]/modules/enterprise/client/src/main/java as a java source directory for your ide. For eclipse users, 'use as source folder'
-
-iii) Build RHQ from [rhq_source] and enable the Webservice endpoints by passing in the following additional parameter at build time:
- -Drhq.server.enable.ws
-
-iv) Run rhq as normal and after startup, verify that your webservices are deployed at http://[server]:7080/jbossws/services
-
-v) Until we figure out how to correctly fit this client side portion into the maven build, or even if, the following will need to be done in your IDE/Dev environment to get the client side JAXB generated types to run the following steps successfully. Jay is tasked with Maven-izing it.
- a) Open up a shell and navigate to [rhq_source]/modules/enterprise/client/src/ and run generate-jaxb-client-types.sh/bat script to generate all JAXB types to ./output directory.
- b) Add ./output directory to the top of your classpath setup in your IDE.
- c) Add the XStream 1.2.2 library from your maven repository to the classpath for your project as well.
- d) Download JLine 0.9.94 library and add it to the classpath for your project as well.
-
-vi) Run the test suite (currently incomplete and we'll be enhancing it as we move forward) by:
- a)Log into the RHQ GUI client and create a new WS test user, u:ws-test p:ws-test and the "Super User" Role.
- b)You should be able to startup XMLClientMainTest.java from you IDE and run it as a junit test.
-
-
-Notes:
--i) Take extra care that the classes that you are using for the exposed SLSBs are coming out of the 'org.rhq.enterprise.server.ws' package only. Any components that are using types NOT from these client side JAXB elements is using server side types which we do NOT want to do. We need to continue to operate as a pure JAXB client so that we most closely mimic the operating environment for all WS* clients.
-
-ii) Sometimes it is helpful when debugging the webservice interface to see what the client side or server side type actually looks like as XML. XStream, while inefficient for serializing arbitrary java object trees, is much less picky about serializing these object trees so you can get a quick picture of a given object. JAXB typically will not serialize unless you do some extra coding.
-
-
-iii) After jaxb type generation may need to:
-
- A)
-Navigate to org.rhq.enterprise.server.ws.ContentManagerRemote.getPackageTypes and change
-
-throws ResourceTypeNotFoundException_Exception
- to
-throws ResourceTypeNotFoundException
-
- B) Navigate to and change
-public class ResourceTypeNotFoundException {
- to
-public class ResourceTypeNotFoundException extends Throwable {
-
- C) Delete the ResourceTypeNotFoundException_Exception class.
diff --git a/modules/enterprise/remoting/cli/src/etc/build.xml b/modules/enterprise/remoting/cli/src/etc/build.xml
deleted file mode 100644
index 6aa91c1..0000000
--- a/modules/enterprise/remoting/cli/src/etc/build.xml
+++ /dev/null
@@ -1,80 +0,0 @@
-<project name="RHQ Remoting" basedir="." default="jar">
-
- <!--location that JAXB remote ws types are compiled to -->
- <property name="rhq-jaxb-types-location"
- location="${basedir}/output"/>
-
- <!--location that RHQ client classes are compiled to -->
- <property name="rhq-remote-classes"
- location="${basedir}/bin"/>
-
- <!--location for JLine dependency -->
- <property name="jline-jar"
- location="C:/installers/Jline/jline-0.9.94/jline-0.9.94.jar"/>
-
- <!-- -->
- <property name="repo" location="C:/Documents and Settings/Simeon/.m2/repository"/>
-
- <!--location for Gnu-Getopt dependency -->
- <property name="gnu-jar"
- location="${repo}/gnu-getopt/getopt/1.0.13/getopt-1.0.13.jar"/>
-
- <!--location for Gnu-Getopt dependency -->
- <property name="i18-jar"
- location="${repo}/i18nlog/i18nlog/1.0.10/i18nlog-1.0.10.jar"/>
-
- <property name="runLocation" value="${basedir}/run"/>
-
- <path id="project.class.path">
- <pathelement location="${runLocation}/getopt-1.0.13.jar"/>
- <pathelement location="${runLocation}/remoting.jar"/>
- <pathelement location="${runLocation}/jline-0.9.94.jar"/>
- <pathelement location="${runLocation}/i18nlog-1.0.10.jar"/>
-<!-- <pathelement path="${java.class.path}/"/>
- <pathelement path="${additional.path}"/> -->
- </path>
-
-
- <!--This target bundles up the remoting elements as an
- executable jar
- -->
- <target name="jar" description="Make executable jar">
- <delete file="${runLocation}/remoting.jar"/>
- <jar destfile="${runLocation}/remoting.jar"
- basedir="${rhq-remote-classes}"
- includes="org/rhq/**"
- excludes="**/WsFindGroupsCommand.class"
- />
-
- <!-- Copy all necessary jars to that location too -->
- <copy tofile="${runLocation}/jline-0.9.94.jar" file="${jline-jar}"/>
- <copy tofile="${runLocation}/getopt-1.0.13.jar" file="${gnu-jar}"/>
- <copy tofile="${runLocation}/i18nlog-1.0.10.jar" file="${i18-jar}"/>
- <copy tofile="${runLocation}/toRun.txt" file="${basedir}/toRun.txt"/>
-<!-- <copy todir="${runLocation}">
- <fileset dir="src_dir" excludes="**/*.java"/>
- </copy> -->
-
- </target>
-
- <target name="zip" depends="jar">
- <delete file="${runLocation}/bundle.zip"/>
- <zip destfile="${runLocation}/bundle.zip"
- basedir="${runLocation}"
- />
- </target>
-
- <target name="run">
- <java classname="org.rhq.enterprise.client.ClientMain">
- <!-- <arg value="-h"/> -->
- <classpath refid="project.class.path">
- <!-- <pathelement refid="project.class.path"/>
- <pathelement path="${java.class.path}"/> -->
-
- </classpath>
- </java>
-
-
- </target>
-
-</project>
diff --git a/modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.bat b/modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.bat
deleted file mode 100644
index 68e8706..0000000
--- a/modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.bat
+++ /dev/null
@@ -1,16 +0,0 @@
-rem This script should consume all the wsdls and compile the JAXB types all
-rem into one directory.
-
-call ../../../../dev-container/jbossas/bin/wsconsume.bat -k http://127.0.0.1:7080/rhq-rhq-server/RoleManagerBean?wsdl -p org.rhq.enterprise.server.ws
-
-call ../../../../dev-container/jbossas/bin/wsconsume.bat -k http://127.0.0.1:7080/rhq-rhq-server/ContentManagerBean?wsdl -p org.rhq.enterprise.server.ws
-
-call ../../../../dev-container/jbossas/bin/wsconsume.bat -k http://127.0.0.1:7080/rhq-rhq-server/SubjectManagerBean?wsdl -p org.rhq.enterprise.server.ws
-
-call ../../../../dev-container/jbossas/bin/wsconsume.bat -k http://127.0.0.1:7080/rhq-rhq-server/OperationManagerBean?wsdl -p org.rhq.enterprise.server.ws
-
-call ../../../../dev-container/jbossas/bin/wsconsume.bat -k http://127.0.0.1:7080/rhq-rhq-server/RepoManagerBean?wsdl -p org.rhq.enterprise.server.ws
-
-call ../../../../dev-container/jbossas/bin/wsconsume.bat -k http://127.0.0.1:7080/rhq-rhq-server/ConfigurationManagerBean?wsdl -p org.rhq.enterprise.server.ws
-
-call ../../../../dev-container/jbossas/bin/wsconsume.bat -k http://127.0.0.1:7080/rhq-rhq-server/ResourceManagerBean?wsdl -p org.rhq.enterprise.server.ws
\ No newline at end of file
diff --git a/modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.sh b/modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.sh
deleted file mode 100644
index f83293b..0000000
--- a/modules/enterprise/remoting/cli/src/etc/generate-jaxb-client-types.sh
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-
-# This script should consume all the wsdls and compile the JAXB types all
-# into one directory.
-
-../../../../dev-container/jbossas/bin/wsconsume.sh -k http://localhost:7080/rhq-rhq-server/RoleManagerBean?wsdl -p org.rhq.enterprise.server.ws
-
-../../../../dev-container/jbossas/bin/wsconsume.sh -k http://localhost:7080/rhq-rhq-server/ContentManagerBean?wsdl -p org.rhq.enterprise.server.ws
-
-../../../../dev-container/jbossas/bin/wsconsume.sh -k http://localhost:7080/rhq-rhq-server/SubjectManagerBean?wsdl -p org.rhq.enterprise.server.ws
-
-../../../../dev-container/jbossas/bin/wsconsume.sh -k http://localhost:7080/rhq-rhq-server/OperationManagerBean?wsdl -p org.rhq.enterprise.server.ws
-
-../../../../dev-container/jbossas/bin/wsconsume.sh -k http://localhost:7080/rhq-rhq-server/RepoManagerBean?wsdl -p org.rhq.enterprise.server.ws
-
-../../../../dev-container/jbossas/bin/wsconsume.sh -k http://localhost:7080/rhq-rhq-server/ConfigurationManagerBean?wsdl -p org.rhq.enterprise.server.ws
-
-../../../../dev-container/jbossas/bin/wsconsume.sh -k http://localhost:7080/rhq-rhq-server/ResourceManagerBean?wsdl -p org.rhq.enterprise.server.ws
\ No newline at end of file
diff --git a/modules/enterprise/remoting/cli/src/etc/toRun.txt b/modules/enterprise/remoting/cli/src/etc/toRun.txt
deleted file mode 100644
index a86a75b..0000000
--- a/modules/enterprise/remoting/cli/src/etc/toRun.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-java -cp getopt-1.0.13.jar:remoting.jar:jline-0.9.94.jar:i18nlog-1.0.9.jar org.rhq.enterprise.client.ClientMain
-
-java -cp getopt-1.0.13.jar;remoting.jar;jline-0.9.94.jar;i18nlog-1.0.9.jar org.rhq.enterprise.client.ClientMain
\ No newline at end of file
10 years, 4 months
[rhq] Changes to 'jay-sync'
by Jay Shaughnessy
New branch 'jay-sync' available with the following commits:
commit 2ad00b7cb9dd80a6debb7b25084601407d21e0a0
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Dec 13 17:21:40 2013 -0500
[1023451] [perf] Large retained heap during inventory report merge (causing OOMs)
Note - this is related work, not necessarily a solution to this problem.
One factor in the memory consumption of mergeInventoryReport is that we
return the entire resource hierarchy for the platform. These hierarchy
is comprised of lightweight (ResourceSyncInfo) objects, but still, for
a large inventory this can be large. Moreover, the agent must receive the
same structure into memory.
This commit aims to reduce memory consumption at the expense of "chunking"
the hierarchy by top-level-server. The general flow is that mergeInventoryReport
now returns the new PlatformSyncInfo, which is just the platform sync info and
the list of top level servers. The agent then performs the sync in pieces, calling back to the server for each
top level server's ResourceSyncInfo.
notes:
- New abstract SyncInfo pulled down from ResourceSyncInfo and new superclass
PlatformSyncInfo. These are both now used in the sync process.
- ResourceSyncInfo made more lightweight by replacing parentResource with
parentId.
- Had to change test mocks to handle the new strategy
- add mock support for getResourceSyncInfo service
- enhance AbstractIgnoreTypesInventoryManagerBaseTest to actually assign
resource ids to the simulated server inventory
- Fix a few PC itest issues
- increase waitForInventory max time, it wasn't long enough
- add missing waitForInventory in a couple of places
10 years, 4 months