[Saga-devel] Context question

Hartmut Kaiser hkaiser at cct.lsu.edu
Fri Jan 30 07:21:17 CST 2009


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.




More information about the saga-devel mailing list