[rhq] etc/rhq-ircBot
by Libor Zoubek
etc/rhq-ircBot/src/main/java/org/rhq/etc/ircbot/RhqIrcBotListener.java | 1 +
1 file changed, 1 insertion(+)
New commits:
commit b92296b4518771e70319c11ff2446a4e523ffd34
Author: Libor Zoubek <lzoubek(a)redhat.com>
Date: Wed Feb 26 16:10:30 2014 +0100
proudly added myself to bot's awareness
diff --git a/etc/rhq-ircBot/src/main/java/org/rhq/etc/ircbot/RhqIrcBotListener.java b/etc/rhq-ircBot/src/main/java/org/rhq/etc/ircbot/RhqIrcBotListener.java
index d56e7f3..ed74576 100644
--- a/etc/rhq-ircBot/src/main/java/org/rhq/etc/ircbot/RhqIrcBotListener.java
+++ b/etc/rhq-ircBot/src/main/java/org/rhq/etc/ircbot/RhqIrcBotListener.java
@@ -83,6 +83,7 @@ public class RhqIrcBotListener extends ListenerAdapter<RhqIrcBot> {
JON_DEVS.add("spinder");
JON_DEVS.add("stefan_n");
JON_DEVS.add("tsegismont");
+ JON_DEVS.add("lzoubek");
}
private final String server;
10 years, 2 months
[rhq] Branch 'jsanda/metrics-schema' - modules/enterprise
by John Sanda
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/StorageResultSetFuture.java | 4
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/aggregation/Aggregator.java | 24 +++++
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/aggregation/BatchException.java | 45 ++++++++++
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/aggregation/BatchFailureListener.java | 26 +++++
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/aggregation/ProcessBatch.java | 24 ++++-
modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/AggregationTests.java | 32 +++++++
modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsDAOTest.java | 2
7 files changed, 150 insertions(+), 7 deletions(-)
New commits:
commit a493f07e7c71b721777ee27e618668d60960cc94
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Feb 25 22:54:07 2014 -0500
adding some initial support for failure handling
This commit gives the capability to log stack traces when exceptions occur
while processing a batch of futures. More importantly, this is a step towards
providing fail fast behavior. Suppose we provide a configurable threshold for
failures, and when that threshold is passed, we abort the aggregation so that
it can be retried at some later time.
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/StorageResultSetFuture.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/StorageResultSetFuture.java
index d6b8598..ca287b0 100644
--- a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/StorageResultSetFuture.java
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/StorageResultSetFuture.java
@@ -43,6 +43,10 @@ public class StorageResultSetFuture implements ListenableFuture<ResultSet> {
return wrapperFuture.isDone();
}
+ public void setException(Throwable t) {
+ wrapperFuture.setException(t);
+ }
+
/**
* Delegates to {@link com.datastax.driver.core.ResultSetFuture#getUninterruptibly()}
*/
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/aggregation/Aggregator.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/aggregation/Aggregator.java
index 95b9e07..f3ee9c3 100644
--- a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/aggregation/Aggregator.java
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/aggregation/Aggregator.java
@@ -4,7 +4,9 @@ import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
+import com.datastax.driver.core.ResultSet;
import com.google.common.base.Stopwatch;
+import com.google.common.util.concurrent.AsyncFunction;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
@@ -45,6 +47,13 @@ class Aggregator {
private TaskTracker taskTracker = new TaskTracker();
+ private AsyncFunction<BatchResult, ResultSet> deleteCachePartition = new AsyncFunction<BatchResult, ResultSet>() {
+ @Override
+ public ListenableFuture<ResultSet> apply(BatchResult batchResult) throws Exception {
+ return dao.deleteCacheEntries(aggregationType.getCacheTable(), startTime.getMillis(), startScheduleId);
+ }
+ };
+
void setComputeMetric(ComputeMetric computeMetric) {
this.computeMetric = computeMetric;
}
@@ -131,7 +140,20 @@ class Aggregator {
@Override
public void onFailure(Throwable t) {
- LOG.warn("There was an unexpected error while processing a batch of " + aggregationType);
+ if (t instanceof BatchException) {
+ BatchException exception = (BatchException) t;
+ LOG.warn("There were errors while processing a batch of " + aggregationType + " with starting " +
+ "schedule id " + startScheduleId + ": " + exception.getErrorMessages());
+ if (LOG.isDebugEnabled()) {
+ for (Throwable error : exception.getRootCauses()) {
+ LOG.debug("Root cause for batch error", error);
+ }
+ }
+ } else {
+ LOG.warn("There was an unexpected error while processing a batch of " + aggregationType +
+ " with starting schedule id " + startScheduleId, t);
+ }
+ // TODO add some configurable strategy to determine whether or not to abort
updateRemainingBatches();
}
};
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/aggregation/BatchException.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/aggregation/BatchException.java
new file mode 100644
index 0000000..46e005b
--- /dev/null
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/aggregation/BatchException.java
@@ -0,0 +1,45 @@
+package org.rhq.server.metrics.aggregation;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.rhq.core.util.exception.ThrowableUtil;
+
+/**
+ * @author John Sanda
+ */
+class BatchException extends Exception {
+
+ private int startScheduleId;
+
+ private List<Throwable> errors;
+
+ public BatchException(int startScheduleId, List<Throwable> errors) {
+ this.startScheduleId = startScheduleId;
+ this.errors = errors;
+ }
+
+ int getStartScheduleId() {
+ return startScheduleId;
+ }
+
+ List<Throwable> getErrors() {
+ return errors;
+ }
+
+ List<String> getErrorMessages() {
+ List<String> messages = new ArrayList<String>(errors.size());
+ for (Throwable error : errors) {
+ messages.add(ThrowableUtil.getRootMessage(error));
+ }
+ return messages;
+ }
+
+ List<Throwable> getRootCauses() {
+ List<Throwable> rootCauses = new ArrayList<Throwable>(errors.size());
+ for (Throwable error : errors) {
+ rootCauses.add(ThrowableUtil.getRootCause(error));
+ }
+ return rootCauses;
+ }
+}
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/aggregation/BatchFailureListener.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/aggregation/BatchFailureListener.java
new file mode 100644
index 0000000..fef0a67
--- /dev/null
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/aggregation/BatchFailureListener.java
@@ -0,0 +1,26 @@
+package org.rhq.server.metrics.aggregation;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.datastax.driver.core.ResultSet;
+import com.google.common.util.concurrent.FutureFallback;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * @author John Sanda
+ */
+class BatchFailureListener implements FutureFallback<ResultSet> {
+
+ private List<Throwable> errors = new ArrayList<Throwable>();
+
+ @Override
+ public ListenableFuture<ResultSet> create(Throwable t) throws Exception {
+ errors.add(t);
+ return null;
+ }
+
+ List<Throwable> getErrors() {
+ return errors;
+ }
+}
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/aggregation/ProcessBatch.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/aggregation/ProcessBatch.java
index 5c8680f..a9519f5 100644
--- a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/aggregation/ProcessBatch.java
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/aggregation/ProcessBatch.java
@@ -41,6 +41,8 @@ class ProcessBatch implements AsyncFunction<ResultSet, BatchResult> {
private int batchSize;
+ private BatchFailureListener failureListener = new BatchFailureListener();
+
public ProcessBatch(MetricsDAO dao, ComputeMetric computeMetric, int startScheduleId,
DateTime timeSlice, AggregationType aggregationType, int batchSize) {
this.dao = dao;
@@ -57,7 +59,7 @@ class ProcessBatch implements AsyncFunction<ResultSet, BatchResult> {
if (log.isDebugEnabled()) {
log.debug("Aggregating batch of " + aggregationType + " with starting schedule id " + startScheduleId);
}
- List<StorageResultSetFuture> insertFutures = new ArrayList<StorageResultSetFuture>(batchSize * 4);
+ List<ListenableFuture<ResultSet>> insertFutures = new ArrayList<ListenableFuture<ResultSet>>(batchSize * 4);
try {
if (resultSet.isExhausted()) {
return Futures.immediateFuture(new BatchResult(timeSlice, startScheduleId));
@@ -81,8 +83,8 @@ class ProcessBatch implements AsyncFunction<ResultSet, BatchResult> {
}
mean.add(currentMetric.getAvg());
} else {
- insertFutures.addAll(computeMetric.execute(startScheduleId, currentMetric.getScheduleId(), min, max,
- mean));
+ insertFutures.addAll(wrapWithFailureListener(computeMetric.execute(startScheduleId,
+ currentMetric.getScheduleId(), min, max, mean)));
currentMetric = nextMetric;
min = currentMetric.getMin();
@@ -91,12 +93,16 @@ class ProcessBatch implements AsyncFunction<ResultSet, BatchResult> {
mean.add(currentMetric.getAvg());
}
}
- insertFutures.addAll(computeMetric.execute(startScheduleId, currentMetric.getScheduleId(), min, max, mean));
+ insertFutures.addAll(wrapWithFailureListener(computeMetric.execute(startScheduleId,
+ currentMetric.getScheduleId(), min, max, mean)));
ListenableFuture<List<ResultSet>> insertsFuture = Futures.successfulAsList(insertFutures);
return Futures.transform(insertsFuture, new AsyncFunction<List<ResultSet>, BatchResult>() {
@Override
- public ListenableFuture<BatchResult> apply(final List<ResultSet> resultSets) {
+ public ListenableFuture<BatchResult> apply(final List<ResultSet> resultSets) throws Exception {
+ if (!failureListener.getErrors().isEmpty()) {
+ throw new BatchException(startScheduleId, failureListener.getErrors());
+ }
StorageResultSetFuture deleteFuture = dao.deleteCacheEntries(
aggregationType.getCacheTable(), timeSlice.getMillis(), startScheduleId);
return Futures.transform(deleteFuture, new Function<ResultSet, BatchResult>() {
@@ -117,4 +123,12 @@ class ProcessBatch implements AsyncFunction<ResultSet, BatchResult> {
}
}
+ private List<ListenableFuture<ResultSet>> wrapWithFailureListener(List<StorageResultSetFuture> futures) {
+ List<ListenableFuture<ResultSet>> wrappedFutures = new ArrayList<ListenableFuture<ResultSet>>(futures.size());
+ for (StorageResultSetFuture future : futures) {
+ wrappedFutures.add(Futures.withFallback(future, failureListener));
+ }
+ return wrappedFutures;
+ }
+
}
diff --git a/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/AggregationTests.java b/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/AggregationTests.java
index a9919f1..f98e80d 100644
--- a/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/AggregationTests.java
+++ b/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/AggregationTests.java
@@ -26,6 +26,7 @@ import org.rhq.core.domain.measurement.MeasurementDataNumeric;
import org.rhq.server.metrics.aggregation.AggregationManager;
import org.rhq.server.metrics.domain.AggregateNumericMetric;
import org.rhq.server.metrics.domain.AggregateType;
+import org.rhq.server.metrics.domain.RawNumericMetric;
/**
* @author John Sanda
@@ -271,6 +272,30 @@ public class AggregationTests extends MetricsTest {
purgeDB();
}
+ @Test(dependsOnMethods = "resetDBForFailureScenarios")
+ public void doNotDeleteCachePartitionOnBatchFailure() throws Exception {
+ currentHour = hour(5);
+ DateTime time = hour(4).plusMinutes(20);
+ insertRawData(hour(4), new MeasurementDataNumeric(time.getMillis(), schedule1.id, 3.0))
+ .await("Failed to insert raw data");
+
+ TestDAO testDAO = new TestDAO() {
+ @Override
+ public StorageResultSetFuture insertOneHourDataAsync(int scheduleId, long timestamp, AggregateType type,
+ double value) {
+ StorageResultSetFuture future = super.insertOneHourDataAsync(scheduleId, timestamp, type, value);
+ future.setException(new Exception("An unexpected error occurred while inserting 1 hour data"));
+ return future;
+ }
+ };
+
+ AggregationManagerTestStub aggregationManager = new AggregationManagerTestStub(hour(4), testDAO);
+ aggregationManager.run();
+
+ assert1HourCacheEquals(hour(4), startScheduleId(schedule1.id), asList(new RawNumericMetric(schedule1.id,
+ time.getMillis(), 3.0)));
+ }
+
//@Test(dependsOnMethods = "resetDBForFailureScenarios")
// public void failToFetchRawDataIndexDuringAggregationForHour12() throws Exception {
// currentHour = hour(12);
@@ -401,6 +426,13 @@ public class AggregationTests extends MetricsTest {
Map<DateTime, AggregateNumericMetric> twentyFourHourData = new HashMap<DateTime, AggregateNumericMetric>();
}
+ private class TestDAO extends MetricsDAO {
+
+ public TestDAO() {
+ super(storageSession, configuration);
+ }
+ }
+
private class FailedStorageResultSetFuture extends StorageResultSetFuture implements ListenableFuture<ResultSet> {
private SettableFuture future;
diff --git a/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsDAOTest.java b/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsDAOTest.java
index 07500f1..5d3f304 100644
--- a/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsDAOTest.java
+++ b/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsDAOTest.java
@@ -91,7 +91,7 @@ public class MetricsDAOTest extends CassandraIntegrationTest {
session.execute("TRUNCATE " + MetricsTable.ONE_HOUR);
session.execute("TRUNCATE " + MetricsTable.SIX_HOUR);
session.execute("TRUNCATE " + MetricsTable.TWENTY_FOUR_HOUR);
- session.execute("TRUNCATE " + MetricsTable.INDEX);
+ session.execute("TRUNCATE " + MetricsTable.METRICS_CACHE);
}
@Test(enabled = ENABLED)
10 years, 2 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/bundle/deploy/GetDestinationStep.java | 16 ++++++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/wizard/AbstractGroupCreateWizard.java | 12 +++++--
2 files changed, 19 insertions(+), 9 deletions(-)
New commits:
commit 12e0cc0530d13d9e5a1f88f46460a2b3df47794c
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Feb 25 17:35:15 2014 -0500
BZ 1069793 - fix the group creation from within bundle wizard
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/bundle/deploy/GetDestinationStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/bundle/deploy/GetDestinationStep.java
index 3e158a2..d0d0e76 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/bundle/deploy/GetDestinationStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/bundle/deploy/GetDestinationStep.java
@@ -59,9 +59,9 @@ import org.rhq.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.coregui.client.inventory.resource.type.ResourceTypeRepository.MetadataType;
import org.rhq.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
import org.rhq.coregui.client.util.FormUtility;
+import org.rhq.coregui.client.util.enhanced.EnhancedVLayout;
import org.rhq.coregui.client.util.message.Message;
import org.rhq.coregui.client.util.message.Message.Severity;
-import org.rhq.coregui.client.util.enhanced.EnhancedVLayout;
/**
* @author Jay Shaughnessy
@@ -219,7 +219,7 @@ public class GetDestinationStep extends AbstractWizardStep {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.view_bundle_deployWizard_error_9(), caught);
- // try anyway and potentially fail again from there
+ // try anyway and potentially fail again from there
createDestination();
}
});
@@ -230,7 +230,7 @@ public class GetDestinationStep extends AbstractWizardStep {
return false;
}
- // this will advance or decrement the step depending on creation success or failure
+ // this will advance or decrement the step depending on creation success or failure
private void createDestination() {
int selectedGroup = (Integer) this.valForm.getValue("group");
@@ -264,7 +264,7 @@ public class GetDestinationStep extends AbstractWizardStep {
destBaseDirItem.clearValue();
destBaseDirItem.setValueMap((String[]) null);
- // this will be null if there is no true group actually selected (e.g. user is typing a partial name to search)
+ // this will be null if there is no true group actually selected (e.g. user is typing a partial name to search)
if (selectedGroupId != null) {
bundleServer.getResourceTypeBundleConfiguration(selectedGroupId.intValue(),
new AsyncCallback<ResourceTypeBundleConfiguration>() {
@@ -324,6 +324,12 @@ public class GetDestinationStep extends AbstractWizardStep {
SC.warn(MSG.view_bundle_deployWizard_createGroup_error_1());
return false;
}
+
+ // BZ 1069793 - We must get these first, before the async call is made.
+ // Otherwise, the group wizard (and this data) will get destroyed before we have a change to get it.
+ final ResourceGroup group = createStep.getGroup();
+ final int[] selectedResourceIds = memberStep.getSelectedResourceIds();
+
ResourceTypeRepository typeRepository = ResourceTypeRepository.Cache.getInstance();
typeRepository.getResourceTypes(ids, EnumSet.of(MetadataType.bundleConfiguration),
new TypesLoadedCallback() {
@@ -334,7 +340,7 @@ public class GetDestinationStep extends AbstractWizardStep {
} else if (typeSet.iterator().next().getResourceTypeBundleConfiguration() == null) {
SC.warn(MSG.view_bundle_deployWizard_createGroup_error_3());
} else {
- QuickGroupCreateWizard.super.createGroup();
+ QuickGroupCreateWizard.super.createGroup(group, selectedResourceIds);
}
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/wizard/AbstractGroupCreateWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/wizard/AbstractGroupCreateWizard.java
index 5cb5ae0..ad37442 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/wizard/AbstractGroupCreateWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/wizard/AbstractGroupCreateWizard.java
@@ -75,21 +75,25 @@ public abstract class AbstractGroupCreateWizard extends AbstractWizard {
}
public boolean createGroup() {
+ return createGroup(createStep.getGroup(), memberStep.getSelectedResourceIds());
+ }
+
+ public boolean createGroup(final ResourceGroup newGroupToCreate, final int[] selectedGroupMembersResourceIds) {
ResourceGroupGWTServiceAsync groupService = GWTServiceLookup.getResourceGroupService();
- groupService.createResourceGroup(createStep.getGroup(), memberStep.getSelectedResourceIds(),
+ groupService.createResourceGroup(newGroupToCreate, selectedGroupMembersResourceIds,
new AsyncCallback<ResourceGroup>() {
public void onFailure(Throwable caught) {
String msg = caught.getMessage();
- CoreGUI.getErrorHandler().handleError(MSG.view_groupCreateWizard_createFailure(createStep.getGroup().getName(),msg), caught);
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_groupCreateWizard_createFailure(newGroupToCreate.getName(), msg), caught);
}
public void onSuccess(ResourceGroup result) {
String conciseMessage = MSG.view_groupCreateWizard_createSuccessful_concise(result.getName());
String detailedMessage = MSG.view_groupCreateWizard_createSuccessful_full(result.getGroupCategory()
- .name().toLowerCase(), result.getName(), String
- .valueOf(memberStep.getSelectedResourceIds().length));
+ .name().toLowerCase(), result.getName(), String.valueOf(selectedGroupMembersResourceIds.length));
CoreGUI.getMessageCenter().notify(new Message(conciseMessage, detailedMessage));
groupCreateCallback(result);
}
10 years, 2 months
[rhq] 3 commits - modules/core modules/enterprise modules/plugins
by Jay Shaughnessy
modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java | 2 -
modules/core/domain/src/main/java/org/rhq/core/domain/discovery/MergeResourceResponse.java | 20 +++++++++-
modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementDataTrait.java | 2 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java | 2 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 15 ++++---
modules/enterprise/gui/portal-war/src/main/webapp/admin/test/sql.jsp | 5 +-
modules/plugins/netservices/src/test/java/org/rhq/plugins/netservices/itest/NetServiceComponentTest.java | 5 +-
7 files changed, 35 insertions(+), 16 deletions(-)
New commits:
commit 75329fce150ea3c9bd99e7f2824d17058c2848a9
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Feb 25 16:16:12 2014 -0500
[1069887] Manual add can create duplicate resources
When manually adding a resource the server instructs the agent to
discover the new resource, given plugin config. After discovery the
agent asks the server to merge the new resource into inventory (assigning
an id, etc). While the server is doing that, it was possible the new
resource could get picked up in an inventory sync because it looked
like the resource was dirty. This fixes that condition.
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 36fb392..c4d4a8a 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
@@ -217,7 +217,7 @@ public class FakeServerInventory {
r = fakePersist(r, InventoryStatus.COMMITTED, new HashSet<String>());
- return new MergeResourceResponse(r.getId(), exists);
+ return new MergeResourceResponse(r.getId(), (exists ? r.getMtime() : r.getCtime()), exists);
}
};
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/discovery/MergeResourceResponse.java b/modules/core/domain/src/main/java/org/rhq/core/domain/discovery/MergeResourceResponse.java
index 1658165..7f477a4 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/discovery/MergeResourceResponse.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/discovery/MergeResourceResponse.java
@@ -34,11 +34,25 @@ public class MergeResourceResponse implements Serializable {
private static final long serialVersionUID = 1L;
private int resourceId;
-
+ private long mtime;
private boolean resourceAlreadyExisted;
+ /**
+ * @deprecated use {@link #MergeResourceResponse(int, long, boolean)}
+ */
+ @Deprecated
public MergeResourceResponse(int resourceId, boolean resourceAlreadyExisted) {
+ this(resourceId, 0L, resourceAlreadyExisted);
+ }
+
+ /**
+ * @param resourceId
+ * @param mtime for new resources, this is the ctime, for existing resources it is the mtime
+ * @param resourceAlreadyExisted
+ */
+ public MergeResourceResponse(int resourceId, long mtime, boolean resourceAlreadyExisted) {
this.resourceId = resourceId;
+ this.mtime = mtime;
this.resourceAlreadyExisted = resourceAlreadyExisted;
}
@@ -46,6 +60,10 @@ public class MergeResourceResponse implements Serializable {
return resourceId;
}
+ public long getMtime() {
+ return mtime;
+ }
+
public boolean resourceAlreadyExisted() {
return resourceAlreadyExisted;
}
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 992b14b..3b323e1 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
@@ -941,7 +941,7 @@ public class StandaloneContainer {
@Override
public MergeResourceResponse addResource(Resource resource, int creatorSubjectId) {
- return new MergeResourceResponse(manualAddResourceCounter++,false);
+ return new MergeResourceResponse(manualAddResourceCounter++, System.currentTimeMillis(), false);
}
@Override
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 5dd9826..1001a3a 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
@@ -19,6 +19,9 @@
package org.rhq.core.pc.inventory;
+import gnu.trove.map.TIntObjectMap;
+import gnu.trove.map.hash.TIntObjectHashMap;
+
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
@@ -45,9 +48,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-import gnu.trove.map.TIntObjectMap;
-import gnu.trove.map.hash.TIntObjectHashMap;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jetbrains.annotations.NotNull;
@@ -235,9 +235,8 @@ public class InventoryManager extends AgentService implements ContainerService,
* Constructs a new instance.
* Call {@link #initialize()} once constructed.
*/
- public InventoryManager(PluginContainerConfiguration configuration,
- AgentServiceStreamRemoter streamRemoter, PluginManager pluginManager,
- EventManager eventManager) {
+ public InventoryManager(PluginContainerConfiguration configuration, AgentServiceStreamRemoter streamRemoter,
+ PluginManager pluginManager, EventManager eventManager) {
super(DiscoveryAgentService.class, streamRemoter);
this.configuration = configuration;
if (pluginManager == null)
@@ -960,8 +959,10 @@ public class InventoryManager extends AgentService implements ContainerService,
mergeResourceResponse = discoveryServerService.addResource(resource, ownerSubjectId);
// Sync our local resource up with the one now in server inventory. Treat this like a newlyCommittedResource
+ // - set mtime (same as ctime for a new resource) to ensure this does not get picked up in an inventory sync
+ // pass, we know we're currently in sync with the server.
resource.setId(mergeResourceResponse.getResourceId());
- resource.setMtime(0); // this will indicate that this resource is "dirty" and needs to be synced/merged later
+ resource.setMtime(mergeResourceResponse.getMtime());
Set newResources = new LinkedHashSet<Resource>();
newResources.add(resource);
postProcessNewlyCommittedResources(newResources);
diff --git a/modules/plugins/netservices/src/test/java/org/rhq/plugins/netservices/itest/NetServiceComponentTest.java b/modules/plugins/netservices/src/test/java/org/rhq/plugins/netservices/itest/NetServiceComponentTest.java
index f0c1230..dce2b4c 100644
--- a/modules/plugins/netservices/src/test/java/org/rhq/plugins/netservices/itest/NetServiceComponentTest.java
+++ b/modules/plugins/netservices/src/test/java/org/rhq/plugins/netservices/itest/NetServiceComponentTest.java
@@ -100,14 +100,15 @@ public abstract class NetServiceComponentTest {
containerConfig.setPluginFinder(new FileSystemPluginFinder(pluginDir));
containerConfig.setPluginDirectory(pluginDir);
containerConfig.setInsideAgent(false);
- // netservices plugin has resources which can only be manually added so we have to mock server integration.
+ // netservices plugin has resources which can only be manually added so we have to mock server integration.
DiscoveryServerService discoveryServerService = Mockito.mock(DiscoveryServerService.class);
when(discoveryServerService.addResource(any(Resource.class), anyInt())).thenAnswer(
new Answer<MergeResourceResponse>() {
@Override
public MergeResourceResponse answer(InvocationOnMock invocation) throws Throwable {
- return new MergeResourceResponse(resourceIdGenerator.decrementAndGet(), false);
+ return new MergeResourceResponse(resourceIdGenerator.decrementAndGet(), System.currentTimeMillis(),
+ false);
}
});
ServerServices serverServices = new ServerServices();
commit d9acd985470322ceb15687d5cbfd48c0809fd093
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Feb 21 17:05:20 2014 -0500
Support postgres WITH queries
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/sql.jsp b/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/sql.jsp
index 7a0f490..292ff56 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/sql.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/sql.jsp
@@ -99,8 +99,9 @@ private StringBuffer processSQL ( Connection conn, String sql, int index, int nu
throw e;
}
}
-
- if ( LCsql.startsWith("select") ||
+
+ if ( LCsql.startsWith("select") ||
+ LCsql.startsWith("with") ||
LCsql.startsWith("values") ) {
try {
markTime = System.currentTimeMillis();
commit b7f798ea56d2b0dac374bdc955fbc71a5b7be264
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Feb 21 09:09:46 2014 -0500
remove useless and confusing annotation. Length attr is used for DDL
generation, which we don't do. And our actual length is 4000 at the
moment.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementDataTrait.java b/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementDataTrait.java
index b340cca..b8e4757 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementDataTrait.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementDataTrait.java
@@ -22,7 +22,6 @@
*/
package org.rhq.core.domain.measurement;
-import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
@@ -100,7 +99,6 @@ public class MeasurementDataTrait extends MeasurementData {
private static final long serialVersionUID = 1L;
- @Column(length = 255)
private String value;
/**
10 years, 2 months
[rhq] modules/enterprise
by Libor Zoubek
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
New commits:
commit ad13c7ec68b1667e40191aaec2683d5d68a9b692
Author: Libor Zoubek <lzoubek(a)redhat.com>
Date: Tue Feb 25 20:52:59 2014 +0100
[BZ 1015719] DiscoveryBossBean: Unknown resource type error, unclear from
which agent the error is from
Log message changed to include agent details
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 0cfbb01..d338a77 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
@@ -217,6 +217,9 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
// we'll get persistence exceptions when we try to merge OR persist the platform.
long rootStart = System.currentTimeMillis();
if (!initResourceTypes(root, allTypes)) {
+ LOG.error("Reported resource [" + root + "] has an unknown type [" + root.getResourceType()
+ + "]. The Agent [" + knownAgent + "] most likely has a plugin named '" + root.getResourceType().getPlugin()
+ + "' installed that is not installed on the Server. Resource will be ignored...");
continue;
}
@@ -1269,9 +1272,6 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
}
if (null == resourceType) {
- LOG.error("Reported resource [" + resource + "] has an unknown type [" + resource.getResourceType()
- + "]. The Agent most likely has a plugin named '" + plugin
- + "' installed that is not installed on the Server. Resource will be ignored...");
return false;
} else {
loadedTypeMap.put(key.toString(), resourceType);
10 years, 2 months
[rhq] 2 commits - modules/core modules/enterprise
by Jay Shaughnessy
modules/core/dbutils/src/main/java/org/rhq/core/db/DatabaseType.java | 24 +-
modules/core/dbutils/src/main/java/org/rhq/core/db/OracleDatabaseType.java | 16 +
modules/core/dbutils/src/main/java/org/rhq/core/db/PostgresqlDatabaseType.java | 23 +-
modules/core/domain/src/main/java/org/rhq/core/domain/discovery/ResourceSyncInfo.java | 22 +
modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java | 78 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/gwt/ResourceGWTService.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/server/gwt/ResourceGWTServiceImpl.java | 9
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java | 41 +++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java | 112 ++++++++--
9 files changed, 280 insertions(+), 47 deletions(-)
New commits:
commit caa08cef46c679064040e6256fdaf24f2d402250
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Feb 25 13:02:29 2014 -0500
[1025918] Uninventoring resources is slow; should not take more than a second
As suggested by Elias Ross, convert our depth-restricted "recursive" join
queries with recursive queries leveraging native support in
Oracle and Postgres.
Also:
- remove unused coregui (GWT) service that depended on an old query.
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 b1fb366..6d5036d 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
@@ -71,6 +71,26 @@ public class ResourceSyncInfo implements Serializable {
* 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";
+ // Native Queries not supported by HQL
+ public static final String QUERY_NATIVE_QUERY_TOP_LEVEL_SERVER_ORACLE = "" //
+ + " SELECT r.id, r.uuid, r.mtime, r.inventory_status " //
+ + " FROM rhq_resource r " //
+ + " START WITH r.id = :resourceId " //
+ + " CONNECT BY PRIOR r.id = r.parent_resource_id ";
+ public static final String QUERY_NATIVE_QUERY_TOP_LEVEL_SERVER_POSTGRES = "" //
+ + " WITH RECURSIVE childResource AS " //
+ + " ( SELECT r.id, r.uuid, r.mtime, r.inventory_status " //
+ + " FROM rhq_resource AS r " //
+ + " WHERE r.id = :resourceId " // non-recursive term
+ + " UNION ALL " //
+ + " SELECT r.id, r.uuid, r.mtime, r.inventory_status " // recursive term
+ + " FROM rhq_resource AS r " //
+ + " JOIN childResource AS cr " //
+ + " ON (r.parent_resource_id = cr.id) " //
+ + " ) " //
+ + " SELECT id, uuid, mtime, inventory_status " //
+ + " FROM childResource ";
+
/**
* Server-assigned id
*/
@@ -140,7 +160,7 @@ public class ResourceSyncInfo implements Serializable {
return true;
}
- protected ResourceSyncInfo(int id, String uuid, long mtime, InventoryStatus istatus) {
+ public ResourceSyncInfo(int id, String uuid, long mtime, InventoryStatus istatus) {
this.id = id;
this.uuid = uuid;
this.mtime = mtime;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
index cf6e69c..bb74bf3 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
@@ -698,8 +698,8 @@ import org.rhq.core.domain.util.Summary;
@NamedQuery(name = Resource.QUERY_FIND_DESCENDANTS_BY_TYPE_AND_NAME, query = "" //
+ "SELECT r.id " //
+ " FROM Resource r " //
- + " WHERE ( r.resourceType.id = :resourceTypeId OR :resourceTypeId IS NULL ) " //
- + " AND ( UPPER(r.name) like :name OR :name IS NULL ) " //
+ + " WHERE ( r.resourceType.id = :resourceTypeId OR :resourceTypeId = 0 ) " //
+ + " AND ( UPPER(r.name) like :resourceName OR :resourceName = '$$$null$$$' ) " //
+ " AND ( r.id = :resourceId " //
+ " OR r.id IN (SELECT rr.id FROM Resource rr WHERE rr.parentResource.id = :resourceId) "
+ " OR r.id IN (SELECT rr.id FROM Resource rr WHERE rr.parentResource.parentResource.id = :resourceId) "
@@ -903,6 +903,80 @@ public class Resource implements Comparable<Resource>, Serializable {
public static final String QUERY_RESOURCE_VERSION_AND_DRIFT_IN_COMPLIANCE = "Resource.findResourceVersionDriftInCompliance";
public static final String QUERY_RESOURCE_VERSION_AND_DRIFT_OUT_OF_COMPLIANCE = "Resource.findResourceVersionDriftOutOfCompliance";
+ // Native Queries not supported by HQL
+ public static final String QUERY_NATIVE_FIND_DESCENDANTS_ORACLE = "" //
+ + " SELECT r.id " //
+ + " FROM rhq_resource r " //
+ + " START WITH r.id = :resourceId " //
+ + " CONNECT BY PRIOR r.id = r.parent_resource_id ";
+ public static final String QUERY_NATIVE_FIND_DESCENDANTS_POSTGRES = "" //
+ + " WITH RECURSIVE childResource AS " //
+ + " ( SELECT r.id " //
+ + " FROM rhq_resource AS r " //
+ + " WHERE r.id = :resourceId " // non-recursive term
+ + " UNION ALL " //
+ + " SELECT r.id " // recursive term
+ + " FROM rhq_resource AS r " //
+ + " JOIN childResource AS cr " //
+ + " ON (r.parent_resource_id = cr.id) " //
+ + " ) " //
+ + " SELECT id " //
+ + " FROM childResource ";
+
+ /**
+ * Note, special parameter values to represent NULL, do not use NULL:<pre>
+ * :resourceTypeId = 0
+ * :resourceName = "$$$null$$$"</pre>
+ */
+ public static final String QUERY_NATIVE_FIND_DESCENDANTS_BY_TYPE_AND_NAME_ORACLE = "" //
+ + " SELECT r.id " //
+ + " FROM rhq_resource r " //
+ + " WHERE ( r.resource_type_id = :resourceTypeId OR :resourceTypeId = 0 ) " //
+ + " AND ( UPPER(r.name) LIKE :resourceName OR :resourceName = '$$$null$$$' ) " //
+ + " START WITH r.id = :resourceId " //
+ + " CONNECT BY PRIOR r.id = r.parent_resource_id ";
+ /**
+ * Note, special parameter values to represent NULL, do not use NULL:<pre>
+ * :resourceTypeId = 0
+ * :resourceName = "$$$null$$$"</pre>
+ */
+ public static final String QUERY_NATIVE_FIND_DESCENDANTS_BY_TYPE_AND_NAME_POSTGRES = "" //
+ + " WITH RECURSIVE childResource AS " //
+ + " ( SELECT r.id AS resourceId, r.name AS resourceName, r.resource_type_id AS resourceTypeId " //
+ + " FROM rhq_resource AS r " //
+ + " WHERE r.id = :resourceId " //
+ + " UNION ALL " //
+ + " SELECT r.id AS resourceId, r.name AS resourceName, r.resource_type_id AS resourceTypeId " //
+ + " FROM rhq_resource AS r " //
+ + " JOIN childResource AS cr " //
+ + " ON (r.parent_resource_id = cr.resourceId) " //
+ + " ) " //
+ + " SELECT cr.resourceId " //
+ + " FROM childResource AS cr " //
+ + " WHERE ( cr.resourceTypeId = :resourceTypeId OR :resourceTypeId = 0 ) " //
+ + " AND ( UPPER(cr.resourceName) LIKE :resourceName OR :resourceName = '$$$null$$$' ) ";
+
+ public static final String QUERY_NATIVE_FIND_RESOURCE_PLATFORM_ORACLE = "" //
+ + " SELECT r.id " //
+ + " FROM rhq_resource r " //
+ + " WHERE r.parent_resource_id IS NULL " //
+ + " START WITH r.id = :resourceId " //
+ + " CONNECT BY PRIOR r.parent_resource_id = r.id ";
+ public static final String QUERY_NATIVE_FIND_RESOURCE_PLATFORM_POSTGRES = "" //
+ + " WITH RECURSIVE parentResource AS " //
+ + " ( SELECT r.id AS resourceId, r.parent_resource_id AS parentResourceId " //
+ + " FROM rhq_resource AS r " //
+ + " WHERE r.id = :resourceId " //
+ + " UNION " //
+ + " SELECT r.id AS resourceId, r.parent_resource_id AS parentResourceId " //
+ + " FROM rhq_resource AS r " //
+ + " JOIN parentResource AS pr " //
+ + " ON (r.id = pr.parentResourceId) " //
+ + " ) " //
+ + " SELECT pr.resourceId " //
+ + " FROM parentResource AS pr " //
+ + " WHERE ( pr.parentResourceId IS NULL ) ";
+
private static final int UUID_LENGTH = 36;
private static final long serialVersionUID = 1L;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/gwt/ResourceGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/gwt/ResourceGWTService.java
index d166dab..75e5b29 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/gwt/ResourceGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/gwt/ResourceGWTService.java
@@ -89,8 +89,6 @@ public interface ResourceGWTService extends RemoteService {
List<ResourceInstallCount> findResourceInstallCounts(boolean groupByVersions) throws RuntimeException;
- Resource getPlatformForResource(int resourceId) throws RuntimeException;
-
PageList<Resource> getQueuedPlatforms(ArrayList<InventoryStatus> statuses, PageControl pc)
throws RuntimeException;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/server/gwt/ResourceGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/server/gwt/ResourceGWTServiceImpl.java
index f89f31a..ca4c595 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/server/gwt/ResourceGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/server/gwt/ResourceGWTServiceImpl.java
@@ -243,15 +243,6 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl implements Re
}
}
- public Resource getPlatformForResource(int resourceId) throws RuntimeException {
- try {
- return SerialUtility.prepare(resourceManager.getRootResourceForResource(resourceId),
- "ResourceService.getPlatformForResource");
- } catch (Throwable t) {
- throw getExceptionToThrowToClient(t);
- }
- }
-
public List<RecentlyAddedResourceComposite> findRecentlyAddedResources(long ctime, int maxItems)
throws RuntimeException {
try {
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 6c8548d..0cfbb01 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
@@ -65,6 +65,8 @@ import org.rhq.core.clientapi.agent.upgrade.ResourceUpgradeResponse;
import org.rhq.core.clientapi.server.discovery.InvalidInventoryReportException;
import org.rhq.core.clientapi.server.discovery.InventoryReport;
import org.rhq.core.clientapi.server.discovery.StaleTypeException;
+import org.rhq.core.db.DatabaseType;
+import org.rhq.core.db.DatabaseTypeFactory;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.configuration.Configuration;
@@ -334,14 +336,42 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
}
}
+ @SuppressWarnings("unchecked")
@Override
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);
+ Query query = null;
+ Collection<ResourceSyncInfo> result = null;
+ boolean isNative = true;
+
+ DatabaseType dbType = DatabaseTypeFactory.getDefaultDatabaseType();
+ if (DatabaseTypeFactory.isOracle(dbType)) {
+ query = entityManager.createNativeQuery(ResourceSyncInfo.QUERY_NATIVE_QUERY_TOP_LEVEL_SERVER_ORACLE);
+
+ } else if (DatabaseTypeFactory.isPostgres(dbType)) {
+ query = entityManager.createNativeQuery(ResourceSyncInfo.QUERY_NATIVE_QUERY_TOP_LEVEL_SERVER_POSTGRES);
+
+ } else {
+ isNative = false;
+ query = entityManager.createNamedQuery(ResourceSyncInfo.QUERY_TOP_LEVEL_SERVER);
+ }
+
+ query.setParameter("resourceId", resourceId);
- Collection<ResourceSyncInfo> result = q.getResultList();
+ if ( isNative ) {
+ List<Object[]> rows = query.getResultList();
+ result = new ArrayList<ResourceSyncInfo>(rows.size());
+ for ( Object[] row : rows ) {
+ int id = dbType.getInteger(row[0]);
+ String uuid = (String)row[1];
+ long mtime = dbType.getLong(row[2]);
+ InventoryStatus status = InventoryStatus.valueOf((String)row[3]);
+ result.add(new ResourceSyncInfo(id, uuid, mtime, status));
+ }
+ } else {
+ result = query.getResultList();
+ }
return result;
}
@@ -634,7 +664,8 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
Resource existingResource = findExistingResource(resource, null);
if (existingResource != null) {
- mergeResourceResponse = new MergeResourceResponse(existingResource.getId(), true);
+ mergeResourceResponse = new MergeResourceResponse(existingResource.getId(), existingResource.getMtime(),
+ true);
} else {
Subject creator = this.subjectManager.getSubjectById(creatorSubjectId);
try {
@@ -658,7 +689,7 @@ public class DiscoveryBossBean implements DiscoveryBossLocal, DiscoveryBossRemot
throw new IllegalStateException(e);
}
- mergeResourceResponse = new MergeResourceResponse(resource.getId(), false);
+ mergeResourceResponse = new MergeResourceResponse(resource.getId(), resource.getCtime(), false);
}
return mergeResourceResponse;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
index c1a745b..6bb586e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/ResourceManagerBean.java
@@ -388,9 +388,7 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
// set agent references null
// foobar the resourceKeys
// update the inventory status to UNINVENTORY
- Query toBeDeletedQuery = entityManager.createNamedQuery(Resource.QUERY_FIND_DESCENDANTS);
- toBeDeletedQuery.setParameter("resourceId", resourceId);
- List<Integer> toBeDeletedResourceIds = toBeDeletedQuery.getResultList();
+ List<Integer> toBeDeletedResourceIds = getDescendents(resourceId);
int i = 0;
if (isDebugEnabled) {
@@ -490,15 +488,71 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
}
@SuppressWarnings("unchecked")
+ private List<Integer> getDescendents(int resourceId) {
+ List<Integer> result = null;
+ Query query = null;
+
+ DatabaseType dbType = DatabaseTypeFactory.getDefaultDatabaseType();
+ if (DatabaseTypeFactory.isOracle(dbType)) {
+ query = entityManager.createNativeQuery(Resource.QUERY_NATIVE_FIND_DESCENDANTS_ORACLE);
+
+ } else if (DatabaseTypeFactory.isPostgres(dbType)) {
+ query = entityManager.createNativeQuery(Resource.QUERY_NATIVE_FIND_DESCENDANTS_POSTGRES);
+
+ } else {
+ query = entityManager.createNamedQuery(Resource.QUERY_FIND_DESCENDANTS);
+ }
+
+ query.setParameter("resourceId", resourceId);
+
+ if (DatabaseTypeFactory.isOracle(dbType)) {
+ List<?> rl = query.getResultList();
+ result = new ArrayList<Integer>(rl.size());
+ for (Object id : rl) {
+ result.add(dbType.getInteger(id));
+ }
+ } else {
+ // native Integer support
+ result = query.getResultList();
+ }
+
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
public List<Integer> getResourceDescendantsByTypeAndName(Subject user, int resourceId, Integer resourceTypeId,
String name) {
- Query descendantQuery = entityManager.createNamedQuery(Resource.QUERY_FIND_DESCENDANTS_BY_TYPE_AND_NAME);
- descendantQuery.setParameter("resourceId", resourceId);
- descendantQuery.setParameter("resourceTypeId", resourceTypeId);
+
+ List<Integer> result = null;
+ Query query = null;
+ DatabaseType dbType = DatabaseTypeFactory.getDefaultDatabaseType();
+
+ if (DatabaseTypeFactory.isOracle(dbType)) {
+ query = entityManager.createNativeQuery(Resource.QUERY_NATIVE_FIND_DESCENDANTS_BY_TYPE_AND_NAME_ORACLE);
+
+ } else if (DatabaseTypeFactory.isPostgres(dbType)) {
+ query = entityManager.createNativeQuery(Resource.QUERY_NATIVE_FIND_DESCENDANTS_BY_TYPE_AND_NAME_POSTGRES);
+
+ } else {
+ query = entityManager.createNamedQuery(Resource.QUERY_FIND_DESCENDANTS_BY_TYPE_AND_NAME);
+ }
+
+ query.setParameter("resourceId", resourceId);
+ query.setParameter("resourceTypeId", ((null != resourceTypeId) ? resourceTypeId : 0));
name = QueryUtility.formatSearchParameter(name);
- descendantQuery.setParameter("name", name);
- List<Integer> descendants = descendantQuery.getResultList();
- return descendants;
+ query.setParameter("resourceName", ((null != name) ? name : "$$$null$$$"));
+
+ if (DatabaseTypeFactory.isOracle(dbType)) {
+ List<?> rl = query.getResultList();
+ result = new ArrayList<Integer>(rl.size());
+ for (Object id : rl) {
+ result.add(dbType.getInteger(id));
+ }
+ } else {
+ // native Integer support
+ result = query.getResultList();
+ }
+ return result;
}
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
@@ -1120,12 +1174,37 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
return sb.toString();
}
+ // Used by Portal WAR only
+ @Deprecated
@NotNull
public Resource getRootResourceForResource(int resourceId) {
- Query q = entityManager.createNamedQuery(Resource.QUERY_FIND_ROOT_PLATFORM_OF_RESOURCE);
- q.setParameter("resourceId", resourceId);
+ Query query = null;
+ Resource result = null;
+ DatabaseType dbType = DatabaseTypeFactory.getDefaultDatabaseType();
- return (Resource) q.getSingleResult();
+ if (DatabaseTypeFactory.isOracle(dbType)) {
+ query = entityManager.createNativeQuery(Resource.QUERY_NATIVE_FIND_RESOURCE_PLATFORM_ORACLE);
+
+ } else if (DatabaseTypeFactory.isPostgres(dbType)) {
+ query = entityManager.createNativeQuery(Resource.QUERY_NATIVE_FIND_RESOURCE_PLATFORM_POSTGRES);
+
+ } else {
+ query = entityManager.createNamedQuery(Resource.QUERY_FIND_ROOT_PLATFORM_OF_RESOURCE);
+ }
+
+ query.setParameter("resourceId", resourceId);
+
+ Integer platformId;
+ if (DatabaseTypeFactory.isOracle(dbType)) {
+ platformId = dbType.getInteger(query.getSingleResult());
+
+ } else {
+ // native Integer support
+ platformId = (Integer)query.getSingleResult();
+ }
+
+ result = entityManager.find(Resource.class, platformId);
+ return result;
}
@SuppressWarnings("unchecked")
@@ -2879,14 +2958,9 @@ public class ResourceManagerBean implements ResourceManagerLocal, ResourceManage
}
private List<Integer> getFamily(Resource resource) {
+ List<Integer> result = getDescendents(resource.getId());
- // note - this query is good only to 6 levels deep
- Query query = entityManager.createNamedQuery(Resource.QUERY_FIND_DESCENDANTS);
- query.setParameter("resourceId", resource.getId());
-
- List<Integer> resourceIds = query.getResultList();
-
- return resourceIds;
+ return result;
}
@Override
commit 31301a1f167e289814f31e2af343834544edb641
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Feb 25 09:45:47 2014 -0500
Added getLong() to the interface since different vendors do it differently.
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/DatabaseType.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/DatabaseType.java
index 9e141a8..88f1405 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/DatabaseType.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/DatabaseType.java
@@ -277,8 +277,8 @@ public abstract class DatabaseType {
* Get the Integer representation of the number type supplied by the db vendor for an integer field value.
* The default implementation simply applies a cast to the passed in number and is appropriate for DB types
* that support a native integer field type (like Postgres). Other db types should override this method
- * (like Oracle).
- *
+ * (like Oracle).
+ *
* @param number
* @return
*/
@@ -287,6 +287,18 @@ public abstract class DatabaseType {
}
/**
+ * Get the Long representation of the number type supplied by the db vendor for a long field value.
+ * The default implementation simply applies a cast to the passed in number and is appropriate for DB types
+ * that support a native long field type. Other db types should override this method (like Oracle).
+ *
+ * @param number
+ * @return
+ */
+ public Long getLong(Object number) {
+ return (Long) number;
+ }
+
+ /**
* Fill out a <code>PreparedStatement</code> correctly with a boolean.
*
* @param bool the boolean you want
@@ -310,7 +322,7 @@ public abstract class DatabaseType {
* the implementation determined the information WITHOUT generating an SQLException (meaning the
* transaction has not been invalidated. Otherwise, throws an exception which should be handled.
*
- * @throws IllegalStateException if the check generated an expected "table does not exist SQLException (note, the
+ * @throws IllegalStateException if the check generated an expected "table does not exist SQLException (note, the
* exception invalidates the transaction).
* @throws Exception if the table check failed for a reason other than a "table does not exist" error.
*/
@@ -646,8 +658,8 @@ public abstract class DatabaseType {
* Provides the value to be used for the ESCAPE character in string literals. The SQL standard is a single
* character, typically '\', but not every dbType conforms to the standard. To override the db default set
* the rhq.server.database.escape-character system property.
- *
- * @return If set, the value of rhq.server.database.escape-character, otherwise the db default.
+ *
+ * @return If set, the value of rhq.server.database.escape-character, otherwise the db default.
*/
public String getEscapeCharacter() {
String result = System.getProperty("rhq.server.database.escape-character");
@@ -658,7 +670,7 @@ public abstract class DatabaseType {
/**
* Most vendors support foreign keys to itself that in fact perform cascade delete. But some do not and
* that currently affects our data model. (see rhq_config_property in content-schema.xml).
- *
+ *
* @return true unless overriden to return false.
*/
public boolean supportsSelfReferringCascade() {
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/OracleDatabaseType.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/OracleDatabaseType.java
index 15ee0af..0e0fb2a 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/OracleDatabaseType.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/OracleDatabaseType.java
@@ -64,9 +64,9 @@ public abstract class OracleDatabaseType extends DatabaseType {
/* (non-Javadoc)
* @see org.rhq.core.db.DatabaseType#getInteger(java.lang.Object)
- *
+ *
* Oracle stores integer fields as Numbers and returns a BigDecimal. It is assumed <code>number</code> is actually
- * an integer value, otherwise precision will be lost in this conversion.
+ * an integer value, otherwise precision will be lost in this conversion.
*/
@Override
public Integer getInteger(Object number) {
@@ -74,6 +74,18 @@ public abstract class OracleDatabaseType extends DatabaseType {
return intField.intValue();
}
+ /* (non-Javadoc)
+ * @see org.rhq.core.db.DatabaseType#getLong(java.lang.Object)
+ *
+ * Oracle stores long fields as Numbers and returns a BigDecimal. It is assumed <code>number</code> is actually
+ * a long value, otherwise precision will be lost in this conversion.
+ */
+ @Override
+ public Long getLong(Object number) {
+ BigDecimal longField = (BigDecimal) number;
+ return longField.longValue();
+ }
+
/**
* For Oracle databases, the boolean parameter will actually be of type "int" with a value of 0 or 1.
*
diff --git a/modules/core/dbutils/src/main/java/org/rhq/core/db/PostgresqlDatabaseType.java b/modules/core/dbutils/src/main/java/org/rhq/core/db/PostgresqlDatabaseType.java
index 4d376f3..a1594dc 100644
--- a/modules/core/dbutils/src/main/java/org/rhq/core/db/PostgresqlDatabaseType.java
+++ b/modules/core/dbutils/src/main/java/org/rhq/core/db/PostgresqlDatabaseType.java
@@ -18,6 +18,7 @@
*/
package org.rhq.core.db;
+import java.math.BigInteger;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -42,10 +43,12 @@ public abstract class PostgresqlDatabaseType extends DatabaseType {
*
* @see DatabaseType#getVendor()
*/
+ @Override
public String getVendor() {
return VENDOR_NAME;
}
+ @Override
public String getHibernateDialect() {
return "org.hibernate.dialect.PostgreSQLDialect";
}
@@ -53,6 +56,7 @@ public abstract class PostgresqlDatabaseType extends DatabaseType {
/**
* @see DatabaseType#isTableNotFoundException(SQLException)
*/
+ @Override
public boolean isTableNotFoundException(SQLException e) {
return (e.getSQLState().toUpperCase().equals("42P01"));
}
@@ -63,6 +67,7 @@ public abstract class PostgresqlDatabaseType extends DatabaseType {
*
* @see DatabaseType#getSequenceValue(Connection, String, String)
*/
+ @Override
public int getSequenceValue(Connection conn, String table, String key) throws SQLException {
String query = "SELECT currval('" + table + "_" + key + "_seq')";
PreparedStatement selectPS = null;
@@ -86,6 +91,7 @@ public abstract class PostgresqlDatabaseType extends DatabaseType {
/**
* @see DatabaseType#getNextSequenceValue(Connection, String, String)
*/
+ @Override
public int getNextSequenceValue(Connection conn, String table, String key) throws SQLException {
String query = "SELECT nextval('" + table + "_" + key + "_seq'::text)";
@@ -110,6 +116,7 @@ public abstract class PostgresqlDatabaseType extends DatabaseType {
/**
* @see DatabaseType#alterColumn(Connection, String, String, String, String, String, Boolean, Boolean)
*/
+ @Override
public void alterColumn(Connection conn, String table, String column, String generic_column_type,
String default_value, String precision, Boolean nullable, Boolean reindex) throws SQLException {
String db_column_type = null;
@@ -150,6 +157,7 @@ public abstract class PostgresqlDatabaseType extends DatabaseType {
/**
* @see DatabaseType#reindexTable(Connection, String)
*/
+ @Override
public void reindexTable(Connection conn, String table) throws SQLException {
executeSql(conn, "REINDEX TABLE " + table);
}
@@ -162,13 +170,26 @@ public abstract class PostgresqlDatabaseType extends DatabaseType {
* Note 1: The default behavior may change in a future version of postgres given that
* the standard_conforming_strings setting may change from 'off' to 'on' out of the box.
* Note 2: Also related, http://opensource.atlassian.com/projects/hibernate/browse/HHH-2674 for more.
- *
+ *
* @see DatabaseType#getEscapeCharacter()
*/
+ @Override
public String getEscapeCharacter() {
String result = System.getProperty("rhq.server.database.escape-character");
return (null == result) ? "\\\\" : result;
}
+ /* (non-Javadoc)
+ * @see org.rhq.core.db.DatabaseType#getLong(java.lang.Object)
+ *
+ * Postgres stores long fields as BigInteger and returns a BigInteger. It is assumed <code>number</code> is actually
+ * a long value, otherwise precision will be lost in this conversion.
+ */
+ @Override
+ public Long getLong(Object number) {
+ BigInteger longField = (BigInteger) number;
+ return longField.longValue();
+ }
+
}
\ No newline at end of file
10 years, 2 months
[rhq] modules/enterprise modules/plugins
by Jiri Kremser
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagement.java | 103 ++++++----
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagementMBean.java | 5
modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml | 8
3 files changed, 74 insertions(+), 42 deletions(-)
New commits:
commit 57fdc211b633b7cea15485cc11cbd79b7a207cf6
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Tue Feb 25 18:39:38 2014 +0100
[BZ 536287] - (RHQ-653) Agent "Get Info On All Plugins" operation does not return the short name of a plugin (and is inconsistent with the agent prompt) - Returning also the display name and the short name of plugin for both the retrieveAllPluginInfo and the retrievePluginInfo agent operations. Now it is more consistent with the prompt command for agent (plugins info) and the short plugin name can be used elsewhere.
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagement.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagement.java
index 249cb51..11eb3e3 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagement.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagement.java
@@ -22,6 +22,7 @@ import java.io.CharArrayWriter;
import java.io.File;
import java.io.IOException;
import java.lang.management.ManagementFactory;
+import java.net.URL;
import java.text.DateFormat;
import java.util.Date;
import java.util.List;
@@ -36,6 +37,9 @@ import javax.management.MBeanServer;
import javax.management.MBeanServerInvocationHandler;
import javax.management.ObjectName;
+import org.rhq.core.clientapi.agent.metadata.PluginMetadataManager;
+import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil;
+import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
import org.rhq.core.clientapi.server.core.CoreServerService;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertyList;
@@ -158,38 +162,49 @@ public class AgentManagement implements AgentManagementMBean, MBeanRegistration
public OperationResult retrieveAllPluginInfo() {
List<File> plugins;
-
+ OperationResult info = new OperationResult();
ClassLoader originalCL = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
PluginUpdate updater = getPluginUpdateObject();
plugins = updater.getCurrentPluginFiles();
- } finally {
- Thread.currentThread().setContextClassLoader(originalCL);
- }
- OperationResult info = new OperationResult();
- PropertyList list = new PropertyList("plugins");
- info.getComplexResults().put(list);
+ PropertyList list = new PropertyList("plugins".intern());
+ info.getComplexResults().put(list);
+
+ if (plugins.size() > 0) {
+ for (File plugin : plugins) {
+ String pluginName;
+ String pluginDisplayName;
+ try {
+ URL url = plugin.toURI().toURL();
+ PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(url);
+ pluginName = descriptor.getName();
+ pluginDisplayName = descriptor.getDisplayName();
+ } catch (Exception t) {
+ pluginName = "?cannot-parse-descriptor?".intern();
+ pluginDisplayName = "?cannot-parse-descriptor?".intern();
+ }
- if (plugins.size() > 0) {
- for (File plugin : plugins) {
- PropertyMap map = new PropertyMap("plugin");
- map.put(new PropertySimple(PLUGIN_INFO_NAME, plugin.getName()));
- map.put(new PropertySimple(PLUGIN_INFO_PATH, plugin.getAbsoluteFile()));
- map.put(new PropertySimple(PLUGIN_INFO_TIMESTAMP, new Date(plugin.lastModified())));
- map.put(new PropertySimple(PLUGIN_INFO_SIZE, plugin.length()));
+ PropertyMap map = new PropertyMap("plugin".intern());
+ map.put(new PropertySimple(PLUGIN_INFO_NAME, pluginName));
+ map.put(new PropertySimple(PLUGIN_INFO_DISPLAY_NAME, pluginDisplayName));
+ map.put(new PropertySimple(PLUGIN_INFO_PATH, plugin.getAbsoluteFile()));
+ map.put(new PropertySimple(PLUGIN_INFO_TIMESTAMP, new Date(plugin.lastModified())));
+ map.put(new PropertySimple(PLUGIN_INFO_SIZE, plugin.length()));
- try {
- map.put(new PropertySimple(PLUGIN_INFO_MD5, MessageDigestGenerator.getDigestString(plugin)));
- } catch (IOException e) {
- map.put(new PropertySimple(PLUGIN_INFO_MD5, e.toString()));
- }
+ try {
+ map.put(new PropertySimple(PLUGIN_INFO_MD5, MessageDigestGenerator.getDigestString(plugin)));
+ } catch (IOException e) {
+ map.put(new PropertySimple(PLUGIN_INFO_MD5, e.toString()));
+ }
- list.add(map);
+ list.add(map);
+ }
}
+ } finally {
+ Thread.currentThread().setContextClassLoader(originalCL);
}
-
return info;
}
@@ -201,31 +216,41 @@ public class AgentManagement implements AgentManagementMBean, MBeanRegistration
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
PluginUpdate updater = getPluginUpdateObject();
plugins = updater.getCurrentPluginFiles();
- } finally {
- Thread.currentThread().setContextClassLoader(originalCL);
- }
-
- if (plugins.size() > 0) {
- for (File plugin : plugins) {
- if (plugin.getName().equals(pluginName)) {
- OperationResult opResults = new OperationResult();
- Configuration info = opResults.getComplexResults();
- info.put(new PropertySimple(PLUGIN_INFO_NAME, plugin.getName()));
- info.put(new PropertySimple(PLUGIN_INFO_PATH, plugin.getAbsoluteFile()));
- info.put(new PropertySimple(PLUGIN_INFO_TIMESTAMP, new Date(plugin.lastModified())));
- info.put(new PropertySimple(PLUGIN_INFO_SIZE, plugin.length()));
+ if (plugins.size() > 0) {
+ for (File plugin : plugins) {
+ String pluginDisplayName;
+ String pluginNameToReturn;
try {
- info.put(new PropertySimple(PLUGIN_INFO_MD5, MessageDigestGenerator.getDigestString(plugin)));
- } catch (IOException e) {
- info.put(new PropertySimple(PLUGIN_INFO_MD5, e.toString()));
+ URL url = plugin.toURI().toURL();
+ PluginDescriptor pluginDescriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(url);
+ pluginDisplayName = pluginDescriptor.getDisplayName();
+ pluginNameToReturn = pluginDescriptor.getName();
+ } catch (Exception t) {
+ continue;
}
- return opResults;
+ if (pluginNameToReturn.toLowerCase().equals(pluginName.toLowerCase())) {
+ OperationResult opResults = new OperationResult();
+ Configuration info = opResults.getComplexResults();
+ info.put(new PropertySimple(PLUGIN_INFO_NAME, pluginNameToReturn));
+ info.put(new PropertySimple(PLUGIN_INFO_DISPLAY_NAME, pluginDisplayName));
+ info.put(new PropertySimple(PLUGIN_INFO_PATH, plugin.getAbsoluteFile()));
+ info.put(new PropertySimple(PLUGIN_INFO_TIMESTAMP, new Date(plugin.lastModified())));
+ info.put(new PropertySimple(PLUGIN_INFO_SIZE, plugin.length()));
+ try {
+ info.put(new PropertySimple(PLUGIN_INFO_MD5, MessageDigestGenerator.getDigestString(plugin)));
+ } catch (IOException e) {
+ info.put(new PropertySimple(PLUGIN_INFO_MD5, e.toString()));
+ }
+
+ return opResults;
+ }
}
}
+ } finally {
+ Thread.currentThread().setContextClassLoader(originalCL);
}
-
throw new IllegalArgumentException("There is no plugin named [" + pluginName + "]");
}
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagementMBean.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagementMBean.java
index 1be62dc..9ba53b4 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagementMBean.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentManagementMBean.java
@@ -61,6 +61,11 @@ public interface AgentManagementMBean {
* Identifies the name of a plugin.
*/
String PLUGIN_INFO_NAME = "name";
+
+ /**
+ * Identifies the display name of a plugin.
+ */
+ String PLUGIN_INFO_DISPLAY_NAME = "displayName";
/**
* Identifies the full path to a plugin.
diff --git a/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
index c9820cf..b8ca439 100644
--- a/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-agent/src/main/resources/META-INF/rhq-plugin.xml
@@ -93,7 +93,8 @@
<results>
<c:list-property name="plugins">
<c:map-property name="plugin">
- <c:simple-property name="name" description="Name of the plugin" />
+ <c:simple-property name="name" description="Short name of the plugin" />
+ <c:simple-property name="displayName" description="Full name of the plugin" />
<c:simple-property name="path" description="Full path to the plugin as seen by the agent" />
<c:simple-property name="timestamp" description="Last time the plugin was updated" />
<c:simple-property name="size" description="Size of the plugin file" />
@@ -110,7 +111,8 @@
<c:simple-property name="pluginName" description="The name of the plugin whose info is to be retrieved"/>
</parameters>
<results>
- <c:simple-property name="name" description="Name of the plugin" />
+ <c:simple-property name="name" description="Short name of the plugin" />
+ <c:simple-property name="displayName" description="Full name of the plugin" />
<c:simple-property name="path" description="Full path to the plugin as seen by the agent" />
<c:simple-property name="timestamp" description="Last time the plugin was updated" />
<c:simple-property name="size" description="Size of the plugin file" />
@@ -836,4 +838,4 @@
</service>
</server>
-</plugin>
\ No newline at end of file
+</plugin>
10 years, 2 months