You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by mo...@apache.org on 2013/05/20 18:51:39 UTC
svn commit: r1484523 [2/5] - in /oozie/trunk: ./
client/src/main/java/org/apache/oozie/
client/src/main/java/org/apache/oozie/cli/
client/src/main/java/org/apache/oozie/client/
client/src/main/java/org/apache/oozie/client/event/
client/src/main/java/or...
Added: oozie/trunk/core/src/main/java/org/apache/oozie/client/rest/sla/JsonSLARegistrationEvent.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/client/rest/sla/JsonSLARegistrationEvent.java?rev=1484523&view=auto
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/client/rest/sla/JsonSLARegistrationEvent.java (added)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/client/rest/sla/JsonSLARegistrationEvent.java Mon May 20 16:51:37 2013
@@ -0,0 +1,314 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oozie.client.rest.sla;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.StringTokenizer;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorType;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import org.apache.oozie.AppType;
+import org.apache.oozie.client.event.SLAEvent;
+import org.apache.oozie.client.rest.JsonBean;
+import org.apache.openjpa.persistence.jdbc.Index;
+import org.json.simple.JSONObject;
+
+@Entity
+@Table(name = "SLA_REGISTRATION")
+@DiscriminatorColumn(name = "bean_type", discriminatorType = DiscriminatorType.STRING)
+public class JsonSLARegistrationEvent extends SLAEvent implements JsonBean {
+
+ @Id
+ @Basic
+ @Index
+ @Column(name = "job_id")
+ private String jobId;
+
+ @Transient
+ private AppType appType = null;
+
+ @Basic
+ @Column(name = "app_name")
+ private String appName = null;
+
+ @Basic
+ @Column(name = "user_name")
+ private String user = null;
+
+ @Transient
+ private Date nominalTime = null;
+
+ @Transient
+ private Date expectedStart = null;
+
+ @Transient
+ private Date expectedEnd = null;
+
+ @Basic
+ @Column(name = "expected_duration")
+ private long expectedDuration = 0;
+
+ @Basic
+ @Column(name = "job_data")
+ private String jobData = null;
+
+ @Basic
+ @Column(name = "parent_id")
+ private String parentId = null;
+
+ @Basic
+ @Column(name = "notification_msg")
+ private String notificationMsg = null;
+
+ @Basic
+ @Column(name = "upstream_apps")
+ private String upstreamApps = null;
+
+ @Basic
+ @Column(name = "sla_config")
+ private String slaConfig = null;
+
+ @Transient
+ private Map<String, String> slaConfigMap;
+ private final String ALERT_EVENTS = "alert_events";
+ private final String ALERT_CONTACT = "alert_contact";
+
+ public JsonSLARegistrationEvent() {
+ slaConfigMap = new HashMap<String, String>();
+ msgType = MessageType.SLA;
+ }
+
+ public JsonSLARegistrationEvent(JSONObject json) {
+ this();
+ // TODO read jsonobject
+ }
+
+ @Override
+ public String getJobId() {
+ return jobId;
+ }
+
+ public void setJobId(String jobId) {
+ this.jobId = jobId;
+ }
+
+ @Override
+ public AppType getAppType() {
+ return appType;
+ }
+
+ public void setAppType(AppType appType) {
+ this.appType = appType;
+ }
+
+ @Override
+ public String getAppName() {
+ return appName;
+ }
+
+ public void setAppName(String appName) {
+ this.appName = appName;
+ }
+
+ @Override
+ public String getUser() {
+ return user;
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ @Override
+ public Date getNominalTime() {
+ return nominalTime;
+ }
+
+ public void setNominalTime(Date nomTime) {
+ this.nominalTime = nomTime;
+ }
+
+ @Override
+ public Date getExpectedStart() {
+ return expectedStart;
+ }
+
+ public void setExpectedStart(Date expectedStart) {
+ this.expectedStart = expectedStart;
+ }
+
+ @Override
+ public Date getExpectedEnd() {
+ return expectedEnd;
+ }
+
+ public void setExpectedEnd(Date expectedEnd) {
+ this.expectedEnd = expectedEnd;
+ }
+
+ @Override
+ public long getExpectedDuration() {
+ return expectedDuration;
+ }
+
+ public void setExpectedDuration(long expectedDuration) {
+ this.expectedDuration = expectedDuration;
+ }
+
+ @Override
+ public String getParentId() {
+ return parentId;
+ }
+
+ public void setParentId(String parentId) {
+ this.parentId = parentId;
+ }
+
+ @Override
+ public String getNotificationMsg() {
+ return notificationMsg;
+ }
+
+ public void setNotificationMsg(String notificationMsg) {
+ this.notificationMsg = notificationMsg;
+ }
+
+ @Override
+ public String getAlertEvents() {
+ return slaConfigMap.get(ALERT_EVENTS);
+ }
+
+ public void setAlertEvents(String alertEvents) {
+ slaConfigMap.put(ALERT_EVENTS, alertEvents);
+ slaConfig = slaConfigMapToString();
+ }
+
+ @Override
+ public String getAlertContact() {
+ return slaConfigMap.get(ALERT_CONTACT);
+ }
+
+ public void setAlertContact(String alertContact) {
+ slaConfigMap.put(ALERT_CONTACT, alertContact);
+ slaConfig = slaConfigMapToString();
+ }
+
+ @Override
+ public String getUpstreamApps() {
+ return upstreamApps;
+ }
+
+ public void setUpstreamApps(String upstreamApps) {
+ this.upstreamApps = upstreamApps;
+ }
+
+ @Override
+ public String getJobData() {
+ return jobData;
+ }
+
+ public void setJobData(String jobData) {
+ this.jobData = jobData;
+ }
+
+ public Map<String, String> getSlaConfigMap() {
+ return slaConfigMap;
+ }
+
+ @Override
+ public String getSlaConfig() {
+ return slaConfig;
+ }
+
+ public void setSlaConfig(String configStr) {
+ this.slaConfig = configStr;
+ slaConfigStringToMap();
+ }
+
+ @Override
+ public SLAStatus getSLAStatus() {
+ return null;
+ }
+
+ @Override
+ public EventStatus getEventStatus() {
+ return null;
+ }
+
+ @Override
+ public Date getActualStart() {
+ return null;
+ }
+
+ @Override
+ public Date getActualEnd() {
+ return null;
+ }
+
+ @Override
+ public long getActualDuration() {
+ return 0;
+ }
+
+ @Override
+ public String getJobStatus() {
+ return null;
+ }
+
+ private void slaConfigStringToMap() {
+ StringTokenizer st = new StringTokenizer(slaConfig, "},");
+ while (st.hasMoreTokens()) {
+ String token = st.nextToken();
+ String[] pair = token.split("=");
+ if (pair.length == 2) {
+ slaConfigMap.put(pair[0].substring(1), pair[1]);
+ }
+ }
+ }
+
+ public String slaConfigMapToString() {
+ StringBuilder sb = new StringBuilder();
+ for (Entry<String, String> e : slaConfigMap.entrySet()) {
+ sb.append("{" + e.getKey() + "=" + e.getValue() + "},");
+ }
+ return sb.toString();
+ }
+
+ @Override
+ public JSONObject toJSONObject() {
+ // TODO
+ return null;
+ }
+
+ @Override
+ public JSONObject toJSONObject(String timeZoneId) {
+ // TODO
+ return null;
+ }
+
+}
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/command/TransitionXCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/TransitionXCommand.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/command/TransitionXCommand.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/command/TransitionXCommand.java Mon May 20 16:51:37 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.
@@ -20,8 +20,12 @@ package org.apache.oozie.command;
import java.util.ArrayList;
import java.util.List;
+import org.apache.oozie.CoordinatorActionBean;
+import org.apache.oozie.CoordinatorJobBean;
import org.apache.oozie.client.Job;
import org.apache.oozie.client.rest.JsonBean;
+import org.apache.oozie.command.coord.CoordinatorXCommand;
+import org.apache.oozie.service.EventHandlerService;
import org.apache.oozie.util.ParamChecker;
/**
@@ -66,6 +70,25 @@ public abstract class TransitionXCommand
public abstract void notifyParent() throws CommandException;
/**
+ * This will be used to generate Job Notification events on status changes
+ *
+ * @param user
+ * @param appName
+ * @param em
+ * @throws CommandException
+ */
+ public void generateEvents(CoordinatorJobBean coordJob) throws CommandException {
+ for (JsonBean actionBean : updateList) {
+ if (actionBean instanceof CoordinatorActionBean) {
+ if (EventHandlerService.isEnabled()) {
+ CoordinatorXCommand.generateEvent((CoordinatorActionBean) actionBean, coordJob.getUser(),
+ coordJob.getAppName());
+ }
+ }
+ }
+ }
+
+ /**
* This will be used to perform atomically all the writes within this command.
*
* @throws CommandException
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionCheckXCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionCheckXCommand.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionCheckXCommand.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionCheckXCommand.java Mon May 20 16:51:37 2013
@@ -50,6 +50,7 @@ import org.apache.oozie.executor.jpa.Wor
/**
* The command checks workflow status for coordinator action.
*/
+@SuppressWarnings("deprecation")
public class CoordActionCheckXCommand extends CoordinatorXCommand<Void> {
private String actionId;
private int actionCheckDelay;
@@ -118,7 +119,7 @@ public class CoordActionCheckXCommand ex
}
jpaService.execute(new BulkUpdateInsertForCoordActionStatusJPAExecutor(updateList, insertList));
- if (EventHandlerService.isEventsConfigured()) {
+ if (EventHandlerService.isEnabled()) {
CoordinatorJobBean coordJob = jpaService.execute(new CoordinatorJobGetForUserAppnameJPAExecutor(
coordAction.getJobId()));
generateEvent(coordAction, coordJob.getUser(), coordJob.getAppName());
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionInputCheckXCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionInputCheckXCommand.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionInputCheckXCommand.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionInputCheckXCommand.java Mon May 20 16:51:37 2013
@@ -212,7 +212,7 @@ public class CoordActionInputCheckXComma
try {
if (isChangeInDependency) {
jpaService.execute(new CoordActionUpdateForInputCheckJPAExecutor(coordAction));
- if (EventHandlerService.isEventsConfigured()
+ if (EventHandlerService.isEnabled()
&& coordAction.getStatus() != CoordinatorAction.Status.READY) {
//since event is not to be generated unless action RUNNING via StartX
generateEvent(coordAction, coordJob.getUser(), coordJob.getAppName());
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionMaterializeCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionMaterializeCommand.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionMaterializeCommand.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionMaterializeCommand.java Mon May 20 16:51:37 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.
@@ -26,6 +26,7 @@ import java.util.List;
import java.util.TimeZone;
import org.apache.hadoop.conf.Configuration;
+import org.apache.oozie.AppType;
import org.apache.oozie.CoordinatorActionBean;
import org.apache.oozie.CoordinatorJobBean;
import org.apache.oozie.ErrorCode;
@@ -45,13 +46,14 @@ import org.apache.oozie.store.Coordinato
import org.apache.oozie.store.StoreException;
import org.apache.oozie.util.DateUtils;
import org.apache.oozie.util.Instrumentation;
+import org.apache.oozie.sla.SLAOperations;
import org.apache.oozie.util.XConfiguration;
import org.apache.oozie.util.XLog;
import org.apache.oozie.util.XmlUtils;
import org.apache.oozie.util.db.SLADbOperations;
import org.jdom.Element;
-import org.jdom.JDOMException;
+@SuppressWarnings("deprecation")
public class CoordActionMaterializeCommand extends CoordinatorCommand<Void> {
private String jobId;
private Date startTime;
@@ -218,7 +220,7 @@ public class CoordActionMaterializeComma
actionBean.setTimeOut(timeout);
if (!dryrun) {
- storeToDB(actionBean, action, store); // Storing to table
+ storeToDB(actionBean, action, store, jobBean.getAppName()); // Storing to table
}
else {
actionStrings.append("action for new instance");
@@ -244,15 +246,15 @@ public class CoordActionMaterializeComma
* @param actionBean
* @param actionXml
* @param store
- * @param wantSla
- * @throws StoreException
- * @throws JDOMException
+ * @param appName
+ * @throws Exception
*/
- private void storeToDB(CoordinatorActionBean actionBean, String actionXml, CoordinatorStore store) throws Exception {
+ private void storeToDB(CoordinatorActionBean actionBean, String actionXml, CoordinatorStore store, String appName)
+ throws Exception {
log.debug("In storeToDB() action Id " + actionBean.getId() + " Size of actionXml " + actionXml.length());
actionBean.setActionXml(actionXml);
insertList.add(actionBean);
- createActionRegistration(actionXml, actionBean, store);
+ createActionRegistration(actionXml, actionBean, store, appName);
// TODO: time 100s should be configurable
queueCallable(new CoordActionNotificationXCommand(actionBean), 100);
@@ -263,10 +265,11 @@ public class CoordActionMaterializeComma
* @param actionXml
* @param actionBean
* @param store
+ * @param appName
* @throws Exception
*/
- private void createActionRegistration(String actionXml, CoordinatorActionBean actionBean, CoordinatorStore store)
- throws Exception {
+ private void createActionRegistration(String actionXml, CoordinatorActionBean actionBean, CoordinatorStore store,
+ String appName) throws Exception {
Element eAction = XmlUtils.parseXml(actionXml);
Element eSla = eAction.getChild("action", eAction.getNamespace()).getChild("info", eAction.getNamespace("sla"));
SLAEventBean slaEvent = SLADbOperations.createSlaRegistrationEvent(eSla, store, actionBean.getId(),
@@ -274,6 +277,9 @@ public class CoordActionMaterializeComma
if(slaEvent != null) {
insertList.add(slaEvent);
}
+ // insert into new sla reg table too
+ SLAOperations.createSlaRegistrationEvent(eSla, actionBean.getId(), actionBean.getJobId(),
+ AppType.COORDINATOR_ACTION, user, appName, log);
}
/**
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionStartXCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionStartXCommand.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionStartXCommand.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionStartXCommand.java Mon May 20 16:51:37 2013
@@ -44,7 +44,6 @@ import org.apache.oozie.client.SLAEvent.
import org.apache.oozie.client.SLAEvent.Status;
import org.apache.oozie.client.rest.JsonBean;
import org.apache.oozie.executor.jpa.BulkUpdateInsertForCoordActionStartJPAExecutor;
-import org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor;
import org.apache.oozie.executor.jpa.JPAExecutorException;
import org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor;
import org.jdom.Element;
@@ -56,6 +55,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+@SuppressWarnings("deprecation")
public class CoordActionStartXCommand extends CoordinatorXCommand<Void> {
public static final String EL_ERROR = "EL_ERROR";
@@ -122,7 +122,7 @@ public class CoordActionStartXCommand ex
// extract 'property' tags under 'configuration' block in the
// coordinator.xml (saved in actionxml column)
// convert Element to XConfiguration
- Element configElement = (Element) workflowProperties.getChild("action", workflowProperties.getNamespace())
+ Element configElement = workflowProperties.getChild("action", workflowProperties.getNamespace())
.getChild("workflow", workflowProperties.getNamespace()).getChild("configuration",
workflowProperties.getNamespace());
if (configElement != null) {
@@ -194,7 +194,7 @@ public class CoordActionStartXCommand ex
updateList.add(coordAction);
try {
jpaService.execute(new BulkUpdateInsertForCoordActionStartJPAExecutor(updateList, insertList));
- if (EventHandlerService.isEventsConfigured()) {
+ if (EventHandlerService.isEnabled()) {
generateEvent(coordAction, user, appName);
}
}
@@ -250,7 +250,7 @@ public class CoordActionStartXCommand ex
try {
// call JPAExecutor to do the bulk writes
jpaService.execute(new BulkUpdateInsertForCoordActionStartJPAExecutor(updateList, insertList));
- if (EventHandlerService.isEventsConfigured()) {
+ if (EventHandlerService.isEnabled()) {
generateEvent(coordAction, user, appName);
}
}
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionTimeOutXCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionTimeOutXCommand.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionTimeOutXCommand.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionTimeOutXCommand.java Mon May 20 16:51:37 2013
@@ -25,7 +25,6 @@ import org.apache.oozie.client.Coordinat
import org.apache.oozie.command.CommandException;
import org.apache.oozie.command.PreconditionException;
import org.apache.oozie.executor.jpa.CoordActionGetForTimeoutJPAExecutor;
-import org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor;
import org.apache.oozie.executor.jpa.JPAExecutorException;
import org.apache.oozie.service.EventHandlerService;
import org.apache.oozie.service.JPAService;
@@ -60,7 +59,7 @@ public class CoordActionTimeOutXCommand
queue(new CoordActionNotificationXCommand(actionBean), 100);
actionBean.setLastModifiedTime(new Date());
jpaService.execute(new org.apache.oozie.executor.jpa.CoordActionUpdateStatusJPAExecutor(actionBean));
- if (EventHandlerService.isEventsConfigured()) {
+ if (EventHandlerService.isEnabled()) {
generateEvent(actionBean, user, appName);
}
}
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionUpdateXCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionUpdateXCommand.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionUpdateXCommand.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordActionUpdateXCommand.java Mon May 20 16:51:37 2013
@@ -44,6 +44,7 @@ import org.apache.oozie.executor.jpa.Coo
import org.apache.oozie.executor.jpa.CoordinatorJobGetForUserAppnameJPAExecutor;
import org.apache.oozie.executor.jpa.JPAExecutorException;
+@SuppressWarnings("deprecation")
public class CoordActionUpdateXCommand extends CoordinatorXCommand<Void> {
private WorkflowJobBean workflow;
private CoordinatorActionBean coordAction = null;
@@ -133,7 +134,7 @@ public class CoordActionUpdateXCommand e
}
jpaService.execute(new BulkUpdateInsertForCoordActionStatusJPAExecutor(updateList, insertList));
- if (EventHandlerService.isEventsConfigured()) {
+ if (EventHandlerService.isEnabled()) {
CoordinatorJobBean coordJob = jpaService.execute(new CoordinatorJobGetForUserAppnameJPAExecutor(coordAction
.getJobId()));
generateEvent(coordAction, coordJob.getUser(), coordJob.getAppName());
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordKillXCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordKillXCommand.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordKillXCommand.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordKillXCommand.java Mon May 20 16:51:37 2013
@@ -168,6 +168,7 @@ public class CoordKillXCommand extends K
public void performWrites() throws CommandException {
try {
jpaService.execute(new BulkUpdateInsertForCoordActionStatusJPAExecutor(updateList, null));
+ generateEvents(coordJob);
}
catch (JPAExecutorException e) {
throw new CommandException(e);
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordMaterializeTransitionXCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordMaterializeTransitionXCommand.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordMaterializeTransitionXCommand.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordMaterializeTransitionXCommand.java Mon May 20 16:51:37 2013
@@ -25,6 +25,7 @@ import java.util.Date;
import java.util.TimeZone;
import org.apache.hadoop.conf.Configuration;
+import org.apache.oozie.AppType;
import org.apache.oozie.CoordinatorActionBean;
import org.apache.oozie.CoordinatorJobBean;
import org.apache.oozie.ErrorCode;
@@ -50,6 +51,7 @@ import org.apache.oozie.util.DateUtils;
import org.apache.oozie.util.Instrumentation;
import org.apache.oozie.util.LogUtils;
import org.apache.oozie.util.ParamChecker;
+import org.apache.oozie.sla.SLAOperations;
import org.apache.oozie.util.StatusUtils;
import org.apache.oozie.util.XConfiguration;
import org.apache.oozie.util.XmlUtils;
@@ -59,6 +61,7 @@ import org.jdom.Element;
/**
* Materialize actions for specified start and end time for coordinator job.
*/
+@SuppressWarnings("deprecation")
public class CoordMaterializeTransitionXCommand extends MaterializeTransitionXCommand {
private static final int LOOKAHEAD_WINDOW = 300; // We look ahead 5 minutes for materialization;
private JPAService jpaService = null;
@@ -112,7 +115,7 @@ public class CoordMaterializeTransitionX
for (JsonBean actionBean : insertList) {
if (actionBean instanceof CoordinatorActionBean) {
CoordinatorActionBean coordAction = (CoordinatorActionBean) actionBean;
- if (EventHandlerService.isEventsConfigured()) {
+ if (EventHandlerService.isEnabled()) {
CoordinatorXCommand.generateEvent(coordAction, coordJob.getUser(), coordJob.getAppName());
}
if (coordAction.getPushMissingDependencies() != null) {
@@ -385,6 +388,9 @@ public class CoordMaterializeTransitionX
if(slaEvent != null) {
insertList.add(slaEvent);
}
+ // inserting into new table also
+ SLAOperations.createSlaRegistrationEvent(eSla, actionBean.getId(), actionBean.getJobId(),
+ AppType.COORDINATOR_ACTION, coordJob.getUser(), coordJob.getAppName(), LOG);
}
private void updateJobMaterializeInfo(CoordinatorJobBean job) throws CommandException {
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordPushDependencyCheckXCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordPushDependencyCheckXCommand.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordPushDependencyCheckXCommand.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordPushDependencyCheckXCommand.java Mon May 20 16:51:37 2013
@@ -253,7 +253,7 @@ public class CoordPushDependencyCheckXCo
try {
if (isChangeInDependency) {
jpaService.execute(new CoordActionUpdatePushInputCheckJPAExecutor(coordAction));
- if (EventHandlerService.isEventsConfigured()
+ if (EventHandlerService.isEnabled()
&& coordAction.getStatus() != CoordinatorAction.Status.READY) {
//since event is not to be generated unless action RUNNING via StartX
generateEvent(coordAction, coordJob.getUser(), coordJob.getAppName());
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordRerunXCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordRerunXCommand.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordRerunXCommand.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordRerunXCommand.java Mon May 20 16:51:37 2013
@@ -70,6 +70,7 @@ import org.jdom.JDOMException;
* <p/>
* The "noCleanup" is used to indicate if user wants to cleanup output events for given rerun actions
*/
+@SuppressWarnings("deprecation")
public class CoordRerunXCommand extends RerunTransitionXCommand<CoordinatorActionInfo> {
private String rerunType;
@@ -406,7 +407,7 @@ public class CoordRerunXCommand extends
public void performWrites() throws CommandException {
try {
jpaService.execute(new BulkUpdateInsertJPAExecutor(updateList, insertList));
- if (EventHandlerService.isEventsConfigured()) {
+ if (EventHandlerService.isEnabled()) {
for (JsonBean bean : updateList) {
if (bean instanceof CoordinatorActionBean) {
CoordinatorXCommand.generateEvent((CoordinatorActionBean) bean, coordJob.getUser(),
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordSubmitXCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordSubmitXCommand.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordSubmitXCommand.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordSubmitXCommand.java Mon May 20 16:51:37 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.
@@ -214,12 +214,12 @@ public class CoordSubmitXCommand extends
LOG.debug("jobXml after initial validation " + XmlUtils.prettyPrint(appXml).toString());
Element eXml = XmlUtils.parseXml(appXml);
-
+
String appNamespace = readAppNamespace(eXml);
coordJob.setAppNamespace(appNamespace);
ParameterVerifier.verifyParameters(conf, eXml);
-
+
appXml = XmlUtils.removeComments(appXml);
initEvaluators();
Element eJob = basicResolveAndIncludeDS(appXml, conf, coordJob);
@@ -748,8 +748,7 @@ public class CoordSubmitXCommand extends
* @throws CommandException thrown if failed to resolve sla events
*/
private void resolveSLA(Element eAppXml, CoordinatorJobBean coordJob) throws CommandException {
- Element eSla = eAppXml.getChild("action", eAppXml.getNamespace()).getChild("info",
- Namespace.getNamespace(SchemaService.SLA_NAME_SPACE_URI));
+ Element eSla = XmlUtils.getSLAElement(eAppXml.getChild("action", eAppXml.getNamespace()));
if (eSla != null) {
String slaXml = XmlUtils.prettyPrint(eSla).toString();
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordSuspendXCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordSuspendXCommand.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordSuspendXCommand.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordSuspendXCommand.java Mon May 20 16:51:37 2013
@@ -185,6 +185,7 @@ public class CoordSuspendXCommand extend
public void performWrites() throws CommandException {
try {
jpaService.execute(new BulkUpdateInsertForCoordActionStatusJPAExecutor(updateList, null));
+ generateEvents(coordJob);
}
catch (JPAExecutorException jex) {
throw new CommandException(jex);
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordinatorXCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordinatorXCommand.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordinatorXCommand.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/CoordinatorXCommand.java Mon May 20 16:51:37 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.
@@ -19,12 +19,11 @@ package org.apache.oozie.command.coord;
import org.apache.oozie.CoordinatorActionBean;
import org.apache.oozie.CoordinatorJobBean;
-import org.apache.oozie.client.event.Event.AppType;
+import org.apache.oozie.AppType;
import org.apache.oozie.command.XCommand;
import org.apache.oozie.coord.CoordELFunctions;
import org.apache.oozie.event.CoordinatorActionEvent;
import org.apache.oozie.event.CoordinatorJobEvent;
-import org.apache.oozie.util.ParamChecker;
/**
* Abstract coordinator command class derived from XCommand
@@ -54,11 +53,8 @@ public abstract class CoordinatorXComman
super(name, type, priority, dryrun);
}
- protected static void generateEvent(CoordinatorActionBean coordAction, String user, String appName) {
- if (eventService.checkSupportedApptype(AppType.COORDINATOR_ACTION.name())) {
- ParamChecker.notNull(coordAction, "coordAction");
- ParamChecker.notNull(user, "user");
- ParamChecker.notNull(appName, "appName");
+ public static void generateEvent(CoordinatorActionBean coordAction, String user, String appName) {
+ if (eventService.isSupportedApptype(AppType.COORDINATOR_ACTION.name())) {
String missDep = coordAction.getMissingDependencies();
if (missDep != null && missDep.length() > 0) {
missDep = missDep.split(CoordELFunctions.INSTANCE_SEPARATOR)[0];
@@ -79,8 +75,7 @@ public abstract class CoordinatorXComman
}
protected void generateEvent(CoordinatorJobBean coordJob) {
- if (eventService.checkSupportedApptype(AppType.COORDINATOR_JOB.name())) {
- ParamChecker.notNull(coordJob, "coordJob");
+ if (eventService.isSupportedApptype(AppType.COORDINATOR_JOB.name())) {
CoordinatorJobEvent event = new CoordinatorJobEvent(coordJob.getId(), coordJob.getBundleId(),
coordJob.getStatus(), coordJob.getUser(), coordJob.getAppName(), coordJob.getStartTime(),
coordJob.getEndTime());
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/SLAEventsXCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/SLAEventsXCommand.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/SLAEventsXCommand.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/command/coord/SLAEventsXCommand.java Mon May 20 16:51:37 2013
@@ -35,6 +35,7 @@ import org.apache.oozie.service.Services
* The command to get a list of SLAEvents which are greater than given seqId.
*
*/
+@SuppressWarnings("deprecation")
public class SLAEventsXCommand extends XCommand<List<SLAEventBean>> {
private long seqId = 0;
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/ActionEndXCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/ActionEndXCommand.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/ActionEndXCommand.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/ActionEndXCommand.java Mon May 20 16:51:37 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.
@@ -53,6 +53,7 @@ import org.apache.oozie.util.XLog;
import org.apache.oozie.util.db.SLADbXOperations;
import org.apache.oozie.workflow.WorkflowInstance;
+@SuppressWarnings("deprecation")
public class ActionEndXCommand extends ActionXCommand<Void> {
public static final String COULD_NOT_END = "COULD_NOT_END";
public static final String END_DATA_MISSING = "END_DATA_MISSING";
@@ -177,7 +178,7 @@ public class ActionEndXCommand extends A
} else {
wfAction.setRetries(0);
wfAction.setEndTime(new Date());
-
+
boolean shouldHandleUserRetry = false;
Status slaStatus = null;
switch (wfAction.getStatus()) {
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/KillXCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/KillXCommand.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/KillXCommand.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/KillXCommand.java Mon May 20 16:51:37 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.
@@ -52,6 +52,7 @@ import java.util.List;
* Kill workflow job and its workflow instance and queue a {@link WorkflowActionKillXCommand} to kill the workflow
* actions.
*/
+@SuppressWarnings("deprecation")
public class KillXCommand extends WorkflowXCommand<Void> {
private String wfId;
@@ -156,8 +157,8 @@ public class KillXCommand extends Workfl
wfJob.setLastModifiedTime(new Date());
updateList.add(wfJob);
jpaService.execute(new BulkUpdateInsertJPAExecutor(updateList, insertList));
- if (EventHandlerService.isEventsConfigured()) {
- generateEvent(wfJob, null, null);
+ if (EventHandlerService.isEnabled()) {
+ generateEvent(wfJob);
}
queue(new NotificationXCommand(wfJob));
}
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/ResumeXCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/ResumeXCommand.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/ResumeXCommand.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/ResumeXCommand.java Mon May 20 16:51:37 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.
@@ -130,7 +130,7 @@ public class ResumeXCommand extends Work
workflow.setLastModifiedTime(new Date());
updateList.add(workflow);
jpaService.execute(new BulkUpdateInsertJPAExecutor(updateList, null));
- if (EventHandlerService.isEventsConfigured()) {
+ if (EventHandlerService.isEnabled()) {
generateEvent(workflow);
}
queue(new NotificationXCommand(workflow));
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SignalXCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SignalXCommand.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SignalXCommand.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SignalXCommand.java Mon May 20 16:51:37 2013
@@ -39,7 +39,6 @@ import org.apache.oozie.executor.jpa.Wor
import org.apache.oozie.service.ELService;
import org.apache.oozie.service.EventHandlerService;
import org.apache.oozie.service.JPAService;
-import org.apache.oozie.service.SchemaService;
import org.apache.oozie.service.Services;
import org.apache.oozie.service.UUIDService;
import org.apache.oozie.service.WorkflowStoreService;
@@ -55,8 +54,6 @@ import org.apache.oozie.util.ParamChecke
import org.apache.oozie.util.XmlUtils;
import org.apache.oozie.util.db.SLADbXOperations;
import org.jdom.Element;
-import org.jdom.Namespace;
-
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Date;
@@ -64,6 +61,7 @@ import java.util.List;
import java.util.Map;
import org.apache.oozie.client.OozieClient;
+@SuppressWarnings("deprecation")
public class SignalXCommand extends WorkflowXCommand<Void> {
protected static final String INSTR_SUCCEEDED_JOBS_COUNTER_NAME = "succeeded";
@@ -312,12 +310,12 @@ public class SignalXCommand extends Work
updateList.add(wfJob);
// call JPAExecutor to do the bulk writes
jpaService.execute(new BulkUpdateInsertJPAExecutor(updateList, insertList));
- if (EventHandlerService.isEventsConfigured()) {
+ if (EventHandlerService.isEnabled()) {
if (wfAction != null) {
generateEvent(wfJob, wfAction.getErrorCode(), wfAction.getErrorMessage());
}
else {
- generateEvent(wfJob, null, null);
+ generateEvent(wfJob);
}
}
}
@@ -352,7 +350,7 @@ public class SignalXCommand extends Work
if (action.getAttributeValue("name").equals(actionName) == false) {
continue;
}
- Element eSla = action.getChild("info", Namespace.getNamespace(SchemaService.SLA_NAME_SPACE_URI));
+ Element eSla = XmlUtils.getSLAElement(action);
if (eSla != null) {
slaXml = XmlUtils.prettyPrint(eSla).toString();
break;
@@ -384,7 +382,7 @@ public class SignalXCommand extends Work
Element eWfJob = XmlUtils.parseXml(wfXml);
Configuration conf = new XConfiguration(new StringReader(strConf));
for (Element action : (List<Element>) eWfJob.getChildren("action", eWfJob.getNamespace())) {
- Element eSla = action.getChild("info", Namespace.getNamespace(SchemaService.SLA_NAME_SPACE_URI));
+ Element eSla = XmlUtils.getSLAElement(action);
if (eSla != null) {
String slaXml = resolveSla(eSla, conf);
eSla = XmlUtils.parseXml(slaXml);
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SubmitXCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SubmitXCommand.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SubmitXCommand.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SubmitXCommand.java Mon May 20 16:51:37 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.
@@ -20,12 +20,14 @@ package org.apache.oozie.command.wf;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.FileSystem;
+import org.apache.oozie.AppType;
import org.apache.oozie.SLAEventBean;
import org.apache.oozie.WorkflowJobBean;
import org.apache.oozie.ErrorCode;
import org.apache.oozie.action.oozie.SubWorkflowActionExecutor;
import org.apache.oozie.service.HadoopAccessorException;
import org.apache.oozie.service.JPAService;
+import org.apache.oozie.service.UUIDService;
import org.apache.oozie.service.WorkflowStoreService;
import org.apache.oozie.service.WorkflowAppService;
import org.apache.oozie.service.HadoopAccessorService;
@@ -34,6 +36,7 @@ import org.apache.oozie.service.DagXLogI
import org.apache.oozie.util.ConfigUtils;
import org.apache.oozie.util.ELUtils;
import org.apache.oozie.util.LogUtils;
+import org.apache.oozie.sla.SLAOperations;
import org.apache.oozie.util.XLog;
import org.apache.oozie.util.ParamChecker;
import org.apache.oozie.util.XConfiguration;
@@ -42,7 +45,6 @@ import org.apache.oozie.command.CommandE
import org.apache.oozie.executor.jpa.BulkUpdateInsertJPAExecutor;
import org.apache.oozie.executor.jpa.JPAExecutorException;
import org.apache.oozie.service.ELService;
-import org.apache.oozie.service.SchemaService;
import org.apache.oozie.store.StoreException;
import org.apache.oozie.workflow.WorkflowApp;
import org.apache.oozie.workflow.WorkflowException;
@@ -58,8 +60,6 @@ import org.apache.oozie.client.WorkflowJ
import org.apache.oozie.client.SLAEvent.SlaAppType;
import org.apache.oozie.client.rest.JsonBean;
import org.jdom.Element;
-import org.jdom.Namespace;
-
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -69,6 +69,7 @@ import java.util.HashSet;
import java.io.IOException;
import java.net.URI;
+@SuppressWarnings("deprecation")
public class SubmitXCommand extends WorkflowXCommand<String> {
public static final String CONFIG_DEFAULT = "config-default.xml";
@@ -202,7 +203,8 @@ public class SubmitXCommand extends Work
ELEvaluator evalSla = createELEvaluatorForGroup(conf, "wf-sla-submit");
String jobSlaXml = verifySlaElements(wfElem, evalSla);
if (!dryrun) {
- writeSLARegistration(jobSlaXml, workflow.getId(), workflow.getUser(), workflow.getGroup(), LOG);
+ writeSLARegistration(wfElem, jobSlaXml, workflow.getId(), workflow.getParentId(), workflow.getUser(),
+ workflow.getGroup(), workflow.getAppName(), LOG, evalSla);
workflow.setSlaXml(jobSlaXml);
// System.out.println("SlaXml :"+ slaXml);
@@ -242,14 +244,14 @@ public class SubmitXCommand extends Work
private String verifySlaElements(Element eWfJob, ELEvaluator evalSla) throws CommandException {
String jobSlaXml = "";
// Validate WF job
- Element eSla = eWfJob.getChild("info", Namespace.getNamespace(SchemaService.SLA_NAME_SPACE_URI));
+ Element eSla = XmlUtils.getSLAElement(eWfJob);
if (eSla != null) {
jobSlaXml = resolveSla(eSla, evalSla);
}
// Validate all actions
for (Element action : (List<Element>) eWfJob.getChildren("action", eWfJob.getNamespace())) {
- eSla = action.getChild("info", Namespace.getNamespace(SchemaService.SLA_NAME_SPACE_URI));
+ eSla = XmlUtils.getSLAElement(eWfJob);
if (eSla != null) {
resolveSla(eSla, evalSla);
}
@@ -257,21 +259,36 @@ public class SubmitXCommand extends Work
return jobSlaXml;
}
- private void writeSLARegistration(String slaXml, String id, String user, String group, XLog log)
- throws CommandException {
+ private void writeSLARegistration(Element eWfJob, String slaXml, String jobId, String parentId, String user,
+ String group, String appName, XLog log, ELEvaluator evalSla) throws CommandException {
try {
if (slaXml != null && slaXml.length() > 0) {
Element eSla = XmlUtils.parseXml(slaXml);
- SLAEventBean slaEvent = SLADbOperations.createSlaRegistrationEvent(eSla, id,
+ SLAEventBean slaEvent = SLADbOperations.createSlaRegistrationEvent(eSla, jobId,
SlaAppType.WORKFLOW_JOB, user, group, log);
if(slaEvent != null) {
insertList.add(slaEvent);
}
+ // insert into new table
+ SLAOperations.createSlaRegistrationEvent(eSla, jobId, parentId, AppType.WORKFLOW_JOB, user, appName,
+ log);
+ }
+ // Add sla for wf actions
+ for (Element action : (List<Element>) eWfJob.getChildren("action", eWfJob.getNamespace())) {
+ Element actionSla = XmlUtils.getSLAElement(action);
+ if (actionSla != null) {
+ String actionSlaXml = SubmitXCommand.resolveSla(actionSla, evalSla);
+ actionSla = XmlUtils.parseXml(actionSlaXml);
+ String actionId = Services.get().get(UUIDService.class)
+ .generateChildId(jobId, action.getAttributeValue("name") + "");
+ SLAOperations.createSlaRegistrationEvent(actionSla, actionId, jobId, AppType.WORKFLOW_ACTION,
+ user, appName, log);
+ }
}
}
catch (Exception e) {
e.printStackTrace();
- throw new CommandException(ErrorCode.E1007, "workflow " + id, e.getMessage(), e);
+ throw new CommandException(ErrorCode.E1007, "workflow " + jobId, e.getMessage(), e);
}
}
@@ -293,7 +310,7 @@ public class SubmitXCommand extends Work
return slaXml;
}
catch (Exception e) {
- throw new CommandException(ErrorCode.E1004, "Validation erro :" + e.getMessage(), e);
+ throw new CommandException(ErrorCode.E1004, "Validation error :" + e.getMessage(), e);
}
}
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SuspendXCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SuspendXCommand.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SuspendXCommand.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/SuspendXCommand.java Mon May 20 16:51:37 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.
@@ -101,7 +101,7 @@ public class SuspendXCommand extends Wor
workflow.setWorkflowInstance(wfInstance);
setPendingFalseForActions(jpaService, id, actionId, updateList);
- if (EventHandlerService.isEventsConfigured()) {
+ if (EventHandlerService.isEnabled()) {
generateEvent(workflow);
}
}
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/WorkflowXCommand.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/WorkflowXCommand.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/WorkflowXCommand.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/command/wf/WorkflowXCommand.java Mon May 20 16:51:37 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.
@@ -17,13 +17,12 @@
*/
package org.apache.oozie.command.wf;
+import org.apache.oozie.AppType;
import org.apache.oozie.WorkflowActionBean;
import org.apache.oozie.WorkflowJobBean;
-import org.apache.oozie.client.event.Event.AppType;
import org.apache.oozie.command.XCommand;
import org.apache.oozie.event.WorkflowActionEvent;
import org.apache.oozie.event.WorkflowJobEvent;
-import org.apache.oozie.util.ParamChecker;
/**
* Abstract coordinator command class derived from XCommand
@@ -55,8 +54,7 @@ public abstract class WorkflowXCommand<T
}
protected static void generateEvent(WorkflowJobBean wfJob, String errorCode, String errorMsg) {
- if (eventService.checkSupportedApptype(AppType.WORKFLOW_JOB.name())) {
- ParamChecker.notNull(wfJob, "wfJob");
+ if (eventService.isSupportedApptype(AppType.WORKFLOW_JOB.name())) {
WorkflowJobEvent event = new WorkflowJobEvent(wfJob.getId(), wfJob.getParentId(), wfJob.getStatus(),
wfJob.getUser(), wfJob.getAppName(), wfJob.getStartTime(), wfJob.getEndTime());
event.setErrorCode(errorCode);
@@ -70,14 +68,12 @@ public abstract class WorkflowXCommand<T
}
protected void generateEvent(WorkflowActionBean wfAction, String wfUser) {
- if (eventService.checkSupportedApptype(AppType.WORKFLOW_ACTION.name())) {
- ParamChecker.notNull(wfAction, "wfAction");
- WorkflowActionEvent event = new WorkflowActionEvent(wfAction.getId(), wfAction.getJobId(),
- wfAction.getStatus(), wfUser, wfAction.getName(), wfAction.getStartTime(), wfAction.getEndTime());
- event.setErrorCode(wfAction.getErrorCode());
- event.setErrorMessage(wfAction.getErrorMessage());
- eventService.queueEvent(event);
- }
+ // Workflow action events not filtered since required for sla
+ WorkflowActionEvent event = new WorkflowActionEvent(wfAction.getId(), wfAction.getJobId(),
+ wfAction.getStatus(), wfUser, wfAction.getName(), wfAction.getStartTime(), wfAction.getEndTime());
+ event.setErrorCode(wfAction.getErrorCode());
+ event.setErrorMessage(wfAction.getErrorMessage());
+ eventService.queueEvent(event);
}
}
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/event/BundleJobEvent.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/event/BundleJobEvent.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/event/BundleJobEvent.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/event/BundleJobEvent.java Mon May 20 16:51:37 2013
@@ -20,6 +20,7 @@ package org.apache.oozie.event;
import java.util.Date;
+import org.apache.oozie.AppType;
import org.apache.oozie.client.BundleJob;
import org.apache.oozie.client.event.JobEvent;
import org.apache.oozie.service.EventHandlerService;
@@ -34,11 +35,11 @@ public class BundleJobEvent extends JobE
private BundleJob.Status status;
public BundleJobEvent(String id, BundleJob.Status status, String user, String appName, Date startTime, Date endTime) {
- super(AppType.BUNDLE_JOB, id, null, user, appName); //parentId is null
+ super(id, null, user, AppType.BUNDLE_JOB, appName); // parentId is null
setStatus(status);
setStartTime(startTime);
setEndTime(endTime);
- XLog.getLog(EventHandlerService.class).debug("Event generated - " + this.toString());
+ XLog.getLog(EventHandlerService.class).trace("Event generated - " + this.toString());
}
public BundleJob.Status getStatus() {
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/event/CoordinatorActionEvent.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/event/CoordinatorActionEvent.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/event/CoordinatorActionEvent.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/event/CoordinatorActionEvent.java Mon May 20 16:51:37 2013
@@ -19,6 +19,8 @@
package org.apache.oozie.event;
import java.util.Date;
+
+import org.apache.oozie.AppType;
import org.apache.oozie.client.CoordinatorAction;
import org.apache.oozie.client.event.JobEvent;
import org.apache.oozie.service.EventHandlerService;
@@ -39,12 +41,12 @@ public class CoordinatorActionEvent exte
public CoordinatorActionEvent(String id, String parentId, CoordinatorAction.Status status, String user,
String appName, Date nomTime, Date startTime, String missDeps) {
- super(AppType.COORDINATOR_ACTION, id, parentId, user, appName);
+ super(id, parentId, user, AppType.COORDINATOR_ACTION, appName);
setStatus(status);
setNominalTime(nomTime);
setStartTime(startTime);
setMissingDeps(missDeps);
- XLog.getLog(EventHandlerService.class).debug("Event generated - " + this.toString());
+ XLog.getLog(EventHandlerService.class).trace("Event generated - " + this.toString());
}
public String getBundleJobId() {
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/event/CoordinatorJobEvent.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/event/CoordinatorJobEvent.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/event/CoordinatorJobEvent.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/event/CoordinatorJobEvent.java Mon May 20 16:51:37 2013
@@ -19,6 +19,8 @@
package org.apache.oozie.event;
import java.util.Date;
+
+import org.apache.oozie.AppType;
import org.apache.oozie.client.CoordinatorJob;
import org.apache.oozie.client.event.JobEvent;
import org.apache.oozie.service.EventHandlerService;
@@ -33,11 +35,11 @@ public class CoordinatorJobEvent extends
public CoordinatorJobEvent(String id, String parentId, CoordinatorJob.Status status, String user, String appName,
Date startTime, Date endTime) {
- super(AppType.COORDINATOR_JOB, id, parentId, user, appName);
+ super(id, parentId, user, AppType.COORDINATOR_JOB, appName);
setStatus(status);
setStartTime(startTime);
setEndTime(endTime);
- XLog.getLog(EventHandlerService.class).debug("Event generated - " + this.toString());
+ XLog.getLog(EventHandlerService.class).trace("Event generated - " + this.toString());
}
public CoordinatorJob.Status getStatus() {
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/event/EventQueue.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/event/EventQueue.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/event/EventQueue.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/event/EventQueue.java Mon May 20 16:51:37 2013
@@ -20,6 +20,7 @@ package org.apache.oozie.event;
import java.io.Serializable;
import java.util.Set;
+import org.apache.hadoop.conf.Configuration;
import org.apache.oozie.client.event.Event;
/**
@@ -39,10 +40,9 @@ public interface EventQueue {
/**
* Initialize the event queue
- * @param queueSize
- * @param batchSize
+ * @param conf
*/
- public void init(int queueSize, int batchSize);
+ public void init(Configuration conf);
/**
* Add event to queue
@@ -72,7 +72,7 @@ public interface EventQueue {
* Get current queue size
* @return size
*/
- public int getCurrentSize();
+ public int size();
/**
* Read topmost event from queue but do not pop from it
@@ -86,4 +86,9 @@ public interface EventQueue {
*/
public int getBatchSize();
+ /**
+ * Clear the events queue
+ */
+ public void clear();
+
}
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/event/MemoryEventQueue.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/event/MemoryEventQueue.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/event/MemoryEventQueue.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/event/MemoryEventQueue.java Mon May 20 16:51:37 2013
@@ -23,7 +23,9 @@ import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.hadoop.conf.Configuration;
import org.apache.oozie.client.event.Event;
+import org.apache.oozie.service.EventHandlerService;
import org.apache.oozie.util.XLog;
/**
@@ -39,12 +41,13 @@ public class MemoryEventQueue implements
private static int batchSize;
@Override
- public void init(int queueSize, int batchsize) {
+ public void init(Configuration conf) {
eventQueue = new ConcurrentLinkedQueue<EventQueueElement>();
- maxSize = queueSize;
+ maxSize = conf.getInt(EventHandlerService.CONF_QUEUE_SIZE, 10000);
currentSize = new AtomicInteger();
- batchSize = batchsize;
+ batchSize = conf.getInt(EventHandlerService.CONF_BATCH_SIZE, 10);
LOG = XLog.getLog(getClass());
+ LOG.info("Memory Event Queue initialized with Max size = [{0}], Batch drain size = [{1}]", maxSize, batchSize);
}
@Override
@@ -56,13 +59,13 @@ public class MemoryEventQueue implements
public void add(Event e) {
EventQueueElement eqe = new EventQueueElement(e);
try {
- if(getCurrentSize() <= maxSize) {
- if(eventQueue.add(eqe)) {
+ if (size() <= maxSize) {
+ if (eventQueue.add(eqe)) {
currentSize.incrementAndGet();
}
}
else {
- LOG.warn("Queue size [{0}] reached max limit. Element [{1}] not added", getCurrentSize(), e);
+ LOG.warn("Queue size [{0}] reached max limit. Element [{1}] not added", size(), e);
}
}
catch (IllegalStateException ise) {
@@ -81,7 +84,7 @@ public class MemoryEventQueue implements
eventBatch.add(polled.event);
}
else {
- LOG.debug("Current queue size [{0}] less than polling batch size [{1}]", currentSize.get(), batchSize);
+ LOG.trace("Current queue size [{0}] less than polling batch size [{1}]", currentSize.get(), batchSize);
break;
}
}
@@ -100,11 +103,11 @@ public class MemoryEventQueue implements
@Override
public boolean isEmpty() {
- return getCurrentSize() == 0;
+ return size() == 0;
}
@Override
- public int getCurrentSize() {
+ public int size() {
return currentSize.intValue();
}
@@ -117,4 +120,9 @@ public class MemoryEventQueue implements
return null;
}
+ @Override
+ public void clear() {
+ eventQueue.clear();
+ }
+
}
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/event/WorkflowActionEvent.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/event/WorkflowActionEvent.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/event/WorkflowActionEvent.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/event/WorkflowActionEvent.java Mon May 20 16:51:37 2013
@@ -19,6 +19,8 @@
package org.apache.oozie.event;
import java.util.Date;
+
+import org.apache.oozie.AppType;
import org.apache.oozie.client.WorkflowAction;
import org.apache.oozie.client.event.JobEvent;
import org.apache.oozie.service.EventHandlerService;
@@ -36,11 +38,11 @@ public class WorkflowActionEvent extends
public WorkflowActionEvent(String id, String parentId, WorkflowAction.Status status, String user, String appName,
Date startTime, Date endTime) {
- super(AppType.WORKFLOW_ACTION, id, parentId, user, appName);
+ super(id, parentId, user, AppType.WORKFLOW_ACTION, appName);
setStatus(status);
setStartTime(startTime);
setEndTime(endTime);
- XLog.getLog(EventHandlerService.class).debug("Event generated - " + this.toString());
+ XLog.getLog(EventHandlerService.class).trace("Event generated - " + this.toString());
}
public WorkflowAction.Status getStatus() {
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/event/WorkflowJobEvent.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/event/WorkflowJobEvent.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/event/WorkflowJobEvent.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/event/WorkflowJobEvent.java Mon May 20 16:51:37 2013
@@ -20,6 +20,7 @@ package org.apache.oozie.event;
import java.util.Date;
+import org.apache.oozie.AppType;
import org.apache.oozie.client.WorkflowJob;
import org.apache.oozie.client.event.JobEvent;
import org.apache.oozie.service.EventHandlerService;
@@ -38,11 +39,11 @@ public class WorkflowJobEvent extends Jo
public WorkflowJobEvent(String id, String parentId, WorkflowJob.Status status, String user, String appName,
Date startTime, Date endTime) {
- super(AppType.WORKFLOW_JOB, id, parentId, user, appName);
+ super(id, parentId, user, AppType.WORKFLOW_JOB, appName);
setStatus(status);
setStartTime(startTime);
setEndTime(endTime);
- XLog.getLog(EventHandlerService.class).debug("Event generated - " + this.toString());
+ XLog.getLog(EventHandlerService.class).trace("Event generated - " + this.toString());
}
public String getCoordJobId() {
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/event/listener/JobEventListener.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/event/listener/JobEventListener.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/event/listener/JobEventListener.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/event/listener/JobEventListener.java Mon May 20 16:51:37 2013
@@ -17,6 +17,7 @@
*/
package org.apache.oozie.event.listener;
+import org.apache.hadoop.conf.Configuration;
import org.apache.oozie.event.BundleJobEvent;
import org.apache.oozie.event.CoordinatorActionEvent;
import org.apache.oozie.event.CoordinatorJobEvent;
@@ -31,8 +32,9 @@ public abstract class JobEventListener {
/**
* Initialize the listener
+ * @param conf
*/
- public abstract void init();
+ public abstract void init(Configuration conf);
/**
* Destroy the listener
@@ -55,18 +57,18 @@ public abstract class JobEventListener {
* On coordinator job transition
* @param CoordinatorJobEvent
*/
- public abstract void onCoordinatorJobEvent(CoordinatorJobEvent wje);
+ public abstract void onCoordinatorJobEvent(CoordinatorJobEvent cje);
/**
* On coordinator action transition
* @param CoordinatorActionEvent
*/
- public abstract void onCoordinatorActionEvent(CoordinatorActionEvent wae);
+ public abstract void onCoordinatorActionEvent(CoordinatorActionEvent cae);
/**
* On bundle job transition
* @param BundleJobEvent
*/
- public abstract void onBundleJobEvent(BundleJobEvent wje);
+ public abstract void onBundleJobEvent(BundleJobEvent bje);
}
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/CoordJobGetActionsNotCompletedJPAExecutor.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/CoordJobGetActionsNotCompletedJPAExecutor.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/CoordJobGetActionsNotCompletedJPAExecutor.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/CoordJobGetActionsNotCompletedJPAExecutor.java Mon May 20 16:51:37 2013
@@ -17,6 +17,7 @@
*/
package org.apache.oozie.executor.jpa;
+import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
@@ -26,6 +27,7 @@ import javax.persistence.Query;
import org.apache.oozie.CoordinatorActionBean;
import org.apache.oozie.ErrorCode;
import org.apache.oozie.client.CoordinatorAction;
+import org.apache.oozie.util.DateUtils;
import org.apache.oozie.util.ParamChecker;
/**
@@ -93,6 +95,12 @@ public class CoordJobGetActionsNotComple
if (arr[4] != null) {
bean.setPushMissingDependencies((String) arr[4]);
}
+ if (arr[5] != null){
+ bean.setNominalTime(DateUtils.toDate((Timestamp) arr[5]));
+ }
+ if (arr[6] != null){
+ bean.setCreatedTime(DateUtils.toDate((Timestamp) arr[6]));
+ }
return bean;
}
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/SLAEventInsertJPAExecutor.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/SLAEventInsertJPAExecutor.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/SLAEventInsertJPAExecutor.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/SLAEventInsertJPAExecutor.java Mon May 20 16:51:37 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.
@@ -25,6 +25,7 @@ import org.apache.oozie.util.ParamChecke
/**
* Persist the SLAEventBean bean.
*/
+@Deprecated
public class SLAEventInsertJPAExecutor implements JPAExecutor<String> {
private SLAEventBean slaEvent = null;
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/SLAEventsGetForFilterJPAExecutor.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/SLAEventsGetForFilterJPAExecutor.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/SLAEventsGetForFilterJPAExecutor.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/SLAEventsGetForFilterJPAExecutor.java Mon May 20 16:51:37 2013
@@ -30,6 +30,7 @@ import org.apache.oozie.client.OozieClie
/**
* Load the list of SLAEventBean for a seqId and return the list.
*/
+@Deprecated
public class SLAEventsGetForFilterJPAExecutor implements JPAExecutor<List<SLAEventBean>> {
private static final String selectStr = "SELECT OBJECT(w) FROM SLAEventBean w WHERE w.event_id > :seqid";
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/SLAEventsGetForSeqIdJPAExecutor.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/SLAEventsGetForSeqIdJPAExecutor.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/SLAEventsGetForSeqIdJPAExecutor.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/SLAEventsGetForSeqIdJPAExecutor.java Mon May 20 16:51:37 2013
@@ -26,6 +26,7 @@ import org.apache.oozie.SLAEventBean;
/**
* Load the list of SLAEventBean for a seqId and return the list.
*/
+@Deprecated
public class SLAEventsGetForSeqIdJPAExecutor implements JPAExecutor<List<SLAEventBean>> {
private long seqId = 0;
Modified: oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/SLAEventsGetJPAExecutor.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/SLAEventsGetJPAExecutor.java?rev=1484523&r1=1484522&r2=1484523&view=diff
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/SLAEventsGetJPAExecutor.java (original)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/SLAEventsGetJPAExecutor.java Mon May 20 16:51:37 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.SLAEventBean;
/**
* Load the list of SLAEventBean and return the list.
*/
+@Deprecated
public class SLAEventsGetJPAExecutor implements JPAExecutor<List<SLAEventBean>> {
private int limitLen = 100; // Default
Added: oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/sla/SLACalculationInsertUpdateJPAExecutor.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/sla/SLACalculationInsertUpdateJPAExecutor.java?rev=1484523&view=auto
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/sla/SLACalculationInsertUpdateJPAExecutor.java (added)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/sla/SLACalculationInsertUpdateJPAExecutor.java Mon May 20 16:51:37 2013
@@ -0,0 +1,105 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oozie.executor.jpa.sla;
+
+import java.util.Collection;
+
+import javax.persistence.EntityManager;
+
+import org.apache.oozie.ErrorCode;
+import org.apache.oozie.FaultInjection;
+import org.apache.oozie.client.rest.JsonBean;
+import org.apache.oozie.executor.jpa.JPAExecutor;
+import org.apache.oozie.executor.jpa.JPAExecutorException;
+import org.apache.oozie.util.ParamChecker;
+
+/**
+ * Persist the SLA beans to tables SLA_CALCULATOR and SLA_SUMMARY.
+ */
+public class SLACalculationInsertUpdateJPAExecutor implements JPAExecutor<String> {
+
+ private Collection<JsonBean> insertList;
+ private Collection<JsonBean> updateList;
+
+ public SLACalculationInsertUpdateJPAExecutor(Collection<JsonBean> insertList, Collection<JsonBean> updateList) {
+ setInsertList(insertList);
+ setUpdateList(updateList);
+ }
+
+ public SLACalculationInsertUpdateJPAExecutor() {
+ }
+
+ /**
+ * Sets the list of beans to insert
+ *
+ * @param insert
+ */
+ public void setInsertList(Collection<JsonBean> insertList) {
+ this.insertList = insertList;
+ }
+
+ /**
+ * Sets the list of beans to update
+ *
+ * @param update
+ */
+ public void setUpdateList(Collection<JsonBean> updateList) {
+ this.updateList = updateList;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.oozie.executor.jpa.JPAExecutor#getName()
+ */
+ @Override
+ public String getName() {
+ return "SLACalculationInsertUpdateJPAExecutor";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.oozie.executor.jpa.JPAExecutor#execute(javax.persistence.
+ * EntityManager)
+ */
+ @Override
+ public String execute(EntityManager em) throws JPAExecutorException {
+ try {
+ if (insertList != null) {
+ for (JsonBean entity : insertList) {
+ ParamChecker.notNull(entity, "JsonBean");
+ em.persist(entity);
+ }
+ }
+ // Only used by test cases to check for rollback of transaction
+ FaultInjection.activate("org.apache.oozie.command.SkipCommitFaultInjection");
+ if (updateList != null) {
+ for (JsonBean entity : updateList) {
+ ParamChecker.notNull(entity, "JsonBean");
+ em.merge(entity);
+ }
+ }
+ return null;
+ }
+ catch (Exception e) {
+ throw new JPAExecutorException(ErrorCode.E0603, e.getMessage(), e);
+ }
+ }
+
+}
Added: oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/sla/SLACalculatorGetJPAExecutor.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/sla/SLACalculatorGetJPAExecutor.java?rev=1484523&view=auto
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/sla/SLACalculatorGetJPAExecutor.java (added)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/sla/SLACalculatorGetJPAExecutor.java Mon May 20 16:51:37 2013
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oozie.executor.jpa.sla;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.oozie.ErrorCode;
+import org.apache.oozie.executor.jpa.JPAExecutor;
+import org.apache.oozie.executor.jpa.JPAExecutorException;
+import org.apache.oozie.sla.SLACalculatorBean;
+
+/**
+ * Load the list of SLACalculatorBean and return the list.
+ */
+public class SLACalculatorGetJPAExecutor implements JPAExecutor<SLACalculatorBean> {
+
+ private String id = null;
+
+ public SLACalculatorGetJPAExecutor(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public String getName() {
+ return "SLACalculatorGetJPAExecutor";
+ }
+
+ @Override
+ public SLACalculatorBean execute(EntityManager em) throws JPAExecutorException {
+ SLACalculatorBean scBean;
+ Query q;
+ try {
+ q = em.createNamedQuery("GET_SLA_CALC");
+ q.setParameter("id", id);
+ scBean = (SLACalculatorBean) q.getSingleResult();
+ }
+ catch (Exception e) {
+ throw new JPAExecutorException(ErrorCode.E0603, e.getMessage(), e);
+ }
+ return scBean;
+ }
+
+}
Added: oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/sla/SLARegistrationGetJPAExecutor.java
URL: http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/sla/SLARegistrationGetJPAExecutor.java?rev=1484523&view=auto
==============================================================================
--- oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/sla/SLARegistrationGetJPAExecutor.java (added)
+++ oozie/trunk/core/src/main/java/org/apache/oozie/executor/jpa/sla/SLARegistrationGetJPAExecutor.java Mon May 20 16:51:37 2013
@@ -0,0 +1,106 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oozie.executor.jpa.sla;
+
+import java.sql.Timestamp;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+
+import org.apache.oozie.AppType;
+import org.apache.oozie.ErrorCode;
+import org.apache.oozie.executor.jpa.JPAExecutor;
+import org.apache.oozie.executor.jpa.JPAExecutorException;
+import org.apache.oozie.sla.SLARegistrationBean;
+import org.apache.oozie.util.DateUtils;
+
+/**
+ * Load the list of SLARegistrationBean and return the list.
+ */
+public class SLARegistrationGetJPAExecutor implements JPAExecutor<SLARegistrationBean> {
+
+ private String id = null;
+
+ public SLARegistrationGetJPAExecutor(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public String getName() {
+ return "SLARegistrationGetJPAExecutor";
+ }
+
+ @Override
+ public SLARegistrationBean execute(EntityManager em) throws JPAExecutorException {
+ try {
+ Query q = em.createNamedQuery("GET_SLA_REG_ALL");
+ q.setParameter("id", id);
+ Object[] obj = (Object[]) q.getSingleResult();
+ return getBeanFromObj(obj);
+ }
+ catch (Exception e) {
+ throw new JPAExecutorException(ErrorCode.E0603, e.getMessage(), e);
+ }
+ }
+
+ private SLARegistrationBean getBeanFromObj(Object[] arr) {
+ SLARegistrationBean bean = new SLARegistrationBean();
+ if (arr[0] != null) {
+ bean.setJobId((String) arr[0]);
+ }
+ if (arr[1] != null) {
+ bean.setAppType(AppType.valueOf((String) arr[1]));
+ }
+ if (arr[2] != null) {
+ bean.setAppName((String) arr[2]);
+ }
+ if (arr[3] != null) {
+ bean.setUser((String) arr[3]);
+ }
+ if (arr[4] != null) {
+ bean.setNominalTime(DateUtils.toDate((Timestamp) arr[4]));
+ }
+ if (arr[5] != null) {
+ bean.setExpectedStart(DateUtils.toDate((Timestamp) arr[5]));
+ }
+ if (arr[6] != null) {
+ bean.setExpectedEnd(DateUtils.toDate((Timestamp) arr[6]));
+ }
+ if (arr[7] != null) {
+ bean.setExpectedDuration((Long) arr[7]);
+ }
+ if (arr[8] != null) {
+ bean.setJobData((String) arr[8]);
+ }
+ if (arr[9] != null) {
+ bean.setParentId((String) arr[9]);
+ }
+ if (arr[10] != null) {
+ bean.setNotificationMsg((String) arr[10]);
+ }
+ if (arr[11] != null) {
+ bean.setUpstreamApps((String) arr[11]);
+ }
+ if (arr[12] != null) {
+ bean.setSlaConfig((String) arr[12]);
+ }
+
+ return bean;
+ }
+
+}