[rhq] modules/core modules/plugins
by Thomas Segismont
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/component/ComponentInvocationContext.java | 44 +++
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java | 59 +++-
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/operation/OperationFacet.java | 22 -
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java | 18 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java | 21 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/component/ComponentInvocationContextImpl.java | 84 ++++++
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationCheckExecutor.java | 8
modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManager.java | 18 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/content/ContentManager.java | 20 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AvailabilityExecutor.java | 18 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 28 +-
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java | 60 ++--
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceFactoryManager.java | 20 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java | 18 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/TimeoutException.java | 21 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementCollectorRunner.java | 18 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java | 18 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/operation/OperationManager.java | 18 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/support/SupportManager.java | 18 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/ComponentServiceImpl.java | 21 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/ComponentUtil.java | 49 +--
modules/core/plugin-container/src/test/java/org/rhq/core/pc/component/ComponentInvocationContextImplTest.java | 92 ++++++
modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/ResourceContainerTest.java | 139 +++++++---
modules/core/plugin-test-util/src/main/java/org/rhq/core/plugin/testutil/AbstractAgentPluginTest.java | 16 -
modules/plugins/jboss-as-5/src/test/java/org/rhq/plugins/jbossas5/test/AbstractDestinationTest.java | 20 -
modules/plugins/jboss-as-5/src/test/java/org/rhq/plugins/jbossas5/test/AbstractResourceTest.java | 22 -
modules/plugins/jboss-as-5/src/test/java/org/rhq/plugins/jbossas5/test/util/AppServerUtils.java | 22 -
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java | 50 +--
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/DeploymentTest.java | 8
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/WebConnectorComponentTest.java | 2
modules/plugins/jboss-cache-v3/src/test/java/org/rhq/plugins/jbosscache3/test/AppServerUtils.java | 20 -
modules/plugins/jboss-cache-v3/src/test/java/org/rhq/plugins/jbosscache3/test/CacheComponentTest.java | 8
modules/plugins/jboss-cache-v3/src/test/java/org/rhq/plugins/jbosscache3/test/OperationTest.java | 21 +
modules/plugins/jboss-cache-v3/src/test/java/org/rhq/plugins/jbosscache3/test/TestHelper.java | 21 +
34 files changed, 679 insertions(+), 363 deletions(-)
New commits:
commit ba84865a0e0172cda10c1350fef054248c43ceed
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Thu Jun 27 16:09:58 2013 +0200
Bug 966777 - EAP 6 plug-in is using a hard-coded operation timeout for start and stop instead of using the operation timeout or agent's default operation timeout of 10 minutes
The component invocation handler now has a transferInterrupt parameter. If set to true, the component invocation thread will be interrupted when the caller thread is.
Introduce ComponentInvocationContext class. An instance of this class is created by the plugin container and bound to facet-locked component invocation thread.
Make BaseServerComponent use ComponentInvocationContext to deal with operation timeout or cancellation.
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/component/ComponentInvocationContext.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/component/ComponentInvocationContext.java
new file mode 100644
index 0000000..4ccfc9d
--- /dev/null
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/component/ComponentInvocationContext.java
@@ -0,0 +1,44 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.core.pluginapi.component;
+
+/**
+ * An instance of this class is created by the plugin container and bound to facet-locked component invocation
+ * thread.
+ *
+ * It helps to detect interrupted component invocations (canceled or timed out).
+ *
+ * @author Thomas Segismont
+ */
+public interface ComponentInvocationContext {
+
+ /**
+ * Whether the component invocation has been interrupted or not.
+ *
+ * @return true if component invocation has been interrupted, false otherwise.
+ */
+ boolean isInterrupted();
+
+
+ /**
+ * Mark this context as interrupted.
+ */
+ void markInterrupted();
+}
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java
index f466df7..8c708db 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java
@@ -1,24 +1,20 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * 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.inventory;
@@ -40,6 +36,7 @@ import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pluginapi.availability.AvailabilityCollectorRunnable;
import org.rhq.core.pluginapi.availability.AvailabilityContext;
import org.rhq.core.pluginapi.availability.AvailabilityFacet;
+import org.rhq.core.pluginapi.component.ComponentInvocationContext;
import org.rhq.core.pluginapi.content.ContentContext;
import org.rhq.core.pluginapi.event.EventContext;
import org.rhq.core.pluginapi.operation.OperationContext;
@@ -86,6 +83,7 @@ public class ResourceContext<T extends ResourceComponent<?>> {
private final InventoryContext inventoryContext;
private final PluginContainerDeployment pluginContainerDeployment;
private final ResourceTypeProcesses trackedProcesses;
+ private final ComponentInvocationContext componentInvocationContext;
private static class Children {
public ResourceType resourceType;
@@ -122,6 +120,32 @@ public class ResourceContext<T extends ResourceComponent<?>> {
private static Map<Children, ResourceTypeProcesses> PROCESSES_PER_PARENT_PER_RESOURCE_TYPE = new HashMap<Children, ResourceTypeProcesses>();
/**
+ * Creates a new {@link ResourceContext} object with a default {@link ComponentInvocationContext}.
+ *
+ * @deprecated as of RHQ 4.9.
+ */
+ @Deprecated
+ public ResourceContext(Resource resource, T parentResourceComponent, ResourceContext<?> parentResourceContext,
+ ResourceDiscoveryComponent<T> resourceDiscoveryComponent, SystemInfo systemInfo, File temporaryDirectory,
+ File dataDirectory, String pluginContainerName, EventContext eventContext, OperationContext operationContext,
+ ContentContext contentContext, AvailabilityContext availabilityContext, InventoryContext inventoryContext,
+ PluginContainerDeployment pluginContainerDeployment) {
+ this(resource, parentResourceComponent, parentResourceContext, resourceDiscoveryComponent, systemInfo,
+ temporaryDirectory, dataDirectory, pluginContainerName, eventContext, operationContext, contentContext,
+ availabilityContext, inventoryContext, pluginContainerDeployment, new ComponentInvocationContext() {
+ @Override
+ public boolean isInterrupted() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void markInterrupted() {
+ throw new UnsupportedOperationException();
+ }
+ });
+ }
+
+ /**
* Creates a new {@link ResourceContext} object.
*
* <b>NOTE:</b> The plugin container is responsible for instantiating these objects; plugin writers should never
@@ -154,7 +178,7 @@ public class ResourceContext<T extends ResourceComponent<?>> {
ResourceDiscoveryComponent<T> resourceDiscoveryComponent, SystemInfo systemInfo, File temporaryDirectory,
File dataDirectory, String pluginContainerName, EventContext eventContext, OperationContext operationContext,
ContentContext contentContext, AvailabilityContext availabilityContext, InventoryContext inventoryContext,
- PluginContainerDeployment pluginContainerDeployment) {
+ PluginContainerDeployment pluginContainerDeployment, ComponentInvocationContext componentInvocationContext) {
this.resourceKey = resource.getResourceKey();
this.resourceType = resource.getResourceType();
@@ -187,6 +211,7 @@ public class ResourceContext<T extends ResourceComponent<?>> {
this.trackedProcesses = getTrackedProcesses(parentResourceUuid, resourceType);
this.resourceUuid = resource.getUuid();
+ this.componentInvocationContext = componentInvocationContext;
}
/**
@@ -562,4 +587,14 @@ public class ResourceContext<T extends ResourceComponent<?>> {
return messageDigest.getDigestString();
}
-}
\ No newline at end of file
+
+ /**
+ * Return the {@link ComponentInvocationContext} object which plugins can use to determine if the component
+ * invocation has been interrupted.
+ *
+ * @return a {@link ComponentInvocationContext} object
+ */
+ public ComponentInvocationContext getComponentInvocationContext() {
+ return componentInvocationContext;
+ }
+}
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/operation/OperationFacet.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/operation/OperationFacet.java
index 11ae84a..5834d83 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/operation/OperationFacet.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/operation/OperationFacet.java
@@ -1,24 +1,20 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * 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.operation;
@@ -55,6 +51,10 @@ public interface OperationFacet {
* {@link OperationResult#setErrorMessage(String) error message} set, in which case, the operation is also
* assumed to have failed.</p>
*
+ * <strong>From RHQ4.9 on, plugin developers should check {@link org.rhq.core.pluginapi.component.ComponentInvocationContext#isInterrupted()}
+ * instead of {@link Thread#isInterrupted()}.</strong> An instance of this class is created by the plugin container
+ * and can be returned by calling {@link org.rhq.core.pluginapi.inventory.ResourceContext#getComponentInvocationContext()}.
+ *
* @param name the name of the operation
* @param parameters the parameters passed to the operation; even for operations with no parameters, an empty
* config will be passed in by the plugin container
@@ -65,4 +65,4 @@ public interface OperationFacet {
* @throws Exception if failed to invoke the operation on the resource
*/
OperationResult invokeOperation(String name, Configuration parameters) throws InterruptedException, Exception;
-}
\ No newline at end of file
+}
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java
index 471978c..90e9f5d 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/upgrade/ResourceUpgradeContext.java
@@ -1,24 +1,20 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * 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.upgrade;
@@ -52,7 +48,7 @@ public class ResourceUpgradeContext<T extends ResourceComponent<?>> extends Reso
private final String description;
/**
- * @see ResourceContext#ResourceContext(org.rhq.core.domain.resource.Resource, org.rhq.core.pluginapi.inventory.ResourceComponent, org.rhq.core.pluginapi.inventory.ResourceContext, org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent, org.rhq.core.system.SystemInfo, java.io.File, java.io.File, String, org.rhq.core.pluginapi.event.EventContext, org.rhq.core.pluginapi.operation.OperationContext, org.rhq.core.pluginapi.content.ContentContext, java.util.concurrent.Executor, org.rhq.core.pluginapi.inventory.PluginContainerDeployment)
+ * @see ResourceContext#ResourceContext(org.rhq.core.domain.resource.Resource, org.rhq.core.pluginapi.inventory.ResourceComponent, org.rhq.core.pluginapi.inventory.ResourceContext, org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent, org.rhq.core.system.SystemInfo, java.io.File, java.io.File, String, org.rhq.core.pluginapi.event.EventContext, org.rhq.core.pluginapi.operation.OperationContext, org.rhq.core.pluginapi.content.ContentContext, org.rhq.core.pluginapi.availability.AvailabilityContext, org.rhq.core.pluginapi.inventory.InventoryContext, org.rhq.core.pluginapi.inventory.PluginContainerDeployment)
*
* @since 4.0
*/
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
index ab79689..4cd148f 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
@@ -1,24 +1,20 @@
/*
- * RHQ Management
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
+ * 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.bundle;
@@ -581,7 +577,8 @@ public class BundleManager extends AgentService implements BundleAgentService, B
* @throws PluginContainerException on error
*/
protected BundleFacet getBundleFacet(int resourceId, long timeout) throws PluginContainerException {
- return ComponentUtil.getComponent(resourceId, BundleFacet.class, FacetLockType.READ, timeout, false, true);
+ return ComponentUtil.getComponent(resourceId, BundleFacet.class, FacetLockType.READ, timeout, false, true,
+ false);
}
/**
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/component/ComponentInvocationContextImpl.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/component/ComponentInvocationContextImpl.java
new file mode 100644
index 0000000..491bb38
--- /dev/null
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/component/ComponentInvocationContextImpl.java
@@ -0,0 +1,84 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.core.pc.component;
+
+import org.rhq.core.pluginapi.component.ComponentInvocationContext;
+
+/**
+ * Plugin container implementation of {@link ComponentInvocationContext}. An instance of this class will be created
+ * by the plugin container and put in the {@link org.rhq.core.pluginapi.inventory.ResourceContext}.
+ *
+ * Component invocation threads MUST call
+ * {@link #setLocalContext(org.rhq.core.pc.component.ComponentInvocationContextImpl.LocalContext)} before executing
+ * component code.
+ *
+ * @author Thomas Segismont
+ */
+public final class ComponentInvocationContextImpl implements ComponentInvocationContext {
+ private static final ThreadLocal<LocalContext> localContext = new ThreadLocal<LocalContext>() {
+ @Override
+ protected LocalContext initialValue() {
+ return new LocalContext();
+ }
+ };
+
+ @Override
+ public boolean isInterrupted() {
+ return localContext.get().isInterrupted();
+ }
+
+ @Override
+ public void markInterrupted() {
+ localContext.get().markInterrupted();
+ }
+
+ /**
+ * Binds the specified {@link LocalContext} instance to the current thread.
+ *
+ * @param localContext
+ *
+ * @throws IllegalArgumentException if <code>localContext</code> is null
+ */
+ public void setLocalContext(LocalContext localContext) {
+ if (localContext == null) {
+ throw new IllegalArgumentException("localContext is null");
+ }
+ ComponentInvocationContextImpl.localContext.set(localContext);
+ }
+
+ /**
+ * Interrupted status holder. A single instance of this class should be bound to the invocation thread by calling
+ * {@link #setLocalContext(org.rhq.core.pc.component.ComponentInvocationContextImpl.LocalContext)}.
+ */
+ public static final class LocalContext implements ComponentInvocationContext {
+
+ private volatile boolean interrupted = false;
+
+ @Override
+ public boolean isInterrupted() {
+ return interrupted;
+ }
+
+ @Override
+ public void markInterrupted() {
+ interrupted = true;
+ }
+ }
+}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationCheckExecutor.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationCheckExecutor.java
index 1af10d6..627070a 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationCheckExecutor.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationCheckExecutor.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2012 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,8 @@
* 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.pc.configuration;
@@ -80,7 +80,7 @@ public class ConfigurationCheckExecutor implements Runnable, Callable {
try {
resourceComponent = resourceContainer.createResourceComponentProxy(ConfigurationFacet.class,
- FacetLockType.NONE, CONFIGURATION_CHECK_TIMEOUT, true, false);
+ FacetLockType.NONE, CONFIGURATION_CHECK_TIMEOUT, true, false, true);
} catch (PluginContainerException e) {
// Expecting when the resource does not support configuration management
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManager.java
index fa2bf09..8ec5d59 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/configuration/ConfigurationManager.java
@@ -1,24 +1,20 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * 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.configuration;
@@ -301,7 +297,7 @@ public class ConfigurationManager extends AgentService implements ContainerServi
throws PluginContainerException {
boolean daemonThread = (lockType != FacetLockType.WRITE);
return ComponentUtil.getComponent(resourceId, ConfigurationFacet.class, lockType, FACET_METHOD_TIMEOUT,
- daemonThread, true);
+ daemonThread, true, daemonThread);
}
/**
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 50bb67a..0b9ef6d 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,24 +1,20 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * 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.content;
@@ -418,7 +414,7 @@ public class ContentManager extends AgentService implements ContainerService, Co
// Perform the discovery
// Use only a read-locked component proxy
ContentFacet contentFacet = ComponentUtil.getComponent(resourceId, ContentFacet.class, FacetLockType.READ,
- FACET_METHOD_TIMEOUT, false, true);
+ FACET_METHOD_TIMEOUT, false, true, false);
Set<ResourcePackageDetails> details = contentFacet.discoverDeployedPackages(type);
@@ -655,7 +651,7 @@ public class ContentManager extends AgentService implements ContainerService, Co
private ContentFacet findContentFacet(int resourceId) throws Exception {
// in case some calls to here need only the read lock - for now, always lock down with the write lock
return ComponentUtil.getComponent(resourceId, ContentFacet.class, FacetLockType.WRITE, FACET_METHOD_TIMEOUT,
- false, true);
+ false, true, false);
}
/**
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AvailabilityExecutor.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AvailabilityExecutor.java
index b4d7106..f9740df 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AvailabilityExecutor.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AvailabilityExecutor.java
@@ -1,24 +1,20 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * 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.inventory;
@@ -206,7 +202,7 @@ public class AvailabilityExecutor implements Runnable, Callable<AvailabilityRepo
AvailabilityFacet resourceComponent;
try {
resourceComponent = resourceContainer.createResourceComponentProxy(AvailabilityFacet.class,
- FacetLockType.NONE, GET_AVAILABILITY_TIMEOUT, true, false);
+ FacetLockType.NONE, GET_AVAILABILITY_TIMEOUT, true, false, true);
} catch (PluginContainerException e) {
// TODO (ips): Why aren't we logging this as an error?
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 704a230..7319c97 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
@@ -1,25 +1,22 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2012 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * 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.inventory;
import java.io.File;
@@ -91,6 +88,7 @@ import org.rhq.core.pc.agent.AgentRegistrar;
import org.rhq.core.pc.agent.AgentService;
import org.rhq.core.pc.availability.AvailabilityCollectorThreadPool;
import org.rhq.core.pc.availability.AvailabilityContextImpl;
+import org.rhq.core.pc.component.ComponentInvocationContextImpl;
import org.rhq.core.pc.content.ContentContextImpl;
import org.rhq.core.pc.drift.sync.DriftSyncManager;
import org.rhq.core.pc.event.EventContextImpl;
@@ -107,6 +105,7 @@ import org.rhq.core.pc.util.FacetLockType;
import org.rhq.core.pc.util.LoggingThreadFactory;
import org.rhq.core.pluginapi.availability.AvailabilityContext;
import org.rhq.core.pluginapi.availability.AvailabilityFacet;
+import org.rhq.core.pluginapi.component.ComponentInvocationContext;
import org.rhq.core.pluginapi.content.ContentContext;
import org.rhq.core.pluginapi.event.EventContext;
import org.rhq.core.pluginapi.inventory.ClassLoaderFacet;
@@ -680,7 +679,7 @@ public class InventoryManager extends AgentService implements ContainerService,
long componentTimeout = (resourceCategory == ResourceCategory.SERVER) ? 10000 : 5000;
// We already possess the lock, so tell the proxy not to do any locking of its own.
resourceComponent = resourceContainer.createResourceComponentProxy(AvailabilityFacet.class,
- FacetLockType.NONE, componentTimeout, true, true);
+ FacetLockType.NONE, componentTimeout, true, true, true);
availType = resourceComponent.getAvailability();
} catch (PluginContainerException e) {
log.error("Failed to retrieve ResourceComponent for " + resource + ".", e);
@@ -1839,7 +1838,7 @@ public class InventoryManager extends AgentService implements ContainerService,
// Wrap the component in a proxy that will provide locking and a timeout for the call to start().
component = container.createResourceComponentProxy(ResourceComponent.class, FacetLockType.READ,
- COMPONENT_START_TIMEOUT, true, false);
+ COMPONENT_START_TIMEOUT, true, false, true);
} catch (Throwable t) {
container.setResourceComponentState(ResourceComponentState.STOPPED);
throw new PluginContainerException("Failed getting proxy for resource " + resource + ".", t);
@@ -1896,7 +1895,8 @@ public class InventoryManager extends AgentService implements ContainerService,
getOperationContext(resource), // for operation manager access
getContentContext(resource), // for content manager access
getAvailabilityContext(resource, this.availabilityCollectors), // for components that want to perform async avail checking
- getInventoryContext(resource), this.configuration.getPluginContainerDeployment()); // helps components make determinations of what to do
+ getInventoryContext(resource), this.configuration.getPluginContainerDeployment(), // helps components make determinations of what to do
+ new ComponentInvocationContextImpl());
}
public <T extends ResourceComponent<?>> ResourceUpgradeContext<T> createResourceUpgradeContext(Resource resource,
@@ -2121,7 +2121,7 @@ public class InventoryManager extends AgentService implements ContainerService,
try {
ResourceComponent<?> component = container.createResourceComponentProxy(ResourceComponent.class,
- FacetLockType.WRITE, COMPONENT_STOP_TIMEOUT, true, true);
+ FacetLockType.WRITE, COMPONENT_STOP_TIMEOUT, true, true, true);
component.stop();
if (log.isDebugEnabled()) {
log.debug("Successfully deactivated resource with id [" + resource.getId() + "].");
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java
index 338676d..4cb2cff 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java
@@ -1,27 +1,26 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * 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.inventory;
+import static org.rhq.core.pc.component.ComponentInvocationContextImpl.LocalContext;
+
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
@@ -56,6 +55,7 @@ import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.MeasurementSchedule;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.pc.component.ComponentInvocationContextImpl;
import org.rhq.core.pc.util.FacetLockType;
import org.rhq.core.pc.util.LoggingThreadFactory;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
@@ -407,13 +407,15 @@ public class ResourceContainer implements Serializable {
* it; value must be positive
* @param daemonThread whether or not the thread used for the invocation should be a daemon thread
* @param onlyIfStarted if <code>true</code>, and the component is not started, an exception is thrown
+ * @param transferInterrupt whether or not interruption of the calling thread should be transfered to the executor
+ * thread
*
* @return a proxy that wraps the given component and exposes the given facet interface; will never be null
*
* @throws PluginContainerException if the component does not exist or does not implement the interface
*/
public <T> T createResourceComponentProxy(Class<T> facetInterface, FacetLockType lockType, long timeout,
- boolean daemonThread, boolean onlyIfStarted) throws PluginContainerException {
+ boolean daemonThread, boolean onlyIfStarted, boolean transferInterrupt) throws PluginContainerException {
if (onlyIfStarted) {
if (!ResourceComponentState.STARTED.equals(getResourceComponentState())) {
throw new PluginContainerException("Resource component could not be retrieved for resource ["
@@ -444,6 +446,7 @@ public class ResourceContainer implements Serializable {
key = 31 * key + lockType.hashCode();
key = 31 * key + (int) (timeout ^ (timeout >>> 32));
key = 31 * key + (daemonThread ? 1 : 0);
+ key = 31 * key + (transferInterrupt ? 1 : 0);
synchronized (this) {
if (this.proxyCache == null) {
@@ -456,7 +459,7 @@ public class ResourceContainer implements Serializable {
// this is the handler that will actually acquire the lock and invoke the facet method call
ResourceComponentInvocationHandler handler = new ResourceComponentInvocationHandler(this, lockType,
- timeout, daemonThread, facetInterface);
+ timeout, daemonThread, facetInterface, transferInterrupt);
// this is the proxy that will look like the facet interface that the caller will use
proxy = (T) Proxy.newProxyInstance(classLoader, new Class<?>[] { facetInterface }, handler);
@@ -501,6 +504,7 @@ public class ResourceContainer implements Serializable {
private final long timeout;
private final boolean daemonThread;
private final Class facetInterface;
+ private final boolean transferInterrupt;
/**
*
@@ -511,9 +515,11 @@ public class ResourceContainer implements Serializable {
* value must be positive
* @param daemonThread whether or not the thread used for the invocation should be a daemon thread
* @param facetInterface the interface that the component implements that is being exposed by this proxy
+ * @param transferInterrupt whether or not interruption of the calling thread should be transfered to the
+ * executor thread
*/
public ResourceComponentInvocationHandler(ResourceContainer container, FacetLockType lockType, long timeout,
- boolean daemonThread, Class facetInterface) {
+ boolean daemonThread, Class facetInterface, boolean transferInterrupt) {
this.container = container;
switch (lockType) {
case WRITE: {
@@ -535,6 +541,7 @@ public class ResourceContainer implements Serializable {
this.timeout = timeout;
this.daemonThread = daemonThread;
this.facetInterface = facetInterface;
+ this.transferInterrupt = transferInterrupt;
}
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
@@ -548,14 +555,15 @@ public class ResourceContainer implements Serializable {
private Object invokeInNewThreadWithLock(Method method, Object[] args) throws Throwable {
ExecutorService threadPool = this.daemonThread ? DAEMON_THREAD_POOL : NON_DAEMON_THREAD_POOL;
- Callable invocationThread = new ComponentInvocationThread(this.container, method, args, this.lock);
- Future<?> future = threadPool.submit(invocationThread);
+ ComponentInvocation componentInvocation = new ComponentInvocation(this.container, method, args, this.lock);
+ Future<?> future = threadPool.submit(componentInvocation);
try {
return future.get(this.timeout, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
LOG.error("Thread [" + Thread.currentThread().getName() + "] was interrupted.");
- if (this.daemonThread) {
+ if (this.transferInterrupt) {
future.cancel(true);
+ componentInvocation.markContextInterrupted();
}
throw new RuntimeException(invokedMethodString(method, args, "was rudely interrupted."), e);
} catch (ExecutionException e) {
@@ -568,6 +576,7 @@ public class ResourceContainer implements Serializable {
+ " milliseconds - invocation thread will be interrupted.");
LOG.debug(msg);
future.cancel(true);
+ componentInvocation.markContextInterrupted();
if (LOG.isDebugEnabled()) {
LOG.debug(this.container.getFacetLockStatus());
}
@@ -599,17 +608,22 @@ public class ResourceContainer implements Serializable {
}
}
- private static class ComponentInvocationThread implements Callable {
+ private static class ComponentInvocation implements Callable {
private final ResourceContainer resourceContainer;
private final Method method;
private final Object[] args;
private final Lock lock;
+ private final ComponentInvocationContextImpl componentInvocationContext;
+ private final LocalContext localContext;
- ComponentInvocationThread(ResourceContainer resourceContainer, Method method, Object[] args, Lock lock) {
+ ComponentInvocation(ResourceContainer resourceContainer, Method method, Object[] args, Lock lock) {
this.resourceContainer = resourceContainer;
this.method = method;
this.args = args;
this.lock = lock;
+ this.componentInvocationContext = (ComponentInvocationContextImpl) resourceContainer.getResourceContext()
+ .getComponentInvocationContext();
+ localContext = new LocalContext();
}
public Object call() throws Exception {
@@ -623,7 +637,11 @@ public class ResourceContainer implements Serializable {
// If we made it here, we have acquired the lock.
}
+ componentInvocationContext.setLocalContext(localContext);
+
ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader();
+
+ // The thread needs to run with a fresh invocation context
try {
ClassLoader pluginClassLoader = this.resourceContainer.getResourceClassLoader();
if (pluginClassLoader == null) {
@@ -648,5 +666,9 @@ public class ResourceContainer implements Serializable {
Thread.currentThread().setContextClassLoader(originalContextClassLoader);
}
}
+
+ public void markContextInterrupted() {
+ localContext.markInterrupted();
+ }
}
-}
\ No newline at end of file
+}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceFactoryManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceFactoryManager.java
index a506493..3dee763 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceFactoryManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceFactoryManager.java
@@ -1,24 +1,20 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * 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.inventory;
@@ -271,7 +267,7 @@ public class ResourceFactoryManager extends AgentService implements ContainerSer
*/
private DeleteResourceFacet getDeleteResourceFacet(int resourceId) throws PluginContainerException {
DeleteResourceFacet facet = ComponentUtil.getComponent(resourceId, DeleteResourceFacet.class,
- FacetLockType.WRITE, FACET_DELETE_TIMEOUT, false, true);
+ FacetLockType.WRITE, FACET_DELETE_TIMEOUT, false, true, false);
return facet;
}
@@ -291,7 +287,7 @@ public class ResourceFactoryManager extends AgentService implements ContainerSer
int createTimeout = (null == timeout || timeout < 1) ? FACET_CREATE_TIMEOUT : timeout;
CreateChildResourceFacet facet = ComponentUtil.getComponent(parentResourceId, CreateChildResourceFacet.class,
- FacetLockType.WRITE, createTimeout, false, true);
+ FacetLockType.WRITE, createTimeout, false, true, false);
return facet;
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java
index 8c663b4..d6a9614 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/RuntimeDiscoveryExecutor.java
@@ -1,24 +1,20 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2012 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * 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.inventory;
@@ -228,7 +224,7 @@ public class RuntimeDiscoveryExecutor implements Runnable, Callable<InventoryRep
AvailabilityFacet parentComponent = null;
try {
parentComponent = parentContainer.createResourceComponentProxy(AvailabilityFacet.class,
- FacetLockType.NONE, AvailabilityExecutor.GET_AVAILABILITY_TIMEOUT, true, false);
+ FacetLockType.NONE, AvailabilityExecutor.GET_AVAILABILITY_TIMEOUT, true, false, true);
} catch (PluginContainerException e) {
if (log.isDebugEnabled()) {
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/TimeoutException.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/TimeoutException.java
index 64695d3..fc4ae17 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/TimeoutException.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/TimeoutException.java
@@ -1,36 +1,31 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * 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.inventory;
import org.rhq.core.pc.util.ComponentUtil;
-import org.rhq.core.pc.util.FacetLockType;
/**
* This exception is thrown when a method invoked on a proxied plugin component times out. If possible, its cause
* will be set to an Exception containing the stack trace of the plugin component thread that timed out.
*
- * @see ResourceContainer#createResourceComponentProxy(Class, FacetLockType, long, boolean, boolean)
- * @see ComponentUtil#getComponent(int, Class, FacetLockType, long, boolean, boolean)
+ * @see ResourceContainer#createResourceComponentProxy(Class, org.rhq.core.pc.util.FacetLockType, long, boolean, boolean, boolean)
+ * @see ComponentUtil#getComponent(int, Class, org.rhq.core.pc.util.FacetLockType, long, boolean, boolean, boolean)
*
* @author Ian Springer
*/
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementCollectorRunner.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementCollectorRunner.java
index 32df8be..7aaf12a 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementCollectorRunner.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementCollectorRunner.java
@@ -1,24 +1,20 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * 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.measurement;
@@ -106,7 +102,7 @@ public class MeasurementCollectorRunner implements Callable<MeasurementReport>,
} else {
MeasurementFacet measurementComponent = ComponentUtil
.getComponent(resourceId, MeasurementFacet.class, FacetLockType.READ,
- MeasurementManager.FACET_METHOD_TIMEOUT, true, true);
+ MeasurementManager.FACET_METHOD_TIMEOUT, true, true, true);
if (log.isDebugEnabled()) {
scheduleHistory.addRequests(requests);
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java
index 8e8c399..6ad3551 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/measurement/MeasurementManager.java
@@ -1,24 +1,20 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * 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.measurement;
@@ -477,7 +473,7 @@ public class MeasurementManager extends AgentService implements MeasurementAgent
try {
measurementFacet = ComponentUtil.getComponent(resourceId, MeasurementFacet.class, FacetLockType.READ,
- FACET_METHOD_TIMEOUT, true, true);
+ FACET_METHOD_TIMEOUT, true, true, true);
} catch (Exception e) {
LOG.warn("Cannot get measurement facet for Resource [" + resourceId + "]. Cause: " + e);
return Collections.emptySet();
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/operation/OperationManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/operation/OperationManager.java
index a3f5f1d..b8a8376 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/operation/OperationManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/operation/OperationManager.java
@@ -1,24 +1,20 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * 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.operation;
@@ -197,7 +193,7 @@ public class OperationManager extends AgentService implements OperationAgentServ
*/
protected OperationFacet getOperationFacet(int resourceId, long facetMethodTimeout) throws PluginContainerException {
return ComponentUtil.getComponent(resourceId, OperationFacet.class, FacetLockType.WRITE, facetMethodTimeout,
- false, false);
+ false, false, true);
}
/**
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/support/SupportManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/support/SupportManager.java
index 6c0f81b..1c67c31 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/support/SupportManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/support/SupportManager.java
@@ -1,24 +1,20 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * 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.support;
@@ -83,6 +79,6 @@ public class SupportManager extends AgentService implements SupportAgentService,
protected SupportFacet getSupportFacet(int resourceId, long facetMethodTimeout) throws PluginContainerException {
return ComponentUtil.getComponent(resourceId, SupportFacet.class, FacetLockType.READ, facetMethodTimeout,
- false, true);
+ false, true, false);
}
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/ComponentServiceImpl.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/ComponentServiceImpl.java
index e1453a6..bd98afd 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/ComponentServiceImpl.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/ComponentServiceImpl.java
@@ -1,34 +1,28 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * 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 org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.plugin.Plugin;
import org.rhq.core.clientapi.agent.PluginContainerException;
import org.rhq.core.pc.PluginContainer;
import org.rhq.core.pc.plugin.PluginManager;
-import org.rhq.core.pluginapi.configuration.ResourceConfigurationFacet;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
public class ComponentServiceImpl implements ComponentService {
@@ -39,7 +33,8 @@ public class ComponentServiceImpl implements ComponentService {
public <T> T getComponent(int resourceId, Class<T> facetInterface, FacetLockType lockType, long timeout,
boolean daemonThread, boolean onlyIfStarted) throws PluginContainerException {
- return ComponentUtil.getComponent(resourceId, facetInterface, lockType, timeout, daemonThread, onlyIfStarted);
+ return ComponentUtil.getComponent(resourceId, facetInterface, lockType, timeout, daemonThread, onlyIfStarted,
+ daemonThread);
}
public String getAmpsVersion(int resourceId) throws PluginContainerException {
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/ComponentUtil.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/ComponentUtil.java
index 9eb6e71..1abe002 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/ComponentUtil.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/util/ComponentUtil.java
@@ -1,25 +1,21 @@
/*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 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-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
package org.rhq.core.pc.util;
import org.rhq.core.clientapi.agent.PluginContainerException;
@@ -84,6 +80,8 @@ public class ComponentUtil {
* it; value must be positive
* @param daemonThread whether or not the thread used for the invocation should be a daemon thread
* @param onlyIfStarted if <code>true</code>, and the component is not started, an exception is thrown
+ * @param transferInterrupt whether or not interruption of the calling thread should be transfered to the executor
+ * thread
*
* @return the resource's <code>T</code> component interface
*
@@ -91,18 +89,19 @@ public class ComponentUtil {
* interface or it is not started and <code>onlyIfStarted</code> is <code>
* true</code>
*
- * @see ResourceContainer#createResourceComponentProxy(Class, FacetLockType, long, boolean, boolean)
+ * @see ResourceContainer#createResourceComponentProxy(Class, FacetLockType, long, boolean, boolean, boolean)
*/
@SuppressWarnings("unchecked")
- public static <T> T getComponent(int resourceId, Class<T> facetInterface, FacetLockType lockType,
- long timeout, boolean daemonThread, boolean onlyIfStarted) throws PluginContainerException {
+ public static <T> T getComponent(int resourceId, Class<T> facetInterface, FacetLockType lockType, long timeout,
+ boolean daemonThread, boolean onlyIfStarted, boolean transferInterrupt) throws PluginContainerException {
InventoryManager inventoryManager = PluginContainer.getInstance().getInventoryManager();
ResourceContainer resourceContainer = inventoryManager.getResourceContainer(resourceId);
if (resourceContainer == null) {
throw new PluginContainerException("Resource component container could not be retrieved for resource: "
+ resourceId);
}
- return resourceContainer.createResourceComponentProxy(facetInterface, lockType, timeout, daemonThread, onlyIfStarted);
+ return resourceContainer.createResourceComponentProxy(facetInterface, lockType, timeout, daemonThread,
+ onlyIfStarted, transferInterrupt);
}
@SuppressWarnings("unchecked")
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/component/ComponentInvocationContextImplTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/component/ComponentInvocationContextImplTest.java
new file mode 100644
index 0000000..00601fa
--- /dev/null
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/component/ComponentInvocationContextImplTest.java
@@ -0,0 +1,92 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.core.pc.component;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.rhq.core.pc.component.ComponentInvocationContextImpl.LocalContext;
+import static org.testng.Assert.assertEquals;
+
+import org.testng.annotations.Test;
+
+/**
+ * @author Thomas Segismont
+ */
+@Test
+public class ComponentInvocationContextImplTest {
+
+ private ComponentInvocationContextImpl componentInvocationContext = new ComponentInvocationContextImpl();
+
+ @Test(timeOut = 1000 * 30)
+ public void newThreadsShouldSeeComponentInvocationContextInitialValue() throws Exception {
+ InterruptedStatusRecorder recorder = new InterruptedStatusRecorder() {
+ @Override
+ public void run() {
+ value = componentInvocationContext.isInterrupted();
+ }
+ };
+ Thread thread = startRecorderThread(recorder);
+ thread.join();
+ assertEquals(recorder.getRecordedValue(), false);
+ }
+
+ @Test(timeOut = 1000 * 30)
+ public void threadShouldSeeLocalContextValue() throws Exception {
+ final LocalContext localContext = new LocalContext();
+ InterruptedStatusRecorder recorder = new InterruptedStatusRecorder() {
+ @Override
+ public void run() {
+ componentInvocationContext.setLocalContext(localContext);
+ while (!componentInvocationContext.isInterrupted()) {
+ try {
+ Thread.sleep(SECONDS.toMillis(1));
+ } catch (InterruptedException e) {
+ break;
+ }
+ }
+ value = componentInvocationContext.isInterrupted();
+ }
+ };
+ Thread thread = startRecorderThread(recorder);
+ localContext.markInterrupted();
+ thread.join();
+ assertEquals(recorder.getRecordedValue(), true);
+ }
+
+ @Test(expectedExceptions = { IllegalArgumentException.class })
+ public void localContextCannotBeNull() {
+ componentInvocationContext.setLocalContext(null);
+ }
+
+ private Thread startRecorderThread(InterruptedStatusRecorder recorder) {
+ Thread thread = new Thread(recorder);
+ thread.setDaemon(true);
+ thread.start();
+ return thread;
+ }
+
+ private abstract class InterruptedStatusRecorder implements Runnable {
+
+ boolean value;
+
+ boolean getRecordedValue() {
+ return value;
+ }
+ }
+}
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/ResourceContainerTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/ResourceContainerTest.java
index 5432eff..75e2d51 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/ResourceContainerTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/inventory/ResourceContainerTest.java
@@ -1,42 +1,50 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * 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.inventory;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
import java.io.File;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.rhq.core.clientapi.agent.metadata.PluginMetadataManager;
+import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.pc.PluginContainer;
import org.rhq.core.pc.PluginContainerConfiguration;
import org.rhq.core.pc.util.FacetLockType;
import org.rhq.core.pluginapi.availability.AvailabilityFacet;
+import org.rhq.core.pluginapi.component.ComponentInvocationContext;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
/**
* Unit test for {@link ResourceContainer}.
@@ -45,6 +53,7 @@ import org.rhq.core.pluginapi.inventory.ResourceContext;
*/
@Test
public class ResourceContainerTest {
+ private static final Log LOG = LogFactory.getLog(ResourceContainerTest.class);
@BeforeClass
public void beforeClass() {
@@ -65,59 +74,115 @@ public class ResourceContainerTest {
}
public void testCreateResourceComponentProxy() throws Exception {
- Resource resource = new Resource("TestPlatformKey", "MyTestPlatform", PluginMetadataManager.TEST_PLATFORM_TYPE);
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
- ResourceContainer resourceContainer = new ResourceContainer(resource, contextClassLoader);
- ResourceComponent resourceComponent = new MockResourceComponent(false);
- resourceContainer.setResourceComponent(resourceComponent);
- System.out.println("Testing proxy call that should timeout...");
+ ResourceContainer resourceContainer = getResourceContainer();
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Testing proxy call that should timeout...");
+ }
AvailabilityFacet resourceComponentProxy = resourceContainer.createResourceComponentProxy(
- AvailabilityFacet.class, FacetLockType.NONE, 50, true, false);
+ AvailabilityFacet.class, FacetLockType.NONE, 50, true, false, true);
try {
resourceComponentProxy.getAvailability();
assert (false);
} catch (RuntimeException e) {
assert (e instanceof TimeoutException) : "[" + e + "] is not a org.rhq.core.pc.inventory.TimeoutException.";
}
- System.out.println("SUCCESS!");
- System.out.println("Testing proxy call that should complete successfully...");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("SUCCESS!");
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Testing proxy call that should complete successfully...");
+ }
resourceComponentProxy = resourceContainer.createResourceComponentProxy(AvailabilityFacet.class,
- FacetLockType.NONE, 150, true, false);
+ FacetLockType.NONE, 150, true, false, true);
AvailabilityType avail = resourceComponentProxy.getAvailability();
assert (avail == AvailabilityType.UP);
- System.out.println("SUCCESS!");
- System.out.println("Testing proxy call that should fail...");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("SUCCESS!");
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Testing proxy call that should fail...");
+ }
ResourceComponent naughtyResourceComponent = new MockResourceComponent(true);
resourceContainer.setResourceComponent(naughtyResourceComponent);
resourceComponentProxy = resourceContainer.createResourceComponentProxy(AvailabilityFacet.class,
- FacetLockType.NONE, Long.MAX_VALUE, true, false);
+ FacetLockType.NONE, Long.MAX_VALUE, true, false, true);
try {
resourceComponentProxy.getAvailability();
assert (false);
} catch (RuntimeException e) {
assert (e instanceof MockRuntimeException);
}
- System.out.println("SUCCESS!");
- System.out.println("Testing proxy call should not timeout; its not to a declared method in proxied interface");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("SUCCESS!");
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Testing proxy call should not timeout; its not to a declared method in proxied interface");
+ }
resourceComponentProxy = resourceContainer.createResourceComponentProxy(AvailabilityFacet.class,
- FacetLockType.NONE, 50, true, false);
+ FacetLockType.NONE, 50, true, false, true);
String string = resourceComponentProxy.toString();
assert (string.equals(MockResourceComponent.class.toString()));
- System.out.println("SUCCESS!");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("SUCCESS!");
+ }
// TODO: Test proxy locking.
}
- class MockResourceComponent implements ResourceComponent {
+ public void testInterruptedComponentInvocationContext() throws Exception {
+ ResourceContainer resourceContainer = getResourceContainer();
+ OperationFacet proxy = resourceContainer.createResourceComponentProxy(OperationFacet.class,
+ FacetLockType.WRITE, 50, true, false, true);
+ try {
+ proxy.invokeOperation("op", new Configuration());
+ fail("Expected invokeOperation to throw a TimeoutException");
+ } catch (TimeoutException e) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Caught expected TimeoutException: " + e.getMessage());
+ }
+ assertTrue(((MockResourceComponent) resourceContainer.getResourceComponent())
+ .caughtInterruptedComponentInvocation());
+ }
+ }
+
+ public void testUninterruptedComponentInvocationContext() throws Exception {
+ ResourceContainer resourceContainer = getResourceContainer();
+ OperationFacet proxy = resourceContainer.createResourceComponentProxy(OperationFacet.class,
+ FacetLockType.WRITE, 150, true, false, true);
+ try {
+ proxy.invokeOperation("op", new Configuration());
+ fail("Expected invokeOperation to throw a TimeoutException");
+ } catch (Exception e) {
+ assertFalse(e instanceof TimeoutException, "Caught unexpected instance of TimeoutException: "
+ + e.getClass().getName());
+ assertFalse(((MockResourceComponent) resourceContainer.getResourceComponent())
+ .caughtInterruptedComponentInvocation());
+ }
+ }
+
+ private ResourceContainer getResourceContainer() {
+ Resource resource = new Resource("TestPlatformKey", "MyTestPlatform", PluginMetadataManager.TEST_PLATFORM_TYPE);
+ ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ ResourceContainer resourceContainer = new ResourceContainer(resource, contextClassLoader);
+ ResourceComponent resourceComponent = new MockResourceComponent(false);
+ resourceContainer.setResourceComponent(resourceComponent);
+ return resourceContainer;
+ }
+
+ class MockResourceComponent implements ResourceComponent, OperationFacet {
private boolean naughty;
+ private boolean caughtInterruptedComponentInvocation;
+ private ResourceContext resourceContext;
MockResourceComponent(boolean naughty) {
this.naughty = naughty;
}
public void start(ResourceContext resourceContext) throws Exception {
+ this.resourceContext = resourceContext;
}
public void stop() {
+ this.resourceContext = null;
}
public AvailabilityType getAvailability() {
@@ -141,6 +206,24 @@ public class ResourceContainerTest {
}
return this.getClass().toString();
}
+
+ @Override
+ public OperationResult invokeOperation(String name, Configuration parameters) throws Exception {
+ long start = System.nanoTime();
+ while (!resourceContext.getComponentInvocationContext().isInterrupted()) {
+ if ((System.nanoTime() - start) > MILLISECONDS.toNanos(100)) {
+ // Make the operation fail after 100ms
+ caughtInterruptedComponentInvocation = false;
+ throw new Exception();
+ }
+ }
+ caughtInterruptedComponentInvocation = true;
+ throw new InterruptedException();
+ }
+
+ public boolean caughtInterruptedComponentInvocation() {
+ return caughtInterruptedComponentInvocation;
+ }
}
class MockRuntimeException extends RuntimeException {
diff --git a/modules/core/plugin-test-util/src/main/java/org/rhq/core/plugin/testutil/AbstractAgentPluginTest.java b/modules/core/plugin-test-util/src/main/java/org/rhq/core/plugin/testutil/AbstractAgentPluginTest.java
index 544c1ce..aef1fa8 100644
--- a/modules/core/plugin-test-util/src/main/java/org/rhq/core/plugin/testutil/AbstractAgentPluginTest.java
+++ b/modules/core/plugin-test-util/src/main/java/org/rhq/core/plugin/testutil/AbstractAgentPluginTest.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2012 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,8 @@
* 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.plugin.testutil;
@@ -204,7 +204,7 @@ public abstract class AbstractAgentPluginTest extends Arquillian {
ResourceContainer resourceContainer = this.pluginContainer.getInventoryManager().getResourceContainer(resource);
long timeoutMillis = 5000;
AvailabilityFacet availFacet = resourceContainer.createResourceComponentProxy(AvailabilityFacet.class,
- FacetLockType.READ, timeoutMillis, false, false);
+ FacetLockType.READ, timeoutMillis, false, false, false);
AvailabilityType avail;
try {
avail = availFacet.getAvailability();
@@ -239,7 +239,7 @@ public abstract class AbstractAgentPluginTest extends Arquillian {
ResourceContainer resourceContainer = this.pluginContainer.getInventoryManager().getResourceContainer(resource);
long timeoutMillis = timeout * 1000;
OperationFacet operationFacet = resourceContainer.createResourceComponentProxy(OperationFacet.class,
- FacetLockType.WRITE, timeoutMillis, false, false);
+ FacetLockType.WRITE, timeoutMillis, false, false, false);
OperationResult operationResult;
try {
operationResult = operationFacet.invokeOperation(operationName, params);
@@ -263,7 +263,7 @@ public abstract class AbstractAgentPluginTest extends Arquillian {
ResourceContainer resourceContainer = this.pluginContainer.getInventoryManager().getResourceContainer(resource);
long timeoutMillis = 5000;
ConfigurationFacet configurationFacet = resourceContainer.createResourceComponentProxy(
- ConfigurationFacet.class, FacetLockType.READ, timeoutMillis, false, false);
+ ConfigurationFacet.class, FacetLockType.READ, timeoutMillis, false, false, false);
return configurationFacet.loadResourceConfiguration();
}
@@ -277,7 +277,7 @@ public abstract class AbstractAgentPluginTest extends Arquillian {
ResourceContainer resourceContainer = this.pluginContainer.getInventoryManager().getResourceContainer(resource);
long timeoutMillis = 5000;
ConfigurationFacet configurationFacet = resourceContainer.createResourceComponentProxy(
- ConfigurationFacet.class, FacetLockType.WRITE, timeoutMillis, false, false);
+ ConfigurationFacet.class, FacetLockType.WRITE, timeoutMillis, false, false, false);
ConfigurationUpdateReport report = new ConfigurationUpdateReport(resourceConfig);
configurationFacet.updateResourceConfiguration(report);
return report;
@@ -547,7 +547,7 @@ public abstract class AbstractAgentPluginTest extends Arquillian {
throw new IllegalStateException("Resource component for " + resource + " has not yet been started.");
}
MeasurementFacet measurementFacet = resourceContainer.createResourceComponentProxy(MeasurementFacet.class,
- FacetLockType.READ, timeoutMillis, false, false);
+ FacetLockType.READ, timeoutMillis, false, false, false);
MeasurementReport report = new MeasurementReport();
MeasurementScheduleRequest request = new MeasurementScheduleRequest(-1, metricName, -1, true,
measurementDefinition.getDataType(), measurementDefinition.getRawNumericType());
diff --git a/modules/plugins/jboss-as-5/src/test/java/org/rhq/plugins/jbossas5/test/AbstractDestinationTest.java b/modules/plugins/jboss-as-5/src/test/java/org/rhq/plugins/jbossas5/test/AbstractDestinationTest.java
index 2c23c8b..5dbdef3 100644
--- a/modules/plugins/jboss-as-5/src/test/java/org/rhq/plugins/jbossas5/test/AbstractDestinationTest.java
+++ b/modules/plugins/jboss-as-5/src/test/java/org/rhq/plugins/jbossas5/test/AbstractDestinationTest.java
@@ -1,24 +1,20 @@
/*
- * Jopr Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
+ * 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.plugins.jbossas5.test;
@@ -159,7 +155,7 @@ public abstract class AbstractDestinationTest extends AbstractResourceTest {
if (resource.getName().equals(getDestinationName())) {
foundDestination = true;
OperationFacet operationFacet = ComponentUtil.getComponent(resource.getId(), OperationFacet.class,
- FacetLockType.WRITE, 3000, true, true);
+ FacetLockType.WRITE, 3000, true, true, true);
String name = "removeAllMessages";
operationFacet.invokeOperation(name, getTestOperationParameters(name));
}
diff --git a/modules/plugins/jboss-as-5/src/test/java/org/rhq/plugins/jbossas5/test/AbstractResourceTest.java b/modules/plugins/jboss-as-5/src/test/java/org/rhq/plugins/jbossas5/test/AbstractResourceTest.java
index b78b522..162254f 100644
--- a/modules/plugins/jboss-as-5/src/test/java/org/rhq/plugins/jbossas5/test/AbstractResourceTest.java
+++ b/modules/plugins/jboss-as-5/src/test/java/org/rhq/plugins/jbossas5/test/AbstractResourceTest.java
@@ -1,24 +1,20 @@
/*
- * Jopr Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
+ * 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.plugins.jbossas5.test;
@@ -95,7 +91,7 @@ public abstract class AbstractResourceTest extends AbstractPluginTest {
for (Resource resource : resources) {
System.out.println("Validating metrics for " + resource + "...");
MeasurementFacet measurementFacet = ComponentUtil.getComponent(resource.getId(),
- MeasurementFacet.class, FacetLockType.READ, MEASUREMENT_FACET_METHOD_TIMEOUT, true, true);
+ MeasurementFacet.class, FacetLockType.READ, MEASUREMENT_FACET_METHOD_TIMEOUT, true, true, true);
for (MeasurementDefinition metricDefinition : metricDefinitions) {
String name = metricDefinition.getName();
try {
@@ -160,7 +156,7 @@ public abstract class AbstractResourceTest extends AbstractPluginTest {
//the 3 seconds to finish. Otherwise all the operations would have to finish in 3 secs
//which can be a bit harsh limit.
OperationFacet operationFacet = ComponentUtil.getComponent(resource.getId(), OperationFacet.class,
- FacetLockType.WRITE, OPERATION_FACET_METHOD_TIMEOUT, true, true);
+ FacetLockType.WRITE, OPERATION_FACET_METHOD_TIMEOUT, true, true, true);
//String name = operationDefinition.getName();
OperationResult result = operationFacet.invokeOperation(name, getTestOperationParameters(name));
System.out.println("Validating operation '" + name + "' result (" + result + ")...");
diff --git a/modules/plugins/jboss-as-5/src/test/java/org/rhq/plugins/jbossas5/test/util/AppServerUtils.java b/modules/plugins/jboss-as-5/src/test/java/org/rhq/plugins/jbossas5/test/util/AppServerUtils.java
index 6b1af87..17e0b1d 100644
--- a/modules/plugins/jboss-as-5/src/test/java/org/rhq/plugins/jbossas5/test/util/AppServerUtils.java
+++ b/modules/plugins/jboss-as-5/src/test/java/org/rhq/plugins/jbossas5/test/util/AppServerUtils.java
@@ -1,24 +1,20 @@
/*
- * Jopr Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
+ * 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.plugins.jbossas5.test.util;
@@ -38,7 +34,6 @@ import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
import org.rhq.core.clientapi.agent.metadata.PluginMetadataManager;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.domain.measurement.ResourceAvailability;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pc.PluginContainer;
@@ -46,7 +41,6 @@ import org.rhq.core.pc.inventory.InventoryManager;
import org.rhq.core.pc.inventory.ResourceContainer;
import org.rhq.core.pc.util.ComponentUtil;
import org.rhq.core.pc.util.FacetLockType;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.plugins.jbossas5.ProfileServiceComponent;
@@ -182,7 +176,7 @@ public class AppServerUtils {
Thread.currentThread().setContextClassLoader(cl);
return ComponentUtil.getComponent(resource.getId(), resourceSpecificFacetInterface, FacetLockType.WRITE,
- timeout, true, true);
+ timeout, true, true, true);
} finally {
Thread.currentThread().setContextClassLoader(currenContextClassLoader);
}
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 13e1b75..0b5dbf5 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
@@ -19,6 +19,8 @@
package org.rhq.modules.plugins.jbossas7;
+import static java.util.concurrent.TimeUnit.SECONDS;
+
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
@@ -43,6 +45,7 @@ import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.pluginapi.availability.AvailabilityCollectorRunnable;
import org.rhq.core.pluginapi.availability.AvailabilityFacet;
+import org.rhq.core.pluginapi.component.ComponentInvocationContext;
import org.rhq.core.pluginapi.event.log.LogFileEventResourceComponentHelper;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
@@ -279,8 +282,6 @@ public abstract class BaseServerComponent<T extends ResourceComponent<?>> extend
protected boolean waitUntilDown() throws InterruptedException {
boolean notAnswering = false;
- int count = 0;
-
while (!notAnswering) {
Operation op = new ReadAttribute(new Address(), "release-version");
@@ -288,21 +289,18 @@ public abstract class BaseServerComponent<T extends ResourceComponent<?>> extend
Result res = getASConnection().execute(op);
if (!res.isSuccess()) { // If op succeeds, server is not down
notAnswering = true;
- } else if (count > 20) {
- break;
}
} catch (Exception e) {
notAnswering = true;
}
if (!notAnswering) {
- try {
- Thread.sleep(1000); // Wait 1s
- } catch (InterruptedException e) {
- // ignore
+ if (context.getComponentInvocationContext().isInterrupted()) {
+ // Operation canceled or timed out
+ throw new InterruptedException();
}
+ Thread.sleep(SECONDS.toMillis(1));
}
- count++;
}
// BZ 893802: wait until server (the process) is really down
@@ -314,8 +312,7 @@ public abstract class BaseServerComponent<T extends ResourceComponent<?>> extend
if (hostPort.isLocal) {
// lets be paranoid here
- for (; count <= 20; count++) {
- ProcessInfo processInfo = context.getNativeProcess();
+ for (ProcessInfo processInfo = context.getNativeProcess(); ; processInfo = context.getNativeProcess()) {
if (processInfo == null) {
// Process not found, so it died, that's fine
break;
@@ -324,16 +321,14 @@ public abstract class BaseServerComponent<T extends ResourceComponent<?>> extend
// Process info says process is no longer running, that's fine
break;
}
- // Process is still running, wait a second and check again
- try {
- Thread.sleep(1000); // Wait 1s
- } catch (InterruptedException e) {
- // ignore
+ if (context.getComponentInvocationContext().isInterrupted()) {
+ // Operation canceled or timed out
+ throw new InterruptedException();
}
+ // Process is still running, wait a second and check again
+ Thread.sleep(SECONDS.toMillis(1));
}
}
-
- log.debug("waitUntilDown: Used " + count + " delay round(s) to shut down. Server down=" + notAnswering);
return notAnswering;
}
@@ -342,7 +337,7 @@ public abstract class BaseServerComponent<T extends ResourceComponent<?>> extend
*
* @return the result of the operation
*/
- protected OperationResult startServer() {
+ protected OperationResult startServer() throws InterruptedException {
OperationResult operationResult = new OperationResult();
if (isManuallyAddedServer(operationResult, "Starting")) {
return operationResult;
@@ -383,8 +378,7 @@ public abstract class BaseServerComponent<T extends ResourceComponent<?>> extend
// standalone.bat.conf and domain.bat.conf respectively.
processExecution.setWorkingDirectory(startScriptFile.getParent());
processExecution.setCaptureOutput(true);
- processExecution.setWaitForCompletion(15000L); // 15 seconds // TODO: Should we wait longer than 15 seconds?
- processExecution.setKillOnTimeout(false);
+ processExecution.setWaitForCompletion(0);
if (log.isDebugEnabled()) {
log.debug("About to execute the following process: [" + processExecution + "]");
@@ -484,17 +478,14 @@ public abstract class BaseServerComponent<T extends ResourceComponent<?>> extend
return startScriptFile;
}
- private boolean waitForServerToStart() {
+ private boolean waitForServerToStart() throws InterruptedException {
boolean up = false;
- int count = 0;
while (!up) {
Operation op = new ReadAttribute(new Address(), "release-version");
try {
Result res = getASConnection().execute(op);
if (res.isSuccess()) { // If op succeeds, server is not down
up = true;
- } else if (count > 20) {
- break;
}
} catch (Exception e) {
//do absolutely nothing
@@ -503,13 +494,12 @@ public abstract class BaseServerComponent<T extends ResourceComponent<?>> extend
}
if (!up) {
- try {
- Thread.sleep(1000); // Wait 1s
- } catch (InterruptedException e) {
- // ignore
+ if (context.getComponentInvocationContext().isInterrupted()) {
+ // Operation canceled or timed out
+ throw new InterruptedException();
}
+ Thread.sleep(SECONDS.toMillis(1));
}
- count++;
}
return up;
}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/DeploymentTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/DeploymentTest.java
index 5b552bc..b872ad6 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/DeploymentTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/DeploymentTest.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2012 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,8 @@
* 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.modules.plugins.jbossas7.itest.standalone;
@@ -272,7 +272,7 @@ public class DeploymentTest extends AbstractJBossAS7PluginTest {
ResourceContainer webRuntimeResourceContainer = pluginContainer.getInventoryManager().getResourceContainer(
webRuntimeResource);
MeasurementFacet measurementFacet = webRuntimeResourceContainer.createResourceComponentProxy(
- MeasurementFacet.class, FacetLockType.READ, SECONDS.toMillis(5), false, false);
+ MeasurementFacet.class, FacetLockType.READ, SECONDS.toMillis(5), false, false, false);
MeasurementReport report = new MeasurementReport();
Set<MeasurementScheduleRequest> measurementScheduleRequests = getMeasurementScheduleRequests(webRuntimeResource);
measurementFacet.getValues(report, measurementScheduleRequests);
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/WebConnectorComponentTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/WebConnectorComponentTest.java
index ca86d5e..31343f3 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/WebConnectorComponentTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/WebConnectorComponentTest.java
@@ -88,7 +88,7 @@ public class WebConnectorComponentTest extends AbstractJBossAS7PluginTest {
requests.add(newMeasurementRequest(MAX_CONNECTIONS_METRIC_NAME));
MeasurementReport report = new MeasurementReport();
ComponentUtil.getComponent(webConnectorResource.getId(), MeasurementFacet.class, FacetLockType.READ,
- SECONDS.toMillis(30), true, false).getValues(report, requests);
+ SECONDS.toMillis(30), true, false, true).getValues(report, requests);
Set<MeasurementDataNumeric> numericMetrics = report.getNumericData();
assertEquals(numericMetrics, 1);
MeasurementData measurementData = numericMetrics.iterator().next();
diff --git a/modules/plugins/jboss-cache-v3/src/test/java/org/rhq/plugins/jbosscache3/test/AppServerUtils.java b/modules/plugins/jboss-cache-v3/src/test/java/org/rhq/plugins/jbosscache3/test/AppServerUtils.java
index 653e86d..b07e10a 100644
--- a/modules/plugins/jboss-cache-v3/src/test/java/org/rhq/plugins/jbosscache3/test/AppServerUtils.java
+++ b/modules/plugins/jboss-cache-v3/src/test/java/org/rhq/plugins/jbosscache3/test/AppServerUtils.java
@@ -1,24 +1,20 @@
/*
- * Jopr Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
+ * 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.plugins.jbosscache3.test;
@@ -187,7 +183,7 @@ public class AppServerUtils {
return ComponentUtil.getComponent(asResource.getId(),
resourceSpecificFacetInterface, FacetLockType.WRITE,
- DEPLOY_CONTENT_TIMEOUT, true, true);
+ DEPLOY_CONTENT_TIMEOUT, true, true, true);
} finally {
Thread.currentThread().setContextClassLoader(
currenContextClassLoader);
diff --git a/modules/plugins/jboss-cache-v3/src/test/java/org/rhq/plugins/jbosscache3/test/CacheComponentTest.java b/modules/plugins/jboss-cache-v3/src/test/java/org/rhq/plugins/jbosscache3/test/CacheComponentTest.java
index 2189e6b..6d9a025 100644
--- a/modules/plugins/jboss-cache-v3/src/test/java/org/rhq/plugins/jbosscache3/test/CacheComponentTest.java
+++ b/modules/plugins/jboss-cache-v3/src/test/java/org/rhq/plugins/jbosscache3/test/CacheComponentTest.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,8 @@
* 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.plugins.jbosscache3.test;
@@ -183,7 +183,7 @@ public class CacheComponentTest {
MeasurementFacet measurementFacet = ComponentUtil.getComponent(
resource.getId(), MeasurementFacet.class,
FacetLockType.READ, MEASUREMENT_FACET_METHOD_TIMEOUT, true,
- true);
+ true, true);
EmsBean relatedBean = connection.getBean(resource.getResourceKey());
for (MeasurementDefinition metricDefinition : metricDefinitions) {
diff --git a/modules/plugins/jboss-cache-v3/src/test/java/org/rhq/plugins/jbosscache3/test/OperationTest.java b/modules/plugins/jboss-cache-v3/src/test/java/org/rhq/plugins/jbosscache3/test/OperationTest.java
index 1c69a88..cab153b 100644
--- a/modules/plugins/jboss-cache-v3/src/test/java/org/rhq/plugins/jbosscache3/test/OperationTest.java
+++ b/modules/plugins/jboss-cache-v3/src/test/java/org/rhq/plugins/jbosscache3/test/OperationTest.java
@@ -1,3 +1,22 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
package org.rhq.plugins.jbosscache3.test;
import java.util.Set;
@@ -51,7 +70,7 @@ public class OperationTest {
resource.getId(), OperationFacet.class,
FacetLockType.WRITE,
CacheComponentTest.OPERATION_FACET_METHOD_TIMEOUT,
- true, true);
+ true, true, true);
for (OperationDefinition operationDefinition : operationDefinitions) {
String name = operationDefinition.getName();
diff --git a/modules/plugins/jboss-cache-v3/src/test/java/org/rhq/plugins/jbosscache3/test/TestHelper.java b/modules/plugins/jboss-cache-v3/src/test/java/org/rhq/plugins/jbosscache3/test/TestHelper.java
index 16c453e..5284f1d 100644
--- a/modules/plugins/jboss-cache-v3/src/test/java/org/rhq/plugins/jbosscache3/test/TestHelper.java
+++ b/modules/plugins/jboss-cache-v3/src/test/java/org/rhq/plugins/jbosscache3/test/TestHelper.java
@@ -1,3 +1,22 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
package org.rhq.plugins.jbosscache3.test;
import java.io.File;
@@ -104,7 +123,7 @@ public class TestHelper {
.getComponent(resource.getId(), MeasurementFacet.class,
FacetLockType.READ,
CacheComponentTest.MEASUREMENT_FACET_METHOD_TIMEOUT,
- true, true);
+ true, true, true);
ResourceType resourceType = resource.getResourceType();
Set<MeasurementDefinition> metricDefinitions = resourceType
.getMetricDefinitions();
10 years, 10 months
[rhq] Changes to 'bug/966777'
by Thomas Segismont
New branch 'bug/966777' available with the following commits:
commit 8d3cee90914164538471b723b1f344fbaffcfe8c
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Tue Jul 2 12:24:21 2013 +0200
Bug 966777 - EAP 6 plug-in is using a hard-coded operation timeout for start and stop instead of using the operation timeout or agent's default operation timeout of 10 minutes
Make ComponentInvocationContext accessible from ResourceContext. Expose interface only in plugin api.
commit cf043bcb4499155839dcf00818e6e12c22b90d05
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Thu Jun 27 17:05:03 2013 +0200
Bug 966777 - EAP 6 plug-in is using a hard-coded operation timeout for start and stop instead of using the operation timeout or agent's default operation timeout of 10 minutes
Introduce ComponentInvocationContext class. An instance of this class is created by the plugin container and bound to facet-locked component invocation thread.
Make BaseServerComponent use ComponentInvocationContext to deal with operation timeout or cancellation.
commit fa52ed9d1a80905903a4294971c898c978cd11d5
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Thu Jun 27 16:09:58 2013 +0200
Bug 966777 - EAP 6 plug-in is using a hard-coded operation timeout for start and stop instead of using the operation timeout or agent's default operation timeout of 10 minutes
The component invocation handler now has a transferInterrupt parameter. If set to true, the component invocation thread will be interrupted when the caller thread is.
10 years, 10 months
[rhq] 2 commits - modules/enterprise
by mike thompson
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/AbstractMetricGraph.java | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupD3GraphListView.java | 18 ----------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupMultiLineGraphListView.java | 14 ++++++-
3 files changed, 11 insertions(+), 22 deletions(-)
New commits:
commit 321fbfbe0a5865449ce5b1f5e9ff2ce2704151ef
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Mon Jul 1 19:48:53 2013 -0700
Syntax error fix.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupMultiLineGraphListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupMultiLineGraphListView.java
index 101df60..2804af0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupMultiLineGraphListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupMultiLineGraphListView.java
@@ -41,7 +41,7 @@ public final class CompositeGroupMultiLineGraphListView extends CompositeGroupD3
@Override
public native void drawJsniChart() /*-{
console.log("Draw nvd3 charts for composite multiline graph");
- var chartId = global.@org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.table.CompositeGroupD3GraphListView::getChartId()(),
+ var chartId = this.@org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.table.CompositeGroupD3GraphListView::getChartId()(),
chartHandle = "#mChart-"+chartId,
chartSelection = chartHandle + " svg",
yAxisUnits = this.@org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.table.CompositeGroupD3GraphListView::getYAxisUnits()(),
commit 4d8fded37b908cf50768b5ef249395b9fba75deb
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Fri Jun 28 09:45:20 2013 -0700
[BZ 958754] On Multi-resource graph, time units should have minutes when appropriate.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/AbstractMetricGraph.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/AbstractMetricGraph.java
index 8661136..e75b65a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/AbstractMetricGraph.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/AbstractMetricGraph.java
@@ -29,7 +29,6 @@ import org.rhq.enterprise.gui.coregui.client.Messages;
import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.components.measurement.AbstractMeasurementRangeEditor;
import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractD3GraphListView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.D3GraphListView;
import org.rhq.enterprise.gui.coregui.client.util.Log;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.preferences.MeasurementUserPreferences;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupD3GraphListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupD3GraphListView.java
index dfb53b3..faeb476 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupD3GraphListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupD3GraphListView.java
@@ -350,24 +350,6 @@ public abstract class CompositeGroupD3GraphListView extends EnhancedVLayout impl
return sb.toString();
}
- /**
- * If there is more than 2 days time window then return true so we can show day of week
- * in axis labels. Function to switch the timescale to whichever is more appropriate hours
- * or hours with days of week.
- * @return true if difference between startTime and endTime is >= x days
- */
- public boolean shouldDisplayDayOfWeekInXAxisLabel() {
- // because of asyncrony this is possible so default it
- if (null == measurementForEachResource || measurementForEachResource.isEmpty()) {
- return true;
- }
- List<MeasurementDataNumericHighLowComposite> firstResourceMeasurementList = measurementForEachResource.get(0)
- .getMeasurementData();
- Long startTime = firstResourceMeasurementList.get(0).getTimestamp();
- Long endTime = firstResourceMeasurementList.get(firstResourceMeasurementList.size() - 1).getTimestamp();
- long timeThreshold = 24 * 60 * 60 * 1000; // 1 days
- return startTime + timeThreshold < endTime;
- }
/**
* Client can choose which graph types to render.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupMultiLineGraphListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupMultiLineGraphListView.java
index 46e51c0..101df60 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupMultiLineGraphListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupMultiLineGraphListView.java
@@ -19,6 +19,9 @@
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.table;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.Messages;
+
/**
* A MultiLine version of the Composite group single metric multiple resource charts.
*
@@ -26,6 +29,7 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring
*/
public final class CompositeGroupMultiLineGraphListView extends CompositeGroupD3GraphListView
{
+ private static final Messages MSG = CoreGUI.getMessages();
public CompositeGroupMultiLineGraphListView(int groupId, int defId, boolean isAutogroup)
{
@@ -37,16 +41,14 @@ public final class CompositeGroupMultiLineGraphListView extends CompositeGroupD3
@Override
public native void drawJsniChart() /*-{
console.log("Draw nvd3 charts for composite multiline graph");
- var chartId = this.@org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.table.CompositeGroupD3GraphListView::getChartId()(),
+ var chartId = global.@org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.table.CompositeGroupD3GraphListView::getChartId()(),
chartHandle = "#mChart-"+chartId,
chartSelection = chartHandle + " svg",
yAxisUnits = this.@org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.table.CompositeGroupD3GraphListView::getYAxisUnits()(),
xAxisLabel = this.@org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.table.CompositeGroupD3GraphListView::getXAxisTitle()(),
- displayDayOfWeek = this.@org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.table.CompositeGroupD3GraphListView::shouldDisplayDayOfWeekInXAxisLabel()(),
- xAxisTimeFormat = (displayDayOfWeek) ? "%a %I %p" : "%I %p",
+ xAxisTimeFormat = this.@org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.table.CompositeGroupMultiLineGraphListView::getXAxisTimeFormatHoursMinutes()();
json = eval(this.@org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.table.CompositeGroupD3GraphListView::getJsonMetrics()());
-
$wnd.nv.addGraph(function() {
var chart = $wnd.nv.models.lineChart();
@@ -68,4 +70,10 @@ public final class CompositeGroupMultiLineGraphListView extends CompositeGroupD3
});
}-*/;
+
+
+
+ public String getXAxisTimeFormatHoursMinutes() {
+ return MSG.chart_xaxis_time_format_hours_minutes();
+ }
}
10 years, 10 months
[rhq] 2 commits - modules/core
by John Sanda
modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNodeLoadComposite.java | 32 +++++++++-
1 file changed, 29 insertions(+), 3 deletions(-)
New commits:
commit 85153e8fc2de1b12eab75560146f20b095ac430c
Merge: 0962d2c c8b2a83
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 1 17:22:12 2013 -0400
Merge branch 'master' of ssh://git.fedorahosted.org/git/rhq/rhq
commit 0962d2c35f1e515ba96c9c606384fd1e6bb8e31d
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 1 17:21:35 2013 -0400
adding some javadocs for reported metrics
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNodeLoadComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNodeLoadComposite.java
index c6507c4..379eba6 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNodeLoadComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/StorageNodeLoadComposite.java
@@ -79,6 +79,9 @@ public class StorageNodeLoadComposite implements Serializable {
this.endTime = endTime;
}
+ /**
+ * @return heapCommitted A computed metric for the amount of memory that is committed for the JVM to use.
+ */
public MeasurementAggregateWithUnits getHeapCommitted() {
return heapCommitted;
}
@@ -86,7 +89,10 @@ public class StorageNodeLoadComposite implements Serializable {
public void setHeapCommitted(MeasurementAggregateWithUnits heapCommitted) {
this.heapCommitted = heapCommitted;
}
-
+
+ /**
+ * @return A computed metric for the amount of JVM heap memory used
+ */
public MeasurementAggregateWithUnits getHeapUsed() {
return heapUsed;
}
@@ -95,6 +101,10 @@ public class StorageNodeLoadComposite implements Serializable {
this.heapUsed = heapUsed;
}
+ /**
+ * @return A computed metric for the {@link #getHeapUsed() heapUsed} divided by the
+ * {@link #getHeapCommitted() heapCommitted} expressed as a percentage.
+ */
public MeasurementAggregateWithUnits getHeapPercentageUsed() {
return heapPercentageUsed;
}
@@ -102,7 +112,11 @@ public class StorageNodeLoadComposite implements Serializable {
public void setHeapPercentageUsed(MeasurementAggregateWithUnits heapPercentageUsed) {
this.heapPercentageUsed = heapPercentageUsed;
}
-
+
+ /**
+ * @return A computed metric for the space used on disk by all SSTables of all column families expressed as a
+ * percentage.
+ */
public MeasurementAggregateWithUnits getDiskSpacePercentageUsed() {
return diskSpacePercentageUsed;
}
@@ -110,7 +124,10 @@ public class StorageNodeLoadComposite implements Serializable {
public void setDiskSpacePercentageUsed(MeasurementAggregateWithUnits diskSpacePercentageUsed) {
this.diskSpacePercentageUsed = diskSpacePercentageUsed;
}
-
+
+ /**
+ * @return A computed metric for the the reported disk space used by all SSTables on disk for all column families.
+ */
public MeasurementAggregateWithUnits getLoad() {
return load;
}
@@ -119,6 +136,10 @@ public class StorageNodeLoadComposite implements Serializable {
this.load = load;
}
+ /**
+ * @return A computed metric for the number of tokens owned by this node. The range of values between two tokens is
+ * the range of possible keys for that portion of the token ring.
+ */
public MeasurementAggregate getTokens() {
return tokens;
}
@@ -127,6 +148,11 @@ public class StorageNodeLoadComposite implements Serializable {
this.tokens = tokens;
}
+ /**
+ * @return A computed metric for a percentage of keys owned by this node. This directly correlates to the
+ * number of {@link #getTokens() tokens}. For example, if you have a a two node cluster with each node having 256
+ * tokens, then with an even distribution, this metric should be right around 50%.
+ */
public MeasurementAggregateWithUnits getActuallyOwns() {
return actuallyOwns;
}
10 years, 10 months
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/agentupdate/AgentUpdateServlet.java | 19 ++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
New commits:
commit c8b2a83182eac7882e78095a43c554b1caf191e5
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jul 1 16:24:33 2013 -0400
BZ 914781 - on error, log the remote client address to help figure out which agent is having the problem
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/agentupdate/AgentUpdateServlet.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/agentupdate/AgentUpdateServlet.java
index 994a924..d115187 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/agentupdate/AgentUpdateServlet.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/agentupdate/AgentUpdateServlet.java
@@ -34,6 +34,7 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.cloud.Server.OperationMode;
import org.rhq.core.domain.common.composite.SystemSetting;
import org.rhq.core.domain.common.composite.SystemSettings;
+import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.core.util.stream.StreamUtil;
import org.rhq.enterprise.server.core.AgentManagerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -160,7 +161,9 @@ public class AgentUpdateServlet extends HttpServlet {
agentJarStream.close();
}
} catch (Throwable t) {
- log.error("Failed to stream agent jar.", t);
+ String clientAddr = getClientAddress(req);
+ log.error("Failed to stream agent jar to remote client [" + clientAddr + "]: "
+ + ThrowableUtil.getAllMessages(t));
disableBrowserCache(resp);
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Failed to stream agent jar");
}
@@ -178,7 +181,9 @@ public class AgentUpdateServlet extends HttpServlet {
byte[] versionData = StreamUtil.slurp(stream);
resp.getOutputStream().write(versionData);
} catch (Throwable t) {
- log.error("Failed to stream version info.", t);
+ String clientAddr = getClientAddress(req);
+ log.error("Failed to stream version info to remote client [" + clientAddr + "]: "
+ + ThrowableUtil.getAllMessages(t));
disableBrowserCache(resp);
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Failed to stream version info");
}
@@ -253,4 +258,14 @@ public class AgentUpdateServlet extends HttpServlet {
}
}
+ private String getClientAddress(HttpServletRequest request) {
+ String ip = request.getHeader("X-Forwarded-For");
+ if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getHeader("HTTP_X_FORWARDED_FOR");
+ if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+ ip = String.format("%s (%s)", request.getRemoteHost(), request.getRemoteAddr());
+ }
+ }
+ return ip;
+ }
}
\ No newline at end of file
10 years, 10 months
[rhq] modules/plugins
by John Sanda
modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
New commits:
commit 870091c34662c19841f8ce40914498ab7cfe4258
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 1 15:18:21 2013 -0400
add some more detail in reporting repair results
diff --git a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
index 5722e37..cc34fe3 100644
--- a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
+++ b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
@@ -157,15 +157,16 @@ public class StorageNodeComponent extends CassandraNodeComponent implements Oper
result.operation = "repair " + keyspace + " keyspace";
try {
if (log.isDebugEnabled()) {
- log.debug("Running repair on " + keyspace + " keyspace");
+ log.debug("Running primary range repair on " + keyspace + " keyspace");
}
long start = System.currentTimeMillis();
keyspaceService.repairPrimaryRange(keyspace);
long end = System.currentTimeMillis();
if (log.isDebugEnabled()) {
- log.debug("Finsihed repair on " + keyspace + " keyspace in " + (end - start) + " ms");
+ log.debug("Finsihed primary range repair on " + keyspace + " keyspace in " + (end - start) + " ms");
}
result.succeeded = true;
+ result.details = "Completed repair operation in " + (end - start) + " ms.";
} catch (Exception e) {
log.error("An error occurred while running repair on " + keyspace, e);
Throwable rootCause = ThrowableUtil.getRootCause(e);
10 years, 10 months
[rhq] modules/enterprise modules/plugins
by John Sanda
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java | 28 ++++++++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java | 13 ++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java | 8 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/StorageClusterReadRepairJob.java | 24 ++++++++
modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java | 19 ++++++
modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml | 12 ++++
6 files changed, 103 insertions(+), 1 deletion(-)
New commits:
commit 53f1d430fcef238e9315071eb355bc1d79985d86
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jul 1 14:54:17 2013 -0400
initial support for regularly scheduled read repair (i.e., anti-entropy repair)
Repair is set up to run weekly starting at 12:30 AM every sunday. The repair
operation is run serially, one node at a time. StorageClusterReadRepairJob is
the new quartz job that kicks off the repair. It simply delegates to
StorageNodeManagerBean.runReadRepair which in turn schedules a group operation.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
index 4504d53..90d9497 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
@@ -48,12 +48,14 @@ import org.rhq.core.domain.cloud.Server;
import org.rhq.core.domain.cloud.StorageNode;
import org.rhq.core.domain.cloud.StorageNode.OperationMode;
import org.rhq.core.domain.cloud.StorageNodeLoadComposite;
+import org.rhq.core.domain.common.JobTrigger;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.criteria.StorageNodeCriteria;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.MeasurementAggregate;
import org.rhq.core.domain.measurement.MeasurementUnits;
+import org.rhq.core.domain.operation.bean.GroupOperationSchedule;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
@@ -118,6 +120,9 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
@EJB
private ResourceGroupManagerLocal resourceGroupManager;
+ @EJB
+ private OperationManagerLocal operationManager;
+
@Override
public synchronized List<StorageNode> scanForStorageNodes() {
List<StorageNode> existingStorageNodes = getStorageNodes();
@@ -551,4 +556,27 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
resourceId = storageNode.getResource().getId();
return resourceId;
}
+
+ @Override
+ public void runReadRepair() {
+ ResourceGroup storageNodeGroup = getStorageNodeGroup();
+
+ if (storageNodeGroup.getExplicitResources().size() < 2) {
+ log.info("Skipping read repair since this is a single-node cluster");
+ return;
+ }
+
+ log.info("Scheduling read repair maintenance for storage cluster");
+
+ GroupOperationSchedule schedule = new GroupOperationSchedule();
+ schedule.setGroup(storageNodeGroup);
+ schedule.setHaltOnFailure(false);
+ schedule.setExecutionOrder(new ArrayList<Resource>(storageNodeGroup.getExplicitResources()));
+ schedule.setJobTrigger(JobTrigger.createNowTrigger());
+ schedule.setSubject(subjectManager.getOverlord());
+ schedule.setOperationName("readRepair");
+ schedule.setDescription("Run scheduled read repair on storage node");
+
+ operationManager.scheduleGroupOperation(subjectManager.getOverlord(), schedule);
+ }
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
index 5b13428..54646ec 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
@@ -73,4 +73,17 @@ public interface StorageNodeManagerLocal {
*/
void prepareNodeForUpgrade(Subject subject, StorageNode storageNode);
+ /**
+ * <p>
+ * Schedules read repair to run on the storage cluster. The repair operation is executed one node at a time. This
+ * method is invoked from {@link org.rhq.enterprise.server.scheduler.jobs.StorageClusterReadRepairJob StorageClusterReadRepairJob}
+ * as part of regularly scheduled maintenance.
+ * </p>
+ * <p>
+ * <strong>NOTE:</strong> Repair is one of the most resource-intensive operations that a storage node performs. Make
+ * sure you know what you are doing if you invoke this method outside of the regularly scheduled maintenance window.
+ * </p>
+ */
+ void runReadRepair();
+
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java
index 9d37b75..7ce77d8 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java
@@ -88,6 +88,7 @@ import org.rhq.enterprise.server.scheduler.jobs.DynaGroupAutoRecalculationJob;
import org.rhq.enterprise.server.scheduler.jobs.PurgePluginsJob;
import org.rhq.enterprise.server.scheduler.jobs.PurgeResourceTypesJob;
import org.rhq.enterprise.server.scheduler.jobs.SavedSearchResultCountRecalculationJob;
+import org.rhq.enterprise.server.scheduler.jobs.StorageClusterReadRepairJob;
import org.rhq.enterprise.server.scheduler.jobs.StorageNodeMaintenanceJob;
import org.rhq.enterprise.server.storage.StorageClientManagerBean;
import org.rhq.enterprise.server.storage.StorageClusterHeartBeatJob;
@@ -665,7 +666,12 @@ public class StartupBean implements StartupLocal {
log.error("Cannot create alert availability duration job.", e);
}
- return;
+ try {
+ String cronString = "0 30 0 ? * SUN *"; // every sunday starting at 00:30.
+ schedulerBean.scheduleSimpleCronJob(StorageClusterReadRepairJob.class, true, true, cronString);
+ } catch (Exception e) {
+ log.error("Cannot create storage cluster read repair job", e);
+ }
}
/**
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/StorageClusterReadRepairJob.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/StorageClusterReadRepairJob.java
new file mode 100644
index 0000000..a6dd934
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/jobs/StorageClusterReadRepairJob.java
@@ -0,0 +1,24 @@
+package org.rhq.enterprise.server.scheduler.jobs;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+
+import org.rhq.enterprise.server.cloud.StorageNodeManagerLocal;
+import org.rhq.enterprise.server.util.LookupUtil;
+
+/**
+ * @author John Sanda
+ */
+public class StorageClusterReadRepairJob extends AbstractStatefulJob {
+
+ private Log log = LogFactory.getLog(StorageClusterReadRepairJob.class);
+
+ @Override
+ public void executeJobCode(JobExecutionContext context) throws JobExecutionException {
+ log.info("Preparing to run read repair on storage cluster");
+ StorageNodeManagerLocal storageNodeManager = LookupUtil.getStorageNodeManager();
+ storageNodeManager.runReadRepair();
+ }
+}
diff --git a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
index 08b5205..5722e37 100644
--- a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
+++ b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
@@ -61,6 +61,8 @@ public class StorageNodeComponent extends CassandraNodeComponent implements Oper
return nodeAdded(parameters);
} else if (name.equals("prepareForUpgrade")) {
return prepareForUpgrade(parameters);
+ } else if (name.equals("readRepair")) {
+ return readRepair();
} else {
return super.invokeOperation(name, parameters);
}
@@ -133,6 +135,23 @@ public class StorageNodeComponent extends CassandraNodeComponent implements Oper
return result;
}
+ private OperationResult readRepair() {
+ KeyspaceService keyspaceService = new KeyspaceService(getEmsConnection());
+ OperationResult result = new OperationResult();
+ Configuration resultConfig = result.getComplexResults();
+ PropertyList resultsList = new PropertyList("results");
+
+ OpResult opResult = repairKeyspace(keyspaceService, RHQ_KEYSPACE);
+ resultsList.add(toPropertyMap(opResult));
+
+ opResult = repairKeyspace(keyspaceService, SYSTEM_AUTH_KEYSPACE);
+ resultsList.add(toPropertyMap(opResult));
+
+ resultConfig.put(resultsList);
+
+ return result;
+ }
+
private OpResult repairKeyspace(KeyspaceService keyspaceService, String keyspace) {
OpResult result = new OpResult();
result.operation = "repair " + keyspace + " keyspace";
diff --git a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
index 0029cd4..f02c8e6 100644
--- a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
@@ -61,6 +61,18 @@
<c:simple-property name="startResult" description="Restart the Cassandra daemon"/>
</results>
</operation>
+
+ <operation name="readRepair" description="Runs read repair on primar range of rhq and system_auth keyspaces">
+ <results>
+ <c:list-property name="results">
+ <c:map-property name="resultsMap">
+ <c:simple-property name="task" type="string"/>
+ <c:simple-property name="succeeded" type="boolean"/>
+ <c:simple-property name="details" type="string"/>
+ </c:map-property>
+ </c:list-property>
+ </results>
+ </operation>
<operation name="addNodeMaintenance">
<parameters>
10 years, 10 months
[rhq] modules/plugins
by mazz
modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptDiscoveryComponent.java | 10 ++++++++--
modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptServerComponent.java | 8 ++++++--
2 files changed, 14 insertions(+), 4 deletions(-)
New commits:
commit 49fe82e497cd3fb258fa29aca8bfebe7c480b14e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jul 1 13:38:52 2013 -0400
BZ 848258 - trim empty space/newlines from script output prior to applying any regex filters.
diff --git a/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptDiscoveryComponent.java b/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptDiscoveryComponent.java
index 8cbd84e..c685efe 100644
--- a/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptDiscoveryComponent.java
+++ b/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptDiscoveryComponent.java
@@ -31,11 +31,11 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ManualAddFacet;
import org.rhq.core.pluginapi.inventory.ProcessScanResult;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-import org.rhq.core.pluginapi.inventory.ManualAddFacet;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.system.ProcessExecutionResults;
import org.rhq.core.util.exception.ThrowableUtil;
@@ -125,6 +125,9 @@ public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent, Man
} else if (results.getCapturedOutput() != null) {
String regex = pluginConfig.getSimpleValue(ScriptServerComponent.PLUGINCONFIG_DESC_REGEX, null);
String output = results.getCapturedOutput();
+ if (output != null) {
+ output = output.trim();
+ }
if (regex == null) {
description = output;
} else {
@@ -176,6 +179,9 @@ public class ScriptDiscoveryComponent implements ResourceDiscoveryComponent, Man
String regex = pluginConfig.getSimpleValue(ScriptServerComponent.PLUGINCONFIG_VERSION_REGEX,
null);
String output = results.getCapturedOutput();
+ if (output != null) {
+ output = output.trim();
+ }
if (regex == null) {
version = output;
} else {
diff --git a/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptServerComponent.java b/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptServerComponent.java
index 0ff12b0..c964c69 100644
--- a/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptServerComponent.java
+++ b/modules/plugins/script/src/main/java/org/rhq/plugins/script/ScriptServerComponent.java
@@ -184,11 +184,13 @@ public class ScriptServerComponent implements ResourceComponent, MeasurementFace
continue;
}
} else if (regex != null) {
- final String output = exeResults.getCapturedOutput();
+ String output = exeResults.getCapturedOutput();
if (output == null) {
log.error("Could not get output for metric property [" + metricPropertyName
+ "] -- metric will not be collected");
continue;
+ } else {
+ output = output.trim();
}
Pattern pattern = Pattern.compile(regex);
@@ -336,7 +338,7 @@ public class ScriptServerComponent implements ResourceComponent, MeasurementFace
resultsConfig.put(new PropertySimple(OPERATION_RESULT_EXITCODE, exitcode));
}
if (output != null) {
- resultsConfig.put(new PropertySimple(OPERATION_RESULT_OUTPUT, output));
+ resultsConfig.put(new PropertySimple(OPERATION_RESULT_OUTPUT, output.trim()));
}
return result;
@@ -498,6 +500,8 @@ public class ScriptServerComponent implements ResourceComponent, MeasurementFace
String output = results.getCapturedOutput();
if (output == null) {
output = "";
+ } else {
+ output = output.trim();
}
boolean outputMatches = output.matches(availOutputRegex);
10 years, 10 months
[rhq] modules/core
by mazz
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
New commits:
commit 6ee04e067165819b7bcfbc9b8a3e4a7b168b8a7c
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jul 1 12:10:14 2013 -0400
BZ 860815 - consider version strings of "" and null as equal
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 5b0e550..704a230 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
@@ -2760,7 +2760,8 @@ public class InventoryManager extends AgentService implements ContainerService,
private void updateResourceVersion(Resource resource, String version) {
String existingVersion = resource.getVersion();
- boolean versionChanged = (existingVersion != null) ? !existingVersion.equals(version) : version != null;
+ boolean versionChanged = (existingVersion != null) ? !existingVersion.equals(version) : version != null
+ && !version.isEmpty();
if (versionChanged) {
if (log.isDebugEnabled()) {
log.debug("Discovery reported that version of [" + resource + "] changed from [" + existingVersion
10 years, 10 months