You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by vi...@apache.org on 2013/03/20 08:33:59 UTC

svn commit: r1458662 - in /oozie/branches/branch-4.0: client/src/main/java/org/apache/oozie/cli/OozieCLI.java core/src/main/java/org/apache/oozie/SLAEventBean.java core/src/main/java/org/apache/oozie/util/db/SLADbOperations.java release-log.txt

Author: virag
Date: Wed Mar 20 07:33:59 2013
New Revision: 1458662

URL: http://svn.apache.org/r1458662
Log:
OOZIE-1246 appname need to be persisted on SLA event table by SLA status event (ryota via virag)

Modified:
    oozie/branches/branch-4.0/client/src/main/java/org/apache/oozie/cli/OozieCLI.java
    oozie/branches/branch-4.0/core/src/main/java/org/apache/oozie/SLAEventBean.java
    oozie/branches/branch-4.0/core/src/main/java/org/apache/oozie/util/db/SLADbOperations.java
    oozie/branches/branch-4.0/release-log.txt

Modified: oozie/branches/branch-4.0/client/src/main/java/org/apache/oozie/cli/OozieCLI.java
URL: http://svn.apache.org/viewvc/oozie/branches/branch-4.0/client/src/main/java/org/apache/oozie/cli/OozieCLI.java?rev=1458662&r1=1458661&r2=1458662&view=diff
==============================================================================
--- oozie/branches/branch-4.0/client/src/main/java/org/apache/oozie/cli/OozieCLI.java (original)
+++ oozie/branches/branch-4.0/client/src/main/java/org/apache/oozie/cli/OozieCLI.java Wed Mar 20 07:33:59 2013
@@ -365,7 +365,7 @@ public class OozieCLI {
         Option oozie = new Option(OOZIE_OPTION, true, "Oozie URL");
         Option start = new Option(OFFSET_OPTION, true, "start offset (default '0')");
         Option len = new Option(LEN_OPTION, true, "number of results (default '100', max '1000')");
-        Option filter = new Option(FILTER_OPTION, true, "filter of SLA events");
+        Option filter = new Option(FILTER_OPTION, true, "filter of SLA events. e.g., jobid=<J>\\;appname=<A>");
         start.setType(Integer.class);
         len.setType(Integer.class);
         Options slaOptions = new Options();

Modified: oozie/branches/branch-4.0/core/src/main/java/org/apache/oozie/SLAEventBean.java
URL: http://svn.apache.org/viewvc/oozie/branches/branch-4.0/core/src/main/java/org/apache/oozie/SLAEventBean.java?rev=1458662&r1=1458661&r2=1458662&view=diff
==============================================================================
--- oozie/branches/branch-4.0/core/src/main/java/org/apache/oozie/SLAEventBean.java (original)
+++ oozie/branches/branch-4.0/core/src/main/java/org/apache/oozie/SLAEventBean.java Wed Mar 20 07:33:59 2013
@@ -271,6 +271,7 @@ public class SLAEventBean extends JsonSL
         e.addContent(createATagElement("job-data", getJobData()));
         e.addContent(createATagElement("user", getUser()));
         e.addContent(createATagElement("group", getGroupName()));
+        e.addContent(createATagElement("app-name", getAppName()));
         eStat.addContent(e);
         return eStat;
     }

Modified: oozie/branches/branch-4.0/core/src/main/java/org/apache/oozie/util/db/SLADbOperations.java
URL: http://svn.apache.org/viewvc/oozie/branches/branch-4.0/core/src/main/java/org/apache/oozie/util/db/SLADbOperations.java?rev=1458662&r1=1458661&r2=1458662&view=diff
==============================================================================
--- oozie/branches/branch-4.0/core/src/main/java/org/apache/oozie/util/db/SLADbOperations.java (original)
+++ oozie/branches/branch-4.0/core/src/main/java/org/apache/oozie/util/db/SLADbOperations.java Wed Mar 20 07:33:59 2013
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,6 +28,7 @@ import org.apache.oozie.service.Services
 import org.apache.oozie.store.Store;
 import org.apache.oozie.util.DateUtils;
 import org.apache.oozie.util.XLog;
+import org.apache.oozie.util.XmlUtils;
 import org.jdom.Element;
 
 public class SLADbOperations {
@@ -35,19 +36,14 @@ public class SLADbOperations {
 
     public static SLAEventBean createSlaRegistrationEvent(Element eSla, Store store, String slaId, SlaAppType appType, String user,
             String groupName) throws Exception {
-        // System.out.println("BBBBB SLA added");
         if (eSla == null) {
             return null;
         }
-        // System.out.println("Writing REG AAAAA " + slaId);
         SLAEventBean sla = new SLAEventBean();
-        // sla.setClientId(getTagElement( eSla, "client-id"));
-        // sla.setClientId(getClientId());
         sla.setAppName(getTagElement(eSla, "app-name"));
         sla.setParentClientId(getTagElement(eSla, "parent-child-id"));
         sla.setParentSlaId(getTagElement(eSla, "parent-sla-id"));
         String strNominalTime = getTagElement(eSla, "nominal-time");
-        // System.out.println("AAAAA SLA nominal time "+ strNominalTime);
         if (strNominalTime == null || strNominalTime.length() == 0) {
             throw new RuntimeException("Nominal time is required"); // TODO:
             // change to
@@ -66,7 +62,6 @@ public class SLADbOperations {
         else {
             Date expectedStart = new Date(nominalTime.getTime() + relExpectedStart * 60 * 1000);
             sla.setExpectedStart(expectedStart);
-            // sla.setExpectedStart(nominalTime);
         }
 
         // Setting expected end time
@@ -108,19 +103,14 @@ public class SLADbOperations {
     public static SLAEventBean createSlaRegistrationEvent(Element eSla,
                                                  String slaId, SlaAppType appType, String user, String groupName, XLog log)
             throws Exception {
-        // System.out.println("BBBBB SLA added");
         if (eSla == null) {
             return null;
         }
-        //System.out.println("Writing REG AAAAA " + slaId);
         SLAEventBean sla = new SLAEventBean();
-        // sla.setClientId(getTagElement( eSla, "client-id"));
-        // sla.setClientId(getClientId());
         sla.setAppName(getTagElement(eSla, "app-name"));
         sla.setParentClientId(getTagElement(eSla, "parent-child-id"));
         sla.setParentSlaId(getTagElement(eSla, "parent-sla-id"));
         String strNominalTime = getTagElement(eSla, "nominal-time");
-        // System.out.println("AAAAA SLA nominal time "+ strNominalTime);
         if (strNominalTime == null || strNominalTime.length() == 0) {
             throw new RuntimeException("Nominal time is required"); // TODO:
             // change to
@@ -140,7 +130,6 @@ public class SLADbOperations {
             Date expectedStart = new Date(nominalTime.getTime()
                     + relExpectedStart * 60 * 1000);
             sla.setExpectedStart(expectedStart);
-            // sla.setExpectedStart(nominalTime);
         }
 
         // Setting expected end time
@@ -177,60 +166,29 @@ public class SLADbOperations {
         sla.setJobStatus(Status.CREATED);
         sla.setStatusTimestamp(new Date());
 
-        //SLAStore slaStore = (SLAStore) Services.get().get(StoreService.class)
-        //        .getStore(SLAStore.class, store);
-        //slaStore.insertSLAEvent(sla);
-
-        return sla;
-    }
-
-    public static SLAEventBean createSlaStatusEvent(String id,
-                                           Status status, Store store, SlaAppType appType) throws Exception {
-        SLAEventBean sla = new SLAEventBean();
-        sla.setSlaId(id);
-        sla.setJobStatus(status);
-        sla.setAppType(appType);
-        sla.setStatusTimestamp(new Date());
-        //System.out.println("Writing STATUS AAAAA " + id);
-        //SLAStore slaStore = (SLAStore) Services.get().get(StoreService.class)
-                //.getStore(SLAStore.class, store);
-        //slaStore.insertSLAEvent(sla);
         return sla;
     }
 
-    public static SLAEventBean createSlaStatusEvent(String id, Status status, SlaAppType appType, XLog log) throws Exception {
+    public static SLAEventBean createSlaStatusEvent(String id, Status status, SlaAppType appType, String appName,
+            XLog log) throws Exception {
         SLAEventBean sla = new SLAEventBean();
         sla.setSlaId(id);
         sla.setJobStatus(status);
         sla.setAppType(appType);
+        sla.setAppName(appName);
         sla.setStatusTimestamp(new Date());
-        // System.out.println("Writing STATUS AAAAA " + id);
-        //SLAStore slaStore = (SLAStore) Services.get().get(StoreService.class).getStore(SLAStore.class, store);
-        //slaStore.insertSLAEvent(sla);
-
         return sla;
     }
 
-    public static SLAEventBean createStatusEvent(String slaXml, String id, Store store,
-                                       Status stat, SlaAppType appType) throws CommandException {
-        if (slaXml == null || slaXml.length() == 0) {
-            return null;
-        }
-        try {
-            return createSlaStatusEvent(id, stat, store, appType);
-        }
-        catch (Exception e) {
-            throw new CommandException(ErrorCode.E1007, " id " + id, e.getMessage(), e);
-        }
-    }
-
     public static SLAEventBean createStatusEvent(String slaXml, String id, Status stat, SlaAppType appType, XLog log)
             throws CommandException {
         if (slaXml == null || slaXml.length() == 0) {
             return null;
         }
         try {
-            return createSlaStatusEvent(id, stat, appType, log);
+            Element eSla = XmlUtils.parseXml(slaXml);
+            Element eAppName = eSla.getChild("app-name", eSla.getNamespace());
+            return createSlaStatusEvent(id, stat, appType, eAppName.getText(), log);
         }
         catch (Exception e) {
             throw new CommandException(ErrorCode.E1007, " id " + id, e.getMessage(), e);
@@ -245,8 +203,6 @@ public class SLADbOperations {
         String clientId = services.getConf().get(CLIENT_ID_TAG,
                                                  "oozie-default-instance"); // TODO" remove default
         if (clientId == null) {
-            //System.out.println("CONF "
-            //       + XmlUtils.prettyPrint(services.getConf()));
             throw new RuntimeException(
                     "No SLA_CLIENT_ID defined in oozie-site.xml with property name "
                             + CLIENT_ID_TAG);

Modified: oozie/branches/branch-4.0/release-log.txt
URL: http://svn.apache.org/viewvc/oozie/branches/branch-4.0/release-log.txt?rev=1458662&r1=1458661&r2=1458662&view=diff
==============================================================================
--- oozie/branches/branch-4.0/release-log.txt (original)
+++ oozie/branches/branch-4.0/release-log.txt Wed Mar 20 07:33:59 2013
@@ -1,5 +1,6 @@
 -- Oozie 4.0.0 (unreleased)
 
+OOZIE-1246 appname need to be persisted on SLA event table by SLA status event (ryota via virag)
 OOZIE-1270 Querying job directly does not pop correct information for coordinator and bundle (rohini via virag)
 OOZIE-1269 Exception in push dependency check when there is also a pull dependency leaves it in waiting till timeout (rohini via virag)
 OOZIE-1267 Dryrun option for push missing deps (virag)