Author: mona
Date: Fri Jun 21 15:02:03 2013
New Revision: 1495465

URL: http://svn.apache.org/r1495465
Log:
OOZIE-1423 Coordinator job change command not removing SLA Registration bean 
(mona)

Modified:
    
oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordChangeXCommand.java
    oozie/trunk/core/src/main/java/org/apache/oozie/sla/SLACalculator.java
    oozie/trunk/core/src/main/java/org/apache/oozie/sla/SLACalculatorMemory.java
    oozie/trunk/core/src/main/java/org/apache/oozie/sla/SLAOperations.java
    oozie/trunk/core/src/main/java/org/apache/oozie/sla/service/SLAService.java

Modified: 
oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordChangeXCommand.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordChangeXCommand.java?rev=1495465&r1=1495464&r2=1495465&view=diff
==============================================================================
--- 
oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordChangeXCommand.java
 (original)
+++ 
oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordChangeXCommand.java
 Fri Jun 21 15:02:03 2013
@@ -43,8 +43,11 @@ import org.apache.oozie.executor.jpa.Coo
 import 
org.apache.oozie.executor.jpa.CoordJobGetActionByActionNumberJPAExecutor;
 import org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor;
 import org.apache.oozie.executor.jpa.JPAExecutorException;
+import org.apache.oozie.executor.jpa.sla.SLARegistrationGetJPAExecutor;
 import org.apache.oozie.service.JPAService;
 import org.apache.oozie.service.Services;
+import org.apache.oozie.sla.SLARegistrationBean;
+import org.apache.oozie.sla.service.SLAService;
 import org.apache.oozie.util.DateUtils;
 import org.apache.oozie.util.JobUtils;
 import org.apache.oozie.util.LogUtils;
@@ -257,8 +260,17 @@ public class CoordChangeXCommand extends
         try {
             String actionId = jpaService.execute(new 
CoordJobGetActionByActionNumberJPAExecutor(jobId, actionNum));
             CoordinatorActionBean bean = jpaService.execute(new 
CoordActionGetJPAExecutor(actionId));
+            // delete SLA registration entry (if any) for action
+            if (SLAService.isEnabled()) {
+                Services.get().get(SLAService.class).removeRegistration(jobId);
+            }
+            SLARegistrationBean slaReg = jpaService.execute(new 
SLARegistrationGetJPAExecutor(jobId));
+            if (slaReg != null) {
+                deleteList.add(slaReg);
+            }
             deleteList.add(bean);
-        } catch (JPAExecutorException e) {
+        }
+        catch (JPAExecutorException e) {
             throw new CommandException(e);
         }
     }

Modified: oozie/trunk/core/src/main/java/org/apache/oozie/sla/SLACalculator.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/sla/SLACalculator.java?rev=1495465&r1=1495464&r2=1495465&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/sla/SLACalculator.java 
(original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/sla/SLACalculator.java Fri 
Jun 21 15:02:03 2013
@@ -37,6 +37,8 @@ public interface SLACalculator {
 
     boolean addRegistration(String jobId, SLARegistrationBean reg) throws 
JPAExecutorException;
 
+    void removeRegistration(String jobId);
+
     boolean addJobStatus(String jobId, String jobStatus, EventStatus 
jobEventStatus, Date startTime, Date endTime)
             throws JPAExecutorException, ServiceException;
 

Modified: 
oozie/trunk/core/src/main/java/org/apache/oozie/sla/SLACalculatorMemory.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/sla/SLACalculatorMemory.java?rev=1495465&r1=1495464&r2=1495465&view=diff
==============================================================================
--- 
oozie/trunk/core/src/main/java/org/apache/oozie/sla/SLACalculatorMemory.java 
(original)
+++ 
oozie/trunk/core/src/main/java/org/apache/oozie/sla/SLACalculatorMemory.java 
Fri Jun 21 15:02:03 2013
@@ -439,6 +439,16 @@ public class SLACalculatorMemory impleme
     }
 
     /**
+     * Remove job from being tracked in map
+     */
+    @Override
+    public void removeRegistration(String jobId) {
+        if (slaMap.remove(jobId) == null) {
+            historySet.remove(jobId);
+        }
+    }
+
+    /**
      * Triggered after receiving Job status change event, update SLA status
      * accordingly
      */

Modified: oozie/trunk/core/src/main/java/org/apache/oozie/sla/SLAOperations.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/sla/SLAOperations.java?rev=1495465&r1=1495464&r2=1495465&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/sla/SLAOperations.java 
(original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/sla/SLAOperations.java Fri 
Jun 21 15:02:03 2013
@@ -33,6 +33,7 @@ import org.apache.oozie.sla.SLARegistrat
 import org.apache.oozie.sla.service.SLAService;
 import org.apache.oozie.util.DateUtils;
 import org.apache.oozie.util.XLog;
+import org.apache.oozie.util.XmlUtils;
 import org.jdom.Element;
 
 public class SLAOperations {
@@ -150,6 +151,7 @@ public class SLAOperations {
             throw new CommandException(ErrorCode.E1007, " id " + jobId, 
e.getMessage(), e);
         }
 
+        log.debug("Job [{0}] reg for SLA. Size of Sla Xml = [{1}]", jobId, 
XmlUtils.prettyPrint(eSla).toString());
         return sla;
     }
 

Modified: 
oozie/trunk/core/src/main/java/org/apache/oozie/sla/service/SLAService.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/sla/service/SLAService.java?rev=1495465&r1=1495464&r2=1495465&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/sla/service/SLAService.java 
(original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/sla/service/SLAService.java 
Fri Jun 21 15:02:03 2013
@@ -164,4 +164,8 @@ public class SLAService implements Servi
         return false;
     }
 
+    public void removeRegistration(String jobId) {
+        calcImpl.removeRegistration(jobId);
+    }
+
 }


Reply via email to