Nitin and Kishan, can you give a use case or example for the logic/details you have given. Would it make sense to just simplify the logic based on start time and window/duration and let the developer/user decide how they would want to filter/reduce the response?
Regards. On 10-Dec-2012, at 5:45 AM, Kishan Kavala <kishan.kav...@citrix.com> wrote: > Just to clarify. > The purpose of finding pending events is to list any APIs initiated in the > last x seconds(entry time) and are still not completed after running for at > least y seconds (duration). > For example, To find events for APIs initiated in the last 24 hrs and are not > completed after running for at least 30mins, entry time and duration would be > as follows: > > EntryTime = 86400 > Duration = 3600 > > More info on Events: > http://wiki.cloudstack.org/display/DesignDocs/Action+Events > > Implementation details: > 1. Find all the events created in the last x seconds with start_id = 0 and > not in Completed state, excluding the event started in the last y seconds > 2. Look for the corresponding Completed event > 3. Add to pending list if Completed event is not found. > > ~kishan > > -----Original Message----- > From: Nitin Mehta [mailto:nitin.me...@citrix.com] > Sent: Sunday, 9 December 2012 3:31 PM > To: cloudstack-dev@incubator.apache.org > Subject: Re: Question on ListEventsCmd > > Min - I will take a stab at this. See if this makes sense to you. I haven't > used them but I think the intention of the code should be this. > > If say you want to query events within a time range then you will use these > parameter. Say at this point of time you want to get all the events that took > place in the last 2 mins then you will mention entryTime = 120 and > duration=0. I think the duration should be interpreted as end time and there > reference is from current system time. So entry time means how many seconds > before the current time and duration (end time) is how many seconds before > the current time. > In our example, since we want to query events that happened in the last 120 > secs I mention entry time as 120 and end time as 0 and as is clear the > duration or the end time shouldn't exceed the entry time. > > Please file documentation bugs and test if these params work as intended. > > Thanks, > -Nitin > > On 08-Dec-2012, at 5:07 AM, Min Chen wrote: > >> Hi there, >> >> In refactoring ListEventsCmd api, I ran into the following code which is a >> mystery to me, hope that somebody can explain here: >> >> >> if ((entryTime != null) && (duration != null)) { >> >> if (entryTime <= duration) { >> >> throw new InvalidParameterValueException("Entry time >> must be greater than duration"); >> >> } >> >> Calendar calMin = Calendar.getInstance(); >> >> Calendar calMax = Calendar.getInstance(); >> >> calMin.add(Calendar.SECOND, -entryTime); >> >> calMax.add(Calendar.SECOND, -duration); >> >> Date minTime = calMin.getTime(); >> >> Date maxTime = calMax.getTime(); >> >> >> sc.setParameters("state", >> com.cloud.event.Event.State.Completed); >> >> sc.setParameters("startId", 0); >> >> sc.setParameters("createDate", minTime, maxTime); >> >> List<EventJoinVO> startedEvents = >> _eventJoinDao.searchAllEvents(sc, searchFilter); >> >> List<EventJoinVO> pendingEvents = new >> ArrayList<EventJoinVO>(); >> >> for (EventVO event : startedEvents) { >> >> EventVO completedEvent = >> _eventDao.findCompletedEvent(event.getId()); >> >> if (completedEvent == null) { >> >> pendingEvents.add(event); >> >> } >> >> } >> >> return pendingEvents; >> >> } >> >> >> I have several questions here: >> >> 1. What are entryTime and duration parameters here? Based on API doc, here >> are description on these two cmd parameters: >> >> entryTime: the time the event is entered >> >> duration: the duration of the event >> >> But from code, it seems that they are both Integer type. So not sure how >> to understand the entryTime and duration here, contradictory to my English >> understanding. >> >> 2. In the code above, why must we have "Entry time must be greater than >> duration"? >> >> 3. When user provides entryTime and duration parameters in the search, what >> kind of events are we supposed to return here? I don't quite understand the >> pendingEvents list we are constructing here. >> >> >> Thanks >> >> -min >