modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
| 7 +
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/DriftSyncManager.java
| 48 +++++++---
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/DriftSynchronizer.java
| 12 ++
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/RuntimeSynchronizer.java
| 5 +
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/StartupSynchronizer.java
| 4
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
| 4
6 files changed, 66 insertions(+), 14 deletions(-)
New commits:
commit c9509c58604f383ff1ed516c6c1c4edddb99f673
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Sep 28 13:47:20 2011 -0400
Resend change set content during inventory sync
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 2dbd0b5..8fd065f 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
@@ -222,7 +222,12 @@ public class DriftManager extends AgentService implements
DriftAgentService, Dri
}
}
- private void scanForContentToResend() {
+ /**
+ * Scans the changesets directory for any change set content zip files. This method
+ * assumes that any content zip files found have not been received or persisted by
the
+ * server. Each content zip file is resent to the server.
+ */
+ public void scanForContentToResend() {
log.info("Scanning for change set content to resend...");
for (File resourceDir : changeSetsDir.listFiles()) {
for (File configDir : resourceDir.listFiles()) {
diff --git
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/DriftSyncManager.java
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/DriftSyncManager.java
index b9df2ce..434ddc1 100644
---
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/DriftSyncManager.java
+++
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/DriftSyncManager.java
@@ -37,9 +37,9 @@ import org.rhq.core.pc.inventory.InventoryManager;
import static
org.rhq.core.domain.drift.DriftConfigurationComparator.CompareMode.BOTH_BASE_INFO_AND_DIRECTORY_SPECIFICATIONS;
/**
- * This class handles syncing drift configurations during inventory sync. This class is
- * intended to server as the public interface (so to speak) to {@link InventoryManager}
for
- * syncing drift configurations.
+ * This class handles syncing drift configurations and drift content during inventory
sync.
+ * This class is intended to server as the public interface (so to speak) to
+ * {@link InventoryManager} for syncing drift configurations and content.
* <br/><br/>
* Please review the docs for each of the setter methods to determine which properties
* should be set before invoking any business logic methods.
@@ -89,13 +89,19 @@ public class DriftSyncManager {
dataDir = dataDirectory;
}
- public void syncConfigsWithServer(Set<Integer> resourceIds) {
- log.info("Starting server sync for drift configurations...");
- long startTime = System.currentTimeMillis();
-
- Map<Integer, List<DriftConfiguration>> configs =
driftServer.getDriftConfigurations(resourceIds);
- DriftConfigurationComparator comparator = new DriftConfigurationComparator(
- BOTH_BASE_INFO_AND_DIRECTORY_SPECIFICATIONS);
+ /**
+ * Synchronized both drift configurations and drift content with the server. The
drift
+ * configuration sync goes from server to agent in that the drift configurations in
the
+ * local inventory are updated to match the drift configurations on the server
+ * inventory.
+ * <br/><br/>
+ * The content sync works as follows. Any change set content zip files found locally
+ * resent to the server under the assumption that the content has not been persisted
on
+ * the server.
+ *
+ * @param resourceIds The ids of resources that need to be synced.
+ */
+ public void syncWithServer(Set<Integer> resourceIds) {
DriftSynchronizerFactory synchronizerFactory = new DriftSynchronizerFactory();
DriftSynchronizer synchronizer;
@@ -105,6 +111,18 @@ public class DriftSyncManager {
synchronizer = synchronizerFactory.getRuntimeSynchronizer(driftMgr);
}
+ syncConfigs(synchronizer, resourceIds);
+ syncContent(synchronizer);
+ }
+
+ private void syncConfigs(DriftSynchronizer synchronizer, Set<Integer>
resourceIds) {
+ log.info("Starting server sync for drift configurations...");
+ long startTime = System.currentTimeMillis();
+
+ Map<Integer, List<DriftConfiguration>> configs =
driftServer.getDriftConfigurations(resourceIds);
+ DriftConfigurationComparator comparator = new DriftConfigurationComparator(
+ BOTH_BASE_INFO_AND_DIRECTORY_SPECIFICATIONS);
+
int totalDeleted = 0;
int totalAdded = 0;
@@ -130,6 +148,16 @@ public class DriftSyncManager {
}
}
+ private void syncContent(DriftSynchronizer synchronizer) {
+ log.info("Starting drift content sync...");
+ long startTime = System.currentTimeMillis();
+ synchronizer.syncChangeSetContent();
+ long endTime = System.currentTimeMillis();
+ if (log.isInfoEnabled()) {
+ log.info("Finished drift content sync in " + (endTime - startTime)
+ " ms");
+ }
+ }
+
/**
* This method determines whether or not this is a sync being done at start up (or
* more precisely during PC initialization). It does by checking to see if
diff --git
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/DriftSynchronizer.java
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/DriftSynchronizer.java
index 757abe6..90c4955 100644
---
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/DriftSynchronizer.java
+++
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/DriftSynchronizer.java
@@ -33,7 +33,9 @@ public interface DriftSynchronizer {
/**
* Determines which drift configurations for a resource have been deleted on the
server
* and need to be purged from the local inventory. This method should not make any
- * changes to the local inventory.
+ * changes to the local inventory. It also handles syncing content with the server.
Any
+ * change set content found on the agent and that is not known to be on the server
+ * should be sent to the server.
*
* @param resourceId
* @param configurationsFromServer A set of drift configurations belonging to the
@@ -81,4 +83,12 @@ public interface DriftSynchronizer {
* @param configurations The drift configurations to add to the local inventory.
*/
void addToLocalInventory(int resourceId, List<DriftConfiguration>
configurations);
+
+ /**
+ * This is an optional operation as it can only be performed when
+ * {@link org.rhq.core.pc.drift.DriftManager DriftManager} is fully initialized.
+ * Implementations are responsible for detecting any change set content that may not
be
+ * on the server and then sending that content to the server.
+ */
+ void syncChangeSetContent();
}
diff --git
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/RuntimeSynchronizer.java
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/RuntimeSynchronizer.java
index 9fe0a7b..94cea4c 100644
---
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/RuntimeSynchronizer.java
+++
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/RuntimeSynchronizer.java
@@ -121,6 +121,11 @@ class RuntimeSynchronizer implements DriftSynchronizer {
}
}
+ @Override
+ public void syncChangeSetContent() {
+ driftMgr.scanForContentToResend();
+ }
+
private String toString(int rid, DriftConfiguration c) {
return "DriftConfiguration[id: " + c.getId() + ", name: " +
c.getName() + ", resourceId: " + rid + "]";
}
diff --git
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/StartupSynchronizer.java
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/StartupSynchronizer.java
index 7a472ad..0e8ed59 100644
---
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/StartupSynchronizer.java
+++
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/sync/StartupSynchronizer.java
@@ -131,6 +131,10 @@ class StartupSynchronizer implements DriftSynchronizer {
}
}
+ @Override
+ public void syncChangeSetContent() {
+ }
+
private String toString(int rid, DriftConfiguration c) {
return "DriftConfiguration[id: " + c.getId() + ", name: " +
c.getName() + ", resourceId: " + rid + "]";
}
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 5d03d0c..bfdb2a3 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
@@ -2036,7 +2036,7 @@ public class InventoryManager extends AgentService implements
ContainerService,
}
DriftSyncManager driftSyncMgr = createDriftSyncManager();
- driftSyncMgr.syncConfigsWithServer(resourceIds);
+ driftSyncMgr.syncWithServer(resourceIds);
}
private boolean supportsDriftManagement(Resource r) {
@@ -2083,7 +2083,7 @@ public class InventoryManager extends AgentService implements
ContainerService,
}
DriftSyncManager driftSyncMgr = createDriftSyncManager();
- driftSyncMgr.syncConfigsWithServer(committedResourceIds);
+ driftSyncMgr.syncWithServer(committedResourceIds);
}
private void postProcessNewlyCommittedResources(Set<Resource> resources) {