001 /**
002 * Copyright (c) 2010 Yahoo! Inc. All rights reserved.
003 * Licensed under the Apache License, Version 2.0 (the "License");
004 * you may not use this file except in compliance with the License.
005 * You may obtain a copy of the License at
006 *
007 * http://www.apache.org/licenses/LICENSE-2.0
008 *
009 * Unless required by applicable law or agreed to in writing, software
010 * distributed under the License is distributed on an "AS IS" BASIS,
011 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012 * See the License for the specific language governing permissions and
013 * limitations under the License. See accompanying LICENSE file.
014 */
015 package org.apache.oozie.command.coord;
016
017 import java.util.List;
018
019 import org.apache.oozie.SLAEventBean;
020 import org.apache.oozie.command.Command;
021 import org.apache.oozie.command.CommandException;
022 import org.apache.oozie.store.SLAStore;
023 import org.apache.oozie.store.Store;
024 import org.apache.oozie.store.StoreException;
025 import org.apache.oozie.util.XLog;
026
027 public class SLAEventsCommand extends Command<List<SLAEventBean>, SLAStore> {
028
029 private long seqId;
030 private int maxNoEvents;
031 private long lastSeqId = -1;
032
033 public SLAEventsCommand(long seqId, int maxNoEvnts) {
034 super("SLAEventsCommand", "SLAEventsCommand", 1, XLog.OPS);
035 this.seqId = seqId;
036 this.maxNoEvents = maxNoEvnts;
037 }
038
039 @Override
040 protected List<SLAEventBean> call(SLAStore store) throws StoreException, CommandException {
041 long lsId[] = new long[1];
042 List<SLAEventBean> slaEvntList = store.getSLAEventListNewerSeqLimited(seqId, maxNoEvents, lsId);
043 store.getEntityManager().clear();
044 setLastSeqId(lsId[0]);
045 return slaEvntList;
046 }
047
048 public void setLastSeqId(long lastSeqId) {
049 this.lastSeqId = lastSeqId;
050 }
051
052 public long getLastSeqId() {
053 return lastSeqId;
054 }
055
056 @Override
057 public Class<? extends Store> getStoreClass() {
058 // TODO Auto-generated method stub
059 return SLAStore.class;
060 }
061
062 }