Generating an update event externally

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Generating an update event externally

Dmitriy Moroz
Gents,

Is it possible to make the event list tick externally, that is, without adding or removing elements?

In my program, I need to extend the original ATF with some columns that get data from a market data source. The original ATF wraps a table and ticks naturally whenever something changes in the table. Extended columns will tap into the external market data source cache. The question is -- when market data ticks, how do I let the pipeline know to update itself? Normally this is done through beginEvent()/comitEvent() pair in ListEventAssembler, but that kitchen is internal to the EventList.

Is there a way to externally generate an update event on a list (without adding/removing elements) to force an update sequence?

Thanks
-Dmitriy
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Generating an update event externally

James Lemieux
There is no way in the GL library to "externally" generate such a ListEvent. We've seen this behavior accomplished in the past by inserting a custom TransformedList into your pipeline resembling this:

        public class Intermediate extends TransformedList {

                protected Intermediate(EventList source) { 
                        super(source); 
                }

                public void listChanged(ListEvent listChanges) { 
                        listChanges.reset(); 
                        updates.forwardEvent(listChanges); 
                }

                public void kick() { 
                        try { 
                                getReadWriteLock().writeLock().lock(); 
                                if (!source.isEmpty()) { 
                                        updates.beginEvent(); 
                                        updates.addUpdate(0, source.size() - 1); 
                                        updates.commitEvent(); 
                                } 
                        } finally { 
                                getReadWriteLock().writeLock().unlock(); 
                        } 
                } 
        }


Is your ticking behavior in response to user input, like clicking a "Refresh" button, or is it periodic on a timer? Perhaps there is room for something like this in the GL core...

James

On Mon, May 11, 2015 at 12:04 PM, Dmitriy Moroz <[hidden email]> wrote:
Gents,

Is it possible to make the event list tick externally, that is, without adding or removing elements?

In my program, I need to extend the original ATF with some columns that get data from a market data source. The original ATF wraps a table and ticks naturally whenever something changes in the table. Extended columns will tap into the external market data source cache. The question is -- when market data ticks, how do I let the pipeline know to update itself? Normally this is done through beginEvent()/comitEvent() pair in ListEventAssembler, but that kitchen is internal to the EventList.

Is there a way to externally generate an update event on a list (without adding/removing elements) to force an update sequence?

Thanks
-Dmitriy

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Generating an update event externally

Dmitriy Moroz
Ehh, dammit...

I already have what you call "kick" (we called it "nudge")...Problem is I can't insert it into the pipeline in this case, the EventList/ATF pair is given to the market data subscription externally and the tables etc will be looking at that one, not the Intermediate...

Thanks for quick response though...

Regards,
-DM


On Mon, May 11, 2015 at 4:10 PM, James Lemieux <[hidden email]> wrote:
There is no way in the GL library to "externally" generate such a ListEvent. We've seen this behavior accomplished in the past by inserting a custom TransformedList into your pipeline resembling this:

        public class Intermediate extends TransformedList {

                protected Intermediate(EventList source) { 
                        super(source); 
                }

                public void listChanged(ListEvent listChanges) { 
                        listChanges.reset(); 
                        updates.forwardEvent(listChanges); 
                }

                public void kick() { 
                        try { 
                                getReadWriteLock().writeLock().lock(); 
                                if (!source.isEmpty()) { 
                                        updates.beginEvent(); 
                                        updates.addUpdate(0, source.size() - 1); 
                                        updates.commitEvent(); 
                                } 
                        } finally { 
                                getReadWriteLock().writeLock().unlock(); 
                        } 
                } 
        }


Is your ticking behavior in response to user input, like clicking a "Refresh" button, or is it periodic on a timer? Perhaps there is room for something like this in the GL core...

James

On Mon, May 11, 2015 at 12:04 PM, Dmitriy Moroz <[hidden email]> wrote:
Gents,

Is it possible to make the event list tick externally, that is, without adding or removing elements?

In my program, I need to extend the original ATF with some columns that get data from a market data source. The original ATF wraps a table and ticks naturally whenever something changes in the table. Extended columns will tap into the external market data source cache. The question is -- when market data ticks, how do I let the pipeline know to update itself? Normally this is done through beginEvent()/comitEvent() pair in ListEventAssembler, but that kitchen is internal to the EventList.

Is there a way to externally generate an update event on a list (without adding/removing elements) to force an update sequence?

Thanks
-Dmitriy


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Generating an update event externally

James Lemieux
It's not clear to me why you can't pass your custom EventList to the "market data subscription." An EventList is an EventList is an EventList.

Are you certain you want to "nudge" the entire EventList's contents when only a (small?) subset of elements are changing? If your number of adds/removes is very small (0?) after creating your pipeline, you could always create a Map over top of the EventList and simply update the individual items as they change...

See <a href="https://svn.java.net/svn/glazedlists~svn/tags/glazedlists-1_9_0/www/api/ca/odell/glazedlists/GlazedLists.html#syncEventListToMap(ca.odell.glazedlists.EventList, ca.odell.glazedlists.FunctionList.Function)">GlazedLists.syncEventListToMap.

On Mon, May 11, 2015 at 1:36 PM, Dmitriy Moroz <[hidden email]> wrote:
Ehh, dammit...

I already have what you call "kick" (we called it "nudge")...Problem is I can't insert it into the pipeline in this case, the EventList/ATF pair is given to the market data subscription externally and the tables etc will be looking at that one, not the Intermediate...

Thanks for quick response though...

Regards,
-DM


On Mon, May 11, 2015 at 4:10 PM, James Lemieux <[hidden email]> wrote:
There is no way in the GL library to "externally" generate such a ListEvent. We've seen this behavior accomplished in the past by inserting a custom TransformedList into your pipeline resembling this:

        public class Intermediate extends TransformedList {

                protected Intermediate(EventList source) { 
                        super(source); 
                }

                public void listChanged(ListEvent listChanges) { 
                        listChanges.reset(); 
                        updates.forwardEvent(listChanges); 
                }

                public void kick() { 
                        try { 
                                getReadWriteLock().writeLock().lock(); 
                                if (!source.isEmpty()) { 
                                        updates.beginEvent(); 
                                        updates.addUpdate(0, source.size() - 1); 
                                        updates.commitEvent(); 
                                } 
                        } finally { 
                                getReadWriteLock().writeLock().unlock(); 
                        } 
                } 
        }


Is your ticking behavior in response to user input, like clicking a "Refresh" button, or is it periodic on a timer? Perhaps there is room for something like this in the GL core...

James

On Mon, May 11, 2015 at 12:04 PM, Dmitriy Moroz <[hidden email]> wrote:
Gents,

Is it possible to make the event list tick externally, that is, without adding or removing elements?

In my program, I need to extend the original ATF with some columns that get data from a market data source. The original ATF wraps a table and ticks naturally whenever something changes in the table. Extended columns will tap into the external market data source cache. The question is -- when market data ticks, how do I let the pipeline know to update itself? Normally this is done through beginEvent()/comitEvent() pair in ListEventAssembler, but that kitchen is internal to the EventList.

Is there a way to externally generate an update event on a list (without adding/removing elements) to force an update sequence?

Thanks
-Dmitriy



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Generating an update event externally

Dmitriy Moroz

James you are correct of course. I'll wrap the source list into the kick list and pass it on up to the models. Forgot that my infra actually allows for that. Thanks.

On May 11, 2015 5:31 PM, "James Lemieux" <[hidden email]> wrote:
It's not clear to me why you can't pass your custom EventList to the "market data subscription." An EventList is an EventList is an EventList.

Are you certain you want to "nudge" the entire EventList's contents when only a (small?) subset of elements are changing? If your number of adds/removes is very small (0?) after creating your pipeline, you could always create a Map over top of the EventList and simply update the individual items as they change...

See GlazedLists.syncEventListToMap.

On Mon, May 11, 2015 at 1:36 PM, Dmitriy Moroz <[hidden email]> wrote:
Ehh, dammit...

I already have what you call "kick" (we called it "nudge")...Problem is I can't insert it into the pipeline in this case, the EventList/ATF pair is given to the market data subscription externally and the tables etc will be looking at that one, not the Intermediate...

Thanks for quick response though...

Regards,
-DM


On Mon, May 11, 2015 at 4:10 PM, James Lemieux <[hidden email]> wrote:
There is no way in the GL library to "externally" generate such a ListEvent. We've seen this behavior accomplished in the past by inserting a custom TransformedList into your pipeline resembling this:

        public class Intermediate extends TransformedList {

                protected Intermediate(EventList source) { 
                        super(source); 
                }

                public void listChanged(ListEvent listChanges) { 
                        listChanges.reset(); 
                        updates.forwardEvent(listChanges); 
                }

                public void kick() { 
                        try { 
                                getReadWriteLock().writeLock().lock(); 
                                if (!source.isEmpty()) { 
                                        updates.beginEvent(); 
                                        updates.addUpdate(0, source.size() - 1); 
                                        updates.commitEvent(); 
                                } 
                        } finally { 
                                getReadWriteLock().writeLock().unlock(); 
                        } 
                } 
        }


Is your ticking behavior in response to user input, like clicking a "Refresh" button, or is it periodic on a timer? Perhaps there is room for something like this in the GL core...

James

On Mon, May 11, 2015 at 12:04 PM, Dmitriy Moroz <[hidden email]> wrote:
Gents,

Is it possible to make the event list tick externally, that is, without adding or removing elements?

In my program, I need to extend the original ATF with some columns that get data from a market data source. The original ATF wraps a table and ticks naturally whenever something changes in the table. Extended columns will tap into the external market data source cache. The question is -- when market data ticks, how do I let the pipeline know to update itself? Normally this is done through beginEvent()/comitEvent() pair in ListEventAssembler, but that kitchen is internal to the EventList.

Is there a way to externally generate an update event on a list (without adding/removing elements) to force an update sequence?

Thanks
-Dmitriy



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Generating an update event externally

James Lemieux
Great! One of the powerful and non-trivial aspect of getting GL "right" was ensuring that data writes flow all of the way to the base of your pipeline. The ListEvents then ripple up from that base. So you'll be able to start your pipeline with BasicEventList -> NudgeList ->... and passing NudgeList into your "market data subscription" area is really the same thing as passing that BasicEventList, since all writes flow through to the BasicEventList anyway. The only meaningful different is the one you actually care about: namely that NudgeList also has a nudge() method on it that "market data subscription" needs to do its job.

Glaze on Dmitriy!

On Mon, May 11, 2015 at 6:12 PM, Dmitriy Moroz <[hidden email]> wrote:

James you are correct of course. I'll wrap the source list into the kick list and pass it on up to the models. Forgot that my infra actually allows for that. Thanks.

On May 11, 2015 5:31 PM, "James Lemieux" <[hidden email]> wrote:
It's not clear to me why you can't pass your custom EventList to the "market data subscription." An EventList is an EventList is an EventList.

Are you certain you want to "nudge" the entire EventList's contents when only a (small?) subset of elements are changing? If your number of adds/removes is very small (0?) after creating your pipeline, you could always create a Map over top of the EventList and simply update the individual items as they change...

See GlazedLists.syncEventListToMap.

On Mon, May 11, 2015 at 1:36 PM, Dmitriy Moroz <[hidden email]> wrote:
Ehh, dammit...

I already have what you call "kick" (we called it "nudge")...Problem is I can't insert it into the pipeline in this case, the EventList/ATF pair is given to the market data subscription externally and the tables etc will be looking at that one, not the Intermediate...

Thanks for quick response though...

Regards,
-DM


On Mon, May 11, 2015 at 4:10 PM, James Lemieux <[hidden email]> wrote:
There is no way in the GL library to "externally" generate such a ListEvent. We've seen this behavior accomplished in the past by inserting a custom TransformedList into your pipeline resembling this:

        public class Intermediate extends TransformedList {

                protected Intermediate(EventList source) { 
                        super(source); 
                }

                public void listChanged(ListEvent listChanges) { 
                        listChanges.reset(); 
                        updates.forwardEvent(listChanges); 
                }

                public void kick() { 
                        try { 
                                getReadWriteLock().writeLock().lock(); 
                                if (!source.isEmpty()) { 
                                        updates.beginEvent(); 
                                        updates.addUpdate(0, source.size() - 1); 
                                        updates.commitEvent(); 
                                } 
                        } finally { 
                                getReadWriteLock().writeLock().unlock(); 
                        } 
                } 
        }


Is your ticking behavior in response to user input, like clicking a "Refresh" button, or is it periodic on a timer? Perhaps there is room for something like this in the GL core...

James

On Mon, May 11, 2015 at 12:04 PM, Dmitriy Moroz <[hidden email]> wrote:
Gents,

Is it possible to make the event list tick externally, that is, without adding or removing elements?

In my program, I need to extend the original ATF with some columns that get data from a market data source. The original ATF wraps a table and ticks naturally whenever something changes in the table. Extended columns will tap into the external market data source cache. The question is -- when market data ticks, how do I let the pipeline know to update itself? Normally this is done through beginEvent()/comitEvent() pair in ListEventAssembler, but that kitchen is internal to the EventList.

Is there a way to externally generate an update event on a list (without adding/removing elements) to force an update sequence?

Thanks
-Dmitriy




Loading...