[rhq] modules/core
by Thomas Segismont
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/log/LogFileEventPoller.java | 66 +++++-----
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/log/LogFileEventResourceComponentHelper.java | 18 +-
2 files changed, 42 insertions(+), 42 deletions(-)
New commits:
commit b4c048f8dfe3aab6f4c8347e856b80f40e66f29a
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Thu Jan 30 18:15:50 2014 +0100
Bug 977350 - Log events will not be collected if target log file doesn't exist at the time the resource is started by the plug-in container
Changed the warning message to indicate that the poller will be started even if the file does not exist
Changed the poller implementation to support "bad" files (non existing or file is a directory): event polling will start as soon as a regular file is found
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/log/LogFileEventPoller.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/log/LogFileEventPoller.java
index b4e19c4..6a2c774 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/log/LogFileEventPoller.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/log/LogFileEventPoller.java
@@ -1,25 +1,22 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2012 Red Hat, Inc.
+ * 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, 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.
+ * 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 and the GNU Lesser General Public License
- * for more details.
+ * GNU 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.
+ * 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.pluginapi.event.log;
import java.io.BufferedReader;
@@ -47,7 +44,7 @@ import org.rhq.core.pluginapi.event.EventPoller;
* @author Ian Springer
*/
public class LogFileEventPoller implements EventPoller {
- private final Log log = LogFactory.getLog(this.getClass());
+ private static final Log LOG = LogFactory.getLog(LogFileEventPoller.class);
private String eventType;
private File logFile;
@@ -76,24 +73,27 @@ public class LogFileEventPoller implements EventPoller {
@Nullable
public Set<Event> poll() {
- if (!this.initialized) {
- init();
- }
- if (this.logFileInfo == null) {
- // This means SIGAR, which we require, is unavailable, so just return null.
- return null;
- }
-
if (!this.logFile.exists()) {
- log.warn("Log file [" + this.logFile + "] being polled does not exist.");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Log file [" + this.logFile + "] being polled does not exist.");
+ }
return null;
}
if (this.logFile.isDirectory()) {
- log.error("Log file [" + this.logFile + "] being polled is a directory, not a regular file.");
+ LOG.error("Log file [" + this.logFile + "] being polled is a directory, not a regular file.");
return null;
}
-
- try {
+ if (!this.initialized) {
+ init();
+ }
+ if (this.logFileInfo == null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Cannot poll log file [" + this.logFile
+ + "] because native integration is either disabled or unavailable.");
+ }
+ return null;
+ }
+ try {
if (!this.logFileInfo.changed()) {
return null;
}
@@ -118,7 +118,7 @@ public class LogFileEventPoller implements EventPoller {
throw new RuntimeException("Failed to obtain file info for log file [" + this.logFile + "].", e);
}
} else {
- log.warn("SIGAR is unavailable - cannot poll log file [" + this.logFile + "] for events.");
+ LOG.warn("SIGAR is unavailable - cannot poll log file [" + this.logFile + "] for events.");
}
this.initialized = true;
@@ -138,7 +138,7 @@ public class LogFileEventPoller implements EventPoller {
BufferedReader bufferedReader = new BufferedReader(reader);
events = this.entryProcessor.processLines(bufferedReader);
} catch (IOException e) {
- log.error("Failed to read log file being tailed: " + this.logFile, e);
+ LOG.error("Failed to read log file being tailed: " + this.logFile, e);
} finally {
if (reader != null) {
//noinspection EmptyCatchBlock
@@ -155,29 +155,29 @@ public class LogFileEventPoller implements EventPoller {
FileInfo previousFileInfo = fileInfo.getPreviousInfo();
if (previousFileInfo == null) {
- if (log.isDebugEnabled()) {
- log.debug(this.logFile + ": first stat");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(this.logFile + ": first stat");
}
return fileInfo.getSize();
}
if (fileInfo.getInode() != previousFileInfo.getInode()) {
- if (log.isDebugEnabled()) {
- log.debug(this.logFile + ": file inode changed");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(this.logFile + ": file inode changed");
}
return -1;
}
if (fileInfo.getSize() < previousFileInfo.getSize()) {
- if (log.isDebugEnabled()) {
- log.debug(this.logFile + ": file truncated");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(this.logFile + ": file truncated");
}
return -1;
}
- if (log.isDebugEnabled()) {
+ if (LOG.isDebugEnabled()) {
long diff = fileInfo.getSize() - previousFileInfo.getSize();
- log.debug(this.logFile + ": " + diff + " new bytes");
+ LOG.debug(this.logFile + ": " + diff + " new bytes");
}
return previousFileInfo.getSize();
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/log/LogFileEventResourceComponentHelper.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/log/LogFileEventResourceComponentHelper.java
index 37a99eb..147b423 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/log/LogFileEventResourceComponentHelper.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/event/log/LogFileEventResourceComponentHelper.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2012 Red Hat, Inc.
+ * Copyright (C) 2005-2014 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,9 +13,10 @@
* 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.
+ * 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.pluginapi.event.log;
import java.io.File;
@@ -49,6 +50,8 @@ import org.rhq.core.system.SystemInfoFactory;
* @author Ian Springer
*/
public class LogFileEventResourceComponentHelper {
+ private static final Log LOG = LogFactory.getLog(LogFileEventResourceComponentHelper.class);
+
public static final String LOG_ENTRY_EVENT_TYPE = "logEntry";
public static final String LOG_EVENT_SOURCES_CONFIG_PROP = "logEventSources";
@@ -65,8 +68,6 @@ public class LogFileEventResourceComponentHelper {
// TODO: Make this configurable via a plugin config prop.
private static final int POLLING_INTERVAL_IN_SECONDS = 60;
- private final Log log = LogFactory.getLog(this.getClass());
-
private ResourceContext<?> resourceContext;
private List<PropertyMap> startedEventSources = new ArrayList<PropertyMap>();
@@ -105,7 +106,7 @@ public class LogFileEventResourceComponentHelper {
boolean nativeSystemInfoDisabled = SystemInfoFactory.isNativeSystemInfoDisabled();
ResourceType resourceType = this.resourceContext.getResourceType();
List<String> logFilePaths = getLogFilePaths(enabledEventSources);
- log.warn("Log files " + logFilePaths + " for [" + resourceType.getPlugin() + ":"
+ LOG.warn("Log files " + logFilePaths + " for [" + resourceType.getPlugin() + ":"
+ resourceType.getName() + "] Resource with key [" + this.resourceContext.getResourceKey()
+ "] cannot be polled, because log file polling requires RHQ native support, which "
+ ((nativeSystemInfoDisabled) ? "has been disabled for this Agent" : "is not available on this platform") + ".");
@@ -121,9 +122,8 @@ public class LogFileEventResourceComponentHelper {
}
File logFile = new File(logFilePath);
if (!logFile.canRead()) {
- log.error("LOGFILE: Logfile at location " + logFilePath
- + " does not exist or is not readable. Can not start watching the event log.");
- continue;
+ LOG.warn("LOGFILE: Logfile at location " + logFilePath + " does not exist or is not readable. "
+ + "The poller will be started but no events will be polled until the file is created.");
}
Log4JLogEntryProcessor processor = new Log4JLogEntryProcessor(LOG_ENTRY_EVENT_TYPE, logFile);
10 years, 3 months
[rhq] modules/enterprise
by lkrejci
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/groups/detail/monitoring/metric/MetricsGroupViewDataSource.java | 27 +++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/resource/detail/monitoring/table/MetricsViewDataSource.java | 27 +++++-----
2 files changed, 28 insertions(+), 26 deletions(-)
New commits:
commit 3cbe934a3b7f986ca816744bb2578bdfbad23e56
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Jan 30 18:04:52 2014 +0100
[BZ 1031200] - Don't assume unique display names of metrics
While having unique names generally is true and even desirable, we were
throwing NPE's in the UI due to that assumption.
Now the UI will just correctly show 2 metrics with the same name which will
hint the user correctly that there's something wrong with the plugin,
not with RHQ itself.
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 a5f1353..dd67500 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
@@ -21,6 +21,8 @@ package org.rhq.coregui.client.inventory.groups.detail.monitoring.metric;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -256,24 +258,23 @@ public class MetricsGroupViewDataSource extends RPCDataSource<MetricDisplaySumma
}
private void organizeMeasurementDefinitionOrder(ResourceGroup resourceGroup) {
- Set<MeasurementDefinition> definitions = getMetricDefinitions(resourceGroup);
+ List<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);
+ Collections.sort(definitions, new Comparator<MeasurementDefinition>() {
+ @Override
+ public int compare(MeasurementDefinition o1, MeasurementDefinition o2) {
+ return o1.getDisplayName().compareTo(o2.getDisplayName());
+ }
+ });
//organize definitionArrayIds for ordered request on server.
int index = 0;
- for (String definitionToDisplay : displayOrder) {
- definitionArrayIds[index++] = measurementDefMap.get(definitionToDisplay).getId();
+ for (MeasurementDefinition definitionToDisplay : definitions) {
+ definitionArrayIds[index++] = definitionToDisplay.getId();
}
}
@@ -302,8 +303,8 @@ public class MetricsGroupViewDataSource extends RPCDataSource<MetricDisplaySumma
this.metricDisplaySummaries = metricDisplaySummaries;
}
- private Set<MeasurementDefinition> getMetricDefinitions(ResourceGroup resourceGroup) {
- Set<MeasurementDefinition> definitions = new HashSet<MeasurementDefinition>();
+ private List<MeasurementDefinition> getMetricDefinitions(ResourceGroup resourceGroup) {
+ List<MeasurementDefinition> definitions = new ArrayList<MeasurementDefinition>();
for (MeasurementDefinition measurementDefinition : resourceGroup.getResourceType().getMetricDefinitions()) {
if (measurementDefinition.getDataType() == MEASUREMENT || measurementDefinition.getDataType() == COMPLEX) {
definitions.add(measurementDefinition);
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 248eee0..db79dc0 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
@@ -24,6 +24,8 @@ import static org.rhq.core.domain.measurement.DataType.MEASUREMENT;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -351,7 +353,7 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
private void queryResourceMetrics(final Resource resource, final Long startTime, final Long endTime,
final CountDownLatch countDownLatch) {
- HashSet<MeasurementDefinition> definitions = getMetricDefinitions(resource);
+ List<MeasurementDefinition> definitions = getMetricDefinitions(resource);
if (definitions.size() == 0) {
countDownLatch.countDown();
return;
@@ -366,22 +368,21 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
}
}
- //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);
+ Collections.sort(definitions, new Comparator<MeasurementDefinition>() {
+ @Override
+ public int compare(MeasurementDefinition o1, MeasurementDefinition o2) {
+ return o1.getDisplayName().compareTo(o2.getDisplayName());
+ }
+ });
//organize definitionArrayIds for ordered request on server.
int index = 0;
- for (String definitionToDisplay : displayOrder) {
- definitionArrayIds[index++] = measurementDefMap.get(definitionToDisplay).getId();
+ for (MeasurementDefinition definitionToDisplay : definitions) {
+ definitionArrayIds[index++] = definitionToDisplay.getId();
}
GWTServiceLookup.getMeasurementDataService().findDataForResource(resource.getId(), definitionArrayIds,
@@ -405,8 +406,8 @@ public class MetricsViewDataSource extends RPCDataSource<MetricDisplaySummary, C
}
- private HashSet<MeasurementDefinition> getMetricDefinitions(Resource resource) {
- HashSet<MeasurementDefinition> definitions = new HashSet<MeasurementDefinition>();
+ private List<MeasurementDefinition> getMetricDefinitions(Resource resource) {
+ List<MeasurementDefinition> definitions = new ArrayList<MeasurementDefinition>();
for (MeasurementDefinition measurementDefinition : resource.getResourceType().getMetricDefinitions()) {
if (measurementDefinition.getDataType() == MEASUREMENT || measurementDefinition.getDataType() == COMPLEX) {
definitions.add(measurementDefinition);
10 years, 3 months
[rhq] 2 commits - modules/core modules/enterprise
by Jay Shaughnessy
modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/avail/AvailTest.java | 20
modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/CmdlineClient.java | 7
modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java | 322 ++--------
3 files changed, 103 insertions(+), 246 deletions(-)
New commits:
commit 7f08f14c4c8a025b169e32e0378335cf9a243c36
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Jan 30 11:55:47 2014 -0500
Fix iPC -tests, allow negative resource ids; now possible for tests based
on FakeServerInventpory.
diff --git a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/avail/AvailTest.java b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/avail/AvailTest.java
index 5c9a5ca..85e1ec2 100644
--- a/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/avail/AvailTest.java
+++ b/modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/avail/AvailTest.java
@@ -195,7 +195,7 @@ public class AvailTest extends Arquillian {
Assert.assertEquals(report.isChangesOnlyReport(), false, "First report should have been a full report");
List<Datum> availData = report.getResourceAvailability();
for (Datum datum : availData) {
- assert datum.getResourceId() > 0 : "resource IDs should be > zero since it should be committed";
+ assert datum.getResourceId() != 0 : "resource ID should be != zero since it should be committed";
Assert.assertEquals(datum.getAvailabilityType(), AvailabilityType.UP, "should be UP at the start");
}
AvailabilityExecutor.Scan scan = executor.getMostRecentScanHistory();
@@ -238,7 +238,7 @@ public class AvailTest extends Arquillian {
Assert.assertEquals(report.isChangesOnlyReport(), false, "First report should have been a full report");
List<Datum> availData = report.getResourceAvailability();
for (Datum datum : availData) {
- assert datum.getResourceId() > 0 : "resource IDs should be > zero since it should be committed";
+ assert datum.getResourceId() != 0 : "resource IDs should be != zero since it should be committed";
Assert.assertEquals(datum.getAvailabilityType(), AvailabilityType.UP, "should be UP at the start");
}
AvailabilityExecutor.Scan scan = executor.getMostRecentScanHistory();
@@ -297,7 +297,7 @@ public class AvailTest extends Arquillian {
List<Datum> availData = report.getResourceAvailability();
int numUp = 0;
for (Datum datum : availData) {
- assert datum.getResourceId() > 0 : "resource IDs should be > zero since it should be committed";
+ assert datum.getResourceId() != 0 : "resource IDs should be != zero since it should be committed";
if (datum.getAvailabilityType() == AvailabilityType.UP) {
++numUp;
}
@@ -342,7 +342,7 @@ public class AvailTest extends Arquillian {
Assert.assertEquals(report.getResourceAvailability().size(), 14, "should report half the resources");
availData = report.getResourceAvailability();
for (Datum datum : availData) {
- assert datum.getResourceId() > 0 : "resource IDs should be > zero since it should be committed";
+ assert datum.getResourceId() != 0 : "resource IDs should be != zero since it should be committed";
Assert.assertEquals(datum.getAvailabilityType(), AvailabilityType.UP, "should be UP at the start");
}
scan = executor.getMostRecentScanHistory();
@@ -362,7 +362,7 @@ public class AvailTest extends Arquillian {
List<Datum> availData = report.getResourceAvailability();
int numUp = 0;
for (Datum datum : availData) {
- assert datum.getResourceId() > 0 : "resource IDs should be > zero since it should be committed";
+ assert datum.getResourceId() != 0 : "resource IDs should be > zero since it should be committed";
if (datum.getAvailabilityType() == AvailabilityType.UP) {
++numUp;
}
@@ -414,7 +414,7 @@ public class AvailTest extends Arquillian {
Assert.assertEquals(report.getResourceAvailability().size(), 14, "should report half the resources");
availData = report.getResourceAvailability();
for (Datum datum : availData) {
- assert datum.getResourceId() > 0 : "resource IDs should be > zero since it should be committed";
+ assert datum.getResourceId() != 0 : "resource IDs should be != zero since it should be committed";
Assert.assertEquals(datum.getAvailabilityType(), AvailabilityType.DOWN, "should be DOWN");
}
scan = executor.getMostRecentScanHistory();
@@ -433,7 +433,7 @@ public class AvailTest extends Arquillian {
Assert.assertEquals(report.isChangesOnlyReport(), false, "First report should have been a full report");
List<Datum> availData = report.getResourceAvailability();
for (Datum datum : availData) {
- assert datum.getResourceId() > 0 : "resource IDs should be > zero since it should be committed";
+ assert datum.getResourceId() != 0 : "resource IDs should be != zero since it should be committed";
Assert.assertEquals(datum.getAvailabilityType(), AvailabilityType.UP, "should be UP at the start");
}
AvailabilityExecutor.Scan scan = executor.getMostRecentScanHistory();
@@ -474,7 +474,7 @@ public class AvailTest extends Arquillian {
Assert.assertEquals(report.getResourceAvailability().size(), 0, "no changes, everything was already up");
availData = report.getResourceAvailability();
for (Datum datum : availData) {
- assert datum.getResourceId() > 0 : "resource IDs should be > zero since it should be committed";
+ assert datum.getResourceId() != 0 : "resource IDs should be != zero since it should be committed";
Assert.assertEquals(datum.getAvailabilityType(), AvailabilityType.UP, "should be UP at the start");
}
scan = executor.getMostRecentScanHistory();
@@ -499,7 +499,7 @@ public class AvailTest extends Arquillian {
Assert.assertEquals(report.isChangesOnlyReport(), false, "First report should have been a full report");
List<Datum> availData = report.getResourceAvailability();
for (Datum datum : availData) {
- assert datum.getResourceId() > 0 : "resource IDs should be > zero since it should be committed";
+ assert datum.getResourceId() != 0 : "resource IDs should be != zero since it should be committed";
Assert.assertEquals(datum.getAvailabilityType(), AvailabilityType.UP, "should be UP at the start");
}
AvailabilityExecutor.Scan scan = executor.getMostRecentScanHistory();
@@ -525,7 +525,7 @@ public class AvailTest extends Arquillian {
Assert.assertEquals(report.getResourceAvailability().size(), 0, "no changes, everything was already up");
availData = report.getResourceAvailability();
for (Datum datum : availData) {
- assert datum.getResourceId() > 0 : "resource IDs should be > zero since it should be committed";
+ assert datum.getResourceId() != 0 : "resource IDs should be != zero since it should be committed";
Assert.assertEquals(datum.getAvailabilityType(), AvailabilityType.UP, "should be UP at the start");
}
scan = executor.getMostRecentScanHistory();
commit 37263f7ece17f28541702666009fe057a28452c1
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu Jan 30 11:11:46 2014 -0500
BZ 1052390 - Clean up remoting wrapper to avoid race conditions if possible
Some unused or rarely constructors and methods were dropped.
The biggest change is in the client caching. The cache code is guaranteed to
call disconnect when a client is 'thrown away'. There is still a possibility
disconnect can happen in the middle of an invoke.
Original Author: Elias Ross <elias_ross(a)apple.com>
Signed-off-by: Jay Shaughnessy <jshaughn(a)redhat.com>
Applying this patch as-is, I see no issues with it and it cleans some
things up. Relevant tests are passing.
diff --git a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/CmdlineClient.java b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/CmdlineClient.java
index 5e42cc2..a2186d0 100644
--- a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/CmdlineClient.java
+++ b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/CmdlineClient.java
@@ -20,6 +20,7 @@ package org.rhq.enterprise.communications.command.client;
import gnu.getopt.Getopt;
import gnu.getopt.LongOpt;
+
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -27,7 +28,10 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
+
import mazz.i18n.Logger;
+
+import org.jboss.remoting.InvokerLocator;
import org.rhq.enterprise.communications.command.Command;
import org.rhq.enterprise.communications.command.CommandResponse;
import org.rhq.enterprise.communications.command.CommandType;
@@ -212,7 +216,8 @@ public class CmdlineClient {
throw new MalformedURLException(LOG.getMsgString(CommI18NResourceKeys.CMDLINE_CLIENT_NULL_URI));
}
- JBossRemotingRemoteCommunicator communicator = new JBossRemotingRemoteCommunicator(m_locatorUri, m_subsystem);
+ InvokerLocator invokerLocator = new InvokerLocator(m_locatorUri);
+ JBossRemotingRemoteCommunicator communicator = new JBossRemotingRemoteCommunicator(invokerLocator, m_subsystem, null);
commandClient.setRemoteCommunicator(communicator);
// tell the concrete command client instance to invoke the command on the remote server
diff --git a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
index 0acc1c7..9bcf181 100644
--- a/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
+++ b/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java
@@ -22,6 +22,7 @@ import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
@@ -30,7 +31,6 @@ import mazz.i18n.Logger;
import org.jboss.remoting.Client;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.ServerInvoker;
-
import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.enterprise.communications.command.Command;
import org.rhq.enterprise.communications.command.CommandResponse;
@@ -47,12 +47,11 @@ import org.rhq.enterprise.communications.util.NotPermittedException;
* where the command is to be invoked.</p>
*
* <p>Under the covers, a {@link org.jboss.remoting.Client remoting client} is created and maintained by this object.
- * The users of this object may manually {@link #connect() connect} and {@link #disconnect() disconnect} that remoting
- * client. Typically, there will not be a need to connect since it will be done automatically when appropriate; however,
- * it is good practice to tell this object to disconnect its remoting client when this object is no longer needed to
+ * There is no need to call {@link #connect()} since it will be done automatically when appropriate; however,
+ * it is good practice to tell this object to {@link #disconnect()} its client when no longer necessary to
* issue commands to the remote server.</p>
*
- * <p>All subclasses should include a no-arg constructor so they can be built dynamically by the cmdline client.</p>
+ * <p>All subclasses should include a no-arg constructor so they can be built dynamically by the command line client.</p>
*
* @author John Mazzitelli
*/
@@ -67,41 +66,40 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
/**
* the JBoss/Remoting locator that this client will use to remotely connect to the command server
*/
- private InvokerLocator m_invokerLocator;
+ private volatile InvokerLocator m_invokerLocator;
/**
* The subsystem to target when invoking commands. The subsystem is defined by the JBoss/Remoting API - it specifies
* the actual invoker handler to target. The Command framework uses the subsystem to organize command processors
* into different domains.
*/
- private String m_subsystem;
+ private final String m_subsystem;
/**
* The configuration to send to the client - used to configure things like the SSL setup.
*/
- private Map<String, String> m_clientConfiguration;
+ private final Map<String, String> m_clientConfiguration;
/**
* the actual JBoss/Remoting client object that will be used to transport the commands to the server
*/
- private Client m_remotingClient;
+ private volatile AtomicReference<Client> m_client = new AtomicReference<Client>();
/**
- * Optionally-defined callback that will be called when a failure is detected when sending a message.
+ * Optionally-defined callback that will be called when a failure is detected when sending a message.
*/
- private FailureCallback m_failureCallback;
+ private volatile FailureCallback m_failureCallback;
/**
- * Optionally-defined callback that will be called when this communicator sends its first command
- * after it has been {@link #connect() connected}.
+ * Optionally-defined callback that will be called when this communicator sends its first command.
*/
- private InitializeCallback m_initializeCallback;
+ private volatile InitializeCallback m_initializeCallback;
/**
* When <code>true</code>, the initialize callback will need to be called prior
* to sending any commands. Used in conjunection with its associated RW lock.
*/
- private boolean m_needToCallInitializeCallback;
+ private volatile boolean m_needToCallInitializeCallback;
/**
* RW lock when needing to access its associated atomic boolean flag.
@@ -109,25 +107,13 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
private final ReentrantReadWriteLock m_needToCallInitializeCallbackLock;
/**
- * Number of minutes to wait while attempting to aquire a lock before attempting
+ * Number of minutes to wait while attempting to acquire a lock before attempting
* to invoke the initialize callback. If this amount of minutes expires before the lock
* is acquired, an error will occur and the initialize callback will have to be attempted later.
*/
private final long m_initializeCallbackLockAcquisitionTimeoutMins;
/**
- * Constructor for {@link JBossRemotingRemoteCommunicator} that initializes the client with no invoker locator
- * defined. It must later be specified through {@link #setInvokerLocator(InvokerLocator)} before any client commands
- * can be issued. In addition, the {@link #getSubsystem()} will be set to the {@link #DEFAULT_SUBSYSTEM}.
- *
- * <p>Note that all subclasses are strongly urged to include this no-arg constructor so it can plug into the cmdline
- * client seamlessly.</p>
- */
- public JBossRemotingRemoteCommunicator() {
- this((InvokerLocator) null, DEFAULT_SUBSYSTEM);
- }
-
- /**
* Constructor for {@link JBossRemotingRemoteCommunicator} that allows you to indicate the
* {@link InvokerLocator invoker locator} to use by specifying the locator's URI. The subsystem will be set to the
* {@link #DEFAULT_SUBSYSTEM}.
@@ -137,7 +123,7 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
* @throws MalformedURLException if failed to create the locator (see {@link InvokerLocator#InvokerLocator(String)})
*/
public JBossRemotingRemoteCommunicator(String locatorUri) throws MalformedURLException {
- this(new InvokerLocator(locatorUri), DEFAULT_SUBSYSTEM);
+ this(new InvokerLocator(locatorUri), DEFAULT_SUBSYSTEM, null);
}
/**
@@ -160,45 +146,6 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
* Constructor for {@link JBossRemotingRemoteCommunicator} that allows you to specify the
* {@link InvokerLocator invoker locator} to use. <code>locator</code> may be <code>null</code>, in which case, it
* must later be specified through {@link #setInvokerLocator(InvokerLocator)} before any client commands can be
- * issued. The subsystem will be set to the {@link #DEFAULT_SUBSYSTEM}.
- *
- * @param locator the locator to use (may be <code>null</code>)
- */
- public JBossRemotingRemoteCommunicator(InvokerLocator locator) {
- this(locator, DEFAULT_SUBSYSTEM);
- }
-
- /**
- * Constructor for {@link JBossRemotingRemoteCommunicator} that allows you to specify the
- * {@link InvokerLocator invoker locator} to use. <code>locator</code> may be <code>null</code>, in which case, it
- * must later be specified through {@link #setInvokerLocator(InvokerLocator)} before any client commands can be
- * issued.The subsystem will be set to the {@link #DEFAULT_SUBSYSTEM}. The given <code>Map</code> should contain
- * <code>Client</code> configuration attributes.
- *
- * @param locator the locator to use (may be <code>null</code>)
- * @param client_config the client configuration (may be <code>null</code> or empty)
- */
- public JBossRemotingRemoteCommunicator(InvokerLocator locator, Map<String, String> client_config) {
- this(locator, DEFAULT_SUBSYSTEM, client_config);
- }
-
- /**
- * Constructor for {@link JBossRemotingRemoteCommunicator} that allows you to specify the
- * {@link InvokerLocator invoker locator} to use. <code>locator</code> may be <code>null</code>, in which case, it
- * must later be specified through {@link #setInvokerLocator(InvokerLocator)} before any client commands can be
- * issued.
- *
- * @param locator the locator to use (may be <code>null</code>)
- * @param subsystem the subsystem (or command domain) in which commands will be invoked (may be <code>null</code>)
- */
- public JBossRemotingRemoteCommunicator(InvokerLocator locator, String subsystem) {
- this(locator, subsystem, null);
- }
-
- /**
- * Constructor for {@link JBossRemotingRemoteCommunicator} that allows you to specify the
- * {@link InvokerLocator invoker locator} to use. <code>locator</code> may be <code>null</code>, in which case, it
- * must later be specified through {@link #setInvokerLocator(InvokerLocator)} before any client commands can be
* issued.
*
* @param locator the locator to use (may be <code>null</code>)
@@ -222,7 +169,7 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
try {
String minsStr = System.getProperty("rhq.communications.initial-callback-lock-wait-mins", "60");
mins = Long.parseLong(minsStr);
- } catch (Throwable t) {
+ } catch (Exception e) {
mins = 60L;
}
m_initializeCallbackLockAcquisitionTimeoutMins = mins;
@@ -231,36 +178,6 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
}
/**
- * Constructor for {@link JBossRemotingRemoteCommunicator} that allows you to indicate the
- * {@link InvokerLocator invoker locator} to use by specifying the locator's URI.
- *
- * @param locatorUri the locator's URI (must not be <code>null</code>)
- * @param subsystem the subsystem (or command domain) in which commands will be invoked (may be <code>null</code>)
- *
- * @throws MalformedURLException if failed to create the locator (see {@link InvokerLocator#InvokerLocator(String)})
- */
- public JBossRemotingRemoteCommunicator(String locatorUri, String subsystem) throws MalformedURLException {
- this(new InvokerLocator(locatorUri), subsystem);
- }
-
- /**
- * Constructor for {@link JBossRemotingRemoteCommunicator} that allows you to indicate the
- * {@link InvokerLocator invoker locator} to use by specifying the locator's URI. The given <code>Map</code> should
- * contain <code>Client</code> configuration attributes.
- *
- * @param locatorUri the locator's URI (must not be <code>null</code>)
- * @param subsystem the subsystem (or command domain) in which commands will be invoked (may be <code>
- * null</code>)
- * @param client_config the client configuration (may be <code>null</code> or empty)
- *
- * @throws MalformedURLException if failed to create the locator (see {@link InvokerLocator#InvokerLocator(String)})
- */
- public JBossRemotingRemoteCommunicator(String locatorUri, String subsystem, Map<String, String> client_config)
- throws MalformedURLException {
- this(new InvokerLocator(locatorUri), subsystem, client_config);
- }
-
- /**
* Returns the invoker locator that is to be used to find the remote JBoss/Remoting server. If <code>null</code> is
* returned, this communicator will not be able to issue commands.
*
@@ -281,81 +198,14 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
* null</code>)
*
* @throws MalformedURLException if failed to create the locator (see {@link InvokerLocator#InvokerLocator(String)})
- *
- * @see #setInvokerLocator(InvokerLocator)
- */
- public void setInvokerLocator(String locatorUri) throws MalformedURLException {
- setInvokerLocator(new InvokerLocator(locatorUri));
- }
-
- /**
- * Sets the invoker locator URI and creates a new locator that is to be used to find the remote JBoss/Remoting
- * server for its subsequent command client invocations. Any existing remoting client is automatically disconnected.
- * New remoting clients will also be configured with the new set of configuration properties - thus allowing you to
- * configure the client to be able to handle the new locator.
- *
- * @param locatorUri the new invoker locator's URI to use for future command client invocations (must not be
- * <code>null</code>)
- * @param client_config the client configuration for any new remoting clients that are created (may be <code>
- * null</code> or empty)
- *
- * @throws MalformedURLException if failed to create the locator (see {@link InvokerLocator#InvokerLocator(String)})
- *
- * @see #setInvokerLocator(InvokerLocator)
- */
- public void setInvokerLocator(String locatorUri, Map<String, String> client_config) throws MalformedURLException {
- setInvokerLocator(new InvokerLocator(locatorUri), client_config);
- }
-
- /**
- * Sets the invoker locator that this communicator should use for its subsequent command client invocations. Any
- * existing remoting client is automatically disconnected.The client configuration properties will, however, remain
- * the same as before - so the new clients that are created will have the same configuration attributes. See
- * {@link #setInvokerLocator(InvokerLocator, Map)} if you want to reconfigure the client with different properties
- * that are more appropriate for the new locator.
- *
- * @param locator the new invoker locator to use for future command client invocations (must not be <code>
- * null</code>)
- *
- * @throws IllegalArgumentException if locator is <code>null</code>
- */
- public void setInvokerLocator(InvokerLocator locator) {
- setInvokerLocator(locator, null);
- }
-
- /**
- * Sets the invoker locator that this communicator should use for its subsequent command client invocations. Any
- * existing remoting client is automatically disconnected. New remoting clients will also be configured with the new
- * set of configuration properties - thus allowing you to configure the client to be able to handle the new locator.
- *
- * @param locator the new invoker locator to use for future command client invocations (must not be <code>
- * null</code>)
- * @param client_config the client configuration for any new remoting clients that are created (may be <code>
- * null</code> or empty)
- *
- * @throws IllegalArgumentException if locator is <code>null</code>
*/
- public void setInvokerLocator(InvokerLocator locator, Map<String, String> client_config) {
- if (locator == null) {
- throw new IllegalArgumentException("locator=null");
- }
-
- // since a new invoker locator is being specified, disconnect any old client that already exists
- if (m_remotingClient != null) {
- m_remotingClient.disconnect();
- m_remotingClient = null;
- m_needToCallInitializeCallback = (getInitializeCallback() != null); // specifically do not synchrononize by using lock, just set it
- }
-
+ public void setRemoteEndpoint(String endpoint) throws Exception {
+ InvokerLocator locator = new InvokerLocator(endpoint);
LOG.info(CommI18NResourceKeys.COMMUNICATOR_CHANGING_ENDPOINT, m_invokerLocator, locator);
m_invokerLocator = locator;
- if (client_config != null) {
- m_clientConfiguration.clear();
- m_clientConfiguration.putAll(client_config);
- }
-
- return;
+ // since a new invoker locator is being specified, disconnect any old client that already exists
+ disconnect();
}
/**
@@ -369,25 +219,6 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
return m_subsystem;
}
- /**
- * Sets the value of the subsystem that will be used to target command invocations. The subsystem is defined by the
- * JBoss/Remoting API and can be used by the Command Framework to organize command processors into different
- * domains.
- *
- * <p>If a remoting client already exists, its subsystem will be changed to the given subsystem.</p>
- *
- * @param subsystem the new value of subsystem (may be <code>null</code>)
- */
- public void setSubsystem(String subsystem) {
- m_subsystem = subsystem;
-
- if (m_remotingClient != null) {
- m_remotingClient.setSubsystem(subsystem);
- }
-
- return;
- }
-
public FailureCallback getFailureCallback() {
return m_failureCallback;
}
@@ -402,17 +233,13 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
public void setInitializeCallback(InitializeCallback callback) {
m_initializeCallback = callback;
- m_needToCallInitializeCallback = (callback != null); // specifically do not synchrononize by using lock, just set it
+ m_needToCallInitializeCallback = (callback != null); // specifically do not synchronize by using lock, just set it
}
public String getRemoteEndpoint() {
return (m_invokerLocator != null) ? m_invokerLocator.getLocatorURI() : "<null>";
}
- public void setRemoteEndpoint(String endpoint) throws Exception {
- setInvokerLocator(endpoint);
- }
-
/**
* Returns the map of name/value pairs of client configuration settings used when creating the client. The returned
* map is a copy - changing its contents has no effect on the clients that already have been or will be created by
@@ -425,26 +252,31 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
return new HashMap<String, String>(m_clientConfiguration);
}
+ /**
+ * Does nothing; send a request to connect.
+ */
public void connect() throws Exception {
- if ((m_remotingClient != null) && !m_remotingClient.isConnected()) {
- m_remotingClient.connect();
- m_needToCallInitializeCallback = (getInitializeCallback() != null); // specifically do not synchrononize by using lock, just set it
+ /*
+ * For the HTTP invoker, simply calling connect() doesn't do anything. It makes
+ * sense to at least send something to test connectivity. However, the code doesn't
+ * make use of this method.
+ try {
+ send(new EchoCommand());
+ } catch (Exception e) {
+ throw e;
+ } catch (Throwable t) {
+ throw new Error(t);
}
-
- return;
+ */
}
public void disconnect() {
- if (m_remotingClient != null) {
- m_remotingClient.disconnect();
- m_needToCallInitializeCallback = (getInitializeCallback() != null); // specifically do not synchrononize by using lock, just set it
- }
-
- return;
+ cacheClient(null);
}
public boolean isConnected() {
- return (m_remotingClient != null) && m_remotingClient.isConnected();
+ Client client = m_client.get();
+ return (client != null) && client.isConnected();
}
public CommandResponse sendWithoutCallbacks(Command command) throws Throwable {
@@ -455,7 +287,7 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
retry = false;
ret_response = rawSend(command);
Throwable exception = ret_response.getException();
- if ((exception != null) && (exception instanceof NotPermittedException)) {
+ if (exception instanceof NotPermittedException) {
long pause = ((NotPermittedException) exception).getSleepBeforeRetry();
LOG.debug(CommI18NResourceKeys.COMMAND_NOT_PERMITTED, command, pause);
retry = true;
@@ -498,11 +330,11 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
/**
* The code that sends the command via the remote client.
- *
+ *
* @param command the command to send
- *
+ *
* @return the command response
- *
+ *
* @throws Throwable if a low-level, unhandled exception occurred
*/
private CommandResponse rawSend(Command command) throws Throwable {
@@ -511,13 +343,13 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
try {
try {
OutgoingCommandTrace.start(command);
- ret_response = getRemotingClient().invoke(command, null);
+ ret_response = invoke(command);
OutgoingCommandTrace.finish(command, ret_response);
} catch (ServerInvoker.InvalidStateException serverDown) {
// under rare condition, a bug in remoting 2.2 causes this when the server restarted
// try it one more time, this will get a new server thread on the server side (JBREM-745)
// once JBREM-745 is fixed, we can probably get rid of this catch block
- ret_response = getRemotingClient().invoke(command, null);
+ ret_response = invoke(command);
OutgoingCommandTrace.finish(command, ret_response);
}
} catch (Throwable t) {
@@ -548,12 +380,12 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
* call it. The initialize callback has the responsibility to handle calling
* {@link #sendWithoutInitializeCallback(Command)} if it wants to send its own commands to the server
* but wants failover to happen when appropriate for those commands.
- *
+ *
* If there is an initialize callback set, this method will block all callers until
* the callback has been invoked.
*
* @param command the command that it going to be sent after the callback is invoked
- *
+ *
* @return if the initialize callback had an error, this response will be non-<code>null</code> and
* will indicate that the sending of <code>command</code> should be aborted.
*/
@@ -600,14 +432,14 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
/**
* This will invoke the failure callback when necessary. It is necessary to call the callback
* when the throwable is not <code>null</code> or the command response has a non-<code>null</code> exception.
- *
+ *
* This method will force a retry by returning <code>true</code>. If <code>false</code> is returned,
* the request need not be retried.
- *
+ *
* @param command the command that was sent (or attempted to be sent)
* @param response the response of the command (may be <code>null</code>)
* @param throwable the exception that was thrown when the command was sent (may be <code>null</code>)
- *
+ *
* @return <code>true</code> if the command should be retried, <code>false</code> otherwise
*/
private boolean invokeFailureCallbackIfNeeded(Command command, CommandResponse response, Throwable throwable) {
@@ -615,7 +447,7 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
FailureCallback callback = getFailureCallback(); // get a local reference to avoid this being changed underneath us
boolean retry = false;
- // only do something if there is a callback defined
+ // only do something if there is a callback defined
if (callback != null) {
// only do something if the command resulted in an exception
if (throwable != null || ((response != null) && (response.getException() != null))) {
@@ -638,28 +470,48 @@ public class JBossRemotingRemoteCommunicator implements RemoteCommunicator {
}
/**
- * Returns the remoting client that is to be used to transport the command request to the server. If for any reason
- * the client cannot be created, an exception is thrown. This will happen if the invoker locator has not been
- * specified (see {@link #setInvokerLocator(InvokerLocator)}).
- *
- * <p>This method will cache the client and connect to the server automatically. Note that the client will be
- * disconnected whenever the invoker is reset via {@link #setInvokerLocator(InvokerLocator)}. Therefore, callers
- * should never cache the returned object themselves - always call this method to obtain a reference to the
- * client.</p>
- *
- * @return the client to be used to transport the command request to the server
+ * Invokes JBoss Remoting using the given command.
+ * Attempts to cache the client if sending the message was successful.
*
- * @throws Exception if failed to create the client for whatever reason
+ * @return object as a result of this call
*/
- protected Client getRemotingClient() throws Exception {
- if (m_remotingClient == null) {
- m_remotingClient = new Client(getInvokerLocator(), getSubsystem(), m_clientConfiguration);
+ private Object invoke(Command command) throws Throwable {
+ InvokerLocator locator = m_invokerLocator;
+ if (locator == null) {
+ throw new IllegalStateException("m_invokerLocator is null");
}
- if (!m_remotingClient.isConnected()) {
- m_remotingClient.connect();
+ Client client = m_client.get();
+ if (client != null && client.getInvoker() == null) {
+ client.disconnect();
+ }
+ if (client == null || !client.isConnected()) {
+ client = new Client(locator, getSubsystem(), m_clientConfiguration);
+ client.connect();
+ try {
+ return client.invoke(command);
+ } finally {
+ cacheClient(client);
+ }
}
- return m_remotingClient;
+ // Note: Despite all the checks above, the client might have been
+ // disconnected before invoke is reached. Let's hope that doesn't happen.
+
+ return client.invoke(command);
+ }
+
+ /**
+ * Cache the client, disconnecting the old client.
+ *
+ * @param client optionally null; new client to cache
+ */
+ private void cacheClient(Client client) {
+ Client old = m_client.getAndSet(client);
+ if (old != null) {
+ old.disconnect();
+ m_needToCallInitializeCallback = (getInitializeCallback() != null);
+ }
}
+
}
10 years, 3 months
[rhq] modules/core modules/plugins
by Thomas Segismont
modules/core/native-system/src/main/java/org/rhq/core/system/FileSystemInfo.java | 52 ++++------
modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemComponent.java | 7 -
2 files changed, 27 insertions(+), 32 deletions(-)
New commits:
commit c9ea7f80a610d0ce22376f76723f8445c6d9cfd7
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Thu Jan 30 14:37:33 2014 +0100
Bug 1026513 - File systems that are offline or not available are still being reported as UP
Return AvailabilityType.UP only if the directory name of the FileSystem is the same as the resource key.
diff --git a/modules/core/native-system/src/main/java/org/rhq/core/system/FileSystemInfo.java b/modules/core/native-system/src/main/java/org/rhq/core/system/FileSystemInfo.java
index 6d5ada6..372b434 100644
--- a/modules/core/native-system/src/main/java/org/rhq/core/system/FileSystemInfo.java
+++ b/modules/core/native-system/src/main/java/org/rhq/core/system/FileSystemInfo.java
@@ -1,25 +1,21 @@
/*
-* RHQ Management Platform
-* Copyright (C) 2005-2012 Red Hat, Inc.
-* All rights reserved.
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License, 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.
-*/
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
package org.rhq.core.system;
import org.apache.commons.logging.Log;
@@ -36,7 +32,7 @@ import org.hyperic.sigar.SigarProxy;
* @author John Mazzitelli
*/
public class FileSystemInfo {
- private final Log log = LogFactory.getLog(this.getClass());
+ private static final Log LOG = LogFactory.getLog(FileSystemInfo.class);
private final String mountPoint;
private FileSystem fs;
@@ -66,14 +62,14 @@ public class FileSystemInfo {
// this happens when the file system is not available (e.g. if it's a CD-ROM without a CD loaded in it) or
// if we don't have permission to access the filesystem. we can ignore it and set the usage data to null.
this.fsUsage = null;
- if (log.isTraceEnabled()) {
- log.trace("Cannot refresh the usage data for file system mounted at [" + this.mountPoint + "].", e);
- } else {
- log.debug("Cannot refresh the usage data for file system mounted at [" + this.mountPoint + "]: " + e);
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Cannot refresh the usage data for file system mounted at [" + this.mountPoint + "].", e);
+ } else if (LOG.isDebugEnabled()) {
+ LOG.debug("Cannot refresh the usage data for file system mounted at [" + this.mountPoint + "]: " + e);
}
} catch (RuntimeException e) {
this.fsUsage = null;
- log.error("An error occurred while refreshing the usage data for file system mounted at [" + this.mountPoint
+ LOG.error("An error occurred while refreshing the usage data for file system mounted at [" + this.mountPoint
+ "].", e);
}
}
@@ -110,4 +106,4 @@ public class FileSystemInfo {
", fsUsage=" + fsUsage +
']';
}
-}
\ No newline at end of file
+}
diff --git a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemComponent.java b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemComponent.java
index 5eae991..02d0b68 100644
--- a/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemComponent.java
+++ b/modules/plugins/platform/src/main/java/org/rhq/plugins/platform/FileSystemComponent.java
@@ -59,8 +59,8 @@ public class FileSystemComponent implements ResourceComponent<PlatformComponent>
public AvailabilityType getAvailability() {
FileSystemInfo fileSystemInfo = getFileSystemInfo();
- // fileSystemInfo can be != null even if the fs is unmounted.
- if (fileSystemInfo != null && fileSystemInfo.getFileSystem() != null) {
+ if (fileSystemInfo != null && fileSystemInfo.getFileSystem() != null
+ && this.resourceContext.getResourceKey().equals(fileSystemInfo.getFileSystem().getDirName())) {
return AvailabilityType.UP;
} else {
return AvailabilityType.DOWN;
@@ -94,5 +94,4 @@ public class FileSystemComponent implements ResourceComponent<PlatformComponent>
SystemInfo systemInfo = resourceContext.getSystemInformation();
return systemInfo.getFileSystem(resourceContext.getResourceKey());
}
-
-}
\ No newline at end of file
+}
10 years, 3 months
[rhq] Branch 'release/jon3.2.x' - modules/enterprise
by Jiri Kremser
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/common/graph/ButtonBarDateTimeRangeEditor.java | 60 +++++++---
1 file changed, 43 insertions(+), 17 deletions(-)
New commits:
commit 8c9d2ac39707da9023eb378ea6a8b31d7b3b64d2
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Wed Jan 29 15:14:46 2014 -0800
[BZ 909155] Error message when setting start date = 00:00 and end date = 24:00.
Changed to individual spinnerItem controls that limit the hours to 23 so valid dates are enforced by the choice up front.
(cherry picked from commit 6a73a05d0513170a7bf8d1bc80110694b9f942e8)
Signed-off-by: Jirka Kremser <jkremser(a)redhat.com>
Conflicts:
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/common/graph/ButtonBarDateTimeRangeEditor.java
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/common/graph/ButtonBarDateTimeRangeEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/common/graph/ButtonBarDateTimeRangeEditor.java
index e0818c7..8ac6777 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/common/graph/ButtonBarDateTimeRangeEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/common/graph/ButtonBarDateTimeRangeEditor.java
@@ -33,7 +33,7 @@ import com.smartgwt.client.widgets.events.CloseClickHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.DateItem;
import com.smartgwt.client.widgets.form.fields.RowSpacerItem;
-import com.smartgwt.client.widgets.form.fields.TimeItem;
+import com.smartgwt.client.widgets.form.fields.SpinnerItem;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.toolbar.ToolStrip;
@@ -258,18 +258,21 @@ public class ButtonBarDateTimeRangeEditor extends EnhancedVLayout {
final ButtonBarDateTimeRangeEditor buttonBarDateTimeRangeEditor,
Date startTime, Date endTime) {
super();
- setTitle(windowTitle + ": " + title);
+ setTitle("");
setShowMinimizeButton(false);
setShowMaximizeButton(false);
setShowCloseButton(true);
setIsModal(true);
setShowModalMask(true);
- setWidth(450);
- setHeight(340);
+ setWidth(420);
+ setHeight(450);
setShowResizer(true);
setCanDragResize(true);
centerInPage();
+
DynamicForm form = new DynamicForm();
+ form.setGroupTitle(windowTitle + " "+title);
+ form.setIsGroup(true);
form.setMargin(25);
form.setAutoFocus(true);
form.setShowErrorText(true);
@@ -278,16 +281,41 @@ public class ButtonBarDateTimeRangeEditor extends EnhancedVLayout {
form.setWidth100();
form.setPadding(5);
form.setLayoutAlign(VerticalAlignment.BOTTOM);
+
final DateItem startDateItem = new DateItem("startDate", MSG.common_buttonbar_start_date());
startDateItem.setValue(startTime);
- final TimeItem startTimeItem = new TimeItem("startTime", MSG.common_buttonbar_start_time());
- startTimeItem.setValue(startTime);
+
+ final SpinnerItem startTimeHours = new SpinnerItem("startTimeHours",MSG.chart_slider_button_bar_hour());
+ startTimeHours.setMax(23);
+ startTimeHours.setMin(0);
+ startTimeHours.setWidth(60);
+ startTimeHours.setValue(startDateItem.getValueAsDate().getHours());
+
+ final SpinnerItem startTimeMinutes = new SpinnerItem("startTimeMinutes",MSG.chart_slider_button_bar_minute());
+ startTimeMinutes.setMax(59);
+ startTimeMinutes.setStep(5);
+ startTimeMinutes.setMin(0);
+ startTimeMinutes.setWidth(60);
+ startTimeMinutes.setEndRow(true);
+ startTimeMinutes.setValue(startDateItem.getValueAsDate().getMinutes());
+
final DateItem endDateItem = new DateItem("endDate", MSG.common_buttonbar_end_date());
endDateItem.setValue(endTime);
- final TimeItem endTimeItem = new TimeItem("endTime", MSG.common_buttonbar_end_time());
- endTimeItem.setValue(endTime);
- form.setFields(startDateItem, startTimeItem, new RowSpacerItem(), endDateItem, endTimeItem,
- new RowSpacerItem());
+ final SpinnerItem endTimeHours = new SpinnerItem("endTimeHours", MSG.chart_slider_button_bar_hour());
+ endTimeHours.setMax(23);
+ endTimeHours.setMin(0);
+ endTimeHours.setWidth(60);
+ endTimeHours.setValue(endDateItem.getValueAsDate().getHours());
+
+ final SpinnerItem endTimeMinutes = new SpinnerItem("endTimeMinutes", MSG.chart_slider_button_bar_minute());
+ endTimeMinutes.setMax(59);
+ endTimeMinutes.setMin(0);
+ endTimeMinutes.setStep(5);
+ endTimeMinutes.setWidth(60);
+ endTimeMinutes.setValue(endDateItem.getValueAsDate().getMinutes());
+
+ form.setFields(startDateItem, startTimeHours, startTimeMinutes, new RowSpacerItem(), new RowSpacerItem(),
+ endDateItem, endTimeHours, endTimeMinutes, new RowSpacerItem());
this.addItem(form);
HLayout buttonHLayout = new HLayout();
@@ -306,15 +334,13 @@ public class ButtonBarDateTimeRangeEditor extends EnhancedVLayout {
saveButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
- Date startTimeDate = (Date) startTimeItem.getValue();
- Date endTimeDate = (Date) endTimeItem.getValue();
-
+ //@todo: eventually get rid of deprecated calls but not in 3.2.1 minor release
Date newStartDate = new Date(startDateItem.getValueAsDate().getYear(), startDateItem
- .getValueAsDate().getMonth(), startDateItem.getValueAsDate().getDate(), startTimeDate
- .getHours(), startTimeDate.getMinutes());
+ .getValueAsDate().getMonth(), startDateItem.getValueAsDate().getDate(),
+ (Integer) startTimeHours.getValue(), (Integer) startTimeMinutes.getValue());
Date newEndDate = new Date(endDateItem.getValueAsDate().getYear(), endDateItem.getValueAsDate()
- .getMonth(), endDateItem.getValueAsDate().getDate(), endTimeDate.getHours(), endTimeDate
- .getMinutes());
+ .getMonth(), endDateItem.getValueAsDate().getDate(), (Integer) endTimeHours.getValue(),
+ (Integer) endTimeMinutes.getValue());
buttonBarDateTimeRangeEditor.saveDateRange(newStartDate.getTime(), newEndDate.getTime());
redrawGraphs();
showUserFriendlyTimeRange(newStartDate.getTime(), newEndDate.getTime());
10 years, 3 months
[rhq] 2 commits - modules/core modules/plugins
by Thomas Segismont
modules/core/plugin-container/src/main/java/org/rhq/core/pc/content/ContentManager.java | 9 +--
modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/InventoryPrinter.java | 26 ++++------
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java | 7 +-
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java | 13 +----
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractServerComponentTest.java | 19 +++----
5 files changed, 34 insertions(+), 40 deletions(-)
New commits:
commit 6785f80b99a4def0128939113fd5af7d3b4ebee5
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Thu Jan 30 12:30:48 2014 +0100
Bug 1025050 - EAP 6 plug-in should not require start script environment variables to be set
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index 000d08c..bda2e5e 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2013 Red Hat, Inc.
+ * Copyright (C) 2005-2014 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -16,6 +16,7 @@
* 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.modules.plugins.jbossas7;
import static org.rhq.modules.plugins.jbossas7.ASConnection.verbose;
@@ -361,7 +362,9 @@ public class BaseComponent<T extends ResourceComponent<?>> implements AS7Compone
@Override
public void deleteResource() throws Exception {
- getLog().info("Removing AS7 resource [" + path + "]...");
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("Removing AS7 resource [" + path + "]...");
+ }
if (context.getResourceType().getName().equals(MANAGED_SERVER)) {
// We need to do two steps because of AS7-4032
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
index 5e2f272..bc7112a 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2013 Red Hat, Inc.
+ * Copyright (C) 2005-2014 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -121,7 +121,9 @@ public abstract class BaseServerComponent<T extends ResourceComponent<?>> extend
try {
if ((availabilityType == AvailabilityType.UP) && (previousAvailabilityType != AvailabilityType.UP)) {
validateServerAttributes();
- log.info(getResourceDescription() + " has just come UP.");
+ if (log.isDebugEnabled()) {
+ log.debug(getResourceDescription() + " has just come UP.");
+ }
}
} finally {
previousAvailabilityType = availabilityType;
@@ -423,13 +425,6 @@ public abstract class BaseServerComponent<T extends ResourceComponent<?>> extend
}
}
- Map<String, String> startScriptEnv = startScriptConfig.getStartScriptEnv();
- if (startScriptEnv.isEmpty()) {
- errors.add("No start script environment variables are set. At a minimum, PATH should be set "
- + "(on UNIX, it should contain at least /bin and /usr/bin). It is recommended that "
- + "JAVA_HOME also be set, otherwise the PATH will be used to find java.");
- }
-
return errors;
}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractServerComponentTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractServerComponentTest.java
index d0f023a..1fd155c 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractServerComponentTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/AbstractServerComponentTest.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2013 Red Hat, Inc.
+ * Copyright (C) 2005-2014 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -16,6 +16,7 @@
* 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.modules.plugins.jbossas7.itest;
import static org.testng.Assert.assertEquals;
@@ -199,17 +200,17 @@ public abstract class AbstractServerComponentTest extends AbstractJBossAS7Plugin
}
protected void validateStartScriptEnv(Map<String, String> env) {
- Assert.assertTrue(env.size() <= 4, env.toString());
-
String javaHome = env.get("JAVA_HOME");
- Assert.assertNotNull(javaHome);
- Assert.assertTrue(new File(javaHome).isDirectory());
+ if (javaHome != null) {
+ Assert.assertTrue(new File(javaHome).isDirectory());
+ }
String path = env.get("PATH");
- Assert.assertNotNull(path);
- String[] pathElements = path.split(File.pathSeparator);
- Assert.assertTrue(pathElements.length >= 1);
- Assert.assertTrue(new File(pathElements[0]).isDirectory());
+ if (path != null) {
+ String[] pathElements = path.split(File.pathSeparator);
+ Assert.assertTrue(pathElements.length >= 1);
+ Assert.assertTrue(new File(pathElements[0]).isDirectory());
+ }
}
protected abstract String getBindAddressSystemPropertyName();
commit 5df3797396c237111cfcbd14dbf8c27e078384b1
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Thu Jan 30 11:41:44 2014 +0100
Fix UnsupportedOperationException @ ContentManager.handleDiscoveredContent
This was due to org.rhq.core.pc.inventory.ResourceContainer#getInstalledPackages, which used to create a new empty set, and now returns Collections#emptySet, which is immutable.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/content/ContentManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/content/ContentManager.java
index 853d3b1..464978d 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/content/ContentManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/content/ContentManager.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2013 Red Hat, Inc.
+ * Copyright (C) 2005-2014 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -16,6 +16,7 @@
* 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.pc.content;
import static org.rhq.core.domain.resource.InventoryStatus.COMMITTED;
@@ -588,10 +589,8 @@ public class ContentManager extends AgentService implements ContainerService, Co
ResourceContainer container = inventoryManager.getResourceContainer(resourceId);
Set<ResourcePackageDetails> updatedPackageSet = new HashSet<ResourcePackageDetails>(details);
- Set<ResourcePackageDetails> existingInstalledPackagesSet = container.getInstalledPackages();
- if (existingInstalledPackagesSet == null) {
- existingInstalledPackagesSet = new HashSet<ResourcePackageDetails>();
- }
+ Set<ResourcePackageDetails> existingInstalledPackagesSet = new HashSet<ResourcePackageDetails>(
+ container.getInstalledPackages());
// Strip out content that have been removed (i.e. not returned on the latest discovery)
int originalPackageCount = existingInstalledPackagesSet.size();
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/InventoryPrinter.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/InventoryPrinter.java
index bcaa45d..9f667a4 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/InventoryPrinter.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/InventoryPrinter.java
@@ -1,25 +1,22 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2012 Red Hat, Inc.
+ * 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, 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.
+ * 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 and the GNU Lesser General Public License
- * for more details.
+ * GNU 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.
+ * 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.pc.util;
import java.io.PrintWriter;
@@ -32,6 +29,7 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
+import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
import org.rhq.core.domain.drift.DriftDefinition;
import org.rhq.core.domain.measurement.Availability;
import org.rhq.core.domain.measurement.AvailabilityType;
@@ -223,10 +221,8 @@ public class InventoryPrinter {
}
String availString = (availType == null) ? "UNKNOWN" : availType.toString();
- int installedPackageCount = 0;
- if (resourceContainer.getInstalledPackages() != null) {
- installedPackageCount = resourceContainer.getInstalledPackages().size();
- }
+ Set<ResourcePackageDetails> installedPackages = resourceContainer.getInstalledPackages();
+ int installedPackageCount = installedPackages == null ? 0 : installedPackages.size();
if (dumpXml) {
exportWriter.printf("%s<resource>\n", indent);
@@ -434,4 +430,4 @@ public class InventoryPrinter {
return serviceCount;
}
}
-}
\ No newline at end of file
+}
10 years, 3 months
[rhq] modules/enterprise
by mike thompson
modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/common/graph/ButtonBarDateTimeRangeEditor.java | 62 +++++++---
1 file changed, 46 insertions(+), 16 deletions(-)
New commits:
commit 6a73a05d0513170a7bf8d1bc80110694b9f942e8
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Wed Jan 29 15:14:46 2014 -0800
[BZ 909155] Error message when setting start date = 00:00 and end date = 24:00.
Changed to individual spinnerItem controls that limit the hours to 23 so valid dates are enforced by the choice up front.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/common/graph/ButtonBarDateTimeRangeEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/common/graph/ButtonBarDateTimeRangeEditor.java
index 89869eb..8281a24 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/common/graph/ButtonBarDateTimeRangeEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/coregui/client/inventory/common/graph/ButtonBarDateTimeRangeEditor.java
@@ -33,7 +33,7 @@ import com.smartgwt.client.widgets.events.CloseClickHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.DateItem;
import com.smartgwt.client.widgets.form.fields.RowSpacerItem;
-import com.smartgwt.client.widgets.form.fields.TimeItem;
+import com.smartgwt.client.widgets.form.fields.SpinnerItem;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.toolbar.ToolStrip;
@@ -257,18 +257,21 @@ public class ButtonBarDateTimeRangeEditor extends EnhancedVLayout {
public CustomDateRangeWindow(String title, String windowTitle,
final ButtonBarDateTimeRangeEditor buttonBarDateTimeRangeEditor, Date startTime, Date endTime) {
super();
- setTitle(windowTitle + ": " + title);
+ setTitle("");
setShowMinimizeButton(false);
setShowMaximizeButton(false);
setShowCloseButton(true);
setIsModal(true);
setShowModalMask(true);
- setWidth(450);
- setHeight(340);
+ setWidth(420);
+ setHeight(450);
setShowResizer(true);
setCanDragResize(true);
centerInPage();
+
DynamicForm form = new DynamicForm();
+ form.setGroupTitle(windowTitle + " "+title);
+ form.setIsGroup(true);
form.setMargin(25);
form.setAutoFocus(true);
form.setShowErrorText(true);
@@ -277,15 +280,44 @@ public class ButtonBarDateTimeRangeEditor extends EnhancedVLayout {
form.setWidth100();
form.setPadding(5);
form.setLayoutAlign(VerticalAlignment.BOTTOM);
+
final DateItem startDateItem = new DateItem("startDate", MSG.common_buttonbar_start_date());
startDateItem.setValue(startTime);
- final TimeItem startTimeItem = new TimeItem("startTime", MSG.common_buttonbar_start_time());
- startTimeItem.setValue(startTime);
+
+ final SpinnerItem startTimeHours = new SpinnerItem("startTimeHours",MSG.chart_slider_button_bar_hour());
+ startTimeHours.setMax(23);
+ startTimeHours.setMin(0);
+ startTimeHours.setWidth(60);
+ startTimeHours.setValue(startDateItem.getValueAsDate().getHours());
+
+ final SpinnerItem startTimeMinutes = new SpinnerItem("startTimeMinutes",MSG.chart_slider_button_bar_minute());
+ startTimeMinutes.setMax(59);
+ startTimeMinutes.setStep(5);
+ startTimeMinutes.setMin(0);
+ startTimeMinutes.setWidth(60);
+ startTimeMinutes.setEndRow(true);
+ startTimeMinutes.setValue(startDateItem.getValueAsDate().getMinutes());
+
final DateItem endDateItem = new DateItem("endDate", MSG.common_buttonbar_end_date());
endDateItem.setValue(endTime);
- final TimeItem endTimeItem = new TimeItem("endTime", MSG.common_buttonbar_end_time());
- endTimeItem.setValue(endTime);
- form.setFields(startDateItem, startTimeItem, new RowSpacerItem(), endDateItem, endTimeItem,
+
+ final SpinnerItem endTimeHours = new SpinnerItem("endTimeHours", MSG.chart_slider_button_bar_hour());
+ endTimeHours.setMax(23);
+ endTimeHours.setMin(0);
+ endTimeHours.setWidth(60);
+ endTimeHours.setValue(endDateItem.getValueAsDate().getHours());
+
+ final SpinnerItem endTimeMinutes = new SpinnerItem("endTimeMinutes",MSG.chart_slider_button_bar_minute());
+ endTimeMinutes.setMax(59);
+ endTimeMinutes.setMin(0);
+ endTimeMinutes.setStep(5);
+ endTimeMinutes.setWidth(60);
+ endTimeMinutes.setValue(endDateItem.getValueAsDate().getMinutes());
+
+ form.setFields(startDateItem, startTimeHours, startTimeMinutes,
+ new RowSpacerItem(), new RowSpacerItem(),
+ endDateItem,
+ endTimeHours, endTimeMinutes,
new RowSpacerItem());
this.addItem(form);
@@ -305,15 +337,13 @@ public class ButtonBarDateTimeRangeEditor extends EnhancedVLayout {
saveButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
- Date startTimeDate = (Date) startTimeItem.getValue();
- Date endTimeDate = (Date) endTimeItem.getValue();
-
+ //@todo: eventually get rid of deprecated calls but not in 3.2.1 minor release
Date newStartDate = new Date(startDateItem.getValueAsDate().getYear(), startDateItem
- .getValueAsDate().getMonth(), startDateItem.getValueAsDate().getDate(), startTimeDate
- .getHours(), startTimeDate.getMinutes());
+ .getValueAsDate().getMonth(), startDateItem.getValueAsDate().getDate(), (Integer) startTimeHours.getValue(),
+ (Integer) startTimeMinutes.getValue());
Date newEndDate = new Date(endDateItem.getValueAsDate().getYear(), endDateItem.getValueAsDate()
- .getMonth(), endDateItem.getValueAsDate().getDate(), endTimeDate.getHours(), endTimeDate
- .getMinutes());
+ .getMonth(), endDateItem.getValueAsDate().getDate(), (Integer) endTimeHours.getValue(),
+ (Integer) endTimeMinutes.getValue());
buttonBarDateTimeRangeEditor.saveDateRange(newStartDate.getTime(), newEndDate.getTime());
redrawGraphs();
showUserFriendlyTimeRange(newStartDate.getTime(), newEndDate.getTime());
10 years, 3 months
[rhq] Branch 'jsanda/throttling' - modules/enterprise
by John Sanda
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit ee84d2ac70d2cb2d70381dba7e3d07e53b09633e
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jan 29 16:56:10 2014 -0500
[BZ 1045589] make sure a non-zero default is used for the aggregation batch size
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java
index 4416ff9..890b630 100644
--- a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java
@@ -83,7 +83,7 @@ public class MetricsServer {
private ListeningExecutorService aggregationWorkers = MoreExecutors.listeningDecorator(
Executors.newFixedThreadPool(5, new StorageClientThreadFactory()));
- private int aggregationBatchSize;
+ private int aggregationBatchSize = Integer.parseInt(System.getProperty("rhq.metrics.aggregation.batch-size", "25"));
private boolean useAsyncAggregation = Boolean.valueOf(System.getProperty("rhq.metrics.aggregation.async", "true"));
10 years, 3 months
[rhq] modules/core
by Jay Shaughnessy
modules/core/plugin-container-itest/src/test/java/org/rhq/core/pc/inventory/AbstractIgnoreTypesInventoryManagerBaseTest.java | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
New commits:
commit 81c5903f3844a3bc5102ed9b21172ed153a6433e
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Jan 29 15:27:42 2014 -0500
Potential fix for intermittent server i-test failure: when waiting for
inventory depth make sure to wait on the inventory manager's view, not
the server-side/fake inv view.
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 cb799de..74a35ad 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
@@ -143,25 +143,25 @@ public abstract class AbstractIgnoreTypesInventoryManagerBaseTest extends Arquil
protected void waitForInventory(int depth) throws Exception {
long start = System.currentTimeMillis();
- int inventoryDepth = getInventoryDepth(platform);
+ int inventoryDepth = getInventoryDepth(pluginContainer.getInventoryManager().getPlatform(), "");
while (inventoryDepth < depth) {
if (System.currentTimeMillis() - start > 60000L) {
assert false : "Failed to get proper depth, depth is currently at=" + inventoryDepth;
}
Thread.sleep(1000);
- inventoryDepth = getInventoryDepth(platform);
+ inventoryDepth = getInventoryDepth(platform, "");
}
return;
}
- protected int getInventoryDepth(Resource root) {
- System.out.println("Inventory depth chart: " + root);
+ protected int getInventoryDepth(Resource root, String indent) {
+ System.out.println("Inventory depth chart: " + indent + root);
if (root == null) {
return 0;
}
int maxDepth = 0;
for (Resource c : root.getChildResources()) {
- int childDepth = getInventoryDepth(c);
+ int childDepth = getInventoryDepth(c, " " + indent);
if (maxDepth < childDepth) {
maxDepth = childDepth;
}
10 years, 3 months
[rhq] modules/plugins
by Jay Shaughnessy
modules/plugins/jboss-as-7/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 15675d86648dbaba58096e58736e5f7917f92882
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Jan 29 14:17:37 2014 -0500
oops, I had narrowed the test suite, re-enable all the test classes
diff --git a/modules/plugins/jboss-as-7/pom.xml b/modules/plugins/jboss-as-7/pom.xml
index 28d33ff..7827000 100644
--- a/modules/plugins/jboss-as-7/pom.xml
+++ b/modules/plugins/jboss-as-7/pom.xml
@@ -627,7 +627,7 @@
<skipITs>false</skipITs>
<includes>
<!-- only include integration tests; normal unit tests are handled above by surefire plugin -->
- <include>org/rhq/modules/plugins/jbossas7/itest/**/DeploymentTest.java</include>
+ <include>org/rhq/modules/plugins/jbossas7/itest/**/*Test.java</include>
<!--<include>org/rhq/modules/plugins/jbossas7/itest/standalone/StandaloneServerComponentTest.java</include>-->
<!--<include>org/rhq/modules/plugins/jbossas7/itest/standalone/InterruptibleOperationsTest.java</include>-->
<!--<include>org/rhq/modules/plugins/jbossas7/itest/standalone/DeploymentTest.java</include>-->
10 years, 3 months