You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by Min Chen <mi...@citrix.com> on 2012/12/08 00:37:23 UTC
Question on ListEventsCmd
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
Re: Question on ListEventsCmd
Posted by Chip Childers <ch...@sungard.com>.
On Mon, Dec 10, 2012 at 1:53 PM, Rohit Yadav <ro...@citrix.com> wrote:
> 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?
IMO, it would!
However, if someone makes this change, please consider that we are
trying to keep the API in our next feature release backward compatible
with 4.0.0-incubating. Otherwise, we'll have to bump up the major
version number, meaning that we would be releasing 5.0.0-incubating.
If we make it easier for an external developer to grok, we should
ensure that the existing params remain as-is in both name and meaning.
-chip
> Regards.
>
> On 10-Dec-2012, at 5:45 AM, Kishan Kavala <Ki...@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.Mehta@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
>>
>
>
Re: Question on ListEventsCmd
Posted by Rohit Yadav <ro...@citrix.com>.
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 <Ki...@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.Mehta@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
>
Re: Question on ListEventsCmd
Posted by prasanna <ts...@apache.org>.
> More info on Events: http://wiki.cloudstack.org/display/DesignDocs/Action+Events
>
moved: https://cwiki.apache.org/confluence/display/CLOUDSTACK/Action+Events
Re: Question on ListEventsCmd
Posted by Min Chen <mi...@citrix.com>.
Kishan, Also, from current implementation logic, it seems that it will not
return those events that are initiated in the last 24 hrs and not
completed after running for 30mins and but already completed now. A major
use case for these two parameters IMHO is to show users those events that
are not completed in the desired SLA window, current implementation seems
missing some of those events.
Thanks
-min
On 12/10/12 10:41 AM, "Min Chen" <mi...@citrix.com> wrote:
>Thanks for your reply. I think that in your example, you meant Duration =
>1800.
>
>Now I understood what is the semantics of using these two parameters. But
>I am wondering how your current logic will work if user passed in pageSize
>and pageNo?
>
>-min
>
>
>On 12/10/12 5:45 AM, "Kishan Kavala" <Ki...@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.Mehta@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
>>
>
Re: Question on ListEventsCmd
Posted by Min Chen <mi...@citrix.com>.
Thanks for your reply. I think that in your example, you meant Duration =
1800.
Now I understood what is the semantics of using these two parameters. But
I am wondering how your current logic will work if user passed in pageSize
and pageNo?
-min
So based on your definition, invoking listEventsCmd?entryTime=x&duration=y
should return all the events that are initiated in the last x seconds
On 12/10/12 5:45 AM, "Kishan Kavala" <Ki...@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.Mehta@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
>
RE: Question on ListEventsCmd
Posted by Kishan Kavala <Ki...@citrix.com>.
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.Mehta@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
Re: Question on ListEventsCmd
Posted by Nitin Mehta <Ni...@citrix.com>.
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