[Saga-devel] Context question

Hartmut Kaiser hkaiser at cct.lsu.edu
Fri Jan 30 08:11:24 CST 2009


Paul,

> This all works as expected now.
> Is there a reason why the defaults aren't set automatically on
> construction of the context?

Initially we have had the context constructor calling the set_defaults() as
long as a type was given to it. As it turned out this lead to other problems
described here: http://fortytwo.cct.lsu.edu:8000/SAGA/ticket/244, but there
was later discussion on the mailing list (attached).

After this discussion we decided to remove the set_defaults() call from
inside the constructor, requiring the explicit call.

HTH
Regards Hartmut



> 
> Thanks,
> 
> Paul.
> 
> 
> -----Original Message-----
> From: Hartmut Kaiser [mailto:hkaiser at cct.lsu.edu]
> Sent: Fri 30/01/2009 13:21
> To: Livesey, P (Paul); saga-devel at cct.lsu.edu
> Subject: RE: [Saga-devel] Context question
> 
> Paul,
> 
> > I have a further question about contexts.
> >
> > After following your example I now have 3 extra attributes on my
> > context, let's call them att1, att2 and att3.
> >
> > I create a context of my required type and set two of the three
> > attributes
> >
> >    saga::context ctx("glite_sd_adaptor");
> >    ctx.set_attribute("att2", "val2");
> >    ctx.set_attribute("att3", "val3");
> 
> At this point you need to explicitly call set_defaults() on your new
> context:
> 
>    ctx.set_defaults();
> 
> which will invoke your set_defaults function in your adaptor.
> 
> Regards Hartmut
> 
> >    saga::session s;
> >    s.add_context(ctx);
> >
> > NOTE: I do not set att1
> >
> > By the time I get to my adaptor, this is exactly what is in my
> context,
> > att2 and att3.
> > How would I get the missing attribute set up by default?  Is there a
> > way of doing this?
> > When in sync_set_defaults I'm seeing all three attributes set with
> > their values from session->add_proto_context()
> >
> > Am I missing something or is this correct behavior?  I expect that
> it's
> > probably my understanding of how the saga engine works.
> >
> > Thanks,
> >
> > Paul.
> >
> > -----Original Message-----
> > From: Hartmut Kaiser [mailto:hkaiser at cct.lsu.edu]
> > Sent: Tue 27/01/2009 16:18
> > To: saga-devel at cct.lsu.edu; Livesey, P (Paul)
> > Subject: RE: [Saga-devel] Context question
> >
> > Paul,
> >
> > > > Further to your email from last week one further question.  If I
> > > needed
> > > > vector attributes on my context (which I do) how would stage 4
> > below
> > > > work?  I presume that vector attributes are allowed.
> > >
> > > Ohh well. I didn't even think about that yet. So it's currently not
> > > supported. But I think it should be easy enough to add. What's your
> > > timeline
> > > on this?
> >
> > Actually, after looking into this it turned out to be _really_ simple
> > to
> > implement, so I went ahead and added a
> >
> >   void saga::impl::session::add_proto_context(
> >     std::vector<std::pair<std::string, std::string> > const&,
> >     std::vector<std::pair<std::string, std::vector<std::string> > >
> > const&
> >   );
> >
> > function overload allowing to specify not only the non-vector
> > attributes as
> > before, but takes a list of proto-vector-attributes as well. Please
> use
> > this
> > instead of the old function if you need to predefine at least one
> > vector
> > attribute.
> >
> > HTH
> > Regards Hartmut
> >
> > >
> > > Regards Hartmut
> > >
> > > >
> > > > Thanks,
> > > >
> > > > Paul.
> > > >
> > > > -----Original Message-----
> > > > From: saga-devel-bounces at cct.lsu.edu
> > > > [mailto:saga-devel-bounces at cct.lsu.edu] On Behalf Of Hartmut
> Kaiser
> > > > Sent: 21 January 2009 13:59
> > > > To: saga-devel at cct.lsu.edu
> > > > Subject: RE: [Saga-devel] Context question
> > > >
> > > >
> > > > 4) Create a proto-context of your type in the constructor of the
> > > > adaptor
> > > > instance (not the CPI!), see default_advert_adaptor.cpp. This has
> > to
> > > be
> > > > done
> > > > only if the session is the default one (only default sessions are
> > > > filled
> > > > with default contexts). Use sensible defaults for all attributes:
> > > >
> > > >     // create a default security context, if needed
> > > >     if (s->is_default_session())
> > > >     {
> > > >         typedef std::pair<std::string, std::string> entry_type;
> > > >         using namespace boost::assign;
> > > >         std::vector<entry_type> entries;
> > > >
> > > >         entries +=
> > > >             entry_type(saga::attributes::context_type,
> > > > "default_advert_db"),
> > > >             entry_type(saga::attributes::context_userid, "SAGA"),
> > > >             entry_type(saga::attributes::context_userpass,
> > > > "SAGA_client")
> > > >         ;
> > > >         s->add_proto_context(entries);
> > > >     }
> > > >
> > > > That's it. All what's left now is in your adaptor to check for
> your
> > > > context
> > > > in the current session when you need the related information:
> > > >
> > > >     std::vector<saga::context> ctxs(s.list_contexts());
> > > >     std::vector<saga::context>::iterator end = ctxs.end();
> > > >     for (std::vector<saga::context>::iterator it = ctxs.begin();
> it
> > > !=
> > > > end;
> > > > ++it)
> > > >     {
> > > >         if
> > ((*it).attribute_exists("saga::attributes::context_type")
> > > &&
> > > >             "default_advert_db" ==
> > > > (*it).get_attribute(saga::attributes::context_type))
> > > >         {
> > > >             ...=
> > > > (*it).get_attribute(saga::attributes::context_userid));
> > > >             ...=
> > > > (*it).get_attribute(saga::attributes::context_userpass));
> > > >             break;
> > > >         }
> > > >     }
> > > >
> > > > Users will have to create a new context using your type, filling
> in
> > > > their
> > > > attributes, and adding this to the sessions object used to create
> > > your
> > > > API
> > > > object:
> > > >
> > > >     saga::context ctx("default_advert_db");
> > > >     ctx.set_attribute(saga::attributes::context_userid, "...");
> > > >     ctx.set_attribute(saga::attributes::context_userpass, "...");
> > > >
> > > >     saga::session s;
> > > >     s.add_context(ctx);
> > > >
> > > >     saga::advert::entry adv(s, ...);
> > > >
> > > > HTH
> > > > Regards Hartmut
> > > >
> > > >
> > > >
> > > > _______________________________________________
> > > > saga-devel mailing list
> > > > saga-devel at cct.lsu.edu
> > > > https://mail.cct.lsu.edu/mailman/listinfo/saga-devel
> > > > --
> > > > Scanned by iCritical.
> > >
> > > _______________________________________________
> > > saga-devel mailing list
> > > saga-devel at cct.lsu.edu
> > > https://mail.cct.lsu.edu/mailman/listinfo/saga-devel
> >
> >
> > --
> >
> > Scanned by iCritical.
> 
> 
> 
> --
> 
> Scanned by iCritical.

-------------- next part --------------
An embedded message was scrubbed...
From: "Ole Weidner" <oweidner at cct.lsu.edu>
Subject: [Saga-devel] saga::context - logical error in specification?
Date: Thu, 11 Sep 2008 14:52:56 -0600
Size: 8449
Url: https://mail.cct.lsu.edu/mailman/private/saga-devel/attachments/20090130/8dabbbb8/attachment-0006.mht
-------------- next part --------------
An embedded message was scrubbed...
From: "Andre Merzky" <andre at merzky.net>
Subject: [Saga-devel] Re: saga::context - logical error in specification?
Date: Thu, 11 Sep 2008 15:53:14 -0600
Size: 13866
Url: https://mail.cct.lsu.edu/mailman/private/saga-devel/attachments/20090130/8dabbbb8/attachment-0007.mht
-------------- next part --------------
An embedded message was scrubbed...
From: "Ole Weidner" <oweidner at cct.lsu.edu>
Subject: [Saga-devel] Re: saga::context - logical error in specification?
Date: Wed, 17 Sep 2008 13:39:09 -0600
Size: 5109
Url: https://mail.cct.lsu.edu/mailman/private/saga-devel/attachments/20090130/8dabbbb8/attachment-0008.mht
-------------- next part --------------
An embedded message was scrubbed...
From: "Andre Merzky" <andre at merzky.net>
Subject: [Saga-devel] Re: saga::context - logical error in specification?
Date: Wed, 17 Sep 2008 20:04:06 -0600
Size: 10690
Url: https://mail.cct.lsu.edu/mailman/private/saga-devel/attachments/20090130/8dabbbb8/attachment-0009.mht
-------------- next part --------------
An embedded message was scrubbed...
From: "Ole Weidner" <oweidner at cct.lsu.edu>
Subject: [Saga-devel] Re: saga::context - logical error in specification?
Date: Wed, 17 Sep 2008 20:12:26 -0600
Size: 12255
Url: https://mail.cct.lsu.edu/mailman/private/saga-devel/attachments/20090130/8dabbbb8/attachment-0010.mht
-------------- next part --------------
An embedded message was scrubbed...
From: "Andre Merzky" <andre at merzky.net>
Subject: [Saga-devel] Re: saga::context - logical error in specification?
Date: Wed, 17 Sep 2008 20:17:09 -0600
Size: 15258
Url: https://mail.cct.lsu.edu/mailman/private/saga-devel/attachments/20090130/8dabbbb8/attachment-0011.mht


More information about the saga-devel mailing list