java/code/src/com/redhat/rhn/common/db/datasource/xml/ErrataCache_queries.xml | 3
java/code/src/com/redhat/rhn/frontend/events/SsmRemovePackagesAction.java | 80
+++++-----
2 files changed, 44 insertions(+), 39 deletions(-)
New commits:
commit a609788ccd1b9b62d47a95bbbb0ff085cb48155e
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Sun Aug 9 15:17:50 2009 -0400
443500 - Made sure the call to complete the SSM async operation always takes place.
Added hook to associate servers with the operation.
diff --git a/java/code/src/com/redhat/rhn/frontend/events/SsmRemovePackagesAction.java
b/java/code/src/com/redhat/rhn/frontend/events/SsmRemovePackagesAction.java
index 994d7bf..55ee1dc 100644
--- a/java/code/src/com/redhat/rhn/frontend/events/SsmRemovePackagesAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/events/SsmRemovePackagesAction.java
@@ -14,40 +14,31 @@
*/
package com.redhat.rhn.frontend.events;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.log4j.Logger;
import com.redhat.rhn.common.db.datasource.DataResult;
-
import com.redhat.rhn.common.localization.LocalizationService;
-
import com.redhat.rhn.common.messaging.EventMessage;
-
import com.redhat.rhn.domain.server.Server;
import com.redhat.rhn.domain.server.ServerFactory;
-
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.domain.user.UserFactory;
-
import com.redhat.rhn.frontend.dto.PackageListItem;
-
import com.redhat.rhn.manager.action.ActionManager;
-
import com.redhat.rhn.manager.ssm.SsmOperationManager;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.log4j.Logger;
+import com.redhat.rhn.manager.rhnset.RhnSetDecl;
/**
* Handles removing packages from servers in the SSM.
*
* @see com.redhat.rhn.frontend.events.SsmRemovePackagesEvent
- * @version $Revision$
*/
public class SsmRemovePackagesAction extends AbstractDatabaseAction {
private static Logger log = Logger.getLogger(SsmRemovePackagesAction.class);
@@ -55,30 +46,46 @@ public class SsmRemovePackagesAction extends AbstractDatabaseAction {
/** {@inheritDoc} */
protected void doExecute(EventMessage msg) {
log.debug("Executing package removals.");
- SsmRemovePackagesEvent event = (SsmRemovePackagesEvent) msg;
- DataResult result = event.getResult();
+ SsmRemovePackagesEvent event = (SsmRemovePackagesEvent) msg;
User user = UserFactory.lookupById(event.getUserId());
- Date earliest = event.getEarliest();
LocalizationService ls = LocalizationService.getInstance();
- long operationId = SsmOperationManager.createOperation(user,
- ls.getMessage("ssm.package.remove.operationname"), null);
- int numPackages = 0;
+ String operationMessage =
ls.getMessage("ssm.package.remove.operationname");
+ long operationId = SsmOperationManager.createOperation(user, operationMessage,
+ RhnSetDecl.SYSTEMS.getLabel());
+
+ try {
+ scheduleDeletes(event, user);
+ }
+ catch (Exception e) {
+ log.error("Error scheduling package deletes for event: " + event,
e);
+ }
+ finally {
+ // This should stay in the finally block so the operation is
+ // not perpetually left in an in progress state
+ SsmOperationManager.completeOperation(user, operationId);
+ }
+ }
+
+ private void scheduleDeletes(SsmRemovePackagesEvent event, User user) {
+
+ DataResult result = event.getResult();
+ Date earliest = event.getEarliest();
/* 443500 - The following was changed to be able to stuff all of the package
- removals into a single action. The schedule package removal page will display
- a fine grained mapping of server to package removed (taking into account to
- only show packages that exist on the server).
+ removals into a single action. The schedule package removal page will display
+ a fine grained mapping of server to package removed (taking into account to
+ only show packages that exist on the server).
- However, there is no issue in requesting a client delete a package it
doesn't
- have. So when we create the action, populate it with all packages and for
- every server to which any package removal applies. This will let us keep all
- of the removals coupled under a single scheduled action and won't cause
an
- issue on the client when the scheduled removals are picked up.
+ However, there is no issue in requesting a client delete a package it
doesn't
+ have. So when we create the action, populate it with all packages and for
+ every server to which any package removal applies. This will let us keep all
+ of the removals coupled under a single scheduled action and won't cause an
+ issue on the client when the scheduled removals are picked up.
- jdobies, Apr 8, 2009
- */
+ jdobies, Apr 8, 2009
+ */
// The package collection is a set to prevent duplciates when keeping a running
// total of all packages selected
@@ -97,12 +104,11 @@ public class SsmRemovePackagesAction extends AbstractDatabaseAction
{
Map data = (Map) it.next();
// Load the server
- Long sid = (Long)data.get("id");
+ Long sid = (Long) data.get("id");
allServerIds.add(sid);
// Get the packages out of the elaborator
List elabList = (List) data.get("elaborator0");
- numPackages += elabList.size();
for (Iterator elabIt = elabList.iterator(); elabIt.hasNext();) {
Map elabData = (Map) elabIt.next();
commit b99539879ea94524505ffcfa912d2d6de7d23352
Author: Jason Dobies <jason.dobies(a)redhat.com>
Date: Sun Aug 9 14:29:03 2009 -0400
Revert "478397 - fixing issue where rhnpush would schedule a taskomatic task to
regenerate needed cache and was using a query that didnt generate for all channels (even
though it was deleting from all channels)"
This reverts commit 63d1a527bb70dd4291ba16a123a4f1d2560f9535.
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/ErrataCache_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/ErrataCache_queries.xml
index 7d94edf..c8efb65 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/ErrataCache_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/ErrataCache_queries.xml
@@ -124,8 +124,7 @@ INSERT INTO rhnServerNeededCache
(server_id, package_id, errata_id)
(SELECT DISTINCT SNV.server_id, SNV.package_id, SNV.errata_id
FROM rhnServerNeededView SNV
- WHERE SNV.server_id in (select SC.server_id from rhnServerChannel SC
- where SC.channel_id = :channel_id ))
+ WHERE SNV.channel_id = :channel_id)
</query>
</write-mode>
Show replies by date