locked
Initial states specified in DSS Manifest Editor for two instances of the same service RRS feed

  • Question

  • Here is a simple question about initial service partners of services that have multiple instances.  I have a service for a servo and the state has a minimum position and a maximum position.  I would like to set these values in the serialized state so I can set them within DSS Manifest Editor.  This would be very useful, because the values would vary between different servos and by changing them in DSS Manifest Editor I won't have to change code.  In my implementation I set this up like the following:

    [ServiceState]
    [InitialStatePartner(
        Optional = true,
        ServiceUri = ServicePaths.MountPoint + @"/Samples/config/MyServoService.xml")]
    MyServoState _state = new MyServoState();

    The problem comes about when I need two instances of this service in my application.  I have an orchestration service that partners with two instances of this servo service to control two servos.

    [Partner(
        "MyServoServiceLeft",
        Contract = myservo.Contract.Identifier,
        CreationPolicy = PartnerCreationPolicy.UseExisting)]
    myservo.MyServoOperations _myServoServiceLeftPort =
        new myservo.MyServoOperations();
    myservo.MyServoOperations _myServoServiceLeftNotify =
        new myservo.MyServoOperations();

    [Partner(
        "MyServoServiceRight",
        Contract = myservo.Contract.Identifier,
        CreationPolicy = PartnerCreationPolicy.UseExisting)]
    myservo.MyServoOperations _myServoServiceRightPort =
        new myservo.MyServoOperations();
    myservo.MyServoOperations _myServoServiceLeftNotify =
        new myservo.MyServoOperations();

    When I run DSS Manifest Editor I create two copies of the servo service with different names and a copy of the orchestration service and set up the partnerships.  All that works fine.  The problem comes in when I try to set the initial states of the two servo services and set the min and max positions of their states.  These values are being preserved in the manifest, but are not being imported to the states of the servo services.  I don't even see how that can work because the ServiceUri value in the InitialStatePartner specifies a specific XML file that both instances would have to share and they have different values.

    How can I get the initial state values from the manifest to be imported to the two instances of the same service?

    Thanks,
    Dogulas

    Saturday, August 29, 2009 10:33 PM

Answers

  • If you intend to specify an Initial State partner in the manifest, then there is no point in specifying a config file in the service itself. However, I believe it should still work.

    You might try UsePartnerListEntry as the Creation Policy instead of UseExisting.

    Trevor
    • Marked as answer by Dogulas Wednesday, September 2, 2009 2:35 PM
    Tuesday, September 1, 2009 6:14 AM
  • With UsePartnerListEntry, you must specify explicitly the partnership in a manifest or in a create request. If not specified, the service cannot be created. With UseExisting, if you don't specify explicilty the partnership, DSS searches for any service that implements partner contract on the same dss node and sets it as partner.

    Regards,
    Vincent
    http://www.simplysim.net/
    • Marked as answer by Dogulas Wednesday, September 2, 2009 2:35 PM
    Wednesday, September 2, 2009 6:20 AM

All replies

  • Ok, here is the answer just for completeness for anyone out there that is curious.

    If you wish to have multiple instances of a particular service as a partner to another service and you wish to initialize the state from the manifest files, you must not specify a ServiceUri in the InitialStatePartner attribute.

    My new state definition looks like this:

    [ServiceState]
    [InitialStatePartner(Optional = true)]
    MyServoState _state = new MyServoState();

    It may be the case that you cannot specify a ServiceUri if you want to use the initial state within the manifest, regardless of the number of partners.  I did not test this.  Perhaps someone with experience in this area can comment.

    Hope this helps someone else.

    Thanks,
    Dogulas

    • Marked as answer by Dogulas Monday, August 31, 2009 12:26 PM
    • Unmarked as answer by Dogulas Tuesday, September 1, 2009 4:17 PM
    Sunday, August 30, 2009 4:27 PM
  • If you intend to specify an Initial State partner in the manifest, then there is no point in specifying a config file in the service itself. However, I believe it should still work.

    You might try UsePartnerListEntry as the Creation Policy instead of UseExisting.

    Trevor
    • Marked as answer by Dogulas Wednesday, September 2, 2009 2:35 PM
    Tuesday, September 1, 2009 6:14 AM
  • Thanks for the response Trevor,

    That is the conclusion I came to.  At first I thought it was required, but if anything, it seems to get in the way.

    Thanks for the tip with PartnerCreationPolicy.  I think my confusion sprang from:

    http://msdn.microsoft.com/en-us/library/microsoft.dss.core.attributes.partnercreationpolicy.aspx

    which defines UsePartnerListEntry and UseExisting exactly the same way.  If this is a typo, could you please elaborate on the incorrect definition.  In other words what is the difference between these two and when should you use each of them.

    Thanks,
    Dogulas

    Tuesday, September 1, 2009 4:16 PM
  • With UsePartnerListEntry, you must specify explicitly the partnership in a manifest or in a create request. If not specified, the service cannot be created. With UseExisting, if you don't specify explicilty the partnership, DSS searches for any service that implements partner contract on the same dss node and sets it as partner.

    Regards,
    Vincent
    http://www.simplysim.net/
    • Marked as answer by Dogulas Wednesday, September 2, 2009 2:35 PM
    Wednesday, September 2, 2009 6:20 AM
  • Vincent,

    Thanks for your response.

    That clears things up and it makes sense in my case.

    Dogulas

    Wednesday, September 2, 2009 2:34 PM