IceGrid Replication

b33fc0d3b33fc0d3 Member Ahmed AmmarOrganization: Edge-Technology.comProject: PoC

I am trying to use IceGrid with replication and ordering on the replicated servers but I'm hitting an issue. I have defined the application as follows (based on the simple IceGrid demo):


  <application name="Simple">

    <server-template id="SimpleServer">
      <parameter name="index"/>
      <parameter name="priority"/>
      <server id="SimpleServer-${index}" exe="./server" activation="always">
        <adapter name="Hello" endpoints="tcp" replica-group="ReplicatedHelloAdapter" priority="${priority}"/>
				<property name="Identity" value="Hello"/>
				<!-- <property name="IceGrid.Node.WaitTime" value="1"/> -->
				<!-- <property name="Ice.Admin.DelayCreation" value="1"/> -->
		<replica-group id="ReplicatedHelloAdapter">
      <load-balancing type="ordered" n-replicas="1"/>
      <object identity="Hello" type="::Demo::Hello"/>

    <node name="Node1">
      <server-instance template="SimpleServer" index="1" priority="2"/>
    <node name="Node2">
      <server-instance template="SimpleServer" index="2" priority="1"/>


Now I've also disabled connection caching on the client but if Node2 becomes Inactive (and the client starts using Node1) then comes back and becomes Active I expect the client to start using Node2 again is it has a higher priority but it does not. It will revert back to Node2 in two cases, either I restart the client or I restart Node1. Is this expected behaviour?

Here is client code:

main(int argc, char* argv[])
    if(argc != 2)
        cerr << "please supply config file using --Ice.Config=$config" << endl;
        return EXIT_FAILURE;


    char c;
		Ice::CommunicatorPtr ic = Ice::initialize(argc, argv);
    				HelloPrx hello;
        		//IceGrid::QueryPrx query = IceGrid::QueryPrx::checkedCast(ic->stringToProxy("DemoIceGrid/Query"));
        		//hello = HelloPrx::checkedCast(query->findObjectByType("::Demo::Hello")->ice_connectionCached(false));
						//HelloPrx hello_nc = hello->ice_connectionCached(false);
        		hello = HelloPrx::checkedCast(ic->stringToProxy("[email protected]")->ice_connectionCached(false));
						cout << ic->proxyToString(hello) << endl;
					  //ic = Ice::initialize(argc, argv);	
						//Ice::EndpointSeq endpoints = hello->ice_getEndpoints();
						//for (unsigned int i=0; i<endpoints.size(); i++){
						//	cout << "Endpoint: " << endpoints[i]->toString() << endl;
						//cout << "Count: " << endpoints.size() << endl;
            cout << "==> ";
            cin >> c;
            if(c == 't')
            else if(c == 's')
            else if(c == 'x')
                // Nothing to do
            else if(c == '?')
                cout << "unknown command `" << c << "'" << endl;
        catch(const Ice::Exception& ex)
            cerr << ex << endl;
				//ic = Ice::initialize(argc, argv, "config.client");
				//hello = HelloPrx::checkedCast(seq[index&0x1]);
				//Ice::ConnectionPtr conn = hello->ice_getConnection();
    while(cin.good() && c != 'x');

    return EXIT_SUCCESS;


  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff

    You also need to configure the proxy with ice_locatorCacheTimeout in order for the client to contact from time to time the IceGrid registry and eventually get the new endpoints for the server hosted on node2 (once it's restarted).

    Without this, the client caches the endpoints for the server running on node1 as long as these endpoints work, it will continue to use them.

    See the Ice manual for more information on this method.

  • b33fc0d3b33fc0d3 Member Ahmed AmmarOrganization: Edge-Technology.comProject: PoC


    Thank you for the quick response and indeed you were correct and that sorted my issue. I knew I was missing something, I think the Manual should mention this in the section where Ordered replication is covered.

    Thanks again,
Sign In or Register to comment.