Archived

This forum has been archived. Please start a new discussion on GitHub.

IceStorm/IceGrid ObjectAdapterID uniqueness management

Hi Ice!

I have an app, A, that receives IceStorm events/callbacks from a particular publisher. We are trying to use the IceGrid location service. Several app A's may be running at once, receiving callbacks from the same publisher. As I understand it, each app A must create an object adapter with a unique AdapterID. For example, each (Java) app must call:
Ice.ObjectAdapter adapter = ic.createObjectAdapter("CallbackAdapter");
This requires me to set in my ice properties something like:
CallbackAdapter.AdapterId=CallbackAdapterN
Where N reflects the Nth app A executing. So I seem to need to manage the assigning of identities to this AdapterID property when in fact I really don't care what these ID's are. Is there a way to just autogenerate an adapter id? Further, I am concerned that Adapter references will accumulate in the IceGrid registry when some app A's do not properly shutdown and de-register. Is there a better mechanism I can use here than just generating a wack of adapter ids?

Thank you in advance :)
Aaron

Comments

  • bernard
    bernard Jupiter, FL
    Hi Aaron,

    Welcome to our forums!

    When you use IceGrid, you typically don't write your Ice configuration files yourself: you describe your servers using XML files or in the IceGrid Admin GUI, and IceGrid generates the corresponding Ice configuration files for you.

    If you have many identical servers, you should describe them using a server template. And if you create an indirect object adapter in a server template and don't specify an ID for it, IceGrid will generate a unique ID in each instance (see http://www.zeroc.com/doc/Ice-3.4.0/manual/IceGrid.39.17.html).

    Before you go ahead and implement this, you should also consider whether these object adapters should be "indirect" (i.e. known to IceGrid) or "direct".

    "direct" makes sense for transient objects - like a subscriber that does not survive a restart of this app. Even when using IceGrid, it's ok to have some direct object adapters!

    "indirect" makes more sense for a persistent subscriber, that survives restarts, and/or if you want IceGrid to start this app on demand , or manage several instances of this app as replicas of each other.

    Best regards,
    Bernard
  • Thank you Bernard,
    I appreciate the quick response :)
    For our use-case, the direct adapter approach probably makes the most sense. These objects are certainly transient. However, one nice thing about using an indirect adapter is that IceGrid will manage your ports for you. We may have several app A's running on a single machine (FYI, they are game servers). Is there a convenience method to acquire an unbound port with which to set up the end point?
    Best regards,
    Aaron
  • mes
    mes California
    Hi Aaron,

    The simplest solution is to let the operating system choose an unassigned port for you. To do this, you just have to omit the port option from your object adapter's endpoint configuration. For example, the endpoint could be as simple as this:

    MyAdapter.Endpoints=tcp

    Each time you create MyAdapter, you're likely to get a different (essentially randomly-assigned) port.

    Regards,
    Mark
  • Thanks a lot guys. This helped!
    Aaron