Re: [rules-users] Drools Fusion: updating event duration
Hi Wolfgang, thanks a lot for the explanation, but i am very sad now. I have to use STREAM mode, because i am implementing a spatio-temporal expert system, so, i need of temporal reasoning. I need to compare events on time too. From my understaning, i am limitated by: - i cannot update timestamp and duration of an event; - i cannot insert a new event with an old timestamp is it right? In a realtime sensor system, i don't receive the event with duration, but i need to correlate them to have an event with duration. Do you have any suggestions? Thanks a lot, Matteo. On Thu, Feb 23, 2012 at 7:39 AM, Wolfgang Laun wolfgang.l...@gmail.comwrote: On 22/02/2012, Edson Tirelli ed.tire...@gmail.com wrote: If your use case somehow has mutable events, you can retract, change the duration and reinsert. But mind the requirements of STREAM mode: Events in each stream must be time-ordered. I.e., inside a given stream, events that happened first must be inserted first into the engine. If reinsertions would violate this, you must run the session in CLOUD mode, which has certain consequences. This is all very well described in the Fusion manual, section on Event Processing Modes. -W The engine uses optimizations for the temporal reasoning that are based on the fact that events should be immutable. That is why the engine resolves the timestamp/duration attributes at insert time and make them immutable. Edson 2012/2/22 Matteo Cusmai cusmaimat...@gmail.com Hi Edson, so, when i want modify an event, i could do as follow: - clone event; - change the duration - retract the previuos event - insert the new event Is it right? Bye bye, Matteo. 2012/2/22 Edson Tirelli ed.tire...@gmail.com Unfortunately you can't update event durations or timestamp. Events are supposed to represent things that happened and as so, are immutable (other than data enrichment). If an event representation is no longer true, that event has to be retracted. Most common case is when you are dealing with atomic events (like start and end atomic events) that represent a complex event. Usually you will have a rule that correlates the start and end atomic events and creates a complex derived event, retracting the atomic ones. Edson 2012/2/22 Matteo Cusmai cusmaimat...@gmail.com Hi all, i am using Drools Fusion in multi sensor data fusion system. I have some rules that generate a new event when some situations occur. But from the other hand, i would like to update the event, when i understand that new sensor observation is referring to the same event. I have my Event clazz with duration field, i try to update it in modify clause, but i have concern about it, because when i use temporal operator (such as before, meets, so on) it seems that Drools manage them as event with duration null. I could post the code too. Bye bye, Matteo. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools Fusion: updating event duration
A couple comments: * The temporal reasoning features/operators are available in both CLOUD and STREAM mode. The biggest differences are that in CLOUD mode there is no automatic garbage collection of old events and you can't use sliding windows, but everything else works. * You can insert events with old timestamps, but in that case it is the rule's author responsibility to understand that sliding windows using that event type might be affected and if running in STREAM mode, you should define an expiration policy for that event type that will keep him in memory for enough time to match any rules that require it. For instance, if in your application events will have a maximum duration of 24hs and because of that they can be inserted into the system with a delay of 24hs, you should define an expiration policy for it that is at least 24hs. Edson 2012/2/24 Matteo Cusmai cusmaimat...@gmail.com Hi Wolfgang, thanks a lot for the explanation, but i am very sad now. I have to use STREAM mode, because i am implementing a spatio-temporal expert system, so, i need of temporal reasoning. I need to compare events on time too. From my understaning, i am limitated by: - i cannot update timestamp and duration of an event; - i cannot insert a new event with an old timestamp is it right? In a realtime sensor system, i don't receive the event with duration, but i need to correlate them to have an event with duration. Do you have any suggestions? Thanks a lot, Matteo. On Thu, Feb 23, 2012 at 7:39 AM, Wolfgang Laun wolfgang.l...@gmail.comwrote: On 22/02/2012, Edson Tirelli ed.tire...@gmail.com wrote: If your use case somehow has mutable events, you can retract, change the duration and reinsert. But mind the requirements of STREAM mode: Events in each stream must be time-ordered. I.e., inside a given stream, events that happened first must be inserted first into the engine. If reinsertions would violate this, you must run the session in CLOUD mode, which has certain consequences. This is all very well described in the Fusion manual, section on Event Processing Modes. -W The engine uses optimizations for the temporal reasoning that are based on the fact that events should be immutable. That is why the engine resolves the timestamp/duration attributes at insert time and make them immutable. Edson 2012/2/22 Matteo Cusmai cusmaimat...@gmail.com Hi Edson, so, when i want modify an event, i could do as follow: - clone event; - change the duration - retract the previuos event - insert the new event Is it right? Bye bye, Matteo. 2012/2/22 Edson Tirelli ed.tire...@gmail.com Unfortunately you can't update event durations or timestamp. Events are supposed to represent things that happened and as so, are immutable (other than data enrichment). If an event representation is no longer true, that event has to be retracted. Most common case is when you are dealing with atomic events (like start and end atomic events) that represent a complex event. Usually you will have a rule that correlates the start and end atomic events and creates a complex derived event, retracting the atomic ones. Edson 2012/2/22 Matteo Cusmai cusmaimat...@gmail.com Hi all, i am using Drools Fusion in multi sensor data fusion system. I have some rules that generate a new event when some situations occur. But from the other hand, i would like to update the event, when i understand that new sensor observation is referring to the same event. I have my Event clazz with duration field, i try to update it in modify clause, but i have concern about it, because when i use temporal operator (such as before, meets, so on) it seems that Drools manage them as event with duration null. I could post the code too. Bye bye, Matteo. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss
[rules-users] Drools Fusion: updating event duration
Hi all, i am using Drools Fusion in multi sensor data fusion system. I have some rules that generate a new event when some situations occur. But from the other hand, i would like to update the event, when i understand that new sensor observation is referring to the same event. I have my Event clazz with duration field, i try to update it in modify clause, but i have concern about it, because when i use temporal operator (such as before, meets, so on) it seems that Drools manage them as event with duration null. I could post the code too. Bye bye, Matteo. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools Fusion: updating event duration
A minimum but complete set of *.java and *.drl files would help. -W 2012/2/22 Matteo Cusmai cusmaimat...@gmail.com Hi all, i am using Drools Fusion in multi sensor data fusion system. I have some rules that generate a new event when some situations occur. But from the other hand, i would like to update the event, when i understand that new sensor observation is referring to the same event. I have my Event clazz with duration field, i try to update it in modify clause, but i have concern about it, because when i use temporal operator (such as before, meets, so on) it seems that Drools manage them as event with duration null. I could post the code too. Bye bye, Matteo. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools Fusion: updating event duration
Hi Wolfgang, this is an extract of drl file: declare GasObservation @role(event) @startTimestamp(timestamp) @expires( 10s ) @duration(duration) end declare GasEvent @startTimestamp(timestampDate) @role(event) @duration(duration) end rule gas1-event no-loop when $obs: GasObservation( $obsLocation : location, gasname == UN 1017, value 60 ) over window:length(1) from entry-point lowLevelSensorStream not GasEvent( location geoIsWithinDistance[ 5m ] $obsLocation, gasname == UN 1017, this before[1s, 25s] $obs ) then insert(new GasEvent( $obs, UN 1017 value threshold[60], Event.THREAT_HIGH, $obsLocation, $obs.getSensor())); end rule gas1-event-update no-loop when $obs: GasObservation( $obsLocation : location, gasname == UN 1017, value 60 ) over window:length(1) from entry-point lowLevelSensorStream $event : GasEvent( location geoIsWithinDistance[ 5m ] $obsLocation, gasname == UN 1017, this before[1s, 25s] $obs ) then modify($event) { updateDuration(), addObservation($obs) } end and these are abstract Observation class and abstract Event public abstract class Observation implements Serializable { /** * */ private static final long serialVersionUID = 3483256523801072709L; private long timestamp; private long duration; private Geometry location; private Sensor sensor; public long getTimestamp() { return timestamp; } public void setTimestamp(long timestamp) { this.timestamp = timestamp; } public long getDuration() { return duration; } public void setDuration(long duration) { this.duration = duration; } public Sensor getSensor() { return sensor; } public void setSensor(Sensor sensor) { this.sensor = sensor; } public Geometry getLocation() { return location; } public void setLocation(Geometry location) { this.location = location; } /** * @param newTimeStamp * this methods allows to update the duration of event by setting the timestamp of new observation. */ public void updateDuration(long newTimeStamp) { setDuration(newTimeStamp - getTimestamp()); } public Date getTimestampDate() { return new Date(timestamp); } public void setTimestampDate(Date timestamp) { this.timestamp = timestamp.getTime(); } public Observation(Sensor sensor, Geometry location, long timestamp) { this.setLocation(location); this.setTimestamp( timestamp ); this.setSensor( sensor ); } /** * @return identification by servicename:timestamp */ public String getServiceIdentification() { return getSensor().getServiceName() + : + getTimestamp() ; } } public abstract class Event implements Serializable { . /** * */ private static final long serialVersionUID = 1L; /** * The timestamp of event. */ private long timestamp; /** * The level of threat of the event. */ private int threat_level; /** * The description of event. */ private String description; /** * The location of event. */ private Geometry location; /** * Duration of event. */ private long duration; /** * Id of sensor. */ private Sensor sensor; /** * The map feature involved into Event. */ private MapFeature feature; /** * link to the timestamp of parent event. */ private long parent; private CollectionObservation observations; private CollectionEvent relatedEvents; public abstract int getType(); public CollectionObservation getObservations() { return observations; } public void addObservation(Observation obs) { observations.add(obs); } public CollectionEvent getRelatedEvents() { return relatedEvents; } public void addRelatedEvent(Event evnt) { relatedEvents.add(evnt); } public Sensor getSensor() { return sensor; } public void setSensor(Sensor sensorId) { this.sensor = sensorId; } public long getDuration() { return duration; } public void setDuration(long duration) { this.duration = duration; } public int getThreat_level() { return threat_level; } public void setThreat_level(int threatLevel) { threat_level = threatLevel; } /** * @param newTimeStamp * this methods allows to update the duration of event by setting the timestamp of new observation. */ public void updateDuration() { setDuration(System.currentTimeMillis() - getTimestamp()); } public long getTimestamp() { return timestamp; } public void setTimestamp(long timestamp) { this.timestamp = timestamp; } public Date getTimestampDate() { return new Date(timestamp); } public void setTimestampDate(Date timestamp) { this.timestamp = timestamp.getTime(); } public String getDescription() { return description; }
Re: [rules-users] Drools Fusion: updating event duration
Unfortunately you can't update event durations or timestamp. Events are supposed to represent things that happened and as so, are immutable (other than data enrichment). If an event representation is no longer true, that event has to be retracted. Most common case is when you are dealing with atomic events (like start and end atomic events) that represent a complex event. Usually you will have a rule that correlates the start and end atomic events and creates a complex derived event, retracting the atomic ones. Edson 2012/2/22 Matteo Cusmai cusmaimat...@gmail.com Hi all, i am using Drools Fusion in multi sensor data fusion system. I have some rules that generate a new event when some situations occur. But from the other hand, i would like to update the event, when i understand that new sensor observation is referring to the same event. I have my Event clazz with duration field, i try to update it in modify clause, but i have concern about it, because when i use temporal operator (such as before, meets, so on) it seems that Drools manage them as event with duration null. I could post the code too. Bye bye, Matteo. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools Fusion: updating event duration
Hi Edson, so, when i want modify an event, i could do as follow: - clone event; - change the duration - retract the previuos event - insert the new event Is it right? Bye bye, Matteo. 2012/2/22 Edson Tirelli ed.tire...@gmail.com Unfortunately you can't update event durations or timestamp. Events are supposed to represent things that happened and as so, are immutable (other than data enrichment). If an event representation is no longer true, that event has to be retracted. Most common case is when you are dealing with atomic events (like start and end atomic events) that represent a complex event. Usually you will have a rule that correlates the start and end atomic events and creates a complex derived event, retracting the atomic ones. Edson 2012/2/22 Matteo Cusmai cusmaimat...@gmail.com Hi all, i am using Drools Fusion in multi sensor data fusion system. I have some rules that generate a new event when some situations occur. But from the other hand, i would like to update the event, when i understand that new sensor observation is referring to the same event. I have my Event clazz with duration field, i try to update it in modify clause, but i have concern about it, because when i use temporal operator (such as before, meets, so on) it seems that Drools manage them as event with duration null. I could post the code too. Bye bye, Matteo. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools Fusion: updating event duration
If your use case somehow has mutable events, you can retract, change the duration and reinsert. The engine uses optimizations for the temporal reasoning that are based on the fact that events should be immutable. That is why the engine resolves the timestamp/duration attributes at insert time and make them immutable. Edson 2012/2/22 Matteo Cusmai cusmaimat...@gmail.com Hi Edson, so, when i want modify an event, i could do as follow: - clone event; - change the duration - retract the previuos event - insert the new event Is it right? Bye bye, Matteo. 2012/2/22 Edson Tirelli ed.tire...@gmail.com Unfortunately you can't update event durations or timestamp. Events are supposed to represent things that happened and as so, are immutable (other than data enrichment). If an event representation is no longer true, that event has to be retracted. Most common case is when you are dealing with atomic events (like start and end atomic events) that represent a complex event. Usually you will have a rule that correlates the start and end atomic events and creates a complex derived event, retracting the atomic ones. Edson 2012/2/22 Matteo Cusmai cusmaimat...@gmail.com Hi all, i am using Drools Fusion in multi sensor data fusion system. I have some rules that generate a new event when some situations occur. But from the other hand, i would like to update the event, when i understand that new sensor observation is referring to the same event. I have my Event clazz with duration field, i try to update it in modify clause, but i have concern about it, because when i use temporal operator (such as before, meets, so on) it seems that Drools manage them as event with duration null. I could post the code too. Bye bye, Matteo. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools Fusion: updating event duration
On 22/02/2012, Edson Tirelli ed.tire...@gmail.com wrote: If your use case somehow has mutable events, you can retract, change the duration and reinsert. But mind the requirements of STREAM mode: Events in each stream must be time-ordered. I.e., inside a given stream, events that happened first must be inserted first into the engine. If reinsertions would violate this, you must run the session in CLOUD mode, which has certain consequences. This is all very well described in the Fusion manual, section on Event Processing Modes. -W The engine uses optimizations for the temporal reasoning that are based on the fact that events should be immutable. That is why the engine resolves the timestamp/duration attributes at insert time and make them immutable. Edson 2012/2/22 Matteo Cusmai cusmaimat...@gmail.com Hi Edson, so, when i want modify an event, i could do as follow: - clone event; - change the duration - retract the previuos event - insert the new event Is it right? Bye bye, Matteo. 2012/2/22 Edson Tirelli ed.tire...@gmail.com Unfortunately you can't update event durations or timestamp. Events are supposed to represent things that happened and as so, are immutable (other than data enrichment). If an event representation is no longer true, that event has to be retracted. Most common case is when you are dealing with atomic events (like start and end atomic events) that represent a complex event. Usually you will have a rule that correlates the start and end atomic events and creates a complex derived event, retracting the atomic ones. Edson 2012/2/22 Matteo Cusmai cusmaimat...@gmail.com Hi all, i am using Drools Fusion in multi sensor data fusion system. I have some rules that generate a new event when some situations occur. But from the other hand, i would like to update the event, when i understand that new sensor observation is referring to the same event. I have my Event clazz with duration field, i try to update it in modify clause, but i have concern about it, because when i use temporal operator (such as before, meets, so on) it seems that Drools manage them as event with duration null. I could post the code too. Bye bye, Matteo. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users