Archived

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

Start new server process using factory design pattern

Hi,

What Ice artefacts can we use in IceGrid environment to start a new server process instantiating from some Server Template using factory method design pattern.


Following is the basic factory method interface:
module Demo
{
         interface MyServerFactory
         {
                MyServer *
                create();
         };

          interface MyServer
          {
                 void 
                 doSomething (string someParams);
          };
}

And using above interface as follows:
Ice::ObjectPrx obj =
    communicator‑>stringToProxy("MyServerFactory");
Demo::MyServerFactoryPrx factory =
    Demo::MyServerFactoryPrx::checkedCast(obj);
Demo::MyServerPrx server = factory‑>create();

My question is, how shall I code, create() function in MyServerFactory such that, it starts a new server process using some well known server template on my grid and returns its proxy? Ideally, I would like to start this server instance anywhere on the grid (any node registered with registry).

My basic understanding of factory methods as described in the IceGrid chapter is that, it creates a new worker object in the same process and registers well known object with the registry. But, since I need to make my application fail-safe, I need to start new server from factory as separate process.

Could IceGrid::Admin interface be the solution?

Any ideas?

Thanks.

Surya

Comments

  • benoit
    benoit Rennes, France
    Hi Surya,

    There's several ways to tackle this depending on your requirements. Could you detail why you need this create method?

    If all the servers are already deployed on the IceGrid nodes, why not simply lookup for a server with the registry (i.e.: lookup a Demo::MyServer well-known object)?

    Cheers,
    Benoit.
  • Hi Benoit,

    I need create method to instantiate a specific messaging task administrator/coordinator server [administrator server]. Since, there could be many administrator server on the grid, I want each of them to be a independent process. Where, each administrator server uses many other replicated utility servers. I expose these administrator server to the external world, hence I want to keep these processes isolated, just in case if due to some bad data, one of the administrator server breaks, it shall not mess the other administrator server.

    Moreover, I want to keep each administrator server data structure separate, otherwise, it becomes very complex for managing shared data for multiple administrator server (thread-safe would slow down things and complicates simple operations)

    I hope, I am not so abstract in defining my problem and need to use create method.

    And since, I want to create new administrator server on demand, I cannot start fixed number of instances on each node and use well-known object to connect to them, since number of these server demand could be more than number of nodes and this number is unpredictable. Though, I would like to limit number of such servers into overall grid.

    I believe, using IceGrid::Admin interface would be the optimal solution to start new server instantiating from server template. What you say? Any other simpler interface or do I need to change the way I see my problem?

    Thanks.

    Surya
  • benoit
    benoit Rennes, France
    Hi,

    You could indeed use the IceGrid::Admin interface to instantiate and deploy a new server instance on a given node. You can find the list of nodes known by the registry with the getAllNodeNames method and instantiate a new server on a given node with the instantiateServer method (provided an application and template name).

    In the server template you could configure a well-known object that allows you to easily create a server proxy object based on some information provided to the instantiateServer method.

    You'll also probably need a mechanism to cleanup stale servers.

    Cheers,
    Benoit.