cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lon Varscsak <lon.varsc...@gmail.com>
Subject Re: Peer Context Synchronization
Date Wed, 24 Apr 2013 21:19:15 GMT
Okay, cool, thanks for the info Andrus!

Is the performance issue true even if the objects aren't in both contexts?
 Just curious.

In my case (at least for this one app), it being synchronous shouldn't
create much of a problem.  While I create many contexts when doing work,
they're only temporary…and there are only a few persistent contexts lying
around.

-Lon


On Wed, Apr 24, 2013 at 11:51 AM, Andrus Adamchik <andrus@objectstyle.org>wrote:

> Yes, performance implications are pretty serious. To a point that in my
> webapps I am completely turning off cross-context syncing via a DI
> property, as even async process is O(N) as far as resource consumption, and
> in an app with a large number of active contexts things are going to get
> bad pretty quickly.
>
> There are a few ways you can deal with it:
>
> 1. You can listen for DataChannel.GRAPH_CHANGED_SUBJECT subject for a
> given context (or all contexts at once, if that makes sense in your app) :
>
> // here is how you access EventManager to register listeners:
> EventManager em = runtime.getChannel().getEventManager();
>
> // register listener
> em.addListener(listener, "xyzMethod", GraphEvent.class,
> DataChannel.GRAPH_CHANGED_SUBJECT, myContext);
>
> 2. You can override ObjectStoreFactory in DI to implement synchronous
> events (isn't it cool to have a DI-based framework :))
>
> // implement the factory
> public class MyObjectStoreFactory implements ObjectStoreFactory {
>  // check DefaultObjectStoreFactory for details, create a sublcass of
> ObjectStore,
>  // overriding 'setDataRowCache'
> }
>
> // bind it in a custom module:
> binder.bind(ObjectStoreFactory.class).toIn(MyObjectStoreFactory.class);
>
> Andrus
>
>
> On Apr 24, 2013, at 2:34 PM, Lon Varscsak <lon.varscsak@gmail.com> wrote:
> > Is there any way to control that behavior?  Like is there a way for my
> code
> > to wait for that to complete?  I understand the performance
> considerations,
> > but it's a fairly common pattern for me (from the WO/EOF space) to expect
> > this to be done before any more of my code gets executed.
> >
> > Thanks,
> >
> > Lon
> >
> >
> > On Wed, Apr 24, 2013 at 11:26 AM, Andrus Adamchik <
> andrus@objectstyle.org>wrote:
> >
> >> Hi Lon,
> >>
> >> Context update is immediate, but asynchronous, so this likely explains
> the
> >> observed behavior.
> >>
> >> Andrus
> >>
> >> On Apr 24, 2013, at 2:14 PM, Lon Varscsak <lon.varscsak@gmail.com>
> wrote:
> >>> Hey all, I'm having some trouble with something that I _think_ should
> >> work.
> >>> :)
> >>>
> >>> It's a very common pattern for me to create a new context, do work,
> save,
> >>> and expect those changes to make it back into peer contexts that share
> >>> object ids.
> >>>
> >>> However, there are times where this isn't happening…and it's
> >> intermittent.
> >>>
> >>> My model in this situation is pretty simple, there's EntityA with a
> >> to-many
> >>> to EntityB.  In a peer context, I'm creating an EntityB and adding it
> to
> >>> the relationship of EntityA (a local instance), and generally speaking,
> >> in
> >>> my other peer context the matching instance of EntityA is updated and
> has
> >>> the proper EntityB in it's relationship (after commitChanges).
> >>>
> >>> However, occasionally…maybe 1 in 10, the peer context doesn't get
> >>> immediately updated (although will, I believe, at a later time).
> >>>
> >>> So the question is, does commitChanges immediately/synchronously push
> all
> >>> changes into peer contexts?  Or does it happen in another way?
> >>>
> >>> Thanks for any insight.
> >>>
> >>> -Lon
> >>
> >>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message