You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by ka...@apache.org on 2012/05/02 09:19:12 UTC
svn commit: r1332940 [2/2] - in /incubator/oozie/trunk: ./
core/src/main/java/org/apache/oozie/
core/src/main/java/org/apache/oozie/command/coord/
core/src/main/java/org/apache/oozie/executor/jpa/
core/src/main/java/org/apache/oozie/service/ core/src/m...
Modified: incubator/oozie/trunk/core/src/main/java/org/apache/oozie/store/CoordinatorStore.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/java/org/apache/oozie/store/CoordinatorStore.java?rev=1332940&r1=1332939&r2=1332940&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/main/java/org/apache/oozie/store/CoordinatorStore.java (original)
+++ incubator/oozie/trunk/core/src/main/java/org/apache/oozie/store/CoordinatorStore.java Wed May 2 07:19:11 2012
@@ -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.
@@ -654,13 +654,13 @@ public class CoordinatorStore extends St
* @return A List of CoordinatorActionBean
* @throws StoreException
*/
- public List<CoordinatorActionBean> getActionsForCoordinatorJob(final String jobId, final boolean locking)
+ public Integer getActionsForCoordinatorJob(final String jobId, final boolean locking)
throws StoreException {
ParamChecker.notEmpty(jobId, "CoordinatorJobID");
- List<CoordinatorActionBean> actions = doOperation("getActionsForCoordinatorJob",
- new Callable<List<CoordinatorActionBean>>() {
+ Integer actionsCount = doOperation("getActionsForCoordinatorJob",
+ new Callable<Integer>() {
@SuppressWarnings("unchecked")
- public List<CoordinatorActionBean> call() throws StoreException {
+ public Integer call() throws StoreException {
List<CoordinatorActionBean> actions;
List<CoordinatorActionBean> actionList = new ArrayList<CoordinatorActionBean>();
try {
@@ -675,11 +675,13 @@ public class CoordinatorStore extends St
* fetch.setReadLockMode(LockModeType.WRITE);
* fetch.setLockTimeout(-1); // 1 second }
*/
- actions = q.getResultList();
+ Long count = (Long) q.getSingleResult();
+ return Integer.valueOf(count.intValue());
+ /*actions = q.getResultList();
for (CoordinatorActionBean a : actions) {
CoordinatorActionBean aa = getBeanForRunningCoordAction(a);
actionList.add(aa);
- }
+ }*/
}
catch (IllegalStateException e) {
throw new StoreException(ErrorCode.E0601, e.getMessage(), e);
@@ -687,11 +689,11 @@ public class CoordinatorStore extends St
/*
* if (locking) { return actions; } else {
*/
- return actionList;
+
// }
}
});
- return actions;
+ return actionsCount;
}
/**
@@ -764,36 +766,6 @@ public class CoordinatorStore extends St
return null;
}
- /*
- * do not need this public void updateCoordinatorActionForExternalId(final
- * CoordinatorActionBean action) throws StoreException { // TODO
- * Auto-generated method stub ParamChecker.notNull(action,
- * "updateCoordinatorActionForExternalId");
- * doOperation("updateCoordinatorActionForExternalId", new Callable<Void>()
- * { public Void call() throws SQLException, StoreException,
- * WorkflowException { Query q =
- * entityManager.createNamedQuery("UPDATE_COORD_ACTION_FOR_EXTERNALID");
- * setActionQueryParameters(action,q); q.executeUpdate(); return null; } });
- * }
- */
- public CoordinatorActionBean getCoordinatorActionForExternalId(final String externalId) throws StoreException {
- // TODO Auto-generated method stub
- ParamChecker.notEmpty(externalId, "coodinatorActionExternalId");
- CoordinatorActionBean cBean = doOperation("getCoordinatorActionForExternalId",
- new Callable<CoordinatorActionBean>() {
- public CoordinatorActionBean call() throws StoreException {
- CoordinatorActionBean caBean = null;
- Query q = entityManager.createNamedQuery("GET_COORD_ACTION_FOR_EXTERNALID");
- q.setParameter("externalId", externalId);
- List<CoordinatorActionBean> actionList = q.getResultList();
- if (actionList.size() > 0) {
- caBean = actionList.get(0);
- }
- return caBean;
- }
- });
- return cBean;
- }
public List<CoordinatorActionBean> getRunningActionsForCoordinatorJob(final String jobId, final boolean locking)
throws StoreException {
Modified: incubator/oozie/trunk/core/src/main/java/org/apache/oozie/util/CoordActionsInDateRange.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/java/org/apache/oozie/util/CoordActionsInDateRange.java?rev=1332940&r1=1332939&r2=1332940&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/main/java/org/apache/oozie/util/CoordActionsInDateRange.java (original)
+++ incubator/oozie/trunk/core/src/main/java/org/apache/oozie/util/CoordActionsInDateRange.java Wed May 2 07:19:11 2012
@@ -30,6 +30,7 @@ import org.apache.oozie.CoordinatorActio
import org.apache.oozie.ErrorCode;
import org.apache.oozie.XException;
import org.apache.oozie.command.PreconditionException;
+import org.apache.oozie.executor.jpa.CoordJobGetActionIdsForDateRangeJPAExecutor;
import org.apache.oozie.executor.jpa.CoordJobGetActionsForDatesJPAExecutor;
import org.apache.oozie.executor.jpa.JPAExecutorException;
import org.apache.oozie.service.JPAService;
@@ -45,34 +46,30 @@ import org.apache.oozie.util.ParamChecke
public class CoordActionsInDateRange {
/**
- * Get the list of actions for given date ranges
+ * Get the list of Coordinator action Ids for given date ranges
*
* @param jobId coordinator job id
* @param scope the date range for log. format is comma-separated list of date ranges. Each date range element is specified with two dates separated by '::'
- * @return the list of coordinator actions for the date range
+ * @return the list of coordinator action Ids for the date range
*
* Internally involves a database operation by invoking method 'getActionIdsFromDateRange'.
*/
- public static List<CoordinatorActionBean> getCoordActionsFromDates(String jobId, String scope) throws XException {
+ public static List<String> getCoordActionIdsFromDates(String jobId, String scope) throws XException {
ParamChecker.notEmpty(jobId, "jobId");
ParamChecker.notEmpty(scope, "scope");
- Set<CoordinatorActionBean> actionSet = new HashSet<CoordinatorActionBean>();
+ Set<String> actionSet = new HashSet<String>();
String[] list = scope.split(",");
for (String s : list) {
s = s.trim();
if (s.contains("::")) {
- List<CoordinatorActionBean> listOfActions = getCoordActionsFromDateRange(jobId, s);
+ List<String> listOfActions = getCoordActionIdsFromDateRange(jobId, s);
actionSet.addAll(listOfActions);
}
else {
throw new XException(ErrorCode.E0308, "'" + s + "'. Separator '::' is missing for start and end dates of range");
}
}
- List<CoordinatorActionBean> coordActions = new ArrayList<CoordinatorActionBean>();
- for (CoordinatorActionBean coordAction : actionSet) {
- coordActions.add(coordAction);
- }
- return coordActions;
+ return new ArrayList<String>(actionSet);
}
/**
@@ -101,10 +98,42 @@ public class CoordActionsInDateRange {
if (start.after(end)) {
throw new XException(ErrorCode.E0308, "'" + range + "'. Start date '" + start + "' is older than end date: '" + end + "'");
}
- List<CoordinatorActionBean> listOfActions = getActionIdsFromDateRange(jobId, start, end);
+ List<CoordinatorActionBean> listOfActions = getActionsFromDateRange(jobId, start, end);
return listOfActions;
}
+ /**
+ * Get the coordinator actions for a given date range
+ * @param jobId the coordinator job id
+ * @param range the date range separated by '::'
+ * @return the list of Coordinator actions for the date range
+ * @throws XException
+ */
+ public static List<String> getCoordActionIdsFromDateRange(String jobId, String range) throws XException{
+ String[] dateRange = range.split("::");
+ // This block checks for errors in the format of specifying date range
+ if (dateRange.length != 2) {
+ throw new XException(ErrorCode.E0308, "'" + range + "'. Date value expected on both sides of the scope resolution operator '::' to signify start and end of range");
+ }
+ Date start;
+ Date end;
+ try {
+ // Get the start and end dates for the range
+ start = DateUtils.parseDateUTC(dateRange[0].trim());
+ end = DateUtils.parseDateUTC(dateRange[1].trim());
+ }
+ catch (ParseException dx) {
+ throw new XException(ErrorCode.E0308, "Error in parsing start or end date. " + dx);
+ }
+ if (start.after(end)) {
+ throw new XException(ErrorCode.E0308, "'" + range + "'. Start date '" + start + "' is older than end date: '" + end + "'");
+ }
+ List<String> list = null;
+ JPAService jpaService = Services.get().get(JPAService.class);
+ list = jpaService.execute(new CoordJobGetActionIdsForDateRangeJPAExecutor(jobId, start, end));
+ return list;
+ }
+
/*
* Get coordinator action ids between given start and end time
*
@@ -113,7 +142,7 @@ public class CoordActionsInDateRange {
* @param end end time
* @return a list of coordinator actions that correspond to the date range
*/
- private static List<CoordinatorActionBean> getActionIdsFromDateRange(String jobId, Date start, Date end) throws XException{
+ private static List<CoordinatorActionBean> getActionsFromDateRange(String jobId, Date start, Date end) throws XException{
List<CoordinatorActionBean> list;
JPAService jpaService = Services.get().get(JPAService.class);
list = jpaService.execute(new CoordJobGetActionsForDatesJPAExecutor(jobId, start, end));
Modified: incubator/oozie/trunk/core/src/main/resources/oozie-default.xml
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/resources/oozie-default.xml?rev=1332940&r1=1332939&r2=1332940&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/main/resources/oozie-default.xml (original)
+++ incubator/oozie/trunk/core/src/main/resources/oozie-default.xml Wed May 2 07:19:11 2012
@@ -1590,4 +1590,12 @@
</description>
</property>
+ <property>
+ <name>oozie.coord.action.get.all.attributes</name>
+ <value>false</value>
+ <description>
+ Setting to true is not recommended as coord job/action info will bring all columns of the action in memory.
+ Set it true only if backward compatibility for action/job info is required.
+ </description>
+ </property>
</configuration>
Modified: incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionInputCheckXCommand.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionInputCheckXCommand.java?rev=1332940&r1=1332939&r2=1332940&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionInputCheckXCommand.java (original)
+++ incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionInputCheckXCommand.java Wed May 2 07:19:11 2012
@@ -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.
Modified: incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionMaterializeCommand.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionMaterializeCommand.java?rev=1332940&r1=1332939&r2=1332940&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionMaterializeCommand.java (original)
+++ incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordActionMaterializeCommand.java Wed May 2 07:19:11 2012
@@ -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.
@@ -283,8 +283,8 @@ public class TestCoordActionMaterializeC
private void checkCoordActions(String jobId, int number, CoordinatorJob.Status status) throws StoreException {
CoordinatorStore store = new CoordinatorStore(false);
try {
- List<CoordinatorActionBean> actions = store.getActionsForCoordinatorJob(jobId, false);
- if (actions.size() != number) {
+ int coordActionsCount = store.getActionsForCoordinatorJob(jobId, false);
+ if (coordActionsCount != number) {
fail("Should have " + number + " actions created for job " + jobId);
}
Modified: incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordChangeXCommand.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordChangeXCommand.java?rev=1332940&r1=1332939&r2=1332940&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordChangeXCommand.java (original)
+++ incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordChangeXCommand.java Wed May 2 07:19:11 2012
@@ -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.
@@ -284,13 +284,24 @@ public class TestCoordChangeXCommand ext
assertEquals(DateUtils.convertDateToString(coordJob.getPauseTime()), DateUtils.convertDateToString(pauseTime));
assertEquals(Job.Status.RUNNING, coordJob.getStatus());
assertEquals(2, coordJob.getLastActionNumber());
+ try {
+ jpaService.execute(new CoordJobGetActionByActionNumberJPAExecutor(job.getId(), 3));
+ fail("Expected to fail as action 3 should have been deleted");
+ }
+ catch (JPAExecutorException jpae) {
+ assertEquals(ErrorCode.E0603, jpae.getErrorCode());
+ jpae.printStackTrace();
+ }
- CoordinatorActionBean actionBean = jpaService.execute(new CoordJobGetActionByActionNumberJPAExecutor(job
- .getId(), 3));
- assertNull(actionBean);
+ try {
+ jpaService.execute(new CoordJobGetActionByActionNumberJPAExecutor(job.getId(), 4));
+ fail("Expected to fail as action 4 should have been deleted");
+ }
+ catch (JPAExecutorException jpae) {
+ assertEquals(ErrorCode.E0603, jpae.getErrorCode());
+ jpae.printStackTrace();
+ }
- actionBean = jpaService.execute(new CoordJobGetActionByActionNumberJPAExecutor(job.getId(), 4));
- assertNull(actionBean);
}
protected CoordinatorJobBean addRecordToCoordJobTableForPauseTimeTest(CoordinatorJob.Status status, Date start,
Modified: incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordMaterializeTransitionXCommand.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordMaterializeTransitionXCommand.java?rev=1332940&r1=1332939&r2=1332940&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordMaterializeTransitionXCommand.java (original)
+++ incubator/oozie/trunk/core/src/test/java/org/apache/oozie/command/coord/TestCoordMaterializeTransitionXCommand.java Wed May 2 07:19:11 2012
@@ -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.
@@ -255,9 +255,9 @@ public class TestCoordMaterializeTransit
private void checkCoordActions(String jobId, int number, CoordinatorJob.Status status) {
try {
JPAService jpaService = Services.get().get(JPAService.class);
- List<CoordinatorActionBean> actions = jpaService.execute(new CoordJobGetActionsJPAExecutor(jobId));
- if (actions.size() != number) {
- fail("Should have " + number + " actions created for job " + jobId + ", but jave " + actions.size() + " actions.");
+ Integer actionsSize = jpaService.execute(new CoordJobGetActionsJPAExecutor(jobId));
+ if (actionsSize != number) {
+ fail("Should have " + number + " actions created for job " + jobId + ", but has " + actionsSize + " actions.");
}
if (status != null) {
Modified: incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordActionGetForExternalIdJPAExecutor.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordActionGetForExternalIdJPAExecutor.java?rev=1332940&r1=1332939&r2=1332940&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordActionGetForExternalIdJPAExecutor.java (original)
+++ incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordActionGetForExternalIdJPAExecutor.java Wed May 2 07:19:11 2012
@@ -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.
@@ -48,19 +48,25 @@ public class TestCoordActionGetForExtern
public void testCoordActionGet() throws Exception {
int actionNum = 1;
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, false, false);
- CoordinatorActionBean action = addRecordToCoordActionTable(job.getId(), actionNum, CoordinatorAction.Status.WAITING, "coord-action-get.xml", 0);
- _testGetActionByExternalId(action.getId(), action.getId() + "_E");
+ CoordinatorActionBean action = createCoordAction(job.getId(), actionNum, CoordinatorAction.Status.WAITING, "coord-action-get.xml", 0);
+ action.setSlaXml(XDataTestCase.slaXml);
+ // Insert the action
+ insertRecordCoordAction(action);
+ _testGetActionByExternalId(action.getId(), job.getId(), CoordinatorAction.Status.WAITING, 0, action.getId() + "_E", XDataTestCase.slaXml);
}
- private void _testGetActionByExternalId(String actionId, String extId) throws Exception {
+ private void _testGetActionByExternalId(String actionId, String jobId, CoordinatorAction.Status status, int pending, String extId, String slaXml) throws Exception {
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordActionGetForExternalIdJPAExecutor actionGetCmd = new CoordActionGetForExternalIdJPAExecutor(extId);
CoordinatorActionBean action = jpaService.execute(actionGetCmd);
assertNotNull(action);
- assertEquals(action.getId(), actionId);
- assertEquals(action.getExternalId(), extId);
+ assertEquals(actionId, action.getId());
+ assertEquals(status, action.getStatus());
+ assertEquals(pending, action.getPending());
+ assertEquals(extId, action.getExternalId());
+ assertEquals(slaXml, action.getSlaXml());
}
catch (Exception ex) {
ex.printStackTrace();
Modified: incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordActionsGetForJobJPAExecutor.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordActionsGetForJobJPAExecutor.java?rev=1332940&r1=1332939&r2=1332940&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordActionsGetForJobJPAExecutor.java (original)
+++ incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordActionsGetForJobJPAExecutor.java Wed May 2 07:19:11 2012
@@ -1,67 +0,0 @@
-/**
- * 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;
-
-import java.util.List;
-
-import org.apache.oozie.CoordinatorActionBean;
-import org.apache.oozie.CoordinatorJobBean;
-import org.apache.oozie.client.CoordinatorAction;
-import org.apache.oozie.client.CoordinatorJob;
-import org.apache.oozie.local.LocalOozie;
-import org.apache.oozie.service.JPAService;
-import org.apache.oozie.service.Services;
-import org.apache.oozie.test.XDataTestCase;
-
-public class TestCoordActionsGetForJobJPAExecutor extends XDataTestCase {
- Services services;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- services = new Services();
- services.init();
- cleanUpDBTables();
- LocalOozie.start();
- }
-
- @Override
- protected void tearDown() throws Exception {
- LocalOozie.stop();
- services.destroy();
- super.tearDown();
- }
-
- public void testCoordActionsGetForJob() throws Exception {
- int actionNum = 1;
- CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, false, false);
- CoordinatorActionBean action = addRecordToCoordActionTable(job.getId(), actionNum,
- CoordinatorAction.Status.READY, "coord-action-get.xml", 0);
- _testCoordActionsGetForJob(job, action);
- }
-
- private void _testCoordActionsGetForJob(CoordinatorJobBean job, CoordinatorActionBean action) throws Exception {
- JPAService jpaService = Services.get().get(JPAService.class);
- assertNotNull(jpaService);
- CoordActionsGetForJobJPAExecutor coordGetCmd = new CoordActionsGetForJobJPAExecutor(job.getId());
- List<CoordinatorActionBean> ret = jpaService.execute(coordGetCmd);
- assertNotNull(ret);
- assertEquals(ret.size(), 1);
- }
-
-}
Modified: incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordActionsRunningGetJPAExecutor.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordActionsRunningGetJPAExecutor.java?rev=1332940&r1=1332939&r2=1332940&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordActionsRunningGetJPAExecutor.java (original)
+++ incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordActionsRunningGetJPAExecutor.java Wed May 2 07:19:11 2012
@@ -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.
@@ -60,10 +60,10 @@ public class TestCoordActionsRunningGetJ
assertNotNull(jpaService);
CoordActionsRunningGetJPAExecutor coordGetCmd = new CoordActionsRunningGetJPAExecutor(0);
- List<CoordinatorActionBean> ret = jpaService.execute(coordGetCmd);
+ List<String> coordActionIds = jpaService.execute(coordGetCmd);
- assertNotNull(ret);
- assertEquals(ret.size(), 1);
+ assertNotNull(coordActionIds);
+ assertEquals(1, coordActionIds.size());
}
}
Modified: incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobGetActionByActionNumberJPAExecutor.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobGetActionByActionNumberJPAExecutor.java?rev=1332940&r1=1332939&r2=1332940&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobGetActionByActionNumberJPAExecutor.java (original)
+++ incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobGetActionByActionNumberJPAExecutor.java Wed May 2 07:19:11 2012
@@ -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.
@@ -59,9 +59,9 @@ public class TestCoordJobGetActionByActi
assertNotNull(jpaService);
CoordJobGetActionByActionNumberJPAExecutor coordGetCmd = new CoordJobGetActionByActionNumberJPAExecutor(job
.getId(), action.getActionNumber());
- CoordinatorActionBean ret = jpaService.execute(coordGetCmd);
- assertNotNull(ret);
- assertEquals(ret.getId(), action.getId());
+ String actionId = jpaService.execute(coordGetCmd);
+ assertNotNull(actionId);
+ assertEquals(actionId, action.getId());
}
}
Modified: incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobGetActionsJPAExecutor.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobGetActionsJPAExecutor.java?rev=1332940&r1=1332939&r2=1332940&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobGetActionsJPAExecutor.java (original)
+++ incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobGetActionsJPAExecutor.java Wed May 2 07:19:11 2012
@@ -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.
@@ -59,9 +59,8 @@ public class TestCoordJobGetActionsJPAEx
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobGetActionsJPAExecutor actionGetCmd = new CoordJobGetActionsJPAExecutor(jobId);
- List<CoordinatorActionBean> actions = jpaService.execute(actionGetCmd);
- assertEquals(actions.size(), 1);
- assertEquals(actions.get(0).getId(), actionId);
+ int actionsSize = jpaService.execute(actionGetCmd);
+ assertEquals(1, actionsSize);
}
}
Modified: incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobGetActionsSubsetJPAExecutor.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobGetActionsSubsetJPAExecutor.java?rev=1332940&r1=1332939&r2=1332940&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobGetActionsSubsetJPAExecutor.java (original)
+++ incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobGetActionsSubsetJPAExecutor.java Wed May 2 07:19:11 2012
@@ -19,8 +19,10 @@ package org.apache.oozie.executor.jpa;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Date;
import java.util.List;
+import org.apache.hadoop.fs.Path;
import org.apache.oozie.CoordinatorActionBean;
import org.apache.oozie.CoordinatorJobBean;
import org.apache.oozie.client.CoordinatorAction;
@@ -29,6 +31,7 @@ import org.apache.oozie.local.LocalOozie
import org.apache.oozie.service.JPAService;
import org.apache.oozie.service.Services;
import org.apache.oozie.test.XDataTestCase;
+import org.apache.oozie.util.DateUtils;
public class TestCoordJobGetActionsSubsetJPAExecutor extends XDataTestCase {
Services services;
@@ -51,19 +54,60 @@ public class TestCoordJobGetActionsSubse
public void testCoordActionGet() throws Exception {
int actionNum = 1;
+ String resourceXmlName = "coord-action-get.xml";
+ Date dummyCreationTime = new Date();
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, false, false);
- CoordinatorActionBean action = addRecordToCoordActionTable(job.getId(), actionNum, CoordinatorAction.Status.WAITING, "coord-action-get.xml", 0);
+ CoordinatorActionBean action = createCoordAction(job.getId(), actionNum, CoordinatorAction.Status.WAITING, resourceXmlName, 0);
+ // Add some attributes
+ action.setConsoleUrl("consoleUrl");
+ action.setExternalStatus("externalStatus");
+ action.setErrorCode("errorCode");
+ action.setErrorMessage("errorMessage");
+ action.setTrackerUri("trackerUri");
+ action.setCreatedTime(dummyCreationTime);
+ String testDir = getTestCaseDir();
+ String missDeps = "file://#testDir/2009/29/_SUCCESS#file://#testDir/2009/22/_SUCCESS#file://#testDir/2009/15/_SUCCESS#file://#testDir/2009/08/_SUCCESS";
+ missDeps = missDeps.replaceAll("#testDir", testDir);
+ action.setMissingDependencies(missDeps);
+ action.setTimeOut(10);
+ // Insert the action
+ insertRecordCoordAction(action);
+
+ Path appPath = new Path(getFsTestCaseDir(), "coord");
+ String actionXml = getCoordActionXml(appPath, resourceXmlName);
+ String actionNominalTime = getActionNominalTime(actionXml);
+ //Pass expected values
+ _testGetActionsSubset(job.getId(), action.getId(), 1, 1, "consoleUrl", "errorCode", "errorMessage",
+ action.getId() + "_E", "externalStatus", "trackerUri", dummyCreationTime,
+ DateUtils.parseDateUTC(actionNominalTime), missDeps, 10, CoordinatorAction.Status.WAITING);
- _testGetActionsSubset(job.getId(), action.getId(), 1, 1);
}
- private void _testGetActionsSubset(String jobId, String actionId, int start, int len) throws Exception {
+ private void _testGetActionsSubset(String jobId, String actionId, int start, int len, String consoleUrl,
+ String errorCode, String errorMessage, String externalId, String externalStatus, String trackerUri,
+ Date createdTime, Date nominalTime, String missDeps, int timeout, CoordinatorAction.Status status)
+ throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
- CoordJobGetActionsSubsetJPAExecutor actionGetCmd = new CoordJobGetActionsSubsetJPAExecutor(jobId, Collections.<String>emptyList(), start, len);
+ CoordJobGetActionsSubsetJPAExecutor actionGetCmd = new CoordJobGetActionsSubsetJPAExecutor(jobId,
+ Collections.<String> emptyList(), start, len);
List<CoordinatorActionBean> actions = jpaService.execute(actionGetCmd);
- assertEquals(actions.size(), 1);
- assertEquals(actions.get(0).getId(), actionId);
+ CoordinatorActionBean action = actions.get(0);
+
+ assertEquals(1, actions.size());
+ assertEquals(actionId, action.getId());
+ assertEquals(jobId, action.getJobId());
+ assertEquals(consoleUrl, action.getConsoleUrl());
+ assertEquals(errorCode, action.getErrorCode());
+ assertEquals(errorMessage, action.getErrorMessage());
+ assertEquals(externalId, action.getExternalId());
+ assertEquals(externalStatus, action.getExternalStatus());
+ assertEquals(trackerUri, action.getTrackerUri());
+ assertEquals(createdTime, action.getCreatedTime());
+ assertEquals(nominalTime, action.getNominalTime());
+ assertEquals(missDeps, action.getMissingDependencies());
+ assertEquals(timeout, action.getTimeOut());
+ assertEquals(status, action.getStatus());
}
// Check the ordering of actions by nominal time
@@ -116,4 +160,36 @@ public class TestCoordJobGetActionsSubse
assertEquals(actions.get(0).getActionNumber(), 1);
}
+ public void testGetActionAllColumns() throws Exception{
+ setSystemProperty(CoordActionGetForInfoJPAExecutor.COORD_GET_ALL_COLS_FOR_ACTION, "true");
+ new Services().init();
+ try {
+ int actionNum = 1;
+ String slaXml = "slaXml";
+ String resourceXmlName = "coord-action-get.xml";
+ CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, false, false);
+ CoordinatorActionBean action = createCoordAction(job.getId(), actionNum, CoordinatorAction.Status.WAITING,
+ resourceXmlName, 0);
+ action.setSlaXml(slaXml);
+ insertRecordCoordAction(action);
+ _testGetForInfoAllActions(job.getId(), slaXml, 1, 1);
+ }
+ finally {
+ Services.get().destroy();
+ }
+ }
+
+ private void _testGetForInfoAllActions(String jobId, String slaXml, int start, int len) throws Exception {
+ JPAService jpaService = Services.get().get(JPAService.class);
+ assertNotNull(jpaService);
+ CoordJobGetActionsSubsetJPAExecutor actionGetCmd = new CoordJobGetActionsSubsetJPAExecutor(jobId,
+ Collections.<String> emptyList(), start, len);
+ List<CoordinatorActionBean> actions = jpaService.execute(actionGetCmd);
+ CoordinatorActionBean action = actions.get(0);
+
+ assertEquals(CoordinatorAction.Status.WAITING, action.getStatus());
+ assertEquals(slaXml, action.getSlaXml());
+ assertEquals(0, action.getPending());
+ }
+
}
Modified: incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobGetReadyActionsJPAExecutor.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobGetReadyActionsJPAExecutor.java?rev=1332940&r1=1332939&r2=1332940&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobGetReadyActionsJPAExecutor.java (original)
+++ incubator/oozie/trunk/core/src/test/java/org/apache/oozie/executor/jpa/TestCoordJobGetReadyActionsJPAExecutor.java Wed May 2 07:19:11 2012
@@ -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.
Modified: incubator/oozie/trunk/core/src/test/java/org/apache/oozie/store/TestCoordinatorStore.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/store/TestCoordinatorStore.java?rev=1332940&r1=1332939&r2=1332940&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/test/java/org/apache/oozie/store/TestCoordinatorStore.java (original)
+++ incubator/oozie/trunk/core/src/test/java/org/apache/oozie/store/TestCoordinatorStore.java Wed May 2 07:19:11 2012
@@ -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.
@@ -63,7 +63,6 @@ public class TestCoordinatorStore extend
_testGetActionForJob(jobId, actionId);
_testGetActionForJobInExecOrder(jobId, actionId);
_testGetActionForJobInLastOnly(jobId, actionId);
- _testGetActionByExternalId(actionId, actionId + "_E");
_testGetActionRunningCount(actionId);
_testGetRecoveryActionsGroupByJobId(jobId);
_testUpdateCoordAction(actionId);
@@ -139,20 +138,6 @@ public class TestCoordinatorStore extend
}
}
- private void _testGetActionByExternalId(String actionId, String extId) {
- store.beginTrx();
- try {
- CoordinatorActionBean action = store.getCoordinatorActionForExternalId(extId);
- assertEquals(action.getId(), actionId);
- assertEquals(action.getExternalId(), extId);
- store.commitTrx();
- }
- catch (Exception ex) {
- store.rollbackTrx();
- ex.printStackTrace();
- fail("Unable to GET a record for COORD ActionBy External ID. actionId =" + actionId + " extID =" + extId);
- }
- }
private void _testGetActionForJobInExecOrder(String jobId, String actionId) {
store.beginTrx();
@@ -189,14 +174,8 @@ public class TestCoordinatorStore extend
private void _testGetActionForJob(String jobId, String actionId) {
store.beginTrx();
try {
- List<CoordinatorActionBean> actionList = store.getActionsForCoordinatorJob(jobId, false);
- assertEquals(actionList.size(), 1);
- CoordinatorActionBean action = actionList.get(0);
- assertEquals(jobId, action.getJobId());
- assertEquals(actionId, action.getId());
- assertEquals(action.getStatus(), CoordinatorAction.Status.READY);
- assertEquals(action.getActionNumber(), 1);
- assertEquals(action.getExternalId(), actionId + "_E");
+ int coordActionsCount = store.getActionsForCoordinatorJob(jobId, false);
+ assertEquals(coordActionsCount, 1);
store.commitTrx();
}
catch (Exception ex) {
Modified: incubator/oozie/trunk/core/src/test/java/org/apache/oozie/test/XDataTestCase.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/test/XDataTestCase.java?rev=1332940&r1=1332939&r2=1332940&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/test/java/org/apache/oozie/test/XDataTestCase.java (original)
+++ incubator/oozie/trunk/core/src/test/java/org/apache/oozie/test/XDataTestCase.java Wed May 2 07:19:11 2012
@@ -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.
@@ -79,6 +79,15 @@ import org.jdom.JDOMException;
public abstract class XDataTestCase extends XFsTestCase {
+ protected static String slaXml = " <sla:info xmlns:sla='uri:oozie:sla:0.1'>" + " <sla:app-name>test-app</sla:app-name>"
+ + " <sla:nominal-time>2009-03-06T10:00Z</sla:nominal-time>" + " <sla:should-start>5</sla:should-start>"
+ + " <sla:should-end>120</sla:should-end>"
+ + " <sla:notification-msg>Notifying User for nominal time : 2009-03-06T10:00Z </sla:notification-msg>"
+ + " <sla:alert-contact>abc@yahoo.com</sla:alert-contact>"
+ + " <sla:dev-contact>abc@yahoo.com</sla:dev-contact>"
+ + " <sla:qa-contact>abc@yahoo.com</sla:qa-contact>" + " <sla:se-contact>abc@yahoo.com</sla:se-contact>"
+ + "</sla:info>";
+
/**
* Insert coord job for testing.
*
@@ -1093,4 +1102,23 @@ public abstract class XDataTestCase exte
}
}
+ /**
+ * Inserts a record to coord action table
+ * @param action the record to be inserted
+ * @throws Exception
+ */
+ protected void insertRecordCoordAction(CoordinatorActionBean action) throws Exception {
+ try {
+ JPAService jpaService = Services.get().get(JPAService.class);
+ assertNotNull(jpaService);
+ CoordActionInsertJPAExecutor coordActionInsertCmd = new CoordActionInsertJPAExecutor(action);
+ jpaService.execute(coordActionInsertCmd);
+ }
+ catch (JPAExecutorException je) {
+ je.printStackTrace();
+ fail("Unable to insert the test coord action record to table");
+ throw je;
+ }
+ }
+
}
Modified: incubator/oozie/trunk/core/src/test/java/org/apache/oozie/util/TestCoordActionsInDateRange.java
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/util/TestCoordActionsInDateRange.java?rev=1332940&r1=1332939&r2=1332940&view=diff
==============================================================================
--- incubator/oozie/trunk/core/src/test/java/org/apache/oozie/util/TestCoordActionsInDateRange.java (original)
+++ incubator/oozie/trunk/core/src/test/java/org/apache/oozie/util/TestCoordActionsInDateRange.java Wed May 2 07:19:11 2012
@@ -74,7 +74,7 @@ public class TestCoordActionsInDateRange
// Test a bad date format.
try {
String badDate = "bad" + date1;
- CoordActionsInDateRange.getCoordActionsFromDates(
+ CoordActionsInDateRange.getCoordActionIdsFromDates(
job.getId().toString(),
badDate + "::" + date2);
fail("Accepted badly formatted date: " + badDate);
@@ -86,7 +86,7 @@ public class TestCoordActionsInDateRange
// Test a bad scope.
try {
String badScope = date1 + "0xbad5c09e" + date2;
- CoordActionsInDateRange.getCoordActionsFromDates(
+ CoordActionsInDateRange.getCoordActionIdsFromDates(
job.getId().toString(),
badScope);
fail("Accepted bad range scope: " + badScope);
@@ -97,7 +97,7 @@ public class TestCoordActionsInDateRange
// Test inverted start and end dates.
try {
- CoordActionsInDateRange.getCoordActionsFromDates(
+ CoordActionsInDateRange.getCoordActionIdsFromDates(
job.getId().toString(),
date2 + "::" + date1);
fail("Accepted inverted dates: [Start::End] = " + date2 + "::" + date1);
@@ -107,12 +107,12 @@ public class TestCoordActionsInDateRange
}
// Testing for the number of coordinator actions in a date range that spans from half an hour prior to the nominal time to 1 hour after the nominal time
- int noOfActions = CoordActionsInDateRange.getCoordActionsFromDates(job.getId().toString(), date1 + "::" + date2).size();
+ int noOfActions = CoordActionsInDateRange.getCoordActionIdsFromDates(job.getId().toString(), date1 + "::" + date2).size();
assertEquals(1, noOfActions);
// Testing for the number of coordinator actions in a date range that spans from half an hour after the nominal time to 1 hour after the nominal time
date1 = DateUtils.formatDateUTC(new Date(nominalTimeMilliseconds + (noOfMillisecondsinOneHour / 2)));
- noOfActions = CoordActionsInDateRange.getCoordActionsFromDates(job.getId().toString(), date1 + "::" + date2).size();
+ noOfActions = CoordActionsInDateRange.getCoordActionIdsFromDates(job.getId().toString(), date1 + "::" + date2).size();
assertEquals(0, noOfActions);
}
catch (Exception e) {
Modified: incubator/oozie/trunk/release-log.txt
URL: http://svn.apache.org/viewvc/incubator/oozie/trunk/release-log.txt?rev=1332940&r1=1332939&r2=1332940&view=diff
==============================================================================
--- incubator/oozie/trunk/release-log.txt (original)
+++ incubator/oozie/trunk/release-log.txt Wed May 2 07:19:11 2012
@@ -1,5 +1,6 @@
-- Oozie 3.2.0 release
+OOZIE-815: Remove select * from queries related to coord action (Virag via Mohammad)
OOZIE-826: TestCoordKillXCommand's testCoordKillXCommandUniqueness testcase is failing after interrupt changes(virag via Mohammad)
OOZIE-819: Interrupt map doesn't have unique set of commands for a given jobid(virag via Mohammad)
OOZIE-810 Modify Oozie POM to pickup doxia 9.2y from a repo where it is avail(tucu via Mohammad)