This project has retired. For details please refer to its
Attic page.
001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018 package org.apache.oozie.command.coord;
019
020 import org.apache.oozie.CoordinatorJobBean;
021 import org.apache.oozie.command.CommandException;
022 import org.apache.oozie.store.CoordinatorStore;
023 import org.apache.oozie.store.StoreException;
024 import org.apache.oozie.util.ParamChecker;
025 import org.apache.oozie.util.XLog;
026
027 /**
028 * Command for loading a coordinator job information
029 */
030 public class CoordJobCommand extends CoordinatorCommand<CoordinatorJobBean> {
031 private String id;
032 private boolean getActionInfo;
033 private int start = 1;
034 private int len = Integer.MAX_VALUE;
035
036 /**
037 * @param id coord jobId
038 */
039 public CoordJobCommand(String id) {
040 this(id, 1, Integer.MAX_VALUE);
041 }
042
043 /**
044 * @param id coord jobId
045 * @param start starting index in the list of actions belonging to the job
046 * @param length number of actions to be returned
047 */
048 public CoordJobCommand(String id, int start, int length) {
049 super("job.info", "job.info", 1, XLog.OPS);
050 this.id = ParamChecker.notEmpty(id, "id");
051 this.getActionInfo = true;
052 this.start = start;
053 this.len = length;
054 }
055
056 /**
057 * @param id coord jobId
058 * @param getActionInfo false to ignore loading actions for the job
059 */
060 public CoordJobCommand(String id, boolean getActionInfo) {
061 super("job.info", "job.info", 1, XLog.OPS);
062 this.id = ParamChecker.notEmpty(id, "id");
063 this.getActionInfo = getActionInfo;
064 }
065
066 @Override
067 protected CoordinatorJobBean call(CoordinatorStore store) throws StoreException, CommandException {
068 CoordinatorJobBean coord = store.getCoordinatorJob(id, false);
069 if (this.getActionInfo == true) {
070 coord.setActions(store.getActionsSubsetForCoordinatorJob(id, start, len));
071 }
072 else {
073 coord.setActions(null);
074 }
075 return coord;
076 }
077
078 }