Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 574577 Details for
Bug 808231
[plugin-container] NullPointerExceptions (NPE's) occur during PC shutdown, because the PC does not wait for ExecutorServices that have been shut down to terminate
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
a patch that implements this enhancement
BZ-808231.patch (text/plain), 90.98 KB, created by
Ian Springer
on 2012-04-02 17:45:28 UTC
(
hide
)
Description:
a patch that implements this enhancement
Filename:
MIME Type:
Creator:
Ian Springer
Created:
2012-04-02 17:45:28 UTC
Size:
90.98 KB
patch
obsolete
>diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/ContainerService.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/ContainerService.java >index 20f84f3..839fe33 100644 >--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/ContainerService.java >+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/ContainerService.java >@@ -43,6 +43,13 @@ public interface ContainerService { > void shutdown(); > > /** >+ * Returns the current state of this service. >+ * >+ * @return the current state of this service >+ */ >+ ContainerServiceState getState(); >+ >+ /** > * Informs the container service how it should be configured by providing the full plugin container configuration. > * The plugin container will ensure it passes in a non-<code>null</code> configuration object so implementations of > * this interface should never have to worry about a <code>null</code> <code>configuration</code> parameter value. >@@ -50,4 +57,5 @@ public interface ContainerService { > * @param configuration > */ > void setConfiguration(PluginContainerConfiguration configuration); >+ > } >\ No newline at end of file >diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java >index 7967be5..2ae87ca 100644 >--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java >+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java >@@ -1,6 +1,6 @@ > /* > * RHQ Management Platform >- * Copyright (C) 2005-2008 Red Hat, Inc. >+ * Copyright (C) 2005-2012 Red Hat, Inc. > * All rights reserved. > * > * This program is free software; you can redistribute it and/or modify >@@ -79,6 +79,7 @@ import org.rhq.core.pluginapi.util.FileUtils; > * @author Greg Hinkle > */ > public class PluginContainer implements ContainerService { >+ > private static final PluginContainer INSTANCE = new PluginContainer(); > > private final Log log = LogFactory.getLog(PluginContainer.class); >@@ -116,7 +117,7 @@ public class PluginContainer implements ContainerService { > > private PluginContainerConfiguration configuration; > private String version; >- private boolean started = false; >+ private ContainerServiceState state = ContainerServiceState.SHUT_DOWN; > > private PluginManager pluginManager; > private PluginComponentFactory pluginComponentFactory; >@@ -243,7 +244,7 @@ public class PluginContainer implements ContainerService { > public boolean isStarted() { > Lock lock = obtainReadLock(); > try { >- return started; >+ return (state == ContainerServiceState.INITIALIZED); > } finally { > releaseLock(lock); > } >@@ -261,7 +262,8 @@ public class PluginContainer implements ContainerService { > public void initialize() { > Lock lock = obtainWriteLock(); > try { >- if (!started) { >+ if (state == ContainerServiceState.SHUT_DOWN) { >+ state = ContainerServiceState.INITIALIZING; > version = PluginContainer.class.getPackage().getImplementationVersion(); > log.info("Initializing Plugin Container" + ((version != null) ? (" v" + version) : "") + "..."); > >@@ -304,7 +306,7 @@ public class PluginContainer implements ContainerService { > startContainerService(bundleManager); > startContainerService(driftManager); > >- started = true; >+ state = ContainerServiceState.INITIALIZED; > > log.info("Plugin Container initialized."); > } >@@ -313,7 +315,7 @@ public class PluginContainer implements ContainerService { > } > > synchronized (initListenersLock) { >- if (started) { >+ if (state == ContainerServiceState.INITIALIZED) { > for (InitializationListener listener : initListeners.values()) { > listener.initialized(); > } >@@ -330,8 +332,8 @@ public class PluginContainer implements ContainerService { > public void shutdown() { > Lock lock = obtainWriteLock(); > try { >- if (started) { >- >+ if (state == ContainerServiceState.INITIALIZED) { >+ state = ContainerServiceState.SHUTTING_DOWN; > log.info("Plugin container is being shutdown..."); > > if (mbean != null) { >@@ -378,7 +380,7 @@ public class PluginContainer implements ContainerService { > > configuration = null; > >- started = false; >+ state = ContainerServiceState.SHUT_DOWN; > > log.info("Plugin container is now shutdown."); > >@@ -392,7 +394,7 @@ public class PluginContainer implements ContainerService { > } > > synchronized (shutdownListenersLock) { >- if (!started) { >+ if (state == ContainerServiceState.SHUT_DOWN) { > for (ShutdownListener listener : shutdownListeners.values()) { > listener.shutdown(); > } >@@ -402,6 +404,10 @@ public class PluginContainer implements ContainerService { > return; > } > >+ public ContainerServiceState getState() { >+ return state; >+ } >+ > /** > * Does things that help the garbage collector clean up the memory. > * Only call this after the plugin container has been shutdown. >@@ -672,7 +678,7 @@ public class PluginContainer implements ContainerService { > synchronized (initListenersLock) { > initListeners.put(name, listener); > >- if (started) { >+ if (state == ContainerServiceState.INITIALIZED) { > listener.initialized(); > } > } >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 561e4a1..89048d0 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 >@@ -56,10 +56,9 @@ import org.rhq.core.domain.bundle.ResourceTypeBundleConfiguration.BundleDestinat > import org.rhq.core.domain.content.PackageVersion; > import org.rhq.core.domain.resource.Resource; > import org.rhq.core.domain.resource.ResourceType; >+import org.rhq.core.pc.AgentContainerService; > import org.rhq.core.pc.ContainerService; > import org.rhq.core.pc.PluginContainer; >-import org.rhq.core.pc.PluginContainerConfiguration; >-import org.rhq.core.pc.agent.AgentService; > import org.rhq.core.pc.inventory.InventoryManager; > import org.rhq.core.pc.inventory.ResourceContainer; > import org.rhq.core.pc.measurement.MeasurementManager; >@@ -82,7 +81,8 @@ import org.rhq.core.util.file.FileUtil; > * > * @author John Mazzitelli > */ >-public class BundleManager extends AgentService implements BundleAgentService, BundleManagerProvider, ContainerService { >+public class BundleManager extends AgentContainerService implements BundleAgentService, BundleManagerProvider { >+ > private final Log log = LogFactory.getLog(BundleManager.class); > > private final String AUDIT_DEPLOYMENT_ENDED = "Deployment Ended"; >@@ -94,22 +94,17 @@ public class BundleManager extends AgentService implements BundleAgentService, B > private final String AUDIT_PURGE_STARTED = "Purge Started"; > private final String AUDIT_PURGE_ENDED = "Purge Ended"; > >- private PluginContainerConfiguration configuration; > private ExecutorService deployerThreadPool; > > public BundleManager() { > super(BundleAgentService.class); > } > >- public void setConfiguration(PluginContainerConfiguration configuration) { >- this.configuration = configuration; >- } >- >- public void initialize() { >+ protected void initializeInternal() { > createDeployerThreadPool(); > } > >- public void shutdown() { >+ protected void shutdownInternal() { > shutdownDeployerThreadPool(); > } > >@@ -558,8 +553,8 @@ public class BundleManager extends AgentService implements BundleAgentService, B > * @return the server-side proxy; <code>null</code> if this manager doesn't have a server to talk to > */ > private BundleServerService getBundleServerService() { >- if (configuration.getServerServices() != null) { >- return configuration.getServerServices().getBundleServerService(); >+ if (getConfiguration().getServerServices() != null) { >+ return getConfiguration().getServerServices().getBundleServerService(); > } > > throw new IllegalStateException("There is no bundle server service available to obtain bundle files"); >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 b237969..334eb87 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 >@@ -43,10 +43,8 @@ import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.Property; > import org.rhq.core.domain.configuration.RawConfiguration; > import org.rhq.core.domain.resource.ResourceType; >-import org.rhq.core.pc.ContainerService; >+import org.rhq.core.pc.AgentContainerService; > import org.rhq.core.pc.PluginContainer; >-import org.rhq.core.pc.PluginContainerConfiguration; >-import org.rhq.core.pc.agent.AgentService; > import org.rhq.core.pc.util.ComponentService; > import org.rhq.core.pc.util.ComponentUtil; > import org.rhq.core.pc.util.FacetLockType; >@@ -62,14 +60,14 @@ import org.rhq.core.util.MessageDigestGenerator; > * > * @author Jason Dobies > */ >-public class ConfigurationManager extends AgentService implements ContainerService, ConfigurationAgentService { >+public class ConfigurationManager extends AgentContainerService implements ConfigurationAgentService { >+ > private final Log log = LogFactory.getLog(ConfigurationManager.class); > > private static final String SENDER_THREAD_POOL_NAME = "ConfigurationManager.threadpool"; > > private static final int FACET_METHOD_TIMEOUT = 60 * 1000; // 60 seconds > >- private PluginContainerConfiguration pluginContainerConfiguration; > private ScheduledExecutorService threadPool; > > private ComponentService componentService; >@@ -80,29 +78,25 @@ public class ConfigurationManager extends AgentService implements ContainerServi > super(ConfigurationAgentService.class); > } > >- public void initialize() { >+ protected void initializeInternal() { > LoggingThreadFactory threadFactory = new LoggingThreadFactory(SENDER_THREAD_POOL_NAME, true); > threadPool = new ScheduledThreadPoolExecutor(1, threadFactory); > > ConfigurationCheckExecutor configurationChecker = new ConfigurationCheckExecutor(this, > getConfigurationServerService(), PluginContainer.getInstance().getInventoryManager()); > >- if (pluginContainerConfiguration.getConfigurationDiscoveryPeriod() > 0 >- && pluginContainerConfiguration.isInsideAgent()) { >- threadPool.scheduleAtFixedRate(configurationChecker, pluginContainerConfiguration >- .getConfigurationDiscoveryInitialDelay(), pluginContainerConfiguration >+ if (getConfiguration().getConfigurationDiscoveryPeriod() > 0 >+ && getConfiguration().isInsideAgent()) { >+ threadPool.scheduleAtFixedRate(configurationChecker, getConfiguration() >+ .getConfigurationDiscoveryInitialDelay(), getConfiguration() > .getConfigurationDiscoveryPeriod(), TimeUnit.SECONDS); > } > } > >- public void shutdown() { >+ protected void shutdownInternal() { > threadPool.shutdown(); > } > >- public void setConfiguration(PluginContainerConfiguration configuration) { >- pluginContainerConfiguration = configuration; >- } >- > public void setComponentService(ComponentService componentService) { > this.componentService = componentService; > } >@@ -236,15 +230,13 @@ public class ConfigurationManager extends AgentService implements ContainerServi > } > > private void updateRawConfig(Configuration configuration, RawConfiguration originalRaw, RawConfiguration mergedRaw) { >- > configuration.removeRawConfiguration(originalRaw); > configuration.addRawConfiguration(mergedRaw); > } > > public Configuration loadResourceConfiguration(int resourceId) throws PluginContainerException { >- > ConfigManagement loadConfig = configMgmtFactory.getStrategy(resourceId); >- Configuration configuration = null; >+ Configuration configuration; > > try { > configuration = loadConfig.executeLoad(resourceId); >@@ -322,8 +314,8 @@ public class ConfigurationManager extends AgentService implements ContainerServi > * @return the server-side proxy; <code>null</code> if this manager doesn't have a server to talk to > */ > protected ConfigurationServerService getConfigurationServerService() { >- if (pluginContainerConfiguration.getServerServices() != null) { >- return pluginContainerConfiguration.getServerServices().getConfigurationServerService(); >+ if (getConfiguration().getServerServices() != null) { >+ return getConfiguration().getServerServices().getConfigurationServerService(); > } > > return null; >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 5fdcb4e..aeb1e7a 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 >@@ -58,11 +58,9 @@ import org.rhq.core.domain.resource.Resource; > import org.rhq.core.domain.resource.ResourceType; > import org.rhq.core.domain.util.PageControl; > import org.rhq.core.domain.util.PageList; >-import org.rhq.core.pc.ContainerService; >+import org.rhq.core.pc.AgentContainerService; > import org.rhq.core.pc.PluginContainer; >-import org.rhq.core.pc.PluginContainerConfiguration; > import org.rhq.core.pc.ServerServices; >-import org.rhq.core.pc.agent.AgentService; > import org.rhq.core.pc.inventory.InventoryEventListener; > import org.rhq.core.pc.inventory.InventoryManager; > import org.rhq.core.pc.inventory.ResourceContainer; >@@ -73,17 +71,12 @@ import org.rhq.core.pluginapi.content.ContentContext; > import org.rhq.core.pluginapi.content.ContentFacet; > import org.rhq.core.pluginapi.content.ContentServices; > >-public class ContentManager extends AgentService implements ContainerService, ContentAgentService, ContentServices { >+public class ContentManager extends AgentContainerService implements ContentAgentService, ContentServices { > > private static final int FACET_METHOD_TIMEOUT = 60 * 60 * 1000; // 60 minutes > private final Log log = LogFactory.getLog(ContentManager.class); > > /** >- * Configuration elements for the running of this manager. >- */ >- private PluginContainerConfiguration configuration; >- >- /** > * Flag indicating whether or not this instance of the manager should run automatic, scheduled discoveries. > */ > private boolean scheduledDiscoveriesEnabled; >@@ -112,14 +105,14 @@ public class ContentManager extends AgentService implements ContainerService, Co > super(ContentAgentService.class); > } > >- public void initialize() { >+ protected void initializeInternal() { > log.info("Initializing Content Manager..."); > > // Determine discovery mode - we only enable discovery if we are inside the agent and the period is positive non-zero >- this.scheduledDiscoveriesEnabled = (configuration.getContentDiscoveryPeriod() > 0); >+ this.scheduledDiscoveriesEnabled = (getConfiguration().getContentDiscoveryPeriod() > 0); > > // Create thread pool executor. Used in both scheduled and non-scheduled mode for all discoveries. >- int threadPoolSize = configuration.getContentDiscoveryThreadPoolSize(); >+ int threadPoolSize = getConfiguration().getContentDiscoveryThreadPoolSize(); > > discoveryThreadPoolExecutor = new ScheduledThreadPoolExecutor(threadPoolSize, new LoggingThreadFactory( > "Content.discovery", true)); >@@ -139,8 +132,8 @@ public class ContentManager extends AgentService implements ContainerService, Co > ContentDiscoveryRunner runner = new ContentDiscoveryRunner(this); > > // Begin the automatic discovery thread >- long initialDelay = configuration.getContentDiscoveryInitialDelay(); >- long discoveryPeriod = configuration.getContentDiscoveryPeriod(); >+ long initialDelay = getConfiguration().getContentDiscoveryInitialDelay(); >+ long discoveryPeriod = getConfiguration().getContentDiscoveryPeriod(); > > discoveryThreadPoolExecutor.scheduleAtFixedRate(runner, initialDelay, discoveryPeriod, TimeUnit.SECONDS); > >@@ -157,17 +150,13 @@ public class ContentManager extends AgentService implements ContainerService, Co > log.info("Content Manager initialized..."); > } > >- public void shutdown() { >+ protected void shutdownInternal() { > log.info("Shutting down Content Manager..."); > discoveryThreadPoolExecutor.shutdown(); > crudExecutor.shutdown(); > PluginContainer.getInstance().getInventoryManager().removeInventoryEventListener(inventoryEventListener); > } > >- public void setConfiguration(PluginContainerConfiguration configuration) { >- this.configuration = configuration; >- } >- > public Set<ResourcePackageDetails> getLastDiscoveredResourcePackages(int resourceId) { > // Get the resource component > InventoryManager inventoryManager = PluginContainer.getInstance().getInventoryManager(); >@@ -488,7 +477,7 @@ public class ContentManager extends AgentService implements ContainerService, Co > */ > ContentServerService getContentServerService() { > ContentServerService serverService = null; >- ServerServices serverServices = configuration.getServerServices(); >+ ServerServices serverServices = getConfiguration().getServerServices(); > if (serverServices != null) { > serverService = serverServices.getContentServerService(); > } >diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java >index d398f4d..6bb11b9 100644 >--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java >+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java >@@ -19,8 +19,23 @@ > > package org.rhq.core.pc.drift; > >+import java.io.BufferedInputStream; >+import java.io.BufferedOutputStream; >+import java.io.File; >+import java.io.FileInputStream; >+import java.io.FileNotFoundException; >+import java.io.FileOutputStream; >+import java.io.FilenameFilter; >+import java.io.IOException; >+import java.util.List; >+import java.util.concurrent.ScheduledThreadPoolExecutor; >+import java.util.concurrent.TimeUnit; >+import java.util.zip.ZipEntry; >+import java.util.zip.ZipOutputStream; >+ > import org.apache.commons.logging.Log; > import org.apache.commons.logging.LogFactory; >+ > import org.rhq.common.drift.ChangeSetWriter; > import org.rhq.common.drift.Headers; > import org.rhq.core.clientapi.agent.drift.DriftAgentService; >@@ -31,34 +46,26 @@ import org.rhq.core.domain.drift.DriftDefinition; > import org.rhq.core.domain.drift.DriftFile; > import org.rhq.core.domain.drift.DriftSnapshot; > import org.rhq.core.domain.resource.Resource; >-import org.rhq.core.pc.ContainerService; >+import org.rhq.core.pc.AgentContainerService; > import org.rhq.core.pc.PluginContainer; > import org.rhq.core.pc.PluginContainerConfiguration; >-import org.rhq.core.pc.agent.AgentService; > import org.rhq.core.pc.inventory.InventoryManager; > import org.rhq.core.pc.inventory.ResourceContainer; > import org.rhq.core.pc.measurement.MeasurementManager; > import org.rhq.core.util.file.FileUtil; > import org.rhq.core.util.stream.StreamUtil; > >-import java.io.*; >-import java.util.List; >-import java.util.concurrent.ScheduledThreadPoolExecutor; >-import java.util.concurrent.TimeUnit; >-import java.util.zip.ZipEntry; >-import java.util.zip.ZipOutputStream; >- >-import static org.rhq.common.drift.FileEntry.*; >+import static org.rhq.common.drift.FileEntry.addedFileEntry; >+import static org.rhq.common.drift.FileEntry.changedFileEntry; >+import static org.rhq.common.drift.FileEntry.removedFileEntry; > import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE; > import static org.rhq.core.domain.drift.DriftChangeSetCategory.DRIFT; > import static org.rhq.core.domain.drift.DriftComplianceStatus.OUT_OF_COMPLIANCE_NO_BASEDIR; > >-public class DriftManager extends AgentService implements DriftAgentService, DriftClient, ContainerService { >+public class DriftManager extends AgentContainerService implements DriftAgentService, DriftClient { > > private final Log log = LogFactory.getLog(DriftManager.class); > >- private PluginContainerConfiguration pluginContainerConfiguration; >- > private File changeSetsDir; > > private ScheduledThreadPoolExecutor driftThreadPool; >@@ -75,8 +82,8 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri > > @Override > public void setConfiguration(PluginContainerConfiguration configuration) { >- pluginContainerConfiguration = configuration; >- changeSetsDir = new File(pluginContainerConfiguration.getDataDirectory(), "changesets"); >+ super.setConfiguration(configuration); >+ changeSetsDir = new File(configuration.getDataDirectory(), "changesets"); > } > > public boolean isInitialized() { >@@ -84,14 +91,17 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri > } > > @Override >- public void initialize() { >+ protected void initializeInternal() { > long initStartTime = System.currentTimeMillis(); >- boolean success = changeSetsDir.mkdir(); >- if (!success) { >- log.warn("Could not create change sets directory " + changeSetsDir); >- initialized = false; >- return; >+ if (!changeSetsDir.exists()) { >+ boolean success = changeSetsDir.mkdirs(); >+ if (!success) { >+ log.error("Could not create change sets directory " + changeSetsDir); >+ return; >+ } >+ log.debug("Created change sets directory " + changeSetsDir); > } >+ > changeSetMgr = new ChangeSetManagerImpl(changeSetsDir); > > DriftDetector driftDetector = new DriftDetector(); >@@ -113,8 +123,8 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri > > driftThreadPool = new ScheduledThreadPoolExecutor(5); > >- long initialDelay = pluginContainerConfiguration.getDriftDetectionInitialDelay(); >- long period = pluginContainerConfiguration.getDriftDetectionPeriod(); >+ long initialDelay = getConfiguration().getDriftDetectionInitialDelay(); >+ long period = getConfiguration().getDriftDetectionPeriod(); > if (period > 0) { > // note that drift detection is globally disabled if the detection period is 0 or less > driftThreadPool.scheduleAtFixedRate(driftDetector, initialDelay, period, TimeUnit.SECONDS); >@@ -122,7 +132,8 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri > log.info("Drift detection has been globally disabled as per plugin container configuration"); > } > >- initialized = true; >+ this.initialized = true; >+ > long initEndTime = System.currentTimeMillis(); > if (log.isInfoEnabled()) { > log.info("Finished initialization in " + (initEndTime - initStartTime) + " ms"); >@@ -164,7 +175,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri > if (!changeSetMgr.changeSetExists(resource.getId(), headers)) { > log.info("No snapshot found for " + toString(resource.getId(), driftDefinition) > + ". Downloading snapshot from server"); >- DriftServerService driftServer = pluginContainerConfiguration.getServerServices().getDriftServerService(); >+ DriftServerService driftServer = getConfiguration().getServerServices().getDriftServerService(); > > DriftSnapshot snapshot = driftServer.getCurrentSnapshot(driftDefinition.getId()); > >@@ -275,7 +286,9 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri > } > > @Override >- public void shutdown() { >+ protected void shutdownInternal() { >+ this.initialized = false; >+ > if (driftThreadPool != null) { > driftThreadPool.shutdown(); > driftThreadPool = null; >@@ -310,7 +323,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri > return; > } > >- DriftServerService driftServer = pluginContainerConfiguration.getServerServices().getDriftServerService(); >+ DriftServerService driftServer = getConfiguration().getServerServices().getDriftServerService(); > > String fileName = "changeset_" + System.currentTimeMillis() + ".zip"; > final File zipFile = new File(changeSetFile.getParentFile(), fileName); >@@ -352,7 +365,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri > int endIndex = contentZipFile.getName().indexOf("."); > String token = contentZipFile.getName().substring(startIndex, endIndex); > >- DriftServerService driftServer = pluginContainerConfiguration.getServerServices().getDriftServerService(); >+ DriftServerService driftServer = getConfiguration().getServerServices().getDriftServerService(); > driftServer.sendFilesZip(resourceId, driftDefName, token, contentZipFile.length(), > remoteInputStream(new BufferedInputStream(new FileInputStream(contentZipFile)))); > } catch (FileNotFoundException e) { >@@ -363,7 +376,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri > > @Override > public void repeatChangeSet(int resourceId, String driftDefName, int version) { >- DriftServerService driftServer = pluginContainerConfiguration.getServerServices().getDriftServerService(); >+ DriftServerService driftServer = getConfiguration().getServerServices().getDriftServerService(); > driftServer.repeatChangeSet(resourceId, driftDefName, version); > } > >@@ -555,7 +568,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Dri > if (log.isDebugEnabled()) { > log.debug("Reporting to server missing base directory for " + toString(resourceId, driftDefinition)); > } >- DriftServerService driftServer = pluginContainerConfiguration.getServerServices().getDriftServerService(); >+ DriftServerService driftServer = getConfiguration().getServerServices().getDriftServerService(); > driftServer.updateCompliance(resourceId, driftDefinition.getName(), OUT_OF_COMPLIANCE_NO_BASEDIR); > } > >diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/event/EventManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/event/EventManager.java >index 87b9bd7..646d735 100644 >--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/event/EventManager.java >+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/event/EventManager.java >@@ -40,19 +40,18 @@ import org.rhq.core.domain.event.EventDefinition; > import org.rhq.core.domain.event.EventSource; > import org.rhq.core.domain.event.transfer.EventReport; > import org.rhq.core.domain.resource.Resource; >-import org.rhq.core.pc.ContainerService; >-import org.rhq.core.pc.PluginContainerConfiguration; >+import org.rhq.core.pc.NonAgentContainerService; > import org.rhq.core.pc.util.LoggingThreadFactory; > import org.rhq.core.pluginapi.event.EventPoller; > import org.rhq.core.system.SigarAccess; >-import org.rhq.core.system.SystemInfoException; > > /** > * Manager for the Plugin Container's Event subsystem. > * > * @author Ian Springer > */ >-public class EventManager implements ContainerService { >+public class EventManager extends NonAgentContainerService { >+ > private final Log log = LogFactory.getLog(this.getClass()); > > private static final String SENDER_THREAD_POOL_NAME = "EventManager.sender"; >@@ -62,7 +61,6 @@ public class EventManager implements ContainerService { > private static final int POLLER_THREAD_POOL_CORE_SIZE = 3; > private static final int POLLER_INITIAL_DELAY_SECS = 0; > >- private PluginContainerConfiguration pcConfig; > private ScheduledThreadPoolExecutor senderThreadPool; > private EventReport activeReport; > private ReentrantReadWriteLock reportLock = new ReentrantReadWriteLock(true); >@@ -70,16 +68,20 @@ public class EventManager implements ContainerService { > private Map<PollerKey, Runnable> pollerThreads; > private SigarProxy sigar; > >- public void initialize() { >- this.activeReport = new EventReport(this.pcConfig.getEventReportMaxPerSource(), this.pcConfig >+ public EventManager() { >+ return; >+ } >+ >+ protected void initializeInternal() { >+ this.activeReport = new EventReport(getConfiguration().getEventReportMaxPerSource(), getConfiguration() > .getEventReportMaxTotal()); > > // Schedule sender thread(s) to send Event reports to the Server periodically. > EventSenderRunner senderRunner = new EventSenderRunner(this); > this.senderThreadPool = new ScheduledThreadPoolExecutor(SENDER_THREAD_POOL_CORE_SIZE, new LoggingThreadFactory( > SENDER_THREAD_POOL_NAME, true)); >- this.senderThreadPool.scheduleAtFixedRate(senderRunner, this.pcConfig.getEventSenderInitialDelay(), >- this.pcConfig.getEventSenderPeriod(), TimeUnit.SECONDS); >+ this.senderThreadPool.scheduleAtFixedRate(senderRunner, getConfiguration().getEventSenderInitialDelay(), >+ getConfiguration().getEventSenderPeriod(), TimeUnit.SECONDS); > > // Set up a thread pool for polling threads. Polling threads will be added to the pool via calls to > // registerEventPoller(). >@@ -88,7 +90,7 @@ public class EventManager implements ContainerService { > this.pollerThreads = new HashMap<PollerKey, Runnable>(); > } > >- public void shutdown() { >+ protected void shutdownInternal() { > if (this.senderThreadPool != null) { > this.senderThreadPool.shutdownNow(); > } >@@ -97,10 +99,6 @@ public class EventManager implements ContainerService { > } > } > >- public void setConfiguration(PluginContainerConfiguration config) { >- this.pcConfig = config; >- } >- > void publishEvents(@NotNull Set<Event> events, @NotNull Resource resource) { > this.reportLock.readLock().lock(); > try { >@@ -140,9 +138,9 @@ public class EventManager implements ContainerService { > } > log.warn("Finish dropped events report"); > } >- if (!report.getEvents().isEmpty() && this.pcConfig.getServerServices() != null) { >+ if (!report.getEvents().isEmpty() && getConfiguration().getServerServices() != null) { > try { >- this.pcConfig.getServerServices().getEventServerService().mergeEventReport(report); >+ getConfiguration().getServerServices().getEventServerService().mergeEventReport(report); > } catch (Exception e) { > log.warn("Failure to report Events to Server.", e); > } >@@ -153,7 +151,7 @@ public class EventManager implements ContainerService { > this.reportLock.writeLock().lock(); > try { > EventReport previousReport = this.activeReport; >- this.activeReport = new EventReport(this.pcConfig.getEventReportMaxPerSource(), this.pcConfig >+ this.activeReport = new EventReport(getConfiguration().getEventReportMaxPerSource(), getConfiguration() > .getEventReportMaxTotal()); > return previousReport; > } finally { >diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AutoDiscoveryExecutor.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AutoDiscoveryExecutor.java >index 67094b5..ec84f73 100644 >--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AutoDiscoveryExecutor.java >+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/AutoDiscoveryExecutor.java >@@ -45,6 +45,7 @@ import org.rhq.core.domain.resource.Resource; > import org.rhq.core.domain.resource.ResourceCategory; > import org.rhq.core.domain.resource.ResourceType; > import org.rhq.core.domain.state.discovery.AutoDiscoveryScanType; >+import org.rhq.core.pc.ContainerServiceState; > import org.rhq.core.pc.PluginContainer; > import org.rhq.core.pc.PluginContainerConfiguration; > import org.rhq.core.pc.plugin.PluginComponentFactory; >@@ -69,6 +70,7 @@ import org.rhq.core.util.exception.Severity; > * @author Ian Springer > */ > public class AutoDiscoveryExecutor implements Runnable, Callable<InventoryReport> { >+ > private Log log = LogFactory.getLog(AutoDiscoveryExecutor.class); > > private AutoDiscoveryRequest autoDiscoveryRequest; >@@ -125,8 +127,10 @@ public class AutoDiscoveryExecutor implements Runnable, Callable<InventoryReport > > inventoryManager.handleReport(report); > } catch (Exception e) { >- log.warn("Exception caught while executing server discovery scan.", e); >- report.addError(new ExceptionPackage(Severity.Warning, e)); >+ if (inventoryManager.getState() == ContainerServiceState.INITIALIZED) { >+ log.warn("Exception caught while executing server discovery scan.", e); >+ report.addError(new ExceptionPackage(Severity.Warning, e)); >+ } > } > > return report; >@@ -165,6 +169,10 @@ public class AutoDiscoveryExecutor implements Runnable, Callable<InventoryReport > Resource platformResource = platformContainer.getResource(); > > for (ResourceType serverType : serverTypes) { >+ if (inventoryManager.getState() != ContainerServiceState.INITIALIZED) { >+ break; >+ } >+ > if (!serverType.getParentResourceTypes().isEmpty()) { > continue; // TODO GH: Need to stop discovering embedded tomcats here and other non-top level servers > } >@@ -202,8 +210,10 @@ public class AutoDiscoveryExecutor implements Runnable, Callable<InventoryReport > } > } > } catch (Throwable e) { >- report.getErrors().add(new ExceptionPackage(Severity.Severe, e)); >- log.error("Error in auto discovery", e); >+ if (inventoryManager.getState() == ContainerServiceState.INITIALIZED) { >+ report.getErrors().add(new ExceptionPackage(Severity.Severe, e)); >+ log.error("An error occurred during server discovery.", e); >+ } > } > } > >@@ -265,4 +275,5 @@ public class AutoDiscoveryExecutor implements Runnable, Callable<InventoryReport > // can we use: parentResourceComponent.getClass().isAssignableFrom( type.getGenericDeclaration().getClass() ) > return true; > } >+ > } >\ No newline at end of file >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 078d7ef..78a01c7 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 >@@ -78,12 +78,12 @@ import org.rhq.core.domain.resource.ResourceError; > import org.rhq.core.domain.resource.ResourceErrorType; > import org.rhq.core.domain.resource.ResourceType; > import org.rhq.core.domain.resource.ResourceUpgradeReport; >+import org.rhq.core.pc.AgentContainerService; > import org.rhq.core.pc.ContainerService; >+import org.rhq.core.pc.ContainerServiceState; > import org.rhq.core.pc.PluginContainer; >-import org.rhq.core.pc.PluginContainerConfiguration; > import org.rhq.core.pc.ServerServices; > 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.content.ContentContextImpl; >@@ -134,7 +134,8 @@ import org.rhq.core.util.exception.WrappedRemotingException; > * @author Jay Shaughnessy > */ > @SuppressWarnings({ "rawtypes", "unchecked" }) >-public class InventoryManager extends AgentService implements ContainerService, DiscoveryAgentService { >+public class InventoryManager extends AgentContainerService implements DiscoveryAgentService { >+ > private static final String INVENTORY_THREAD_POOL_NAME = "InventoryManager.discovery"; > private static final String AVAIL_THREAD_POOL_NAME = "InventoryManager.availability"; > private static final int AVAIL_THREAD_POOL_CORE_POOL_SIZE = 1; >@@ -144,8 +145,6 @@ public class InventoryManager extends AgentService implements ContainerService, > > private final Log log = LogFactory.getLog(InventoryManager.class); > >- private PluginContainerConfiguration configuration; >- > private ScheduledThreadPoolExecutor inventoryThreadPoolExecutor; > private ScheduledThreadPoolExecutor availabilityThreadPoolExecutor; > >@@ -206,7 +205,7 @@ public class InventoryManager extends AgentService implements ContainerService, > /** > * @see ContainerService#initialize() > */ >- public void initialize() { >+ protected void initializeInternal() { > inventoryLock.writeLock().lock(); > > try { >@@ -215,14 +214,14 @@ public class InventoryManager extends AgentService implements ContainerService, > this.discoveryComponentProxyFactory = new DiscoveryComponentProxyFactory(); > this.discoveryComponentProxyFactory.initialize(); > >- this.agent = new Agent(this.configuration.getContainerName(), null, 0, null, null); >+ this.agent = new Agent(getConfiguration().getContainerName(), null, 0, null, null); > > //make sure the avail collectors are available before we instantiate any > //resource context - either from disk or from anywhere else. > availabilityCollectors = new AvailabilityCollectorThreadPool(); > availabilityCollectors.initialize(); > >- if (configuration.isInsideAgent()) { >+ if (getConfiguration().isInsideAgent()) { > loadFromDisk(); > } > >@@ -242,25 +241,25 @@ public class InventoryManager extends AgentService implements ContainerService, > // Never run more than one discovery scan at a time (service and service scans share the same pool). > inventoryThreadPoolExecutor = new ScheduledThreadPoolExecutor(1, new LoggingThreadFactory( > INVENTORY_THREAD_POOL_NAME, true)); >- serverScanExecutor = new AutoDiscoveryExecutor(null, this, configuration); >- serviceScanExecutor = new RuntimeDiscoveryExecutor(this, configuration); >+ serverScanExecutor = new AutoDiscoveryExecutor(null, this, getConfiguration()); >+ serviceScanExecutor = new RuntimeDiscoveryExecutor(this, getConfiguration()); > > // Only schedule periodic discovery scans and avail checks if we are running inside the RHQ Agent (versus > // inside EmbJopr). >- if (configuration.isInsideAgent()) { >+ if (getConfiguration().isInsideAgent()) { > // After an initial delay (5s by default), periodically run an availability check (every 1m by default). > availabilityThreadPoolExecutor.scheduleWithFixedDelay(availabilityExecutor, >- configuration.getAvailabilityScanInitialDelay(), configuration.getAvailabilityScanPeriod(), >+ getConfiguration().getAvailabilityScanInitialDelay(), getConfiguration().getAvailabilityScanPeriod(), > TimeUnit.SECONDS); > > // After an initial delay (10s by default), periodically run a server discovery scan (every 15m by default). > inventoryThreadPoolExecutor.scheduleWithFixedDelay(serverScanExecutor, >- configuration.getServerDiscoveryInitialDelay(), configuration.getServerDiscoveryPeriod(), >+ getConfiguration().getServerDiscoveryInitialDelay(), getConfiguration().getServerDiscoveryPeriod(), > TimeUnit.SECONDS); > > // After an initial delay (20s by default), periodically run a service discovery scan (every 1d by default). > inventoryThreadPoolExecutor.scheduleWithFixedDelay(serviceScanExecutor, >- configuration.getServiceDiscoveryInitialDelay(), configuration.getServiceDiscoveryPeriod(), >+ getConfiguration().getServiceDiscoveryInitialDelay(), getConfiguration().getServiceDiscoveryPeriod(), > TimeUnit.SECONDS); > } > } finally { >@@ -270,13 +269,10 @@ public class InventoryManager extends AgentService implements ContainerService, > log.info("Inventory Manager initialized."); > } > >- /** >- * @see ContainerService#shutdown() >- */ >- public void shutdown() { >+ protected void shutdownInternal() { > this.inventoryThreadPoolExecutor.shutdownNow(); > this.availabilityThreadPoolExecutor.shutdownNow(); >- if (this.configuration.isInsideAgent()) { >+ if (getConfiguration().isInsideAgent()) { > this.persistToDisk(); > } > this.discoveryComponentProxyFactory.shutdown(); >@@ -395,7 +391,7 @@ public class InventoryManager extends AgentService implements ContainerService, > > ResourceDiscoveryContext discoveryContext = new ResourceDiscoveryContext(resourceType, parentComponent, > parentResourceContext, SystemInfoFactory.createSystemInfo(), null, null, >- this.configuration.getContainerName(), this.configuration.getPluginContainerDeployment()); >+ getConfiguration().getContainerName(), getConfiguration().getPluginContainerDeployment()); > > // Configurations are not immutable, so clone the plugin config, so the plugin will not be able to change the > // actual PC-managed plugin config. >@@ -514,10 +510,6 @@ public class InventoryManager extends AgentService implements ContainerService, > } > } > >- public void setConfiguration(PluginContainerConfiguration configuration) { >- this.configuration = configuration; >- } >- > public void updatePluginConfiguration(int resourceId, Configuration newPluginConfiguration) > throws InvalidPluginConfigurationClientException, PluginContainerException { > ResourceContainer container = getResourceContainer(resourceId); >@@ -705,8 +697,8 @@ public class InventoryManager extends AgentService implements ContainerService, > ResourceDiscoveryContext<ResourceComponent<?>> discoveryContext = new ResourceDiscoveryContext<ResourceComponent<?>>( > resourceType, parentResourceComponent, parentResourceContainer.getResourceContext(), > SystemInfoFactory.createSystemInfo(), new ArrayList<ProcessScanResult>(0), >- new ArrayList<Configuration>(0), this.configuration.getContainerName(), >- this.configuration.getPluginContainerDeployment()); >+ new ArrayList<Configuration>(0), getConfiguration().getContainerName(), >+ getConfiguration().getPluginContainerDeployment()); > > // Ask the plugin's discovery component to find the new resource, throwing exceptions if it cannot be > // found at all. >@@ -732,7 +724,7 @@ public class InventoryManager extends AgentService implements ContainerService, > ResourceDiscoveryContext<ResourceComponent<?>> discoveryContext = new ResourceDiscoveryContext<ResourceComponent<?>>( > resourceType, parentResourceComponent, parentResourceContainer.getResourceContext(), > SystemInfoFactory.createSystemInfo(), new ArrayList<ProcessScanResult>(0), pluginConfigurations, >- this.configuration.getContainerName(), this.configuration.getPluginContainerDeployment()); >+ getConfiguration().getContainerName(), getConfiguration().getPluginContainerDeployment()); > > // Ask the plugin's discovery component to find the new resource, throwing exceptions if it cannot be > // found at all. >@@ -811,7 +803,7 @@ public class InventoryManager extends AgentService implements ContainerService, > // NOTE: We don't mess with inventory status - that's the server's responsibility. > > // Tell the server to merge the resource into its inventory. >- DiscoveryServerService discoveryServerService = this.configuration.getServerServices() >+ DiscoveryServerService discoveryServerService = getConfiguration().getServerServices() > .getDiscoveryServerService(); > mergeResourceResponse = discoveryServerService.addResource(resource, ownerSubjectId); > >@@ -930,6 +922,10 @@ public class InventoryManager extends AgentService implements ContainerService, > } > > public void handleReport(AvailabilityReport report) { >+ if (getState() != ContainerServiceState.INITIALIZED) { >+ return; >+ } >+ > // a null report means a non-committed inventory - we are either brand new or our platform was deleted recently > if (report == null) { > if ((this.platform != null) && (this.platform.getInventoryStatus() == InventoryStatus.NEW) >@@ -945,7 +941,7 @@ public class InventoryManager extends AgentService implements ContainerService, > > List<AvailabilityReport.Datum> reportAvails = report.getResourceAvailability(); > >- if (configuration.isInsideAgent() && reportAvails.size() > 0) { >+ if (getConfiguration().isInsideAgent() && reportAvails.size() > 0) { > // Due to the asynchronous nature of the availability collection, > // it is possible we may have collected availability of a resource that has just recently been deleted; > // therefore, as a secondary check, let's remove any availabilities for resources that no longer exist. >@@ -978,7 +974,7 @@ public class InventoryManager extends AgentService implements ContainerService, > log.debug("Availability report content: " + report.toString(log.isTraceEnabled())); > } > >- boolean ok = configuration.getServerServices().getDiscoveryServerService() >+ boolean ok = getConfiguration().getServerServices().getDiscoveryServerService() > .mergeAvailabilityReport(report); > if (!ok) { > // I guess I could immediately call executeAvailabilityScanImmediately and pass its results to >@@ -1008,7 +1004,11 @@ public class InventoryManager extends AgentService implements ContainerService, > * @return true if sending the report to the Server succeeded, or false otherwise > */ > public boolean handleReport(InventoryReport report) { >- if (!configuration.isInsideAgent()) { >+ if (getState() != ContainerServiceState.INITIALIZED) { >+ return false; >+ } >+ >+ if (!getConfiguration().isInsideAgent()) { > return true; > } > >@@ -1017,7 +1017,7 @@ public class InventoryManager extends AgentService implements ContainerService, > String reportType = (report.isRuntimeReport()) ? "runtime" : "server"; > log.info("Sending [" + reportType + "] inventory report to Server..."); > long startTime = System.currentTimeMillis(); >- DiscoveryServerService discoveryServerService = configuration.getServerServices() >+ DiscoveryServerService discoveryServerService = getConfiguration().getServerServices() > .getDiscoveryServerService(); > syncInfo = discoveryServerService.mergeInventoryReport(report); > if (log.isDebugEnabled()) { >@@ -1163,7 +1163,7 @@ public class InventoryManager extends AgentService implements ContainerService, > return; > } > Resource resource = resourceContainer.getResource(); >- RuntimeDiscoveryExecutor oneTimeExecutor = new RuntimeDiscoveryExecutor(this, configuration, resource); >+ RuntimeDiscoveryExecutor oneTimeExecutor = new RuntimeDiscoveryExecutor(this, getConfiguration(), resource); > > try { > inventoryThreadPoolExecutor.submit((Callable<InventoryReport>) oneTimeExecutor).get(); >@@ -1303,7 +1303,7 @@ public class InventoryManager extends AgentService implements ContainerService, > public void mergeResourcesFromUpgrade(Set<ResourceUpgradeRequest> upgradeRequests) throws Exception { > Set<ResourceUpgradeResponse> serverUpdates = null; > try { >- ServerServices serverServices = this.configuration.getServerServices(); >+ ServerServices serverServices = getConfiguration().getServerServices(); > if (serverServices != null) { > DiscoveryServerService discoveryServerService = serverServices.getDiscoveryServerService(); > >@@ -1367,7 +1367,7 @@ public class InventoryManager extends AgentService implements ContainerService, > } > > // Auto-generate id and auto-commit if embedded within JBossAS. >- if (!this.configuration.isInsideAgent()) { >+ if (!getConfiguration().isInsideAgent()) { > resource.setId(this.temporaryKeyIndex.decrementAndGet()); > resource.setInventoryStatus(InventoryStatus.COMMITTED); > } >@@ -1408,7 +1408,7 @@ public class InventoryManager extends AgentService implements ContainerService, > > // Auto-activate if embedded within JBossAS (if within Agent, we need to wait until the Resource has been > // imported into the Server's inventory before activating it). >- if (!this.configuration.isInsideAgent()) { >+ if (!getConfiguration().isInsideAgent()) { > try { > activateResource(resource, resourceContainer, true); // just start 'em up as we find 'em for the embedded side > } catch (InvalidPluginConfigurationException e) { >@@ -1471,7 +1471,7 @@ public class InventoryManager extends AgentService implements ContainerService, > classLoader = null; > } > resourceContainer = new ResourceContainer(resource, classLoader); >- if (!this.configuration.isInsideAgent()) { >+ if (!getConfiguration().isInsideAgent()) { > // Auto-sync if the PC is running within the embedded JBossAS console. > resourceContainer.setSynchronizationState(ResourceContainer.SynchronizationState.SYNCHRONIZED); > } >@@ -1706,40 +1706,40 @@ public class InventoryManager extends AgentService implements ContainerService, > > private <T extends ResourceComponent<?>> ResourceContext<T> createResourceContext(Resource resource, > T parentComponent, ResourceContext<?> parentResourceContext, ResourceDiscoveryComponent<T> discoveryComponent) { >- File pluginDataDir = new File(this.configuration.getDataDirectory(), resource.getResourceType().getPlugin()); >+ File pluginDataDir = new File(getConfiguration().getDataDirectory(), resource.getResourceType().getPlugin()); > > return new ResourceContext<T>(resource, // the resource itself > parentComponent, // its parent component > parentResourceContext, //the resource context of the parent > discoveryComponent, // the discovery component (this is actually the proxy to it) > SystemInfoFactory.createSystemInfo(), // for native access >- this.configuration.getTemporaryDirectory(), // location for plugin to write temp files >+ getConfiguration().getTemporaryDirectory(), // location for plugin to write temp files > pluginDataDir, // location for plugin to write data files >- this.configuration.getContainerName(), // the name of the agent/PC >+ getConfiguration().getContainerName(), // the name of the agent/PC > getEventContext(resource), // for event access > 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 >- this.configuration.getPluginContainerDeployment()); // helps components make determinations of what to do >+ getConfiguration().getPluginContainerDeployment()); // helps components make determinations of what to do > } > > public <T extends ResourceComponent<?>> ResourceUpgradeContext<T> createResourceUpgradeContext(Resource resource, > ResourceContext<?> parentResourceContext, T parentComponent, ResourceDiscoveryComponent<T> discoveryComponent) { >- File pluginDataDir = new File(this.configuration.getDataDirectory(), resource.getResourceType().getPlugin()); >+ File pluginDataDir = new File(getConfiguration().getDataDirectory(), resource.getResourceType().getPlugin()); > > return new ResourceUpgradeContext<T>(resource, // the resource itself > parentResourceContext, //the context of its parent resource > parentComponent, // its parent component > discoveryComponent, // the discovery component (this is actually the proxy to it) > SystemInfoFactory.createSystemInfo(), // for native access >- this.configuration.getTemporaryDirectory(), // location for plugin to write temp files >+ getConfiguration().getTemporaryDirectory(), // location for plugin to write temp files > pluginDataDir, // location for plugin to write data files >- this.configuration.getContainerName(), // the name of the agent/PC >+ getConfiguration().getContainerName(), // the name of the agent/PC > getEventContext(resource), // for event access > getOperationContext(resource), // for operation manager access > getContentContext(resource), // for content manager access > getAvailabilityContext(resource, this.availabilityCollectors), // for components that want avail manager access >- this.configuration.getPluginContainerDeployment()); // helps components make determinations of what to do >+ getConfiguration().getPluginContainerDeployment()); // helps components make determinations of what to do > } > > /** >@@ -1763,7 +1763,7 @@ public class InventoryManager extends AgentService implements ContainerService, > boolean errorSent = false; > > DiscoveryServerService serverService = null; >- ServerServices serverServices = this.configuration.getServerServices(); >+ ServerServices serverServices = getConfiguration().getServerServices(); > if (serverServices != null) { > serverService = serverServices.getDiscoveryServerService(); > } >@@ -1883,7 +1883,7 @@ public class InventoryManager extends AgentService implements ContainerService, > > File file = null; > try { >- file = new File(this.configuration.getDataDirectory(), "inventory.dat"); >+ file = new File(getConfiguration().getDataDirectory(), "inventory.dat"); > if (file.exists()) { > long start = System.currentTimeMillis(); > log.info("Loading inventory from data file [" + file + "]..."); >@@ -1954,7 +1954,7 @@ public class InventoryManager extends AgentService implements ContainerService, > private void persistToDisk() { > try { > deactivateResource(this.platform); >- File dataDir = this.configuration.getDataDirectory(); >+ File dataDir = getConfiguration().getDataDirectory(); > if (!dataDir.exists()) { > if (!dataDir.mkdirs()) { > throw new RuntimeException("Failed to create data directory [" + dataDir + "]."); >@@ -1998,8 +1998,8 @@ public class InventoryManager extends AgentService implements ContainerService, > try { > ResourceDiscoveryComponent component = componentFactory.getDiscoveryComponent(platformType, null); > ResourceDiscoveryContext context = new ResourceDiscoveryContext(platformType, null, null, >- systemInfo, Collections.EMPTY_LIST, Collections.EMPTY_LIST, configuration.getContainerName(), >- this.configuration.getPluginContainerDeployment()); >+ systemInfo, Collections.EMPTY_LIST, Collections.EMPTY_LIST, getConfiguration().getContainerName(), >+ getConfiguration().getPluginContainerDeployment()); > Set<DiscoveredResourceDetails> discoveredResources = null; > > try { >@@ -2071,7 +2071,7 @@ public class InventoryManager extends AgentService implements ContainerService, > } > Set<Resource> childResources = Collections.newSetFromMap(new ConcurrentHashMap<Resource, Boolean>()); > Resource platform = new Resource(childResources); >- platform.setResourceKey("testkey" + configuration.getContainerName()); >+ platform.setResourceKey("testkey" + getConfiguration().getContainerName()); > platform.setName("testplatform"); > platform.setResourceType(type); > platform.setUuid(UUID.randomUUID().toString()); >@@ -2099,7 +2099,7 @@ public class InventoryManager extends AgentService implements ContainerService, > if (resource.getResourceType().getCategory() == ResourceCategory.PLATFORM) { > // Get and schedule the latest measurement schedules rooted at the given id. > // This should include disabled schedules to make sure that previously enabled schedules are shut off. >- Set<ResourceMeasurementScheduleRequest> scheduleRequests = configuration.getServerServices() >+ Set<ResourceMeasurementScheduleRequest> scheduleRequests = getConfiguration().getServerServices() > .getMeasurementServerService().getLatestSchedulesForResourceId(resource.getId(), false); > installSchedules(scheduleRequests); > >@@ -2108,11 +2108,11 @@ public class InventoryManager extends AgentService implements ContainerService, > for (Resource child : resource.getChildResources()) { > childrenIds.add(child.getId()); > } >- scheduleRequests = configuration.getServerServices().getMeasurementServerService() >+ scheduleRequests = getConfiguration().getServerServices().getMeasurementServerService() > .getLatestSchedulesForResourceIds(childrenIds, true); > installSchedules(scheduleRequests); > } else { >- Set<ResourceMeasurementScheduleRequest> scheduleRequests = configuration.getServerServices() >+ Set<ResourceMeasurementScheduleRequest> scheduleRequests = getConfiguration().getServerServices() > .getMeasurementServerService().getLatestSchedulesForResourceId(resource.getId(), true); > installSchedules(scheduleRequests); > } >@@ -2165,7 +2165,7 @@ public class InventoryManager extends AgentService implements ContainerService, > } > } > >- Set<ResourceMeasurementScheduleRequest> scheduleRequests = configuration.getServerServices() >+ Set<ResourceMeasurementScheduleRequest> scheduleRequests = getConfiguration().getServerServices() > .getMeasurementServerService().getLatestSchedulesForResourceIds(committedResourceIds, false); > installSchedules(scheduleRequests); > } >@@ -2205,7 +2205,7 @@ public class InventoryManager extends AgentService implements ContainerService, > newlyCommittedResourceIds.add(resource.getId()); > } > } >- Set<ResourceMeasurementScheduleRequest> schedules = configuration.getServerServices() >+ Set<ResourceMeasurementScheduleRequest> schedules = getConfiguration().getServerServices() > .getDiscoveryServerService().postProcessNewlyCommittedResources(newlyCommittedResourceIds); > installSchedules(schedules); > } >@@ -2231,8 +2231,8 @@ public class InventoryManager extends AgentService implements ContainerService, > > private DriftSyncManager createDriftSyncManager() { > DriftSyncManager mgr = new DriftSyncManager(); >- mgr.setDriftServer(configuration.getServerServices().getDriftServerService()); >- mgr.setDataDirectory(configuration.getDataDirectory()); >+ mgr.setDriftServer(getConfiguration().getServerServices().getDriftServerService()); >+ mgr.setDataDirectory(getConfiguration().getDataDirectory()); > mgr.setDriftManager(PluginContainer.getInstance().getDriftManager()); > mgr.setInventoryManager(this); > return mgr; >@@ -2417,8 +2417,8 @@ public class InventoryManager extends AgentService implements ContainerService, > try { > ResourceDiscoveryContext context = new ResourceDiscoveryContext(resourceType, parentComponent, > parentResourceContext, SystemInfoFactory.createSystemInfo(), processScanResults, >- Collections.EMPTY_LIST, this.configuration.getContainerName(), >- this.configuration.getPluginContainerDeployment()); >+ Collections.EMPTY_LIST, getConfiguration().getContainerName(), >+ getConfiguration().getPluginContainerDeployment()); > newResources = new HashSet<Resource>(); > try { > Set<DiscoveredResourceDetails> discoveredResources = invokeDiscoveryComponent(parentContainer, >@@ -2571,7 +2571,7 @@ public class InventoryManager extends AgentService implements ContainerService, > > private boolean updateResourceVersionOnServer(Resource resource, String newVersion) { > boolean versionUpdated = false; >- ServerServices serverServices = this.configuration.getServerServices(); >+ ServerServices serverServices = getConfiguration().getServerServices(); > if (serverServices != null) { > try { > DiscoveryServerService discoveryServerService = serverServices.getDiscoveryServerService(); >@@ -2666,7 +2666,7 @@ public class InventoryManager extends AgentService implements ContainerService, > if (log.isDebugEnabled()) { > log.debug("Merging [" + modifiedResourceIds.size() + "] modified Resources into local inventory..."); > } >- Set<Resource> modifiedResources = configuration.getServerServices().getDiscoveryServerService() >+ Set<Resource> modifiedResources = getConfiguration().getServerServices().getDiscoveryServerService() > .getResources(modifiedResourceIds, false); > syncSchedules(modifiedResources); // RHQ-792, mtime is the indicator that schedules should be sync'ed too > syncDriftDefinitions(modifiedResources); >@@ -2684,7 +2684,7 @@ public class InventoryManager extends AgentService implements ContainerService, > if (!unknownResourceIds.isEmpty()) { > PluginMetadataManager pmm = this.pluginManager.getMetadataManager(); > >- Set<Resource> unknownResources = configuration.getServerServices().getDiscoveryServerService() >+ Set<Resource> unknownResources = getConfiguration().getServerServices().getDiscoveryServerService() > .getResources(unknownResourceIds, true); > > Set<Integer> toBeIgnored = new HashSet<Integer>(); >@@ -2956,7 +2956,7 @@ public class InventoryManager extends AgentService implements ContainerService, > boolean activate = true; > > //only do upgrade inside the agent. it does not make sense in embedded mode. >- if (doUpgrade && configuration.isInsideAgent()) { >+ if (doUpgrade && getConfiguration().isInsideAgent()) { > try { > activate = prepareResourceForActivation(resource, container, false); > activate = activate && resourceUpgradeDelegate.processAndQueue(container); >@@ -2995,7 +2995,7 @@ public class InventoryManager extends AgentService implements ContainerService, > log.debug("Resource got finally activated, cleaning out config errors: " + resource); > } > >- DiscoveryServerService serverService = configuration.getServerServices().getDiscoveryServerService(); >+ DiscoveryServerService serverService = getConfiguration().getServerServices().getDiscoveryServerService(); > if (serverService != null) { > serverService.clearResourceConfigError(resource.getId()); > } >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 2993b2b..46b37fb 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 >@@ -40,11 +40,9 @@ import org.rhq.core.clientapi.agent.inventory.ResourceFactoryAgentService; > import org.rhq.core.clientapi.agent.metadata.PluginMetadataManager; > import org.rhq.core.clientapi.server.inventory.ResourceFactoryServerService; > import org.rhq.core.domain.resource.ResourceType; >-import org.rhq.core.pc.ContainerService; >+import org.rhq.core.pc.AgentContainerService; > import org.rhq.core.pc.PluginContainer; >-import org.rhq.core.pc.PluginContainerConfiguration; > import org.rhq.core.pc.ServerServices; >-import org.rhq.core.pc.agent.AgentService; > import org.rhq.core.pc.util.ComponentUtil; > import org.rhq.core.pc.util.FacetLockType; > import org.rhq.core.pc.util.LoggingThreadFactory; >@@ -58,7 +56,7 @@ import org.rhq.core.pluginapi.inventory.DeleteResourceFacet; > * > * @author Jason Dobies > */ >-public class ResourceFactoryManager extends AgentService implements ContainerService, ResourceFactoryAgentService { >+public class ResourceFactoryManager extends AgentContainerService implements ResourceFactoryAgentService { > > // This used to be a single value fixed at 60 seconds. But create and delete actions can very well exceed 1 minute > // depending on the type of resource being created, or perhaps graceful shutdown of a resource being deleted. So, >@@ -99,11 +97,6 @@ public class ResourceFactoryManager extends AgentService implements ContainerSer > private final Log log = LogFactory.getLog(ResourceFactoryManager.class); > > /** >- * Configuration elements for the running of this manager. >- */ >- private PluginContainerConfiguration configuration; >- >- /** > * Executor service used to perform tasks. > */ > private ExecutorService executor; >@@ -124,29 +117,25 @@ public class ResourceFactoryManager extends AgentService implements ContainerSer > > // ContainerService Implementation -------------------------------------------- > >- public void initialize() { >- log.info("Initializing"); >+ protected void initializeInternal() { >+ log.debug("Initializing..."); > > // Retrieve handle to metadata manager > metadataManager = PluginContainer.getInstance().getPluginManager().getMetadataManager(); > > // Initialize thread pool for executing tasks >- int corePoolSize = configuration.getResourceFactoryCoreThreadPoolSize(); >- int keepAliveTime = configuration.getResourceFactoryKeepAliveTime(); >- int maxPoolSize = configuration.getResourceFactoryMaxThreadPoolSize(); >+ int corePoolSize = getConfiguration().getResourceFactoryCoreThreadPoolSize(); >+ int keepAliveTime = getConfiguration().getResourceFactoryKeepAliveTime(); >+ int maxPoolSize = getConfiguration().getResourceFactoryMaxThreadPoolSize(); > > executor = new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, TimeUnit.MILLISECONDS, > new LinkedBlockingQueue<Runnable>(10000), new LoggingThreadFactory("ResourceFactory.executor", true)); > } > >- public void shutdown() { >+ protected void shutdownInternal() { > executor.shutdown(); > } > >- public void setConfiguration(PluginContainerConfiguration configuration) { >- this.configuration = configuration; >- } >- > // ResourceFactoryAgentService Implementation -------------------------------------------- > > @SuppressWarnings("unchecked") >@@ -173,7 +162,7 @@ public class ResourceFactoryManager extends AgentService implements ContainerSer > .getTimeout()); > > CreateResourceRunner runner = new CreateResourceRunner(this, request.getParentResourceId(), facet, request >- .getRequestId(), report, configuration.isInsideAgent()); >+ .getRequestId(), report, getConfiguration().isInsideAgent()); > > CreateResourceResponse response; > try { >@@ -207,7 +196,7 @@ public class ResourceFactoryManager extends AgentService implements ContainerSer > .getTimeout()); > > CreateResourceRunner runner = new CreateResourceRunner(this, request.getParentResourceId(), facet, request >- .getRequestId(), report, configuration.isInsideAgent()); >+ .getRequestId(), report, getConfiguration().isInsideAgent()); > executor.submit((Runnable) runner); > } > >@@ -246,7 +235,7 @@ public class ResourceFactoryManager extends AgentService implements ContainerSer > * @return server service if one is registered; <code>null</code> otherwise > */ > ResourceFactoryServerService getServerService() { >- ServerServices serverServices = configuration.getServerServices(); >+ ServerServices serverServices = getConfiguration().getServerServices(); > if (serverServices == null) { > return null; > } >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 cf5b86e..e3fcceb 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 >@@ -40,6 +40,7 @@ import org.rhq.core.domain.measurement.AvailabilityType; > import org.rhq.core.domain.resource.InventoryStatus; > import org.rhq.core.domain.resource.Resource; > import org.rhq.core.domain.resource.ResourceType; >+import org.rhq.core.pc.ContainerServiceState; > import org.rhq.core.pc.PluginContainer; > import org.rhq.core.pc.PluginContainerConfiguration; > import org.rhq.core.pc.plugin.PluginComponentFactory; >@@ -54,6 +55,7 @@ import org.rhq.core.util.exception.Severity; > * @author Ian Springer > */ > public class RuntimeDiscoveryExecutor implements Runnable, Callable<InventoryReport> { >+ > private Log log = LogFactory.getLog(RuntimeDiscoveryExecutor.class); > > private InventoryManager inventoryManager; >@@ -120,8 +122,10 @@ public class RuntimeDiscoveryExecutor implements Runnable, Callable<InventoryRep > > this.inventoryManager.handleReport(report); > } catch (Exception e) { >- log.warn("Exception caught while executing runtime discovery scan rooted at [" + target + "].", e); >- report.addError(new ExceptionPackage(Severity.Warning, e)); >+ if (inventoryManager.getState() == ContainerServiceState.INITIALIZED) { >+ log.warn("Exception caught while executing runtime discovery scan rooted at [" + target + "].", e); >+ report.addError(new ExceptionPackage(Severity.Warning, e)); >+ } > } > > return report; >@@ -149,6 +153,9 @@ public class RuntimeDiscoveryExecutor implements Runnable, Callable<InventoryRep > > private void discoverForResourceRecursive(Resource parent, InventoryReport report) throws PluginContainerException { > for (Resource child : parent.getChildResources()) { >+ if (inventoryManager.getState() != ContainerServiceState.INITIALIZED) { >+ break; >+ } > // See if the child has new children itself. Then we check those children to see if there are grandchildren. > // Note that if the child has already been added to the report, there is no need to process it again, so skip it. > boolean alreadyProcessed = report.getAddedRoots().contains(child); >@@ -236,6 +243,9 @@ public class RuntimeDiscoveryExecutor implements Runnable, Callable<InventoryRep > PluginComponentFactory factory = PluginContainer.getInstance().getPluginComponentFactory(); > Set<ResourceType> childResourceTypes = parent.getResourceType().getChildResourceTypes(); > for (ResourceType childResourceType : childResourceTypes) { >+ if (inventoryManager.getState() != ContainerServiceState.INITIALIZED) { >+ break; >+ } > try { > // Make sure we have a discovery component for that type, otherwise there is nothing to do > ResourceDiscoveryComponent discoveryComponent = null; >@@ -277,8 +287,10 @@ public class RuntimeDiscoveryExecutor implements Runnable, Callable<InventoryRep > } > removeStaleResources(parent, childResourceType, mergedResources); > } catch (Throwable t) { >- report.getErrors().add(new ExceptionPackage(Severity.Severe, t)); >- log.error("Error in runtime discovery", t); >+ if (inventoryManager.getState() == ContainerServiceState.INITIALIZED) { >+ report.getErrors().add(new ExceptionPackage(Severity.Severe, t)); >+ log.error("An error occurred during service discovery.", t); >+ } > } > } > >@@ -300,4 +312,5 @@ public class RuntimeDiscoveryExecutor implements Runnable, Callable<InventoryRep > } > } > } >+ > } >\ No newline at end of file >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 e6c4f40..bf33f37 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 >@@ -53,10 +53,9 @@ import org.rhq.core.domain.measurement.NumericType; > import org.rhq.core.domain.measurement.ResourceMeasurementScheduleRequest; > import org.rhq.core.domain.resource.Resource; > import org.rhq.core.domain.resource.ResourceType; >+import org.rhq.core.pc.AgentContainerService; > import org.rhq.core.pc.ContainerService; > import org.rhq.core.pc.PluginContainer; >-import org.rhq.core.pc.PluginContainerConfiguration; >-import org.rhq.core.pc.agent.AgentService; > import org.rhq.core.pc.inventory.InventoryManager; > import org.rhq.core.pc.inventory.ResourceContainer; > import org.rhq.core.pc.util.ComponentUtil; >@@ -73,8 +72,9 @@ import org.rhq.core.pluginapi.measurement.MeasurementFacet; > * @author Greg Hinkle > * @author John Mazzitelli > */ >-public class MeasurementManager extends AgentService implements MeasurementAgentService, ContainerService, >+public class MeasurementManager extends AgentContainerService implements MeasurementAgentService, > MeasurementManagerMBean { >+ > public static final String OBJECT_NAME = "rhq.pc:type=MeasurementManager"; > > private static final String COLLECTOR_THREAD_POOL_NAME = "MeasurementManager.collector"; >@@ -90,8 +90,6 @@ public class MeasurementManager extends AgentService implements MeasurementAgent > private MeasurementSenderRunner measurementSenderRunner; > MeasurementCollectorRunner measurementCollectorRunner; > >- private PluginContainerConfiguration configuration; >- > private PriorityQueue<ScheduledMeasurementInfo> scheduledRequests = new PriorityQueue<ScheduledMeasurementInfo>( > 10000); > >@@ -118,8 +116,8 @@ public class MeasurementManager extends AgentService implements MeasurementAgent > super(MeasurementAgentService.class); > } > >- public void initialize() { >- if (configuration.isStartManagementBean()) { >+ protected void initializeInternal() { >+ if (getConfiguration().isStartManagementBean()) { > MBeanServer server = ManagementFactory.getPlatformMBeanServer(); > try { > server.registerMBean(this, new ObjectName(OBJECT_NAME)); >@@ -130,10 +128,10 @@ public class MeasurementManager extends AgentService implements MeasurementAgent > > this.inventoryManager = PluginContainer.getInstance().getInventoryManager(); > >- int threadPoolSize = configuration.getMeasurementCollectionThreadPoolSize(); >- long collectionInitialDelaySecs = configuration.getMeasurementCollectionInitialDelay(); >+ int threadPoolSize = getConfiguration().getMeasurementCollectionThreadPoolSize(); >+ long collectionInitialDelaySecs = getConfiguration().getMeasurementCollectionInitialDelay(); > >- if (configuration.isInsideAgent()) { >+ if (getConfiguration().isInsideAgent()) { > this.collectorThreadPool = new ScheduledThreadPoolExecutor(threadPoolSize, new LoggingThreadFactory( > COLLECTOR_THREAD_POOL_NAME, true)); > >@@ -272,7 +270,7 @@ public class MeasurementManager extends AgentService implements MeasurementAgent > } > } > >- public void shutdown() { >+ protected void shutdownInternal() { > if (this.collectorThreadPool != null) { > this.collectorThreadPool.shutdownNow(); > } >@@ -281,7 +279,7 @@ public class MeasurementManager extends AgentService implements MeasurementAgent > this.senderThreadPool.shutdownNow(); > } > >- if (configuration.isStartManagementBean()) { >+ if (getConfiguration().isStartManagementBean()) { > MBeanServer server = ManagementFactory.getPlatformMBeanServer(); > try { > server.unregisterMBean(new ObjectName(OBJECT_NAME)); >@@ -291,10 +289,6 @@ public class MeasurementManager extends AgentService implements MeasurementAgent > } > } > >- public void setConfiguration(PluginContainerConfiguration configuration) { >- this.configuration = configuration; >- } >- > /** > * This remoted method allows the server to schedule a bunch of resources with one call. > * >@@ -375,8 +369,8 @@ public class MeasurementManager extends AgentService implements MeasurementAgent > // This will enable them to be collected at the same time > long firstCollection = System.currentTimeMillis(); > // see BZ 751231 for why we delay the first collection >- if (configuration != null) { >- firstCollection += (configuration.getMeasurementCollectionInitialDelay() * 1000L); >+ if (getConfiguration() != null) { >+ firstCollection += (getConfiguration().getMeasurementCollectionInitialDelay() * 1000L); > } else { > firstCollection += 30000L; > } >@@ -529,9 +523,9 @@ public class MeasurementManager extends AgentService implements MeasurementAgent > this.collectedMeasurements.addAndGet(report.getDataCount()); > this.sinceLastCollectedMeasurements.addAndGet(report.getDataCount()); > this.totalTimeCollecting.addAndGet(report.getCollectionTime()); >- if (configuration.getServerServices() != null) { >+ if (getConfiguration().getServerServices() != null) { > try { >- configuration.getServerServices().getMeasurementServerService().mergeMeasurementReport(report); >+ getConfiguration().getServerServices().getMeasurementServerService().mergeMeasurementReport(report); > } catch (Exception e) { > LOG.warn("Failure to report measurements to server", e); > } >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 d87f5c1..120a84f 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 >@@ -45,9 +45,8 @@ import org.rhq.core.domain.configuration.Configuration; > import org.rhq.core.domain.configuration.PropertySimple; > import org.rhq.core.domain.operation.OperationDefinition; > import org.rhq.core.domain.resource.ResourceType; >+import org.rhq.core.pc.AgentContainerService; > import org.rhq.core.pc.ContainerService; >-import org.rhq.core.pc.PluginContainerConfiguration; >-import org.rhq.core.pc.agent.AgentService; > import org.rhq.core.pc.operation.OperationInvocation.Status; > import org.rhq.core.pc.util.ComponentUtil; > import org.rhq.core.pc.util.FacetLockType; >@@ -63,12 +62,12 @@ import org.rhq.core.util.exception.WrappedRemotingException; > * @author Ian Springer > * @author John Mazzitelli > */ >-public class OperationManager extends AgentService implements OperationAgentService, ContainerService { >+public class OperationManager extends AgentContainerService implements OperationAgentService { >+ > private static final String SENDER_THREAD_POOL_NAME = "OperationManager.invoker"; > > private final Log log = LogFactory.getLog(OperationManager.class); > >- private PluginContainerConfiguration configuration; > private Timer timer; > private OperationThreadPoolGateway operationGateway; > >@@ -76,13 +75,13 @@ public class OperationManager extends AgentService implements OperationAgentServ > super(OperationAgentService.class); > } > >- public void initialize() { >+ protected void initializeInternal() { > timer = new Timer(SENDER_THREAD_POOL_NAME + ".timeout-timer"); > > // read the javadoc on ThreadPoolExecutor and how max pool size is affected when using LinkedBlockingQueue > LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(10000); > LoggingThreadFactory threadFactory = new LoggingThreadFactory(SENDER_THREAD_POOL_NAME, true); >- int maxPoolSize = configuration.getOperationInvokerThreadPoolSize(); >+ int maxPoolSize = getConfiguration().getOperationInvokerThreadPoolSize(); > ThreadPoolExecutor threadPool = new ThreadPoolExecutor(1, maxPoolSize, 1000, TimeUnit.MILLISECONDS, queue, > threadFactory); > operationGateway = new OperationThreadPoolGateway(threadPool); >@@ -96,15 +95,11 @@ public class OperationManager extends AgentService implements OperationAgentServ > * > * @see ContainerService#shutdown() > */ >- public void shutdown() { >+ protected void shutdownInternal() { > timer.cancel(); > operationGateway.shutdown(); > } > >- public void setConfiguration(PluginContainerConfiguration configuration) { >- this.configuration = configuration; >- } >- > public void invokeOperation(@NotNull final String jobId, final int resourceId, @NotNull final String operationName, > @Nullable final Configuration parameterConfig) throws PluginContainerException { > invokeOperation(jobId, resourceId, operationName, parameterConfig, getOperationServerService()); >@@ -250,7 +245,7 @@ public class OperationManager extends AgentService implements OperationAgentServ > } > > // use the PC's default since we can't find it anywhere else >- return configuration.getOperationInvocationTimeout() * 1000L; >+ return getConfiguration().getOperationInvocationTimeout() * 1000L; > } > > /** >@@ -288,8 +283,8 @@ public class OperationManager extends AgentService implements OperationAgentServ > * @return the server-side proxy; <code>null</code> if this manager doesn't have a server to talk to > */ > private OperationServerService getOperationServerService() { >- if (configuration.getServerServices() != null) { >- return configuration.getServerServices().getOperationServerService(); >+ if (getConfiguration().getServerServices() != null) { >+ return getConfiguration().getServerServices().getOperationServerService(); > } > > return null; >diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java >index 9d81a9a..d655bfa 100644 >--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java >+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginComponentFactory.java >@@ -35,8 +35,8 @@ import org.rhq.core.domain.measurement.AvailabilityType; > import org.rhq.core.domain.resource.Resource; > import org.rhq.core.domain.resource.ResourceType; > import org.rhq.core.pc.ContainerService; >+import org.rhq.core.pc.NonAgentContainerService; > import org.rhq.core.pc.PluginContainer; >-import org.rhq.core.pc.PluginContainerConfiguration; > import org.rhq.core.pc.inventory.InventoryManager; > import org.rhq.core.pc.inventory.ResourceContainer; > import org.rhq.core.pluginapi.inventory.ClassLoaderFacet; >@@ -51,10 +51,10 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent; > * @author John Mazzitelli > */ > @SuppressWarnings("unchecked") >-public class PluginComponentFactory implements ContainerService { >+public class PluginComponentFactory extends NonAgentContainerService { >+ > private static final Log log = LogFactory.getLog(PluginComponentFactory.class); > >- private PluginContainerConfiguration configuration; > private InventoryManager inventoryManager; > private PluginManager pluginManager; > >@@ -288,7 +288,8 @@ public class PluginComponentFactory implements ContainerService { > * > * @see ContainerService#initialize() > */ >- public void initialize() { >+ protected void initializeInternal() { >+ return; > } > > /** >@@ -296,12 +297,9 @@ public class PluginComponentFactory implements ContainerService { > * > * @see ContainerService#shutdown() > */ >- public void shutdown() { >+ protected void shutdownInternal() { > this.inventoryManager = null; > this.pluginManager = null; > } > >- public void setConfiguration(PluginContainerConfiguration configuration) { >- this.configuration = configuration; >- } > } >\ No newline at end of file >diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginManager.java >index addfbc8..6e71fcd 100644 >--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginManager.java >+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/plugin/PluginManager.java >@@ -44,6 +44,7 @@ import org.rhq.core.clientapi.descriptor.PluginTransformer; > import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor; > import org.rhq.core.domain.plugin.Plugin; > import org.rhq.core.pc.ContainerService; >+import org.rhq.core.pc.NonAgentContainerService; > import org.rhq.core.pc.PluginContainerConfiguration; > import org.rhq.core.pluginapi.plugin.PluginContext; > import org.rhq.core.pluginapi.plugin.PluginLifecycleListener; >@@ -61,7 +62,7 @@ import org.rhq.core.util.exception.ThrowableUtil; > * @author Jason Dobies > * @author John Mazzitelli > */ >-public class PluginManager implements ContainerService { >+public class PluginManager extends NonAgentContainerService { > > /** > * A callback interface for updating the loadedPlugins list. When running inside of an agent, loadedPlugins gets >@@ -94,11 +95,10 @@ public class PluginManager implements ContainerService { > /** > * Finds all plugins using the plugin finder defined in the > * {@link #setConfiguration(PluginContainerConfiguration) plugin container configuration} and >- * {@link #loadPlugin(java.net.URL, ClassLoader, org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor) loads} each plugin found. >- * >- * @see ContainerService#initialize() >+ * {@link #loadPlugin(java.net.URL, ClassLoader, org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor) loads} >+ * each plugin found. > */ >- public void initialize() { >+ protected void initializeInternal() { > loadedPluginEnvironments = new HashMap<String, PluginEnvironment>(); > loadedPlugins = new ArrayList<Plugin>(); > metadataManager = new PluginMetadataManager(); >@@ -190,10 +190,7 @@ public class PluginManager implements ContainerService { > }; > } > >- /** >- * @see ContainerService#shutdown() >- */ >- public void shutdown() { >+ protected void shutdownInternal() { > // Inform the plugins we are shutting them down. > // We want to shut them down in the reverse order that we initialized them. > Collections.reverse(this.loadedPlugins); >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 6f4e955..74039aa 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 >@@ -26,9 +26,7 @@ import java.io.InputStream; > > import org.rhq.core.clientapi.agent.PluginContainerException; > import org.rhq.core.clientapi.agent.support.SupportAgentService; >-import org.rhq.core.pc.ContainerService; >-import org.rhq.core.pc.PluginContainerConfiguration; >-import org.rhq.core.pc.agent.AgentService; >+import org.rhq.core.pc.AgentContainerService; > import org.rhq.core.pc.util.ComponentUtil; > import org.rhq.core.pc.util.FacetLockType; > import org.rhq.core.pluginapi.support.SnapshotReportRequest; >@@ -42,19 +40,18 @@ import org.rhq.core.pluginapi.support.SupportFacet; > * > * @author John Mazzitelli > */ >-public class SupportManager extends AgentService implements SupportAgentService, ContainerService { >+public class SupportManager extends AgentContainerService implements SupportAgentService { > > public SupportManager() { > super(SupportAgentService.class); > } > >- public void setConfiguration(PluginContainerConfiguration configuration) { >+ protected void initializeInternal() { >+ return; > } > >- public void initialize() { >- } >- >- public void shutdown() { >+ protected void shutdownInternal() { >+ return; > } > > public InputStream getSnapshotReport(int resourceId, String name, String description) throws Exception { >diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftManagerTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftManagerTest.java >index e1ec00d..0c8a180 100644 >--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftManagerTest.java >+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftManagerTest.java >@@ -302,7 +302,7 @@ public class DriftManagerTest extends DriftTest { > /** > * Sets a callback that will be invoked immediately after DriftManager calls > * {@link DriftServerService#sendChangesetZip(int, long, java.io.InputStream)} or >- * {@link DriftServerService#sendFilesZip(int, long, java.io.InputStream)}. The callback >+ * {@link DriftServerService#sendFilesZip(int, String, String, long, java.io.InputStream)}. The callback > * can perform any verification as necessary, and that will happen before the call to > * to DriftServerService returns. > *
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 808231
: 574577