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 java.util.List; 021 022 import org.apache.oozie.SLAEventBean; 023 import org.apache.oozie.command.Command; 024 import org.apache.oozie.command.CommandException; 025 import org.apache.oozie.store.SLAStore; 026 import org.apache.oozie.store.Store; 027 import org.apache.oozie.store.StoreException; 028 import org.apache.oozie.util.XLog; 029 030 public class SLAEventsCommand extends Command<List<SLAEventBean>, SLAStore> { 031 032 private long seqId; 033 private int maxNoEvents; 034 private long lastSeqId = -1; 035 036 public SLAEventsCommand(long seqId, int maxNoEvnts) { 037 super("SLAEventsCommand", "SLAEventsCommand", 1, XLog.OPS); 038 this.seqId = seqId; 039 this.maxNoEvents = maxNoEvnts; 040 } 041 042 @Override 043 protected List<SLAEventBean> call(SLAStore store) throws StoreException, CommandException { 044 long lsId[] = new long[1]; 045 List<SLAEventBean> slaEvntList = store.getSLAEventListNewerSeqLimited(seqId, maxNoEvents, lsId); 046 store.getEntityManager().clear(); 047 setLastSeqId(lsId[0]); 048 return slaEvntList; 049 } 050 051 public void setLastSeqId(long lastSeqId) { 052 this.lastSeqId = lastSeqId; 053 } 054 055 public long getLastSeqId() { 056 return lastSeqId; 057 } 058 059 @Override 060 public Class<? extends Store> getStoreClass() { 061 // TODO Auto-generated method stub 062 return SLAStore.class; 063 } 064 065 }